From 6501e90018ab1d58047e5b4382c6bc6d04051191 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 22 Aug 2024 10:30:45 -0700 Subject: [PATCH] Use C++ style comments consistently in SDL source code Implemented using this script: find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \; git checkout \ core/linux/SDL_evdev_kbd_default_keymap.h \ events/imKStoUCS.* \ hidapi \ joystick/controller_type.c \ joystick/controller_type.h \ joystick/hidapi/steam/controller_constants.h \ joystick/hidapi/steam/controller_structs.h \ joystick/SDL_gamepad_db.h \ libm \ render/*/*Shader*.h \ render/vitagxm/SDL_render_vita_gxm_shaders.h \ render/metal/SDL_shaders_metal_*.h \ stdlib/SDL_malloc.c \ stdlib/SDL_qsort.c \ stdlib/SDL_strtokr.c \ test/ \ video/directx/SDL_d3d12_xbox_cmacros.h \ video/directx/d3d12.h \ video/directx/d3d12sdklayers.h \ video/khronos \ video/x11/edid-parse.c \ video/x11/xsettings-client.* \ video/yuv2rgb sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c --- src/SDL.c | 88 +- src/SDL_assert.c | 64 +- src/SDL_assert_c.h | 2 +- src/SDL_error.c | 6 +- src/SDL_error_c.h | 4 +- src/SDL_guid.c | 14 +- src/SDL_hashtable.h | 4 +- src/SDL_hints_c.h | 4 +- src/SDL_internal.h | 28 +- src/SDL_list.c | 6 +- src/SDL_list.h | 2 +- src/SDL_log.c | 70 +- src/SDL_log_c.h | 4 +- src/SDL_properties.c | 4 +- src/SDL_utils.c | 26 +- src/SDL_utils_c.h | 6 +- src/atomic/SDL_atomic.c | 18 +- src/atomic/SDL_spinlock.c | 24 +- src/audio/SDL_audio.c | 2 +- src/audio/SDL_audio_c.h | 2 +- src/audio/SDL_audio_channel_converters.h | 2 +- src/audio/SDL_wave.c | 246 ++--- src/audio/SDL_wave.h | 70 +- src/audio/coreaudio/SDL_coreaudio.m | 2 +- src/audio/emscripten/SDL_emscriptenaudio.c | 4 +- src/audio/netbsd/SDL_netbsdaudio.c | 4 +- src/audio/wasapi/SDL_wasapi.c | 2 +- src/camera/emscripten/SDL_camera_emscripten.c | 4 +- .../SDL_camera_mediafoundation.c | 8 +- src/core/SDL_core_unsupported.c | 10 +- src/core/android/SDL_android.c | 282 ++--- src/core/android/SDL_android.h | 42 +- .../freebsd/SDL_evdev_kbd_default_keyaccmap.h | 50 +- src/core/freebsd/SDL_evdev_kbd_freebsd.c | 88 +- src/core/gdk/SDL_gdk.cpp | 16 +- src/core/gdk/SDL_gdk.h | 2 +- src/core/haiku/SDL_BApp.h | 62 +- src/core/haiku/SDL_BeApp.cc | 34 +- src/core/haiku/SDL_BeApp.h | 8 +- src/core/linux/SDL_dbus.c | 50 +- src/core/linux/SDL_dbus.h | 8 +- src/core/linux/SDL_evdev.c | 82 +- src/core/linux/SDL_evdev.h | 4 +- src/core/linux/SDL_evdev_capabilities.c | 32 +- src/core/linux/SDL_evdev_capabilities.h | 6 +- src/core/linux/SDL_evdev_kbd.c | 72 +- src/core/linux/SDL_evdev_kbd.h | 2 +- src/core/linux/SDL_fcitx.c | 28 +- src/core/linux/SDL_fcitx.h | 2 +- src/core/linux/SDL_ibus.c | 34 +- src/core/linux/SDL_ibus.h | 8 +- src/core/linux/SDL_ime.c | 10 +- src/core/linux/SDL_ime.h | 2 +- src/core/linux/SDL_sandbox.h | 4 +- src/core/linux/SDL_system_theme.c | 4 +- src/core/linux/SDL_system_theme.h | 2 +- src/core/linux/SDL_threadprio.c | 28 +- src/core/linux/SDL_udev.c | 24 +- src/core/linux/SDL_udev.h | 6 +- src/core/openbsd/SDL_wscons_kbd.c | 78 +- src/core/openbsd/SDL_wscons_mouse.c | 12 +- src/core/unix/SDL_appid.c | 6 +- src/core/unix/SDL_appid.h | 2 +- src/core/unix/SDL_poll.c | 8 +- src/core/unix/SDL_poll.h | 2 +- src/core/windows/SDL_directx.h | 16 +- src/core/windows/SDL_hid.c | 8 +- src/core/windows/SDL_hid.h | 4 +- src/core/windows/SDL_immdevice.c | 28 +- src/core/windows/SDL_immdevice.h | 2 +- src/core/windows/SDL_windows.c | 48 +- src/core/windows/SDL_windows.h | 52 +- src/core/windows/SDL_xinput.c | 22 +- src/core/windows/SDL_xinput.h | 48 +- src/core/winrt/SDL_winrtapp_common.cpp | 2 +- src/core/winrt/SDL_winrtapp_direct3d.cpp | 10 +- src/core/winrt/SDL_winrtapp_xaml.cpp | 6 +- src/cpuinfo/SDL_cpuinfo.c | 78 +- src/cpuinfo/SDL_cpuinfo_c.h | 2 +- src/dialog/SDL_dialog_utils.c | 12 +- src/dialog/SDL_dialog_utils.h | 14 +- src/dialog/android/SDL_androiddialog.c | 4 +- src/dialog/cocoa/SDL_cocoadialog.m | 4 +- src/dialog/unix/SDL_portaldialog.c | 30 +- src/dialog/unix/SDL_unixdialog.c | 14 +- src/dialog/unix/SDL_zenitydialog.c | 18 +- src/dialog/windows/SDL_windowsdialog.c | 24 +- src/dynapi/SDL_dynapi.c | 70 +- src/dynapi/SDL_dynapi.h | 24 +- src/dynapi/SDL_dynapi.sym | 2 +- src/dynapi/SDL_dynapi_overrides.h | 4 +- src/dynapi/SDL_dynapi_procs.h | 4 +- src/dynapi/gendynapi.py | 2 +- src/events/SDL_categories.c | 6 +- src/events/SDL_categories_c.h | 2 +- src/events/SDL_clipboardevents.c | 4 +- src/events/SDL_clipboardevents_c.h | 2 +- src/events/SDL_displayevents.c | 4 +- src/events/SDL_displayevents_c.h | 2 +- src/events/SDL_dropevents.c | 6 +- src/events/SDL_dropevents_c.h | 2 +- src/events/SDL_events.c | 136 +-- src/events/SDL_events_c.h | 6 +- src/events/SDL_keyboard.c | 54 +- src/events/SDL_keyboard_c.h | 34 +- src/events/SDL_keymap.c | 4 +- src/events/SDL_keymap_c.h | 2 +- src/events/SDL_keysym_to_scancode.c | 674 ++++++------ src/events/SDL_keysym_to_scancode_c.h | 4 +- src/events/SDL_mouse.c | 126 +-- src/events/SDL_mouse_c.h | 78 +- src/events/SDL_pen.c | 2 +- src/events/SDL_pen_c.h | 4 +- src/events/SDL_quit.c | 20 +- src/events/SDL_scancode_tables.c | 2 +- src/events/SDL_touch.c | 36 +- src/events/SDL_touch_c.h | 18 +- src/events/SDL_windowevents.c | 10 +- src/events/SDL_windowevents_c.h | 2 +- src/events/default_cursor.h | 4 +- src/events/scancodes_darwin.h | 48 +- src/events/scancodes_linux.h | 992 +++++++++--------- src/events/scancodes_windows.h | 10 +- src/events/scancodes_xfree86.h | 528 +++++----- src/file/SDL_iostream.c | 66 +- src/file/n3ds/SDL_iostreamromfs.c | 8 +- src/file/n3ds/SDL_iostreamromfs.h | 2 +- src/filesystem/SDL_filesystem.c | 2 +- src/filesystem/android/SDL_sysfilesystem.c | 6 +- src/filesystem/cocoa/SDL_sysfilesystem.m | 12 +- src/filesystem/dummy/SDL_sysfilesystem.c | 4 +- src/filesystem/dummy/SDL_sysfsops.c | 2 +- src/filesystem/emscripten/SDL_sysfilesystem.c | 4 +- src/filesystem/gdk/SDL_sysfilesystem.cpp | 22 +- src/filesystem/haiku/SDL_sysfilesystem.cc | 10 +- src/filesystem/n3ds/SDL_sysfilesystem.c | 6 +- src/filesystem/posix/SDL_sysfsops.c | 4 +- src/filesystem/ps2/SDL_sysfilesystem.c | 8 +- src/filesystem/psp/SDL_sysfilesystem.c | 6 +- src/filesystem/riscos/SDL_sysfilesystem.c | 12 +- src/filesystem/unix/SDL_sysfilesystem.c | 52 +- src/filesystem/vita/SDL_sysfilesystem.c | 6 +- src/filesystem/windows/SDL_sysfilesystem.c | 26 +- src/filesystem/windows/SDL_sysfsops.c | 2 +- src/filesystem/winrt/SDL_sysfilesystem.cpp | 8 +- src/haptic/SDL_haptic.c | 70 +- src/haptic/SDL_haptic_c.h | 2 +- src/haptic/SDL_syshaptic.h | 36 +- src/haptic/android/SDL_syshaptic.c | 8 +- src/haptic/android/SDL_syshaptic_c.h | 2 +- src/haptic/darwin/SDL_syshaptic.c | 216 ++-- src/haptic/darwin/SDL_syshaptic_c.h | 2 +- src/haptic/dummy/SDL_syshaptic.c | 2 +- src/haptic/linux/SDL_syshaptic.c | 206 ++-- src/haptic/windows/SDL_dinputhaptic.c | 224 ++-- src/haptic/windows/SDL_dinputhaptic_c.h | 4 +- src/haptic/windows/SDL_windowshaptic.c | 30 +- src/haptic/windows/SDL_windowshaptic_c.h | 10 +- src/hidapi/SDL_hidapi.c | 158 +-- src/joystick/SDL_gamepad.c | 200 ++-- src/joystick/SDL_gamepad_c.h | 14 +- src/joystick/SDL_joystick.c | 580 +++++----- src/joystick/SDL_joystick_c.h | 86 +- src/joystick/SDL_steam_virtual_gamepad.c | 2 +- src/joystick/SDL_sysjoystick.h | 110 +- src/joystick/android/SDL_sysjoystick.c | 42 +- src/joystick/android/SDL_sysjoystick_c.h | 10 +- src/joystick/apple/SDL_mfijoystick.m | 142 +-- src/joystick/apple/SDL_mfijoystick_c.h | 2 +- src/joystick/bsd/SDL_bsdjoystick.c | 54 +- src/joystick/controller_list.h | 2 +- src/joystick/darwin/SDL_iokitjoystick.c | 82 +- src/joystick/darwin/SDL_iokitjoystick_c.h | 38 +- src/joystick/dummy/SDL_sysjoystick.c | 4 +- src/joystick/emscripten/SDL_sysjoystick.c | 30 +- src/joystick/emscripten/SDL_sysjoystick_c.h | 4 +- src/joystick/gdk/SDL_gameinputjoystick.c | 70 +- src/joystick/haiku/SDL_haikujoystick.cc | 42 +- src/joystick/hidapi/SDL_hidapi_combined.c | 10 +- src/joystick/hidapi/SDL_hidapi_gamecube.c | 112 +- src/joystick/hidapi/SDL_hidapi_luna.c | 28 +- src/joystick/hidapi/SDL_hidapi_nintendo.h | 6 +- src/joystick/hidapi/SDL_hidapi_ps3.c | 260 ++--- src/joystick/hidapi/SDL_hidapi_ps4.c | 118 +-- src/joystick/hidapi/SDL_hidapi_ps5.c | 324 +++--- src/joystick/hidapi/SDL_hidapi_rumble.c | 12 +- src/joystick/hidapi/SDL_hidapi_rumble.h | 8 +- src/joystick/hidapi/SDL_hidapi_shield.c | 42 +- src/joystick/hidapi/SDL_hidapi_stadia.c | 16 +- src/joystick/hidapi/SDL_hidapi_steam.c | 44 +- src/joystick/hidapi/SDL_hidapi_steamdeck.c | 6 +- src/joystick/hidapi/SDL_hidapi_switch.c | 204 ++-- src/joystick/hidapi/SDL_hidapi_wii.c | 156 +-- src/joystick/hidapi/SDL_hidapi_xbox360.c | 26 +- src/joystick/hidapi/SDL_hidapi_xbox360w.c | 20 +- src/joystick/hidapi/SDL_hidapi_xboxone.c | 130 +-- src/joystick/hidapi/SDL_hidapijoystick.c | 188 ++-- src/joystick/hidapi/SDL_hidapijoystick_c.h | 36 +- src/joystick/linux/SDL_sysjoystick.c | 240 ++--- src/joystick/linux/SDL_sysjoystick_c.h | 26 +- src/joystick/n3ds/SDL_sysjoystick.c | 8 +- src/joystick/ps2/SDL_sysjoystick.c | 54 +- src/joystick/psp/SDL_sysjoystick.c | 46 +- src/joystick/steam/SDL_steamcontroller.h | 2 +- src/joystick/usb_ids.h | 18 +- src/joystick/virtual/SDL_virtualjoystick.c | 18 +- src/joystick/virtual/SDL_virtualjoystick_c.h | 4 +- src/joystick/vita/SDL_sysjoystick.c | 42 +- src/joystick/windows/SDL_dinputjoystick.c | 102 +- src/joystick/windows/SDL_dinputjoystick_c.h | 4 +- src/joystick/windows/SDL_rawinputjoystick.c | 182 ++-- src/joystick/windows/SDL_rawinputjoystick_c.h | 6 +- .../windows/SDL_windows_gaming_input.c | 60 +- src/joystick/windows/SDL_windowsjoystick.c | 72 +- src/joystick/windows/SDL_windowsjoystick_c.h | 22 +- src/joystick/windows/SDL_xinputjoystick.c | 34 +- src/joystick/windows/SDL_xinputjoystick_c.h | 4 +- src/loadso/dlopen/SDL_sysloadso.c | 6 +- src/loadso/dummy/SDL_sysloadso.c | 6 +- src/loadso/windows/SDL_sysloadso.c | 6 +- src/locale/SDL_locale.c | 18 +- src/locale/SDL_syslocale.h | 2 +- src/locale/dummy/SDL_syslocale.c | 2 +- src/locale/emscripten/SDL_syslocale.c | 14 +- src/locale/n3ds/SDL_syslocale.c | 4 +- src/locale/unix/SDL_syslocale.c | 16 +- src/locale/windows/SDL_syslocale.c | 20 +- src/locale/winrt/SDL_syslocale.c | 8 +- src/main/SDL_runapp.c | 2 +- src/main/gdk/SDL_sysmain_runapp.cpp | 16 +- src/main/n3ds/SDL_sysmain_runapp.c | 6 +- src/main/ngage/SDL_sysmain_runapp.cpp | 16 +- src/main/ps2/SDL_sysmain_runapp.c | 4 +- src/main/psp/SDL_sysmain_runapp.c | 4 +- src/main/windows/SDL_sysmain_runapp.c | 12 +- src/misc/ios/SDL_sysurl.m | 2 +- src/misc/macos/SDL_sysurl.m | 2 +- src/misc/unix/SDL_sysurl.c | 20 +- src/misc/windows/SDL_sysurl.c | 8 +- src/power/SDL_power.c | 28 +- src/power/SDL_syspower.h | 8 +- src/power/android/SDL_syspower.c | 4 +- src/power/emscripten/SDL_syspower.c | 4 +- src/power/haiku/SDL_syspower.c | 36 +- src/power/linux/SDL_syspower.c | 132 +-- src/power/macos/SDL_syspower.c | 26 +- src/power/n3ds/SDL_syspower.c | 4 +- src/power/psp/SDL_syspower.c | 6 +- src/power/uikit/SDL_syspower.h | 2 +- src/power/uikit/SDL_syspower.m | 18 +- src/power/vita/SDL_syspower.c | 6 +- src/power/windows/SDL_syspower.c | 26 +- src/power/winrt/SDL_syspower.cpp | 6 +- src/render/SDL_d3dmath.c | 4 +- src/render/SDL_d3dmath.h | 8 +- src/render/SDL_render.c | 294 +++--- src/render/SDL_sysrender.h | 50 +- src/render/SDL_yuv_sw.c | 30 +- src/render/SDL_yuv_sw_c.h | 8 +- src/render/direct3d/SDL_render_d3d.c | 94 +- src/render/direct3d/SDL_shaders_d3d.c | 4 +- src/render/direct3d/SDL_shaders_d3d.h | 2 +- src/render/direct3d11/SDL_render_d3d11.c | 220 ++-- src/render/direct3d11/SDL_render_winrt.cpp | 8 +- src/render/direct3d11/SDL_render_winrt.h | 2 +- src/render/direct3d11/SDL_shaders_d3d11.c | 10 +- src/render/direct3d11/SDL_shaders_d3d11.h | 2 +- src/render/direct3d12/SDL_render_d3d12.c | 290 ++--- .../direct3d12/SDL_render_d3d12_xbox.cpp | 2 +- src/render/direct3d12/SDL_render_d3d12_xbox.h | 4 +- src/render/direct3d12/SDL_shaders_d3d12.c | 4 +- src/render/direct3d12/SDL_shaders_d3d12.h | 6 +- .../direct3d12/SDL_shaders_d3d12_xboxone.cpp | 6 +- .../SDL_shaders_d3d12_xboxseries.cpp | 6 +- src/render/metal/SDL_render_metal.m | 74 +- src/render/opengl/SDL_render_gl.c | 138 +-- src/render/opengl/SDL_shaders_gl.c | 82 +- src/render/opengl/SDL_shaders_gl.h | 4 +- src/render/opengles2/SDL_render_gles2.c | 178 ++-- src/render/opengles2/SDL_shaders_gles2.c | 20 +- src/render/opengles2/SDL_shaders_gles2.h | 6 +- src/render/ps2/SDL_render_ps2.c | 50 +- src/render/psp/SDL_render_psp.c | 36 +- src/render/software/SDL_blendfillrect.c | 16 +- src/render/software/SDL_blendfillrect.h | 2 +- src/render/software/SDL_blendline.c | 14 +- src/render/software/SDL_blendline.h | 2 +- src/render/software/SDL_blendpoint.c | 12 +- src/render/software/SDL_blendpoint.h | 2 +- src/render/software/SDL_draw.h | 10 +- src/render/software/SDL_drawline.c | 12 +- src/render/software/SDL_drawline.h | 2 +- src/render/software/SDL_drawpoint.c | 8 +- src/render/software/SDL_drawpoint.h | 2 +- src/render/software/SDL_render_sw.c | 68 +- src/render/software/SDL_render_sw_c.h | 2 +- src/render/software/SDL_rotate.c | 52 +- src/render/software/SDL_rotate.h | 2 +- src/render/software/SDL_triangle.c | 76 +- src/render/software/SDL_triangle.h | 2 +- src/render/vitagxm/SDL_render_vita_gxm.c | 24 +- .../vitagxm/SDL_render_vita_gxm_memory.c | 2 +- .../vitagxm/SDL_render_vita_gxm_memory.h | 2 +- .../vitagxm/SDL_render_vita_gxm_tools.c | 20 +- .../vitagxm/SDL_render_vita_gxm_tools.h | 2 +- .../vitagxm/SDL_render_vita_gxm_types.h | 2 +- src/render/vulkan/SDL_render_vulkan.c | 240 ++--- src/render/vulkan/SDL_shaders_vulkan.c | 4 +- src/render/vulkan/SDL_shaders_vulkan.h | 6 +- src/render/vulkan/VULKAN_VertexShader.hlsl | 2 +- src/render/vulkan/compile_shaders.bat | 8 +- src/sensor/SDL_sensor.c | 32 +- src/sensor/SDL_sensor_c.h | 18 +- src/sensor/SDL_syssensor.h | 40 +- src/sensor/android/SDL_androidsensor.c | 14 +- src/sensor/coremotion/SDL_coremotionsensor.h | 2 +- src/sensor/coremotion/SDL_coremotionsensor.m | 4 +- src/sensor/dummy/SDL_dummysensor.c | 2 +- src/sensor/n3ds/SDL_n3dssensor.c | 4 +- src/sensor/vita/SDL_vitasensor.c | 2 +- src/sensor/vita/SDL_vitasensor.h | 2 +- src/sensor/windows/SDL_windowssensor.c | 12 +- src/stdlib/SDL_casefolding.h | 2 +- src/stdlib/SDL_crc16.c | 2 +- src/stdlib/SDL_crc32.c | 2 +- src/stdlib/SDL_getenv.c | 58 +- src/stdlib/SDL_iconv.c | 58 +- src/stdlib/SDL_memcpy.c | 10 +- src/stdlib/SDL_memmove.c | 10 +- src/stdlib/SDL_memset.c | 12 +- src/stdlib/SDL_mslibc.c | 14 +- src/stdlib/SDL_random.c | 2 +- src/stdlib/SDL_stdlib.c | 14 +- src/stdlib/SDL_string.c | 134 +-- src/stdlib/SDL_vacopy.h | 4 +- src/storage/SDL_storage.c | 8 +- src/storage/SDL_sysstorage.h | 6 +- src/storage/generic/SDL_genericstorage.c | 28 +- src/storage/steam/SDL_steamstorage.c | 12 +- src/thread/SDL_systhread.h | 24 +- src/thread/SDL_thread.c | 42 +- src/thread/SDL_thread_c.h | 16 +- src/thread/generic/SDL_syscond.c | 22 +- src/thread/generic/SDL_syscond_c.h | 4 +- src/thread/generic/SDL_sysmutex.c | 4 +- src/thread/generic/SDL_syssem.c | 6 +- src/thread/generic/SDL_systhread.c | 2 +- src/thread/generic/SDL_systhread_c.h | 2 +- src/thread/n3ds/SDL_syscond.c | 12 +- src/thread/n3ds/SDL_sysmutex_c.h | 2 +- src/thread/n3ds/SDL_syssem.c | 8 +- src/thread/n3ds/SDL_systhread.c | 8 +- src/thread/n3ds/SDL_systhread_c.h | 2 +- src/thread/ngage/SDL_sysmutex.cpp | 16 +- src/thread/ngage/SDL_syssem.cpp | 4 +- src/thread/ngage/SDL_systhread.cpp | 4 +- src/thread/ps2/SDL_syssem.c | 12 +- src/thread/ps2/SDL_systhread.c | 12 +- src/thread/psp/SDL_syssem.c | 14 +- src/thread/psp/SDL_systhread.c | 10 +- src/thread/pthread/SDL_syscond.c | 10 +- src/thread/pthread/SDL_sysmutex_c.h | 2 +- src/thread/pthread/SDL_sysrwlock.c | 2 +- src/thread/pthread/SDL_syssem.c | 20 +- src/thread/pthread/SDL_systhread.c | 36 +- src/thread/stdcpp/SDL_syscond.cpp | 10 +- src/thread/stdcpp/SDL_sysmutex.cpp | 2 +- src/thread/stdcpp/SDL_systhread.cpp | 4 +- src/thread/stdcpp/SDL_systhread_c.h | 2 +- src/thread/vita/SDL_syssem.c | 14 +- src/thread/vita/SDL_systhread.c | 10 +- src/thread/windows/SDL_syscond_cv.c | 20 +- src/thread/windows/SDL_sysmutex.c | 6 +- src/thread/windows/SDL_sysmutex_c.h | 4 +- src/thread/windows/SDL_sysrwlock_srw.c | 18 +- src/thread/windows/SDL_syssem.c | 38 +- src/thread/windows/SDL_systhread.c | 22 +- src/thread/windows/SDL_systhread_c.h | 2 +- src/thread/windows/SDL_systls.c | 2 +- src/time/SDL_time.c | 12 +- src/time/SDL_time_c.h | 2 +- src/time/n3ds/SDL_systime.c | 34 +- src/time/ps2/SDL_systime.c | 6 +- src/time/psp/SDL_systime.c | 6 +- src/time/unix/SDL_systime.c | 8 +- src/time/vita/SDL_systime.c | 6 +- src/time/windows/SDL_systime.c | 10 +- src/timer/SDL_timer.c | 60 +- src/timer/SDL_timer_c.h | 4 +- src/timer/haiku/SDL_systimer.c | 2 +- src/timer/n3ds/SDL_systimer.c | 2 +- src/timer/ngage/SDL_systimer.cpp | 4 +- src/timer/ps2/SDL_systimer.c | 2 +- src/timer/psp/SDL_systimer.c | 2 +- src/timer/unix/SDL_systimer.c | 14 +- src/timer/vita/SDL_systimer.c | 2 +- src/timer/windows/SDL_systimer.c | 8 +- src/video/SDL_RLEaccel.c | 152 +-- src/video/SDL_RLEaccel_c.h | 4 +- src/video/SDL_blit.c | 46 +- src/video/SDL_blit.h | 56 +- src/video/SDL_blit_0.c | 24 +- src/video/SDL_blit_1.c | 90 +- src/video/SDL_blit_A.c | 296 +++--- src/video/SDL_blit_N.c | 444 ++++---- src/video/SDL_blit_auto.c | 8 +- src/video/SDL_blit_auto.h | 8 +- src/video/SDL_blit_copy.c | 6 +- src/video/SDL_blit_copy.h | 2 +- src/video/SDL_blit_slow.c | 56 +- src/video/SDL_blit_slow.h | 2 +- src/video/SDL_bmp.c | 162 +-- src/video/SDL_clipboard.c | 14 +- src/video/SDL_clipboard_c.h | 10 +- src/video/SDL_egl.c | 120 +-- src/video/SDL_egl_c.h | 24 +- src/video/SDL_fillrect.c | 22 +- src/video/SDL_pixels.c | 130 +-- src/video/SDL_pixels_c.h | 12 +- src/video/SDL_rect.c | 8 +- src/video/SDL_rect_c.h | 2 +- src/video/SDL_rect_impl.h | 58 +- src/video/SDL_stretch.c | 96 +- src/video/SDL_surface.c | 230 ++-- src/video/SDL_surface_c.h | 10 +- src/video/SDL_sysvideo.h | 64 +- src/video/SDL_video.c | 374 +++---- src/video/SDL_video_c.h | 2 +- src/video/SDL_video_unsupported.c | 4 +- src/video/SDL_vulkan_internal.h | 8 +- src/video/SDL_vulkan_utils.c | 36 +- src/video/SDL_yuv.c | 148 +-- src/video/SDL_yuv_c.h | 4 +- src/video/android/SDL_androidclipboard.c | 2 +- src/video/android/SDL_androidclipboard.h | 2 +- src/video/android/SDL_androidevents.c | 18 +- src/video/android/SDL_androidgl.c | 4 +- src/video/android/SDL_androidgl.h | 2 +- src/video/android/SDL_androidkeyboard.c | 562 +++++----- src/video/android/SDL_androidmessagebox.c | 2 +- src/video/android/SDL_androidmessagebox.h | 2 +- src/video/android/SDL_androidmouse.c | 12 +- src/video/android/SDL_androidmouse.h | 2 +- src/video/android/SDL_androidtouch.c | 10 +- src/video/android/SDL_androidvideo.c | 36 +- src/video/android/SDL_androidvideo.h | 6 +- src/video/android/SDL_androidvulkan.c | 2 +- src/video/android/SDL_androidvulkan.h | 2 +- src/video/android/SDL_androidwindow.c | 14 +- src/video/android/SDL_androidwindow.h | 6 +- src/video/cocoa/SDL_cocoaclipboard.h | 4 +- src/video/cocoa/SDL_cocoaclipboard.m | 4 +- src/video/cocoa/SDL_cocoaevents.h | 2 +- src/video/cocoa/SDL_cocoaevents.m | 40 +- src/video/cocoa/SDL_cocoakeyboard.h | 2 +- src/video/cocoa/SDL_cocoakeyboard.m | 34 +- src/video/cocoa/SDL_cocoamessagebox.h | 2 +- src/video/cocoa/SDL_cocoamessagebox.m | 6 +- src/video/cocoa/SDL_cocoametalview.h | 6 +- src/video/cocoa/SDL_cocoametalview.m | 10 +- src/video/cocoa/SDL_cocoamodes.h | 2 +- src/video/cocoa/SDL_cocoamodes.m | 38 +- src/video/cocoa/SDL_cocoamouse.h | 8 +- src/video/cocoa/SDL_cocoamouse.m | 26 +- src/video/cocoa/SDL_cocoaopengl.h | 8 +- src/video/cocoa/SDL_cocoaopengl.m | 50 +- src/video/cocoa/SDL_cocoaopengles.h | 6 +- src/video/cocoa/SDL_cocoaopengles.m | 16 +- src/video/cocoa/SDL_cocoapen.h | 2 +- src/video/cocoa/SDL_cocoapen.m | 2 +- src/video/cocoa/SDL_cocoashape.h | 2 +- src/video/cocoa/SDL_cocoashape.m | 2 +- src/video/cocoa/SDL_cocoavideo.h | 10 +- src/video/cocoa/SDL_cocoavideo.m | 22 +- src/video/cocoa/SDL_cocoavulkan.h | 2 +- src/video/cocoa/SDL_cocoavulkan.m | 8 +- src/video/cocoa/SDL_cocoawindow.h | 12 +- src/video/cocoa/SDL_cocoawindow.m | 246 ++--- src/video/directx/SDL_d3d12.h | 18 +- src/video/directx/gen_xbox_cmacros.cs | 2 +- src/video/dummy/SDL_nullevents.c | 4 +- src/video/dummy/SDL_nullevents_c.h | 2 +- src/video/dummy/SDL_nullframebuffer.c | 8 +- src/video/dummy/SDL_nullframebuffer_c.h | 2 +- src/video/dummy/SDL_nullvideo.c | 20 +- src/video/dummy/SDL_nullvideo.h | 2 +- src/video/emscripten/SDL_emscriptenevents.c | 50 +- src/video/emscripten/SDL_emscriptenevents.h | 2 +- .../emscripten/SDL_emscriptenframebuffer.c | 16 +- .../emscripten/SDL_emscriptenframebuffer.h | 2 +- src/video/emscripten/SDL_emscriptenmouse.c | 18 +- src/video/emscripten/SDL_emscriptenmouse.h | 2 +- src/video/emscripten/SDL_emscriptenopengles.c | 10 +- src/video/emscripten/SDL_emscriptenopengles.h | 6 +- src/video/emscripten/SDL_emscriptenvideo.c | 44 +- src/video/emscripten/SDL_emscriptenvideo.h | 2 +- src/video/gdk/SDL_gdktextinput.cpp | 52 +- src/video/haiku/SDL_BWin.h | 80 +- src/video/haiku/SDL_bclipboard.cc | 10 +- src/video/haiku/SDL_bevents.cc | 4 +- src/video/haiku/SDL_bframebuffer.cc | 18 +- src/video/haiku/SDL_bkeyboard.cc | 4 +- src/video/haiku/SDL_bmessagebox.cc | 4 +- src/video/haiku/SDL_bmessagebox.h | 2 +- src/video/haiku/SDL_bmodes.cc | 30 +- src/video/haiku/SDL_bopengl.cc | 10 +- src/video/haiku/SDL_bopengl.h | 12 +- src/video/haiku/SDL_bvideo.cc | 22 +- src/video/haiku/SDL_bwindow.cc | 20 +- src/video/kmsdrm/SDL_kmsdrmdyn.c | 28 +- src/video/kmsdrm/SDL_kmsdrmdyn.h | 4 +- src/video/kmsdrm/SDL_kmsdrmevents.c | 2 +- src/video/kmsdrm/SDL_kmsdrmevents.h | 2 +- src/video/kmsdrm/SDL_kmsdrmmouse.c | 66 +- src/video/kmsdrm/SDL_kmsdrmmouse.h | 2 +- src/video/kmsdrm/SDL_kmsdrmopengles.c | 14 +- src/video/kmsdrm/SDL_kmsdrmopengles.h | 6 +- src/video/kmsdrm/SDL_kmsdrmsym.h | 8 +- src/video/kmsdrm/SDL_kmsdrmvideo.c | 162 +-- src/video/kmsdrm/SDL_kmsdrmvideo.h | 28 +- src/video/kmsdrm/SDL_kmsdrmvulkan.c | 84 +- src/video/kmsdrm/SDL_kmsdrmvulkan.h | 2 +- src/video/n3ds/SDL_n3dsevents.c | 2 +- src/video/n3ds/SDL_n3dsevents_c.h | 2 +- src/video/n3ds/SDL_n3dsframebuffer.c | 4 +- src/video/n3ds/SDL_n3dsframebuffer_c.h | 2 +- src/video/n3ds/SDL_n3dsswkb.c | 2 +- src/video/n3ds/SDL_n3dsswkb.h | 2 +- src/video/n3ds/SDL_n3dstouch.c | 2 +- src/video/n3ds/SDL_n3dstouch.h | 2 +- src/video/n3ds/SDL_n3dsvideo.c | 8 +- src/video/n3ds/SDL_n3dsvideo.h | 2 +- src/video/ngage/SDL_ngageevents.cpp | 14 +- src/video/ngage/SDL_ngageframebuffer.cpp | 54 +- src/video/ngage/SDL_ngageframebuffer_c.h | 2 +- src/video/ngage/SDL_ngagevideo.cpp | 28 +- src/video/ngage/SDL_ngagevideo.h | 8 +- src/video/ngage/SDL_ngagewindow.cpp | 4 +- src/video/ngage/SDL_ngagewindow.h | 2 +- src/video/offscreen/SDL_offscreenevents.c | 4 +- .../offscreen/SDL_offscreenframebuffer.c | 8 +- src/video/offscreen/SDL_offscreenopengles.c | 4 +- src/video/offscreen/SDL_offscreenopengles.h | 4 +- src/video/offscreen/SDL_offscreenvideo.c | 20 +- src/video/offscreen/SDL_offscreenvideo.h | 2 +- src/video/offscreen/SDL_offscreenvulkan.c | 10 +- src/video/offscreen/SDL_offscreenvulkan.h | 4 +- src/video/offscreen/SDL_offscreenwindow.c | 4 +- src/video/offscreen/SDL_offscreenwindow.h | 2 +- src/video/ps2/SDL_ps2video.c | 16 +- src/video/ps2/SDL_ps2video.h | 2 +- src/video/psp/SDL_pspevents.c | 12 +- src/video/psp/SDL_pspevents_c.h | 2 +- src/video/psp/SDL_pspgl.c | 16 +- src/video/psp/SDL_pspgl_c.h | 2 +- src/video/psp/SDL_pspmessagebox.c | 30 +- src/video/psp/SDL_pspmessagebox.h | 4 +- src/video/psp/SDL_pspmouse.c | 4 +- src/video/psp/SDL_pspmouse_c.h | 2 +- src/video/psp/SDL_pspvideo.c | 32 +- src/video/psp/SDL_pspvideo.h | 16 +- src/video/qnx/SDL_qnxgl.c | 2 +- src/video/qnx/SDL_qnxvideo.c | 4 +- src/video/raspberry/SDL_rpievents.c | 2 +- src/video/raspberry/SDL_rpievents_c.h | 2 +- src/video/raspberry/SDL_rpimouse.c | 22 +- src/video/raspberry/SDL_rpimouse.h | 2 +- src/video/raspberry/SDL_rpiopengles.c | 4 +- src/video/raspberry/SDL_rpiopengles.h | 6 +- src/video/raspberry/SDL_rpivideo.c | 58 +- src/video/raspberry/SDL_rpivideo.h | 14 +- src/video/riscos/SDL_riscosdefs.h | 28 +- src/video/riscos/SDL_riscosevents.c | 16 +- src/video/riscos/SDL_riscosevents_c.h | 2 +- src/video/riscos/SDL_riscosframebuffer.c | 16 +- src/video/riscos/SDL_riscosframebuffer_c.h | 2 +- src/video/riscos/SDL_riscosmessagebox.c | 2 +- src/video/riscos/SDL_riscosmessagebox.h | 2 +- src/video/riscos/SDL_riscosmodes.c | 14 +- src/video/riscos/SDL_riscosmodes.h | 2 +- src/video/riscos/SDL_riscosmouse.c | 22 +- src/video/riscos/SDL_riscosmouse.h | 2 +- src/video/riscos/SDL_riscosvideo.c | 18 +- src/video/riscos/SDL_riscosvideo.h | 2 +- src/video/riscos/SDL_riscoswindow.c | 4 +- src/video/riscos/SDL_riscoswindow.h | 2 +- src/video/riscos/scancodes_riscos.h | 24 +- src/video/sdlgenblit.pl | 8 +- src/video/uikit/SDL_uikitappdelegate.m | 68 +- src/video/uikit/SDL_uikitclipboard.h | 2 +- src/video/uikit/SDL_uikitclipboard.m | 2 +- src/video/uikit/SDL_uikitevents.h | 2 +- src/video/uikit/SDL_uikitevents.m | 20 +- src/video/uikit/SDL_uikitmessagebox.h | 2 +- src/video/uikit/SDL_uikitmessagebox.m | 8 +- src/video/uikit/SDL_uikitmetalview.h | 4 +- src/video/uikit/SDL_uikitmetalview.m | 6 +- src/video/uikit/SDL_uikitmodes.h | 2 +- src/video/uikit/SDL_uikitmodes.m | 28 +- src/video/uikit/SDL_uikitopengles.h | 2 +- src/video/uikit/SDL_uikitopengles.m | 12 +- src/video/uikit/SDL_uikitopenglview.h | 2 +- src/video/uikit/SDL_uikitopenglview.m | 34 +- src/video/uikit/SDL_uikitvideo.h | 4 +- src/video/uikit/SDL_uikitvideo.m | 20 +- src/video/uikit/SDL_uikitview.m | 46 +- src/video/uikit/SDL_uikitviewcontroller.m | 36 +- src/video/uikit/SDL_uikitvulkan.h | 2 +- src/video/uikit/SDL_uikitvulkan.m | 8 +- src/video/uikit/SDL_uikitwindow.h | 4 +- src/video/uikit/SDL_uikitwindow.m | 44 +- src/video/vita/SDL_vitaframebuffer.c | 4 +- src/video/vita/SDL_vitagl_pvr.c | 10 +- src/video/vita/SDL_vitagl_pvr_c.h | 2 +- src/video/vita/SDL_vitagles.c | 12 +- src/video/vita/SDL_vitagles_c.h | 2 +- src/video/vita/SDL_vitagles_pvr.c | 2 +- src/video/vita/SDL_vitagles_pvr_c.h | 2 +- src/video/vita/SDL_vitakeyboard.c | 2 +- src/video/vita/SDL_vitakeyboard.h | 4 +- src/video/vita/SDL_vitamessagebox.c | 4 +- src/video/vita/SDL_vitamessagebox.h | 4 +- src/video/vita/SDL_vitamouse.c | 2 +- src/video/vita/SDL_vitamouse_c.h | 4 +- src/video/vita/SDL_vitatouch.c | 2 +- src/video/vita/SDL_vitatouch.h | 4 +- src/video/vita/SDL_vitavideo.c | 42 +- src/video/vita/SDL_vitavideo.h | 16 +- src/video/vivante/SDL_vivanteopengles.c | 4 +- src/video/vivante/SDL_vivanteopengles.h | 6 +- src/video/vivante/SDL_vivanteplatform.c | 4 +- src/video/vivante/SDL_vivanteplatform.h | 4 +- src/video/vivante/SDL_vivantevideo.c | 36 +- src/video/vivante/SDL_vivantevideo.h | 12 +- src/video/vivante/SDL_vivantevulkan.c | 6 +- src/video/vivante/SDL_vivantevulkan.h | 2 +- src/video/wayland/SDL_waylandclipboard.c | 2 +- src/video/wayland/SDL_waylandclipboard.h | 2 +- src/video/wayland/SDL_waylanddatamanager.c | 16 +- src/video/wayland/SDL_waylanddatamanager.h | 12 +- src/video/wayland/SDL_waylanddyn.c | 28 +- src/video/wayland/SDL_waylanddyn.h | 12 +- src/video/wayland/SDL_waylandevents.c | 162 +-- src/video/wayland/SDL_waylandevents_c.h | 32 +- src/video/wayland/SDL_waylandkeyboard.c | 10 +- src/video/wayland/SDL_waylandkeyboard.h | 2 +- src/video/wayland/SDL_waylandmessagebox.c | 64 +- src/video/wayland/SDL_waylandmessagebox.h | 4 +- src/video/wayland/SDL_waylandmouse.c | 62 +- src/video/wayland/SDL_waylandmouse.h | 4 +- src/video/wayland/SDL_waylandopengles.c | 26 +- src/video/wayland/SDL_waylandopengles.h | 4 +- src/video/wayland/SDL_waylandshmbuffer.c | 4 +- src/video/wayland/SDL_waylandshmbuffer.h | 2 +- src/video/wayland/SDL_waylandsym.h | 10 +- src/video/wayland/SDL_waylandvideo.c | 130 +-- src/video/wayland/SDL_waylandvideo.h | 4 +- src/video/wayland/SDL_waylandvulkan.c | 2 +- src/video/wayland/SDL_waylandvulkan.h | 2 +- src/video/wayland/SDL_waylandwindow.c | 220 ++-- src/video/wayland/SDL_waylandwindow.h | 20 +- src/video/windows/SDL_msctf.h | 6 +- src/video/windows/SDL_windowsclipboard.c | 26 +- src/video/windows/SDL_windowsclipboard.h | 4 +- src/video/windows/SDL_windowsevents.c | 262 ++--- src/video/windows/SDL_windowsevents.h | 2 +- src/video/windows/SDL_windowsframebuffer.c | 18 +- src/video/windows/SDL_windowsgameinput.c | 24 +- src/video/windows/SDL_windowskeyboard.c | 38 +- src/video/windows/SDL_windowskeyboard.h | 2 +- src/video/windows/SDL_windowsmessagebox.c | 102 +- src/video/windows/SDL_windowsmessagebox.h | 2 +- src/video/windows/SDL_windowsmodes.c | 34 +- src/video/windows/SDL_windowsmodes.h | 2 +- src/video/windows/SDL_windowsmouse.c | 24 +- src/video/windows/SDL_windowsmouse.h | 2 +- src/video/windows/SDL_windowsopengl.c | 88 +- src/video/windows/SDL_windowsopengl.h | 10 +- src/video/windows/SDL_windowsopengles.c | 20 +- src/video/windows/SDL_windowsopengles.h | 6 +- src/video/windows/SDL_windowsrawinput.c | 12 +- src/video/windows/SDL_windowsrawinput.h | 2 +- src/video/windows/SDL_windowsshape.c | 16 +- src/video/windows/SDL_windowsshape.h | 2 +- src/video/windows/SDL_windowsvideo.c | 74 +- src/video/windows/SDL_windowsvideo.h | 50 +- src/video/windows/SDL_windowsvulkan.c | 2 +- src/video/windows/SDL_windowsvulkan.h | 2 +- src/video/windows/SDL_windowswindow.c | 174 +-- src/video/windows/SDL_windowswindow.h | 8 +- src/video/winrt/SDL_winrtevents.cpp | 8 +- src/video/winrt/SDL_winrtevents_c.h | 6 +- src/video/winrt/SDL_winrtgamebar.cpp | 12 +- src/video/winrt/SDL_winrtgamebar_cpp.h | 2 +- src/video/winrt/SDL_winrtkeyboard.cpp | 6 +- src/video/winrt/SDL_winrtmessagebox.cpp | 12 +- src/video/winrt/SDL_winrtmessagebox.h | 2 +- src/video/winrt/SDL_winrtmouse.cpp | 2 +- src/video/winrt/SDL_winrtmouse_c.h | 2 +- src/video/winrt/SDL_winrtopengles.cpp | 18 +- src/video/winrt/SDL_winrtopengles.h | 8 +- src/video/winrt/SDL_winrtpointerinput.cpp | 6 +- src/video/winrt/SDL_winrtvideo.cpp | 60 +- src/video/winrt/SDL_winrtvideo_cpp.h | 16 +- src/video/x11/SDL_x11clipboard.c | 16 +- src/video/x11/SDL_x11clipboard.h | 2 +- src/video/x11/SDL_x11dyn.c | 30 +- src/video/x11/SDL_x11dyn.h | 10 +- src/video/x11/SDL_x11events.c | 176 ++-- src/video/x11/SDL_x11events.h | 2 +- src/video/x11/SDL_x11framebuffer.c | 32 +- src/video/x11/SDL_x11framebuffer.h | 2 +- src/video/x11/SDL_x11keyboard.c | 26 +- src/video/x11/SDL_x11keyboard.h | 2 +- src/video/x11/SDL_x11messagebox.c | 180 ++-- src/video/x11/SDL_x11messagebox.h | 4 +- src/video/x11/SDL_x11modes.c | 108 +- src/video/x11/SDL_x11modes.h | 6 +- src/video/x11/SDL_x11mouse.c | 32 +- src/video/x11/SDL_x11mouse.h | 2 +- src/video/x11/SDL_x11opengl.c | 106 +- src/video/x11/SDL_x11opengl.h | 6 +- src/video/x11/SDL_x11opengles.c | 16 +- src/video/x11/SDL_x11opengles.h | 10 +- src/video/x11/SDL_x11pen.c | 14 +- src/video/x11/SDL_x11settings.c | 2 +- src/video/x11/SDL_x11settings.h | 2 +- src/video/x11/SDL_x11shape.c | 8 +- src/video/x11/SDL_x11shape.h | 2 +- src/video/x11/SDL_x11sym.h | 20 +- src/video/x11/SDL_x11touch.c | 2 +- src/video/x11/SDL_x11touch.h | 2 +- src/video/x11/SDL_x11video.c | 44 +- src/video/x11/SDL_x11video.h | 18 +- src/video/x11/SDL_x11vulkan.c | 4 +- src/video/x11/SDL_x11vulkan.h | 2 +- src/video/x11/SDL_x11window.c | 182 ++-- src/video/x11/SDL_x11window.h | 6 +- src/video/x11/SDL_x11xfixes.c | 20 +- src/video/x11/SDL_x11xfixes.h | 4 +- src/video/x11/SDL_x11xinput2.c | 60 +- src/video/x11/SDL_x11xinput2.h | 2 +- src/video/x11/edid.h | 20 +- 743 files changed, 11882 insertions(+), 11882 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index d037f3b485..2b3ae4e296 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -24,17 +24,17 @@ #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" #elif !defined(SDL_PLATFORM_WINRT) -#include /* _exit(), etc. */ +#include // _exit(), etc. #endif -/* this checks for HAVE_DBUS_DBUS_H internally. */ +// this checks for HAVE_DBUS_DBUS_H internally. #include "core/linux/SDL_dbus.h" #ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif -/* Initialization code for SDL */ +// Initialization code for SDL #include "SDL_assert_c.h" #include "SDL_hints_c.h" @@ -56,7 +56,7 @@ #define SDL_INIT_EVERYTHING ~0U -/* Initialization/Cleanup routines */ +// Initialization/Cleanup routines #include "timer/SDL_timer_c.h" #ifdef SDL_VIDEO_DRIVER_WINDOWS extern int SDL_HelperWindowCreate(void); @@ -72,7 +72,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION, SDL_MICRO_VERSION == SDL_BUILD_MICRO_VERSION); #endif -/* Limited by its encoding in SDL_VERSIONNUM */ +// Limited by its encoding in SDL_VERSIONNUM SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0); SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 10); SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0); @@ -95,19 +95,19 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode) ExitProcess here that will never be reached but make MingW happy. */ ExitProcess(exitcode); #elif defined(SDL_PLATFORM_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(SDL_PLATFORM_HAIKU) /* Haiku has _Exit, but it's not marked noreturn. */ +#elif defined(SDL_PLATFORM_HAIKU) // Haiku has _Exit, but it's not marked noreturn. _exit(exitcode); -#elif defined(HAVE__EXIT) /* Upper case _Exit() */ +#elif defined(HAVE__EXIT) // Upper case _Exit() _Exit(exitcode); #else _exit(exitcode); #endif } -/* App metadata */ +// App metadata int SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier) { @@ -171,7 +171,7 @@ const char *SDL_GetAppMetadataProperty(const char *name) } -/* The initialized subsystems */ +// The initialized subsystems #ifdef SDL_MAIN_NEEDED static SDL_bool SDL_MainIsReady = SDL_FALSE; #else @@ -180,7 +180,7 @@ static SDL_bool SDL_MainIsReady = SDL_TRUE; static SDL_bool SDL_bInMainQuit = SDL_FALSE; static Uint8 SDL_SubsystemRefCount[32]; -/* Private helper to increment a subsystem's ref counter. */ +// Private helper to increment a subsystem's ref counter. static void SDL_IncrementSubsystemRefCount(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); @@ -190,7 +190,7 @@ static void SDL_IncrementSubsystemRefCount(Uint32 subsystem) } } -/* Private helper to decrement a subsystem's ref counter. */ +// Private helper to decrement a subsystem's ref counter. static void SDL_DecrementSubsystemRefCount(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); @@ -203,7 +203,7 @@ static void SDL_DecrementSubsystemRefCount(Uint32 subsystem) } } -/* Private helper to check if a system needs init. */ +// Private helper to check if a system needs init. static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); @@ -211,7 +211,7 @@ static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem) return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)); } -/* Private helper to check if a system needs to be quit. */ +// Private helper to check if a system needs to be quit. static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); @@ -246,7 +246,7 @@ void SDL_SetMainReady(void) SDL_MainIsReady = SDL_TRUE; } -/* Initialize all the subsystems that require initialization before threads start */ +// Initialize all the subsystems that require initialization before threads start void SDL_InitMainThread(void) { SDL_InitTLSData(); @@ -290,7 +290,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags) } #endif - /* Initialize the event subsystem */ + // Initialize the event subsystem if (flags & SDL_INIT_EVENTS) { if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) { SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS); @@ -304,7 +304,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags) flags_initialized |= SDL_INIT_EVENTS; } - /* Initialize the timer subsystem */ + // Initialize the timer subsystem if (flags & SDL_INIT_TIMER) { if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) { SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER); @@ -318,11 +318,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags) flags_initialized |= SDL_INIT_TIMER; } - /* Initialize the video subsystem */ + // Initialize the video subsystem if (flags & SDL_INIT_VIDEO) { #ifndef SDL_VIDEO_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_VIDEO)) { - /* video implies events */ + // video implies events if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) { goto quit_and_error; } @@ -342,11 +342,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags) #endif } - /* Initialize the audio subsystem */ + // Initialize the audio subsystem if (flags & SDL_INIT_AUDIO) { #ifndef SDL_AUDIO_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_AUDIO)) { - /* audio implies events */ + // audio implies events if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) { goto quit_and_error; } @@ -366,11 +366,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags) #endif } - /* Initialize the joystick subsystem */ + // Initialize the joystick subsystem if (flags & SDL_INIT_JOYSTICK) { #ifndef SDL_JOYSTICK_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_JOYSTICK)) { - /* joystick implies events */ + // joystick implies events if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) { goto quit_and_error; } @@ -393,7 +393,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags) if (flags & SDL_INIT_GAMEPAD) { #ifndef SDL_JOYSTICK_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_GAMEPAD)) { - /* game controller implies joystick */ + // game controller implies joystick if (!SDL_InitOrIncrementSubsystem(SDL_INIT_JOYSTICK)) { goto quit_and_error; } @@ -413,7 +413,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags) #endif } - /* Initialize the haptic subsystem */ + // Initialize the haptic subsystem if (flags & SDL_INIT_HAPTIC) { #ifndef SDL_HAPTIC_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) { @@ -432,7 +432,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags) #endif } - /* Initialize the sensor subsystem */ + // Initialize the sensor subsystem if (flags & SDL_INIT_SENSOR) { #ifndef SDL_SENSOR_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) { @@ -451,11 +451,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags) #endif } - /* Initialize the camera subsystem */ + // Initialize the camera subsystem if (flags & SDL_INIT_CAMERA) { #ifndef SDL_CAMERA_DISABLED if (SDL_ShouldInitSubsystem(SDL_INIT_CAMERA)) { - /* camera implies events */ + // camera implies events if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) { goto quit_and_error; } @@ -475,7 +475,7 @@ int SDL_InitSubSystem(SDL_InitFlags 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 SDL_ClearError(); @@ -491,13 +491,13 @@ int SDL_Init(SDL_InitFlags flags) void SDL_QuitSubSystem(SDL_InitFlags flags) { - /* Shut down requested initialized subsystems */ + // Shut down requested initialized subsystems #ifndef SDL_CAMERA_DISABLED if (flags & SDL_INIT_CAMERA) { if (SDL_ShouldQuitSubsystem(SDL_INIT_CAMERA)) { SDL_QuitCamera(); - /* camera implies events */ + // camera implies events SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_DecrementSubsystemRefCount(SDL_INIT_CAMERA); @@ -517,7 +517,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags) if (flags & SDL_INIT_GAMEPAD) { if (SDL_ShouldQuitSubsystem(SDL_INIT_GAMEPAD)) { SDL_QuitGamepads(); - /* game controller implies joystick */ + // game controller implies joystick SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD); @@ -526,7 +526,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags) if (flags & SDL_INIT_JOYSTICK) { if (SDL_ShouldQuitSubsystem(SDL_INIT_JOYSTICK)) { SDL_QuitJoysticks(); - /* joystick implies events */ + // joystick implies events SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK); @@ -546,7 +546,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags) if (flags & SDL_INIT_AUDIO) { if (SDL_ShouldQuitSubsystem(SDL_INIT_AUDIO)) { SDL_QuitAudio(); - /* audio implies events */ + // audio implies events SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO); @@ -558,7 +558,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags) if (SDL_ShouldQuitSubsystem(SDL_INIT_VIDEO)) { SDL_QuitRender(); SDL_VideoQuit(); - /* video implies events */ + // video implies events SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO); @@ -586,7 +586,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags) int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount); Uint32 initialized = 0; - /* Fast path for checking one flag */ + // Fast path for checking one flag if (SDL_HasExactlyOneBitSet32(flags)) { int subsystem_index = SDL_MostSignificantBitIndex32(flags); return SDL_SubsystemRefCount[subsystem_index] ? flags : 0; @@ -598,7 +598,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags) num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1); - /* Iterate over each bit in flags, and check the matching subsystem. */ + // Iterate over each bit in flags, and check the matching subsystem. for (i = 0; i < num_subsystems; ++i) { if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) { initialized |= (1 << i); @@ -614,7 +614,7 @@ void SDL_Quit(void) { SDL_bInMainQuit = SDL_TRUE; - /* Quit all subsystems */ + // Quit all subsystems #ifdef SDL_VIDEO_DRIVER_WINDOWS SDL_HelperWindowDestroy(); #endif @@ -641,13 +641,13 @@ void SDL_Quit(void) SDL_bInMainQuit = SDL_FALSE; } -/* Get the library version number */ +// Get the library version number int SDL_GetVersion(void) { return SDL_VERSION; } -/* Get the library source revision */ +// Get the library source revision const char *SDL_GetRevision(void) { return SDL_REVISION; @@ -739,7 +739,7 @@ SDL_bool SDL_IsTablet(void) #ifdef SDL_PLATFORM_WIN32 #if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB) -/* FIXME: Still need to include DllMain() on Watcom C ? */ +// FIXME: Still need to include DllMain() on Watcom C ? BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { @@ -752,6 +752,6 @@ BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_rea } return TRUE; } -#endif /* Building DLL */ +#endif // Building DLL -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 1fa62409f8..b3efe41735 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -35,7 +35,7 @@ #ifdef SDL_PLATFORM_EMSCRIPTEN #include - /* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ + // older Emscriptens don't have this, but we need to for wasm64 compatibility. #ifndef MAIN_THREAD_EM_ASM_PTR #ifdef __wasm64__ #error You need to upgrade your Emscripten compiler to support wasm64 @@ -45,7 +45,7 @@ #endif #endif -/* The size of the stack buffer to use for rendering assert messages. */ +// The size of the stack buffer to use for rendering assert messages. #define SDL_MAX_ASSERT_MESSAGE_STACK 256 static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, void *userdata); @@ -80,7 +80,7 @@ static void SDL_AddAssertionToReport(SDL_AssertData *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; } @@ -105,7 +105,7 @@ static void SDL_GenerateAssertionReport(void) { const SDL_AssertData *item = triggered_assertions; - /* only do this if the app hasn't assigned an assertion handler. */ + // only do this if the app hasn't assigned an assertion handler. if ((item) && (assertion_handler != SDL_PromptAssertion)) { debug_print("\n\nSDL assertion report.\n"); debug_print("All SDL assertions between last init/quit:\n\n"); @@ -168,12 +168,12 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v 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... */ + // Assume the output will fit... len = SDL_RenderAssertMessage(message, buf_len, data); - /* .. and if it didn't, try to allocate as much room as we actually need. */ + // .. and if it didn't, try to allocate as much room as we actually need. if (len >= (int)buf_len) { if (SDL_size_add_overflow(len, 1, &buf_len) == 0) { message = (char *)SDL_malloc(buf_len); @@ -185,7 +185,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } } - /* Something went very wrong */ + // Something went very wrong if (len < 0) { if (message != stack_buf) { SDL_free(message); @@ -195,7 +195,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v debug_print("\n\n%s\n\n", message); - /* let env. variable override, so unit tests won't block in a GUI. */ + // let env. variable override, so unit tests won't block in a GUI. const char *hint = SDL_GetHint(SDL_HINT_ASSERT); if (hint) { if (message != stack_buf) { @@ -213,23 +213,23 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } else if (SDL_strcmp(hint, "always_ignore") == 0) { return SDL_ASSERTION_ALWAYS_IGNORE; } else { - return SDL_ASSERTION_ABORT; /* oh well. */ + return SDL_ASSERTION_ABORT; // oh well. } } - /* Leave fullscreen mode, if possible (scary!) */ + // Leave fullscreen mode, if possible (scary!) window = SDL_GetToplevelForKeyboardFocus(); if (window) { if (window->fullscreen_exclusive) { SDL_MinimizeWindow(window); } else { - /* !!! FIXME: ungrab the input if we're not fullscreen? */ - /* No need to mess with the window */ + // !!! FIXME: ungrab the input if we're not fullscreen? + // No need to mess with the window window = NULL; } } - /* Show a messagebox if we can, otherwise fall back to stdio */ + // Show a messagebox if we can, otherwise fall back to stdio SDL_zero(messagebox); messagebox.flags = SDL_MESSAGEBOX_WARNING; messagebox.window = window; @@ -246,10 +246,10 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } } else { #ifdef SDL_PLATFORM_EMSCRIPTEN - /* This is nasty, but we can't block on a custom UI. */ + // This is nasty, but we can't block on a custom UI. for (;;) { SDL_bool okay = SDL_TRUE; - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({ var str = UTF8ToString($0) + '\n\n' + @@ -260,11 +260,11 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); }, message); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on if (SDL_strcmp(buf, "a") == 0) { state = SDL_ASSERTION_ABORT; -#if 0 /* (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; #endif @@ -277,14 +277,14 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } else { okay = SDL_FALSE; } - free(buf); /* This should NOT be SDL_free() */ + free(buf); // This should NOT be SDL_free() if (okay) { break; } } #elif defined(HAVE_STDIO_H) - /* this is a little hacky. */ + // this is a little hacky. for (;;) { char buf[32]; (void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : "); @@ -310,10 +310,10 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v break; } } -#endif /* HAVE_STDIO_H */ +#endif // HAVE_STDIO_H } - /* Re-enter fullscreen mode */ + // Re-enter fullscreen mode if (window) { SDL_RestoreWindow(window); } @@ -333,19 +333,19 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons #ifndef SDL_THREADS_DISABLED static SDL_SpinLock spinlock = 0; SDL_LockSpinlock(&spinlock); - if (!assertion_mutex) { /* never called SDL_Init()? */ + if (!assertion_mutex) { // never called SDL_Init()? assertion_mutex = SDL_CreateMutex(); if (!assertion_mutex) { SDL_UnlockSpinlock(&spinlock); - return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ + return SDL_ASSERTION_IGNORE; // oh well, I guess. } } SDL_UnlockSpinlock(&spinlock); SDL_LockMutex(assertion_mutex); -#endif /* !SDL_THREADS_DISABLED */ +#endif // !SDL_THREADS_DISABLED - /* doing this because Visual C is upset over assigning in the macro. */ + // doing this because Visual C is upset over assigning in the macro. if (data->trigger_count == 0) { data->function = func; data->filename = file; @@ -355,13 +355,13 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons 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,11 +379,11 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons case SDL_ASSERTION_IGNORE: case SDL_ASSERTION_RETRY: case SDL_ASSERTION_BREAK: - break; /* macro handles these. */ + break; // macro handles these. case SDL_ASSERTION_ABORT: SDL_AbortAssertion(); - /*break; ...shouldn't return, but oh well. */ + // break; ...shouldn't return, but oh well. } assertion_running--; @@ -405,7 +405,7 @@ void SDL_AssertionsQuit(void) assertion_mutex = NULL; } #endif -#endif /* SDL_ASSERT_LEVEL > 0 */ +#endif // SDL_ASSERT_LEVEL > 0 } void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata) diff --git a/src/SDL_assert_c.h b/src/SDL_assert_c.h index f4f1d2f8bb..93b1753aa8 100644 --- a/src/SDL_assert_c.h +++ b/src/SDL_assert_c.h @@ -25,4 +25,4 @@ extern void SDL_AssertionsQuit(void); -#endif /* SDL_assert_c_h_ */ +#endif // SDL_assert_c_h_ diff --git a/src/SDL_error.c b/src/SDL_error.c index 679a067699..5b0d35d4e3 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -20,13 +20,13 @@ */ #include "SDL_internal.h" -/* Simple error handling in SDL */ +// Simple error handling in SDL #include "SDL_error_c.h" int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { - /* Ignore call if invalid format pointer was passed */ + // Ignore call if invalid format pointer was passed if (fmt) { va_list ap; int result; @@ -51,7 +51,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) } if (SDL_GetLogPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) { - /* If we are in debug mode, print out the error message */ + // If we are in debug mode, print out the error message SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); } } diff --git a/src/SDL_error_c.h b/src/SDL_error_c.h index c3e4f78224..55fa92d1e0 100644 --- a/src/SDL_error_c.h +++ b/src/SDL_error_c.h @@ -43,7 +43,7 @@ typedef struct SDL_error SDL_free_func free_func; } SDL_error; -/* Defined in SDL_thread.c */ +// Defined in SDL_thread.c extern SDL_error *SDL_GetErrBuf(SDL_bool create); -#endif /* SDL_error_c_h_ */ +#endif // SDL_error_c_h_ diff --git a/src/SDL_guid.c b/src/SDL_guid.c index cae9683a34..b7efe9a99c 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* convert the guid to a printable string */ +// convert the guid to a printable string void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) { static const char k_rgchHexToASCII[] = "0123456789abcdef"; @@ -31,8 +31,8 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) } 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 */ + // 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]; *pszGUID++ = k_rgchHexToASCII[c >> 4]; @@ -60,12 +60,12 @@ static unsigned char nibble(unsigned char c) return c - 'a' + 0x0a; } - /* received an invalid character, and no real way to return an error */ - /* AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c); */ + // received an invalid character, and no real way to return an error + // AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c); return 0; } -/* convert the string version of a guid to the struct */ +// convert the string version of a guid to the struct SDL_GUID SDL_StringToGUID(const char *pchGUID) { SDL_GUID guid; @@ -74,7 +74,7 @@ SDL_GUID SDL_StringToGUID(const char *pchGUID) Uint8 *p; size_t i; - /* Make sure it's even */ + // Make sure it's even len = (len) & ~0x1; SDL_memset(&guid, 0x00, sizeof(guid)); diff --git a/src/SDL_hashtable.h b/src/SDL_hashtable.h index 4c3f74dfa7..160180ea62 100644 --- a/src/SDL_hashtable.h +++ b/src/SDL_hashtable.h @@ -21,7 +21,7 @@ #ifndef SDL_hashtable_h_ #define SDL_hashtable_h_ -/* this is not (currently) a public API. But maybe it should be! */ +// this is not (currently) a public API. But maybe it should be! struct SDL_HashTable; typedef struct SDL_HashTable SDL_HashTable; @@ -57,4 +57,4 @@ extern SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused); extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused); -#endif /* SDL_hashtable_h_ */ +#endif // SDL_hashtable_h_ diff --git a/src/SDL_hints_c.h b/src/SDL_hints_c.h index bd33ad8ac8..10b674ba81 100644 --- a/src/SDL_hints_c.h +++ b/src/SDL_hints_c.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This file defines useful function for working with SDL hints */ +// This file defines useful function for working with SDL hints #ifndef SDL_hints_c_h_ #define SDL_hints_c_h_ @@ -30,4 +30,4 @@ extern SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value); extern int SDL_GetStringInteger(const char *value, int default_value); extern void SDL_QuitHints(void); -#endif /* SDL_hints_c_h_ */ +#endif // SDL_hints_c_h_ diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 1e77ae0e00..9be670d47a 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -21,12 +21,12 @@ #ifndef SDL_internal_h_ #define SDL_internal_h_ -/* Many of SDL's features require _GNU_SOURCE on various platforms */ +// Many of SDL's features require _GNU_SOURCE on various platforms #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -/* Need this so Linux systems define fseek64o, ftell64o and off64_t */ +// Need this so Linux systems define fseek64o, ftell64o and off64_t #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE 1 #endif @@ -44,11 +44,11 @@ #define HAVE_GCC_DIAGNOSTIC_PRAGMA 1 #endif -#ifdef _MSC_VER /* We use constant comparison for generated code */ +#ifdef _MSC_VER // We use constant comparison for generated code #pragma warning(disable : 6326) #endif -#ifdef _MSC_VER /* SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe */ +#ifdef _MSC_VER // SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe #pragma warning(disable : 6255) #endif #define SDL_MAX_SMALL_ALLOC_STACKSIZE 128 @@ -76,7 +76,7 @@ #ifdef SDL_PLATFORM_APPLE #ifndef _DARWIN_C_SOURCE -#define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */ +#define _DARWIN_C_SOURCE 1 // for memset_pattern4() #endif #endif @@ -121,7 +121,7 @@ #include #endif -/* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */ +// 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 #endif @@ -192,7 +192,7 @@ #endif #ifndef SDL_RENDER_DISABLED -/* define the not defined ones as 0 */ +// define the not defined ones as 0 #ifndef SDL_VIDEO_RENDER_D3D #define SDL_VIDEO_RENDER_D3D 0 #endif @@ -223,7 +223,7 @@ #ifndef SDL_VIDEO_RENDER_VULKAN #define SDL_VIDEO_RENDER_VULKAN 0 #endif -#else /* define all as 0 */ +#else // define all as 0 #undef SDL_VIDEO_RENDER_SW #define SDL_VIDEO_RENDER_SW 0 #undef SDL_VIDEO_RENDER_D3D @@ -246,7 +246,7 @@ #define SDL_VIDEO_RENDER_VITA_GXM 0 #undef SDL_VIDEO_RENDER_VULKAN #define SDL_VIDEO_RENDER_VULKAN 0 -#endif /* SDL_RENDER_DISABLED */ +#endif // SDL_RENDER_DISABLED #define SDL_HAS_RENDER_DRIVER \ (SDL_VIDEO_RENDER_SW | \ @@ -276,17 +276,17 @@ #include #include -#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ +#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main #include -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif #include "SDL_utils_c.h" -/* Do any initialization that needs to happen before threads are started */ +// Do any initialization that needs to happen before threads are started extern void SDL_InitMainThread(void); /* The internal implementations of these functions have up to nanosecond precision. @@ -296,9 +296,9 @@ extern int SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeout extern int SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS); extern SDL_bool SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_internal_h_ */ +#endif // SDL_internal_h_ diff --git a/src/SDL_list.c b/src/SDL_list.c index 8c95876f83..b6c689ba27 100644 --- a/src/SDL_list.c +++ b/src/SDL_list.c @@ -22,7 +22,7 @@ #include "./SDL_list.h" -/* Push */ +// Push int SDL_ListAdd(SDL_ListNode **head, void *ent) { SDL_ListNode *node = (SDL_ListNode *)SDL_malloc(sizeof(*node)); @@ -37,12 +37,12 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent) return 0; } -/* Pop from end as a FIFO (if add with SDL_ListAdd) */ +// Pop from end as a FIFO (if add with SDL_ListAdd) void SDL_ListPop(SDL_ListNode **head, void **ent) { SDL_ListNode **ptr = head; - /* Invalid or empty */ + // Invalid or empty if (!head || !*head) { return; } diff --git a/src/SDL_list.h b/src/SDL_list.h index 583f78aa07..3834e9af7b 100644 --- a/src/SDL_list.h +++ b/src/SDL_list.h @@ -33,4 +33,4 @@ void SDL_ListPop(SDL_ListNode **head, void **ent); void SDL_ListRemove(SDL_ListNode **head, void *ent); void SDL_ListClear(SDL_ListNode **head); -#endif /* SDL_list_h_ */ +#endif // SDL_list_h_ diff --git a/src/SDL_log.c b/src/SDL_log.c index 000c90e642..017dc5ac4c 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -24,7 +24,7 @@ #include "core/windows/SDL_windows.h" #endif -/* Simple log messages in SDL */ +// Simple log messages in SDL #include "SDL_log_c.h" @@ -38,7 +38,7 @@ #include "stdlib/SDL_vacopy.h" -/* The size of the stack buffer to use for rendering log messages. */ +// The size of the stack buffer to use for rendering log messages. #define SDL_MAX_LOG_MESSAGE_STACK 256 #define DEFAULT_CATEGORY -1 @@ -51,7 +51,7 @@ typedef struct SDL_LogLevel } SDL_LogLevel; -/* The default log output function */ +// The default log output function static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message); static void SDL_ResetLogPrefixes(void); @@ -68,7 +68,7 @@ static SDL_Mutex *log_function_mutex = NULL; #pragma GCC diagnostic ignored "-Wunused-variable" #endif -/* If this list changes, update the documentation for SDL_HINT_LOGGING */ +// If this list changes, update the documentation for SDL_HINT_LOGGING static const char * const SDL_priority_names[] = { NULL, "VERBOSE", @@ -82,7 +82,7 @@ SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES]; -/* If this list changes, update the documentation for SDL_HINT_LOGGING */ +// If this list changes, update the documentation for SDL_HINT_LOGGING static const char * const SDL_category_names[] = { "APP", "ERROR", @@ -110,12 +110,12 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { ANDROID_LOG_ERROR, ANDROID_LOG_FATAL }; -#endif /* SDL_PLATFORM_ANDROID */ +#endif // SDL_PLATFORM_ANDROID void SDL_InitLog(void) { if (!log_function_mutex) { - /* if this fails we'll try to continue without it. */ + // if this fails we'll try to continue without it. log_function_mutex = SDL_CreateMutex(); } } @@ -154,7 +154,7 @@ void SDL_SetLogPriority(int category, SDL_LogPriority priority) } } - /* Create a new entry */ + // Create a new entry entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); if (entry) { entry->category = category; @@ -194,7 +194,7 @@ static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogP if (SDL_isdigit(*string)) { i = SDL_atoi(string); if (i == 0) { - /* 0 has a special meaning of "disable this category" */ + // 0 has a special meaning of "disable this category" *priority = SDL_NUM_LOG_PRIORITIES; return SDL_TRUE; } @@ -439,7 +439,7 @@ static const char *GetCategoryPrefix(int category) } return "CUSTOM"; } -#endif /* SDL_PLATFORM_ANDROID */ +#endif // SDL_PLATFORM_ANDROID void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) { @@ -449,27 +449,27 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S int len; va_list aq; - /* Nothing to do if we don't have an output function */ + // Nothing to do if we don't have an output function if (!SDL_log_function) { return; } - /* Make sure we don't exceed array bounds */ + // Make sure we don't exceed array bounds if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { return; } - /* See if we want to do anything with this message */ + // See if we want to do anything with this message if (priority < SDL_GetLogPriority(category)) { return; } if (!log_function_mutex) { - /* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */ + // this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! log_function_mutex = SDL_CreateMutex(); } - /* Render into stack buffer */ + // Render into stack buffer va_copy(aq, ap); len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq); va_end(aq); @@ -478,9 +478,9 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S return; } - /* If message truncated, allocate and re-render */ + // If message truncated, allocate and re-render if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) { - /* Allocate exactly what we need, including the zero-terminator */ + // Allocate exactly what we need, including the zero-terminator message = (char *)SDL_malloc(len_plus_term); if (!message) { return; @@ -492,10 +492,10 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S message = stack_buf; } - /* Chop off final endline. */ + // Chop off final endline. 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'; } } @@ -504,7 +504,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S SDL_log_function(SDL_log_userdata, category, priority, message); SDL_UnlockMutex(log_function_mutex); - /* Free only if dynamically allocated */ + // Free only if dynamically allocated if (message != stack_buf) { SDL_free(message); } @@ -519,7 +519,7 @@ enum { CONSOLE_ATTACHED_ERROR = -1, } consoleAttached = CONSOLE_UNATTACHED; -/* Handle to stderr output of console. */ +// Handle to stderr output of console. static HANDLE stderrHandle = NULL; #endif @@ -527,8 +527,8 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority const char *message) { #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) - /* Way too many allocations here, urgh */ - /* Note: One can't call SDL_SetError here, since that function itself logs. */ + // Way too many allocations here, urgh + // Note: One can't call SDL_SetError here, since that function itself logs. { char *output; size_t length; @@ -543,27 +543,27 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority DWORD charsWritten; #endif - /* Maybe attach console and get stderr handle */ + // Maybe attach console and get stderr handle if (consoleAttached == CONSOLE_UNATTACHED) { 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"));*/ + // This is expected when running from Visual Studio + // OutputDebugString(TEXT("Parent process has no console\r\n")); consoleAttached = CONSOLE_ATTACHED_MSVC; } else if (attachError == ERROR_GEN_FAILURE) { OutputDebugString(TEXT("Could not attach to console of parent process\r\n")); consoleAttached = CONSOLE_ATTACHED_ERROR; } else if (attachError == ERROR_ACCESS_DENIED) { - /* Already attached */ + // Already attached consoleAttached = CONSOLE_ATTACHED_CONSOLE; } else { OutputDebugString(TEXT("Error attaching console\r\n")); consoleAttached = CONSOLE_ATTACHED_ERROR; } } else { - /* Newly attached */ + // Newly attached consoleAttached = CONSOLE_ATTACHED_CONSOLE; } @@ -571,12 +571,12 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority stderrHandle = GetStdHandle(STD_ERROR_HANDLE); if (GetConsoleMode(stderrHandle, &consoleMode) == 0) { - /* WriteConsole fails if the output is redirected to a file. Must use WriteFile instead. */ + // WriteConsole fails if the output is redirected to a file. Must use WriteFile instead. consoleAttached = CONSOLE_ATTACHED_FILE; } } } -#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */ +#endif // !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) length = SDL_strlen(SDL_GetLogPriorityPrefix(priority)) + SDL_strlen(message) + 1 + 1 + 1; output = SDL_small_alloc(char, length, &isstack); (void)SDL_snprintf(output, length, "%s%s\r\n", SDL_GetLogPriorityPrefix(priority), message); @@ -584,18 +584,18 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority #if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) - /* When running in MSVC and using stdio, rely on forwarding of stderr to the debug stream */ + // When running in MSVC and using stdio, rely on forwarding of stderr to the debug stream if (consoleAttached != CONSOLE_ATTACHED_MSVC) { - /* Output to debugger */ + // Output to debugger OutputDebugString(tstr); } #else - /* Output to debugger */ + // Output to debugger OutputDebugString(tstr); #endif #if !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) - /* Screen output to stderr, if console was attached. */ + // Screen output to stderr, if console was attached. if (consoleAttached == CONSOLE_ATTACHED_CONSOLE) { if (!WriteConsole(stderrHandle, tstr, (DWORD)SDL_tcslen(tstr), &charsWritten, NULL)) { OutputDebugString(TEXT("Error calling WriteConsole\r\n")); @@ -609,7 +609,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } -#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */ +#endif // !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) SDL_free(tstr); SDL_small_free(output, isstack); diff --git a/src/SDL_log_c.h b/src/SDL_log_c.h index 3da88d6842..bb79ed60cb 100644 --- a/src/SDL_log_c.h +++ b/src/SDL_log_c.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This file defines useful function for working with SDL logging */ +// This file defines useful function for working with SDL logging #ifndef SDL_log_c_h_ #define SDL_log_c_h_ @@ -28,4 +28,4 @@ extern void SDL_InitLog(void); extern void SDL_QuitLog(void); -#endif /* SDL_log_c_h_ */ +#endif // SDL_log_c_h_ diff --git a/src/SDL_properties.c b/src/SDL_properties.c index 323bb91dc8..3fa3169593 100644 --- a/src/SDL_properties.c +++ b/src/SDL_properties.c @@ -177,7 +177,7 @@ SDL_PropertiesID SDL_CreateProperties(void) SDL_UnlockMutex(SDL_properties_lock); if (inserted) { - /* All done! */ + // All done! return props; } @@ -225,7 +225,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst) SDL_Property *dst_property; if (src_property->cleanup) { - /* Can't copy properties with cleanup functions, we don't know how to duplicate the data */ + // Can't copy properties with cleanup functions, we don't know how to duplicate the data continue; } diff --git a/src/SDL_utils.c b/src/SDL_utils.c index b3584c8fbb..290bc8ecfa 100644 --- a/src/SDL_utils.c +++ b/src/SDL_utils.c @@ -26,18 +26,18 @@ #include #endif -/* Common utility functions that aren't in the public API */ +// Common utility functions that aren't in the public API int SDL_powerof2(int x) { int value; if (x <= 0) { - /* Return some sane value - we shouldn't hit this in our use cases */ + // Return some sane value - we shouldn't hit this in our use cases return 1; } - /* This trick works for 32-bit values */ + // This trick works for 32-bit values { SDL_COMPILE_TIME_ASSERT(SDL_powerof2, sizeof(x) == sizeof(Uint32)); } @@ -105,7 +105,7 @@ SDL_bool SDL_endswith(const char *string, const char *suffix) return SDL_FALSE; } -/* Assume we can wrap SDL_AtomicInt values and cast to Uint32 */ +// Assume we can wrap SDL_AtomicInt values and cast to Uint32 SDL_COMPILE_TIME_ASSERT(sizeof_object_id, sizeof(int) == sizeof(Uint32)); Uint32 SDL_GetNextObjectID(void) @@ -165,7 +165,7 @@ SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type) void SDL_SetObjectsInvalid(void) { if (SDL_objects) { - /* Log any leaked objects */ + // Log any leaked objects const void *object, *object_type; void *iter = NULL; while (SDL_IterateHashTable(SDL_objects, &object, &object_type, &iter)) { @@ -223,13 +223,13 @@ static int SDL_URIDecode(const char *src, char *dst, int len) } for (ri = 0, wi = 0, di = 0; ri < len && wi < len; ri += 1) { if (di == 0) { - /* start decoding */ + // start decoding if (src[ri] == '%') { decode = '\0'; di += 1; continue; } - /* normal write */ + // normal write dst[wi] = src[ri]; wi += 1; } else if (di == 1 || di == 2) { @@ -238,7 +238,7 @@ static int SDL_URIDecode(const char *src, char *dst, int len) char isA = src[ri] >= 'A' && src[ri] <= 'F'; char isn = src[ri] >= '0' && src[ri] <= '9'; if (!(isa || isA || isn)) { - /* not a hexadecimal */ + // not a hexadecimal int sri; for (sri = ri - di; sri <= ri; sri += 1) { dst[wi] = src[sri]; @@ -247,7 +247,7 @@ static int SDL_URIDecode(const char *src, char *dst, int len) di = 0; continue; } - /* itsy bitsy magicsy */ + // itsy bitsy magicsy if (isn) { off = 0 - '0'; } else if (isa) { @@ -272,14 +272,14 @@ static int SDL_URIDecode(const char *src, char *dst, int len) int SDL_URIToLocal(const char *src, char *dst) { if (SDL_memcmp(src, "file:/", 6) == 0) { - src += 6; /* local file? */ + src += 6; // local file? } else if (SDL_strstr(src, ":/") != NULL) { - return -1; /* wrong scheme */ + return -1; // wrong scheme } SDL_bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/'); - /* Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive. */ + // Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive. if (!local && src[0] == '/' && src[2] != '/') { char *hostname_end = SDL_strchr(src + 1, '/'); if (hostname_end) { @@ -310,7 +310,7 @@ int SDL_URIToLocal(const char *src, char *dst) } if (local) { - /* Convert URI escape sequences to real characters */ + // Convert URI escape sequences to real characters if (src[0] == '/') { src++; } else { diff --git a/src/SDL_utils_c.h b/src/SDL_utils_c.h index 36375e6a13..f093adb149 100644 --- a/src/SDL_utils_c.h +++ b/src/SDL_utils_c.h @@ -23,9 +23,9 @@ #ifndef SDL_utils_h_ #define SDL_utils_h_ -/* Common utility functions that aren't in the public API */ +// Common utility functions that aren't in the public API -/* Return the smallest power of 2 greater than or equal to 'x' */ +// Return the smallest power of 2 greater than or equal to 'x' extern int SDL_powerof2(int x); extern void SDL_CalculateFraction(float x, int *numerator, int *denominator); @@ -67,4 +67,4 @@ extern void SDL_SetObjectsInvalid(void); extern const char *SDL_GetPersistentString(const char *string); -#endif /* SDL_utils_h_ */ +#endif // SDL_utils_h_ diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index ea26f17ae9..fd368759c7 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -25,7 +25,7 @@ #define HAVE_MSC_ATOMICS 1 #endif -#ifdef SDL_PLATFORM_MACOS /* !!! FIXME: should we favor gcc atomics? */ +#ifdef SDL_PLATFORM_MACOS // !!! FIXME: should we favor gcc atomics? #include #endif @@ -33,7 +33,7 @@ #include #endif -/* The __atomic_load_n() intrinsic showed up in different times for different compilers. */ +// The __atomic_load_n() intrinsic showed up in different times for different compilers. #ifdef __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. @@ -48,7 +48,7 @@ #endif #endif -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #if defined(__WATCOMC__) && defined(__386__) SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int)); #define HAVE_WATCOM_ATOMICS @@ -74,8 +74,8 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v); value [eax] \ modify exact [eax]; -#endif /* __WATCOMC__ && __386__ */ -/* *INDENT-ON* */ /* clang-format on */ +#endif // __WATCOMC__ && __386__ +/* *INDENT-ON* */ // clang-format on /* If any of the operations are not provided then we must emulate some @@ -131,7 +131,7 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval) return _SDL_cmpxchg_watcom(&a->value, newval, oldval); #elif defined(HAVE_GCC_ATOMICS) return __sync_bool_compare_and_swap(&a->value, oldval, newval); -#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics. return OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value); #elif defined(SDL_PLATFORM_SOLARIS) return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval); @@ -159,9 +159,9 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval) return _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval); #elif defined(HAVE_GCC_ATOMICS) return __sync_bool_compare_and_swap(a, oldval, newval); -#elif defined(SDL_PLATFORM_MACOS) && defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) && defined(__LP64__) // this is deprecated in 10.12 sdk; favor gcc atomics. return OSAtomicCompareAndSwap64Barrier((int64_t)oldval, (int64_t)newval, (int64_t *)a); -#elif defined(SDL_PLATFORM_MACOS) && !defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) && !defined(__LP64__) // this is deprecated in 10.12 sdk; favor gcc atomics. return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)a); #elif defined(SDL_PLATFORM_SOLARIS) return (atomic_cas_ptr(a, oldval, newval) == oldval); @@ -254,7 +254,7 @@ int SDL_AtomicGet(SDL_AtomicInt *a) return _SDL_xadd_watcom(&a->value, 0); #elif defined(HAVE_GCC_ATOMICS) return __sync_or_and_fetch(&a->value, 0); -#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics. return sizeof(a->value) == sizeof(uint32_t) ? OSAtomicOr32Barrier(0, (volatile uint32_t *)&a->value) : OSAtomicAdd64Barrier(0, (volatile int64_t *)&a->value); #elif defined(SDL_PLATFORM_SOLARIS) return atomic_or_uint_nv((volatile uint_t *)&a->value, 0); diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 0896b41cc4..f119f05fc3 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -44,7 +44,7 @@ #include #endif -/* *INDENT-OFF* */ /* clang-format off */ +/* *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); @@ -53,10 +53,10 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v); parm [ecx] [eax] \ value [eax] \ modify exact [eax]; -#endif /* __WATCOMC__ && __386__ */ -/* *INDENT-ON* */ /* clang-format on */ +#endif // __WATCOMC__ && __386__ +/* *INDENT-ON* */ // clang-format on -/* This function is where all the magic happens... */ +// This function is where all the magic happens... SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) { #if defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET) @@ -116,15 +116,15 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) return result == 0; #elif defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) - /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ + // Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. return OSAtomicCompareAndSwap32Barrier(0, 1, lock); #elif defined(SDL_PLATFORM_SOLARIS) && defined(_LP64) - /* Used for Solaris with non-gcc compilers. */ + // Used for Solaris with non-gcc compilers. return ((int)atomic_cas_64((volatile uint64_t *)lock, 0, 1) == 0); #elif defined(SDL_PLATFORM_SOLARIS) && !defined(_LP64) - /* Used for Solaris with non-gcc compilers. */ + // Used for Solaris with non-gcc compilers. return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0); #elif defined(PS2) uint32_t oldintr; @@ -142,11 +142,11 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) } return res; #else - /* Terrible terrible damage */ + // Terrible terrible damage static SDL_Mutex *_spinlock_mutex; if (!_spinlock_mutex) { - /* Race condition on first lock... */ + // Race condition on first lock... _spinlock_mutex = SDL_CreateMutex(); } SDL_LockMutex(_spinlock_mutex); @@ -164,13 +164,13 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) void SDL_LockSpinlock(SDL_SpinLock *lock) { int iterations = 0; - /* FIXME: Should we have an eventual timeout? */ + // FIXME: Should we have an eventual timeout? while (!SDL_TryLockSpinlock(lock)) { if (iterations < 32) { iterations++; SDL_CPUPauseInstruction(); } else { - /* !!! FIXME: this doesn't definitely give up the current timeslice, it does different things on various platforms. */ + // !!! FIXME: this doesn't definitely give up the current timeslice, it does different things on various platforms. SDL_Delay(0); } } @@ -193,7 +193,7 @@ void SDL_UnlockSpinlock(SDL_SpinLock *lock) *lock = 0; #elif defined(SDL_PLATFORM_SOLARIS) - /* Used for Solaris when not using gcc. */ + // Used for Solaris when not using gcc. *lock = 0; membar_producer(); diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 8b41836e35..d2c190d1d4 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1722,7 +1722,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp // uhoh, this device is undead, and just waiting to be cleaned up. Refuse explicit opens. SDL_SetError("Device was already lost and can't accept new opens"); } else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) { - /* SDL_calloc already called SDL_OutOfMemory */ + // SDL_calloc already called SDL_OutOfMemory } else if (OpenPhysicalAudioDevice(device, spec) < 0) { // if this is the first thing using this physical device, open at the OS level if necessary... SDL_free(logdev); } else { diff --git a/src/audio/SDL_audio_c.h b/src/audio/SDL_audio_c.h index 95cac81aac..148489f175 100644 --- a/src/audio/SDL_audio_c.h +++ b/src/audio/SDL_audio_c.h @@ -24,4 +24,4 @@ extern void SDL_UpdateAudio(void); -#endif /* SDL_audio_c_h_ */ +#endif // SDL_audio_c_h_ diff --git a/src/audio/SDL_audio_channel_converters.h b/src/audio/SDL_audio_channel_converters.h index a005a7ee25..bee3858dcc 100644 --- a/src/audio/SDL_audio_channel_converters.h +++ b/src/audio/SDL_audio_channel_converters.h @@ -1055,7 +1055,7 @@ static void SDL_Convert71To61(float *dst, const float *src, int num_frames) } -static const SDL_AudioChannelConverter channel_converters[8][8] = { /* [from][to] */ +static const SDL_AudioChannelConverter 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 }, diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 6472d1649a..9484b09c68 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -24,14 +24,14 @@ #include #endif #ifndef INT_MAX -/* Make a lucky guess. */ +// Make a lucky guess. #define INT_MAX SDL_MAX_SINT32 #endif #ifndef SIZE_MAX #define SIZE_MAX ((size_t)-1) #endif -/* Microsoft WAVE file loading routines */ +// Microsoft WAVE file loading routines #include "SDL_wave.h" #include "SDL_sysaudio.h" @@ -52,17 +52,17 @@ static int SafeMult(size_t *f1, size_t f2) typedef struct ADPCM_DecoderState { - Uint32 channels; /* Number of channels. */ - size_t blocksize; /* Size of an ADPCM block in bytes. */ - size_t blockheadersize; /* Size of an ADPCM block header in bytes. */ - size_t samplesperblock; /* Number of samples per channel in an ADPCM block. */ - size_t framesize; /* Size of a sample frame (16-bit PCM) in bytes. */ - Sint64 framestotal; /* Total number of sample frames. */ - Sint64 framesleft; /* Number of sample frames still to be decoded. */ - void *ddata; /* Decoder data from initialization. */ - void *cstate; /* Decoding state for each channel. */ + Uint32 channels; // Number of channels. + size_t blocksize; // Size of an ADPCM block in bytes. + size_t blockheadersize; // Size of an ADPCM block header in bytes. + size_t samplesperblock; // Number of samples per channel in an ADPCM block. + size_t framesize; // Size of a sample frame (16-bit PCM) in bytes. + Sint64 framestotal; // Total number of sample frames. + Sint64 framesleft; // Number of sample frames still to be decoded. + void *ddata; // Decoder data from initialization. + void *cstate; // Decoding state for each channel. - /* ADPCM data. */ + // ADPCM data. struct { Uint8 *data; @@ -70,7 +70,7 @@ typedef struct ADPCM_DecoderState size_t pos; } input; - /* Current ADPCM block in the ADPCM data above. */ + // Current ADPCM block in the ADPCM data above. struct { Uint8 *data; @@ -78,7 +78,7 @@ typedef struct ADPCM_DecoderState size_t pos; } block; - /* Decoded 16-bit PCM data. */ + // Decoded 16-bit PCM data. struct { Sint16 *data; @@ -91,7 +91,7 @@ typedef struct MS_ADPCM_CoeffData { Uint16 coeffcount; Sint16 *coeff; - Sint16 aligndummy; /* Has to be last member. */ + Sint16 aligndummy; // Has to be last member. } MS_ADPCM_CoeffData; typedef struct MS_ADPCM_ChannelState @@ -342,18 +342,18 @@ static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) const size_t trailingdata = datalength % file->format.blockalign; if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) { - /* The size of the data chunk must be a multiple of the block size. */ + // The size of the data chunk must be a multiple of the block size. if (datalength < blockheadersize || trailingdata > 0) { return SDL_SetError("Truncated MS ADPCM block"); } } - /* Calculate number of sample frames that will be decoded. */ + // Calculate number of sample frames that will be decoded. file->sampleframes = (Sint64)availableblocks * format->samplesperblock; if (trailingdata > 0) { - /* The last block is truncated. Check if we can get any samples out of it. */ + // The last block is truncated. Check if we can get any samples out of it. if (file->trunchint == TruncDropFrame) { - /* Drop incomplete sample frame. */ + // Drop incomplete sample frame. if (trailingdata >= blockheadersize) { size_t trailingsamples = 2 + (trailingdata - blockheadersize) * 8 / blockframebitsize; if (trailingsamples > format->samplesperblock) { @@ -384,7 +384,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) size_t i, coeffcount; MS_ADPCM_CoeffData *coeffdata; - /* Sanity checks. */ + // Sanity checks. /* While it's clear how IMA ADPCM handles more than two channels, the nibble * order of MS ADPCM makes it awkward. The Standards Update does not talk @@ -398,7 +398,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) return SDL_SetError("Invalid MS ADPCM bits per sample of %u", (unsigned int)format->bitspersample); } - /* The block size must be big enough to contain the block header. */ + // The block size must be big enough to contain the block header. if (format->blockalign < blockheadersize) { return SDL_SetError("Invalid MS ADPCM block size (nBlockAlign)"); } @@ -419,7 +419,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) } format->samplesperblock = chunk->data[18] | ((Uint16)chunk->data[19] << 8); - /* Number of coefficient pairs. A pair has two 16-bit integers. */ + // Number of coefficient pairs. A pair has two 16-bit integers. coeffcount = chunk->data[20] | ((size_t)chunk->data[21] << 8); /* bPredictor, the integer offset into the coefficients array, is only * 8 bits. It can only address the first 256 coefficients. Let's limit @@ -438,14 +438,14 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) } coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4); - file->decoderdata = coeffdata; /* Freed in cleanup. */ + file->decoderdata = coeffdata; // Freed in cleanup. if (!coeffdata) { return -1; } coeffdata->coeff = &coeffdata->aligndummy; coeffdata->coeffcount = (Uint16)coeffcount; - /* Copy the 16-bit pairs. */ + // Copy the 16-bit pairs. for (i = 0; i < coeffcount * 2; i++) { Sint32 c = chunk->data[22 + i * 2] | ((Sint32)chunk->data[23 + i * 2] << 8); if (c >= 0x8000) { @@ -504,7 +504,7 @@ static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sampl Uint32 delta = cstate->delta; new_sample = (sample1 * cstate->coeff1 + sample2 * cstate->coeff2) / 256; - /* The nibble is a signed 4-bit error delta. */ + // The nibble is a signed 4-bit error delta. errordelta = (Sint32)nybble - (nybble >= 0x08 ? 0x10 : 0); new_sample += (Sint32)delta * errordelta; if (new_sample < min_audioval) { @@ -538,7 +538,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) for (c = 0; c < channels; c++) { size_t o = c; - /* Load the coefficient pair into the channel state. */ + // Load the coefficient pair into the channel state. coeffindex = state->block.data[o]; if (coeffindex > ddata->coeffcount) { return SDL_SetError("Invalid MS ADPCM coefficient index in block header"); @@ -546,7 +546,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) cstate[c].coeff1 = ddata->coeff[coeffindex * 2]; cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1]; - /* Initial delta value. */ + // Initial delta value. o = (size_t)channels + c * 2; cstate[c].delta = state->block.data[o] | ((Uint16)state->block.data[o + 1] << 8); @@ -572,10 +572,10 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) state->block.pos += state->blockheadersize; - /* Skip second sample frame that came from the header. */ + // Skip second sample frame that came from the header. state->output.pos += state->channels; - /* Header provided two sample frames. */ + // Header provided two sample frames. state->framesleft -= 2; return 0; @@ -611,12 +611,12 @@ static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) } else if (blockpos < blocksize) { nybble = state->block.data[blockpos++] | 0x4000; } else { - /* Out of input data. Drop the incomplete frame and return. */ + // Out of input data. Drop the incomplete frame and return. state->output.pos = outpos - c; return -1; } - /* Load previous samples which may come from the block header. */ + // Load previous samples which may come from the block header. sample1 = state->output.data[outpos - channels]; sample2 = state->output.data[outpos - channels * 2]; @@ -645,13 +645,13 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) SDL_zeroa(cstate); if (chunk->size != chunk->length) { - /* Could not read everything. Recalculate number of sample frames. */ + // Could not read everything. Recalculate number of sample frames. if (MS_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) { return -1; } } - /* Nothing to decode, nothing to return. */ + // Nothing to decode, nothing to return. if (file->sampleframes == 0) { *audio_buf = NULL; *audio_len = 0; @@ -671,7 +671,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) state.input.size = chunk->size; state.input.pos = 0; - /* The output size in bytes. May get modified if data is truncated. */ + // The output size in bytes. May get modified if data is truncated. outputsize = (size_t)state.framestotal; if (SafeMult(&outputsize, state.framesize)) { return SDL_SetError("WAVE file too big"); @@ -688,7 +688,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) state.cstate = cstate; - /* Decode block by block. A truncated block will stop the decoding. */ + // Decode block by block. A truncated block will stop the decoding. bytesleft = state.input.size - state.input.pos; while (state.framesleft > 0 && bytesleft >= state.blockheadersize) { state.block.data = state.input.data + state.input.pos; @@ -696,29 +696,29 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) state.block.pos = 0; if (state.output.size - state.output.pos < (Uint64)state.framesleft * state.channels) { - /* Somehow didn't allocate enough space for the output. */ + // Somehow didn't allocate enough space for the output. SDL_free(state.output.data); return SDL_SetError("Unexpected overflow in MS ADPCM decoder"); } - /* Initialize decoder with the values from the block header. */ + // Initialize decoder with the values from the block header. result = MS_ADPCM_DecodeBlockHeader(&state); if (result < 0) { SDL_free(state.output.data); return -1; } - /* Decode the block data. It stores the samples directly in the output. */ + // Decode the block data. It stores the samples directly in the output. result = MS_ADPCM_DecodeBlockData(&state); if (result < 0) { - /* Unexpected end. Stop decoding and return partial data if necessary. */ + // Unexpected end. Stop decoding and return partial data if necessary. if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) { SDL_free(state.output.data); return SDL_SetError("Truncated data chunk"); } else if (file->trunchint != TruncDropFrame) { state.output.pos -= state.output.pos % (state.samplesperblock * state.channels); } - outputsize = state.output.pos * sizeof(Sint16); /* Can't overflow, is always smaller. */ + outputsize = state.output.pos * sizeof(Sint16); // Can't overflow, is always smaller. break; } @@ -741,16 +741,16 @@ static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) const size_t trailingdata = datalength % format->blockalign; if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) { - /* The size of the data chunk must be a multiple of the block size. */ + // The size of the data chunk must be a multiple of the block size. if (datalength < blockheadersize || trailingdata > 0) { return SDL_SetError("Truncated IMA ADPCM block"); } } - /* Calculate number of sample frames that will be decoded. */ + // Calculate number of sample frames that will be decoded. file->sampleframes = (Uint64)availableblocks * format->samplesperblock; if (trailingdata > 0) { - /* The last block is truncated. Check if we can get any samples out of it. */ + // The last block is truncated. Check if we can get any samples out of it. if (file->trunchint == TruncDropFrame && trailingdata > blockheadersize - 2) { /* The sample frame in the header of the truncated block is present. * Drop incomplete sample frames. @@ -758,7 +758,7 @@ static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength) size_t trailingsamples = 1; if (trailingdata > blockheadersize) { - /* More data following after the header. */ + // More data following after the header. const size_t trailingblockdata = trailingdata - blockheadersize; const size_t trailingsubblockdata = trailingblockdata % subblockframesize; trailingsamples += (trailingblockdata / subblockframesize) * 8; @@ -794,9 +794,9 @@ static int IMA_ADPCM_Init(WaveFile *file, size_t datalength) const size_t blockframebitsize = (size_t)format->bitspersample * format->channels; const size_t blockdatasamples = (blockdatasize * 8) / blockframebitsize; - /* Sanity checks. */ + // Sanity checks. - /* IMA ADPCM can also have 3-bit samples, but it's not supported by SDL at this time. */ + // IMA ADPCM can also have 3-bit samples, but it's not supported by SDL at this time. if (format->bitspersample == 3) { return SDL_SetError("3-bit IMA ADPCM currently not supported"); } else if (format->bitspersample != 4) { @@ -815,7 +815,7 @@ static int IMA_ADPCM_Init(WaveFile *file, size_t datalength) * format because the extensible header has wSampePerBlocks too. */ } else { - /* The Standards Update says there 'should' be 2 bytes for wSamplesPerBlock. */ + // The Standards Update says there 'should' be 2 bytes for wSamplesPerBlock. if (chunk->size >= 20 && format->extsize >= 2) { format->samplesperblock = chunk->data[18] | ((Uint16)chunk->data[19] << 8); } @@ -874,17 +874,17 @@ static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 ny Sint32 sample, delta; Sint8 index = *cindex; - /* Clamp index into valid range. */ + // Clamp index into valid range. if (index > 88) { index = 88; } else if (index < 0) { index = 0; } - /* explicit cast to avoid gcc warning about using 'char' as array index */ + // explicit cast to avoid gcc warning about using 'char' as array index step = step_table[(size_t)index]; - /* Update index value */ + // Update index value *cindex = index + index_table_4b[nybble]; /* This calculation uses shifts and additions because multiplications were @@ -909,7 +909,7 @@ static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 ny sample = lastsample + delta; - /* Clamp output sample */ + // Clamp output sample if (sample > max_audioval) { sample = max_audioval; } else if (sample < min_audioval) { @@ -928,18 +928,18 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) for (c = 0; c < state->channels; c++) { size_t o = state->block.pos + c * 4; - /* Extract the sample from the header. */ + // Extract the sample from the header. Sint32 sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8); if (sample >= 0x8000) { sample -= 0x10000; } state->output.data[state->output.pos++] = (Sint16)sample; - /* Channel step index. */ + // Channel step index. step = (Sint16)state->block.data[o + 2]; cstate[c] = (Sint8)(step > 0x80 ? step - 0x100 : step); - /* Reserved byte in block header, should be 0. */ + // Reserved byte in block header, should be 0. if (state->block.data[o + 3] != 0) { /* Uh oh, corrupt data? Buggy code? */; } @@ -947,7 +947,7 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state) state->block.pos += state->blockheadersize; - /* Header provided one sample frame. */ + // Header provided one sample frame. state->framesleft--; return 0; @@ -980,14 +980,14 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) bytesrequired = (blockframesleft + 7) / 8 * subblockframesize; if (blockleft < bytesrequired) { - /* Data truncated. Calculate how many samples we can get out if it. */ + // Data truncated. Calculate how many samples we can get out if it. const size_t guaranteedframes = blockleft / subblockframesize; const size_t remainingbytes = blockleft % subblockframesize; blockframesleft = guaranteedframes; if (remainingbytes > subblockframesize - 4) { blockframesleft += (Sint64)(remainingbytes % 4) * 2; } - /* Signal the truncation. */ + // Signal the truncation. retval = -1; } @@ -1001,7 +1001,7 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state) for (c = 0; c < channels; c++) { Uint8 nybble = 0; - /* Load previous sample which may come from the block header. */ + // Load previous sample which may come from the block header. Sint16 sample = state->output.data[outpos + c - channels]; for (i = 0; i < subblocksamples; i++) { @@ -1036,13 +1036,13 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len Sint8 *cstate; if (chunk->size != chunk->length) { - /* Could not read everything. Recalculate number of sample frames. */ + // Could not read everything. Recalculate number of sample frames. if (IMA_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) { return -1; } } - /* Nothing to decode, nothing to return. */ + // Nothing to decode, nothing to return. if (file->sampleframes == 0) { *audio_buf = NULL; *audio_len = 0; @@ -1062,7 +1062,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len state.input.size = chunk->size; state.input.pos = 0; - /* The output size in bytes. May get modified if data is truncated. */ + // The output size in bytes. May get modified if data is truncated. outputsize = (size_t)state.framestotal; if (SafeMult(&outputsize, state.framesize)) { return SDL_SetError("WAVE file too big"); @@ -1084,7 +1084,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len } state.cstate = cstate; - /* Decode block by block. A truncated block will stop the decoding. */ + // Decode block by block. A truncated block will stop the decoding. bytesleft = state.input.size - state.input.pos; while (state.framesleft > 0 && bytesleft >= state.blockheadersize) { state.block.data = state.input.data + state.input.pos; @@ -1092,21 +1092,21 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len state.block.pos = 0; if (state.output.size - state.output.pos < (Uint64)state.framesleft * state.channels) { - /* Somehow didn't allocate enough space for the output. */ + // Somehow didn't allocate enough space for the output. SDL_free(state.output.data); SDL_free(cstate); return SDL_SetError("Unexpected overflow in IMA ADPCM decoder"); } - /* Initialize decoder with the values from the block header. */ + // Initialize decoder with the values from the block header. result = IMA_ADPCM_DecodeBlockHeader(&state); if (result == 0) { - /* Decode the block data. It stores the samples directly in the output. */ + // Decode the block data. It stores the samples directly in the output. result = IMA_ADPCM_DecodeBlockData(&state); } if (result < 0) { - /* Unexpected end. Stop decoding and return partial data if necessary. */ + // Unexpected end. Stop decoding and return partial data if necessary. if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) { SDL_free(state.output.data); SDL_free(cstate); @@ -1114,7 +1114,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len } else if (file->trunchint != TruncDropFrame) { state.output.pos -= state.output.pos % (state.samplesperblock * state.channels); } - outputsize = state.output.pos * sizeof(Sint16); /* Can't overflow, is always smaller. */ + outputsize = state.output.pos * sizeof(Sint16); // Can't overflow, is always smaller. break; } @@ -1134,12 +1134,12 @@ static int LAW_Init(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; - /* Standards Update requires this to be 8. */ + // Standards Update requires this to be 8. if (format->bitspersample != 8) { return SDL_SetError("Invalid companded bits per sample of %u", (unsigned int)format->bitspersample); } - /* Not going to bother with weird padding. */ + // Not going to bother with weird padding. if (format->blockalign != format->channels) { return SDL_SetError("Unsupported block alignment"); } @@ -1212,7 +1212,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) } } - /* Nothing to decode, nothing to return. */ + // Nothing to decode, nothing to return. if (file->sampleframes == 0) { *audio_buf = NULL; *audio_len = 0; @@ -1231,7 +1231,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return SDL_SetError("WAVE file too big"); } - /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ + // 1 to avoid allocating zero bytes, to keep static analysis happy. src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); if (!src) { return -1; @@ -1310,7 +1310,7 @@ static int PCM_Init(WaveFile *file, size_t datalength) case 16: case 24: case 32: - /* These are supported. */ + // These are supported. break; default: return SDL_SetError("%u-bit PCM format not supported", (unsigned int)format->bitspersample); @@ -1324,7 +1324,7 @@ static int PCM_Init(WaveFile *file, size_t datalength) /* It wouldn't be that hard to support more exotic block sizes, but * the most common formats should do for now. */ - /* Make sure we're a multiple of the blockalign, at least. */ + // Make sure we're a multiple of the blockalign, at least. if ((format->channels * format->bitspersample) % (format->blockalign * 8)) { return SDL_SetError("Unsupported block alignment"); } @@ -1362,20 +1362,20 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 * return SDL_SetError("WAVE file too big"); } - /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ + // 1 to avoid allocating zero bytes, to keep static analysis happy. ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); if (!ptr) { return -1; } - /* This pointer is now invalid. */ + // This pointer is now invalid. chunk->data = NULL; chunk->size = 0; *audio_buf = ptr; *audio_len = (Uint32)expanded_len; - /* work from end to start, since we're expanding in-place. */ + // work from end to start, since we're expanding in-place. for (i = sample_count; i > 0; i--) { const size_t o = i - 1; uint8_t b[4]; @@ -1407,14 +1407,14 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) } } - /* Nothing to decode, nothing to return. */ + // Nothing to decode, nothing to return. if (file->sampleframes == 0) { *audio_buf = NULL; *audio_len = 0; return 0; } - /* 24-bit samples get shifted to 32 bits. */ + // 24-bit samples get shifted to 32 bits. if (format->encoding == PCM_CODE && format->bitspersample == 24) { return PCM_ConvertSint24ToSint32(file, audio_buf, audio_len); } @@ -1429,7 +1429,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) *audio_buf = chunk->data; *audio_len = (Uint32)outputsize; - /* This pointer is going to be returned to the caller. Prevent free in cleanup. */ + // This pointer is going to be returned to the caller. Prevent free in cleanup. chunk->data = NULL; chunk->size = 0; @@ -1507,21 +1507,21 @@ static int WaveNextChunk(SDL_IOStream *src, WaveChunk *chunk) Uint32 chunkheader[2]; Sint64 nextposition = chunk->position + chunk->length; - /* Data is no longer valid after this function returns. */ + // Data is no longer valid after this function returns. WaveFreeChunkData(chunk); - /* Error on overflows. */ + // Error on overflows. if (SDL_MAX_SINT64 - chunk->length < chunk->position || SDL_MAX_SINT64 - 8 < nextposition) { return -1; } - /* RIFF chunks have a 2-byte alignment. Skip padding byte. */ + // RIFF chunks have a 2-byte alignment. Skip padding byte. if (chunk->length & 1) { nextposition++; } if (SDL_SeekIO(src, nextposition, SDL_IO_SEEK_SET) != nextposition) { - /* Not sure how we ended up here. Just abort. */ + // Not sure how we ended up here. Just abort. return -2; } else if (SDL_ReadIO(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) { return -1; @@ -1549,13 +1549,13 @@ static int WaveReadPartialChunkData(SDL_IOStream *src, WaveChunk *chunk, size_t } if (SDL_SeekIO(src, chunk->position, SDL_IO_SEEK_SET) != chunk->position) { - /* Not sure how we ended up here. Just abort. */ + // Not sure how we ended up here. Just abort. return -2; } chunk->size = SDL_ReadIO(src, chunk->data, length); if (chunk->size != length) { - /* Expected to be handled by the caller. */ + // Expected to be handled by the caller. } } @@ -1573,7 +1573,7 @@ typedef struct WaveExtensibleGUID Uint8 guid[16]; } WaveExtensibleGUID; -/* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */ +// 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 \ @@ -1606,7 +1606,7 @@ static int WaveReadFormat(WaveFile *file) size_t fmtlen = chunk->size; if (fmtlen > SDL_MAX_SINT32) { - /* Limit given by SDL_IOFromConstMem. */ + // Limit given by SDL_IOFromConstMem. return SDL_SetError("Data of WAVE fmt chunk too big"); } fmtsrc = SDL_IOFromConstMem(chunk->data, (int)chunk->size); @@ -1623,7 +1623,7 @@ static int WaveReadFormat(WaveFile *file) } format->encoding = format->formattag; - /* This is PCM specific in the first version of the specification. */ + // This is PCM specific in the first version of the specification. if (fmtlen >= 16) { if (!SDL_ReadU16LE(fmtsrc, &format->bitspersample)) { return -1; @@ -1633,7 +1633,7 @@ static int WaveReadFormat(WaveFile *file) return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk"); } - /* The earlier versions also don't have this field. */ + // The earlier versions also don't have this field. if (fmtlen >= 18) { if (!SDL_ReadU16LE(fmtsrc, &format->extsize)) { return -1; @@ -1647,7 +1647,7 @@ static int WaveReadFormat(WaveFile *file) * to be useful working when they use this format flag. */ - /* Extensible header must be at least 22 bytes. */ + // Extensible header must be at least 22 bytes. if (fmtlen < 40 || format->extsize < 22) { SDL_CloseIO(fmtsrc); return SDL_SetError("Extensible WAVE header too small"); @@ -1670,7 +1670,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength) { WaveFormat *format = &file->format; - /* Check for some obvious issues. */ + // Check for some obvious issues. if (format->channels == 0) { return SDL_SetError("Invalid number of channels"); @@ -1682,7 +1682,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength) return SDL_SetError("Sample rate exceeds limit of %d", INT_MAX); } - /* Reject invalid fact chunks in strict mode. */ + // Reject invalid fact chunks in strict mode. if (file->facthint == FactStrict && file->fact.status == -1) { return SDL_SetError("Invalid fact chunk in WAVE file"); } @@ -1697,22 +1697,22 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength) case MULAW_CODE: case MS_ADPCM_CODE: case IMA_ADPCM_CODE: - /* These formats require a fact chunk. */ + // These formats require a fact chunk. if (file->facthint == FactStrict && file->fact.status <= 0) { return SDL_SetError("Missing fact chunk in WAVE file"); } SDL_FALLTHROUGH; case PCM_CODE: - /* All supported formats require a non-zero bit depth. */ + // All supported formats require a non-zero bit depth. if (file->chunk.size < 16) { return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk"); } else if (format->bitspersample == 0) { return SDL_SetError("Invalid bits per sample"); } - /* All supported formats must have a proper block size. */ + // All supported formats must have a proper block size. if (format->blockalign == 0) { - format->blockalign = 1; /* force it to 1 if it was unset. */ + format->blockalign = 1; // force it to 1 if it was unset. } /* If the fact chunk is valid and the appropriate hint is set, the @@ -1727,7 +1727,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength) } } - /* Check the format for encoding specific issues and initialize decoders. */ + // Check the format for encoding specific issues and initialize decoders. switch (format->encoding) { case PCM_CODE: case IEEE_FLOAT_CODE: @@ -1805,24 +1805,24 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint return SDL_SetError("Could not read RIFF header"); } - /* Check main WAVE file identifiers. */ + // Check main WAVE file identifiers. if (RIFFchunk.fourcc == RIFF) { Uint32 formtype; - /* Read the form type. "WAVE" expected. */ + // Read the form type. "WAVE" expected. if (!SDL_ReadU32LE(src, &formtype)) { return SDL_SetError("Could not read RIFF form type"); } else if (formtype != WAVE) { return SDL_SetError("RIFF form type is not WAVE (not a Waveform file)"); } } else if (RIFFchunk.fourcc == WAVE) { - /* RIFF chunk missing or skipped. Length unknown. */ + // RIFF chunk missing or skipped. Length unknown. RIFFchunk.position = 0; RIFFchunk.length = 0; } else { return SDL_SetError("Could not find RIFF or WAVE identifiers (not a Waveform file)"); } - /* The 4-byte form type is immediately followed by the first chunk.*/ + // The 4-byte form type is immediately followed by the first chunk. chunk->position = RIFFchunk.position + 4; /* Use the RIFF chunk size to limit the search for the chunks. This is not @@ -1854,18 +1854,18 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint * currently also ignores cue, list, and slnt chunks. */ while ((Uint64)RIFFend > (Uint64)chunk->position + chunk->length + (chunk->length & 1)) { - /* Abort after too many chunks or else corrupt files may waste time. */ + // Abort after too many chunks or else corrupt files may waste time. if (chunkcount++ >= chunkcountlimit) { return SDL_SetError("Chunk count in WAVE file exceeds limit of %" SDL_PRIu32, chunkcountlimit); } result = WaveNextChunk(src, chunk); if (result < 0) { - /* Unexpected EOF. Corrupt file or I/O issues. */ + // Unexpected EOF. Corrupt file or I/O issues. if (file->trunchint == TruncVeryStrict) { return SDL_SetError("Unexpected end of WAVE file"); } - /* Let the checks after this loop sort this issue out. */ + // Let the checks after this loop sort this issue out. break; } else if (result == -2) { return SDL_SetError("Could not seek to WAVE chunk header"); @@ -1873,9 +1873,9 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint if (chunk->fourcc == FMT) { if (fmtchunk.fourcc == FMT) { - /* Multiple fmt chunks. Ignore or error? */ + // Multiple fmt chunks. Ignore or error? } else { - /* The fmt chunk must occur before the data chunk. */ + // The fmt chunk must occur before the data chunk. if (datachunk.fourcc == DATA) { return SDL_SetError("fmt chunk after data chunk in WAVE file"); } @@ -1896,7 +1896,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint if (chunk->length < 4) { file->fact.status = -1; } else { - /* Let's use src directly, it's just too convenient. */ + // Let's use src directly, it's just too convenient. Sint64 position = SDL_SeekIO(src, chunk->position, SDL_IO_SEEK_SET); if (position == chunk->position && SDL_ReadU32LE(src, &file->fact.samplelength)) { file->fact.status = 1; @@ -1926,17 +1926,17 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint */ lastchunkpos = chunk->position + chunk->length; - /* The fmt chunk is mandatory. */ + // The fmt chunk is mandatory. if (fmtchunk.fourcc != FMT) { return SDL_SetError("Missing fmt chunk in WAVE file"); } - /* A data chunk must be present. */ + // A data chunk must be present. if (datachunk.fourcc != DATA) { return SDL_SetError("Missing data chunk in WAVE file"); } - /* Check if the last chunk has all of its data in verystrict mode. */ + // Check if the last chunk has all of its data in verystrict mode. if (file->trunchint == TruncVeryStrict) { - /* data chunk is handled later. */ + // data chunk is handled later. if (chunk->fourcc != DATA && chunk->length > 0) { Uint8 tmp; Uint64 position = (Uint64)chunk->position + chunk->length - 1; @@ -1948,7 +1948,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint } } - /* Process fmt chunk. */ + // Process fmt chunk. *chunk = fmtchunk; /* No need to read more than 1046 bytes of the fmt chunk data with the @@ -1980,7 +1980,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint WaveFreeChunkData(chunk); - /* Process data chunk. */ + // Process data chunk. *chunk = datachunk; if (chunk->length > 0) { @@ -1993,14 +1993,14 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint } if (chunk->length != chunk->size) { - /* I/O issues or corrupt file. */ + // I/O issues or corrupt file. if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) { return SDL_SetError("Could not read data of WAVE data chunk"); } - /* The decoders handle this truncation. */ + // The decoders handle this truncation. } - /* Decode or convert the data if necessary. */ + // Decode or convert the data if necessary. switch (format->encoding) { case PCM_CODE: case IEEE_FLOAT_CODE: @@ -2038,7 +2038,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint case IMA_ADPCM_CODE: case ALAW_CODE: case MULAW_CODE: - /* These can be easily stored in the byte order of the system. */ + // These can be easily stored in the byte order of the system. spec->format = SDL_AUDIO_S16; break; case IEEE_FLOAT_CODE: @@ -2052,12 +2052,12 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint case 16: spec->format = SDL_AUDIO_S16LE; break; - case 24: /* Has been shifted to 32 bits. */ + case 24: // Has been shifted to 32 bits. case 32: spec->format = SDL_AUDIO_S32LE; break; default: - /* Just in case something unexpected happened in the checks. */ + // Just in case something unexpected happened in the checks. return SDL_SetError("Unexpected %u-bit PCM data format", (unsigned int)format->bitspersample); } break; @@ -2065,7 +2065,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint return SDL_SetError("Unexpected data format"); } - /* Report the end position back to the cleanup code. */ + // Report the end position back to the cleanup code. if (RIFFlengthknown) { chunk->position = RIFFend; } else { @@ -2090,9 +2090,9 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin *audio_len = 0; } - /* Make sure we are passed a valid data source */ + // Make sure we are passed a valid data source if (!src) { - goto done; /* Error may come from SDL_IOStream. */ + goto done; // Error may come from SDL_IOStream. } else if (!spec) { SDL_InvalidParamError("spec"); goto done; @@ -2116,7 +2116,7 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin audio_len = 0; } - /* Cleanup */ + // Cleanup if (!closeio) { SDL_SeekIO(src, file.chunk.position, SDL_IO_SEEK_SET); } diff --git a/src/audio/SDL_wave.h b/src/audio/SDL_wave.h index 66128f7520..47fe2b5144 100644 --- a/src/audio/SDL_wave.h +++ b/src/audio/SDL_wave.h @@ -20,21 +20,21 @@ */ #include "SDL_internal.h" -/* RIFF WAVE files are little-endian */ +// RIFF WAVE files are little-endian /*******************************************/ -/* Define values for Microsoft WAVE format */ +// 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" */ -/* Format tags */ +// 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" +// Format tags #define UNKNOWN_CODE 0x0000 #define PCM_CODE 0x0001 #define MS_ADPCM_CODE 0x0002 @@ -46,30 +46,30 @@ #define MPEGLAYER3_CODE 0x0055 #define EXTENSIBLE_CODE 0xFFFE -/* Stores the WAVE format information. */ +// 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. */ Uint16 extsize; - /* Extensible WAVE header fields */ + // Extensible WAVE header fields Uint16 validsamplebits; - Uint32 samplesperblock; /* For compressed formats. Can be zero. Actually 16 bits in the header. */ + 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. */ +// Stores information on the fact chunk. typedef struct WaveFact { /* Represents the state of the fact chunk in the WAVE file. @@ -88,20 +88,20 @@ typedef struct WaveFact * because a compressed block is usually decoded to a fixed number of * sample frames. */ - Uint32 samplelength; /* Raw sample length value from the fact chunk. */ + Uint32 samplelength; // Raw sample length value from the fact chunk. } WaveFact; -/* Generic struct for the chunks in the WAVE file. */ +// Generic struct for the chunks in the WAVE file. typedef struct WaveChunk { - Uint32 fourcc; /* FOURCC of the chunk. */ - Uint32 length; /* Size of the chunk data. */ - Sint64 position; /* Position of the data in the stream. */ - Uint8 *data; /* When allocated, this points to the chunk data. length is used for the memory allocation size. */ - size_t size; /* Number of bytes in data that could be read from the stream. Can be smaller than length. */ + Uint32 fourcc; // FOURCC of the chunk. + Uint32 length; // Size of the chunk data. + Sint64 position; // Position of the data in the stream. + Uint8 *data; // When allocated, this points to the chunk data. length is used for the memory allocation size. + size_t size; // Number of bytes in data that could be read from the stream. Can be smaller than length. } WaveChunk; -/* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */ +// Controls how the size of the RIFF chunk affects the loading of a WAVE file. typedef enum WaveRiffSizeHint { RiffSizeNoHint, @@ -111,7 +111,7 @@ typedef enum WaveRiffSizeHint RiffSizeMaximum } WaveRiffSizeHint; -/* Controls how a truncated WAVE file is handled. */ +// Controls how a truncated WAVE file is handled. typedef enum WaveTruncationHint { TruncNoHint, @@ -121,7 +121,7 @@ typedef enum WaveTruncationHint TruncDropBlock } WaveTruncationHint; -/* Controls how the fact chunk affects the loading of a WAVE file. */ +// Controls how the fact chunk affects the loading of a WAVE file. typedef enum WaveFactChunkHint { FactNoHint, @@ -143,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/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index aacae90e59..e500af6de6 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -883,7 +883,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) } #else // Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS - #endif /* SDL_PLATFORM_TVOS */ + #endif // SDL_PLATFORM_TVOS } #endif diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index 508843895e..ab0b2390c7 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -29,7 +29,7 @@ // just turn off clang-format for this whole file, this INDENT_OFF stuff on // each EM_ASM section is ugly. -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static Uint8 *EMSCRIPTENAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) { @@ -346,6 +346,6 @@ AudioBootStrap EMSCRIPTENAUDIO_bootstrap = { "emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, SDL_FALSE }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on #endif // SDL_AUDIO_DRIVER_EMSCRIPTEN diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index d2e5cc8d58..3846be075b 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -47,7 +47,7 @@ static void NETBSDAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Au static void NETBSDAUDIO_Status(SDL_AudioDevice *device) { #ifdef DEBUG_AUDIO - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off audio_info_t info; const struct audio_prinfo *prinfo; @@ -109,7 +109,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device) "", device->spec.format, device->buffer_size); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on #endif // DEBUG_AUDIO } diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index f1e71f59b6..e38a1a4650 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -48,7 +48,7 @@ static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0x static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } }; #ifdef __IAudioClient3_INTERFACE_DEFINED__ static const IID SDL_IID_IAudioClient3 = { 0x7ed4ee07, 0x8e67, 0x4cd4, { 0x8c, 0x1a, 0x2b, 0x7a, 0x59, 0x87, 0xad, 0x42 } }; -#endif /**/ +#endif // // WASAPI is _really_ particular about various things happening on the same thread, for COM and such, diff --git a/src/camera/emscripten/SDL_camera_emscripten.c b/src/camera/emscripten/SDL_camera_emscripten.c index 79fa8e3230..b22e8d8f55 100644 --- a/src/camera/emscripten/SDL_camera_emscripten.c +++ b/src/camera/emscripten/SDL_camera_emscripten.c @@ -30,7 +30,7 @@ // just turn off clang-format for this whole file, this INDENT_OFF stuff on // each EM_ASM section is ugly. -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off EM_JS_DEPS(sdlcamera, "$dynCall"); @@ -261,7 +261,7 @@ CameraBootStrap EMSCRIPTENCAMERA_bootstrap = { "emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, SDL_FALSE }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on #endif // SDL_CAMERA_DRIVER_EMSCRIPTEN diff --git a/src/camera/mediafoundation/SDL_camera_mediafoundation.c b/src/camera/mediafoundation/SDL_camera_mediafoundation.c index e392a18b24..f080ab94ae 100644 --- a/src/camera/mediafoundation/SDL_camera_mediafoundation.c +++ b/src/camera/mediafoundation/SDL_camera_mediafoundation.c @@ -449,7 +449,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, *timestampNS = timestamp100NS * 100; // the timestamps are in 100-nanosecond increments; move to full nanoseconds. } - ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); /*IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer);*/ + ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); // IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer); if (FAILED(ret)) { SDL_free(objs); @@ -546,7 +546,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, } IMFMediaBuffer *buffer = NULL; - ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); /*IMFSample_GetBufferByIndex(sample, 0, &buffer);*/ + ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); // IMFSample_GetBufferByIndex(sample, 0, &buffer); if (FAILED(ret)) { retval = -1; @@ -660,7 +660,7 @@ static HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride) GUID subtype = GUID_NULL; UINT32 width = 0; - /* UINT32 height = 0; */ + // UINT32 height = 0; UINT64 val = 0; // Get the subtype and the image size. @@ -675,7 +675,7 @@ static HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride) } width = (UINT32) (val >> 32); - /* height = (UINT32) val; */ + // height = (UINT32) val; ret = pMFGetStrideForBitmapInfoHeader(subtype.Data1, width, &lStride); if (FAILED(ret)) { diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c index 61bccf7cf6..96e62dd186 100644 --- a/src/core/SDL_core_unsupported.c +++ b/src/core/SDL_core_unsupported.c @@ -77,7 +77,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) return SDL_Unsupported(); } -SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); /* SDL_WindowsMessageHook callback */ +SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); // SDL_WindowsMessageHook callback void SDL_SetWindowsMessageHook(void *callback, void *userdata) { (void)callback; @@ -95,15 +95,15 @@ void SDL_UnregisterApp(void) #ifndef SDL_PLATFORM_WINRT -/* Returns SDL_WinRT_DeviceFamily enum */ +// Returns SDL_WinRT_DeviceFamily enum SDL_DECLSPEC int SDLCALL SDL_GetWinRTDeviceFamily(void); int SDL_GetWinRTDeviceFamily(void) { SDL_Unsupported(); - return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */ + return 0; // SDL_WINRT_DEVICEFAMILY_UNKNOWN } -SDL_DECLSPEC const char *SDLCALL SDL_GetWinRTFSPath(int pathType); /* SDL_WinRT_Path pathType */ +SDL_DECLSPEC const char *SDLCALL SDL_GetWinRTFSPath(int pathType); // SDL_WinRT_Path pathType const char *SDL_GetWinRTFSPath(int pathType) { (void)pathType; @@ -224,6 +224,6 @@ Sint32 JNI_OnLoad(void *vm, void *reserved) (void)vm; (void)reserved; SDL_Unsupported(); - return -1; /* JNI_ERR */ + return -1; // JNI_ERR } #endif diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 1c10815cdd..1a9bcc81f0 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -52,12 +52,12 @@ #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 */ +// Audio encoding definitions #define ENCODING_PCM_8BIT 3 #define ENCODING_PCM_16BIT 2 #define ENCODING_PCM_FLOAT 4 -/* Java class SDLActivity */ +// Java class SDLActivity JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)( JNIEnv *env, jclass cls); @@ -232,7 +232,7 @@ static JNINativeMethod SDLActivity_tab[] = { { "onNativeFileDialog", "(I[Ljava/lang/String;I)V", SDL_JAVA_INTERFACE(onNativeFileDialog) } }; -/* Java class SDLInputConnection */ +// Java class SDLInputConnection JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( JNIEnv *env, jclass cls, jstring text, jint newCursorPosition); @@ -246,7 +246,7 @@ static JNINativeMethod SDLInputConnection_tab[] = { { "nativeGenerateScancodeForUnichar", "(C)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar) } }; -/* Java class SDLAudioManager */ +// Java class SDLAudioManager JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)( JNIEnv *env, jclass jcls); @@ -264,7 +264,7 @@ static JNINativeMethod SDLAudioManager_tab[] = { { "removeAudioDevice", "(ZI)V", SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice) } }; -/* Java class SDLControllerManager */ +// Java class SDLControllerManager JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)( JNIEnv *env, jclass jcls); @@ -313,8 +313,8 @@ static JNINativeMethod SDLControllerManager_tab[] = { { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) } }; -/* Uncomment this to log messages entering and exiting methods in this file */ -/* #define DEBUG_JNI */ +// Uncomment this to log messages entering and exiting methods in this file +// #define DEBUG_JNI static void checkJNIReady(void); @@ -330,10 +330,10 @@ static pthread_key_t mThreadKey; static pthread_once_t key_once = PTHREAD_ONCE_INIT; static JavaVM *mJavaVM = NULL; -/* Main activity */ +// Main activity static jclass mActivityClass; -/* method signatures */ +// method signatures static jmethodID midClipboardGetText; static jmethodID midClipboardHasText; static jmethodID midClipboardSetText; @@ -366,25 +366,25 @@ static jmethodID midSupportsRelativeMouse; static jmethodID midOpenFileDescriptor; static jmethodID midShowFileDialog; -/* audio manager */ +// audio manager static jclass mAudioManagerClass; -/* method signatures */ +// method signatures static jmethodID midRegisterAudioDeviceCallback; static jmethodID midUnregisterAudioDeviceCallback; static jmethodID midAudioSetThreadPriority; -/* controller manager */ +// controller manager static jclass mControllerManagerClass; -/* method signatures */ +// method signatures static jmethodID midPollInputDevices; static jmethodID midPollHapticDevices; static jmethodID midHapticRun; static jmethodID midHapticRumble; static jmethodID midHapticStop; -/* Accelerometer data storage */ +// Accelerometer data storage static SDL_DisplayOrientation displayNaturalOrientation; static SDL_DisplayOrientation displayCurrentOrientation; static float fLastAccelerometer[3]; @@ -392,13 +392,13 @@ static SDL_bool bHasNewData; static SDL_bool bHasEnvironmentVariables; -/* Android AssetManager */ +// Android AssetManager static void Internal_Android_Create_AssetManager(void); static void Internal_Android_Destroy_AssetManager(void); static AAssetManager *asset_manager = NULL; static jobject javaAssetManagerRef = 0; -/* Re-create activity hint */ +// Re-create activity hint static SDL_AtomicInt bAllowRecreateActivity; static SDL_Mutex *Android_ActivityMutex = NULL; @@ -433,7 +433,7 @@ static int Android_NumLifecycleEvents; * (except for some lost CPU cycles) */ -/* Set local storage value */ +// Set local storage value static int Android_JNI_SetEnv(JNIEnv *env) { int status = pthread_setspecific(mThreadKey, env); @@ -443,16 +443,16 @@ static int Android_JNI_SetEnv(JNIEnv *env) return status; } -/* Get local storage value */ +// Get local storage value JNIEnv *Android_JNI_GetEnv(void) { - /* Get JNIEnv from the Thread local storage */ + // Get JNIEnv from the Thread local storage JNIEnv *env = pthread_getspecific(mThreadKey); if (!env) { - /* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */ + // If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() int status; - /* There should be a JVM */ + // There should be a JVM if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return NULL; @@ -466,7 +466,7 @@ JNIEnv *Android_JNI_GetEnv(void) return NULL; } - /* Save JNIEnv into the Thread local storage */ + // Save JNIEnv into the Thread local storage if (Android_JNI_SetEnv(env) < 0) { return NULL; } @@ -475,13 +475,13 @@ JNIEnv *Android_JNI_GetEnv(void) return env; } -/* Set up an external thread for using JNI with Android_JNI_GetEnv() */ +// Set up an external thread for using JNI with Android_JNI_GetEnv() int Android_JNI_SetupThread(void) { JNIEnv *env; int status; - /* There should be a JVM */ + // There should be a JVM if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return 0; @@ -495,7 +495,7 @@ int Android_JNI_SetupThread(void) return 0; } - /* Save JNIEnv into the Thread local storage */ + // Save JNIEnv into the Thread local storage if (Android_JNI_SetEnv(env) < 0) { return 0; } @@ -503,10 +503,10 @@ int Android_JNI_SetupThread(void) return 1; } -/* Destructor called for each thread where mThreadKey is not NULL */ +// Destructor called for each thread where mThreadKey is not NULL 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 */ + // The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required JNIEnv *env = (JNIEnv *)value; if (env) { (*mJavaVM)->DetachCurrentThread(mJavaVM); @@ -514,7 +514,7 @@ static void Android_JNI_ThreadDestroyed(void *value) } } -/* Creation of local storage mThreadKey */ +// Creation of local storage mThreadKey static void Android_JNI_CreateKey(void) { int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed); @@ -540,7 +540,7 @@ static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod } } -/* Library init */ +// Library init JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { JNIEnv *env = NULL; @@ -565,14 +565,14 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) void checkJNIReady(void) { if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) { - /* We aren't fully initialized, let's just return. */ + // We aren't fully initialized, let's just return. return; } SDL_SetMainReady(); } -/* Get SDL version -- called before SDL_main() to verify JNI bindings */ +// Get SDL version -- called before SDL_main() to verify JNI bindings JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jclass cls) { char version[128]; @@ -582,12 +582,12 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jcla return (*env)->NewStringUTF(env, version); } -/* Activity initialization -- called before SDL_main() to initialize JNI bindings */ +// Activity initialization -- called before SDL_main() to initialize JNI bindings JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()"); - /* Start with a clean slate */ + // Start with a clean slate SDL_ClearError(); /* @@ -596,7 +596,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl */ Android_JNI_CreateKey_once(); - /* Save JNIEnv of SDLActivity */ + // Save JNIEnv of SDLActivity Android_JNI_SetEnv(env); if (!mJavaVM) { @@ -607,7 +607,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl * (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. ) */ if (!Android_ActivityMutex) { - Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */ + Android_ActivityMutex = SDL_CreateMutex(); // Could this be created twice if onCreate() is called a second time ? } if (!Android_ActivityMutex) { @@ -695,7 +695,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl checkJNIReady(); } -/* Audio initialization -- called before SDL_main() to initialize JNI bindings */ +// Audio initialization -- called before SDL_main() to initialize JNI bindings JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()"); @@ -719,7 +719,7 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jcl checkJNIReady(); } -/* Controller initialization -- called before SDL_main() to initialize JNI bindings */ +// Controller initialization -- called before SDL_main() to initialize JNI bindings JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()"); @@ -744,7 +744,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env checkJNIReady(); } -/* SDL main function prototype */ +// SDL main function prototype typedef int (*SDL_main_func)(int argc, char *argv[]); static int run_count = 0; @@ -781,7 +781,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeInitMainThread)( } run_count += 1; - /* Save JNIEnv of SDLThread */ + // Save JNIEnv of SDLThread Android_JNI_SetEnv(env); } @@ -793,7 +793,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeCleanupMainThread)( Android_JNI_SetEnv(NULL); } -/* Start up the SDL app */ +// Start up the SDL app JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, jstring library, jstring function, jobject array) { int status = -1; @@ -826,9 +826,9 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, char **argv; SDL_bool isstack; - /* Prepare the arguments. */ + // 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://github.com/love2d/love-android/issues/24 @@ -852,10 +852,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, } argv[argc] = NULL; - /* Run the application. */ + // Run the application. status = SDL_main(argc, argv); - /* Release the arguments. */ + // Release the arguments. for (i = 0; i < argc; ++i) { SDL_free(argv[i]); } @@ -873,8 +873,8 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, } (*env)->ReleaseStringUTFChars(env, library, library_file); - /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - /* exit(status); */ + // Do not issue an exit or the whole application will terminate instead of just the SDL thread + // exit(status); return status; } @@ -984,7 +984,7 @@ void Android_UnlockActivityMutex(void) SDL_UnlockMutex(Android_ActivityMutex); } -/* Drop file */ +// Drop file JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEnv *env, jclass jcls, jstring filename) @@ -995,7 +995,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( SDL_SendDropComplete(NULL); } -/* Set screen resolution */ +// Set screen resolution JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( JNIEnv *env, jclass jcls, jint surfaceWidth, jint surfaceHeight, @@ -1008,7 +1008,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( SDL_UnlockMutex(Android_ActivityMutex); } -/* Resize */ +// Resize JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv *env, jclass jcls) { @@ -1116,7 +1116,7 @@ SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean r #endif } -/* Paddown */ +// Paddown JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( JNIEnv *env, jclass jcls, jint device_id, jint keycode) @@ -1125,10 +1125,10 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( return Android_OnPadDown(device_id, keycode); #else return -1; -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID } -/* Padup */ +// Padup JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( JNIEnv *env, jclass jcls, jint device_id, jint keycode) @@ -1137,27 +1137,27 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( return Android_OnPadUp(device_id, keycode); #else return -1; -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID } -/* Joy */ +// Joy JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( JNIEnv *env, jclass jcls, jint device_id, jint axis, jfloat value) { #ifdef SDL_JOYSTICK_ANDROID Android_OnJoy(device_id, axis, value); -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID } -/* POV Hat */ +// POV Hat JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( JNIEnv *env, jclass jcls, jint device_id, jint hat_id, jint x, jint y) { #ifdef SDL_JOYSTICK_ANDROID Android_OnHat(device_id, hat_id, x, y); -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( @@ -1177,7 +1177,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( (*env)->ReleaseStringUTFChars(env, device_desc, desc); #else retval = -1; -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID return retval; } @@ -1189,7 +1189,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( return Android_RemoveJoystick(device_id); #else return -1; -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( @@ -1204,7 +1204,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( (*env)->ReleaseStringUTFChars(env, device_name, name); #else retval = -1; -#endif /* SDL_HAPTIC_ANDROID */ +#endif // SDL_HAPTIC_ANDROID return retval; } @@ -1218,7 +1218,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( #endif } -/* Called from surfaceCreated() */ +// Called from surfaceCreated() JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, jclass jcls) { SDL_LockMutex(Android_ActivityMutex); @@ -1236,7 +1236,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, j SDL_UnlockMutex(Android_ActivityMutex); } -/* Called from surfaceChanged() */ +// Called from surfaceChanged() JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, jclass jcls) { SDL_LockMutex(Android_ActivityMutex); @@ -1246,20 +1246,20 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_WindowData *data = Android_Window->internal; - /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ + // 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, Android_Window, (NativeWindowType)data->native_window); SDL_SetPointerProperty(SDL_GetWindowProperties(Android_Window), SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER, data->egl_surface); } - /* GL Context handling is done in the event loop because this function is run from the Java thread */ + // GL Context handling is done in the event loop because this function is run from the Java thread } #endif SDL_UnlockMutex(Android_ActivityMutex); } -/* Called from surfaceDestroyed() */ +// Called from surfaceDestroyed() JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env, jclass jcls) { int nb_attempt = 50; @@ -1271,7 +1271,7 @@ retry: if (Android_Window) { SDL_WindowData *data = Android_Window->internal; - /* Wait for Main thread being paused and context un-activated to release 'egl_surface' */ + // Wait for Main thread being paused and context un-activated to release 'egl_surface' if ((Android_Window->flags & SDL_WINDOW_OPENGL) && !data->backup_done) { nb_attempt -= 1; if (nb_attempt == 0) { @@ -1295,13 +1295,13 @@ retry: data->native_window = NULL; } - /* GL Context handling is done in the event loop because this function is run from the Java thread */ + // GL Context handling is done in the event loop because this function is run from the Java thread } SDL_UnlockMutex(Android_ActivityMutex); } -/* Keydown */ +// Keydown JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( JNIEnv *env, jclass jcls, jint keycode) @@ -1315,7 +1315,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( SDL_UnlockMutex(Android_ActivityMutex); } -/* Keyup */ +// Keyup JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( JNIEnv *env, jclass jcls, jint keycode) @@ -1329,7 +1329,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( SDL_UnlockMutex(Android_ActivityMutex); } -/* Virtual keyboard return key might stop text input */ +// Virtual keyboard return key might stop text input JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)( JNIEnv *env, jclass jcls) { @@ -1340,15 +1340,15 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)( return JNI_FALSE; } -/* Keyboard Focus Lost */ +// Keyboard Focus Lost JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( JNIEnv *env, jclass jcls) { - /* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */ + // Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget SDL_StopTextInput(Android_Window); } -/* Touch */ +// Touch JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( JNIEnv *env, jclass jcls, jint touch_device_id_in, jint pointer_finger_id_in, @@ -1361,7 +1361,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( SDL_UnlockMutex(Android_ActivityMutex); } -/* Mouse */ +// Mouse JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( JNIEnv *env, jclass jcls, jint button, jint action, jfloat x, jfloat y, jboolean relative) @@ -1373,7 +1373,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( SDL_UnlockMutex(Android_ActivityMutex); } -/* Accelerometer */ +// Accelerometer JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( JNIEnv *env, jclass jcls, jfloat x, jfloat y, jfloat z) @@ -1384,14 +1384,14 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( bHasNewData = SDL_TRUE; } -/* Clipboard */ +// Clipboard JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( JNIEnv *env, jclass jcls) { SDL_SendClipboardUpdate(); } -/* Low memory */ +// Low memory JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( JNIEnv *env, jclass cls) { @@ -1406,21 +1406,21 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeLocaleChanged)( SDL_SendAppEvent(SDL_EVENT_LOCALE_CHANGED); } -/* Dark mode */ +// Dark mode JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDarkModeChanged)( JNIEnv *env, jclass cls, jboolean enabled) { Android_SetDarkMode(enabled); } -/* Send Quit event to "SDLThread" thread */ +// Send Quit event to "SDLThread" thread JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( JNIEnv *env, jclass cls) { Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_DESTROY); } -/* Activity ends */ +// Activity ends JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( JNIEnv *env, jclass cls) { @@ -1453,7 +1453,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( } } -/* Pause */ +// Pause JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( JNIEnv *env, jclass cls) { @@ -1462,7 +1462,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_PAUSE); } -/* Resume */ +// Resume JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( JNIEnv *env, jclass cls) { @@ -1692,21 +1692,21 @@ void Android_AudioThreadInit(SDL_AudioDevice *device) Android_JNI_AudioSetThreadPriority((int) device->recording, (int)device->instance_id); } -/* Test for an exception and call SDL_SetError with its detail if one occurs */ -/* If the parameter silent is truthy then SDL_SetError() will not be called. */ +// Test for an exception and call SDL_SetError with its detail if one occurs +// If the parameter silent is truthy then SDL_SetError() will not be called. static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent) { JNIEnv *env = Android_JNI_GetEnv(); jthrowable exception; - /* Detect mismatch LocalReferenceHolder_Init/Cleanup */ + // Detect mismatch LocalReferenceHolder_Init/Cleanup SDL_assert(SDL_AtomicGet(&s_active) > 0); exception = (*env)->ExceptionOccurred(env); if (exception != NULL) { jmethodID mid; - /* Until this happens most JNI operations have undefined behaviour */ + // Until this happens most JNI operations have undefined behaviour (*env)->ExceptionClear(env); if (!silent) { @@ -1754,10 +1754,10 @@ static void Internal_Android_Create_AssetManager(void) return; } - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); - /* javaAssetManager = context.getAssets(); */ + // javaAssetManager = context.getAssets(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getAssets", "()Landroid/content/res/AssetManager;"); javaAssetManager = (*env)->CallObjectMethod(env, context, mid); @@ -1901,7 +1901,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco return -1; } - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); action = (*env)->NewStringUTF(env, "android.intent.action.BATTERY_CHANGED"); @@ -1922,7 +1922,7 @@ 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 */ + // Watch out for C89 scoping rules because of the macro #define GET_INT_EXTRA(var, key) \ int var; \ iname = (*env)->NewStringUTF(env, key); \ @@ -1931,7 +1931,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z"); - /* Watch out for C89 scoping rules because of the macro */ + // Watch out for C89 scoping rules because of the macro #define GET_BOOL_EXTRA(var, key) \ int var; \ bname = (*env)->NewStringUTF(env, key); \ @@ -1939,49 +1939,49 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco (*env)->DeleteLocalRef(env, bname); if (plugged) { - /* Watch out for C89 scoping rules because of the macro */ - GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */ + // Watch out for C89 scoping rules because of the macro + GET_INT_EXTRA(plug, "plugged") // == BatteryManager.EXTRA_PLUGGED (API 5) if (plug == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - /* 1 == BatteryManager.BATTERY_PLUGGED_AC */ - /* 2 == BatteryManager.BATTERY_PLUGGED_USB */ + // 1 == BatteryManager.BATTERY_PLUGGED_AC + // 2 == BatteryManager.BATTERY_PLUGGED_USB *plugged = (0 < plug) ? 1 : 0; } if (charged) { - /* Watch out for C89 scoping rules because of the macro */ - GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */ + // Watch out for C89 scoping rules because of the macro + GET_INT_EXTRA(status, "status") // == BatteryManager.EXTRA_STATUS (API 5) if (status == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - /* 5 == BatteryManager.BATTERY_STATUS_FULL */ + // 5 == BatteryManager.BATTERY_STATUS_FULL *charged = (status == 5) ? 1 : 0; } if (battery) { - GET_BOOL_EXTRA(present, "present") /* == BatteryManager.EXTRA_PRESENT (API 5) */ + GET_BOOL_EXTRA(present, "present") // == BatteryManager.EXTRA_PRESENT (API 5) *battery = present ? 1 : 0; } if (seconds) { - *seconds = -1; /* not possible */ + *seconds = -1; // not possible } if (percent) { int level; int scale; - /* Watch out for C89 scoping rules because of the macro */ + // Watch out for C89 scoping rules because of the macro { - GET_INT_EXTRA(level_temp, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */ + GET_INT_EXTRA(level_temp, "level") // == BatteryManager.EXTRA_LEVEL (API 5) level = level_temp; } - /* Watch out for C89 scoping rules because of the macro */ + // Watch out for C89 scoping rules because of the macro { - GET_INT_EXTRA(scale_temp, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */ + GET_INT_EXTRA(scale_temp, "scale") // == BatteryManager.EXTRA_SCALE (API 5) scale = scale_temp; } @@ -1998,7 +1998,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco return 0; } -/* Add all touch devices */ +// Add all touch devices void Android_JNI_InitTouch(void) { JNIEnv *env = Android_JNI_GetEnv(); @@ -2035,7 +2035,7 @@ void Android_JNI_HapticStop(int device_id) (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticStop, device_id); } -/* See SDLActivity.java for constants. */ +// See SDLActivity.java for constants. #define COMMAND_SET_KEEP_SCREEN_ON 5 int SDL_SendAndroidMessage(Uint32 command, int param) @@ -2046,7 +2046,7 @@ int SDL_SendAndroidMessage(Uint32 command, int param) return -1; } -/* sends message to be handled on the UI event dispatch thread */ +// sends message to be handled on the UI event dispatch thread int Android_JNI_SendMessage(int command, int param) { JNIEnv *env = Android_JNI_GetEnv(); @@ -2073,7 +2073,7 @@ void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect) void Android_JNI_HideScreenKeyboard(void) { - /* has to match Activity constant */ + // has to match Activity constant const int COMMAND_TEXTEDIT_HIDE = 3; Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0); } @@ -2104,7 +2104,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu env = Android_JNI_GetEnv(); - /* convert parameters */ + // convert parameters clazz = (*env)->FindClass(env, "java/lang/String"); @@ -2148,7 +2148,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu (*env)->DeleteLocalRef(env, clazz); - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); clazz = (*env)->GetObjectClass(env, context); @@ -2167,7 +2167,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu (*env)->DeleteLocalRef(env, context); (*env)->DeleteLocalRef(env, clazz); - /* delete parameters */ + // delete parameters (*env)->DeleteLocalRef(env, title); (*env)->DeleteLocalRef(env, message); @@ -2193,14 +2193,14 @@ void *SDL_GetAndroidJNIEnv(void) void *SDL_GetAndroidActivity(void) { - /* See SDL_system.h for caveats on using this function. */ + // See SDL_system.h for caveats on using this function. JNIEnv *env = Android_JNI_GetEnv(); if (!env) { return NULL; } - /* return SDLActivity.getContext(); */ + // return SDLActivity.getContext(); return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); } @@ -2264,7 +2264,7 @@ const char *SDL_GetAndroidInternalStoragePath(void) return NULL; } - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); if (!context) { SDL_SetError("Couldn't get Android context!"); @@ -2272,7 +2272,7 @@ const char *SDL_GetAndroidInternalStoragePath(void) return NULL; } - /* fileObj = context.getFilesDir(); */ + // fileObj = context.getFilesDir(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getFilesDir", "()Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid); @@ -2282,7 +2282,7 @@ const char *SDL_GetAndroidInternalStoragePath(void) return NULL; } - /* path = fileObject.getCanonicalPath(); */ + // path = fileObject.getCanonicalPath(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getCanonicalPath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); @@ -2322,7 +2322,7 @@ Uint32 SDL_GetAndroidExternalStorageState(void) state_string = (*env)->GetStringUTFChars(env, stateString, NULL); - /* Print an info message so people debugging know the storage state */ + // Print an info message so people debugging know the storage state __android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state_string); if (SDL_strcmp(state_string, "mounted") == 0) { @@ -2358,10 +2358,10 @@ const char *SDL_GetAndroidExternalStoragePath(void) return NULL; } - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); - /* fileObj = context.getExternalFilesDir(); */ + // fileObj = context.getExternalFilesDir(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); @@ -2371,7 +2371,7 @@ const char *SDL_GetAndroidExternalStoragePath(void) return NULL; } - /* path = fileObject.getAbsolutePath(); */ + // path = fileObject.getAbsolutePath(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); @@ -2404,10 +2404,10 @@ const char *SDL_GetAndroidCachePath(void) return NULL; } - /* context = SDLActivity.getContext(); */ + // context = SDLActivity.getContext(); context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); - /* fileObj = context.getExternalFilesDir(); */ + // fileObj = context.getExternalFilesDir(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getCacheDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); @@ -2417,7 +2417,7 @@ const char *SDL_GetAndroidCachePath(void) return NULL; } - /* path = fileObject.getAbsolutePath(); */ + // path = fileObject.getAbsolutePath(); mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); @@ -2568,7 +2568,7 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi return 0; } -/* Show toast notification */ +// Show toast notification int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset) { int result = 0; @@ -2585,7 +2585,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) SDL_assert(buflen > 6); - /* Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED) */ + // Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED) Internal_Android_Destroy_AssetManager(); if (!asset_manager) { @@ -2610,7 +2610,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) AConfiguration_getLanguage(cfg, language); AConfiguration_getCountry(cfg, country); - /* copy language (not null terminated) */ + // copy language (not null terminated) if (language[0]) { buf[id++] = language[0]; if (language[1]) { @@ -2620,7 +2620,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) buf[id++] = '_'; - /* copy country (not null terminated) */ + // copy country (not null terminated) if (country[0]) { buf[id++] = country[0]; if (country[1]) { @@ -2648,7 +2648,7 @@ int Android_JNI_OpenURL(const char *url) int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode) { - /* Get fopen-style modes */ + // Get fopen-style modes int moderead = 0, modewrite = 0, modeappend = 0, modeupdate = 0; for (const char *cmode = mode; *cmode; cmode++) { @@ -2670,8 +2670,8 @@ int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode) } } - /* Translate fopen-style modes to ContentResolver modes. */ - /* Android only allows "r", "w", "wt", "wa", "rw" or "rwt". */ + // Translate fopen-style modes to ContentResolver modes. + // Android only allows "r", "w", "wt", "wa", "rw" or "rwt". const char *contentResolverMode = "r"; if (moderead) { @@ -2719,7 +2719,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)( return; } - /* Convert fileList to string */ + // Convert fileList to string size_t count = (*env)->GetArrayLength(env, fileList); char **charFileList = SDL_calloc(sizeof(char*), count + 1); @@ -2729,8 +2729,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)( return; } - /* Convert to UTF-8 */ - /* TODO: Fix modified UTF-8 to classic UTF-8 */ + // Convert to UTF-8 + // TODO: Fix modified UTF-8 to classic UTF-8 for (int i = 0; i < count; i++) { jstring string = (*env)->GetObjectArrayElement(env, fileList, i); if (!string) { @@ -2750,7 +2750,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)( mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, NULL, -1); mAndroidFileDialogData.callback = NULL; - /* Cleanup memory */ + // Cleanup memory for (int j = 0; j < i; j++) { SDL_free(charFileList[j]); } @@ -2763,12 +2763,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)( (*env)->DeleteLocalRef(env, string); } - /* Call user-provided callback */ + // Call user-provided callback SDL_ClearError(); mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, (const char *const *) charFileList, filter); mAndroidFileDialogData.callback = NULL; - /* Cleanup memory */ + // Cleanup memory for (int i = 0; i < count; i++) { SDL_free(charFileList[i]); } @@ -2792,13 +2792,13 @@ SDL_bool Android_JNI_OpenFileDialog( JNIEnv *env = Android_JNI_GetEnv(); - /* Setup filters */ + // Setup filters jobjectArray filtersArray = NULL; if (filters) { jclass stringClass = (*env)->FindClass(env, "java/lang/String"); filtersArray = (*env)->NewObjectArray(env, nfilters, stringClass, NULL); - /* Convert to string */ + // Convert to string for (int i = 0; i < nfilters; i++) { jstring str = (*env)->NewStringUTF(env, filters[i].pattern); (*env)->SetObjectArrayElement(env, filtersArray, i, str); @@ -2806,13 +2806,13 @@ SDL_bool Android_JNI_OpenFileDialog( } } - /* Setup data */ + // Setup data static SDL_AtomicInt next_request_code; mAndroidFileDialogData.request_code = SDL_AtomicAdd(&next_request_code, 1); mAndroidFileDialogData.userdata = userdata; mAndroidFileDialogData.callback = callback; - /* Invoke JNI */ + // Invoke JNI jboolean success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midShowFileDialog, filtersArray, (jboolean) multiple, (jboolean) forwrite, mAndroidFileDialogData.request_code); (*env)->DeleteLocalRef(env, filtersArray); @@ -2827,4 +2827,4 @@ SDL_bool Android_JNI_OpenFileDialog( return SDL_TRUE; } -#endif /* SDL_PLATFORM_ANDROID */ +#endif // SDL_PLATFORM_ANDROID diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 6950ef2c76..b91e576f0d 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -23,7 +23,7 @@ #ifndef SDL_android_h #define SDL_android_h -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -38,7 +38,7 @@ extern "C" { // this appears to be broken right now (on Android, not SDL, I think...?). #define ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES 0 -/* Life cycle */ +// Life cycle typedef enum { SDL_ANDROID_LIFECYCLE_WAKE, @@ -55,7 +55,7 @@ SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 tim void Android_LockActivityMutex(void); void Android_UnlockActivityMutex(void); -/* Interface from the SDL library into the Android Java activity */ +// Interface from the SDL library into the Android Java activity extern void Android_JNI_SetActivityTitle(const char *title); extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen); extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint); @@ -71,12 +71,12 @@ extern ANativeWindow *Android_JNI_GetNativeWindow(void); extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void); extern SDL_DisplayOrientation Android_JNI_GetDisplayCurrentOrientation(void); -/* Audio support */ +// Audio support void Android_StartAudioHotplug(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording); void Android_StopAudioHotplug(void); extern void Android_AudioThreadInit(SDL_AudioDevice *device); -/* Detecting device type */ +// Detecting device type extern SDL_bool Android_IsDeXMode(void); extern SDL_bool Android_IsChromebook(void); @@ -87,58 +87,58 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status); int Android_JNI_FileClose(void *userdata); -/* Environment support */ +// Environment support void Android_JNI_GetManifestEnvironmentVariables(void); int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode); -/* Clipboard support */ +// Clipboard support int Android_JNI_SetClipboardText(const char *text); char *Android_JNI_GetClipboardText(void); SDL_bool Android_JNI_HasClipboardText(void); -/* Power support */ +// Power support int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent); -/* Joystick support */ +// Joystick support void Android_JNI_PollInputDevices(void); -/* Haptic support */ +// Haptic support void Android_JNI_PollHapticDevices(void); void Android_JNI_HapticRun(int device_id, float intensity, int length); void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, float high_frequency_intensity, int length); void Android_JNI_HapticStop(int device_id); -/* Video */ +// Video int Android_JNI_SuspendScreenSaver(SDL_bool suspend); -/* Touch support */ +// Touch support void Android_JNI_InitTouch(void); -/* Threads */ +// Threads #include JNIEnv *Android_JNI_GetEnv(void); int Android_JNI_SetupThread(void); -/* Locale */ +// Locale int Android_JNI_GetLocale(char *buf, size_t buflen); -/* Generic messages */ +// Generic messages int Android_JNI_SendMessage(int command, int param); -/* MessageBox */ +// MessageBox int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -/* Cursor support */ +// Cursor support int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y); void Android_JNI_DestroyCustomCursor(int cursorID); SDL_bool Android_JNI_SetCustomCursor(int cursorID); SDL_bool Android_JNI_SetSystemCursor(int cursorID); -/* Relative mouse support */ +// Relative mouse support SDL_bool Android_JNI_SupportsRelativeMouse(void); SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); -/* Show toast notification */ +// Show toast notification int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset); int Android_JNI_OpenURL(const char *url); @@ -150,12 +150,12 @@ SDL_bool SDL_IsAndroidTV(void); SDL_bool SDL_IsChromebook(void); SDL_bool SDL_IsDeXMode(void); -/* File Dialogs */ +// File Dialogs SDL_bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata, const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite, SDL_bool multiple); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus /* *INDENT-OFF* */ } diff --git a/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h b/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h index 8cb7430aba..fc6e5e8bf2 100644 --- a/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h +++ b/src/core/freebsd/SDL_evdev_kbd_default_keyaccmap.h @@ -1,6 +1,6 @@ #include -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off /* * Automatically generated from /usr/share/vt/keymaps/us.acc.kbd. * DO NOT EDIT! @@ -123,45 +123,45 @@ static keymap_t keymap_default_us_acc = { 0x6d, { } }; static accentmap_t accentmap_default_us_acc = { 11, { - /* dgra=0 */ + // dgra=0 { '`', { { 'a',0xe0 }, { 'A',0xc0 }, { 'e',0xe8 }, { 'E',0xc8 }, { 'i',0xec }, { 'I',0xcc }, { 'o',0xf2 }, { 'O',0xd2 }, { 'u',0xf9 }, { 'U',0xd9 }, }, }, - /* dacu=1 */ + // dacu=1 { 0xb4, { { 'a',0xe1 }, { 'A',0xc1 }, { 'e',0xe9 }, { 'E',0xc9 }, { 'i',0xed }, { 'I',0xcd }, { 'o',0xf3 }, { 'O',0xd3 }, { 'u',0xfa }, { 'U',0xda }, { 'y',0xfd }, { 'Y',0xdd }, }, }, - /* dcir=2 */ + // dcir=2 { '^', { { 'a',0xe2 }, { 'A',0xc2 }, { 'e',0xea }, { 'E',0xca }, { 'i',0xee }, { 'I',0xce }, { 'o',0xf4 }, { 'O',0xd4 }, { 'u',0xfb }, { 'U',0xdb }, }, }, - /* dtil=3 */ + // dtil=3 { '~', { { 'a',0xe3 }, { 'A',0xc3 }, { 'n',0xf1 }, { 'N',0xd1 }, { 'o',0xf5 }, { 'O',0xd5 }, }, }, - /* dmac=4 */ - { 0x00 }, - /* dbre=5 */ - { 0x00 }, - /* ddot=6 */ - { 0x00 }, - /* duml=7 */ + // dmac=4 + { 0x00 }, + // dbre=5 + { 0x00 }, + // ddot=6 + { 0x00 }, + // duml=7 { 0xa8, { { 'a',0xe4 }, { 'A',0xc4 }, { 'e',0xeb }, { 'E',0xcb }, { 'i',0xef }, { 'I',0xcf }, { 'o',0xf6 }, { 'O',0xd6 }, { 'u',0xfc }, { 'U',0xdc }, { 'y',0xff }, }, }, - /* dsla=8 */ - { 0x00 }, - /* drin=9 */ + // dsla=8 + { 0x00 }, + // drin=9 { 0xb0, { { 'a',0xe5 }, { 'A',0xc5 }, }, }, - /* dced=10 */ + // dced=10 { 0xb8, { { 'c',0xe7 }, { 'C',0xc7 }, }, }, - /* dapo=11 */ - { 0x00 }, - /* ddac=12 */ - { 0x00 }, - /* dogo=13 */ - { 0x00 }, - /* dcar=14 */ - { 0x00 }, + // dapo=11 + { 0x00 }, + // ddac=12 + { 0x00 }, + // dogo=13 + { 0x00 }, + // dcar=14 + { 0x00 }, } }; -/* *INDENT-ON* */ /* clang-format on */ +/* *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 a980c8d18e..cc96a4d109 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -25,7 +25,7 @@ #ifdef SDL_INPUT_FBSDKBIO -/* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source, slightly modified to work with FreeBSD */ +// This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source, slightly modified to work with FreeBSD #include #include @@ -52,12 +52,12 @@ struct SDL_EVDEV_keyboard_state unsigned short **key_maps; keymap_t *key_map; keyboard_info_t *kbInfo; - unsigned char shift_down[4]; /* shift state counters.. */ + 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; @@ -77,7 +77,7 @@ static int kbd_cleanup_atexit_installed = 0; static struct sigaction old_sigaction[NSIG]; static int fatal_signals[] = { - /* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */ + // Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. SIGHUP, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, SIGSYS @@ -114,22 +114,22 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex struct sigaction *old_action_p = &(old_sigaction[signum]); sigset_t sigset; - /* Restore original signal handler before going any further. */ + // Restore original signal handler before going any further. sigaction(signum, old_action_p, NULL); - /* Unmask current signal. */ + // Unmask current signal. sigemptyset(&sigset); sigaddset(&sigset, signum); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - /* Save original signal info and context for archeologists. */ + // Save original signal info and context for archeologists. SDL_EVDEV_kdb_cleanup_siginfo = info; SDL_EVDEV_kdb_cleanup_ucontext = ucontext; - /* Restore keyboard. */ + // Restore keyboard. kbd_cleanup(); - /* Reraise signal. */ + // Reraise signal. SDL_EVDEV_kbd_reraise_signal(signum); } @@ -150,27 +150,27 @@ static void kbd_unregister_emerg_cleanup(void) int signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); - /* Examine current signal action */ + // Examine current signal action if (sigaction(signum, NULL, &cur_action)) { continue; } - /* Check if action installed and not modified */ + // Check if action installed and not modified if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) { continue; } - /* Restore original action */ + // Restore original action sigaction(signum, old_action_p, NULL); } } static void kbd_cleanup_atexit(void) { - /* Restore keyboard. */ + // Restore keyboard. kbd_cleanup(); - /* Try to restore signal handlers in case shared library is being unloaded */ + // Try to restore signal handlers in case shared library is being unloaded kbd_unregister_emerg_cleanup(); } @@ -236,7 +236,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) kbd->npadch = -1; - /* This might fail if we're not connected to a tty (e.g. on the Steam Link) */ + // This might fail if we're not connected to a tty (e.g. on the Steam Link) kbd->keyboard_fd = kbd->console_fd = open("/dev/tty", O_RDONLY | O_CLOEXEC); kbd->shift_state = 0; @@ -258,7 +258,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) } if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) { - /* Set the keyboard in XLATE mode and load the keymaps */ + // Set the keyboard in XLATE mode and load the keymaps ioctl(kbd->console_fd, KDSKBMODE, (unsigned long)(K_XLATE)); if (!SDL_EVDEV_kbd_load_keymaps(kbd)) { SDL_free(kbd->key_map); @@ -306,7 +306,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) kbd_unregister_emerg_cleanup(); if (kbd->keyboard_fd >= 0) { - /* Restore the original keyboard mode */ + // Restore the original keyboard mode ioctl(kbd->keyboard_fd, KDSKBMODE, kbd->old_kbd_mode); close(kbd->keyboard_fd); @@ -337,7 +337,7 @@ void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) */ 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 */ + // c is already part of a UTF-8 sequence and safe to add as a character if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)c; } @@ -389,7 +389,7 @@ 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 */ + if (kbd->accents->acc[i].map[j][0] == 0) { // end of table break; } if (kbd->accents->acc[i].map[j][0] == ch) { @@ -426,7 +426,7 @@ static void chg_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag) static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag) { if (up_flag) { - return; /* no action, if this is a key release */ + return; // no action, if this is a key release } if (kbd->diacr) { @@ -472,7 +472,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ else kbd->shift_state &= ~(1 << value); - /* kludge */ + // kludge if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) { put_utf8(kbd, kbd->npadch); kbd->npadch = -1; @@ -496,7 +496,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, if (keycode < NUM_KEYS) { if (keycode >= 89 && keycode <= 95) { - /* These constitute unprintable language-related keys, so ignore them. */ + // These constitute unprintable language-related keys, so ignore them. return; } if (keycode > 95) { @@ -520,69 +520,69 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, map_from_key_sym = keysym.map[final_key_state]; if ((keysym.spcl & (0x80 >> final_key_state)) || (map_from_key_sym & SPCLKEY)) { - /* Special function.*/ + // Special function. if (map_from_key_sym == 0) - return; /* Nothing to do. */ + return; // Nothing to do. if (map_from_key_sym & SPCLKEY) { map_from_key_sym &= ~SPCLKEY; } if (map_from_key_sym >= F_ACC && map_from_key_sym <= L_ACC) { - /* Accent function.*/ + // Accent function. unsigned int accent_index = map_from_key_sym - F_ACC; if (kbd->accents->acc[accent_index].accchar != 0) { k_deadunicode(kbd, kbd->accents->acc[accent_index].accchar, !down); } } else { switch (map_from_key_sym) { - case ASH: /* alt/meta shift */ + case ASH: // alt/meta shift k_shift(kbd, 3, down == 0); break; - case LSHA: /* left shift + alt lock */ - case RSHA: /* right shift + alt lock */ + case LSHA: // left shift + alt lock + case RSHA: // right shift + alt lock if (down == 0) { chg_vc_kbd_led(kbd, ALKED); } SDL_FALLTHROUGH; - case LSH: /* left shift */ - case RSH: /* right shift */ + case LSH: // left shift + case RSH: // right shift k_shift(kbd, 0, down == 0); break; - case LCTRA: /* left ctrl + alt lock */ - case RCTRA: /* right ctrl + alt lock */ + case LCTRA: // left ctrl + alt lock + case RCTRA: // right ctrl + alt lock if (down == 0) { chg_vc_kbd_led(kbd, ALKED); } SDL_FALLTHROUGH; - case LCTR: /* left ctrl */ - case RCTR: /* right ctrl */ + case LCTR: // left ctrl + case RCTR: // right ctrl k_shift(kbd, 1, down == 0); break; - case LALTA: /* left alt + alt lock */ - case RALTA: /* right alt + alt lock */ + case LALTA: // left alt + alt lock + case RALTA: // right alt + alt lock if (down == 0) { chg_vc_kbd_led(kbd, ALKED); } SDL_FALLTHROUGH; - case LALT: /* left alt */ - case RALT: /* right alt */ + case LALT: // left alt + case RALT: // right alt k_shift(kbd, 2, down == 0); break; - case ALK: /* alt lock */ + case ALK: // alt lock if (down == 1) { chg_vc_kbd_led(kbd, ALKED); } break; - case CLK: /* caps lock*/ + case CLK: // caps lock if (down == 1) { chg_vc_kbd_led(kbd, CLKED); } break; - case NLK: /* num lock */ + case NLK: // num lock if (down == 1) { chg_vc_kbd_led(kbd, NLKED); } break; - case SLK: /* scroll lock */ + case SLK: // scroll lock if (down == 1) { chg_vc_kbd_led(kbd, SLKED); } @@ -610,4 +610,4 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, } } -#endif /* SDL_INPUT_FBSDKBIO */ +#endif // SDL_INPUT_FBSDKBIO diff --git a/src/core/gdk/SDL_gdk.cpp b/src/core/gdk/SDL_gdk.cpp index f5f15f20cf..354d052d5d 100644 --- a/src/core/gdk/SDL_gdk.cpp +++ b/src/core/gdk/SDL_gdk.cpp @@ -37,7 +37,7 @@ HANDLE plmSuspendComplete = nullptr; extern "C" int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue) { - /* If this is the first call, first create the global task queue. */ + // If this is the first call, first create the global task queue. if (!GDK_GlobalTaskQueue) { HRESULT hr; @@ -48,10 +48,10 @@ int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue) return SDL_SetError("[GDK] Could not create global task queue"); } - /* The initial call gets the non-duplicated handle so they can clean it up */ + // The initial call gets the non-duplicated handle so they can clean it up *outTaskQueue = GDK_GlobalTaskQueue; } else { - /* Duplicate the global task queue handle into outTaskQueue */ + // Duplicate the global task queue handle into outTaskQueue if (FAILED(XTaskQueueDuplicateHandle(GDK_GlobalTaskQueue, outTaskQueue))) { return SDL_SetError("[GDK] Unable to acquire global task queue"); } @@ -67,7 +67,7 @@ void GDK_DispatchTaskQueue(void) * This gives the option to opt-out for those who want to handle everything themselves. */ if (GDK_GlobalTaskQueue) { - /* Dispatch any callbacks which are ready. */ + // Dispatch any callbacks which are ready. while (XTaskQueueDispatch(GDK_GlobalTaskQueue, XTaskQueuePort::Completion, 0)) ; } @@ -76,7 +76,7 @@ void GDK_DispatchTaskQueue(void) extern "C" int GDK_RegisterChangeNotifications(void) { - /* Register suspend/resume handling */ + // Register suspend/resume handling plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE); if (!plmSuspendComplete) { SDL_SetError("[GDK] Unable to create plmSuspendComplete event"); @@ -102,7 +102,7 @@ int GDK_RegisterChangeNotifications(void) return -1; } - /* Register constrain/unconstrain handling */ + // Register constrain/unconstrain handling auto raccn = [](BOOLEAN constrained, PVOID context) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler"); SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -125,11 +125,11 @@ int GDK_RegisterChangeNotifications(void) extern "C" void GDK_UnregisterChangeNotifications(void) { - /* Unregister suspend/resume handling */ + // Unregister suspend/resume handling UnregisterAppStateChangeNotification(hPLM); CloseHandle(plmSuspendComplete); - /* Unregister constrain/unconstrain handling */ + // Unregister constrain/unconstrain handling UnregisterAppConstrainedChangeNotification(hCPLM); } diff --git a/src/core/gdk/SDL_gdk.h b/src/core/gdk/SDL_gdk.h index 913bae46da..f5e814e87d 100644 --- a/src/core/gdk/SDL_gdk.h +++ b/src/core/gdk/SDL_gdk.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is called from WIN_PumpEvents on GDK */ +// This is called from WIN_PumpEvents on GDK extern void GDK_DispatchTaskQueue(void); extern int GDK_RegisterChangeNotifications(void); diff --git a/src/core/haiku/SDL_BApp.h b/src/core/haiku/SDL_BApp.h index 80a61c338b..3e55bebb41 100644 --- a/src/core/haiku/SDL_BApp.h +++ b/src/core/haiku/SDL_BApp.h @@ -36,7 +36,7 @@ extern "C" { #include "SDL_internal.h" -/* Local includes */ +// Local includes #include "../../events/SDL_events_c.h" #include "../../video/haiku/SDL_bframebuffer.h" @@ -47,27 +47,27 @@ extern "C" { #include -/* Forward declarations */ +// Forward declarations class SDL_BLooper; class SDL_BWin; -/* Message constants */ +// Message constants enum ToSDL { - /* Intercepted by BWindow on its way to BView */ + // Intercepted by BWindow on its way to BView BAPP_MOUSE_MOVED, BAPP_MOUSE_BUTTON, BAPP_MOUSE_WHEEL, BAPP_KEY, - BAPP_REPAINT, /* from _UPDATE_ */ - /* From BWindow */ - BAPP_MAXIMIZE, /* from B_ZOOM */ + BAPP_REPAINT, // from _UPDATE_ + // From BWindow + 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, @@ -78,7 +78,7 @@ enum ToSDL extern "C" SDL_BLooper *SDL_Looper; -/* Create a descendant of BLooper */ +// Create a descendant of BLooper class SDL_BLooper : public BLooper { public: @@ -93,10 +93,10 @@ class SDL_BLooper : public BLooper { } - /* Event-handling functions */ + // Event-handling functions virtual void MessageReceived(BMessage *message) { - /* Sort out SDL-related messages */ + // Sort out SDL-related messages switch (message->what) { case BAPP_MOUSE_MOVED: _HandleMouseMove(message); @@ -159,7 +159,7 @@ class SDL_BLooper : public BLooper break; case BAPP_SCREEN_CHANGED: - /* TODO: Handle screen resize or workspace change */ + // TODO: Handle screen resize or workspace change break; default: @@ -168,7 +168,7 @@ class SDL_BLooper : public BLooper } } - /* Window creation/destruction methods */ + // Window creation/destruction methods int32 GetID(SDL_Window *win) { int32 i; @@ -179,19 +179,19 @@ class SDL_BLooper : public BLooper } } - /* Expand the vector if all slots are full */ + // Expand the vector if all slots are full if (i == _GetNumWindowSlots()) { _PushBackWindow(win); return i; } - /* TODO: error handling */ + // TODO: error handling return 0; } /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is there another way to do this? */ - void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ + void ClearID(SDL_BWin *bwin); // Defined in SDL_BeApp.cc SDL_Window *GetSDLWindow(int32 winID) { @@ -215,7 +215,7 @@ class SDL_BLooper : public BLooper #endif private: - /* Event management */ + // Event management void _HandleBasicWindowEvent(BMessage *msg, SDL_EventType sdlEventType) { SDL_Window *win; @@ -235,8 +235,8 @@ class SDL_BLooper : public BLooper int32 x = 0, y = 0; if ( !_GetWinID(msg, &winID) || - msg->FindInt32("x", &x) != B_OK || /* x movement */ - msg->FindInt32("y", &y) != B_OK /* y movement */ + msg->FindInt32("x", &x) != B_OK || // x movement + msg->FindInt32("y", &y) != B_OK // y movement ) { return; } @@ -264,7 +264,7 @@ class SDL_BLooper : public BLooper { SDL_Window *win; int32 winID; - int32 button, state; /* left/middle/right, pressed/released */ + int32 button, state; // left/middle/right, pressed/released if ( !_GetWinID(msg, &winID) || msg->FindInt32("button-id", &button) != B_OK || @@ -294,7 +294,7 @@ class SDL_BLooper : public BLooper { SDL_Window *win; int32 winID; - int32 scancode, state; /* scancode, pressed/released */ + int32 scancode, state; // scancode, pressed/released if ( !_GetWinID(msg, &winID) || msg->FindInt32("key-state", &state) != B_OK || @@ -321,7 +321,7 @@ class SDL_BLooper : public BLooper { SDL_Window *win; int32 winID; - bool bSetFocus; /* If false, lose focus */ + bool bSetFocus; // If false, lose focus if ( !_GetWinID(msg, &winID) || msg->FindBool("focusGained", &bSetFocus) != B_OK) { @@ -331,7 +331,7 @@ class SDL_BLooper : public BLooper if (bSetFocus) { SDL_SetMouseFocus(win); } else if (SDL_GetMouseFocus() == win) { - /* Only lose all focus if this window was the current focus */ + // Only lose all focus if this window was the current focus SDL_SetMouseFocus(NULL); } } @@ -340,7 +340,7 @@ class SDL_BLooper : public BLooper { SDL_Window *win; int32 winID; - bool bSetFocus; /* If false, lose focus */ + bool bSetFocus; // If false, lose focus if ( !_GetWinID(msg, &winID) || msg->FindBool("focusGained", &bSetFocus) != B_OK) { @@ -350,7 +350,7 @@ class SDL_BLooper : public BLooper if (bSetFocus) { SDL_SetKeyboardFocus(win); } else if (SDL_GetKeyboardFocus() == win) { - /* Only lose all focus if this window was the current focus */ + // Only lose all focus if this window was the current focus SDL_SetKeyboardFocus(NULL); } } @@ -360,7 +360,7 @@ class SDL_BLooper : public BLooper SDL_Window *win; int32 winID; int32 xPos, yPos; - /* Get the window id and new x/y position of the window */ + // Get the window id and new x/y position of the window if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-x", &xPos) != B_OK || @@ -376,7 +376,7 @@ class SDL_BLooper : public BLooper SDL_Window *win; int32 winID; int32 w, h; - /* Get the window id ]and new x/y position of the window */ + // Get the window id ]and new x/y position of the window if ( !_GetWinID(msg, &winID) || msg->FindInt32("window-w", &w) != B_OK || @@ -414,8 +414,8 @@ class SDL_BLooper : public BLooper _window_map.push_back(win); } - /* Members */ - std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ + // Members + std::vector _window_map; // Keeps track of SDL_Windows by index-id #ifdef SDL_VIDEO_OPENGL BGLView *_current_context; diff --git a/src/core/haiku/SDL_BeApp.cc b/src/core/haiku/SDL_BeApp.cc index cc41c75289..5e914e253b 100644 --- a/src/core/haiku/SDL_BeApp.cc +++ b/src/core/haiku/SDL_BeApp.cc @@ -22,7 +22,7 @@ #ifdef SDL_PLATFORM_HAIKU -/* Handle the BeApp specific portions of the application */ +// Handle the BeApp specific portions of the application #include #include @@ -32,7 +32,7 @@ #include #include -#include "SDL_BApp.h" /* SDL_BLooper class definition */ +#include "SDL_BApp.h" // SDL_BLooper class definition #include "SDL_BeApp.h" #include "../../video/haiku/SDL_BWin.h" @@ -43,17 +43,17 @@ extern "C" { #include "../../thread/SDL_systhread.h" -/* Flag to tell whether or not the Be application and looper are active or not */ +// Flag to tell whether or not the Be application and looper are active or not static int SDL_BeAppActive = 0; static SDL_Thread *SDL_AppThread = NULL; SDL_BLooper *SDL_Looper = NULL; -/* Default application signature */ +// Default application signature const char *SDL_signature = "application/x-SDL-executable"; -/* Create a descendant of BApplication */ +// Create a descendant of BApplication class SDL_BApp : public BApplication { public: SDL_BApp(const char* signature) : @@ -123,43 +123,43 @@ static int StartBeLooper() } -/* Initialize the Be Application, if it's not already started */ +// Initialize the Be Application, if it's not already started int SDL_InitBeApp(void) { - /* Create the BApplication that handles appserver interaction */ + // Create the BApplication that handles appserver interaction if (SDL_BeAppActive <= 0) { StartBeLooper(); - /* Mark the application active */ + // Mark the application active SDL_BeAppActive = 0; } - /* Increment the application reference count */ + // Increment the application reference count ++SDL_BeAppActive; - /* The app is running, and we're ready to go */ + // The app is running, and we're ready to go return 0; } -/* Quit the Be Application, if there's nothing left to do */ +// Quit the Be Application, if there's nothing left to do void SDL_QuitBeApp(void) { - /* Decrement the application reference count */ + // Decrement the application reference count --SDL_BeAppActive; - /* If the reference count reached zero, clean up the app */ + // If the reference count reached zero, clean up the app if (SDL_BeAppActive == 0) { SDL_Looper->Lock(); SDL_Looper->Quit(); SDL_Looper = NULL; if (SDL_AppThread) { - if (be_app != NULL) { /* Not tested */ + if (be_app != NULL) { // Not tested be_app->PostMessage(B_QUIT_REQUESTED); } SDL_WaitThread(SDL_AppThread, NULL); SDL_AppThread = NULL; } - /* be_app should now be NULL since be_app has quit */ + // be_app should now be NULL since be_app has quit } } @@ -167,7 +167,7 @@ void SDL_QuitBeApp(void) } #endif -/* SDL_BApp functions */ +// SDL_BApp functions void SDL_BLooper::ClearID(SDL_BWin *bwin) { _SetSDLWindow(NULL, bwin->GetID()); int32 i = _GetNumWindowSlots() - 1; @@ -177,4 +177,4 @@ void SDL_BLooper::ClearID(SDL_BWin *bwin) { } } -#endif /* SDL_PLATFORM_HAIKU */ +#endif // SDL_PLATFORM_HAIKU diff --git a/src/core/haiku/SDL_BeApp.h b/src/core/haiku/SDL_BeApp.h index fde331aec9..405900b608 100644 --- a/src/core/haiku/SDL_BeApp.h +++ b/src/core/haiku/SDL_BeApp.h @@ -23,15 +23,15 @@ #ifdef __cplusplus extern "C" { #endif -/* Handle the BeApp specific portions of the application */ +// Handle the BeApp specific portions of the application -/* Initialize the Be Application, if it's not already started */ +// Initialize the Be Application, if it's not already started extern int SDL_InitBeApp(void); -/* Quit the Be Application, if there's nothing left to do */ +// Quit the Be Application, if there's nothing left to do extern void SDL_QuitBeApp(void); -/* Be Application Signature*/ +// Be Application Signature extern const char *SDL_signature; diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index 15da60520f..d0ff169e1d 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -24,7 +24,7 @@ #include "../../stdlib/SDL_vacopy.h" #ifdef SDL_USE_LIBDBUS -/* we never link directly to libdbus. */ +// we never link directly to libdbus. static const char *dbus_library = "libdbus-1.so.3"; static void *dbus_handle = NULL; static char *inhibit_handle = NULL; @@ -111,7 +111,7 @@ static int LoadDBUSLibrary(void) dbus_handle = SDL_LoadObject(dbus_library); if (!dbus_handle) { retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + // Don't call SDL_SetError(): SDL_LoadObject already did. } else { retval = LoadDBUSSyms(); if (retval < 0) { @@ -125,19 +125,19 @@ static int LoadDBUSLibrary(void) static SDL_SpinLock spinlock_dbus_init = 0; -/* you must hold spinlock_dbus_init before calling this! */ +// you must hold spinlock_dbus_init before calling this! 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. */ + is_dbus_available = SDL_FALSE; // can't load at all? Don't keep trying. return; } @@ -147,18 +147,18 @@ static void SDL_DBus_Init_Spinlocked(void) } dbus.error_init(&err); - /* session bus is required */ + // session bus is required dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err); if (dbus.error_is_set(&err)) { 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); - /* system bus is optional */ + // system bus is optional dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err); if (!dbus.error_is_set(&err)) { dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0); @@ -170,7 +170,7 @@ static void SDL_DBus_Init_Spinlocked(void) void SDL_DBus_Init(void) { - SDL_LockSpinlock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */ + SDL_LockSpinlock(&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_UnlockSpinlock(&spinlock_dbus_init); } @@ -216,14 +216,14 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no 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); if (reply) { - /* skip any input args, get to output args. */ + // 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. */ + // we assume D-Bus already validated all this. { void *dumpptr = va_arg(ap_reply, void *); (void)dumpptr; @@ -361,8 +361,8 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char * void SDL_DBus_ScreensaverTickle(void) { - if (screensaver_cookie == 0 && !inhibit_handle) { /* 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. */ + if (screensaver_cookie == 0 && !inhibit_handle) { // 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); } @@ -443,8 +443,8 @@ SDL_bool 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 */ - static const unsigned int INHIBIT_IDLE = 8; /* Taken from the portal API reference */ + 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; if (inhibit) { @@ -469,7 +469,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) dbus.message_iter_init_append(msg, &iterInit); - /* a{sv} */ + // a{sv} if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) { dbus.message_unref(msg); return SDL_FALSE; @@ -524,7 +524,7 @@ void SDL_DBus_PumpEvents(void) dbus.connection_read_write(dbus.session_conn, 0); while (dbus.connection_dispatch(dbus.session_conn) == DBUS_DISPATCH_DATA_REMAINS) { - /* Do nothing, actual work happens in DBus_MessageFilter */ + // Do nothing, actual work happens in DBus_MessageFilter SDL_DelayNS(SDL_US_TO_NS(10)); } } @@ -541,7 +541,7 @@ char *SDL_DBus_GetLocalMachineId(void) dbus.error_init(&err); if (dbus.try_get_local_machine_id) { - /* Available since dbus 1.12.0, has proper error-handling */ + // Available since dbus 1.12.0, has proper error-handling result = dbus.try_get_local_machine_id(&err); } else { /* Available since time immemorial, but has no error-handling: @@ -575,12 +575,12 @@ char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *path_count) DBusMessageIter iter, iterDict; char **paths = NULL; DBusMessage *reply = NULL; - DBusMessage *msg = dbus.message_new_method_call("org.freedesktop.portal.Documents", /* Node */ - "/org/freedesktop/portal/documents", /* Path */ - "org.freedesktop.portal.FileTransfer", /* Interface */ - "RetrieveFiles"); /* Method */ + DBusMessage *msg = dbus.message_new_method_call("org.freedesktop.portal.Documents", // Node + "/org/freedesktop/portal/documents", // Path + "org.freedesktop.portal.FileTransfer", // Interface + "RetrieveFiles"); // Method - /* Make sure we have a connection to the dbus session bus */ + // Make sure we have a connection to the dbus session bus if (!SDL_DBus_GetContext() || !dbus.session_conn) { /* We either cannot connect to the session bus or were unable to * load the D-Bus library at all. */ @@ -589,7 +589,7 @@ char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *path_count) dbus.error_init(&err); - /* First argument is a "application/vnd.portal.filetransfer" key from a DnD or clipboard event */ + // First argument is a "application/vnd.portal.filetransfer" key from a DnD or clipboard event if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { SDL_OutOfMemory(); dbus.message_unref(msg); diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index 0be866b360..11c6d95395 100644 --- a/src/core/linux/SDL_dbus.h +++ b/src/core/linux/SDL_dbus.h @@ -91,12 +91,12 @@ extern void SDL_DBus_Init(void); extern void SDL_DBus_Quit(void); extern SDL_DBusContext *SDL_DBus_GetContext(void); -/* These use the built-in Session connection. */ +// 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, ...); extern SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result); -/* These use whatever connection you like. */ +// These use whatever connection you like. extern SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result); @@ -109,6 +109,6 @@ extern char *SDL_DBus_GetLocalMachineId(void); extern char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *files_count); -#endif /* HAVE_DBUS_DBUS_H */ +#endif // HAVE_DBUS_DBUS_H -#endif /* SDL_dbus_h_ */ +#endif // SDL_dbus_h_ diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index 96c59802bc..e998c1b303 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -22,7 +22,7 @@ #ifdef SDL_INPUT_LINUXEV -/* This is based on the linux joystick driver */ +// This is based on the linux joystick driver /* 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 @@ -43,7 +43,7 @@ #include "../../core/linux/SDL_evdev_capabilities.h" #include "../../core/linux/SDL_udev.h" -/* These are not defined in older Linux kernel headers */ +// These are not defined in older Linux kernel headers #ifndef SYN_DROPPED #define SYN_DROPPED 3 #endif @@ -59,12 +59,12 @@ #define REL_HWHEEL_HI_RES 0x0c #endif -/* The field to look up in struct input_event for integer seconds */ +// The field to look up in struct input_event for integer seconds #ifndef input_event_sec #define input_event_sec time.tv_sec #endif -/* The field to look up in struct input_event for fractional seconds */ +// The field to look up in struct input_event for fractional seconds #ifndef input_event_usec #define input_event_usec time.tv_usec #endif @@ -75,7 +75,7 @@ typedef struct SDL_evdevlist_item int fd; int udev_class; - /* TODO: use this for every device, not just touchscreen */ + // TODO: use this for every device, not just touchscreen SDL_bool out_of_sync; /* TODO: expand on this to have data for every possible class (mouse, @@ -107,7 +107,7 @@ typedef struct SDL_evdevlist_item } *touchscreen_data; - /* Mouse state */ + // Mouse state SDL_bool high_res_wheel; SDL_bool high_res_hwheel; SDL_bool relative_mouse; @@ -137,22 +137,22 @@ static int SDL_EVDEV_device_removed(const char *dev_path); static int SDL_EVDEV_device_added(const char *dev_path, int udev_class); #ifdef SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path); -#endif /* SDL_USE_LIBUDEV */ +#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) { - /* Mice already send relative events through this interface */ + // Mice already send relative events through this interface return 0; } @@ -180,7 +180,7 @@ int SDL_EVDEV_Init(void) return -1; } - /* Set up the udev callback */ + // Set up the udev callback if (SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) { SDL_UDEV_Quit(); SDL_free(_this); @@ -188,7 +188,7 @@ int SDL_EVDEV_Init(void) return -1; } - /* Force a scan to build the initial device list */ + // Force a scan to build the initial device list SDL_UDEV_Scan(); #else { @@ -212,10 +212,10 @@ int SDL_EVDEV_Init(void) } } } else { - /* TODO: Scan the devices manually, like a caveman */ + // TODO: Scan the devices manually, like a caveman } } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV _this->kbd = SDL_EVDEV_kbd_init(); @@ -241,9 +241,9 @@ void SDL_EVDEV_Quit(void) #ifdef SDL_USE_LIBUDEV SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback); SDL_UDEV_Quit(); -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV - /* Remove existing devices */ + // Remove existing devices while (_this->first) { SDL_EVDEV_device_removed(_this->first->path); } @@ -286,7 +286,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl break; } } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) @@ -371,7 +371,7 @@ void SDL_EVDEV_Poll(void) break; } - /* Probably keyboard */ + // Probably keyboard scancode = SDL_EVDEV_translate_keycode(event->code); if (event->value == 0) { SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, SDL_RELEASED); @@ -383,13 +383,13 @@ void SDL_EVDEV_Poll(void) case EV_ABS: switch (event->code) { case ABS_MT_SLOT: - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } item->touchscreen_data->current_slot = event->value; break; case ABS_MT_TRACKING_ID: - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } if (event->value >= 0) { @@ -400,7 +400,7 @@ void SDL_EVDEV_Poll(void) } break; case ABS_MT_POSITION_X: - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } item->touchscreen_data->slots[item->touchscreen_data->current_slot].x = event->value; @@ -409,7 +409,7 @@ void SDL_EVDEV_Poll(void) } break; case ABS_MT_POSITION_Y: - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } item->touchscreen_data->slots[item->touchscreen_data->current_slot].y = event->value; @@ -418,7 +418,7 @@ void SDL_EVDEV_Poll(void) } break; case ABS_MT_PRESSURE: - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } item->touchscreen_data->slots[item->touchscreen_data->current_slot].pressure = event->value; @@ -487,7 +487,7 @@ void SDL_EVDEV_Poll(void) case EV_SYN: switch (event->code) { case SYN_REPORT: - /* Send mouse axis changes together to ensure consistency and reduce event processing overhead */ + // Send mouse axis changes together to ensure consistency and reduce event processing overhead if (item->relative_mouse) { if (item->mouse_x != 0 || item->mouse_y != 0) { SDL_SendMouseMotion(SDL_EVDEV_GetEventTimestamp(event), mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, (float)item->mouse_x, (float)item->mouse_y); @@ -521,7 +521,7 @@ void SDL_EVDEV_Poll(void) item->mouse_wheel = item->mouse_hwheel = 0; } - if (!item->is_touchscreen) { /* FIXME: temp hack */ + if (!item->is_touchscreen) { // FIXME: temp hack break; } @@ -535,7 +535,7 @@ void SDL_EVDEV_Poll(void) norm_pressure = (float)(item->touchscreen_data->slots[j].pressure - item->touchscreen_data->min_pressure) / (float)item->touchscreen_data->range_pressure; } else { - /* This touchscreen does not support pressure */ + // This touchscreen does not support pressure norm_pressure = 1.0f; } @@ -598,7 +598,7 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode) keycode); } } -#endif /* DEBUG_SCANCODES */ +#endif // DEBUG_SCANCODES return scancode; } @@ -741,7 +741,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) return -1; } - ret = SDL_AddTouch(item->fd, /* I guess our fd is unique enough */ + 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); if (ret < 0) { @@ -783,7 +783,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) Sint32 *mt_req_values; size_t mt_req_size; - /* TODO: sync devices other than touchscreen */ + // TODO: sync devices other than touchscreen if (!item->is_touchscreen) { return; } @@ -888,7 +888,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) SDL_free(mt_req_code); -#endif /* EVIOCGMTSLOTS */ +#endif // EVIOCGMTSLOTS } static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) @@ -896,10 +896,10 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) SDL_evdevlist_item *item; unsigned long relbit[NBITS(REL_MAX)] = { 0 }; - /* Check to make sure it's not already in list. */ + // Check to make sure it's not already in list. for (item = _this->first; item; item = item->next) { if (SDL_strcmp(dev_path, item->path) == 0) { - return -1; /* already have this one */ + return -1; // already have this one } } @@ -929,7 +929,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) item->high_res_hwheel = test_bit(REL_HWHEEL_HI_RES, relbit); } - /* For now, we just treat a touchpad like a touchscreen */ + // For now, we just treat a touchpad like a touchscreen if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) { int ret; item->is_touchscreen = SDL_TRUE; @@ -978,7 +978,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path) SDL_evdevlist_item *prev = NULL; for (item = _this->first; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (SDL_strcmp(dev_path, item->path) == 0) { if (prev) { prev->next = item->next; @@ -1033,4 +1033,4 @@ Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event) return timestamp; } -#endif /* SDL_INPUT_LINUXEV */ +#endif // SDL_INPUT_LINUXEV diff --git a/src/core/linux/SDL_evdev.h b/src/core/linux/SDL_evdev.h index fc7c4bd53f..6a4be50719 100644 --- a/src/core/linux/SDL_evdev.h +++ b/src/core/linux/SDL_evdev.h @@ -36,6 +36,6 @@ extern int SDL_EVDEV_GetDeviceCount(int device_class); extern void SDL_EVDEV_Poll(void); extern Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event); -#endif /* SDL_INPUT_LINUXEV */ +#endif // SDL_INPUT_LINUXEV -#endif /* SDL_evdev_h_ */ +#endif // SDL_evdev_h_ diff --git a/src/core/linux/SDL_evdev_capabilities.c b/src/core/linux/SDL_evdev_capabilities.c index 6c146ab10c..1a04f6b59f 100644 --- a/src/core/linux/SDL_evdev_capabilities.c +++ b/src/core/linux/SDL_evdev_capabilities.c @@ -25,7 +25,7 @@ #ifdef HAVE_LINUX_INPUT_H -/* missing defines in older Linux kernel headers */ +// missing defines in older Linux kernel headers #ifndef BTN_TRIGGER_HAPPY #define BTN_TRIGGER_HAPPY 0x2c0 #endif @@ -49,7 +49,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA unsigned end; }; - /* key code ranges above BTN_MISC (start is inclusive, stop is exclusive)*/ + // key code ranges above BTN_MISC (start is inclusive, stop is exclusive) static const struct range high_key_blocks[] = { { KEY_OK, BTN_DPAD_UP }, { KEY_ALS_TOGGLE, BTN_TRIGGER_HAPPY } @@ -58,24 +58,24 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA int devclass = 0; unsigned long keyboard_mask; - /* If the kernel specifically says it's an accelerometer, believe it */ + // If the kernel specifically says it's an accelerometer, believe it if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) { return SDL_UDEV_DEVICE_ACCELEROMETER; } - /* We treat pointing sticks as indistinguishable from mice */ + // We treat pointing sticks as indistinguishable from mice if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props)) { return SDL_UDEV_DEVICE_MOUSE; } - /* We treat buttonpads as equivalent to touchpads */ + // We treat buttonpads as equivalent to touchpads if (test_bit(INPUT_PROP_TOPBUTTONPAD, bitmask_props) || test_bit(INPUT_PROP_BUTTONPAD, bitmask_props) || test_bit(INPUT_PROP_SEMI_MT, bitmask_props)) { return SDL_UDEV_DEVICE_TOUCHPAD; } - /* X, Y, Z axes but no buttons probably means an accelerometer */ + // X, Y, Z axes but no buttons probably means an accelerometer if (test_bit(EV_ABS, bitmask_ev) && test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs) && @@ -97,15 +97,15 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA if (test_bit(EV_ABS, bitmask_ev) && test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) { if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) { - ; /* ID_INPUT_TABLET */ + ; // ID_INPUT_TABLET } else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) { - devclass |= SDL_UDEV_DEVICE_TOUCHPAD; /* ID_INPUT_TOUCHPAD */ + devclass |= SDL_UDEV_DEVICE_TOUCHPAD; // ID_INPUT_TOUCHPAD } else if (test_bit(BTN_MOUSE, bitmask_key)) { - devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */ + devclass |= SDL_UDEV_DEVICE_MOUSE; // ID_INPUT_MOUSE } else if (test_bit(BTN_TOUCH, bitmask_key)) { /* TODO: better determining between touchscreen and multitouch touchpad, see https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-input_id.c */ - devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; /* ID_INPUT_TOUCHSCREEN */ + devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; // ID_INPUT_TOUCHSCREEN } if (test_bit(BTN_TRIGGER, bitmask_key) || @@ -119,14 +119,14 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA test_bit(ABS_WHEEL, bitmask_abs) || test_bit(ABS_GAS, bitmask_abs) || test_bit(ABS_BRAKE, bitmask_abs)) { - devclass |= SDL_UDEV_DEVICE_JOYSTICK; /* ID_INPUT_JOYSTICK */ + devclass |= SDL_UDEV_DEVICE_JOYSTICK; // ID_INPUT_JOYSTICK } } if (test_bit(EV_REL, bitmask_ev) && test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) && test_bit(BTN_MOUSE, bitmask_key)) { - devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */ + devclass |= SDL_UDEV_DEVICE_MOUSE; // ID_INPUT_MOUSE } if (test_bit(EV_KEY, bitmask_ev)) { @@ -136,7 +136,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA 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 */ + // If there are no keys in the lower block, check the higher blocks if (!found) { unsigned block; for (block = 0; block < (sizeof(high_key_blocks) / sizeof(struct range)); ++block) { @@ -150,7 +150,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA } if (found > 0) { - devclass |= SDL_UDEV_DEVICE_HAS_KEYS; /* ID_INPUT_KEY */ + devclass |= SDL_UDEV_DEVICE_HAS_KEYS; // ID_INPUT_KEY } } @@ -159,10 +159,10 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA * do not test KEY_RESERVED, though */ keyboard_mask = 0xFFFFFFFE; if ((bitmask_key[0] & keyboard_mask) == keyboard_mask) { - devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */ + devclass |= SDL_UDEV_DEVICE_KEYBOARD; // ID_INPUT_KEYBOARD } return devclass; } -#endif /* HAVE_LINUX_INPUT_H */ +#endif // HAVE_LINUX_INPUT_H diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h index ae09b68c31..57667d2578 100644 --- a/src/core/linux/SDL_evdev_capabilities.h +++ b/src/core/linux/SDL_evdev_capabilities.h @@ -44,7 +44,7 @@ #define INPUT_PROP_MAX 0x1f #endif -/* A device can be any combination of these classes */ +// A device can be any combination of these classes typedef enum { SDL_UDEV_DEVICE_UNKNOWN = 0x0000, @@ -71,6 +71,6 @@ extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(IN const unsigned long bitmask_key[NBITS(KEY_MAX)], const unsigned long bitmask_rel[NBITS(REL_MAX)]); -#endif /* HAVE_LINUX_INPUT_H */ +#endif // HAVE_LINUX_INPUT_H -#endif /* SDL_evdev_capabilities_h_ */ +#endif // SDL_evdev_capabilities_h_ diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index 8af1cf35ee..cf3cecb9f1 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -24,7 +24,7 @@ #ifdef SDL_INPUT_LINUXKD -/* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source */ +// This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source #include #include @@ -32,7 +32,7 @@ #include #include #include -#include /* for TIOCL_GETSHIFTSTATE */ +#include // for TIOCL_GETSHIFTSTATE #include @@ -40,7 +40,7 @@ #include "SDL_evdev_kbd_default_accents.h" #include "SDL_evdev_kbd_default_keymap.h" -/* These are not defined in older Linux kernel headers */ +// These are not defined in older Linux kernel headers #ifndef K_UNICODE #define K_UNICODE 0x03 #endif @@ -87,12 +87,12 @@ struct SDL_EVDEV_keyboard_state SDL_bool muted; 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; @@ -125,7 +125,7 @@ static void SDL_EVDEV_dump_accents(SDL_EVDEV_keyboard_state *kbd) printf(" }\n"); printf("};\n"); } -#endif /* DUMP_ACCENTS */ +#endif // DUMP_ACCENTS #ifdef DUMP_KEYMAP static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd) @@ -155,7 +155,7 @@ static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd) } printf("};\n"); } -#endif /* DUMP_KEYMAP */ +#endif // DUMP_KEYMAP static SDL_EVDEV_keyboard_state *kbd_cleanup_state = NULL; static int kbd_cleanup_sigactions_installed = 0; @@ -164,7 +164,7 @@ static int kbd_cleanup_atexit_installed = 0; static struct sigaction old_sigaction[NSIG]; static int fatal_signals[] = { - /* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */ + // Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. SIGHUP, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, SIGSYS @@ -194,22 +194,22 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex struct sigaction *old_action_p = &(old_sigaction[signum]); sigset_t sigset; - /* Restore original signal handler before going any further. */ + // Restore original signal handler before going any further. sigaction(signum, old_action_p, NULL); - /* Unmask current signal. */ + // Unmask current signal. sigemptyset(&sigset); sigaddset(&sigset, signum); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - /* Save original signal info and context for archeologists. */ + // Save original signal info and context for archeologists. SDL_EVDEV_kdb_cleanup_siginfo = info; SDL_EVDEV_kdb_cleanup_ucontext = ucontext; - /* Restore keyboard. */ + // Restore keyboard. kbd_cleanup(); - /* Reraise signal. */ + // Reraise signal. SDL_EVDEV_kbd_reraise_signal(signum); } @@ -230,27 +230,27 @@ static void kbd_unregister_emerg_cleanup(void) int signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); - /* Examine current signal action */ + // Examine current signal action if (sigaction(signum, NULL, &cur_action)) { continue; } - /* Check if action installed and not modified */ + // Check if action installed and not modified if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) { continue; } - /* Restore original action */ + // Restore original action sigaction(signum, old_action_p, NULL); } } static void kbd_cleanup_atexit(void) { - /* Restore keyboard. */ + // Restore keyboard. kbd_cleanup(); - /* Try to restore signal handlers in case shared library is being unloaded */ + // Try to restore signal handlers in case shared library is being unloaded kbd_unregister_emerg_cleanup(); } @@ -333,7 +333,7 @@ static SDL_bool setup_vt_signal(int signum, signal_handler handler) return SDL_FALSE; } if (old_action_p->sa_handler != SIG_DFL) { - /* This signal is already in use */ + // This signal is already in use sigaction(signum, old_action_p, NULL); return SDL_FALSE; } @@ -432,7 +432,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) return NULL; } - /* This might fail if we're not connected to a tty (e.g. on the Steam Link) */ + // This might fail if we're not connected to a tty (e.g. on the Steam Link) kbd->console_fd = open("/dev/tty", O_RDONLY | O_CLOEXEC); if (!((ioctl(kbd->console_fd, KDGKBTYPE, &kbtype) == 0) && ((kbtype == KB_101) || (kbtype == KB_84)))) { close(kbd->console_fd); @@ -453,7 +453,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) kbd->key_maps = default_key_maps; if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) { - /* Set the keyboard in UNICODE mode and load the keymaps */ + // Set the keyboard in UNICODE mode and load the keymaps ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE); } @@ -489,7 +489,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) } else { kbd_unregister_emerg_cleanup(); - /* Restore the original keyboard mode */ + // Restore the original keyboard mode ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode); } state->muted = muted; @@ -549,7 +549,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) */ 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 */ + // c is already part of a UTF-8 sequence and safe to add as a character if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)c; } @@ -599,7 +599,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch) if (kbd->console_fd >= 0) if (ioctl(kbd->console_fd, KDGKBDIACR, kbd->accents) < 0) { - /* No worries, we'll use the default accent table */ + // No worries, we'll use the default accent table } for (i = 0; i < kbd->accents->kb_cnt; i++) { @@ -721,7 +721,7 @@ static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { if (up_flag) { - return; /* no action, if this is a key release */ + return; // no action, if this is a key release } if (kbd->diacr) { @@ -774,11 +774,11 @@ 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 */ + // unprintable action return; } @@ -821,7 +821,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ kbd->shift_state &= ~(1 << value); } - /* kludge */ + // kludge if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) { put_utf8(kbd, kbd->npadch); kbd->npadch = -1; @@ -841,10 +841,10 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ } if (value < 10) { - /* decimal input of code, while Alt depressed */ + // decimal input of code, while Alt depressed base = 10; } else { - /* hexadecimal input of code, while AltGr depressed */ + // hexadecimal input of code, while AltGr depressed value -= 10; base = 16; } @@ -873,7 +873,7 @@ static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_ } chg_vc_kbd_slock(kbd, value); - /* try to make Alt, oops, AltGr and such work */ + // try to make Alt, oops, AltGr and such work if (!kbd->key_maps[kbd->lockstate ^ kbd->slockstate]) { kbd->slockstate = 0; chg_vc_kbd_slock(kbd, value); @@ -900,7 +900,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode shift_final = (state->shift_state | state->slockstate) ^ state->lockstate; key_map = state->key_maps[shift_final]; if (!key_map) { - /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */ + // Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state state->shift_state = 0; state->slockstate = 0; state->lockstate = 0; @@ -932,7 +932,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode } else { type -= 0xf0; - /* if type is KT_LETTER then it can be affected by Caps Lock */ + // if type is KT_LETTER then it can be affected by Caps Lock if (type == KT_LETTER) { type = KT_LATIN; @@ -967,7 +967,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode } } -#elif !defined(SDL_INPUT_FBSDKBIO) /* !SDL_INPUT_LINUXKD */ +#elif !defined(SDL_INPUT_FBSDKBIO) // !SDL_INPUT_LINUXKD SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) { @@ -994,4 +994,4 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) { } -#endif /* SDL_INPUT_LINUXKD */ +#endif // SDL_INPUT_LINUXKD diff --git a/src/core/linux/SDL_evdev_kbd.h b/src/core/linux/SDL_evdev_kbd.h index 7c38bc9d59..e08d641109 100644 --- a/src/core/linux/SDL_evdev_kbd.h +++ b/src/core/linux/SDL_evdev_kbd.h @@ -32,4 +32,4 @@ extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state); extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down); extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state); -#endif /* SDL_evdev_kbd_h_ */ +#endif // SDL_evdev_kbd_h_ diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index a4f6560da2..ed36bd1120 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -76,7 +76,7 @@ static char *GetAppName(void) return SDL_strdup(linkfile); } } -#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD */ +#endif // SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD return SDL_strdup("SDL_App"); } @@ -94,10 +94,10 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, Sint32 p_end_pos = -1; dbus->message_iter_init(msg, &iter); - /* Message type is a(si)i, we only need string part */ + // Message type is a(si)i, we only need string part if (dbus->message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) { size_t pos = 0; - /* First pass: calculate string length */ + // First pass: calculate string length dbus->message_iter_recurse(&iter, &array); while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) { dbus->message_iter_recurse(&array, &sub); @@ -110,12 +110,12 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, } dbus->message_iter_next(&sub); if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_INT32 && p_end_pos == -1) { - /* Type is a bit field defined as follows: */ - /* bit 3: Underline, bit 4: HighLight, bit 5: DontCommit, */ - /* bit 6: Bold, bit 7: Strike, bit 8: Italic */ + // Type is a bit field defined as follows: + // bit 3: Underline, bit 4: HighLight, bit 5: DontCommit, + // bit 6: Bold, bit 7: Strike, bit 8: Italic Sint32 type; dbus->message_iter_get_basic(&sub, &type); - /* We only consider highlight */ + // We only consider highlight if (type & (1 << 4)) { if (p_start_pos == -1) { p_start_pos = pos; @@ -138,7 +138,7 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, if (text) { char *pivot = text; - /* Second pass: join all the sub string */ + // Second pass: join all the sub string dbus->message_iter_recurse(&iter, &array); while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) { dbus->message_iter_recurse(&array, &sub); @@ -239,8 +239,8 @@ static void SDLCALL Fcitx_SetCapabilities(void *data, } if (hint && SDL_strstr(hint, "composition")) { - caps |= (1 << 1); /* Preedit Flag */ - caps |= (1 << 4); /* Formatted Preedit Flag */ + caps |= (1 << 1); // Preedit Flag + caps |= (1 << 4); // Formatted Preedit Flag } if (hint && SDL_strstr(hint, "candidates")) { // FIXME, turn off native candidate rendering @@ -285,9 +285,9 @@ static SDL_bool FcitxClientCreateIC(FcitxClient *client) char *ic_path = NULL; SDL_DBusContext *dbus = client->dbus; - /* SDL_DBus_CallMethod cannot handle a(ss) type, call dbus function directly */ + // 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); @@ -433,7 +433,7 @@ void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window) #endif if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) { - /* move to bottom left */ + // move to bottom left int w = 0, h = 0; SDL_GetWindowSize(window, &w, &h); cursor->x = 0; @@ -455,6 +455,6 @@ void SDL_Fcitx_PumpEvents(void) dbus->connection_read_write(conn, 0); while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) { - /* Do nothing, actual work happens in DBus_MessageFilter */ + // Do nothing, actual work happens in DBus_MessageFilter } } diff --git a/src/core/linux/SDL_fcitx.h b/src/core/linux/SDL_fcitx.h index 75c2510e05..abc763399e 100644 --- a/src/core/linux/SDL_fcitx.h +++ b/src/core/linux/SDL_fcitx.h @@ -32,4 +32,4 @@ extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 s extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window); extern void SDL_Fcitx_PumpEvents(void); -#endif /* SDL_fcitx_h_ */ +#endif // SDL_fcitx_h_ diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 7fe5baa65e..f7438d347b 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -62,7 +62,7 @@ static Uint32 IBus_ModState(void) Uint32 ibus_mods = 0; SDL_Keymod sdl_mods = SDL_GetModState(); - /* Not sure about MOD3, MOD4 and HYPER mappings */ + // Not sure about MOD3, MOD4 and HYPER mappings if (sdl_mods & SDL_KMOD_LSHIFT) { ibus_mods |= IBUS_SHIFT_MASK; } @@ -152,16 +152,16 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter dbus->message_iter_next(&sub); dbus->message_iter_next(&sub); - /* From here on, the structure looks like this: */ - /* Uint32 type: 1=underline, 2=foreground, 3=background */ - /* Uint32 value: for underline it's 0=NONE, 1=SINGLE, 2=DOUBLE, */ - /* 3=LOW, 4=ERROR */ - /* for foreground and background it's a color */ - /* Uint32 start_index: starting position for the style (utf8-char) */ - /* Uint32 end_index: end position for the style (utf8-char) */ + // From here on, the structure looks like this: + // Uint32 type: 1=underline, 2=foreground, 3=background + // Uint32 value: for underline it's 0=NONE, 1=SINGLE, 2=DOUBLE, + // 3=LOW, 4=ERROR + // for foreground and background it's a color + // Uint32 start_index: starting position for the style (utf8-char) + // Uint32 end_index: end position for the style (utf8-char) dbus->message_iter_get_basic(&sub, &type); - /* We only use the background type to determine the selection */ + // We only use the background type to determine the selection if (type == 3) { Uint32 start = -1; dbus->message_iter_next(&sub); @@ -184,7 +184,7 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter 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 */ + // The text we need is nested weirdly, use dbus-monitor to see the structure better const char *text = NULL; DBusMessageIter sub; @@ -330,7 +330,7 @@ static char *IBus_GetDBusAddressFilename(void) return NULL; } - /* Use this environment variable if it exists. */ + // Use this environment variable if it exists. addr = SDL_getenv("IBUS_ADDRESS"); if (addr && *addr) { return SDL_strdup(addr); @@ -453,7 +453,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) ibus_conn = dbus->connection_open_private(addr, NULL); if (!ibus_conn) { - return SDL_FALSE; /* oh well. */ + return SDL_FALSE; // oh well. } dbus->connection_flush(ibus_conn); @@ -469,7 +469,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); } else { - /* re-using dbus->session_conn */ + // re-using dbus->session_conn dbus->connection_ref(ibus_conn); } @@ -584,7 +584,7 @@ SDL_bool SDL_IBus_Init(void) result = IBus_SetupConnection(dbus, addr); SDL_free(addr); - /* don't use the addr_file if using the portal interface. */ + // don't use the addr_file if using the portal interface. if (result && ibus_is_portal_interface) { if (inotify_fd > 0) { if (inotify_wd > 0) { @@ -616,7 +616,7 @@ void SDL_IBus_Quit(void) dbus = SDL_DBus_GetContext(); - /* if using portal, ibus_conn == session_conn; don't release it here. */ + // 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); dbus->connection_unref(ibus_conn); @@ -633,7 +633,7 @@ void SDL_IBus_Quit(void) inotify_wd = -1; } - /* !!! FIXME: should we close(inotify_fd) here? */ + // !!! FIXME: should we close(inotify_fd) here? SDL_DelHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, IBus_SetCapabilities, NULL); @@ -733,7 +733,7 @@ void SDL_IBus_PumpEvents(void) 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 */ + // 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 97ce32a71c..97f924b60e 100644 --- a/src/core/linux/SDL_ibus.h +++ b/src/core/linux/SDL_ibus.h @@ -31,10 +31,10 @@ extern SDL_bool SDL_IBus_Init(void); extern void SDL_IBus_Quit(void); -/* Lets the IBus server know about changes in window focus */ +// Lets the IBus server know about changes in window focus extern void SDL_IBus_SetFocus(SDL_bool focused); -/* Closes the candidate list and resets any text currently being edited */ +// Closes the candidate list and resets any text currently being edited extern void SDL_IBus_Reset(void); /* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to @@ -50,6 +50,6 @@ extern void SDL_IBus_UpdateTextInputArea(SDL_Window *window); SDL_SendEditingText for each event it finds */ extern void SDL_IBus_PumpEvents(void); -#endif /* HAVE_IBUS_IBUS_H */ +#endif // HAVE_IBUS_IBUS_H -#endif /* SDL_ibus_h_ */ +#endif // SDL_ibus_h_ diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c index d9be1f0edf..c248c019a1 100644 --- a/src/core/linux/SDL_ime.c +++ b/src/core/linux/SDL_ime.c @@ -54,7 +54,7 @@ static void InitIME(void) inited = SDL_TRUE; - /* See if fcitx IME support is being requested */ + // See if fcitx IME support is being requested #ifdef HAVE_FCITX if (!SDL_IME_Init_Real && ((im_module && SDL_strcmp(im_module, "fcitx") == 0) || @@ -67,9 +67,9 @@ static void InitIME(void) SDL_IME_UpdateTextInputArea_Real = SDL_Fcitx_UpdateTextInputArea; SDL_IME_PumpEvents_Real = SDL_Fcitx_PumpEvents; } -#endif /* HAVE_FCITX */ +#endif // HAVE_FCITX - /* default to IBus */ + // default to IBus #ifdef HAVE_IBUS_IBUS_H if (!SDL_IME_Init_Real) { SDL_IME_Init_Real = SDL_IBus_Init; @@ -80,7 +80,7 @@ static void InitIME(void) SDL_IME_UpdateTextInputArea_Real = SDL_IBus_UpdateTextInputArea; SDL_IME_PumpEvents_Real = SDL_IBus_PumpEvents; } -#endif /* HAVE_IBUS_IBUS_H */ +#endif // HAVE_IBUS_IBUS_H } SDL_bool SDL_IME_Init(void) @@ -92,7 +92,7 @@ SDL_bool SDL_IME_Init(void) return SDL_TRUE; } - /* uhoh, the IME implementation's init failed! Disable IME support. */ + // uhoh, the IME implementation's init failed! Disable IME support. SDL_IME_Init_Real = NULL; SDL_IME_Quit_Real = NULL; SDL_IME_SetFocus_Real = NULL; diff --git a/src/core/linux/SDL_ime.h b/src/core/linux/SDL_ime.h index 700f5c626c..ef16cdbe5b 100644 --- a/src/core/linux/SDL_ime.h +++ b/src/core/linux/SDL_ime.h @@ -32,4 +32,4 @@ extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 sta extern void SDL_IME_UpdateTextInputArea(SDL_Window *window); extern void SDL_IME_PumpEvents(void); -#endif /* SDL_ime_h_ */ +#endif // SDL_ime_h_ diff --git a/src/core/linux/SDL_sandbox.h b/src/core/linux/SDL_sandbox.h index 8339c90b45..d480658ce2 100644 --- a/src/core/linux/SDL_sandbox.h +++ b/src/core/linux/SDL_sandbox.h @@ -31,7 +31,7 @@ typedef enum SDL_SANDBOX_SNAP, } SDL_Sandbox; -/* Return the sandbox type currently in use, if any */ +// Return the sandbox type currently in use, if any SDL_Sandbox SDL_DetectSandbox(void); -#endif /* SDL_SANDBOX_H */ +#endif // SDL_SANDBOX_H diff --git a/src/core/linux/SDL_system_theme.c b/src/core/linux/SDL_system_theme.c index 1623775afe..0d4846b9d0 100644 --- a/src/core/linux/SDL_system_theme.c +++ b/src/core/linux/SDL_system_theme.c @@ -77,7 +77,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m const char *namespace, *key; dbus->message_iter_init(msg, &signal_iter); - /* Check if the parameters are what we expect */ + // Check if the parameters are what we expect if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING) goto not_our_signal; dbus->message_iter_get_basic(&signal_iter, &namespace); @@ -127,7 +127,7 @@ SDL_bool SDL_SystemTheme_Init(void) DBusMessageIter reply_iter, variant_outer_iter; dbus->message_iter_init(reply, &reply_iter); - /* The response has signature <> */ + // The response has signature <> if (dbus->message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT) goto incorrect_type; dbus->message_iter_recurse(&reply_iter, &variant_outer_iter); diff --git a/src/core/linux/SDL_system_theme.h b/src/core/linux/SDL_system_theme.h index 396b3a76ef..85e1fffbb7 100644 --- a/src/core/linux/SDL_system_theme.h +++ b/src/core/linux/SDL_system_theme.h @@ -27,4 +27,4 @@ extern SDL_bool SDL_SystemTheme_Init(void); extern SDL_SystemTheme SDL_SystemTheme_Get(void); -#endif /* SDL_system_theme_h_ */ +#endif // SDL_system_theme_h_ diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index d70d9a7eb2..bd1daac081 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -29,11 +29,11 @@ #include #include -/* RLIMIT_RTTIME requires kernel >= 2.6.25 and is in glibc >= 2.14 */ +// RLIMIT_RTTIME requires kernel >= 2.6.25 and is in glibc >= 2.14 #ifndef RLIMIT_RTTIME #define RLIMIT_RTTIME 15 #endif -/* SCHED_RESET_ON_FORK is in kernel >= 2.6.32. */ +// SCHED_RESET_ON_FORK is in kernel >= 2.6.32. #ifndef SCHED_RESET_ON_FORK #define SCHED_RESET_ON_FORK 0x40000000 #endif @@ -42,12 +42,12 @@ #ifdef SDL_USE_LIBDBUS -/* d-bus queries to org.freedesktop.RealtimeKit1. */ +// d-bus queries to 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 */ +// 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_INTERFACE "org.freedesktop.portal.Realtime" @@ -78,13 +78,13 @@ static void set_rtkit_interface(void) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - /* xdg-desktop-portal works in all instances, so check for it first. */ + // xdg-desktop-portal works in all instances, so check for it first. if (dbus && realtime_portal_supported(dbus->session_conn)) { rtkit_use_session_conn = SDL_TRUE; rtkit_dbus_node = XDG_PORTAL_DBUS_NODE; rtkit_dbus_path = XDG_PORTAL_DBUS_PATH; rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE; - } else { /* Fall back to the standard rtkit interface in all other cases. */ + } else { // Fall back to the standard rtkit interface in all other cases. rtkit_use_session_conn = SDL_FALSE; rtkit_dbus_node = RTKIT_DBUS_NODE; rtkit_dbus_path = RTKIT_DBUS_PATH; @@ -110,19 +110,19 @@ static void rtkit_initialize(void) set_rtkit_interface(); dbus_conn = get_rtkit_dbus_connection(); - /* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */ + // Try getting minimum nice level: this is often greater than PRIO_MIN (-20). if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel", DBUS_TYPE_INT32, &rtkit_min_nice_level)) { rtkit_min_nice_level = -20; } - /* Try getting maximum realtime priority: this can be less than the POSIX default (99). */ + // Try getting maximum realtime priority: this can be less than the POSIX default (99). if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority", DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) { rtkit_max_realtime_priority = 99; } - /* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */ + // Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax", DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) { rtkit_max_rttime_usec = 200000; @@ -245,10 +245,10 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) #define rtkit_max_realtime_priority 99 -#endif /* dbus */ -#endif /* threads */ +#endif // dbus +#endif // threads -/* this is a public symbol, so it has to exist even if threads are disabled. */ +// this is a public symbol, so it has to exist even if threads are disabled. int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority) { #ifdef SDL_THREADS_DISABLED @@ -280,7 +280,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority) #endif } -/* this is a public symbol, so it has to exist even if threads are disabled. */ +// this is a public symbol, so it has to exist even if threads are disabled. int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) { #ifdef SDL_THREADS_DISABLED @@ -342,4 +342,4 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc #endif } -#endif /* SDL_PLATFORM_LINUX */ +#endif // SDL_PLATFORM_LINUX diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index fb99213825..3faf2194cc 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -52,7 +52,7 @@ static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); if (!*addr) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + // Don't call SDL_SetError(): SDL_LoadFunction already did. return SDL_FALSE; } @@ -146,7 +146,7 @@ int SDL_UDEV_Init(void) _this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "video4linux", NULL); _this->syms.udev_monitor_enable_receiving(_this->udev_mon); - /* Do an initial scan of existing devices */ + // Do an initial scan of existing devices SDL_UDEV_Scan(); } @@ -174,7 +174,7 @@ void SDL_UDEV_Quit(void) _this->udev = NULL; } - /* Remove existing devices */ + // Remove existing devices while (_this->first) { SDL_UDEV_CallbackList *item = _this->first; _this->first = _this->first->next; @@ -299,13 +299,13 @@ int SDL_UDEV_LoadLibrary(void) return SDL_SetError("UDEV not initialized"); } - /* See if there is a udev library already loaded */ + // See if there is a udev library already loaded if (SDL_UDEV_load_syms() == 0) { return 0; } #ifdef SDL_UDEV_DYNAMIC - /* Check for the build environment's libudev first */ + // Check for the build environment's libudev first if (!_this->udev_handle) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC); if (_this->udev_handle) { @@ -332,7 +332,7 @@ int SDL_UDEV_LoadLibrary(void) if (!_this->udev_handle) { retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + // Don't call SDL_SetError(): SDL_LoadObject already did. } } @@ -420,7 +420,7 @@ static int device_class(struct udev_device *dev) devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE; } } else if (SDL_strcmp(subsystem, "input") == 0) { - /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */ + // 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 && SDL_strcmp(val, "1") == 0) { @@ -459,7 +459,7 @@ static int device_class(struct udev_device *dev) } if (devclass == 0) { - /* Fall back to old style input classes */ + // Fall back to old style input classes val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS"); if (val) { if (SDL_strcmp(val, "joystick") == 0) { @@ -470,7 +470,7 @@ static int device_class(struct udev_device *dev) devclass = SDL_UDEV_DEVICE_HAS_KEYS | SDL_UDEV_DEVICE_KEYBOARD; } } else { - /* We could be linked with libudev on a system that doesn't have udev running */ + // We could be linked with libudev on a system that doesn't have udev running devclass = guess_device_class(dev); } } @@ -495,7 +495,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) return; } - /* Process callbacks */ + // Process callbacks for (item = _this->first; item; item = item->next) { item->callback(type, devclass, path); } @@ -559,7 +559,7 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) } for (item = _this->first; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (item->callback == cb) { if (prev) { prev->next = item->next; @@ -592,4 +592,4 @@ void SDL_UDEV_ReleaseUdevSyms(void) SDL_UDEV_Quit(); } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index b3972d675c..fccdd22a49 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -92,7 +92,7 @@ typedef struct SDL_UDEV_PrivateData int ref_count; SDL_UDEV_CallbackList *first, *last; - /* Function pointers */ + // Function pointers SDL_UDEV_Symbols syms; } SDL_UDEV_PrivateData; @@ -108,6 +108,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 // HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H -#endif /* SDL_udev_h_ */ +#endif // SDL_udev_h_ diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index d1bc42bd68..2d02135702 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -53,44 +53,44 @@ 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 */ +// 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 */ + // 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 }; -/* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ +// Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c static struct SDL_wscons_compose_tab_s { keysym_t elem[2]; @@ -487,7 +487,7 @@ void SDL_WSCONS_Quit(void) 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 */ + // c is already part of a UTF-8 sequence and safe to add as a character if (kbd->text_len < (sizeof(kbd->text) - 1)) { kbd->text[kbd->text_len++] = (char)(c); } @@ -535,7 +535,7 @@ static void Translate_to_text(SDL_WSCONS_input_data *input, keysym_t ksym) case KS_BackSpace: case KS_Return: case KS_Linefeed: - /* All of these are unprintable characters. Ignore them */ + // All of these are unprintable characters. Ignore them break; default: put_utf8(input, ksym); @@ -544,7 +544,7 @@ static void Translate_to_text(SDL_WSCONS_input_data *input, keysym_t ksym) if (input->text_len > 0) { input->text[input->text_len] = '\0'; SDL_SendKeyboardText(input->text); - /*SDL_memset(input->text, 0, sizeof(input->text));*/ + // SDL_memset(input->text, 0, sizeof(input->text)); input->text_len = 0; input->text[0] = 0; } @@ -556,7 +556,7 @@ static void Translate_to_keycode(SDL_WSCONS_input_data *input, int type, keysym_ 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]*/ + // Check command first, then group[0] switch (keyDesc.command) { case KS_Cmd_ScrollBack: { diff --git a/src/core/openbsd/SDL_wscons_mouse.c b/src/core/openbsd/SDL_wscons_mouse.c index 13864be935..9eadd36c24 100644 --- a/src/core/openbsd/SDL_wscons_mouse.c +++ b/src/core/openbsd/SDL_wscons_mouse.c @@ -78,13 +78,13 @@ void updateMouse(SDL_WSCONS_mouse_input_data *input) case WSCONS_EVENT_MOUSE_DOWN: { switch (events[i].value) { - case 0: /* Left Mouse Button. */ + case 0: // Left Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); break; - case 1: /* Middle Mouse Button. */ + case 1: // Middle Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_MIDDLE); break; - case 2: /* Right Mouse Button. */ + case 2: // Right Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); break; } @@ -92,13 +92,13 @@ void updateMouse(SDL_WSCONS_mouse_input_data *input) case WSCONS_EVENT_MOUSE_UP: { switch (events[i].value) { - case 0: /* Left Mouse Button. */ + case 0: // Left Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); break; - case 1: /* Middle Mouse Button. */ + case 1: // Middle Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_MIDDLE); break; - case 2: /* Right Mouse Button. */ + case 2: // Right Mouse Button. SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); break; } diff --git a/src/core/unix/SDL_appid.c b/src/core/unix/SDL_appid.c index 4a3a53b222..046b882447 100644 --- a/src/core/unix/SDL_appid.c +++ b/src/core/unix/SDL_appid.c @@ -28,7 +28,7 @@ const char *SDL_GetExeName(void) { static const char *proc_name = NULL; - /* TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all) */ + // TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all) if (!proc_name) { #if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD) static char linkfile[1024]; @@ -62,12 +62,12 @@ const char *SDL_GetAppID(void) const char *id_str = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING); if (!id_str) { - /* If the hint isn't set, try to use the application's executable name */ + // If the hint isn't set, try to use the application's executable name id_str = SDL_GetExeName(); } if (!id_str) { - /* Finally, use the default we've used forever */ + // Finally, use the default we've used forever id_str = "SDL_App"; } diff --git a/src/core/unix/SDL_appid.h b/src/core/unix/SDL_appid.h index 976788cb13..476605097e 100644 --- a/src/core/unix/SDL_appid.h +++ b/src/core/unix/SDL_appid.h @@ -27,4 +27,4 @@ freely, subject to the following restrictions: extern const char *SDL_GetExeName(); extern const char *SDL_GetAppID(); -#endif /* SDL_appid_h_ */ +#endif // SDL_appid_h_ diff --git a/src/core/unix/SDL_poll.c b/src/core/unix/SDL_poll.c index 2ff460997d..b164efd4d4 100644 --- a/src/core/unix/SDL_poll.c +++ b/src/core/unix/SDL_poll.c @@ -38,7 +38,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS) SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE)); - /* Note: We don't bother to account for elapsed time if we get EINTR */ + // Note: We don't bother to account for elapsed time if we get EINTR do { #ifdef HAVE_POLL struct pollfd info; @@ -52,7 +52,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS) if (flags & SDL_IOR_WRITE) { info.events |= POLLOUT; } - /* FIXME: Add support for ppoll() for nanosecond precision */ + // FIXME: Add support for ppoll() for nanosecond precision if (timeoutNS > 0) { timeoutMS = (int)SDL_NS_TO_MS(timeoutNS); } else if (timeoutNS == 0) { @@ -66,7 +66,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS) fd_set wfdset, *wfdp = NULL; struct timeval tv, *tvp = NULL; - /* If this assert triggers we'll corrupt memory here */ + // If this assert triggers we'll corrupt memory here SDL_assert(fd >= 0 && fd < FD_SETSIZE); if (flags & SDL_IOR_READ) { @@ -87,7 +87,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS) } result = select(fd + 1, rfdp, wfdp, NULL, tvp); -#endif /* HAVE_POLL */ +#endif // HAVE_POLL } while (result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY)); diff --git a/src/core/unix/SDL_poll.h b/src/core/unix/SDL_poll.h index eef1d64b27..8034b1dc08 100644 --- a/src/core/unix/SDL_poll.h +++ b/src/core/unix/SDL_poll.h @@ -30,4 +30,4 @@ extern int SDL_IOReady(int fd, int flags, Sint64 timeoutNS); -#endif /* SDL_poll_h_ */ +#endif // SDL_poll_h_ diff --git a/src/core/windows/SDL_directx.h b/src/core/windows/SDL_directx.h index 6736d8d7bd..3acf0ae468 100644 --- a/src/core/windows/SDL_directx.h +++ b/src/core/windows/SDL_directx.h @@ -23,7 +23,7 @@ #ifndef SDL_directx_h_ #define SDL_directx_h_ -/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */ +// Include all of the DirectX 8.0 headers and adds any necessary tweaks #include "SDL_windows.h" #include @@ -32,12 +32,12 @@ #endif #undef WINNT -/* Far pointers don't exist in 32-bit code */ +// Far pointers don't exist in 32-bit code #ifndef FAR #define FAR #endif -/* Error codes not yet included in Win32 API header files */ +// 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)))) @@ -73,12 +73,12 @@ #define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L #endif -/* Severity codes */ +// Severity codes #ifndef SEVERITY_ERROR #define SEVERITY_ERROR 1 #endif -/* Error facility codes */ +// Error facility codes #ifndef FACILITY_WIN32 #define FACILITY_WIN32 7 #endif @@ -89,10 +89,10 @@ /* DirectX headers (if it isn't included, I haven't tested it yet) */ -/* We need these defines to mark what version of DirectX API we use */ +// We need these defines to mark what version of DirectX API we use #define DIRECTDRAW_VERSION 0x0700 #define DIRECTSOUND_VERSION 0x0800 -#define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */ +#define DIRECTINPUT_VERSION 0x0800 // Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... #ifdef HAVE_DDRAW_H #include @@ -109,4 +109,4 @@ typedef struct } DIDEVICEINSTANCE; #endif -#endif /* SDL_directx_h_ */ +#endif // SDL_directx_h_ diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 0e42bb6671..a427aba86e 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -41,7 +41,7 @@ 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")); @@ -82,11 +82,11 @@ void WIN_UnloadHIDDLL(void) } } -#endif /* !SDL_PLATFORM_WINRT */ +#endif // !SDL_PLATFORM_WINRT #if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -/* CM_Register_Notification definitions */ +// CM_Register_Notification definitions #define CR_SUCCESS 0 @@ -224,7 +224,7 @@ void WIN_QuitDeviceNotification(void) if (--s_DeviceNotificationsRequested > 0) { return; } - /* Make sure we have balanced calls to init/quit */ + // Make sure we have balanced calls to init/quit SDL_assert(s_DeviceNotificationsRequested == 0); if (cfgmgr32_lib_handle) { diff --git a/src/core/windows/SDL_hid.h b/src/core/windows/SDL_hid.h index 3d78211265..01cca0a593 100644 --- a/src/core/windows/SDL_hid.h +++ b/src/core/windows/SDL_hid.h @@ -208,11 +208,11 @@ extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps; extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength; extern HidP_GetData_t SDL_HidP_GetData; -#endif /* !SDL_PLATFORM_WINRT */ +#endif // !SDL_PLATFORM_WINRT void WIN_InitDeviceNotification(void); Uint64 WIN_GetLastDeviceNotification(void); void WIN_QuitDeviceNotification(void); -#endif /* SDL_hid_h_ */ +#endif // SDL_hid_h_ diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index fb3e74fd37..07f86ccc2e 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -25,7 +25,7 @@ #include "SDL_windows.h" #include "SDL_immdevice.h" #include "../../audio/SDL_sysaudio.h" -#include /* For CLSIDFromString */ +#include // For CLSIDFromString typedef struct SDL_IMMDevice_HandleData { @@ -33,20 +33,20 @@ typedef struct SDL_IMMDevice_HandleData GUID directsound_guid; } SDL_IMMDevice_HandleData; -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. */ +// This is global to the WASAPI target, to handle hotplug and default device lookup. static IMMDeviceEnumerator *enumerator = NULL; static SDL_IMMDevice_callbacks immcallbacks; -/* PropVariantInit() is an inline function/macro in PropIdl.h that calls the C runtime's memset() directly. Use ours instead, to avoid dependency. */ +// PropVariantInit() is an inline function/macro in PropIdl.h that calls the C runtime's memset() directly. Use ours instead, to avoid dependency. #ifdef PropVariantInit #undef PropVariantInit #endif #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 */ +// 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 } }; @@ -54,7 +54,7 @@ static const IID SDL_IID_IMMEndpoint = { 0x1be09788, 0x6894, 0x4089,{ 0x85, 0x86 static const PROPERTYKEY SDL_PKEY_Device_FriendlyName = { { 0xa45c254e, 0xdf1c, 0x4efd,{ 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, } }, 14 }; static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x82c, 0x4e27,{ 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, } }, 0 }; static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on static SDL_bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata) { @@ -205,11 +205,11 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_AddRef(IMMNotificationCli static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationClient *iclient) { - /* client is a static object; we don't ever free it. */ + // client is a static object; we don't ever free it. SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient; const ULONG retval = SDL_AtomicDecRef(&client->refcount); if (retval == 0) { - SDL_AtomicSet(&client->refcount, 0); /* uhh... */ + SDL_AtomicSet(&client->refcount, 0); // uhh... return 0; } return retval - 1; @@ -292,7 +292,7 @@ int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks) { HRESULT ret; - /* just skip the discussion with COM here. */ + // just skip the discussion with COM here. if (!WIN_IsWindowsVistaOrGreater()) { return SDL_SetError("IMMDevice support requires Windows Vista or later"); } @@ -338,7 +338,7 @@ void SDL_IMMDevice_Quit(void) int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording) { - const Uint64 timeout = SDL_GetTicks() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */ + const Uint64 timeout = SDL_GetTicks() + 8000; // intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. SDL_assert(device != NULL); SDL_assert(immdevice != NULL); @@ -351,7 +351,7 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool r const Uint64 now = SDL_GetTicks(); if (timeout > now) { const Uint64 ticksleft = timeout - now; - SDL_Delay((Uint32)SDL_min(ticksleft, 300)); /* wait awhile and try again. */ + SDL_Delay((Uint32)SDL_min(ticksleft, 300)); // wait awhile and try again. continue; } break; @@ -425,8 +425,8 @@ void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_Au EnumerateEndpointsForFlow(SDL_FALSE, default_playback); EnumerateEndpointsForFlow(SDL_TRUE, default_recording); - /* if this fails, we just won't get hotplug events. Carry on anyhow. */ + // if this fails, we just won't get hotplug events. Carry on anyhow. IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client); } -#endif /* (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) */ +#endif // (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) diff --git a/src/core/windows/SDL_immdevice.h b/src/core/windows/SDL_immdevice.h index d3b8435c8a..b119ed05df 100644 --- a/src/core/windows/SDL_immdevice.h +++ b/src/core/windows/SDL_immdevice.h @@ -42,4 +42,4 @@ LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device); LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device); void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device); -#endif /* SDL_IMMDEVICE_H */ +#endif // SDL_IMMDEVICE_H diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 85d7ba07d2..c7913cb025 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -24,9 +24,9 @@ #include "SDL_windows.h" -#include /* for CoInitialize/CoUninitialize (Win32 only) */ +#include // for CoInitialize/CoUninitialize (Win32 only) #ifdef HAVE_ROAPI_H -#include /* For RoInitialize/RoUninitialize (Win32 only) */ +#include // For RoInitialize/RoUninitialize (Win32 only) #else typedef enum RO_INIT_TYPE { @@ -53,7 +53,7 @@ typedef enum RO_INIT_TYPE #define WC_ERR_INVALID_CHARS 0x00000080 #endif -/* Sets an error message based on an HRESULT */ +// Sets an error message based on an HRESULT int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) { TCHAR buffer[1024]; @@ -62,7 +62,7 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) DWORD c = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, buffer, SDL_arraysize(buffer), NULL); buffer[c] = 0; - /* kill CR/LF that FormatMessage() sticks at the end */ + // kill CR/LF that FormatMessage() sticks at the end while (*p) { if (*p == '\r') { *p = 0; @@ -76,7 +76,7 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) return -1; } -/* Sets an error message based on GetLastError() */ +// Sets an error message based on GetLastError() int WIN_SetError(const char *prefix) { return WIN_SetErrorFromHRESULT(prefix, GetLastError()); @@ -98,7 +98,7 @@ WIN_CoInitialize(void) */ return S_OK; #elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - /* On Xbox, there's no need to call CoInitializeEx (and it's not implemented) */ + // On Xbox, there's no need to call CoInitializeEx (and it's not implemented) return S_OK; #else HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -106,8 +106,8 @@ WIN_CoInitialize(void) hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); } - /* S_FALSE means success, but someone else already initialized. */ - /* You still need to call CoUninitialize in this case! */ + // S_FALSE means success, but someone else already initialized. + // You still need to call CoUninitialize in this case! if (hr == S_FALSE) { return S_OK; } @@ -150,14 +150,14 @@ WIN_RoInitialize(void) 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 */ + // RO_INIT_SINGLETHREADED is equivalent to COINIT_APARTMENTTHREADED HRESULT hr = RoInitializeFunc(RO_INIT_SINGLETHREADED); if (hr == RPC_E_CHANGED_MODE) { hr = RoInitializeFunc(RO_INIT_MULTITHREADED); } - /* S_FALSE means success, but someone else already initialized. */ - /* You still need to call RoUninitialize in this case! */ + // S_FALSE means success, but someone else already initialized. + // You still need to call RoUninitialize in this case! if (hr == S_FALSE) { return S_OK; } @@ -266,7 +266,7 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM. char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { #if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - return WIN_StringToUTF8W(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */ + return WIN_StringToUTF8W(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; @@ -278,7 +278,7 @@ char *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; @@ -291,34 +291,34 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) 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)); if (!strw) { 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); 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); return retval ? retval : WIN_StringToUTF8(name); -#endif /* if SDL_PLATFORM_WINRT / else */ +#endif // if SDL_PLATFORM_WINRT / else } BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) @@ -349,15 +349,15 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) BOOL WIN_IsRectEmpty(const RECT *rect) { - /* Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty. */ + // Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty. return (rect->right <= rect->left) || (rect->bottom <= rect->top); } -/* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ -/* *INDENT-OFF* */ /* clang-format off */ +// Some GUIDs we need to know without linking to libraries that aren't available before Vista. +/* *INDENT-OFF* */ // clang-format off 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 */ +/* *INDENT-ON* */ // clang-format on SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat) { @@ -389,4 +389,4 @@ int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, return WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar); } -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index d1a54ab323..3d7f5c043f 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* This is an include file for windows.h with the SDL build settings */ +// This is an include file for windows.h with the SDL build settings #ifndef _INCLUDED_WINDOWS_H #define _INCLUDED_WINDOWS_H @@ -37,11 +37,11 @@ #undef WINVER #undef _WIN32_WINNT #if SDL_VIDEO_RENDER_D3D12 || defined(HAVE_DXGI1_6_H) -#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 @@ -76,8 +76,8 @@ #define WINVER _WIN32_WINNT #endif -/* See https://github.com/libsdl-org/SDL/pull/7607 */ -/* force_align_arg_pointer attribute requires gcc >= 4.2.x. */ +// See https://github.com/libsdl-org/SDL/pull/7607 +// force_align_arg_pointer attribute requires gcc >= 4.2.x. #if defined(__clang__) #define HAVE_FORCE_ALIGN_ARG_POINTER #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) @@ -90,13 +90,13 @@ #endif #include -#include /* for REFIID with broken mingw.org headers */ +#include // for REFIID with broken mingw.org headers #include -/* Routines to convert from UTF8 to native Windows text */ +// 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) -/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ +// !!! 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) #if UNICODE @@ -111,64 +111,64 @@ #define SDL_tcsstr SDL_strstr #endif -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* Sets an error message based on a given HRESULT */ +// Sets an error message based on a given HRESULT extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); -/* Sets an error message based on GetLastError(). Always return -1. */ +// Sets an error message based on GetLastError(). Always return -1. extern int WIN_SetError(const char *prefix); #ifndef SDL_PLATFORM_WINRT -/* Load a function from combase.dll */ +// Load a function from combase.dll FARPROC WIN_LoadComBaseFunction(const char *name); #endif -/* Wrap up the oddities of CoInitialize() into a common function. */ +// Wrap up the oddities of CoInitialize() into a common function. extern HRESULT WIN_CoInitialize(void); extern void WIN_CoUninitialize(void); -/* Wrap up the oddities of RoInitialize() into a common function. */ +// Wrap up the oddities of RoInitialize() into a common function. extern HRESULT WIN_RoInitialize(void); extern void WIN_RoUninitialize(void); -/* Returns SDL_TRUE if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"! */ +// Returns SDL_TRUE if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"! extern BOOL WIN_IsWindowsXP(void); -/* Returns SDL_TRUE if we're running on Windows Vista and newer */ +// Returns SDL_TRUE if we're running on Windows Vista and newer extern BOOL WIN_IsWindowsVistaOrGreater(void); -/* Returns SDL_TRUE if we're running on Windows 7 and newer */ +// Returns SDL_TRUE if we're running on Windows 7 and newer extern BOOL WIN_IsWindows7OrGreater(void); -/* Returns SDL_TRUE if we're running on Windows 8 and newer */ +// Returns SDL_TRUE if we're running on Windows 8 and newer extern BOOL WIN_IsWindows8OrGreater(void); -/* You need to SDL_free() the result of this call. */ +// You need to SDL_free() the result of this call. extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); -/* Checks to see if two GUID are the same. */ +// Checks to see if two GUID are the same. extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b); extern BOOL WIN_IsEqualIID(REFIID a, REFIID b); -/* Convert between SDL_rect and RECT */ +// Convert between SDL_rect and RECT extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect); extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect); -/* Returns SDL_TRUE if the rect is empty */ +// Returns SDL_TRUE if the rect is empty extern BOOL WIN_IsRectEmpty(const RECT *rect); extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat); -/* WideCharToMultiByte, but with some WinXP manangement. */ +// WideCharToMultiByte, but with some WinXP manangement. extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* _INCLUDED_WINDOWS_H */ +#endif // _INCLUDED_WINDOWS_H diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 13c06bde4d..7221904162 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -22,7 +22,7 @@ #include "SDL_xinput.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -58,7 +58,7 @@ int WIN_LoadXInputDLL(void) SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities; SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation; - /* XInput 1.4 ships with Windows 8 and 8.1: */ + // XInput 1.4 ships with Windows 8 and 8.1: SDL_XInputVersion = (1 << 16) | 4; return 0; @@ -68,7 +68,7 @@ void WIN_UnloadXInputDLL(void) { } -#else /* !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#else // !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) int WIN_LoadXInputDLL(void) { @@ -77,7 +77,7 @@ int WIN_LoadXInputDLL(void) if (s_pXInputDLL) { SDL_assert(s_XInputDLLRefCount > 0); s_XInputDLLRefCount++; - return 0; /* already loaded */ + return 0; // already loaded } /* NOTE: Don't load XinputUap.dll @@ -85,16 +85,16 @@ int 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")); } if (!s_pXInputDLL) { - /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) */ + // "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll")); } if (!s_pXInputDLL) { @@ -105,14 +105,14 @@ int WIN_LoadXInputDLL(void) SDL_XInputVersion = version; s_XInputDLLRefCount = 1; - /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */ + // 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100); if (!SDL_XInputGetState) { SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState"); } SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState"); SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities"); - /* 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller. */ + // 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller. SDL_XInputGetCapabilitiesEx = (XInputGetCapabilitiesEx_t)GetProcAddress(s_pXInputDLL, (LPCSTR)108); SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation"); if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) { @@ -136,9 +136,9 @@ void WIN_UnloadXInputDLL(void) } } -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h index 200c8b6fe1..48f6740927 100644 --- a/src/core/windows/SDL_xinput.h +++ b/src/core/windows/SDL_xinput.h @@ -27,14 +27,14 @@ #ifdef HAVE_XINPUT_H #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) -/* Xbox supports an XInput wrapper which is a C++-only header... */ -#include /* Required to compile with recent MSVC... */ +// Xbox supports an XInput wrapper which is a C++-only header... +#include // Required to compile with recent MSVC... #include using namespace XInputOnGameInput; #else #include #endif -#endif /* HAVE_XINPUT_H */ +#endif // HAVE_XINPUT_H #ifndef XUSER_MAX_COUNT #define XUSER_MAX_COUNT 4 @@ -160,15 +160,15 @@ using namespace XInputOnGameInput; #define BATTERY_LEVEL_FULL 0x03 #endif -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* typedef's for XInput structs we use */ +// typedef's for XInput structs we use -/* This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 */ +// This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 typedef struct { BYTE BatteryType; @@ -209,9 +209,9 @@ typedef struct XINPUT_VIBRATION Vibration; } XINPUT_CAPABILITIES; -#endif /* HAVE_XINPUT_H */ +#endif // HAVE_XINPUT_H -/* This struct is not defined in XInput headers. */ +// This struct is not defined in XInput headers. typedef struct { XINPUT_CAPABILITIES Capabilities; @@ -222,29 +222,29 @@ typedef struct DWORD unk2; } SDL_XINPUT_CAPABILITIES_EX; -/* Forward decl's for XInput API's we load dynamically and use if available */ +// 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 *pState /* [out] Receives the current state */ + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + XINPUT_STATE *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 */ + 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 */ + 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 ); -/* Only available in XInput 1.4 that is shipped with Windows 8 and newer. */ +// Only available in XInput 1.4 that is shipped with Windows 8 and newer. typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)( - DWORD dwReserved, /* [in] Must be 1 */ - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - DWORD dwFlags, /* [in] Input flags that identify the device type */ - SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */ + DWORD dwReserved, // [in] Must be 1 + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + DWORD dwFlags, // [in] Input flags that identify the device type + SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx // [out] Receives the capabilities ); typedef DWORD(WINAPI *XInputGetBatteryInformation_t)( @@ -260,9 +260,9 @@ extern XInputSetState_t SDL_XInputSetState; extern XInputGetCapabilities_t SDL_XInputGetCapabilities; extern XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx; 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++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif @@ -273,4 +273,4 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ #define XINPUTGETCAPABILITIESEX SDL_XInputGetCapabilitiesEx #define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation -#endif /* SDL_xinput_h_ */ +#endif // SDL_xinput_h_ diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp index 231d6cf4d9..be3558dea7 100644 --- a/src/core/winrt/SDL_winrtapp_common.cpp +++ b/src/core/winrt/SDL_winrtapp_common.cpp @@ -27,7 +27,7 @@ int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL; extern "C" SDL_WinRT_DeviceFamily SDL_GetWinRTDeviceFamily() { -#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. */ +#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")) { diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 65c623bf45..9cde09902c 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Windows includes */ +// Windows includes #include "ppltasks.h" using namespace concurrency; using namespace Windows::ApplicationModel; @@ -37,7 +37,7 @@ using namespace Windows::UI::Input; using namespace Windows::Phone::UI::Input; #endif -/* SDL includes */ +// SDL includes extern "C" { #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_events_c.h" @@ -354,7 +354,7 @@ static bool IsSDLWindowEventPending(SDL_EventType windowEventID) bool SDL_WinRTApp::ShouldWaitForAppResumeEvents() { - /* Don't wait if the app is visible: */ + // Don't wait if the app is visible: if (m_windowVisible) { return false; } @@ -541,10 +541,10 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, cursorPos.X, cursorPos.Y); #endif - /* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */ + // 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); - /* TODO, WinRT: implement clipboard support, if possible */ + // TODO, WinRT: implement clipboard support, if possible ///* // * FIXME: Update keyboard state // */ diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp index 81a54515de..ad259a2ddb 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Windows includes */ +// Windows includes #include #include @@ -28,13 +28,13 @@ #include #endif -/* SDL includes */ +// SDL includes #include "../../video/winrt/SDL_winrtevents_c.h" #include "../../video/winrt/SDL_winrtvideo_cpp.h" #include "SDL_winrtapp_common.h" #include "SDL_winrtapp_xaml.h" -/* SDL-internal globals: */ +// SDL-internal globals: SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; #if WINAPI_FAMILY == WINAPI_FAMILY_APP diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index ba886d976f..9872f7e815 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -27,7 +27,7 @@ #include "../core/windows/SDL_windows.h" #endif -/* CPU feature detection for SDL */ +// CPU feature detection for SDL #ifdef HAVE_SYSCONF #include @@ -37,10 +37,10 @@ #include #endif #if defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__)) -#include /* For AltiVec check */ +#include // For AltiVec check #elif defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__) #include -#include /* For AltiVec check */ +#include // For AltiVec check #include #elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__) #include @@ -57,7 +57,7 @@ #include #include -/*#include */ +// #include #ifndef AT_HWCAP #define AT_HWCAP 16 #endif @@ -122,13 +122,13 @@ static void illegal_instruction(int sig) { longjmp(jmpbuf, 1); } -#endif /* HAVE_SETJMP */ +#endif // HAVE_SETJMP static int CPU_haveCPUID(void) { int has_CPUID = 0; -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #ifndef SDL_PLATFORM_EMSCRIPTEN #if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__) __asm__ ( @@ -216,8 +216,8 @@ done: "1: \n" ); #endif -#endif /* !SDL_PLATFORM_EMSCRIPTEN */ -/* *INDENT-ON* */ /* clang-format on */ +#endif // !SDL_PLATFORM_EMSCRIPTEN +/* *INDENT-ON* */ // clang-format on return has_CPUID; } @@ -253,7 +253,7 @@ done: __asm mov d, edx \ } #elif (defined(_MSC_VER) && defined(_M_X64)) -/* Use __cpuidex instead of __cpuid because ICL does not clear ecx register */ +// Use __cpuidex instead of __cpuid because ICL does not clear ecx register #define cpuid(func, a, b, c, d) \ { \ int CPUInfo[4]; \ @@ -295,15 +295,15 @@ static void CPU_calcCPUIDFeatures(void) CPU_CPUIDFeatures[2] = c; CPU_CPUIDFeatures[3] = d; - /* Check to make sure we can call xgetbv */ + // Check to make sure we can call xgetbv if (c & 0x08000000) { - /* Call xgetbv to see if YMM (etc) register state is saved */ + // 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"); -#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ +#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 @@ -447,28 +447,28 @@ 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_PLATFORM_WINDOWS) && (defined(_M_ARM) || defined(_M_ARM64)) -/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */ -/* Seems to have been removed */ +// Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. +// Seems to have been removed #ifndef 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. */ + // 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 defined(SDL_PLATFORM_VITA) return 1; #elif defined(SDL_PLATFORM_3DS) return 0; #elif defined(SDL_PLATFORM_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. */ + // (note that sysctlbyname("hw.optional.neon") doesn't work!) + return 1; // all Apple ARMv7 chips and later have NEON. #elif defined(SDL_PLATFORM_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(SDL_PLATFORM_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) { @@ -480,7 +480,7 @@ static int CPU_haveNEON(void) #elif defined(SDL_PLATFORM_LINUX) return readProcAuxvForNeon(); #elif defined(SDL_PLATFORM_ANDROID) - /* Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo */ + // Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo { AndroidCpuFamily cpu_family = android_getCpuFamily(); if (cpu_family == ANDROID_CPU_FAMILY_ARM) { @@ -492,7 +492,7 @@ static int CPU_haveNEON(void) return 0; } #elif defined(SDL_PLATFORM_RISCOS) - /* Use the VFPSupport_Features SWI to access the MVFR registers */ + // Use the VFPSupport_Features SWI to access the MVFR registers { _kernel_swi_regs regs; regs.r[0] = 0; @@ -590,7 +590,7 @@ static int CPU_haveAVX2(void) (void)a; (void)b; (void)c; - (void)d; /* compiler warnings... */ + (void)d; // compiler warnings... cpuid(7, a, b, c, d); return b & 0x00000020; } @@ -612,7 +612,7 @@ static int CPU_haveAVX512F(void) (void)a; (void)b; (void)c; - (void)d; /* compiler warnings... */ + (void)d; // compiler warnings... cpuid(7, a, b, c, d); return b & 0x00010000; } @@ -643,7 +643,7 @@ int SDL_GetCPUCount(void) SDL_CPUCount = info.dwNumberOfProcessors; } #endif - /* There has to be at least 1, right? :) */ + // There has to be at least 1, right? :) if (SDL_CPUCount <= 0) { SDL_CPUCount = 1; } @@ -662,7 +662,7 @@ SDL_GetCPUType(void) return SDL_CPUType; } #else -/* Oh, such a sweet sweet trick, just not very useful. :) */ +// Oh, such a sweet sweet trick, just not very useful. :) static const char *SDL_GetCPUType(void) { static char SDL_CPUType[13]; @@ -671,7 +671,7 @@ static const char *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; @@ -729,7 +729,7 @@ static const char *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); @@ -845,7 +845,7 @@ static const char *SDL_GetCPUName(void) int SDL_GetCPUCacheLineSize(void) { const char *cpuType = SDL_GetCPUType(); - int cacheline_size = SDL_CACHELINE_SIZE; /* initial guess */ + int cacheline_size = SDL_CACHELINE_SIZE; // initial guess int a, b, c, d; (void)a; (void)b; @@ -949,7 +949,7 @@ static Uint32 SDLCALL SDL_CPUFeatureMaskFromHint(void) } else if (ref_string_equals("lasx", spot, end)) { spot_mask = CPU_HAS_LASX; } else { - /* Ignore unknown/incorrect cpu feature(s) */ + // Ignore unknown/incorrect cpu feature(s) continue; } if (add_spot_mask) { @@ -967,7 +967,7 @@ static Uint32 SDL_GetCPUFeatures(void) if (SDL_CPUFeatures == SDL_CPUFEATURES_RESET_VALUE) { 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_haveAltiVec()) { SDL_CPUFeatures |= CPU_HAS_ALTIVEC; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); @@ -1118,18 +1118,18 @@ int SDL_GetSystemRAM(void) #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { #ifdef HW_PHYSMEM64 - /* (64-bit): NetBSD since 2003, OpenBSD */ + // (64-bit): NetBSD since 2003, OpenBSD int mib[2] = { CTL_HW, HW_PHYSMEM64 }; #elif defined(HW_REALMEM) - /* (64-bit): FreeBSD since 2005, DragonFly */ + // (64-bit): FreeBSD since 2005, DragonFly int mib[2] = { CTL_HW, HW_REALMEM }; #elif defined(HW_MEMSIZE) - /* (64-bit): Darwin */ + // (64-bit): Darwin int mib[2] = { CTL_HW, HW_MEMSIZE }; #else - /* (32-bit): very old BSD, might only report up to 2 GiB */ + // (32-bit): very old BSD, might only report up to 2 GiB int mib[2] = { CTL_HW, HW_PHYSMEM }; -#endif /* HW_PHYSMEM64 */ +#endif // HW_PHYSMEM64 Uint64 memsize = 0; size_t len = sizeof(memsize); @@ -1165,7 +1165,7 @@ int SDL_GetSystemRAM(void) #endif #ifdef SDL_PLATFORM_PS2 if (SDL_SystemRAM <= 0) { - /* PlayStation 2 has 32MiB however there are some special models with 64 and 128 */ + // PlayStation 2 has 32MiB however there are some special models with 64 and 128 SDL_SystemRAM = GetMemorySize(); } #endif @@ -1186,7 +1186,7 @@ int SDL_GetSystemRAM(void) size_t SDL_GetSIMDAlignment(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; diff --git a/src/cpuinfo/SDL_cpuinfo_c.h b/src/cpuinfo/SDL_cpuinfo_c.h index c64a091ed9..1e239bd86c 100644 --- a/src/cpuinfo/SDL_cpuinfo_c.h +++ b/src/cpuinfo/SDL_cpuinfo_c.h @@ -24,4 +24,4 @@ extern void SDL_QuitCPUInfo(void); -#endif /* SDL_cpuinfo_c_h_ */ +#endif // SDL_cpuinfo_c_h_ diff --git a/src/dialog/SDL_dialog_utils.c b/src/dialog/SDL_dialog_utils.c index d961553570..bbca9d0e69 100644 --- a/src/dialog/SDL_dialog_utils.c +++ b/src/dialog/SDL_dialog_utils.c @@ -78,7 +78,7 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters, SDL_free(converted); } - /* If the filter list is empty, put the suffix */ + // If the filter list is empty, put the suffix if (!filters->name || !filters->pattern) { new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1; @@ -117,7 +117,7 @@ char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf, if (ntf) { name_filtered = ntf(filter.name); } else { - /* Useless strdup, but easier to read and maintain code this way */ + // Useless strdup, but easier to read and maintain code this way name_filtered = SDL_strdup(filter.name); } @@ -161,10 +161,10 @@ char *convert_ext_list(const char *list, const char *prefix, } total_length = - SDL_strlen(list) - semicolons /* length of list contents */ - + semicolons * SDL_strlen(separator) /* length of separators */ - + SDL_strlen(prefix) + SDL_strlen(suffix) /* length of prefix/suffix */ - + 1; /* terminating null byte */ + SDL_strlen(list) - semicolons // length of list contents + + semicolons * SDL_strlen(separator) // length of separators + + SDL_strlen(prefix) + SDL_strlen(suffix) // length of prefix/suffix + + 1; // terminating null byte converted = (char *) SDL_malloc(total_length); diff --git a/src/dialog/SDL_dialog_utils.h b/src/dialog/SDL_dialog_utils.h index 26d178e4d6..1422231acf 100644 --- a/src/dialog/SDL_dialog_utils.h +++ b/src/dialog/SDL_dialog_utils.h @@ -30,8 +30,8 @@ as "|" with Zenity). */ typedef char *(NameTransform)(const char * name); -/* Converts all the filters into a single string. */ -/* [filter]{[filter]...} */ +// Converts all the filters into a single string. +// [filter]{[filter]...} char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters, NameTransform ntf, const char *prefix, const char *separator, const char *suffix, @@ -39,20 +39,20 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters, const char *filt_suffix, const char *ext_prefix, const char *ext_separator, const char *ext_suffix); -/* Converts one filter into a single string. */ -/* [filter name][filter extension list] */ +// Converts one filter into a single string. +// [filter name][filter extension list] char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf, const char *prefix, const char *separator, const char *suffix, const char *ext_prefix, const char *ext_separator, const char *ext_suffix); -/* Converts the extenstion list of a filter into a single string. */ -/* [extension]{[extension]...} */ +// Converts the extenstion list of a filter into a single string. +// [extension]{[extension]...} char *convert_ext_list(const char *list, const char *prefix, const char *separator, const char *suffix); /* Must be used if convert_* functions aren't used */ -/* Returns an error message if there's a problem, NULL otherwise */ +// Returns an error message if there's a problem, NULL otherwise const char *validate_filters(const SDL_DialogFileFilter *filters, int nfilters); diff --git a/src/dialog/android/SDL_androiddialog.c b/src/dialog/android/SDL_androiddialog.c index 19b212e2ce..be09792956 100644 --- a/src/dialog/android/SDL_androiddialog.c +++ b/src/dialog/android/SDL_androiddialog.c @@ -25,7 +25,7 @@ void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, SDL_bool allow_many) { if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_FALSE, allow_many)) { - /* SDL_SetError is already called when it fails */ + // SDL_SetError is already called when it fails callback(userdata, NULL, -1); } } @@ -33,7 +33,7 @@ void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userd void SDLCALL SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location) { if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_TRUE, SDL_FALSE)) { - /* SDL_SetError is already called when it fails */ + // SDL_SetError is already called when it fails callback(userdata, NULL, -1); } } diff --git a/src/dialog/cocoa/SDL_cocoadialog.m b/src/dialog/cocoa/SDL_cocoadialog.m index eeddfe75c0..f65025b050 100644 --- a/src/dialog/cocoa/SDL_cocoadialog.m +++ b/src/dialog/cocoa/SDL_cocoadialog.m @@ -53,7 +53,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback return; } - /* NSOpenPanel inherits from NSSavePanel */ + // NSOpenPanel inherits from NSSavePanel NSSavePanel *dialog; NSOpenPanel *dialog_as_open; @@ -120,7 +120,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback } } - /* Keep behavior consistent with other platforms */ + // Keep behavior consistent with other platforms [dialog setAllowsOtherFileTypes:YES]; if (default_location) { diff --git a/src/dialog/unix/SDL_portaldialog.c b/src/dialog/unix/SDL_portaldialog.c index b5e7348c20..642f4f342d 100644 --- a/src/dialog/unix/SDL_portaldialog.c +++ b/src/dialog/unix/SDL_portaldialog.c @@ -165,19 +165,19 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m const char **path; dbus->message_iter_init(msg, &signal_iter); - /* Check if the parameters are what we expect */ + // Check if the parameters are what we expect if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_UINT32) goto not_our_signal; dbus->message_iter_get_basic(&signal_iter, &result); if (result == 1 || result == 2) { - /* cancelled */ + // cancelled const char *result_data[] = { NULL }; - signal_data->callback(signal_data->userdata, result_data, -1); /* TODO: Set this to the last selected filter */ + signal_data->callback(signal_data->userdata, result_data, -1); // TODO: Set this to the last selected filter goto handled; } else if (result) { - /* some error occurred */ + // some error occurred signal_data->callback(signal_data->userdata, NULL, -1); goto handled; } @@ -199,7 +199,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m dbus->message_iter_get_basic(&array_entry, &method); if (!SDL_strcmp(method, "uris")) { - /* we only care about the selected file paths */ + // we only care about the selected file paths break; } @@ -239,8 +239,8 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m dbus->message_iter_get_basic(&uri_entry, &uri); - /* https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html */ - /* Returned paths will always start with 'file://'; SDL_URIToLocal() truncates it. */ + // https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html + // Returned paths will always start with 'file://'; SDL_URIToLocal() truncates it. char *decoded_uri = SDL_malloc(SDL_strlen(uri) + 1); if (SDL_URIToLocal(uri, decoded_uri)) { path[current] = decoded_uri; @@ -255,7 +255,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m ++current; } path[length - 1] = NULL; - signal_data->callback(signal_data->userdata, path, -1); /* TODO: Fetch the index of the filter that was used */ + signal_data->callback(signal_data->userdata, path, -1); // TODO: Fetch the index of the filter that was used cleanup: dbus->connection_remove_filter(conn, &DBus_MessageFilter, signal_data); @@ -326,14 +326,14 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di } else { const Uint64 xid = (Uint64)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); if (xid) { - const size_t len = sizeof(X11_HANDLE_PREFIX) + 24; /* A 64-bit number can be 20 characters max. */ + const size_t len = sizeof(X11_HANDLE_PREFIX) + 24; // A 64-bit number can be 20 characters max. handle_str = SDL_malloc(len * sizeof(char)); if (!handle_str) { callback(userdata, NULL, -1); return; } - /* The portal wants X11 window ID numbers in hex. */ + // The portal wants X11 window ID numbers in hex. SDL_snprintf(handle_str, len, "%s%" SDL_PRIx64, X11_HANDLE_PREFIX, xid); } } @@ -448,7 +448,7 @@ int SDL_Portal_detect(void) DBusMessageIter reply_iter; static int portal_present = -1; - /* No need for this if the result is cached. */ + // No need for this if the result is cached. if (portal_present != -1) { return portal_present; } @@ -460,7 +460,7 @@ int SDL_Portal_detect(void) return 0; } - /* Use introspection to get the available services. */ + // Use introspection to get the available services. msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, "org.freedesktop.DBus.Introspectable", "Introspect"); if (!msg) { goto done; @@ -485,7 +485,7 @@ int SDL_Portal_detect(void) */ dbus->message_iter_get_basic(&reply_iter, &reply_str); if (SDL_strstr(reply_str, PORTAL_INTERFACE)) { - portal_present = 1; /* Found it! */ + portal_present = 1; // Found it! } done: @@ -498,7 +498,7 @@ done: #else -/* Dummy implementation to avoid compilation problems */ +// Dummy implementation to avoid compilation problems void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) { @@ -523,4 +523,4 @@ int SDL_Portal_detect(void) return 0; } -#endif /* SDL_USE_LIBDBUS */ +#endif // SDL_USE_LIBDBUS diff --git a/src/dialog/unix/SDL_unixdialog.c b/src/dialog/unix/SDL_unixdialog.c index d489094a57..6928d24d57 100644 --- a/src/dialog/unix/SDL_unixdialog.c +++ b/src/dialog/unix/SDL_unixdialog.c @@ -44,7 +44,7 @@ static void set_callback(void) } } -/* Returns non-zero on success, 0 on failure */ +// Returns non-zero on success, 0 on failure static int detect_available_methods(const char *value) { const char *driver = value ? value : SDL_GetHint(SDL_HINT_FILE_DIALOG_DRIVER); @@ -75,9 +75,9 @@ static int detect_available_methods(const char *value) void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) { - /* Call detect_available_methods() again each time in case the situation changed */ + // Call detect_available_methods() again each time in case the situation changed if (!detected_open && !detect_available_methods(NULL)) { - /* SetError() done by detect_available_methods() */ + // SetError() done by detect_available_methods() callback(userdata, NULL, -1); return; } @@ -87,9 +87,9 @@ void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location) { - /* Call detect_available_methods() again each time in case the situation changed */ + // Call detect_available_methods() again each time in case the situation changed if (!detected_save && !detect_available_methods(NULL)) { - /* SetError() done by detect_available_methods() */ + // SetError() done by detect_available_methods() callback(userdata, NULL, -1); return; } @@ -99,9 +99,9 @@ void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many) { - /* Call detect_available_methods() again each time in case the situation changed */ + // Call detect_available_methods() again each time in case the situation changed if (!detected_folder && !detect_available_methods(NULL)) { - /* SetError() done by detect_available_methods() */ + // SetError() done by detect_available_methods() callback(userdata, NULL, -1); return; } diff --git a/src/dialog/unix/SDL_zenitydialog.c b/src/dialog/unix/SDL_zenitydialog.c index 929415195f..a6e07b8376 100644 --- a/src/dialog/unix/SDL_zenitydialog.c +++ b/src/dialog/unix/SDL_zenitydialog.c @@ -73,7 +73,7 @@ char *zenity_clean_name(const char *name) there aren't others. TODO: find something better. */ for (char *c = newname; *c; c++) { if (*c == '|') { - /* Zenity doesn't support escaping with \ */ + // Zenity doesn't support escaping with '\' *c = '/'; } } @@ -93,7 +93,7 @@ static char** generate_args(const zenityArgs* info) int nextarg = 0; char **argv = NULL; - /* ARGC PASS */ + // ARGC PASS if (info->flags & ZENITY_MULTIPLE) { argc++; } @@ -128,7 +128,7 @@ static char** generate_args(const zenityArgs* info) argv[nextarg++] = SDL_strdup("--separator=\n"); CHECK_OOM() - /* ARGV PASS */ + // ARGV PASS if (info->flags & ZENITY_MULTIPLE) { argv[nextarg++] = SDL_strdup("--multiple"); CHECK_OOM() @@ -185,7 +185,7 @@ void free_args(char **argv) SDL_free(argv); } -/* TODO: Zenity survives termination of the parent */ +// TODO: Zenity survives termination of the parent static void run_zenity(zenityArgs* arg_struct) { @@ -207,7 +207,7 @@ static void run_zenity(zenityArgs* arg_struct) char **args = generate_args(arg_struct); if (!args) { - /* SDL_SetError will have been called already */ + // SDL_SetError will have been called already callback(userdata, NULL, -1); return; } @@ -223,7 +223,7 @@ static void run_zenity(zenityArgs* arg_struct) return; } else if (process == 0){ dup2(out[1], STDOUT_FILENO); - close(STDERR_FILENO); /* Hide errors from Zenity to stderr */ + close(STDERR_FILENO); // Hide errors from Zenity to stderr close(out[0]); close(out[1]); @@ -286,7 +286,7 @@ static void run_zenity(zenityArgs* arg_struct) for (int i = 0; i < bytes_read; i++) { if (container[i] == '\n') { container[i] = '\0'; - /* Reading from a process often leaves a trailing \n, so ignore the last one */ + // Reading from a process often leaves a trailing \n, so ignore the last one if (i < bytes_read - 1) { array[narray] = container + i + 1; narray++; @@ -303,7 +303,7 @@ static void run_zenity(zenityArgs* arg_struct) } } - /* 0 = the user chose one or more files, 1 = the user canceled the dialog */ + // 0 = the user chose one or more files, 1 = the user canceled the dialog if (status == 0 || status == 1) { callback(userdata, (const char * const*) array, -1); } else { @@ -418,7 +418,7 @@ int SDL_Zenity_detect(void) SDL_SetError("Could not fork process: %s", strerror(errno)); return 0; } else if (process == 0){ - /* Disable output */ + // Disable output close(STDERR_FILENO); close(STDOUT_FILENO); execl("/usr/bin/env", "/usr/bin/env", "zenity", "--version", NULL); diff --git a/src/dialog/windows/SDL_windowsdialog.c b/src/dialog/windows/SDL_windowsdialog.c index 5fad1d110e..b6f7508267 100644 --- a/src/dialog/windows/SDL_windowsdialog.c +++ b/src/dialog/windows/SDL_windowsdialog.c @@ -27,7 +27,7 @@ #include "../../core/windows/SDL_windows.h" #include "../../thread/SDL_systhread.h" -/* If this number is too small, selecting too many files will give an error */ +// If this number is too small, selecting too many files will give an error #define SELECTLIST_SIZE 65536 typedef struct @@ -56,7 +56,7 @@ int getFilterIndex(int as_reported_by_windows) return as_reported_by_windows - 1; } -/* TODO: The new version of file dialogs */ +// TODO: The new version of file dialogs void windows_ShowFileDialog(void *ptr) { winArgs *args = (winArgs *) ptr; @@ -104,14 +104,14 @@ void windows_ShowFileDialog(void *ptr) window = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(parent), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); } - wchar_t *filebuffer; /* lpstrFile */ - wchar_t initfolder[MAX_PATH] = L""; /* lpstrInitialDir */ + wchar_t *filebuffer; // lpstrFile + wchar_t initfolder[MAX_PATH] = L""; // lpstrInitialDir /* If SELECTLIST_SIZE is too large, putting filebuffer on the stack might cause an overflow */ filebuffer = (wchar_t *) SDL_malloc(SELECTLIST_SIZE * sizeof(wchar_t)); - /* Necessary for the return code below */ + // Necessary for the return code below SDL_memset(filebuffer, 0, SELECTLIST_SIZE * sizeof(wchar_t)); if (default_file) { @@ -151,8 +151,8 @@ void windows_ShowFileDialog(void *ptr) wchar_t *filter_wchar = NULL; if (filters) { - /* '\x01' is used in place of a null byte */ - /* suffix needs two null bytes in case the filter list is empty */ + // '\x01' is used in place of a null byte + // suffix needs two null bytes in case the filter list is empty char *filterlist = convert_filters(filters, nfilters, NULL, "", "", "\x01\x01", "", "\x01", "\x01", "*.", ";*.", ""); @@ -206,7 +206,7 @@ void windows_ShowFileDialog(void *ptr) dialog.lCustData = 0; dialog.lpfnHook = NULL; dialog.lpTemplateName = NULL; - /* Skipped many mac-exclusive and reserved members */ + // Skipped many mac-exclusive and reserved members dialog.FlagsEx = 0; BOOL result = pGetAnyFileName(&dialog); @@ -215,7 +215,7 @@ void windows_ShowFileDialog(void *ptr) if (result) { if (!(flags & OFN_ALLOWMULTISELECT)) { - /* File is a C string stored in dialog.lpstrFile */ + // File is a C string stored in dialog.lpstrFile char *chosen_file = WIN_StringToUTF8W(dialog.lpstrFile); const char* opts[2] = { chosen_file, NULL }; callback(userdata, opts, getFilterIndex(dialog.nFilterIndex)); @@ -306,7 +306,7 @@ void windows_ShowFileDialog(void *ptr) } } - /* If the user chose only one file, it's all just one string */ + // If the user chose only one file, it's all just one string if (nfiles == 0) { nfiles++; char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char*) * (nfiles + 1)); @@ -340,7 +340,7 @@ void windows_ShowFileDialog(void *ptr) } } else { DWORD error = pCommDlgExtendedError(); - /* Error code 0 means the user clicked the cancel button. */ + // Error code 0 means the user clicked the cancel button. if (error == 0) { /* Unlike SDL's handling of errors, Windows does reset the error code to 0 after calling GetOpenFileName if another Windows @@ -399,7 +399,7 @@ void windows_ShowFolderDialog(void* ptr) BROWSEINFOW dialog; dialog.hwndOwner = parent; dialog.pidlRoot = NULL; - /* Windows docs say this is `LPTSTR` - apparently it's actually `LPWSTR`*/ + // Windows docs say this is `LPTSTR` - apparently it's actually `LPWSTR` dialog.pszDisplayName = buffer; dialog.lpszTitle = NULL; dialog.ulFlags = BIF_USENEWUI; diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 3ac0b317e6..cdd8bbd136 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -35,11 +35,11 @@ #endif #include -#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ +#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main #include -/* These headers have system specific definitions, so aren't included above */ +// These headers have system specific definitions, so aren't included above #include /* This is the version of the dynamic API. This doesn't match the SDL version @@ -62,9 +62,9 @@ static void SDL_InitDynamicAPI(void); /* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP. Even self-contained stuff might call SDL_SetError() and break everything. */ -/* behold, the macro salsa! */ +// behold, the macro salsa! -/* Can't use the macro for varargs nonsense. This is atrocious. */ +// 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, ...) \ { \ @@ -175,9 +175,9 @@ static void SDL_InitDynamicAPI(void); SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) -/* 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. */ +// 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; \ @@ -185,7 +185,7 @@ static void SDL_InitDynamicAPI(void); #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC -/* The jump table! */ +// The jump table! typedef struct { #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) SDL_DYNAPIFN_##fn fn; @@ -193,19 +193,19 @@ typedef struct #undef SDL_DYNAPI_PROC } SDL_DYNAPI_jump_table; -/* Predeclare the default functions for initializing the 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; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC -/* The actual jump table. */ +// 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 }; -/* Default functions init the function table then call right thing. */ +// Default functions init the function table then call right thing. #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ static rc SDLCALL fn##_DEFAULT params \ { \ @@ -218,7 +218,7 @@ static SDL_DYNAPI_jump_table jump_table = { #undef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI()) -/* Public API functions to jump into the jump table. */ +// Public API functions to jump into the jump table. #define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \ rc SDLCALL fn params \ { \ @@ -234,7 +234,7 @@ SDL_DYNAPI_VARARGS(, , ) #if ENABLE_SDL_CALL_LOGGING static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { - char buf[512]; /* !!! FIXME: dynamic allocation */ + char buf[512]; // !!! FIXME: dynamic allocation va_list ap; SDL_Log_REAL("SDL3CALL SDL_SetError"); va_start(ap, fmt); @@ -342,13 +342,13 @@ static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) 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. */ + // !!! 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; // newer version of SDL with functions we can't provide. } -/* Init our jump table first. */ +// Init our jump table first. #if ENABLE_SDL_CALL_LOGGING { const char *env = SDL_getenv_REAL("SDL_DYNAPI_LOG_CALLS"); @@ -369,18 +369,18 @@ static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) #undef SDL_DYNAPI_PROC #endif - /* Then the external table... */ + // Then the external table... if (output_jump_table != &jump_table) { jump_table.SDL_memcpy(output_jump_table, &jump_table, tablesize); } - /* Safe to call SDL functions now; jump table is initialized! */ + // 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. */ +// 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); extern SDL_DECLSPEC Sint32 SDLCALL SDL_DYNAPI_entry(Uint32, void *, Uint32); @@ -393,8 +393,8 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) } #endif -/* Obviously we can't use SDL_LoadObject() to load SDL. :) */ -/* Also obviously, we never close the loaded library. */ +// Obviously we can't use SDL_LoadObject() to load SDL. :) +// Also obviously, we never close the loaded library. #if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 @@ -436,7 +436,7 @@ static void dynapi_warn(const char *msg) { const char *caption = "SDL Dynamic API Failure!"; (void)caption; -/* SDL_ShowSimpleMessageBox() is a too heavy for here. */ +// SDL_ShowSimpleMessageBox() is a too heavy for here. #if (defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR); #elif defined(HAVE_STDIO_H) @@ -462,7 +462,7 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode); 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) { @@ -484,29 +484,29 @@ static void SDL_InitDynamicAPILocked(void) } if (!entry) { dynapi_warn("Couldn't load an 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. */ + // Just fill in the function pointers from this library, later. } } if (entry) { 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. */ + // 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. */ + // Just fill in the function pointers from this library. if (use_internal) { if (initialize_jumptable(SDL_DYNAPI_VERSION, &jump_table, sizeof(jump_table)) < 0) { - /* Now we're screwed. Should definitely abort now. */ + // 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); } } - /* we intentionally never close the newly-loaded lib, of course. */ + // we intentionally never close the newly-loaded lib, of course. } static void SDL_InitDynamicAPI(void) @@ -535,7 +535,7 @@ static void SDL_InitDynamicAPI(void) SDL_UnlockSpinlock_REAL(&lock); } -#else /* SDL_DYNAMIC_API */ +#else // SDL_DYNAMIC_API #include @@ -545,7 +545,7 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) (void)apiver; (void)table; (void)tablesize; - return -1; /* not compatible. */ + return -1; // not compatible. } -#endif /* SDL_DYNAMIC_API */ +#endif // SDL_DYNAMIC_API diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 914c9badfb..2e8e238320 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,33 +43,33 @@ #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(SDL_PLATFORM_ANDROID) /* probably not useful on Android. */ +#elif defined(SDL_PLATFORM_ANDROID) // probably not useful on Android. #define SDL_DYNAMIC_API 0 -#elif defined(SDL_PLATFORM_EMSCRIPTEN) /* probably not useful on Emscripten. */ +#elif defined(SDL_PLATFORM_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(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2 #define SDL_DYNAMIC_API 0 #elif defined(SDL_PLATFORM_PSP) && SDL_PLATFORM_PSP #define SDL_DYNAMIC_API 0 -#elif defined(SDL_PLATFORM_RISCOS) /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */ +#elif defined(SDL_PLATFORM_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__) || defined(__INTELLISENSE__) || defined(SDL_THREAD_SAFETY_ANALYSIS) -#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(SDL_PLATFORM_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(SDL_PLATFORM_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(SDL_PLATFORM_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. */ +// everyone else. This is where we turn on the API if nothing forced it off. #ifndef SDL_DYNAMIC_API #define SDL_DYNAMIC_API 1 #endif diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 7eb3c21f9a..f5d6cb3032 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -987,7 +987,7 @@ SDL3_0.0.0 { SDL_powf; SDL_qsort; SDL_qsort_r; - SDL_rand; + SDL_rand; SDL_rand_bits; SDL_rand_bits_r; SDL_rand_r; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 9567b41143..7d6259dc8c 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -20,13 +20,13 @@ */ -/* DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl. */ +// DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl. #if !SDL_DYNAMIC_API #error You should not be here. #endif -/* New API symbols are added at the end */ +// New API symbols are added at the end #define SDL_AcquireCameraFrame SDL_AcquireCameraFrame_REAL #define SDL_AddEventWatch SDL_AddEventWatch_REAL #define SDL_AddGamepadMapping SDL_AddGamepadMapping_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index c86bff4721..74163819c9 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -28,7 +28,7 @@ Also, this file gets included multiple times, don't add #pragma once, etc. */ -/* direct jump magic can use these, the rest needs special code. */ +// direct jump magic can use these, the rest needs special code. #ifndef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_PROC(size_t,SDL_IOprintf,(SDL_IOStream *a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return) SDL_DYNAPI_PROC(void,SDL_Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),) @@ -46,7 +46,7 @@ SDL_DYNAPI_PROC(int,SDL_sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const cha SDL_DYNAPI_PROC(int,SDL_swprintf,(SDL_OUT_Z_CAP(b) wchar_t *a, size_t b, SDL_PRINTF_FORMAT_STRING const wchar_t *c, ...),(a,b,c),return) #endif -/* New API symbols are added at the end */ +// New API symbols are added at the end SDL_DYNAPI_PROC(SDL_Surface*,SDL_AcquireCameraFrame,(SDL_Camera *a, Uint64 *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return) diff --git a/src/dynapi/gendynapi.py b/src/dynapi/gendynapi.py index fb601af9df..7c5f430f18 100755 --- a/src/dynapi/gendynapi.py +++ b/src/dynapi/gendynapi.py @@ -99,7 +99,7 @@ def main(): if match: continue - # Remove one line comment /* ... */ + # Remove one line comment // ... # eg: extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */); line = reg_comment_remove_content.sub('', line) diff --git a/src/events/SDL_categories.c b/src/events/SDL_categories.c index 657efdf409..8707e10eb8 100644 --- a/src/events/SDL_categories.c +++ b/src/events/SDL_categories.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* SDL event categories */ +// SDL event categories #include "SDL_events_c.h" #include "SDL_categories_c.h" @@ -233,8 +233,8 @@ SDL_Window *SDL_GetWindowFromEvent(const SDL_Event *event) windowID = event->drop.windowID; break; default: - /* < 0 -> invalid event type (error is set by SDL_GetEventCategory) */ - /* else -> event has no associated window (not an error) */ + // < 0 -> invalid event type (error is set by SDL_GetEventCategory) + // else -> event has no associated window (not an error) return NULL; } return SDL_GetWindowFromID(windowID); diff --git a/src/events/SDL_categories_c.h b/src/events/SDL_categories_c.h index 6eba1e95f3..1b527788f1 100644 --- a/src/events/SDL_categories_c.h +++ b/src/events/SDL_categories_c.h @@ -65,4 +65,4 @@ typedef enum SDL_EventCategory extern SDL_EventCategory SDL_GetEventCategory(Uint32 type); -#endif /* SDL_categories_c_h_ */ +#endif // SDL_categories_c_h_ diff --git a/src/events/SDL_clipboardevents.c b/src/events/SDL_clipboardevents.c index 0c2f20ac59..d30906cc99 100644 --- a/src/events/SDL_clipboardevents.c +++ b/src/events/SDL_clipboardevents.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Clipboard event handling code for SDL */ +// Clipboard event handling code for SDL #include "SDL_events_c.h" #include "SDL_clipboardevents_c.h" @@ -29,7 +29,7 @@ int SDL_SendClipboardUpdate(void) { int posted; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_CLIPBOARD_UPDATE)) { SDL_Event event; diff --git a/src/events/SDL_clipboardevents_c.h b/src/events/SDL_clipboardevents_c.h index 557bd0d1a2..c4edda2978 100644 --- a/src/events/SDL_clipboardevents_c.h +++ b/src/events/SDL_clipboardevents_c.h @@ -25,4 +25,4 @@ extern int SDL_SendClipboardUpdate(void); -#endif /* SDL_clipboardevents_c_h_ */ +#endif // SDL_clipboardevents_c_h_ diff --git a/src/events/SDL_displayevents.c b/src/events/SDL_displayevents.c index 3740ef1148..84eee4098c 100644 --- a/src/events/SDL_displayevents.c +++ b/src/events/SDL_displayevents.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Display event handling code for SDL */ +// Display event handling code for SDL #include "SDL_events_c.h" @@ -42,7 +42,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, break; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(displayevent)) { SDL_Event event; diff --git a/src/events/SDL_displayevents_c.h b/src/events/SDL_displayevents_c.h index 6ccba10eae..138484299f 100644 --- a/src/events/SDL_displayevents_c.h +++ b/src/events/SDL_displayevents_c.h @@ -25,4 +25,4 @@ extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2); -#endif /* SDL_displayevents_c_h_ */ +#endif // SDL_displayevents_c_h_ diff --git a/src/events/SDL_dropevents.c b/src/events/SDL_dropevents.c index 41fb629e8d..d7ad1f3e2f 100644 --- a/src/events/SDL_dropevents.c +++ b/src/events/SDL_dropevents.c @@ -20,12 +20,12 @@ */ #include "SDL_internal.h" -/* Drag and drop event handling code for SDL */ +// Drag and drop event handling code for SDL #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 *source, const char *data, float x, float y) { @@ -34,7 +34,7 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch static float last_drop_y = 0; int posted = 0; - /* Post the event, if desired */ + // Post the event, if desired if (SDL_EventEnabled(evtype)) { const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping; SDL_Event event; diff --git a/src/events/SDL_dropevents_c.h b/src/events/SDL_dropevents_c.h index 4379d68c2f..d3d3bebb43 100644 --- a/src/events/SDL_dropevents_c.h +++ b/src/events/SDL_dropevents_c.h @@ -28,4 +28,4 @@ extern int SDL_SendDropPosition(SDL_Window *window, float x, float y); extern int SDL_SendDropText(SDL_Window *window, const char *text); extern int SDL_SendDropComplete(SDL_Window *window); -#endif /* SDL_dropevents_c_h_ */ +#endif // SDL_dropevents_c_h_ diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 62fda0867b..f21c9ce1e1 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* General event handling code for SDL */ +// General event handling code for SDL #include "SDL_events_c.h" #include "../SDL_hints_c.h" @@ -40,16 +40,16 @@ #include "../video/android/SDL_androidevents.h" #endif -/* An arbitrary limit so we don't have unbounded growth */ +// An arbitrary limit so we don't have unbounded growth #define SDL_MAX_QUEUED_EVENTS 65535 -/* Determines how often we pump events if joystick or sensor subsystems are active */ +// Determines how often we pump events if joystick or sensor subsystems are active #define ENUMERATION_POLL_INTERVAL_NS (3 * SDL_NS_PER_SECOND) -/* Determines how often to pump events if joysticks or sensors are actively being read */ +// Determines how often to pump events if joysticks or sensors are actively being read #define EVENT_POLL_INTERVAL_NS SDL_MS_TO_NS(1) -/* Make sure the type in the SDL_Event aligns properly across the union */ +// Make sure the type in the SDL_Event aligns properly across the union SDL_COMPILE_TIME_ASSERT(SDL_Event_type, sizeof(Uint32) == sizeof(SDL_EventType)); typedef struct SDL_EventWatcher @@ -345,7 +345,7 @@ static void SDLCALL SDL_AutoUpdateJoysticksChanged(void *userdata, const char *n SDL_update_joysticks = SDL_GetStringBoolean(hint, SDL_TRUE); } -#endif /* !SDL_JOYSTICK_DISABLED */ +#endif // !SDL_JOYSTICK_DISABLED #ifndef SDL_SENSOR_DISABLED @@ -356,7 +356,7 @@ static void SDLCALL SDL_AutoUpdateSensorsChanged(void *userdata, const char *nam SDL_update_sensors = SDL_GetStringBoolean(hint, SDL_TRUE); } -#endif /* !SDL_SENSOR_DISABLED */ +#endif // !SDL_SENSOR_DISABLED static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { @@ -384,7 +384,7 @@ static void SDL_LogEvent(const SDL_Event *event) char name[64]; char details[128]; - /* sensor/mouse/pen/finger motion are spammy, ignore these if they aren't demanded. */ + // sensor/mouse/pen/finger motion are spammy, ignore these if they aren't demanded. if ((SDL_EventLoggingVerbosity < 2) && ((event->type == SDL_EVENT_MOUSE_MOTION) || (event->type == SDL_EVENT_FINGER_MOTION) || @@ -396,13 +396,13 @@ static void SDL_LogEvent(const SDL_Event *event) return; } -/* this is to make (void)SDL_snprintf() calls cleaner. */ +// this is to make (void)SDL_snprintf() calls cleaner. #define uint unsigned int name[0] = '\0'; details[0] = '\0'; - /* !!! FIXME: This code is kinda ugly, sorry. */ + // !!! FIXME: This code is kinda ugly, sorry. if ((event->type >= SDL_EVENT_USER) && (event->type <= SDL_EVENT_LAST)) { char plusstr[16]; @@ -802,7 +802,7 @@ static void SDL_LogEvent(const SDL_Event *event) #undef SDL_EVENT_CASE case SDL_EVENT_POLL_SENTINEL: - /* No logging necessary for this one */ + // No logging necessary for this one break; default: @@ -839,7 +839,7 @@ void SDL_StopEventLoop(void) SDL_EventQ.max_events_seen); } - /* Clean out EventQ */ + // Clean out EventQ for (entry = SDL_EventQ.head; entry;) { SDL_EventEntry *next = entry->next; SDL_TransferTemporaryMemoryFromEvent(entry); @@ -859,7 +859,7 @@ void SDL_StopEventLoop(void) SDL_EventQ.free = NULL; SDL_AtomicSet(&SDL_sentinel_pending, 0); - /* Clear disabled event state */ + // Clear disabled event state for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) { SDL_free(SDL_disabled_events[i]); SDL_disabled_events[i] = NULL; @@ -884,7 +884,7 @@ void SDL_StopEventLoop(void) } } -/* This function (and associated calls) may be called more than once */ +// This function (and associated calls) may be called more than once int SDL_StartEventLoop(void) { /* We'll leave the event queue alone, since we might have gotten @@ -893,7 +893,7 @@ int SDL_StartEventLoop(void) FIXME: Does this introduce any other bugs with events at startup? */ - /* Create the lock and set ourselves active */ + // Create the lock and set ourselves active #ifndef SDL_THREADS_DISABLED if (!SDL_EventQ.lock) { SDL_EventQ.lock = SDL_CreateMutex(); @@ -910,14 +910,14 @@ int SDL_StartEventLoop(void) return -1; } } -#endif /* !SDL_THREADS_DISABLED */ +#endif // !SDL_THREADS_DISABLED SDL_EventQ.active = SDL_TRUE; SDL_UnlockMutex(SDL_EventQ.lock); return 0; } -/* Add an event to the event queue -- called with the queue locked */ +// Add an event to the event queue -- called with the queue locked static int SDL_AddEvent(SDL_Event *event) { SDL_EventEntry *entry; @@ -973,7 +973,7 @@ static int SDL_AddEvent(SDL_Event *event) return 1; } -/* Remove an event from the queue -- called with the queue locked */ +// Remove an event from the queue -- called with the queue locked static void SDL_CutEvent(SDL_EventEntry *entry) { SDL_TransferTemporaryMemoryFromEvent(entry); @@ -1019,7 +1019,7 @@ static int SDL_SendWakeupEvent(void) if (_this->wakeup_window) { _this->SendWakeupEvent(_this, _this->wakeup_window); - /* No more wakeup events needed until we enter a new wait */ + // No more wakeup events needed until we enter a new wait _this->wakeup_window = NULL; } } @@ -1029,20 +1029,20 @@ static int SDL_SendWakeupEvent(void) return 0; } -/* Lock the event queue, take a peep at it, and unlock it */ +// 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) { int i, used, sentinels_expected = 0; - /* Lock the event queue */ + // Lock the event queue used = 0; SDL_LockMutex(SDL_EventQ.lock); { - /* Don't look after we've quit */ + // Don't look after we've quit if (!SDL_EventQ.active) { - /* We get a few spurious events at shutdown, so don't warn then */ + // We get a few spurious events at shutdown, so don't warn then if (action == SDL_GETEVENT) { SDL_SetError("The event system has been shut down"); } @@ -1073,16 +1073,16 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAct } } if (type == SDL_EVENT_POLL_SENTINEL) { - /* Special handling for the sentinel event */ + // Special handling for the sentinel event if (!include_sentinel) { - /* Skip it, we don't want to include it */ + // Skip it, we don't want to include it continue; } if (events == NULL || action != SDL_GETEVENT) { ++sentinels_expected; } if (SDL_AtomicGet(&SDL_sentinel_pending) > sentinels_expected) { - /* Skip it, there's another one pending */ + // Skip it, there's another one pending continue; } } @@ -1125,7 +1125,7 @@ void SDL_FlushEvents(Uint32 minType, Uint32 maxType) SDL_EventEntry *entry, *next; Uint32 type; - /* Make sure the events are current */ + // Make sure the events are current #if 0 /* Actually, we can't do this since we might be flushing while processing a resize event, and calling this might trigger further resize events. @@ -1133,10 +1133,10 @@ void SDL_FlushEvents(Uint32 minType, Uint32 maxType) SDL_PumpEvents(); #endif - /* Lock the event queue */ + // Lock the event queue SDL_LockMutex(SDL_EventQ.lock); { - /* Don't look after we've quit */ + // Don't look after we've quit if (!SDL_EventQ.active) { SDL_UnlockMutex(SDL_EventQ.lock); return; @@ -1152,20 +1152,20 @@ void SDL_FlushEvents(Uint32 minType, Uint32 maxType) SDL_UnlockMutex(SDL_EventQ.lock); } -/* Run the system dependent event loops */ +// Run the system dependent event loops static void SDL_PumpEventsInternal(SDL_bool push_sentinel) { - /* Free any temporary memory from old events */ + // Free any temporary memory from old events SDL_FreeTemporaryMemory(); - /* Release any keys held down from last frame */ + // Release any keys held down from last frame SDL_ReleaseAutoReleaseKeys(); #ifdef SDL_PLATFORM_ANDROID - /* Android event processing is independent of the video subsystem */ + // Android event processing is independent of the video subsystem Android_PumpEvents(0); #else - /* Get events from the video subsystem */ + // Get events from the video subsystem SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (_this) { _this->PumpEvents(_this); @@ -1181,25 +1181,25 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) #endif #ifndef SDL_SENSOR_DISABLED - /* Check for sensor state change */ + // Check for sensor state change if (SDL_update_sensors) { SDL_UpdateSensors(); } #endif #ifndef SDL_JOYSTICK_DISABLED - /* Check for joystick state change */ + // Check for joystick state change if (SDL_update_joysticks) { SDL_UpdateJoysticks(); } #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_EventEnabled(SDL_EVENT_POLL_SENTINEL)) { SDL_Event sentinel; - /* Make sure we don't already have a sentinel in the queue, and add one to the end */ + // Make sure we don't already have a sentinel in the queue, and add one to the end if (SDL_AtomicGet(&SDL_sentinel_pending) > 0) { SDL_PeepEventsInternal(&sentinel, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE); } @@ -1215,7 +1215,7 @@ void SDL_PumpEvents(void) SDL_PumpEventsInternal(SDL_FALSE); } -/* Public functions */ +// Public functions SDL_bool SDL_PollEvent(SDL_Event *event) { @@ -1231,10 +1231,10 @@ static Sint64 SDL_events_get_polling_interval(void) #ifndef SDL_JOYSTICK_DISABLED if (SDL_WasInit(SDL_INIT_JOYSTICK) && SDL_update_joysticks) { if (SDL_JoysticksOpened()) { - /* If we have joysticks open, we need to poll rapidly for events */ + // If we have joysticks open, we need to poll rapidly for events poll_intervalNS = SDL_min(poll_intervalNS, EVENT_POLL_INTERVAL_NS); } else { - /* If not, just poll every few seconds to enumerate new joysticks */ + // If not, just poll every few seconds to enumerate new joysticks poll_intervalNS = SDL_min(poll_intervalNS, ENUMERATION_POLL_INTERVAL_NS); } } @@ -1242,7 +1242,7 @@ static Sint64 SDL_events_get_polling_interval(void) #ifndef SDL_SENSOR_DISABLED if (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors && SDL_SensorsOpened()) { - /* If we have sensors open, we need to poll rapidly for events */ + // If we have sensors open, we need to poll rapidly for events poll_intervalNS = SDL_min(poll_intervalNS, EVENT_POLL_INTERVAL_NS); } #endif @@ -1268,7 +1268,7 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu SDL_LockMutex(_this->wakeup_lock); { status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST); - /* If status == 0 we are going to block so wakeup will be needed. */ + // If status == 0 we are going to block so wakeup will be needed. if (status == 0) { _this->wakeup_window = wakeup_window; } else { @@ -1278,24 +1278,24 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu SDL_UnlockMutex(_this->wakeup_lock); if (status < 0) { - /* Got an error: return */ + // Got an error: return break; } if (status > 0) { - /* There is an event, we can return. */ + // There is an event, we can return. return 1; } - /* No events found in the queue, call WaitEventTimeout to wait for an event. */ + // No events found in the queue, call WaitEventTimeout to wait for an event. if (timeoutNS > 0) { Sint64 elapsed = SDL_GetTicksNS() - start; if (elapsed >= timeoutNS) { - /* Set wakeup_window to NULL without holding the lock. */ + // Set wakeup_window to NULL without holding the lock. _this->wakeup_window = NULL; return 0; } loop_timeoutNS = (timeoutNS - elapsed); } - /* Adjust the timeout for any polling requirements we currently have. */ + // Adjust the timeout for any polling requirements we currently have. if (poll_intervalNS != SDL_MAX_SINT64) { if (loop_timeoutNS >= 0) { loop_timeoutNS = SDL_min(loop_timeoutNS, poll_intervalNS); @@ -1304,13 +1304,13 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu } } status = _this->WaitEventTimeout(_this, loop_timeoutNS); - /* Set wakeup_window to NULL without holding the lock. */ + // Set wakeup_window to NULL without holding the lock. _this->wakeup_window = NULL; if (status == 0 && poll_intervalNS != SDL_MAX_SINT64 && loop_timeoutNS == poll_intervalNS) { - /* We may have woken up to poll. Try again */ + // We may have woken up to poll. Try again continue; } else if (status <= 0) { - /* There is either an error or the timeout is elapsed: return */ + // There is either an error or the timeout is elapsed: return return status; } /* An event was found and pumped into the SDL events queue. Continue the loop @@ -1363,12 +1363,12 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) expiration = 0; } - /* If there isn't a poll sentinel event pending, pump events and add one */ + // If there isn't a poll sentinel event pending, pump events and add one if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) { SDL_PumpEventsInternal(SDL_TRUE); } - /* First check for existing events */ + // First check for existing events result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, include_sentinel); if (result < 0) { return SDL_FALSE; @@ -1376,31 +1376,31 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) if (include_sentinel) { if (event) { if (event->type == SDL_EVENT_POLL_SENTINEL) { - /* Reached the end of a poll cycle, and not willing to wait */ + // Reached the end of a poll cycle, and not willing to wait return SDL_FALSE; } } else { - /* Need to peek the next event to check for sentinel */ + // Need to peek the next event to check for sentinel SDL_Event dummy; if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, SDL_TRUE) && dummy.type == SDL_EVENT_POLL_SENTINEL) { SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE); - /* Reached the end of a poll cycle, and not willing to wait */ + // Reached the end of a poll cycle, and not willing to wait return SDL_FALSE; } } } if (result == 0) { if (timeoutNS == 0) { - /* No events available, and not willing to wait */ + // No events available, and not willing to wait return SDL_FALSE; } } else { - /* Has existing events */ + // Has existing events return SDL_TRUE; } - /* We should have completely handled timeoutNS == 0 above */ + // We should have completely handled timeoutNS == 0 above SDL_assert(timeoutNS != 0); #ifdef SDL_PLATFORM_ANDROID @@ -1413,7 +1413,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) if (timeoutNS > 0) { Uint64 now = SDL_GetTicksNS(); if (now >= expiration) { - /* Timeout expired and no events */ + // Timeout expired and no events return SDL_FALSE; } delay = (expiration - now); @@ -1423,7 +1423,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) #else SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (_this && _this->WaitEventTimeout && _this->SendWakeupEvent) { - /* Look if a shown window is available to send the wakeup event. */ + // Look if a shown window is available to send the wakeup event. SDL_Window *wakeup_window = SDL_find_active_window(_this); if (wakeup_window) { result = SDL_WaitEventTimeout_Device(_this, wakeup_window, event, start, timeoutNS); @@ -1450,7 +1450,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) if (timeoutNS > 0) { Uint64 now = SDL_GetTicksNS(); if (now >= expiration) { - /* Timeout expired and no events */ + // Timeout expired and no events return SDL_FALSE; } delay = SDL_min((expiration - now), delay); @@ -1472,7 +1472,7 @@ static SDL_bool SDL_CallEventWatchers(SDL_Event *event) } if (SDL_event_watchers_count > 0) { - /* Make sure we only dispatch the current watcher list */ + // Make sure we only dispatch the current watcher list int i, event_watchers_count = SDL_event_watchers_count; SDL_event_watchers_dispatching = SDL_TRUE; @@ -1524,11 +1524,11 @@ void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) SDL_EventEntry *event, *next; SDL_LockMutex(SDL_event_watchers_lock); { - /* Set filter and discard pending events */ + // Set filter and discard pending events SDL_EventOK.callback = filter; SDL_EventOK.userdata = userdata; if (filter) { - /* Cut all events not accepted by the filter */ + // Cut all events not accepted by the filter SDL_LockMutex(SDL_EventQ.lock); { for (event = SDL_EventQ.head; event; event = next) { @@ -1649,7 +1649,7 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled) SDL_assert(SDL_disabled_events[hi] != NULL); SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31)); - /* Gamepad events depend on joystick events */ + // Gamepad events depend on joystick events switch (type) { case SDL_EVENT_GAMEPAD_ADDED: SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_ADDED, SDL_TRUE); @@ -1672,11 +1672,11 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled) break; } } else { - /* Disable this event type and discard pending events */ + // 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)); } - /* Out of memory, nothing we can do... */ + // Out of memory, nothing we can do... if (SDL_disabled_events[hi]) { SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31)); SDL_FlushEvent(type); diff --git a/src/events/SDL_events_c.h b/src/events/SDL_events_c.h index ba37401ea4..284b576c11 100644 --- a/src/events/SDL_events_c.h +++ b/src/events/SDL_events_c.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -/* Useful functions and variables from SDL_events.c */ +// Useful functions and variables from SDL_events.c #include "../video/SDL_sysvideo.h" #include "SDL_clipboardevents_c.h" @@ -36,7 +36,7 @@ #include "SDL_pen_c.h" #include "SDL_windowevents_c.h" -/* Start and stop the event processing loop */ +// Start and stop the event processing loop extern int SDL_StartEventLoop(void); extern void SDL_StopEventLoop(void); extern void SDL_QuitInterrupt(void); @@ -61,4 +61,4 @@ extern void SDL_SendPendingSignalEvents(void); extern int SDL_InitQuit(void); extern void SDL_QuitQuit(void); -#endif /* SDL_events_c_h_ */ +#endif // SDL_events_c_h_ diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 45dbdc0e70..7a5d57701c 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -20,15 +20,15 @@ */ #include "SDL_internal.h" -/* General keyboard handling code for SDL */ +// General keyboard handling code for SDL #include "SDL_events_c.h" #include "SDL_keymap_c.h" #include "../video/SDL_sysvideo.h" -/* #define DEBUG_KEYBOARD */ +// #define DEBUG_KEYBOARD -/* Global keyboard information */ +// Global keyboard information #define KEYBOARD_HARDWARE 0x01 #define KEYBOARD_VIRTUAL 0x02 @@ -50,7 +50,7 @@ typedef struct SDL_KeyboardInstance typedef struct SDL_Keyboard { - /* Data common to all keyboards */ + // Data common to all keyboards SDL_Window *focus; SDL_Keymod modstate; Uint8 keysource[SDL_NUM_SCANCODES]; @@ -91,7 +91,7 @@ static void SDLCALL SDL_KeycodeOptionsChanged(void *userdata, const char *name, } } -/* Public functions */ +// Public functions int SDL_InitKeyboard(void) { SDL_AddHintCallback(SDL_HINT_KEYCODE_OPTIONS, @@ -106,7 +106,7 @@ SDL_bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys) return SDL_FALSE; } - /* Eventually we'll have a blacklist of devices that enumerate as keyboards but aren't really */ + // Eventually we'll have a blacklist of devices that enumerate as keyboards but aren't really return SDL_TRUE; } @@ -124,7 +124,7 @@ void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, SDL_bool send_ { int keyboard_index = SDL_GetKeyboardIndex(keyboardID); if (keyboard_index >= 0) { - /* We already know about this keyboard */ + // We already know about this keyboard return; } @@ -153,7 +153,7 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, SDL_bool send_event) { int keyboard_index = SDL_GetKeyboardIndex(keyboardID); if (keyboard_index < 0) { - /* We don't know about this keyboard */ + // We don't know about this keyboard return; } @@ -330,15 +330,15 @@ int SDL_SetKeyboardFocus(SDL_Window *window) } if (keyboard->focus && !window) { - /* We won't get anymore keyboard messages, so reset keyboard state */ + // We won't get anymore keyboard messages, so reset keyboard state SDL_ResetKeyboard(); } - /* See if the current window has lost focus */ + // See if the current window has lost focus if (keyboard->focus && keyboard->focus != window) { SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0); - /* Ensures IME compositions are committed */ + // Ensures IME compositions are committed if (SDL_TextInputActive(keyboard->focus)) { if (video && video->StopTextInput) { video->StopTextInput(video, keyboard->focus); @@ -504,7 +504,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo state == SDL_PRESSED ? "pressed" : "released"); #endif - /* Figure out what type of event this is */ + // Figure out what type of event this is switch (state) { case SDL_PRESSED: type = SDL_EVENT_KEY_DOWN; @@ -513,12 +513,12 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo type = SDL_EVENT_KEY_UP; break; default: - /* Invalid state -- bail */ + // Invalid state -- bail return 0; } if (scancode > SDL_SCANCODE_UNKNOWN && scancode < SDL_NUM_SCANCODES) { - /* Drop events that don't change state */ + // Drop events that don't change state if (state) { if (keyboard->keystate[scancode]) { if (!(keyboard->keysource[scancode] & source)) { @@ -535,13 +535,13 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo keyboard->keysource[scancode] = 0; } - /* Update internal keyboard state */ + // Update internal keyboard state keyboard->keystate[scancode] = state; keycode = SDL_GetKeyFromScancode(scancode, keyboard->modstate, SDL_TRUE); } else if (rawcode == 0) { - /* Nothing to do! */ + // Nothing to do! return 0; } @@ -551,7 +551,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo keyboard->autorelease_pending = SDL_TRUE; } - /* Update modifiers state if applicable */ + // Update modifiers state if applicable if (!(flags & KEYBOARD_IGNOREMODIFIERS) && !repeat) { SDL_Keymod modifier; @@ -607,7 +607,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo } } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(type)) { SDL_Event event; @@ -655,16 +655,16 @@ int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch) } if (modstate & SDL_KMOD_SHIFT) { - /* If the character uses shift, press shift down */ + // If the character uses shift, press shift down SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_LSHIFT, SDL_PRESSED); } - /* Send a keydown and keyup for the character */ + // Send a keydown and keyup for the character SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, SDL_PRESSED); SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, SDL_RELEASED); if (modstate & SDL_KMOD_SHIFT) { - /* If the character uses shift, release shift */ + // If the character uses shift, release shift SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_LSHIFT, SDL_RELEASED); } return 0; @@ -710,7 +710,7 @@ void SDL_ReleaseAutoReleaseKeys(void) } if (keyboard->hardware_timestamp) { - /* Keep hardware keyboard "active" for 250 ms */ + // Keep hardware keyboard "active" for 250 ms if (SDL_GetTicks() >= keyboard->hardware_timestamp + 250) { keyboard->hardware_timestamp = 0; } @@ -744,12 +744,12 @@ int SDL_SendKeyboardText(const char *text) return 0; } - /* Don't post text events for unprintable characters */ + // Don't post text events for unprintable characters if (SDL_iscntrl((unsigned char)*text)) { return 0; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) { SDL_Event event; @@ -778,7 +778,7 @@ int SDL_SendEditingText(const char *text, int start, int length) return 0; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_TEXT_EDITING)) { SDL_Event event; @@ -837,7 +837,7 @@ int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int sel return 0; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_TEXT_EDITING_CANDIDATES)) { SDL_Event event; @@ -906,7 +906,7 @@ void SDL_SetModState(SDL_Keymod modstate) keyboard->modstate = modstate; } -/* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */ +// Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) { SDL_Keyboard *keyboard = &SDL_keyboard; diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index de3f162ecb..17f9596cd6 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -25,28 +25,28 @@ #include "SDL_keymap_c.h" -/* Keyboard events not associated with a specific input device */ +// Keyboard events not associated with a specific input device #define SDL_GLOBAL_KEYBOARD_ID 0 -/* The default keyboard input device, for platforms that don't have multiple keyboards */ +// The default keyboard input device, for platforms that don't have multiple keyboards #define SDL_DEFAULT_KEYBOARD_ID 1 -/* Initialize the keyboard subsystem */ +// Initialize the keyboard subsystem extern int SDL_InitKeyboard(void); -/* Return whether a device is actually a keyboard */ +// Return whether a device is actually a keyboard extern SDL_bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys); -/* A keyboard has been added to the system */ +// A keyboard has been added to the system extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, SDL_bool send_event); -/* A keyboard has been removed from the system */ +// A keyboard has been removed from the system extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, SDL_bool send_event); -/* Set the mapping of scancode to key codes */ +// Set the mapping of scancode to key codes extern void SDL_SetKeymap(SDL_Keymap *keymap, SDL_bool send_event); -/* Set the keyboard focus window */ +// Set the keyboard focus window extern int SDL_SetKeyboardFocus(SDL_Window *window); /* Send a character from an on-screen keyboard as scancode and modifier key events, @@ -54,7 +54,7 @@ extern int SDL_SetKeyboardFocus(SDL_Window *window); */ extern int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch); -/* Send a keyboard key event */ +// Send a keyboard key event extern int SDL_SendKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, Uint8 state); extern int SDL_SendKeyboardKeyIgnoreModifiers(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, Uint8 state); extern int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode); @@ -63,25 +63,25 @@ extern int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancod Most platforms should prefer to optionally call SDL_SetKeymap and then use SDL_SendKeyboardKey. */ extern int SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, SDL_Keycode keycode, Uint8 state); -/* Release all the autorelease keys */ +// Release all the autorelease keys extern void SDL_ReleaseAutoReleaseKeys(void); -/* Return true if any hardware key is pressed */ +// Return true if any hardware key is pressed extern SDL_bool SDL_HardwareKeyboardKeyPressed(void); -/* Send keyboard text input */ +// Send keyboard text input extern int SDL_SendKeyboardText(const char *text); -/* Send editing text for selected range from start to end */ +// Send editing text for selected range from start to end extern int SDL_SendEditingText(const char *text, int start, int length); -/* Send editing text candidates, which will be copied into the event */ +// Send editing text candidates, which will be copied into the event int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, SDL_bool horizontal); -/* Shutdown the keyboard subsystem */ +// Shutdown the keyboard subsystem extern void SDL_QuitKeyboard(void); -/* Toggle on or off pieces of the keyboard mod state. */ +// Toggle on or off pieces of the keyboard mod state. extern void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle); -#endif /* SDL_keyboard_c_h_ */ +#endif // SDL_keyboard_c_h_ diff --git a/src/events/SDL_keymap.c b/src/events/SDL_keymap.c index 2344694ddd..ca158551e8 100644 --- a/src/events/SDL_keymap.c +++ b/src/events/SDL_keymap.c @@ -1033,12 +1033,12 @@ SDL_Keycode SDL_GetKeyFromName(const char *name) const SDL_bool uppercase = SDL_TRUE; SDL_Keycode key; - /* Check input */ + // Check input if (!name) { return SDLK_UNKNOWN; } - /* If it's a single UTF-8 character, then that's the keycode itself */ + // If it's a single UTF-8 character, then that's the keycode itself key = *(const unsigned char *)name; if (key >= 0xF0) { if (SDL_strlen(name) == 4) { diff --git a/src/events/SDL_keymap_c.h b/src/events/SDL_keymap_c.h index 72da37a373..1f8cff4645 100644 --- a/src/events/SDL_keymap_c.h +++ b/src/events/SDL_keymap_c.h @@ -32,4 +32,4 @@ SDL_Keycode SDL_GetKeymapKeycode(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_ SDL_Scancode SDL_GetKeymapScancode(SDL_Keymap *keymap, SDL_Keycode keycode, SDL_Keymod *modstate); void SDL_DestroyKeymap(SDL_Keymap *keymap); -#endif /* SDL_keymap_c_h_ */ +#endif // SDL_keymap_c_h_ diff --git a/src/events/SDL_keysym_to_scancode.c b/src/events/SDL_keysym_to_scancode.c index 08e9809424..e80b6f6d76 100644 --- a/src/events/SDL_keysym_to_scancode.c +++ b/src/events/SDL_keysym_to_scancode.c @@ -26,290 +26,290 @@ #include "SDL_scancode_tables_c.h" #include "SDL_keysym_to_scancode_c.h" -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static const struct { Uint32 keysym; SDL_Scancode scancode; } KeySymToSDLScancode[] = { - { 0xFF9C, SDL_SCANCODE_KP_1 }, /* XK_KP_End */ - { 0xFF99, SDL_SCANCODE_KP_2 }, /* XK_KP_Down */ - { 0xFF9B, SDL_SCANCODE_KP_3 }, /* XK_KP_Next */ - { 0xFF96, SDL_SCANCODE_KP_4 }, /* XK_KP_Left */ - { 0xFF9D, SDL_SCANCODE_KP_5 }, /* XK_KP_Begin */ - { 0xFF98, SDL_SCANCODE_KP_6 }, /* XK_KP_Right */ - { 0xFF95, SDL_SCANCODE_KP_7 }, /* XK_KP_Home */ - { 0xFF97, SDL_SCANCODE_KP_8 }, /* XK_KP_Up */ - { 0xFF9A, SDL_SCANCODE_KP_9 }, /* XK_KP_Prior */ - { 0xFF9E, SDL_SCANCODE_KP_0 }, /* XK_KP_Insert */ - { 0xFF9F, SDL_SCANCODE_KP_PERIOD }, /* XK_KP_Delete */ - { 0xFF62, SDL_SCANCODE_EXECUTE }, /* XK_Execute */ - { 0xFFEE, SDL_SCANCODE_APPLICATION }, /* XK_Hyper_R */ - { 0xFE03, SDL_SCANCODE_RALT }, /* XK_ISO_Level3_Shift */ - { 0xFFEB, SDL_SCANCODE_LGUI }, /* XK_Super_L */ - { 0xFFEC, SDL_SCANCODE_RGUI }, /* XK_Super_R */ - { 0xFF7E, SDL_SCANCODE_MODE }, /* XK_Mode_switch */ - { 0x1008FF65, SDL_SCANCODE_MENU }, /* XF86MenuKB */ - { 0x1008FF81, SDL_SCANCODE_F13 }, /* XF86Tools */ - { 0x1008FF45, SDL_SCANCODE_F14 }, /* XF86Launch5 */ - { 0x1008FF46, SDL_SCANCODE_F15 }, /* XF86Launch6 */ - { 0x1008FF47, SDL_SCANCODE_F16 }, /* XF86Launch7 */ - { 0x1008FF48, SDL_SCANCODE_F17 }, /* XF86Launch8 */ - { 0x1008FF49, SDL_SCANCODE_F18 }, /* XF86Launch9 */ + { 0xFF9C, SDL_SCANCODE_KP_1 }, // XK_KP_End + { 0xFF99, SDL_SCANCODE_KP_2 }, // XK_KP_Down + { 0xFF9B, SDL_SCANCODE_KP_3 }, // XK_KP_Next + { 0xFF96, SDL_SCANCODE_KP_4 }, // XK_KP_Left + { 0xFF9D, SDL_SCANCODE_KP_5 }, // XK_KP_Begin + { 0xFF98, SDL_SCANCODE_KP_6 }, // XK_KP_Right + { 0xFF95, SDL_SCANCODE_KP_7 }, // XK_KP_Home + { 0xFF97, SDL_SCANCODE_KP_8 }, // XK_KP_Up + { 0xFF9A, SDL_SCANCODE_KP_9 }, // XK_KP_Prior + { 0xFF9E, SDL_SCANCODE_KP_0 }, // XK_KP_Insert + { 0xFF9F, SDL_SCANCODE_KP_PERIOD }, // XK_KP_Delete + { 0xFF62, SDL_SCANCODE_EXECUTE }, // XK_Execute + { 0xFFEE, SDL_SCANCODE_APPLICATION }, // XK_Hyper_R + { 0xFE03, SDL_SCANCODE_RALT }, // XK_ISO_Level3_Shift + { 0xFFEB, SDL_SCANCODE_LGUI }, // XK_Super_L + { 0xFFEC, SDL_SCANCODE_RGUI }, // XK_Super_R + { 0xFF7E, SDL_SCANCODE_MODE }, // XK_Mode_switch + { 0x1008FF65, SDL_SCANCODE_MENU }, // XF86MenuKB + { 0x1008FF81, SDL_SCANCODE_F13 }, // XF86Tools + { 0x1008FF45, SDL_SCANCODE_F14 }, // XF86Launch5 + { 0x1008FF46, SDL_SCANCODE_F15 }, // XF86Launch6 + { 0x1008FF47, SDL_SCANCODE_F16 }, // XF86Launch7 + { 0x1008FF48, SDL_SCANCODE_F17 }, // XF86Launch8 + { 0x1008FF49, SDL_SCANCODE_F18 }, // XF86Launch9 }; -/* This is a mapping from X keysym to Linux keycode */ +// This is a mapping from X keysym to Linux keycode static const Uint32 LinuxKeycodeKeysyms[] = { - /* 0, 0x000 */ 0x0, /* NoSymbol */ - /* 1, 0x001 */ 0xFF1B, /* Escape */ - /* 2, 0x002 */ 0x31, /* 1 */ - /* 3, 0x003 */ 0x32, /* 2 */ - /* 4, 0x004 */ 0x33, /* 3 */ - /* 5, 0x005 */ 0x34, /* 4 */ - /* 6, 0x006 */ 0x35, /* 5 */ - /* 7, 0x007 */ 0x36, /* 6 */ - /* 8, 0x008 */ 0x37, /* 7 */ - /* 9, 0x009 */ 0x38, /* 8 */ - /* 10, 0x00a */ 0x39, /* 9 */ - /* 11, 0x00b */ 0x30, /* 0 */ - /* 12, 0x00c */ 0x2D, /* minus */ - /* 13, 0x00d */ 0x3D, /* equal */ - /* 14, 0x00e */ 0xFF08, /* BackSpace */ - /* 15, 0x00f */ 0xFF09, /* Tab */ - /* 16, 0x010 */ 0x71, /* q */ - /* 17, 0x011 */ 0x77, /* w */ - /* 18, 0x012 */ 0x65, /* e */ - /* 19, 0x013 */ 0x72, /* r */ - /* 20, 0x014 */ 0x74, /* t */ - /* 21, 0x015 */ 0x79, /* y */ - /* 22, 0x016 */ 0x75, /* u */ - /* 23, 0x017 */ 0x69, /* i */ - /* 24, 0x018 */ 0x6F, /* o */ - /* 25, 0x019 */ 0x70, /* p */ - /* 26, 0x01a */ 0x5B, /* bracketleft */ - /* 27, 0x01b */ 0x5D, /* bracketright */ - /* 28, 0x01c */ 0xFF0D, /* Return */ - /* 29, 0x01d */ 0xFFE3, /* Control_L */ - /* 30, 0x01e */ 0x61, /* a */ - /* 31, 0x01f */ 0x73, /* s */ - /* 32, 0x020 */ 0x64, /* d */ - /* 33, 0x021 */ 0x66, /* f */ - /* 34, 0x022 */ 0x67, /* g */ - /* 35, 0x023 */ 0x68, /* h */ - /* 36, 0x024 */ 0x6A, /* j */ - /* 37, 0x025 */ 0x6B, /* k */ - /* 38, 0x026 */ 0x6C, /* l */ - /* 39, 0x027 */ 0x3B, /* semicolon */ - /* 40, 0x028 */ 0x27, /* apostrophe */ - /* 41, 0x029 */ 0x60, /* grave */ - /* 42, 0x02a */ 0xFFE1, /* Shift_L */ - /* 43, 0x02b */ 0x5C, /* backslash */ - /* 44, 0x02c */ 0x7A, /* z */ - /* 45, 0x02d */ 0x78, /* x */ - /* 46, 0x02e */ 0x63, /* c */ - /* 47, 0x02f */ 0x76, /* v */ - /* 48, 0x030 */ 0x62, /* b */ - /* 49, 0x031 */ 0x6E, /* n */ - /* 50, 0x032 */ 0x6D, /* m */ - /* 51, 0x033 */ 0x2C, /* comma */ - /* 52, 0x034 */ 0x2E, /* period */ - /* 53, 0x035 */ 0x2F, /* slash */ - /* 54, 0x036 */ 0xFFE2, /* Shift_R */ - /* 55, 0x037 */ 0xFFAA, /* KP_Multiply */ - /* 56, 0x038 */ 0xFFE9, /* Alt_L */ - /* 57, 0x039 */ 0x20, /* space */ - /* 58, 0x03a */ 0xFFE5, /* Caps_Lock */ - /* 59, 0x03b */ 0xFFBE, /* F1 */ - /* 60, 0x03c */ 0xFFBF, /* F2 */ - /* 61, 0x03d */ 0xFFC0, /* F3 */ - /* 62, 0x03e */ 0xFFC1, /* F4 */ - /* 63, 0x03f */ 0xFFC2, /* F5 */ - /* 64, 0x040 */ 0xFFC3, /* F6 */ - /* 65, 0x041 */ 0xFFC4, /* F7 */ - /* 66, 0x042 */ 0xFFC5, /* F8 */ - /* 67, 0x043 */ 0xFFC6, /* F9 */ - /* 68, 0x044 */ 0xFFC7, /* F10 */ - /* 69, 0x045 */ 0xFF7F, /* Num_Lock */ - /* 70, 0x046 */ 0xFF14, /* Scroll_Lock */ - /* 71, 0x047 */ 0xFFB7, /* KP_7 */ - /* 72, 0x048 */ 0XFFB8, /* KP_8 */ - /* 73, 0x049 */ 0XFFB9, /* KP_9 */ - /* 74, 0x04a */ 0xFFAD, /* KP_Subtract */ - /* 75, 0x04b */ 0xFFB4, /* KP_4 */ - /* 76, 0x04c */ 0xFFB5, /* KP_5 */ - /* 77, 0x04d */ 0xFFB6, /* KP_6 */ - /* 78, 0x04e */ 0xFFAB, /* KP_Add */ - /* 79, 0x04f */ 0xFFB1, /* KP_1 */ - /* 80, 0x050 */ 0xFFB2, /* KP_2 */ - /* 81, 0x051 */ 0xFFB3, /* KP_3 */ - /* 82, 0x052 */ 0xFFB0, /* KP_0 */ - /* 83, 0x053 */ 0xFFAE, /* KP_Decimal */ - /* 84, 0x054 */ 0x0, /* NoSymbol */ - /* 85, 0x055 */ 0x0, /* NoSymbol */ - /* 86, 0x056 */ 0x3C, /* less */ - /* 87, 0x057 */ 0xFFC8, /* F11 */ - /* 88, 0x058 */ 0xFFC9, /* F12 */ - /* 89, 0x059 */ 0x0, /* NoSymbol */ - /* 90, 0x05a */ 0xFF26, /* Katakana */ - /* 91, 0x05b */ 0xFF25, /* Hiragana */ - /* 92, 0x05c */ 0xFF23, /* Henkan_Mode */ - /* 93, 0x05d */ 0xFF27, /* Hiragana_Katakana */ - /* 94, 0x05e */ 0xFF22, /* Muhenkan */ - /* 95, 0x05f */ 0x0, /* NoSymbol */ - /* 96, 0x060 */ 0xFF8D, /* KP_Enter */ - /* 97, 0x061 */ 0xFFE4, /* Control_R */ - /* 98, 0x062 */ 0xFFAF, /* KP_Divide */ - /* 99, 0x063 */ 0xFF15, /* Sys_Req */ - /* 100, 0x064 */ 0xFFEA, /* Alt_R */ - /* 101, 0x065 */ 0xFF0A, /* Linefeed */ - /* 102, 0x066 */ 0xFF50, /* Home */ - /* 103, 0x067 */ 0xFF52, /* Up */ - /* 104, 0x068 */ 0xFF55, /* Prior */ - /* 105, 0x069 */ 0xFF51, /* Left */ - /* 106, 0x06a */ 0xFF53, /* Right */ - /* 107, 0x06b */ 0xFF57, /* End */ - /* 108, 0x06c */ 0xFF54, /* Down */ - /* 109, 0x06d */ 0xFF56, /* Next */ - /* 110, 0x06e */ 0xFF63, /* Insert */ - /* 111, 0x06f */ 0xFFFF, /* Delete */ - /* 112, 0x070 */ 0x0, /* NoSymbol */ - /* 113, 0x071 */ 0x1008FF12, /* XF86AudioMute */ - /* 114, 0x072 */ 0x1008FF11, /* XF86AudioLowerVolume */ - /* 115, 0x073 */ 0x1008FF13, /* XF86AudioRaiseVolume */ - /* 116, 0x074 */ 0x1008FF2A, /* XF86PowerOff */ - /* 117, 0x075 */ 0xFFBD, /* KP_Equal */ - /* 118, 0x076 */ 0xB1, /* plusminus */ - /* 119, 0x077 */ 0xFF13, /* Pause */ - /* 120, 0x078 */ 0x1008FF4A, /* XF86LaunchA */ - /* 121, 0x079 */ 0xFFAC, /* KP_Separator */ - /* 122, 0x07a */ 0xFF31, /* Hangul */ - /* 123, 0x07b */ 0xFF34, /* Hangul_Hanja */ - /* 124, 0x07c */ 0x0, /* NoSymbol */ - /* 125, 0x07d */ 0xFFE7, /* Meta_L */ - /* 126, 0x07e */ 0xFFE8, /* Meta_R */ - /* 127, 0x07f */ 0xFF67, /* Menu */ - /* 128, 0x080 */ 0x00, /* NoSymbol */ - /* 129, 0x081 */ 0xFF66, /* Redo */ - /* 130, 0x082 */ 0x1005FF70, /* SunProps */ - /* 131, 0x083 */ 0xFF65, /* Undo */ - /* 132, 0x084 */ 0x1005FF71, /* SunFront */ - /* 133, 0x085 */ 0x1008FF57, /* XF86Copy */ - /* 134, 0x086 */ 0x1008FF6B, /* XF86Open */ - /* 135, 0x087 */ 0x1008FF6D, /* XF86Paste */ - /* 136, 0x088 */ 0xFF68, /* Find */ - /* 137, 0x089 */ 0x1008FF58, /* XF86Cut */ - /* 138, 0x08a */ 0xFF6A, /* Help */ - /* 139, 0x08b */ 0xFF67, /* Menu */ - /* 140, 0x08c */ 0x1008FF1D, /* XF86Calculator */ - /* 141, 0x08d */ 0x0, /* NoSymbol */ - /* 142, 0x08e */ 0x1008FF2F, /* XF86Sleep */ - /* 143, 0x08f */ 0x1008FF2B, /* XF86WakeUp */ - /* 144, 0x090 */ 0x1008FF5D, /* XF86Explorer */ - /* 145, 0x091 */ 0x1008FF7B, /* XF86Send */ - /* 146, 0x092 */ 0x0, /* NoSymbol */ - /* 147, 0x093 */ 0x1008FF8A, /* XF86Xfer */ - /* 148, 0x094 */ 0x1008FF41, /* XF86Launch1 */ - /* 149, 0x095 */ 0x1008FF42, /* XF86Launch2 */ - /* 150, 0x096 */ 0x1008FF2E, /* XF86WWW */ - /* 151, 0x097 */ 0x1008FF5A, /* XF86DOS */ - /* 152, 0x098 */ 0x1008FF2D, /* XF86ScreenSaver */ - /* 153, 0x099 */ 0x1008FF74, /* XF86RotateWindows */ - /* 154, 0x09a */ 0x1008FF7F, /* XF86TaskPane */ - /* 155, 0x09b */ 0x1008FF19, /* XF86Mail */ - /* 156, 0x09c */ 0x1008FF30, /* XF86Favorites */ - /* 157, 0x09d */ 0x1008FF33, /* XF86MyComputer */ - /* 158, 0x09e */ 0x1008FF26, /* XF86Back */ - /* 159, 0x09f */ 0x1008FF27, /* XF86Forward */ - /* 160, 0x0a0 */ 0x0, /* NoSymbol */ - /* 161, 0x0a1 */ 0x1008FF2C, /* XF86Eject */ - /* 162, 0x0a2 */ 0x1008FF2C, /* XF86Eject */ - /* 163, 0x0a3 */ 0x1008FF17, /* XF86AudioNext */ - /* 164, 0x0a4 */ 0x1008FF14, /* XF86AudioPlay */ - /* 165, 0x0a5 */ 0x1008FF16, /* XF86AudioPrev */ - /* 166, 0x0a6 */ 0x1008FF15, /* XF86AudioStop */ - /* 167, 0x0a7 */ 0x1008FF1C, /* XF86AudioRecord */ - /* 168, 0x0a8 */ 0x1008FF3E, /* XF86AudioRewind */ - /* 169, 0x0a9 */ 0x1008FF6E, /* XF86Phone */ - /* 170, 0x0aa */ 0x0, /* NoSymbol */ - /* 171, 0x0ab */ 0x1008FF81, /* XF86Tools */ - /* 172, 0x0ac */ 0x1008FF18, /* XF86HomePage */ - /* 173, 0x0ad */ 0x1008FF73, /* XF86Reload */ - /* 174, 0x0ae */ 0x1008FF56, /* XF86Close */ - /* 175, 0x0af */ 0x0, /* NoSymbol */ - /* 176, 0x0b0 */ 0x0, /* NoSymbol */ - /* 177, 0x0b1 */ 0x1008FF78, /* XF86ScrollUp */ - /* 178, 0x0b2 */ 0x1008FF79, /* XF86ScrollDown */ - /* 179, 0x0b3 */ 0x0, /* NoSymbol */ - /* 180, 0x0b4 */ 0x0, /* NoSymbol */ - /* 181, 0x0b5 */ 0x1008FF68, /* XF86New */ - /* 182, 0x0b6 */ 0xFF66, /* Redo */ - /* 183, 0x0b7 */ 0xFFCA, /* F13 */ - /* 184, 0x0b8 */ 0xFFCB, /* F14 */ - /* 185, 0x0b9 */ 0xFFCC, /* F15 */ - /* 186, 0x0ba */ 0xFFCD, /* F16 */ - /* 187, 0x0bb */ 0xFFCE, /* F17 */ - /* 188, 0x0bc */ 0xFFCF, /* F18 */ - /* 189, 0x0bd */ 0xFFD0, /* F19 */ - /* 190, 0x0be */ 0xFFD1, /* F20 */ - /* 191, 0x0bf */ 0xFFD2, /* F21 */ - /* 192, 0x0c0 */ 0xFFD3, /* F22 */ - /* 193, 0x0c1 */ 0xFFD4, /* F23 */ - /* 194, 0x0c2 */ 0xFFD5, /* F24 */ - /* 195, 0x0c3 */ 0x0, /* NoSymbol */ - /* 196, 0x0c4 */ 0x0, /* NoSymbol */ - /* 197, 0x0c5 */ 0x0, /* NoSymbol */ - /* 198, 0x0c6 */ 0x0, /* NoSymbol */ - /* 199, 0x0c7 */ 0x0, /* NoSymbol */ - /* 200, 0x0c8 */ 0x1008FF14, /* XF86AudioPlay */ - /* 201, 0x0c9 */ 0x1008FF31, /* XF86AudioPause */ - /* 202, 0x0ca */ 0x1008FF43, /* XF86Launch3 */ - /* 203, 0x0cb */ 0x1008FF44, /* XF86Launch4 */ - /* 204, 0x0cc */ 0x1008FF4B, /* XF86LaunchB */ - /* 205, 0x0cd */ 0x1008FFA7, /* XF86Suspend */ - /* 206, 0x0ce */ 0x1008FF56, /* XF86Close */ - /* 207, 0x0cf */ 0x1008FF14, /* XF86AudioPlay */ - /* 208, 0x0d0 */ 0x1008FF97, /* XF86AudioForward */ - /* 209, 0x0d1 */ 0x0, /* NoSymbol */ - /* 210, 0x0d2 */ 0xFF61, /* Print */ - /* 211, 0x0d3 */ 0x0, /* NoSymbol */ - /* 212, 0x0d4 */ 0x1008FF8F, /* XF86WebCam */ - /* 213, 0x0d5 */ 0x1008FFB6, /* XF86AudioPreset */ - /* 214, 0x0d6 */ 0x0, /* NoSymbol */ - /* 215, 0x0d7 */ 0x1008FF19, /* XF86Mail */ - /* 216, 0x0d8 */ 0x1008FF8E, /* XF86Messenger */ - /* 217, 0x0d9 */ 0x1008FF1B, /* XF86Search */ - /* 218, 0x0da */ 0x1008FF5F, /* XF86Go */ - /* 219, 0x0db */ 0x1008FF3C, /* XF86Finance */ - /* 220, 0x0dc */ 0x1008FF5E, /* XF86Game */ - /* 221, 0x0dd */ 0x1008FF36, /* XF86Shop */ - /* 222, 0x0de */ 0x0, /* NoSymbol */ - /* 223, 0x0df */ 0xFF69, /* Cancel */ - /* 224, 0x0e0 */ 0x1008FF03, /* XF86MonBrightnessDown */ - /* 225, 0x0e1 */ 0x1008FF02, /* XF86MonBrightnessUp */ - /* 226, 0x0e2 */ 0x1008FF32, /* XF86AudioMedia */ - /* 227, 0x0e3 */ 0x1008FF59, /* XF86Display */ - /* 228, 0x0e4 */ 0x1008FF04, /* XF86KbdLightOnOff */ - /* 229, 0x0e5 */ 0x1008FF06, /* XF86KbdBrightnessDown */ - /* 230, 0x0e6 */ 0x1008FF05, /* XF86KbdBrightnessUp */ - /* 231, 0x0e7 */ 0x1008FF7B, /* XF86Send */ - /* 232, 0x0e8 */ 0x1008FF72, /* XF86Reply */ - /* 233, 0x0e9 */ 0x1008FF90, /* XF86MailForward */ - /* 234, 0x0ea */ 0x1008FF77, /* XF86Save */ - /* 235, 0x0eb */ 0x1008FF5B, /* XF86Documents */ - /* 236, 0x0ec */ 0x1008FF93, /* XF86Battery */ - /* 237, 0x0ed */ 0x1008FF94, /* XF86Bluetooth */ - /* 238, 0x0ee */ 0x1008FF95, /* XF86WLAN */ - /* 239, 0x0ef */ 0x1008FF96, /* XF86UWB */ - /* 240, 0x0f0 */ 0x0, /* NoSymbol */ - /* 241, 0x0f1 */ 0x1008FE22, /* XF86Next_VMode */ - /* 242, 0x0f2 */ 0x1008FE23, /* XF86Prev_VMode */ - /* 243, 0x0f3 */ 0x1008FF07, /* XF86MonBrightnessCycle */ - /* 244, 0x0f4 */ 0x100810F4, /* XF86BrightnessAuto */ - /* 245, 0x0f5 */ 0x100810F5, /* XF86DisplayOff */ - /* 246, 0x0f6 */ 0x1008FFB4, /* XF86WWAN */ - /* 247, 0x0f7 */ 0x1008FFB5, /* XF86RFKill */ + /* 0, 0x000 */ 0x0, // NoSymbol + /* 1, 0x001 */ 0xFF1B, // Escape + /* 2, 0x002 */ 0x31, // 1 + /* 3, 0x003 */ 0x32, // 2 + /* 4, 0x004 */ 0x33, // 3 + /* 5, 0x005 */ 0x34, // 4 + /* 6, 0x006 */ 0x35, // 5 + /* 7, 0x007 */ 0x36, // 6 + /* 8, 0x008 */ 0x37, // 7 + /* 9, 0x009 */ 0x38, // 8 + /* 10, 0x00a */ 0x39, // 9 + /* 11, 0x00b */ 0x30, // 0 + /* 12, 0x00c */ 0x2D, // minus + /* 13, 0x00d */ 0x3D, // equal + /* 14, 0x00e */ 0xFF08, // BackSpace + /* 15, 0x00f */ 0xFF09, // Tab + /* 16, 0x010 */ 0x71, // q + /* 17, 0x011 */ 0x77, // w + /* 18, 0x012 */ 0x65, // e + /* 19, 0x013 */ 0x72, // r + /* 20, 0x014 */ 0x74, // t + /* 21, 0x015 */ 0x79, // y + /* 22, 0x016 */ 0x75, // u + /* 23, 0x017 */ 0x69, // i + /* 24, 0x018 */ 0x6F, // o + /* 25, 0x019 */ 0x70, // p + /* 26, 0x01a */ 0x5B, // bracketleft + /* 27, 0x01b */ 0x5D, // bracketright + /* 28, 0x01c */ 0xFF0D, // Return + /* 29, 0x01d */ 0xFFE3, // Control_L + /* 30, 0x01e */ 0x61, // a + /* 31, 0x01f */ 0x73, // s + /* 32, 0x020 */ 0x64, // d + /* 33, 0x021 */ 0x66, // f + /* 34, 0x022 */ 0x67, // g + /* 35, 0x023 */ 0x68, // h + /* 36, 0x024 */ 0x6A, // j + /* 37, 0x025 */ 0x6B, // k + /* 38, 0x026 */ 0x6C, // l + /* 39, 0x027 */ 0x3B, // semicolon + /* 40, 0x028 */ 0x27, // apostrophe + /* 41, 0x029 */ 0x60, // grave + /* 42, 0x02a */ 0xFFE1, // Shift_L + /* 43, 0x02b */ 0x5C, // backslash + /* 44, 0x02c */ 0x7A, // z + /* 45, 0x02d */ 0x78, // x + /* 46, 0x02e */ 0x63, // c + /* 47, 0x02f */ 0x76, // v + /* 48, 0x030 */ 0x62, // b + /* 49, 0x031 */ 0x6E, // n + /* 50, 0x032 */ 0x6D, // m + /* 51, 0x033 */ 0x2C, // comma + /* 52, 0x034 */ 0x2E, // period + /* 53, 0x035 */ 0x2F, // slash + /* 54, 0x036 */ 0xFFE2, // Shift_R + /* 55, 0x037 */ 0xFFAA, // KP_Multiply + /* 56, 0x038 */ 0xFFE9, // Alt_L + /* 57, 0x039 */ 0x20, // space + /* 58, 0x03a */ 0xFFE5, // Caps_Lock + /* 59, 0x03b */ 0xFFBE, // F1 + /* 60, 0x03c */ 0xFFBF, // F2 + /* 61, 0x03d */ 0xFFC0, // F3 + /* 62, 0x03e */ 0xFFC1, // F4 + /* 63, 0x03f */ 0xFFC2, // F5 + /* 64, 0x040 */ 0xFFC3, // F6 + /* 65, 0x041 */ 0xFFC4, // F7 + /* 66, 0x042 */ 0xFFC5, // F8 + /* 67, 0x043 */ 0xFFC6, // F9 + /* 68, 0x044 */ 0xFFC7, // F10 + /* 69, 0x045 */ 0xFF7F, // Num_Lock + /* 70, 0x046 */ 0xFF14, // Scroll_Lock + /* 71, 0x047 */ 0xFFB7, // KP_7 + /* 72, 0x048 */ 0XFFB8, // KP_8 + /* 73, 0x049 */ 0XFFB9, // KP_9 + /* 74, 0x04a */ 0xFFAD, // KP_Subtract + /* 75, 0x04b */ 0xFFB4, // KP_4 + /* 76, 0x04c */ 0xFFB5, // KP_5 + /* 77, 0x04d */ 0xFFB6, // KP_6 + /* 78, 0x04e */ 0xFFAB, // KP_Add + /* 79, 0x04f */ 0xFFB1, // KP_1 + /* 80, 0x050 */ 0xFFB2, // KP_2 + /* 81, 0x051 */ 0xFFB3, // KP_3 + /* 82, 0x052 */ 0xFFB0, // KP_0 + /* 83, 0x053 */ 0xFFAE, // KP_Decimal + /* 84, 0x054 */ 0x0, // NoSymbol + /* 85, 0x055 */ 0x0, // NoSymbol + /* 86, 0x056 */ 0x3C, // less + /* 87, 0x057 */ 0xFFC8, // F11 + /* 88, 0x058 */ 0xFFC9, // F12 + /* 89, 0x059 */ 0x0, // NoSymbol + /* 90, 0x05a */ 0xFF26, // Katakana + /* 91, 0x05b */ 0xFF25, // Hiragana + /* 92, 0x05c */ 0xFF23, // Henkan_Mode + /* 93, 0x05d */ 0xFF27, // Hiragana_Katakana + /* 94, 0x05e */ 0xFF22, // Muhenkan + /* 95, 0x05f */ 0x0, // NoSymbol + /* 96, 0x060 */ 0xFF8D, // KP_Enter + /* 97, 0x061 */ 0xFFE4, // Control_R + /* 98, 0x062 */ 0xFFAF, // KP_Divide + /* 99, 0x063 */ 0xFF15, // Sys_Req + /* 100, 0x064 */ 0xFFEA, // Alt_R + /* 101, 0x065 */ 0xFF0A, // Linefeed + /* 102, 0x066 */ 0xFF50, // Home + /* 103, 0x067 */ 0xFF52, // Up + /* 104, 0x068 */ 0xFF55, // Prior + /* 105, 0x069 */ 0xFF51, // Left + /* 106, 0x06a */ 0xFF53, // Right + /* 107, 0x06b */ 0xFF57, // End + /* 108, 0x06c */ 0xFF54, // Down + /* 109, 0x06d */ 0xFF56, // Next + /* 110, 0x06e */ 0xFF63, // Insert + /* 111, 0x06f */ 0xFFFF, // Delete + /* 112, 0x070 */ 0x0, // NoSymbol + /* 113, 0x071 */ 0x1008FF12, // XF86AudioMute + /* 114, 0x072 */ 0x1008FF11, // XF86AudioLowerVolume + /* 115, 0x073 */ 0x1008FF13, // XF86AudioRaiseVolume + /* 116, 0x074 */ 0x1008FF2A, // XF86PowerOff + /* 117, 0x075 */ 0xFFBD, // KP_Equal + /* 118, 0x076 */ 0xB1, // plusminus + /* 119, 0x077 */ 0xFF13, // Pause + /* 120, 0x078 */ 0x1008FF4A, // XF86LaunchA + /* 121, 0x079 */ 0xFFAC, // KP_Separator + /* 122, 0x07a */ 0xFF31, // Hangul + /* 123, 0x07b */ 0xFF34, // Hangul_Hanja + /* 124, 0x07c */ 0x0, // NoSymbol + /* 125, 0x07d */ 0xFFE7, // Meta_L + /* 126, 0x07e */ 0xFFE8, // Meta_R + /* 127, 0x07f */ 0xFF67, // Menu + /* 128, 0x080 */ 0x00, // NoSymbol + /* 129, 0x081 */ 0xFF66, // Redo + /* 130, 0x082 */ 0x1005FF70, // SunProps + /* 131, 0x083 */ 0xFF65, // Undo + /* 132, 0x084 */ 0x1005FF71, // SunFront + /* 133, 0x085 */ 0x1008FF57, // XF86Copy + /* 134, 0x086 */ 0x1008FF6B, // XF86Open + /* 135, 0x087 */ 0x1008FF6D, // XF86Paste + /* 136, 0x088 */ 0xFF68, // Find + /* 137, 0x089 */ 0x1008FF58, // XF86Cut + /* 138, 0x08a */ 0xFF6A, // Help + /* 139, 0x08b */ 0xFF67, // Menu + /* 140, 0x08c */ 0x1008FF1D, // XF86Calculator + /* 141, 0x08d */ 0x0, // NoSymbol + /* 142, 0x08e */ 0x1008FF2F, // XF86Sleep + /* 143, 0x08f */ 0x1008FF2B, // XF86WakeUp + /* 144, 0x090 */ 0x1008FF5D, // XF86Explorer + /* 145, 0x091 */ 0x1008FF7B, // XF86Send + /* 146, 0x092 */ 0x0, // NoSymbol + /* 147, 0x093 */ 0x1008FF8A, // XF86Xfer + /* 148, 0x094 */ 0x1008FF41, // XF86Launch1 + /* 149, 0x095 */ 0x1008FF42, // XF86Launch2 + /* 150, 0x096 */ 0x1008FF2E, // XF86WWW + /* 151, 0x097 */ 0x1008FF5A, // XF86DOS + /* 152, 0x098 */ 0x1008FF2D, // XF86ScreenSaver + /* 153, 0x099 */ 0x1008FF74, // XF86RotateWindows + /* 154, 0x09a */ 0x1008FF7F, // XF86TaskPane + /* 155, 0x09b */ 0x1008FF19, // XF86Mail + /* 156, 0x09c */ 0x1008FF30, // XF86Favorites + /* 157, 0x09d */ 0x1008FF33, // XF86MyComputer + /* 158, 0x09e */ 0x1008FF26, // XF86Back + /* 159, 0x09f */ 0x1008FF27, // XF86Forward + /* 160, 0x0a0 */ 0x0, // NoSymbol + /* 161, 0x0a1 */ 0x1008FF2C, // XF86Eject + /* 162, 0x0a2 */ 0x1008FF2C, // XF86Eject + /* 163, 0x0a3 */ 0x1008FF17, // XF86AudioNext + /* 164, 0x0a4 */ 0x1008FF14, // XF86AudioPlay + /* 165, 0x0a5 */ 0x1008FF16, // XF86AudioPrev + /* 166, 0x0a6 */ 0x1008FF15, // XF86AudioStop + /* 167, 0x0a7 */ 0x1008FF1C, // XF86AudioRecord + /* 168, 0x0a8 */ 0x1008FF3E, // XF86AudioRewind + /* 169, 0x0a9 */ 0x1008FF6E, // XF86Phone + /* 170, 0x0aa */ 0x0, // NoSymbol + /* 171, 0x0ab */ 0x1008FF81, // XF86Tools + /* 172, 0x0ac */ 0x1008FF18, // XF86HomePage + /* 173, 0x0ad */ 0x1008FF73, // XF86Reload + /* 174, 0x0ae */ 0x1008FF56, // XF86Close + /* 175, 0x0af */ 0x0, // NoSymbol + /* 176, 0x0b0 */ 0x0, // NoSymbol + /* 177, 0x0b1 */ 0x1008FF78, // XF86ScrollUp + /* 178, 0x0b2 */ 0x1008FF79, // XF86ScrollDown + /* 179, 0x0b3 */ 0x0, // NoSymbol + /* 180, 0x0b4 */ 0x0, // NoSymbol + /* 181, 0x0b5 */ 0x1008FF68, // XF86New + /* 182, 0x0b6 */ 0xFF66, // Redo + /* 183, 0x0b7 */ 0xFFCA, // F13 + /* 184, 0x0b8 */ 0xFFCB, // F14 + /* 185, 0x0b9 */ 0xFFCC, // F15 + /* 186, 0x0ba */ 0xFFCD, // F16 + /* 187, 0x0bb */ 0xFFCE, // F17 + /* 188, 0x0bc */ 0xFFCF, // F18 + /* 189, 0x0bd */ 0xFFD0, // F19 + /* 190, 0x0be */ 0xFFD1, // F20 + /* 191, 0x0bf */ 0xFFD2, // F21 + /* 192, 0x0c0 */ 0xFFD3, // F22 + /* 193, 0x0c1 */ 0xFFD4, // F23 + /* 194, 0x0c2 */ 0xFFD5, // F24 + /* 195, 0x0c3 */ 0x0, // NoSymbol + /* 196, 0x0c4 */ 0x0, // NoSymbol + /* 197, 0x0c5 */ 0x0, // NoSymbol + /* 198, 0x0c6 */ 0x0, // NoSymbol + /* 199, 0x0c7 */ 0x0, // NoSymbol + /* 200, 0x0c8 */ 0x1008FF14, // XF86AudioPlay + /* 201, 0x0c9 */ 0x1008FF31, // XF86AudioPause + /* 202, 0x0ca */ 0x1008FF43, // XF86Launch3 + /* 203, 0x0cb */ 0x1008FF44, // XF86Launch4 + /* 204, 0x0cc */ 0x1008FF4B, // XF86LaunchB + /* 205, 0x0cd */ 0x1008FFA7, // XF86Suspend + /* 206, 0x0ce */ 0x1008FF56, // XF86Close + /* 207, 0x0cf */ 0x1008FF14, // XF86AudioPlay + /* 208, 0x0d0 */ 0x1008FF97, // XF86AudioForward + /* 209, 0x0d1 */ 0x0, // NoSymbol + /* 210, 0x0d2 */ 0xFF61, // Print + /* 211, 0x0d3 */ 0x0, // NoSymbol + /* 212, 0x0d4 */ 0x1008FF8F, // XF86WebCam + /* 213, 0x0d5 */ 0x1008FFB6, // XF86AudioPreset + /* 214, 0x0d6 */ 0x0, // NoSymbol + /* 215, 0x0d7 */ 0x1008FF19, // XF86Mail + /* 216, 0x0d8 */ 0x1008FF8E, // XF86Messenger + /* 217, 0x0d9 */ 0x1008FF1B, // XF86Search + /* 218, 0x0da */ 0x1008FF5F, // XF86Go + /* 219, 0x0db */ 0x1008FF3C, // XF86Finance + /* 220, 0x0dc */ 0x1008FF5E, // XF86Game + /* 221, 0x0dd */ 0x1008FF36, // XF86Shop + /* 222, 0x0de */ 0x0, // NoSymbol + /* 223, 0x0df */ 0xFF69, // Cancel + /* 224, 0x0e0 */ 0x1008FF03, // XF86MonBrightnessDown + /* 225, 0x0e1 */ 0x1008FF02, // XF86MonBrightnessUp + /* 226, 0x0e2 */ 0x1008FF32, // XF86AudioMedia + /* 227, 0x0e3 */ 0x1008FF59, // XF86Display + /* 228, 0x0e4 */ 0x1008FF04, // XF86KbdLightOnOff + /* 229, 0x0e5 */ 0x1008FF06, // XF86KbdBrightnessDown + /* 230, 0x0e6 */ 0x1008FF05, // XF86KbdBrightnessUp + /* 231, 0x0e7 */ 0x1008FF7B, // XF86Send + /* 232, 0x0e8 */ 0x1008FF72, // XF86Reply + /* 233, 0x0e9 */ 0x1008FF90, // XF86MailForward + /* 234, 0x0ea */ 0x1008FF77, // XF86Save + /* 235, 0x0eb */ 0x1008FF5B, // XF86Documents + /* 236, 0x0ec */ 0x1008FF93, // XF86Battery + /* 237, 0x0ed */ 0x1008FF94, // XF86Bluetooth + /* 238, 0x0ee */ 0x1008FF95, // XF86WLAN + /* 239, 0x0ef */ 0x1008FF96, // XF86UWB + /* 240, 0x0f0 */ 0x0, // NoSymbol + /* 241, 0x0f1 */ 0x1008FE22, // XF86Next_VMode + /* 242, 0x0f2 */ 0x1008FE23, // XF86Prev_VMode + /* 243, 0x0f3 */ 0x1008FF07, // XF86MonBrightnessCycle + /* 244, 0x0f4 */ 0x100810F4, // XF86BrightnessAuto + /* 245, 0x0f5 */ 0x100810F5, // XF86DisplayOff + /* 246, 0x0f6 */ 0x1008FFB4, // XF86WWAN + /* 247, 0x0f7 */ 0x1008FFB5, // XF86RFKill }; -#if 0 /* Here is a script to generate the ExtendedLinuxKeycodeKeysyms table */ +#if 0 // Here is a script to generate the ExtendedLinuxKeycodeKeysyms table #!/bin/bash function process_line @@ -329,70 +329,70 @@ static const struct { Uint32 keysym; int linux_keycode; } ExtendedLinuxKeycodeKeysyms[] = { - { 0x1008FF2C, 0x0a2 }, /* XF86XK_Eject */ - { 0x1008FF68, 0x0b5 }, /* XF86XK_New */ - { 0x0000FF66, 0x0b6 }, /* XK_Redo */ - { 0x1008FF4B, 0x0cc }, /* XF86XK_LaunchB */ - { 0x1008FF59, 0x0e3 }, /* XF86XK_Display */ - { 0x1008FF04, 0x0e4 }, /* XF86XK_KbdLightOnOff */ - { 0x1008FF06, 0x0e5 }, /* XF86XK_KbdBrightnessDown */ - { 0x1008FF05, 0x0e6 }, /* XF86XK_KbdBrightnessUp */ - { 0x1008FF7B, 0x0e7 }, /* XF86XK_Send */ - { 0x1008FF72, 0x0e8 }, /* XF86XK_Reply */ - { 0x1008FF90, 0x0e9 }, /* XF86XK_MailForward */ - { 0x1008FF77, 0x0ea }, /* XF86XK_Save */ - { 0x1008FF5B, 0x0eb }, /* XF86XK_Documents */ - { 0x1008FF93, 0x0ec }, /* XF86XK_Battery */ - { 0x1008FF94, 0x0ed }, /* XF86XK_Bluetooth */ - { 0x1008FF95, 0x0ee }, /* XF86XK_WLAN */ - { 0x1008FF96, 0x0ef }, /* XF86XK_UWB */ - { 0x1008FE22, 0x0f1 }, /* XF86XK_Next_VMode */ - { 0x1008FE23, 0x0f2 }, /* XF86XK_Prev_VMode */ - { 0x1008FF07, 0x0f3 }, /* XF86XK_MonBrightnessCycle */ - { 0x1008FFB4, 0x0f6 }, /* XF86XK_WWAN */ - { 0x1008FFB5, 0x0f7 }, /* XF86XK_RFKill */ - { 0x1008FFB2, 0x0f8 }, /* XF86XK_AudioMicMute */ - { 0x1008FF9C, 0x173 }, /* XF86XK_CycleAngle */ - { 0x1008FFB8, 0x174 }, /* XF86XK_FullScreen */ - { 0x1008FF87, 0x189 }, /* XF86XK_Video */ - { 0x1008FF20, 0x18d }, /* XF86XK_Calendar */ - { 0x1008FF99, 0x19a }, /* XF86XK_AudioRandomPlay */ - { 0x1008FF5E, 0x1a1 }, /* XF86XK_Game */ - { 0x1008FF8B, 0x1a2 }, /* XF86XK_ZoomIn */ - { 0x1008FF8C, 0x1a3 }, /* XF86XK_ZoomOut */ - { 0x1008FF89, 0x1a5 }, /* XF86XK_Word */ - { 0x1008FF5C, 0x1a7 }, /* XF86XK_Excel */ - { 0x1008FF69, 0x1ab }, /* XF86XK_News */ - { 0x1008FF8E, 0x1ae }, /* XF86XK_Messenger */ - { 0x1008FF61, 0x1b1 }, /* XF86XK_LogOff */ - { 0x00000024, 0x1b2 }, /* XK_dollar */ - { 0x000020AC, 0x1b3 }, /* XK_EuroSign */ - { 0x1008FF9D, 0x1b4 }, /* XF86XK_FrameBack */ - { 0x1008FF9E, 0x1b5 }, /* XF86XK_FrameForward */ - { 0x0000FFF1, 0x1f1 }, /* XK_braille_dot_1 */ - { 0x0000FFF2, 0x1f2 }, /* XK_braille_dot_2 */ - { 0x0000FFF3, 0x1f3 }, /* XK_braille_dot_3 */ - { 0x0000FFF4, 0x1f4 }, /* XK_braille_dot_4 */ - { 0x0000FFF5, 0x1f5 }, /* XK_braille_dot_5 */ - { 0x0000FFF6, 0x1f6 }, /* XK_braille_dot_6 */ - { 0x0000FFF7, 0x1f7 }, /* XK_braille_dot_7 */ - { 0x0000FFF8, 0x1f8 }, /* XK_braille_dot_8 */ - { 0x0000FFF9, 0x1f9 }, /* XK_braille_dot_9 */ - { 0x0000FFF1, 0x1fa }, /* XK_braille_dot_1 */ - { 0x1008FFA9, 0x212 }, /* XF86XK_TouchpadToggle */ - { 0x1008FFB0, 0x213 }, /* XF86XK_TouchpadOn */ - { 0x1008FFB1, 0x214 }, /* XF86XK_TouchpadOff */ - { 0x1008FFB7, 0x231 }, /* XF86XK_RotationLockToggle */ - { 0x0000FE08, 0x248 }, /* XK_ISO_Next_Group */ + { 0x1008FF2C, 0x0a2 }, // XF86XK_Eject + { 0x1008FF68, 0x0b5 }, // XF86XK_New + { 0x0000FF66, 0x0b6 }, // XK_Redo + { 0x1008FF4B, 0x0cc }, // XF86XK_LaunchB + { 0x1008FF59, 0x0e3 }, // XF86XK_Display + { 0x1008FF04, 0x0e4 }, // XF86XK_KbdLightOnOff + { 0x1008FF06, 0x0e5 }, // XF86XK_KbdBrightnessDown + { 0x1008FF05, 0x0e6 }, // XF86XK_KbdBrightnessUp + { 0x1008FF7B, 0x0e7 }, // XF86XK_Send + { 0x1008FF72, 0x0e8 }, // XF86XK_Reply + { 0x1008FF90, 0x0e9 }, // XF86XK_MailForward + { 0x1008FF77, 0x0ea }, // XF86XK_Save + { 0x1008FF5B, 0x0eb }, // XF86XK_Documents + { 0x1008FF93, 0x0ec }, // XF86XK_Battery + { 0x1008FF94, 0x0ed }, // XF86XK_Bluetooth + { 0x1008FF95, 0x0ee }, // XF86XK_WLAN + { 0x1008FF96, 0x0ef }, // XF86XK_UWB + { 0x1008FE22, 0x0f1 }, // XF86XK_Next_VMode + { 0x1008FE23, 0x0f2 }, // XF86XK_Prev_VMode + { 0x1008FF07, 0x0f3 }, // XF86XK_MonBrightnessCycle + { 0x1008FFB4, 0x0f6 }, // XF86XK_WWAN + { 0x1008FFB5, 0x0f7 }, // XF86XK_RFKill + { 0x1008FFB2, 0x0f8 }, // XF86XK_AudioMicMute + { 0x1008FF9C, 0x173 }, // XF86XK_CycleAngle + { 0x1008FFB8, 0x174 }, // XF86XK_FullScreen + { 0x1008FF87, 0x189 }, // XF86XK_Video + { 0x1008FF20, 0x18d }, // XF86XK_Calendar + { 0x1008FF99, 0x19a }, // XF86XK_AudioRandomPlay + { 0x1008FF5E, 0x1a1 }, // XF86XK_Game + { 0x1008FF8B, 0x1a2 }, // XF86XK_ZoomIn + { 0x1008FF8C, 0x1a3 }, // XF86XK_ZoomOut + { 0x1008FF89, 0x1a5 }, // XF86XK_Word + { 0x1008FF5C, 0x1a7 }, // XF86XK_Excel + { 0x1008FF69, 0x1ab }, // XF86XK_News + { 0x1008FF8E, 0x1ae }, // XF86XK_Messenger + { 0x1008FF61, 0x1b1 }, // XF86XK_LogOff + { 0x00000024, 0x1b2 }, // XK_dollar + { 0x000020AC, 0x1b3 }, // XK_EuroSign + { 0x1008FF9D, 0x1b4 }, // XF86XK_FrameBack + { 0x1008FF9E, 0x1b5 }, // XF86XK_FrameForward + { 0x0000FFF1, 0x1f1 }, // XK_braille_dot_1 + { 0x0000FFF2, 0x1f2 }, // XK_braille_dot_2 + { 0x0000FFF3, 0x1f3 }, // XK_braille_dot_3 + { 0x0000FFF4, 0x1f4 }, // XK_braille_dot_4 + { 0x0000FFF5, 0x1f5 }, // XK_braille_dot_5 + { 0x0000FFF6, 0x1f6 }, // XK_braille_dot_6 + { 0x0000FFF7, 0x1f7 }, // XK_braille_dot_7 + { 0x0000FFF8, 0x1f8 }, // XK_braille_dot_8 + { 0x0000FFF9, 0x1f9 }, // XK_braille_dot_9 + { 0x0000FFF1, 0x1fa }, // XK_braille_dot_1 + { 0x1008FFA9, 0x212 }, // XF86XK_TouchpadToggle + { 0x1008FFB0, 0x213 }, // XF86XK_TouchpadOn + { 0x1008FFB1, 0x214 }, // XF86XK_TouchpadOff + { 0x1008FFB7, 0x231 }, // XF86XK_RotationLockToggle + { 0x0000FE08, 0x248 }, // XK_ISO_Next_Group }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode) { int i; Uint32 linux_keycode = 0; - /* First check our custom list */ + // First check our custom list for (i = 0; i < SDL_arraysize(KeySymToSDLScancode); ++i) { if (keysym == KeySymToSDLScancode[i].keysym) { return KeySymToSDLScancode[i].scancode; @@ -400,7 +400,7 @@ SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode) } if (keysym >= 0x41 && keysym <= 0x5a) { - /* Normalize alphabetic keysyms to the lowercase form */ + // Normalize alphabetic keysyms to the lowercase form keysym += 0x20; } else if (keysym >= 0x10081000 && keysym <= 0x10081FFF) { /* The rest of the keysyms map to Linux keycodes, so use that mapping @@ -409,12 +409,12 @@ SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode) linux_keycode = (keysym - 0x10081000); } if (!linux_keycode) { - /* See if this keysym is an exact match in our table */ + // See if this keysym is an exact match in our table i = (keycode - 8); if (i >= 0 && i < SDL_arraysize(LinuxKeycodeKeysyms) && keysym == LinuxKeycodeKeysyms[i]) { linux_keycode = i; } else { - /* Scan the table for this keysym */ + // Scan the table for this keysym for (i = 0; i < SDL_arraysize(LinuxKeycodeKeysyms); ++i) { if (keysym == LinuxKeycodeKeysyms[i]) { linux_keycode = i; @@ -424,7 +424,7 @@ SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode) } } if (!linux_keycode) { - /* Scan the extended table for this keysym */ + // Scan the extended table for this keysym for (i = 0; i < SDL_arraysize(ExtendedLinuxKeycodeKeysyms); ++i) { if (keysym == ExtendedLinuxKeycodeKeysyms[i].keysym) { linux_keycode = ExtendedLinuxKeycodeKeysyms[i].linux_keycode; @@ -435,4 +435,4 @@ SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode) return SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, linux_keycode); } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/events/SDL_keysym_to_scancode_c.h b/src/events/SDL_keysym_to_scancode_c.h index 91611a5d15..2d504145e7 100644 --- a/src/events/SDL_keysym_to_scancode_c.h +++ b/src/events/SDL_keysym_to_scancode_c.h @@ -22,7 +22,7 @@ #ifndef SDL_keysym_to_scancode_c_h_ #define SDL_keysym_to_scancode_c_h_ -/* This function only correctly maps letters and numbers for keyboards in US QWERTY layout */ +// This function only correctly maps letters and numbers for keyboards in US QWERTY layout extern SDL_Scancode SDL_GetScancodeFromKeySym(Uint32 keysym, Uint32 keycode); -#endif /* SDL_keysym_to_scancode_c_h_ */ +#endif // SDL_keysym_to_scancode_c_h_ diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 5af1906f9e..a3024f22db 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* General mouse handling code for SDL */ +// General mouse handling code for SDL #include "../SDL_hints_c.h" #include "../video/SDL_sysvideo.h" @@ -30,7 +30,7 @@ #include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() #endif -/* #define DEBUG_MOUSE */ +// #define DEBUG_MOUSE #define WARP_EMULATION_THRESHOLD_NS SDL_MS_TO_NS(30) @@ -40,12 +40,12 @@ typedef struct SDL_MouseInstance char *name; } SDL_MouseInstance; -/* The mouse state */ +// The mouse state static SDL_Mouse SDL_mouse; static int SDL_mouse_count; static SDL_MouseInstance *SDL_mice; -/* for mapping mouse events to touch */ +// for mapping mouse events to touch static SDL_bool track_mouse_down = SDL_FALSE; static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y); @@ -83,7 +83,7 @@ static void SDLCALL SDL_MouseDoubleClickRadiusChanged(void *userdata, const char 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 } } @@ -202,7 +202,7 @@ static void SDLCALL SDL_MouseRelativeCursorVisibleChanged(void *userdata, const mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, SDL_FALSE); } -/* Public functions */ +// Public functions int SDL_PreInitMouse(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -250,7 +250,7 @@ int SDL_PreInitMouse(void) SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL, SDL_MouseRelativeClipIntervalChanged, mouse); - mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */ + mouse->was_touch_mouse_events = SDL_FALSE; // no touch to mouse movement event pending mouse->cursor_shown = SDL_TRUE; @@ -276,7 +276,7 @@ void SDL_PostInitMouse(void) SDL_bool SDL_IsMouse(Uint16 vendor, Uint16 product) { - /* Eventually we'll have a blacklist of devices that enumerate as mice but aren't really */ + // Eventually we'll have a blacklist of devices that enumerate as mice but aren't really return SDL_TRUE; } @@ -294,7 +294,7 @@ void SDL_AddMouse(SDL_MouseID mouseID, const char *name, SDL_bool send_event) { int mouse_index = SDL_GetMouseIndex(mouseID); if (mouse_index >= 0) { - /* We already know about this mouse */ + // We already know about this mouse return; } @@ -323,7 +323,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, SDL_bool send_event) { int mouse_index = SDL_GetMouseIndex(mouseID); if (mouse_index < 0) { - /* We don't know about this mouse */ + // We don't know about this mouse return; } @@ -334,7 +334,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, SDL_bool send_event) } --SDL_mouse_count; - /* Remove any mouse input sources for this mouseID */ + // Remove any mouse input sources for this mouseID SDL_Mouse *mouse = SDL_GetMouse(); for (int i = 0; i < mouse->num_sources; ++i) { SDL_MouseInputSource *source = &mouse->sources[i]; @@ -491,7 +491,7 @@ void SDL_ResetMouse(void) } SDL_assert(SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_FALSE) == 0); } -#endif /* 0 */ +#endif // 0 void SDL_SetMouseFocus(SDL_Window *window) { @@ -508,12 +508,12 @@ void SDL_SetMouseFocus(SDL_Window *window) */ #if 0 if (mouse->focus && !window) { - /* We won't get anymore mouse messages, so reset mouse state */ + // We won't get anymore mouse messages, so reset mouse state SDL_ResetMouse(); } #endif - /* See if the current window has lost focus */ + // See if the current window has lost focus if (mouse->focus) { SDL_SendWindowEvent(mouse->focus, SDL_EVENT_WINDOW_MOUSE_LEAVE, 0, 0); } @@ -525,7 +525,7 @@ void SDL_SetMouseFocus(SDL_Window *window) SDL_SendWindowEvent(mouse->focus, SDL_EVENT_WINDOW_MOUSE_ENTER, 0, 0); } - /* Update cursor visibility */ + // Update cursor visibility SDL_SetCursor(NULL); } @@ -543,7 +543,7 @@ SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y) return SDL_TRUE; } -/* Check to see if we need to synthesize focus events */ +// Check to see if we need to synthesize focus events static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint32 buttonstate, SDL_bool send_mouse_motion) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -593,7 +593,7 @@ static float CalculateSystemScale(SDL_Mouse *mouse, SDL_Window *window, const fl float *v = mouse->system_scale_values; float speed, coef, scale; - /* If we're using a single scale value, return that */ + // If we're using a single scale value, return that if (n == 1) { scale = v[0]; } else { @@ -614,7 +614,7 @@ static float CalculateSystemScale(SDL_Mouse *mouse, SDL_Window *window, const fl } #ifdef SDL_PLATFORM_WIN32 { - /* On Windows the mouse speed is affected by the content scale */ + // On Windows the mouse speed is affected by the content scale SDL_VideoDisplay *display; if (window) { @@ -630,7 +630,7 @@ static float CalculateSystemScale(SDL_Mouse *mouse, SDL_Window *window, const fl return scale; } -/* You can set either a single scale, or a set of {speed, scale} values in ascending order */ +// 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) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -638,7 +638,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values) if (num_values == mouse->num_system_scale_values && SDL_memcmp(values, mouse->system_scale_values, num_values * sizeof(*values)) == 0) { - /* Nothing has changed */ + // Nothing has changed return 0; } @@ -647,7 +647,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values) } if (num_values > 1) { - /* Validate the values */ + // Validate the values int i; if (num_values < 4 || (num_values % 2) != 0) { @@ -740,11 +740,11 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ float yrel = 0.0f; if ((!mouse->relative_mode || mouse->warp_emulation_active) && mouseID != SDL_TOUCH_MOUSEID) { - /* We're not in relative mode, so all mouse events are global mouse events */ + // We're not in relative mode, so all mouse events are global mouse events mouseID = SDL_GLOBAL_MOUSE_ID; } - /* SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events */ + // SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events if (mouse->mouse_touch_events) { if (mouseID != SDL_TOUCH_MOUSEID && !relative && track_mouse_down) { if (window) { @@ -755,7 +755,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ } } - /* SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer */ + // SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer if (!mouse->touch_mouse_events && mouseID == SDL_TOUCH_MOUSEID) { return 0; } @@ -800,21 +800,21 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ } } - if (mouse->has_position && xrel == 0.0f && yrel == 0.0f) { /* Drop events that don't change state */ + if (mouse->has_position && xrel == 0.0f && yrel == 0.0f) { // Drop events that don't change state #ifdef DEBUG_MOUSE SDL_Log("Mouse event didn't change state - dropped!\n"); #endif return 0; } - /* Ignore relative motion positioning the first touch */ + // Ignore relative motion positioning the first touch if (mouseID == SDL_TOUCH_MOUSEID && !SDL_GetMouseButtonState(mouse, mouseID, SDL_TRUE)) { xrel = 0.0f; yrel = 0.0f; } if (mouse->has_position) { - /* Update internal mouse coordinates */ + // Update internal mouse coordinates if (!mouse->relative_mode) { mouse->x = x; mouse->y = y; @@ -832,13 +832,13 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ mouse->xdelta += xrel; mouse->ydelta += yrel; - /* Move the mouse cursor, if needed */ + // Move the mouse cursor, if needed if (mouse->cursor_shown && !mouse->relative_mode && mouse->MoveCursor && mouse->cur_cursor) { mouse->MoveCursor(mouse->cur_cursor); } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_MOUSE_MOTION)) { SDL_Event event; @@ -846,7 +846,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ event.common.timestamp = timestamp; 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 */ + // Set us pending (or clear during a normal mouse movement event) as having triggered mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID); event.motion.state = SDL_GetMouseButtonState(mouse, mouseID, SDL_TRUE); event.motion.x = mouse->x; @@ -859,7 +859,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ mouse->last_x = mouse->x; mouse->last_y = mouse->y; } else { - /* Use unclamped values if we're getting events outside the window */ + // Use unclamped values if we're getting events outside the window mouse->last_x = x; mouse->last_y = y; } @@ -934,7 +934,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ SDL_MouseInputSource *source; if (!mouse->relative_mode && mouseID != SDL_TOUCH_MOUSEID) { - /* We're not in relative mode, so all mouse events are global mouse events */ + // We're not in relative mode, so all mouse events are global mouse events mouseID = SDL_GLOBAL_MOUSE_ID; } @@ -944,7 +944,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ } buttonstate = source->buttonstate; - /* SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events */ + // SDL_HINT_MOUSE_TOUCH_EVENTS: controlling whether mouse events should generate synthetic touch events if (mouse->mouse_touch_events) { if (mouseID != SDL_TOUCH_MOUSEID && button == SDL_BUTTON_LEFT) { if (state == SDL_PRESSED) { @@ -960,14 +960,14 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ } } - /* SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer */ + // SDL_HINT_TOUCH_MOUSE_EVENTS: if not set, discard synthetic mouse events coming from platform layer if (mouse->touch_mouse_events == 0) { if (mouseID == SDL_TOUCH_MOUSEID) { return 0; } } - /* Figure out which event to perform */ + // Figure out which event to perform switch (state) { case SDL_PRESSED: type = SDL_EVENT_MOUSE_BUTTON_DOWN; @@ -978,17 +978,17 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ buttonstate &= ~SDL_BUTTON(button); break; default: - /* Invalid state -- bail */ + // Invalid state -- bail return 0; } - /* We do this after calculating buttonstate so button presses gain focus */ + // We do this after calculating buttonstate so button presses gain focus if (window && state == SDL_PRESSED) { SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, SDL_TRUE); } if (buttonstate == source->buttonstate) { - /* Ignore this event, no state change */ + // Ignore this event, no state change return 0; } source->buttonstate = buttonstate; @@ -1017,7 +1017,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ } } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(type)) { SDL_Event event; @@ -1033,12 +1033,12 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ posted = (SDL_PushEvent(&event) > 0); } - /* We do this after dispatching event so button releases can lose focus */ + // We do this after dispatching event so button releases can lose focus if (window && state == SDL_RELEASED) { SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, SDL_TRUE); } - /* Automatically capture the mouse while buttons are pressed */ + // Automatically capture the mouse while buttons are pressed if (mouse->auto_capture) { SDL_UpdateMouseCapture(SDL_FALSE); } @@ -1070,7 +1070,7 @@ int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID return 0; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL)) { SDL_Event event; @@ -1209,7 +1209,7 @@ SDL_MouseButtonFlags SDL_GetGlobalMouseState(float *x, float *y) if (mouse->GetGlobalMouseState) { float tmpx, tmpy; - /* make sure these are never NULL for the backend implementations... */ + // make sure these are never NULL for the backend implementations... if (!x) { x = &tmpx; } @@ -1241,7 +1241,7 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool return; } - /* Ignore the previous position when we warp */ + // Ignore the previous position when we warp mouse->last_x = x; mouse->last_y = y; mouse->has_position = SDL_FALSE; @@ -1296,7 +1296,7 @@ static void SDL_MaybeEnableWarpEmulation(SDL_Window *window, float x, float y) if (x >= SDL_floorf(cx) && x <= SDL_ceilf(cx) && y >= SDL_floorf(cy) && y <= SDL_ceilf(cy)) { - /* Require two consecutive warps to the center within a certain timespan to enter warp emulation mode. */ + // Require two consecutive warps to the center within a certain timespan to enter warp emulation mode. const Uint64 now = SDL_GetTicksNS(); if (now - mouse->last_center_warp_time_ns < WARP_EMULATION_THRESHOLD_NS) { if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) { @@ -1335,7 +1335,7 @@ int SDL_WarpMouseGlobal(float x, float y) static SDL_bool SDL_ShouldUseRelativeModeWarp(SDL_Mouse *mouse) { if (!mouse->WarpMouse) { - /* Need this functionality for relative mode warp implementation */ + // Need this functionality for relative mode warp implementation return SDL_FALSE; } @@ -1348,7 +1348,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) SDL_Window *focusWindow = SDL_GetKeyboardFocus(); if (!enabled) { - /* If warps were being emulated, reset the flag. */ + // If warps were being emulated, reset the flag. mouse->warp_emulation_active = SDL_FALSE; } @@ -1356,14 +1356,14 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) return 0; } - /* Set the relative mode */ + // Set the relative mode if (!enabled && mouse->relative_mode_warp) { mouse->relative_mode_warp = SDL_FALSE; } else if (enabled && SDL_ShouldUseRelativeModeWarp(mouse)) { mouse->relative_mode_warp = SDL_TRUE; } else if (!mouse->SetRelativeMouseMode || mouse->SetRelativeMouseMode(enabled) < 0) { if (enabled) { - /* Fall back to warp mode if native relative mode failed */ + // Fall back to warp mode if native relative mode failed if (!mouse->WarpMouse) { return SDL_SetError("No relative mode implementation available"); } @@ -1373,7 +1373,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) mouse->relative_mode = enabled; if (enabled) { - /* Update cursor visibility before we potentially warp the mouse */ + // Update cursor visibility before we potentially warp the mouse SDL_SetCursor(NULL); } @@ -1390,7 +1390,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) if (focusWindow) { SDL_UpdateWindowGrab(focusWindow); - /* Put the cursor back to where the application expects it */ + // Put the cursor back to where the application expects it if (!enabled) { SDL_PerformWarpMouseInWindow(focusWindow, mouse->x, mouse->y, SDL_TRUE); } @@ -1399,11 +1399,11 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) } if (!enabled) { - /* Update cursor visibility after we restore the mouse position */ + // Update cursor visibility after we restore the mouse position SDL_SetCursor(NULL); } - /* Flush pending mouse motion - ideally we would pump events, but that's not always safe */ + // Flush pending mouse motion - ideally we would pump events, but that's not always safe SDL_FlushEvent(SDL_EVENT_MOUSE_MOTION); return 0; @@ -1463,7 +1463,7 @@ int SDL_UpdateMouseCapture(SDL_bool force_release) mouse->capture_window = capture_window; if (mouse->CaptureMouse(capture_window) < 0) { - /* CaptureMouse() will have set an error, just restore the state */ + // CaptureMouse() will have set an error, just restore the state if (previous_capture) { previous_capture->flags |= SDL_WINDOW_MOUSE_CAPTURE; } @@ -1495,7 +1495,7 @@ int SDL_CaptureMouse(SDL_bool enabled) if (!SDL_OnVideoThread()) { return SDL_SetError("SDL_CaptureMouse() must be called on the main thread"); } -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) if (enabled && SDL_GetKeyboardFocus() == NULL) { return SDL_SetError("No window has focus"); @@ -1516,16 +1516,16 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, const Uint32 white = 0xFFFFFFFF; const Uint32 transparent = 0x00000000; #if defined(SDL_PLATFORM_WIN32) - /* Only Windows backend supports inverted pixels in mono cursors. */ + // Only Windows backend supports inverted pixels in mono cursors. const Uint32 inverted = 0x00FFFFFF; #else const Uint32 inverted = 0xFF000000; -#endif /* defined(SDL_PLATFORM_WIN32) */ +#endif // defined(SDL_PLATFORM_WIN32) - /* Make sure the width is a multiple of 8 */ + // Make sure the width is a multiple of 8 w = ((w + 7) & ~7); - /* Create the surface from a bitmap */ + // Create the surface from a bitmap surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888); if (!surface) { return NULL; @@ -1565,7 +1565,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) return NULL; } - /* Sanity check the hot spot */ + // Sanity check the hot spot if ((hot_x < 0) || (hot_y < 0) || (hot_x >= surface->w) || (hot_y >= surface->h)) { SDL_SetError("Cursor hot spot doesn't lie within cursor"); @@ -1622,14 +1622,14 @@ int SDL_SetCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - /* Return immediately if setting the cursor to the currently set one (fixes #7151) */ + // Return immediately if setting the cursor to the currently set one (fixes #7151) if (cursor == mouse->cur_cursor) { return 0; } - /* Set the new cursor */ + // Set the new cursor if (cursor) { - /* Make sure the cursor is still valid for this mouse */ + // Make sure the cursor is still valid for this mouse if (cursor != mouse->def_cursor) { SDL_Cursor *found; for (found = mouse->cursors; found; found = found->next) { diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 3b8d89a432..064f6ea2b5 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -23,10 +23,10 @@ #ifndef SDL_mouse_c_h_ #define SDL_mouse_c_h_ -/* Mouse events not associated with a specific input device */ +// Mouse events not associated with a specific input device #define SDL_GLOBAL_MOUSE_ID 0 -/* The default mouse input device, for platforms that don't have multiple mice */ +// The default mouse input device, for platforms that don't have multiple mice #define SDL_DEFAULT_MOUSE_ID 1 typedef struct SDL_CursorData SDL_CursorData; @@ -52,43 +52,43 @@ typedef struct typedef struct { - /* Create a cursor from a surface */ + // Create a cursor from a surface SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y); - /* Create a system cursor */ + // Create a system cursor SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id); - /* Show the specified cursor, or hide if cursor is NULL */ + // Show the specified cursor, or hide if cursor is NULL int (*ShowCursor)(SDL_Cursor *cursor); - /* This is called when a mouse motion event occurs */ + // This is called when a mouse motion event occurs int (*MoveCursor)(SDL_Cursor *cursor); - /* Free a window manager cursor */ + // Free a window manager cursor void (*FreeCursor)(SDL_Cursor *cursor); - /* Warp the mouse to (x,y) within a window */ + // Warp the mouse to (x,y) within a window int (*WarpMouse)(SDL_Window *window, float x, float y); - /* Warp the mouse to (x,y) in screen space */ + // Warp the mouse to (x,y) in screen space int (*WarpMouseGlobal)(float x, float y); - /* Set relative mode */ + // Set relative mode int (*SetRelativeMouseMode)(SDL_bool enabled); - /* Set mouse capture */ + // Set mouse capture int (*CaptureMouse)(SDL_Window *window); - /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */ + // Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. SDL_MouseButtonFlags (*GetGlobalMouseState)(float *x, float *y); - /* Data common to all mice */ + // Data common to all mice SDL_Window *focus; float x; float y; float xdelta; float ydelta; - float last_x, last_y; /* the last reported x and y coordinates */ + float last_x, last_y; // the last reported x and y coordinates SDL_bool has_position; SDL_bool relative_mode; SDL_bool relative_mode_warp; @@ -110,7 +110,7 @@ typedef struct int double_click_radius; SDL_bool touch_mouse_events; SDL_bool mouse_touch_events; - SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */ + SDL_bool was_touch_mouse_events; // Was a touch-mouse event pending? #ifdef SDL_PLATFORM_VITA Uint8 vita_touch_mouse_device; #endif @@ -118,11 +118,11 @@ typedef struct SDL_bool capture_desired; SDL_Window *capture_window; - /* Data for input source state */ + // Data for input source state int num_sources; SDL_MouseInputSource *sources; - /* Data for double-click tracking */ + // Data for double-click tracking int num_clickstates; SDL_MouseClickState *clickstate; @@ -131,70 +131,70 @@ typedef struct SDL_Cursor *cur_cursor; SDL_bool cursor_shown; - /* Driver-dependent data. */ + // Driver-dependent data. void *internal; } SDL_Mouse; -/* Initialize the mouse subsystem, called before the main video driver is initialized */ +// Initialize the mouse subsystem, called before the main video driver is initialized extern int SDL_PreInitMouse(void); -/* Finish initializing the mouse subsystem, called after the main video driver was initialized */ +// Finish initializing the mouse subsystem, called after the main video driver was initialized extern void SDL_PostInitMouse(void); -/* Return whether a device is actually a mouse */ +// Return whether a device is actually a mouse extern SDL_bool SDL_IsMouse(Uint16 vendor, Uint16 product); -/* A mouse has been added to the system */ +// A mouse has been added to the system extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, SDL_bool send_event); -/* A mouse has been removed from the system */ +// A mouse has been removed from the system extern void SDL_RemoveMouse(SDL_MouseID mouseID, SDL_bool send_event); -/* Get the mouse state structure */ +// Get the mouse state structure extern SDL_Mouse *SDL_GetMouse(void); -/* Set the default mouse cursor */ +// Set the default mouse cursor extern void SDL_SetDefaultCursor(SDL_Cursor *cursor); -/* Set the mouse focus window */ +// Set the mouse focus window extern void SDL_SetMouseFocus(SDL_Window *window); -/* Update the mouse capture window */ +// Update the mouse capture window extern int SDL_UpdateMouseCapture(SDL_bool force_release); -/* You can set either a single scale, or a set of {speed, scale} values in sorted order */ +// You can set either a single scale, or a set of {speed, scale} values in sorted order extern int SDL_SetMouseSystemScale(int num_values, const float *values); -/* Send a mouse motion event */ +// Send a mouse motion event extern int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y); -/* Send a mouse button event */ +// Send a mouse button event extern int SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button); -/* Send a mouse button event with a click count */ +// Send a mouse button event with a click count extern int SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks); -/* Send a mouse wheel event */ +// Send a mouse wheel event extern int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); -/* Warp the mouse within the window, potentially overriding relative mode */ +// Warp the mouse within the window, potentially overriding relative mode extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool ignore_relative_mode); -/* Relative mouse mode */ +// Relative mouse mode extern int SDL_SetRelativeMouseMode(SDL_bool enabled); extern SDL_bool SDL_GetRelativeMouseMode(void); extern void SDL_UpdateRelativeMouseMode(void); extern void SDL_DisableMouseWarpEmulation(void); -/* TODO RECONNECT: Set mouse state to "zero" */ +// TODO RECONNECT: Set mouse state to "zero" #if 0 extern void SDL_ResetMouse(void); -#endif /* 0 */ +#endif // 0 -/* Check if mouse position is within window or captured by window */ +// Check if mouse position is within window or captured by window extern SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y); -/* Shutdown the mouse subsystem */ +// Shutdown the mouse subsystem extern void SDL_QuitMouse(void); -#endif /* SDL_mouse_c_h_ */ +#endif // SDL_mouse_c_h_ diff --git a/src/events/SDL_pen.c b/src/events/SDL_pen.c index df5860fc36..15d7b41622 100644 --- a/src/events/SDL_pen.c +++ b/src/events/SDL_pen.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Pressure-sensitive pen handling code for SDL */ +// Pressure-sensitive pen handling code for SDL #include "../SDL_hints_c.h" #include "SDL_events_c.h" diff --git a/src/events/SDL_pen_c.h b/src/events/SDL_pen_c.h index 366176a985..d405d13f68 100644 --- a/src/events/SDL_pen_c.h +++ b/src/events/SDL_pen_c.h @@ -94,6 +94,6 @@ extern int SDL_InitPen(void); // Higher-level SDL video subsystem code calls this when shutting down. Backends shouldn't. extern void SDL_QuitPen(void); -#endif /* SDL_pen_c_h_ */ +#endif // SDL_pen_c_h_ -/* vi: set ts=4 sw=4 expandtab: */ +// vi: set ts=4 sw=4 expandtab: diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c index 7c03b39146..30f73243c8 100644 --- a/src/events/SDL_quit.c +++ b/src/events/SDL_quit.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* General quit handling code for SDL */ +// General quit handling code for SDL #ifdef HAVE_SIGNAL_H #include @@ -46,11 +46,11 @@ static SDL_bool send_foregrounding_pending = SDL_FALSE; static void SDL_HandleSIG(int sig) { - /* Reset the signal handler */ + // Reset the signal handler (void)signal(sig, SDL_HandleSIG); - /* Send a quit event next time the event loop pumps. */ - /* We can't send it in signal handler; SDL_malloc() might be interrupted! */ + // Send a quit event next time the event loop pumps. + // We can't send it in signal handler; SDL_malloc() might be interrupted! if ((sig == SIGINT) || (sig == SIGTERM)) { send_quit_pending = SDL_TRUE; } @@ -104,14 +104,14 @@ static void SDL_EventSignal_Quit(const int sig) if (ohandler != SDL_HandleSIG) { signal(sig, ohandler); } -#endif /* HAVE_SIGNAL_H */ +#endif // HAVE_SIGNAL_H } -/* Public functions */ +// Public functions 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. */ + // 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); @@ -123,7 +123,7 @@ static int SDL_QuitInit_Internal(void) SDL_EventSignal_Init(SDL_FOREGROUNDING_SIGNAL); #endif - /* That's it! */ + // That's it! return 0; } @@ -185,7 +185,7 @@ void SDL_SendPendingSignalEvents(void) #endif } -/* This function returns 1 if it's okay to close the application window */ +// This function returns 1 if it's okay to close the application window int SDL_SendQuit(void) { #ifdef HAVE_SIGNAL_SUPPORT diff --git a/src/events/SDL_scancode_tables.c b/src/events/SDL_scancode_tables.c index c09d9797e2..03c5368862 100644 --- a/src/events/SDL_scancode_tables.c +++ b/src/events/SDL_scancode_tables.c @@ -68,4 +68,4 @@ SDL_Scancode SDL_GetScancodeFromTable(SDL_ScancodeTable table, int keycode) return scancode; } -#endif /* SDL_INPUT_LINUXEV || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_INPUT_LINUXEV || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11 diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 4206f6383a..87c1670b14 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* General touch handling code for SDL */ +// General touch handling code for SDL #include "SDL_events_c.h" #include "../video/SDL_sysvideo.h" @@ -28,7 +28,7 @@ static int SDL_num_touch = 0; static SDL_Touch **SDL_touchDevices = NULL; -/* for mapping touch events to mice */ +// for mapping touch events to mice #define SYNTHESIZE_TOUCH_TO_MOUSE 1 @@ -38,7 +38,7 @@ static SDL_FingerID track_fingerid; static SDL_TouchID track_touchid; #endif -/* Public functions */ +// Public functions int SDL_InitTouch(void) { return 0; @@ -179,7 +179,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name return index; } - /* Add the touch to the list of touch */ + // Add the touch to the list of touch touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices, (SDL_num_touch + 1) * sizeof(*touchDevices)); if (!touchDevices) { @@ -194,10 +194,10 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name return -1; } - /* Added touch to list */ + // Added touch to list ++SDL_num_touch; - /* we're setting the touch properties */ + // we're setting the touch properties SDL_touchDevices[index]->id = touchID; SDL_touchDevices[index]->type = type; SDL_touchDevices[index]->num_fingers = 0; @@ -269,15 +269,15 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W mouse = SDL_GetMouse(); #if SYNTHESIZE_TOUCH_TO_MOUSE - /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */ - /* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */ + // SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events + // SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only { #ifdef SDL_PLATFORM_VITA if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2))) { #else if (mouse->touch_mouse_events) { #endif - /* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */ + // FIXME: maybe we should only restrict to a few SDL_TouchDeviceType if (id != SDL_MOUSE_TOUCHID) { if (window) { if (down) { @@ -321,7 +321,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W } #endif - /* SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer */ + // SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer if (mouse->mouse_touch_events == 0) { if (id == SDL_MOUSE_TOUCHID) { return 0; @@ -357,7 +357,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W } } else { if (!finger) { - /* This finger is already up */ + // This finger is already up return 0; } @@ -368,7 +368,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W event.common.timestamp = timestamp; event.tfinger.touchID = id; event.tfinger.fingerID = fingerid; - /* I don't trust the coordinates passed on fingerUp */ + // I don't trust the coordinates passed on fingerUp event.tfinger.x = finger->x; event.tfinger.y = finger->y; event.tfinger.dx = 0; @@ -400,7 +400,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, mouse = SDL_GetMouse(); #if SYNTHESIZE_TOUCH_TO_MOUSE - /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */ + // SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events { if (mouse->touch_mouse_events) { if (id != SDL_MOUSE_TOUCHID) { @@ -428,7 +428,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, } #endif - /* SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer */ + // SDL_HINT_MOUSE_TOUCH_EVENTS: if not set, discard synthetic touch events coming from platform layer if (mouse->mouse_touch_events == 0) { if (id == SDL_MOUSE_TOUCHID) { return 0; @@ -444,7 +444,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, yrel = y - finger->y; prel = pressure - finger->pressure; - /* Drop events that don't change state */ + // Drop events that don't change state if (xrel == 0.0f && yrel == 0.0f && prel == 0.0f) { #if 0 printf("Touch event didn't change state - dropped!\n"); @@ -452,12 +452,12 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, return 0; } - /* Update internal touch coordinates */ + // Update internal touch coordinates finger->x = x; finger->y = y; finger->pressure = pressure; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_FINGER_MOTION)) { SDL_Event event; @@ -482,7 +482,7 @@ void SDL_DelTouch(SDL_TouchID id) SDL_Touch *touch; if (SDL_num_touch == 0) { - /* We've already cleaned up, we won't find this device */ + // We've already cleaned up, we won't find this device return; } diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h index dda6adc14d..87748f18c2 100644 --- a/src/events/SDL_touch_c.h +++ b/src/events/SDL_touch_c.h @@ -33,28 +33,28 @@ typedef struct SDL_Touch char *name; } SDL_Touch; -/* Initialize the touch subsystem */ +// Initialize the touch subsystem extern int SDL_InitTouch(void); -/* Returns SDL_TRUE if _any_ connected touch devices are known to SDL */ +// Returns SDL_TRUE if _any_ connected touch devices are known to SDL extern SDL_bool SDL_TouchDevicesAvailable(void); -/* Add a touch, returning the index of the touch, or -1 if there was an error. */ +// Add a touch, returning the index of the touch, or -1 if there was an error. extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name); -/* Get the touch with a given id */ +// Get the touch with a given id extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); -/* Send a touch down/up event for a touch */ +// Send a touch down/up event for a touch extern int SDL_SendTouch(Uint64 timestamp, 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 */ +// Send a touch motion event for a touch extern int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure); -/* Remove a touch */ +// Remove a touch extern void SDL_DelTouch(SDL_TouchID id); -/* Shutdown the touch subsystem */ +// Shutdown the touch subsystem extern void SDL_QuitTouch(void); -#endif /* SDL_touch_c_h_ */ +#endif // SDL_touch_c_h_ diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 529be7f603..58b96ea356 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Window event handling code for SDL */ +// Window event handling code for SDL #include "SDL_events_c.h" #include "SDL_mouse_c.h" @@ -32,7 +32,7 @@ static SDL_bool SDLCALL RemoveSupercededWindowEvents(void *userdata, SDL_Event * if (event->type == new_event->type && event->window.windowID == new_event->window.windowID) { - /* We're about to post a new move event, drop the old one */ + // We're about to post a new move event, drop the old one return SDL_FALSE; } return SDL_TRUE; @@ -181,7 +181,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, break; } - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(windowevent)) { SDL_Event event; @@ -191,7 +191,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, event.window.data2 = data2; event.window.windowID = window->id; - /* Fixes queue overflow with move/resize events that aren't processed */ + // Fixes queue overflow with move/resize events that aren't processed if (windowevent == SDL_EVENT_WINDOW_MOVED || windowevent == SDL_EVENT_WINDOW_RESIZED || windowevent == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED || @@ -258,7 +258,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, if (toplevel_count <= 1) { if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) { - SDL_SendQuit(); /* This is the last toplevel window in the list so send the SDL_EVENT_QUIT event */ + SDL_SendQuit(); // This is the last toplevel window in the list so send the SDL_EVENT_QUIT event } } } diff --git a/src/events/SDL_windowevents_c.h b/src/events/SDL_windowevents_c.h index 93e9509344..715a947200 100644 --- a/src/events/SDL_windowevents_c.h +++ b/src/events/SDL_windowevents_c.h @@ -26,4 +26,4 @@ extern int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data1, int data2); -#endif /* SDL_windowevents_c_h_ */ +#endif // SDL_windowevents_c_h_ diff --git a/src/events/default_cursor.h b/src/events/default_cursor.h index 4e30aff2a9..5068f06929 100644 --- a/src/events/default_cursor.h +++ b/src/events/default_cursor.h @@ -27,7 +27,7 @@ #define DEFAULT_CHOTX 0 #define DEFAULT_CHOTY 0 -/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */ +// Added a real MacOS cursor, at the request of Luc-Olivier de Charrière #define USE_MACOS_CURSOR #ifdef USE_MACOS_CURSOR @@ -110,4 +110,4 @@ static const unsigned char default_cmask[] = { 0x03, 0x00 }; -#endif /* USE_MACOS_CURSOR */ +#endif // USE_MACOS_CURSOR diff --git a/src/events/scancodes_darwin.h b/src/events/scancodes_darwin.h index c38ed60ef1..0006070d24 100644 --- a/src/events/scancodes_darwin.h +++ b/src/events/scancodes_darwin.h @@ -25,7 +25,7 @@ - Apple USB keyboard driver source - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static const SDL_Scancode darwin_scancode_table[] = { /* 0 */ SDL_SCANCODE_A, /* 1 */ SDL_SCANCODE_S, @@ -37,7 +37,7 @@ static const SDL_Scancode darwin_scancode_table[] = { /* 7 */ SDL_SCANCODE_X, /* 8 */ SDL_SCANCODE_C, /* 9 */ SDL_SCANCODE_V, - /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */ + /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, // SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) /* 11 */ SDL_SCANCODE_B, /* 12 */ SDL_SCANCODE_Q, /* 13 */ SDL_SCANCODE_W, @@ -77,9 +77,9 @@ static const SDL_Scancode darwin_scancode_table[] = { /* 47 */ SDL_SCANCODE_PERIOD, /* 48 */ SDL_SCANCODE_TAB, /* 49 */ SDL_SCANCODE_SPACE, - /* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */ + /* 50 */ SDL_SCANCODE_GRAVE, // SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) /* 51 */ SDL_SCANCODE_BACKSPACE, - /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */ + /* 52 */ SDL_SCANCODE_KP_ENTER, // keyboard enter on portables /* 53 */ SDL_SCANCODE_ESCAPE, /* 54 */ SDL_SCANCODE_RGUI, /* 55 */ SDL_SCANCODE_LGUI, @@ -90,21 +90,21 @@ static const SDL_Scancode darwin_scancode_table[] = { /* 60 */ SDL_SCANCODE_RSHIFT, /* 61 */ SDL_SCANCODE_RALT, /* 62 */ SDL_SCANCODE_RCTRL, - /* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */ + /* 63 */ SDL_SCANCODE_RGUI, // fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R /* 64 */ SDL_SCANCODE_F17, /* 65 */ SDL_SCANCODE_KP_PERIOD, - /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 66 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 67 */ SDL_SCANCODE_KP_MULTIPLY, - /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 68 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 69 */ SDL_SCANCODE_KP_PLUS, - /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 70 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 72 */ SDL_SCANCODE_VOLUMEUP, /* 73 */ SDL_SCANCODE_VOLUMEDOWN, /* 74 */ SDL_SCANCODE_MUTE, /* 75 */ SDL_SCANCODE_KP_DIVIDE, - /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */ - /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 76 */ SDL_SCANCODE_KP_ENTER, // keypad enter on external keyboards, fn-return on portables + /* 77 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 78 */ SDL_SCANCODE_KP_MINUS, /* 79 */ SDL_SCANCODE_F18, /* 80 */ SDL_SCANCODE_F19, @@ -117,31 +117,31 @@ static const SDL_Scancode darwin_scancode_table[] = { /* 87 */ SDL_SCANCODE_KP_5, /* 88 */ SDL_SCANCODE_KP_6, /* 89 */ SDL_SCANCODE_KP_7, - /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 90 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 91 */ SDL_SCANCODE_KP_8, /* 92 */ SDL_SCANCODE_KP_9, - /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */ - /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */ - /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */ + /* 93 */ SDL_SCANCODE_INTERNATIONAL3, // Cosmo_USB2ADB.c says "Yen (JIS)" + /* 94 */ SDL_SCANCODE_INTERNATIONAL1, // Cosmo_USB2ADB.c says "Ro (JIS)" + /* 95 */ SDL_SCANCODE_KP_COMMA, // Cosmo_USB2ADB.c says ", JIS only" /* 96 */ SDL_SCANCODE_F5, /* 97 */ SDL_SCANCODE_F6, /* 98 */ SDL_SCANCODE_F7, /* 99 */ SDL_SCANCODE_F3, /* 100 */ SDL_SCANCODE_F8, /* 101 */ SDL_SCANCODE_F9, - /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */ + /* 102 */ SDL_SCANCODE_LANG2, // Cosmo_USB2ADB.c says "Eisu" /* 103 */ SDL_SCANCODE_F11, - /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */ - /* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */ + /* 104 */ SDL_SCANCODE_LANG1, // Cosmo_USB2ADB.c says "Kana" + /* 105 */ SDL_SCANCODE_PRINTSCREEN, // On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. /* 106 */ SDL_SCANCODE_F16, - /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */ - /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ + /* 107 */ SDL_SCANCODE_SCROLLLOCK, // F14/scroll lock, see comment about F13/print screen above + /* 108 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) /* 109 */ SDL_SCANCODE_F10, - /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */ + /* 110 */ SDL_SCANCODE_APPLICATION, // windows contextual menu key, fn-enter on portables /* 111 */ SDL_SCANCODE_F12, - /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ - /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */ - /* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */ + /* 112 */ SDL_SCANCODE_UNKNOWN, // unknown (unused?) + /* 113 */ SDL_SCANCODE_PAUSE, // F15/pause, see comment about F13/print screen above + /* 114 */ SDL_SCANCODE_INSERT, // the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards /* 115 */ SDL_SCANCODE_HOME, /* 116 */ SDL_SCANCODE_PAGEUP, /* 117 */ SDL_SCANCODE_DELETE, @@ -156,4 +156,4 @@ static const SDL_Scancode darwin_scancode_table[] = { /* 126 */ SDL_SCANCODE_UP, /* 127 */ SDL_SCANCODE_POWER }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/events/scancodes_linux.h b/src/events/scancodes_linux.h index 9c8e2063ad..e90bbf1cbe 100644 --- a/src/events/scancodes_linux.h +++ b/src/events/scancodes_linux.h @@ -24,257 +24,257 @@ Sources: - Linux kernel source input.h */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static SDL_Scancode const linux_scancode_table[] = { - /* 0, 0x000 */ SDL_SCANCODE_UNKNOWN, /* KEY_RESERVED */ - /* 1, 0x001 */ SDL_SCANCODE_ESCAPE, /* KEY_ESC */ - /* 2, 0x002 */ SDL_SCANCODE_1, /* KEY_1 */ - /* 3, 0x003 */ SDL_SCANCODE_2, /* KEY_2 */ - /* 4, 0x004 */ SDL_SCANCODE_3, /* KEY_3 */ - /* 5, 0x005 */ SDL_SCANCODE_4, /* KEY_4 */ - /* 6, 0x006 */ SDL_SCANCODE_5, /* KEY_5 */ - /* 7, 0x007 */ SDL_SCANCODE_6, /* KEY_6 */ - /* 8, 0x008 */ SDL_SCANCODE_7, /* KEY_7 */ - /* 9, 0x009 */ SDL_SCANCODE_8, /* KEY_8 */ - /* 10, 0x00a */ SDL_SCANCODE_9, /* KEY_9 */ - /* 11, 0x00b */ SDL_SCANCODE_0, /* KEY_0 */ - /* 12, 0x00c */ SDL_SCANCODE_MINUS, /* KEY_MINUS */ - /* 13, 0x00d */ SDL_SCANCODE_EQUALS, /* KEY_EQUAL */ - /* 14, 0x00e */ SDL_SCANCODE_BACKSPACE, /* KEY_BACKSPACE */ - /* 15, 0x00f */ SDL_SCANCODE_TAB, /* KEY_TAB */ - /* 16, 0x010 */ SDL_SCANCODE_Q, /* KEY_Q */ - /* 17, 0x011 */ SDL_SCANCODE_W, /* KEY_W */ - /* 18, 0x012 */ SDL_SCANCODE_E, /* KEY_E */ - /* 19, 0x013 */ SDL_SCANCODE_R, /* KEY_R */ - /* 20, 0x014 */ SDL_SCANCODE_T, /* KEY_T */ - /* 21, 0x015 */ SDL_SCANCODE_Y, /* KEY_Y */ - /* 22, 0x016 */ SDL_SCANCODE_U, /* KEY_U */ - /* 23, 0x017 */ SDL_SCANCODE_I, /* KEY_I */ - /* 24, 0x018 */ SDL_SCANCODE_O, /* KEY_O */ - /* 25, 0x019 */ SDL_SCANCODE_P, /* KEY_P */ - /* 26, 0x01a */ SDL_SCANCODE_LEFTBRACKET, /* KEY_LEFTBRACE */ - /* 27, 0x01b */ SDL_SCANCODE_RIGHTBRACKET, /* KEY_RIGHTBRACE */ - /* 28, 0x01c */ SDL_SCANCODE_RETURN, /* KEY_ENTER */ - /* 29, 0x01d */ SDL_SCANCODE_LCTRL, /* KEY_LEFTCTRL */ - /* 30, 0x01e */ SDL_SCANCODE_A, /* KEY_A */ - /* 31, 0x01f */ SDL_SCANCODE_S, /* KEY_S */ - /* 32, 0x020 */ SDL_SCANCODE_D, /* KEY_D */ - /* 33, 0x021 */ SDL_SCANCODE_F, /* KEY_F */ - /* 34, 0x022 */ SDL_SCANCODE_G, /* KEY_G */ - /* 35, 0x023 */ SDL_SCANCODE_H, /* KEY_H */ - /* 36, 0x024 */ SDL_SCANCODE_J, /* KEY_J */ - /* 37, 0x025 */ SDL_SCANCODE_K, /* KEY_K */ - /* 38, 0x026 */ SDL_SCANCODE_L, /* KEY_L */ - /* 39, 0x027 */ SDL_SCANCODE_SEMICOLON, /* KEY_SEMICOLON */ - /* 40, 0x028 */ SDL_SCANCODE_APOSTROPHE, /* KEY_APOSTROPHE */ - /* 41, 0x029 */ SDL_SCANCODE_GRAVE, /* KEY_GRAVE */ - /* 42, 0x02a */ SDL_SCANCODE_LSHIFT, /* KEY_LEFTSHIFT */ - /* 43, 0x02b */ SDL_SCANCODE_BACKSLASH, /* KEY_BACKSLASH */ - /* 44, 0x02c */ SDL_SCANCODE_Z, /* KEY_Z */ - /* 45, 0x02d */ SDL_SCANCODE_X, /* KEY_X */ - /* 46, 0x02e */ SDL_SCANCODE_C, /* KEY_C */ - /* 47, 0x02f */ SDL_SCANCODE_V, /* KEY_V */ - /* 48, 0x030 */ SDL_SCANCODE_B, /* KEY_B */ - /* 49, 0x031 */ SDL_SCANCODE_N, /* KEY_N */ - /* 50, 0x032 */ SDL_SCANCODE_M, /* KEY_M */ - /* 51, 0x033 */ SDL_SCANCODE_COMMA, /* KEY_COMMA */ - /* 52, 0x034 */ SDL_SCANCODE_PERIOD, /* KEY_DOT */ - /* 53, 0x035 */ SDL_SCANCODE_SLASH, /* KEY_SLASH */ - /* 54, 0x036 */ SDL_SCANCODE_RSHIFT, /* KEY_RIGHTSHIFT */ - /* 55, 0x037 */ SDL_SCANCODE_KP_MULTIPLY, /* KEY_KPASTERISK */ - /* 56, 0x038 */ SDL_SCANCODE_LALT, /* KEY_LEFTALT */ - /* 57, 0x039 */ SDL_SCANCODE_SPACE, /* KEY_SPACE */ - /* 58, 0x03a */ SDL_SCANCODE_CAPSLOCK, /* KEY_CAPSLOCK */ - /* 59, 0x03b */ SDL_SCANCODE_F1, /* KEY_F1 */ - /* 60, 0x03c */ SDL_SCANCODE_F2, /* KEY_F2 */ - /* 61, 0x03d */ SDL_SCANCODE_F3, /* KEY_F3 */ - /* 62, 0x03e */ SDL_SCANCODE_F4, /* KEY_F4 */ - /* 63, 0x03f */ SDL_SCANCODE_F5, /* KEY_F5 */ - /* 64, 0x040 */ SDL_SCANCODE_F6, /* KEY_F6 */ - /* 65, 0x041 */ SDL_SCANCODE_F7, /* KEY_F7 */ - /* 66, 0x042 */ SDL_SCANCODE_F8, /* KEY_F8 */ - /* 67, 0x043 */ SDL_SCANCODE_F9, /* KEY_F9 */ - /* 68, 0x044 */ SDL_SCANCODE_F10, /* KEY_F10 */ - /* 69, 0x045 */ SDL_SCANCODE_NUMLOCKCLEAR, /* KEY_NUMLOCK */ - /* 70, 0x046 */ SDL_SCANCODE_SCROLLLOCK, /* KEY_SCROLLLOCK */ - /* 71, 0x047 */ SDL_SCANCODE_KP_7, /* KEY_KP7 */ - /* 72, 0x048 */ SDL_SCANCODE_KP_8, /* KEY_KP8 */ - /* 73, 0x049 */ SDL_SCANCODE_KP_9, /* KEY_KP9 */ - /* 74, 0x04a */ SDL_SCANCODE_KP_MINUS, /* KEY_KPMINUS */ - /* 75, 0x04b */ SDL_SCANCODE_KP_4, /* KEY_KP4 */ - /* 76, 0x04c */ SDL_SCANCODE_KP_5, /* KEY_KP5 */ - /* 77, 0x04d */ SDL_SCANCODE_KP_6, /* KEY_KP6 */ - /* 78, 0x04e */ SDL_SCANCODE_KP_PLUS, /* KEY_KPPLUS */ - /* 79, 0x04f */ SDL_SCANCODE_KP_1, /* KEY_KP1 */ - /* 80, 0x050 */ SDL_SCANCODE_KP_2, /* KEY_KP2 */ - /* 81, 0x051 */ SDL_SCANCODE_KP_3, /* KEY_KP3 */ - /* 82, 0x052 */ SDL_SCANCODE_KP_0, /* KEY_KP0 */ - /* 83, 0x053 */ SDL_SCANCODE_KP_PERIOD, /* KEY_KPDOT */ + /* 0, 0x000 */ SDL_SCANCODE_UNKNOWN, // KEY_RESERVED + /* 1, 0x001 */ SDL_SCANCODE_ESCAPE, // KEY_ESC + /* 2, 0x002 */ SDL_SCANCODE_1, // KEY_1 + /* 3, 0x003 */ SDL_SCANCODE_2, // KEY_2 + /* 4, 0x004 */ SDL_SCANCODE_3, // KEY_3 + /* 5, 0x005 */ SDL_SCANCODE_4, // KEY_4 + /* 6, 0x006 */ SDL_SCANCODE_5, // KEY_5 + /* 7, 0x007 */ SDL_SCANCODE_6, // KEY_6 + /* 8, 0x008 */ SDL_SCANCODE_7, // KEY_7 + /* 9, 0x009 */ SDL_SCANCODE_8, // KEY_8 + /* 10, 0x00a */ SDL_SCANCODE_9, // KEY_9 + /* 11, 0x00b */ SDL_SCANCODE_0, // KEY_0 + /* 12, 0x00c */ SDL_SCANCODE_MINUS, // KEY_MINUS + /* 13, 0x00d */ SDL_SCANCODE_EQUALS, // KEY_EQUAL + /* 14, 0x00e */ SDL_SCANCODE_BACKSPACE, // KEY_BACKSPACE + /* 15, 0x00f */ SDL_SCANCODE_TAB, // KEY_TAB + /* 16, 0x010 */ SDL_SCANCODE_Q, // KEY_Q + /* 17, 0x011 */ SDL_SCANCODE_W, // KEY_W + /* 18, 0x012 */ SDL_SCANCODE_E, // KEY_E + /* 19, 0x013 */ SDL_SCANCODE_R, // KEY_R + /* 20, 0x014 */ SDL_SCANCODE_T, // KEY_T + /* 21, 0x015 */ SDL_SCANCODE_Y, // KEY_Y + /* 22, 0x016 */ SDL_SCANCODE_U, // KEY_U + /* 23, 0x017 */ SDL_SCANCODE_I, // KEY_I + /* 24, 0x018 */ SDL_SCANCODE_O, // KEY_O + /* 25, 0x019 */ SDL_SCANCODE_P, // KEY_P + /* 26, 0x01a */ SDL_SCANCODE_LEFTBRACKET, // KEY_LEFTBRACE + /* 27, 0x01b */ SDL_SCANCODE_RIGHTBRACKET, // KEY_RIGHTBRACE + /* 28, 0x01c */ SDL_SCANCODE_RETURN, // KEY_ENTER + /* 29, 0x01d */ SDL_SCANCODE_LCTRL, // KEY_LEFTCTRL + /* 30, 0x01e */ SDL_SCANCODE_A, // KEY_A + /* 31, 0x01f */ SDL_SCANCODE_S, // KEY_S + /* 32, 0x020 */ SDL_SCANCODE_D, // KEY_D + /* 33, 0x021 */ SDL_SCANCODE_F, // KEY_F + /* 34, 0x022 */ SDL_SCANCODE_G, // KEY_G + /* 35, 0x023 */ SDL_SCANCODE_H, // KEY_H + /* 36, 0x024 */ SDL_SCANCODE_J, // KEY_J + /* 37, 0x025 */ SDL_SCANCODE_K, // KEY_K + /* 38, 0x026 */ SDL_SCANCODE_L, // KEY_L + /* 39, 0x027 */ SDL_SCANCODE_SEMICOLON, // KEY_SEMICOLON + /* 40, 0x028 */ SDL_SCANCODE_APOSTROPHE, // KEY_APOSTROPHE + /* 41, 0x029 */ SDL_SCANCODE_GRAVE, // KEY_GRAVE + /* 42, 0x02a */ SDL_SCANCODE_LSHIFT, // KEY_LEFTSHIFT + /* 43, 0x02b */ SDL_SCANCODE_BACKSLASH, // KEY_BACKSLASH + /* 44, 0x02c */ SDL_SCANCODE_Z, // KEY_Z + /* 45, 0x02d */ SDL_SCANCODE_X, // KEY_X + /* 46, 0x02e */ SDL_SCANCODE_C, // KEY_C + /* 47, 0x02f */ SDL_SCANCODE_V, // KEY_V + /* 48, 0x030 */ SDL_SCANCODE_B, // KEY_B + /* 49, 0x031 */ SDL_SCANCODE_N, // KEY_N + /* 50, 0x032 */ SDL_SCANCODE_M, // KEY_M + /* 51, 0x033 */ SDL_SCANCODE_COMMA, // KEY_COMMA + /* 52, 0x034 */ SDL_SCANCODE_PERIOD, // KEY_DOT + /* 53, 0x035 */ SDL_SCANCODE_SLASH, // KEY_SLASH + /* 54, 0x036 */ SDL_SCANCODE_RSHIFT, // KEY_RIGHTSHIFT + /* 55, 0x037 */ SDL_SCANCODE_KP_MULTIPLY, // KEY_KPASTERISK + /* 56, 0x038 */ SDL_SCANCODE_LALT, // KEY_LEFTALT + /* 57, 0x039 */ SDL_SCANCODE_SPACE, // KEY_SPACE + /* 58, 0x03a */ SDL_SCANCODE_CAPSLOCK, // KEY_CAPSLOCK + /* 59, 0x03b */ SDL_SCANCODE_F1, // KEY_F1 + /* 60, 0x03c */ SDL_SCANCODE_F2, // KEY_F2 + /* 61, 0x03d */ SDL_SCANCODE_F3, // KEY_F3 + /* 62, 0x03e */ SDL_SCANCODE_F4, // KEY_F4 + /* 63, 0x03f */ SDL_SCANCODE_F5, // KEY_F5 + /* 64, 0x040 */ SDL_SCANCODE_F6, // KEY_F6 + /* 65, 0x041 */ SDL_SCANCODE_F7, // KEY_F7 + /* 66, 0x042 */ SDL_SCANCODE_F8, // KEY_F8 + /* 67, 0x043 */ SDL_SCANCODE_F9, // KEY_F9 + /* 68, 0x044 */ SDL_SCANCODE_F10, // KEY_F10 + /* 69, 0x045 */ SDL_SCANCODE_NUMLOCKCLEAR, // KEY_NUMLOCK + /* 70, 0x046 */ SDL_SCANCODE_SCROLLLOCK, // KEY_SCROLLLOCK + /* 71, 0x047 */ SDL_SCANCODE_KP_7, // KEY_KP7 + /* 72, 0x048 */ SDL_SCANCODE_KP_8, // KEY_KP8 + /* 73, 0x049 */ SDL_SCANCODE_KP_9, // KEY_KP9 + /* 74, 0x04a */ SDL_SCANCODE_KP_MINUS, // KEY_KPMINUS + /* 75, 0x04b */ SDL_SCANCODE_KP_4, // KEY_KP4 + /* 76, 0x04c */ SDL_SCANCODE_KP_5, // KEY_KP5 + /* 77, 0x04d */ SDL_SCANCODE_KP_6, // KEY_KP6 + /* 78, 0x04e */ SDL_SCANCODE_KP_PLUS, // KEY_KPPLUS + /* 79, 0x04f */ SDL_SCANCODE_KP_1, // KEY_KP1 + /* 80, 0x050 */ SDL_SCANCODE_KP_2, // KEY_KP2 + /* 81, 0x051 */ SDL_SCANCODE_KP_3, // KEY_KP3 + /* 82, 0x052 */ SDL_SCANCODE_KP_0, // KEY_KP0 + /* 83, 0x053 */ SDL_SCANCODE_KP_PERIOD, // KEY_KPDOT /* 84, 0x054 */ SDL_SCANCODE_UNKNOWN, - /* 85, 0x055 */ SDL_SCANCODE_LANG5, /* KEY_ZENKAKUHANKAKU */ - /* 86, 0x056 */ SDL_SCANCODE_NONUSBACKSLASH, /* KEY_102ND */ - /* 87, 0x057 */ SDL_SCANCODE_F11, /* KEY_F11 */ - /* 88, 0x058 */ SDL_SCANCODE_F12, /* KEY_F12 */ - /* 89, 0x059 */ SDL_SCANCODE_INTERNATIONAL1, /* KEY_RO */ - /* 90, 0x05a */ SDL_SCANCODE_LANG3, /* KEY_KATAKANA */ - /* 91, 0x05b */ SDL_SCANCODE_LANG4, /* KEY_HIRAGANA */ - /* 92, 0x05c */ SDL_SCANCODE_INTERNATIONAL4, /* KEY_HENKAN */ - /* 93, 0x05d */ SDL_SCANCODE_INTERNATIONAL2, /* KEY_KATAKANAHIRAGANA */ - /* 94, 0x05e */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_MUHENKAN */ - /* 95, 0x05f */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_KPJPCOMMA */ - /* 96, 0x060 */ SDL_SCANCODE_KP_ENTER, /* KEY_KPENTER */ - /* 97, 0x061 */ SDL_SCANCODE_RCTRL, /* KEY_RIGHTCTRL */ - /* 98, 0x062 */ SDL_SCANCODE_KP_DIVIDE, /* KEY_KPSLASH */ - /* 99, 0x063 */ SDL_SCANCODE_SYSREQ, /* KEY_SYSRQ */ - /* 100, 0x064 */ SDL_SCANCODE_RALT, /* KEY_RIGHTALT */ - /* 101, 0x065 */ SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED */ - /* 102, 0x066 */ SDL_SCANCODE_HOME, /* KEY_HOME */ - /* 103, 0x067 */ SDL_SCANCODE_UP, /* KEY_UP */ - /* 104, 0x068 */ SDL_SCANCODE_PAGEUP, /* KEY_PAGEUP */ - /* 105, 0x069 */ SDL_SCANCODE_LEFT, /* KEY_LEFT */ - /* 106, 0x06a */ SDL_SCANCODE_RIGHT, /* KEY_RIGHT */ - /* 107, 0x06b */ SDL_SCANCODE_END, /* KEY_END */ - /* 108, 0x06c */ SDL_SCANCODE_DOWN, /* KEY_DOWN */ - /* 109, 0x06d */ SDL_SCANCODE_PAGEDOWN, /* KEY_PAGEDOWN */ - /* 110, 0x06e */ SDL_SCANCODE_INSERT, /* KEY_INSERT */ - /* 111, 0x06f */ SDL_SCANCODE_DELETE, /* KEY_DELETE */ - /* 112, 0x070 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO */ - /* 113, 0x071 */ SDL_SCANCODE_MUTE, /* KEY_MUTE */ - /* 114, 0x072 */ SDL_SCANCODE_VOLUMEDOWN, /* KEY_VOLUMEDOWN */ - /* 115, 0x073 */ SDL_SCANCODE_VOLUMEUP, /* KEY_VOLUMEUP */ - /* 116, 0x074 */ SDL_SCANCODE_POWER, /* KEY_POWER */ - /* 117, 0x075 */ SDL_SCANCODE_KP_EQUALS, /* KEY_KPEQUAL */ - /* 118, 0x076 */ SDL_SCANCODE_KP_PLUSMINUS, /* KEY_KPPLUSMINUS */ - /* 119, 0x077 */ SDL_SCANCODE_PAUSE, /* KEY_PAUSE */ - /* 120, 0x078 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCALE */ - /* 121, 0x079 */ SDL_SCANCODE_KP_COMMA, /* KEY_KPCOMMA */ - /* 122, 0x07a */ SDL_SCANCODE_LANG1, /* KEY_HANGEUL */ - /* 123, 0x07b */ SDL_SCANCODE_LANG2, /* KEY_HANJA */ - /* 124, 0x07c */ SDL_SCANCODE_INTERNATIONAL3, /* KEY_YEN */ - /* 125, 0x07d */ SDL_SCANCODE_LGUI, /* KEY_LEFTMETA */ - /* 126, 0x07e */ SDL_SCANCODE_RGUI, /* KEY_RIGHTMETA */ - /* 127, 0x07f */ SDL_SCANCODE_APPLICATION, /* KEY_COMPOSE */ - /* 128, 0x080 */ SDL_SCANCODE_STOP, /* KEY_STOP */ - /* 129, 0x081 */ SDL_SCANCODE_AGAIN, /* KEY_AGAIN */ - /* 130, 0x082 */ SDL_SCANCODE_AC_PROPERTIES, /* KEY_PROPS */ - /* 131, 0x083 */ SDL_SCANCODE_UNDO, /* KEY_UNDO */ - /* 132, 0x084 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRONT */ - /* 133, 0x085 */ SDL_SCANCODE_COPY, /* KEY_COPY */ - /* 134, 0x086 */ SDL_SCANCODE_AC_OPEN, /* KEY_OPEN */ - /* 135, 0x087 */ SDL_SCANCODE_PASTE, /* KEY_PASTE */ - /* 136, 0x088 */ SDL_SCANCODE_FIND, /* KEY_FIND */ - /* 137, 0x089 */ SDL_SCANCODE_CUT, /* KEY_CUT */ - /* 138, 0x08a */ SDL_SCANCODE_HELP, /* KEY_HELP */ - /* 139, 0x08b */ SDL_SCANCODE_MENU, /* KEY_MENU */ - /* 140, 0x08c */ SDL_SCANCODE_UNKNOWN, /* KEY_CALC */ - /* 141, 0x08d */ SDL_SCANCODE_UNKNOWN, /* KEY_SETUP */ - /* 142, 0x08e */ SDL_SCANCODE_SLEEP, /* KEY_SLEEP */ - /* 143, 0x08f */ SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP */ - /* 144, 0x090 */ SDL_SCANCODE_UNKNOWN, /* KEY_FILE */ - /* 145, 0x091 */ SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE */ - /* 146, 0x092 */ SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE */ - /* 147, 0x093 */ SDL_SCANCODE_UNKNOWN, /* KEY_XFER */ - /* 148, 0x094 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG1 */ - /* 149, 0x095 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG2 */ - /* 150, 0x096 */ SDL_SCANCODE_UNKNOWN, /* KEY_WWW */ - /* 151, 0x097 */ SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS */ - /* 152, 0x098 */ SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE */ - /* 153, 0x099 */ SDL_SCANCODE_UNKNOWN, /* KEY_ROTATE_DISPLAY */ - /* 154, 0x09a */ SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS */ - /* 155, 0x09b */ SDL_SCANCODE_UNKNOWN, /* KEY_MAIL */ - /* 156, 0x09c */ SDL_SCANCODE_AC_BOOKMARKS, /* KEY_BOOKMARKS */ - /* 157, 0x09d */ SDL_SCANCODE_UNKNOWN, /* KEY_COMPUTER */ - /* 158, 0x09e */ SDL_SCANCODE_AC_BACK, /* KEY_BACK */ - /* 159, 0x09f */ SDL_SCANCODE_AC_FORWARD, /* KEY_FORWARD */ - /* 160, 0x0a0 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD */ - /* 161, 0x0a1 */ SDL_SCANCODE_MEDIA_EJECT, /* KEY_EJECTCD */ - /* 162, 0x0a2 */ SDL_SCANCODE_MEDIA_EJECT, /* KEY_EJECTCLOSECD */ - /* 163, 0x0a3 */ SDL_SCANCODE_MEDIA_NEXT_TRACK, /* KEY_NEXTSONG */ - /* 164, 0x0a4 */ SDL_SCANCODE_MEDIA_PLAY_PAUSE, /* KEY_PLAYPAUSE */ - /* 165, 0x0a5 */ SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, /* KEY_PREVIOUSSONG */ - /* 166, 0x0a6 */ SDL_SCANCODE_MEDIA_STOP, /* KEY_STOPCD */ - /* 167, 0x0a7 */ SDL_SCANCODE_MEDIA_RECORD, /* KEY_RECORD */ - /* 168, 0x0a8 */ SDL_SCANCODE_MEDIA_REWIND, /* KEY_REWIND */ - /* 169, 0x0a9 */ SDL_SCANCODE_UNKNOWN, /* KEY_PHONE */ - /* 170, 0x0aa */ SDL_SCANCODE_UNKNOWN, /* KEY_ISO */ - /* 171, 0x0ab */ SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG */ - /* 172, 0x0ac */ SDL_SCANCODE_AC_HOME, /* KEY_HOMEPAGE */ - /* 173, 0x0ad */ SDL_SCANCODE_AC_REFRESH, /* KEY_REFRESH */ - /* 174, 0x0ae */ SDL_SCANCODE_AC_EXIT, /* KEY_EXIT */ - /* 175, 0x0af */ SDL_SCANCODE_UNKNOWN, /* KEY_MOVE */ - /* 176, 0x0b0 */ SDL_SCANCODE_UNKNOWN, /* KEY_EDIT */ - /* 177, 0x0b1 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP */ - /* 178, 0x0b2 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN */ - /* 179, 0x0b3 */ SDL_SCANCODE_KP_LEFTPAREN, /* KEY_KPLEFTPAREN */ - /* 180, 0x0b4 */ SDL_SCANCODE_KP_RIGHTPAREN, /* KEY_KPRIGHTPAREN */ - /* 181, 0x0b5 */ SDL_SCANCODE_AC_NEW, /* KEY_NEW */ - /* 182, 0x0b6 */ SDL_SCANCODE_AGAIN, /* KEY_REDO */ - /* 183, 0x0b7 */ SDL_SCANCODE_F13, /* KEY_F13 */ - /* 184, 0x0b8 */ SDL_SCANCODE_F14, /* KEY_F14 */ - /* 185, 0x0b9 */ SDL_SCANCODE_F15, /* KEY_F15 */ - /* 186, 0x0ba */ SDL_SCANCODE_F16, /* KEY_F16 */ - /* 187, 0x0bb */ SDL_SCANCODE_F17, /* KEY_F17 */ - /* 188, 0x0bc */ SDL_SCANCODE_F18, /* KEY_F18 */ - /* 189, 0x0bd */ SDL_SCANCODE_F19, /* KEY_F19 */ - /* 190, 0x0be */ SDL_SCANCODE_F20, /* KEY_F20 */ - /* 191, 0x0bf */ SDL_SCANCODE_F21, /* KEY_F21 */ - /* 192, 0x0c0 */ SDL_SCANCODE_F22, /* KEY_F22 */ - /* 193, 0x0c1 */ SDL_SCANCODE_F23, /* KEY_F23 */ - /* 194, 0x0c2 */ SDL_SCANCODE_F24, /* KEY_F24 */ + /* 85, 0x055 */ SDL_SCANCODE_LANG5, // KEY_ZENKAKUHANKAKU + /* 86, 0x056 */ SDL_SCANCODE_NONUSBACKSLASH, // KEY_102ND + /* 87, 0x057 */ SDL_SCANCODE_F11, // KEY_F11 + /* 88, 0x058 */ SDL_SCANCODE_F12, // KEY_F12 + /* 89, 0x059 */ SDL_SCANCODE_INTERNATIONAL1, // KEY_RO + /* 90, 0x05a */ SDL_SCANCODE_LANG3, // KEY_KATAKANA + /* 91, 0x05b */ SDL_SCANCODE_LANG4, // KEY_HIRAGANA + /* 92, 0x05c */ SDL_SCANCODE_INTERNATIONAL4, // KEY_HENKAN + /* 93, 0x05d */ SDL_SCANCODE_INTERNATIONAL2, // KEY_KATAKANAHIRAGANA + /* 94, 0x05e */ SDL_SCANCODE_INTERNATIONAL5, // KEY_MUHENKAN + /* 95, 0x05f */ SDL_SCANCODE_INTERNATIONAL5, // KEY_KPJPCOMMA + /* 96, 0x060 */ SDL_SCANCODE_KP_ENTER, // KEY_KPENTER + /* 97, 0x061 */ SDL_SCANCODE_RCTRL, // KEY_RIGHTCTRL + /* 98, 0x062 */ SDL_SCANCODE_KP_DIVIDE, // KEY_KPSLASH + /* 99, 0x063 */ SDL_SCANCODE_SYSREQ, // KEY_SYSRQ + /* 100, 0x064 */ SDL_SCANCODE_RALT, // KEY_RIGHTALT + /* 101, 0x065 */ SDL_SCANCODE_UNKNOWN, // KEY_LINEFEED + /* 102, 0x066 */ SDL_SCANCODE_HOME, // KEY_HOME + /* 103, 0x067 */ SDL_SCANCODE_UP, // KEY_UP + /* 104, 0x068 */ SDL_SCANCODE_PAGEUP, // KEY_PAGEUP + /* 105, 0x069 */ SDL_SCANCODE_LEFT, // KEY_LEFT + /* 106, 0x06a */ SDL_SCANCODE_RIGHT, // KEY_RIGHT + /* 107, 0x06b */ SDL_SCANCODE_END, // KEY_END + /* 108, 0x06c */ SDL_SCANCODE_DOWN, // KEY_DOWN + /* 109, 0x06d */ SDL_SCANCODE_PAGEDOWN, // KEY_PAGEDOWN + /* 110, 0x06e */ SDL_SCANCODE_INSERT, // KEY_INSERT + /* 111, 0x06f */ SDL_SCANCODE_DELETE, // KEY_DELETE + /* 112, 0x070 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO + /* 113, 0x071 */ SDL_SCANCODE_MUTE, // KEY_MUTE + /* 114, 0x072 */ SDL_SCANCODE_VOLUMEDOWN, // KEY_VOLUMEDOWN + /* 115, 0x073 */ SDL_SCANCODE_VOLUMEUP, // KEY_VOLUMEUP + /* 116, 0x074 */ SDL_SCANCODE_POWER, // KEY_POWER + /* 117, 0x075 */ SDL_SCANCODE_KP_EQUALS, // KEY_KPEQUAL + /* 118, 0x076 */ SDL_SCANCODE_KP_PLUSMINUS, // KEY_KPPLUSMINUS + /* 119, 0x077 */ SDL_SCANCODE_PAUSE, // KEY_PAUSE + /* 120, 0x078 */ SDL_SCANCODE_UNKNOWN, // KEY_SCALE + /* 121, 0x079 */ SDL_SCANCODE_KP_COMMA, // KEY_KPCOMMA + /* 122, 0x07a */ SDL_SCANCODE_LANG1, // KEY_HANGEUL + /* 123, 0x07b */ SDL_SCANCODE_LANG2, // KEY_HANJA + /* 124, 0x07c */ SDL_SCANCODE_INTERNATIONAL3, // KEY_YEN + /* 125, 0x07d */ SDL_SCANCODE_LGUI, // KEY_LEFTMETA + /* 126, 0x07e */ SDL_SCANCODE_RGUI, // KEY_RIGHTMETA + /* 127, 0x07f */ SDL_SCANCODE_APPLICATION, // KEY_COMPOSE + /* 128, 0x080 */ SDL_SCANCODE_STOP, // KEY_STOP + /* 129, 0x081 */ SDL_SCANCODE_AGAIN, // KEY_AGAIN + /* 130, 0x082 */ SDL_SCANCODE_AC_PROPERTIES, // KEY_PROPS + /* 131, 0x083 */ SDL_SCANCODE_UNDO, // KEY_UNDO + /* 132, 0x084 */ SDL_SCANCODE_UNKNOWN, // KEY_FRONT + /* 133, 0x085 */ SDL_SCANCODE_COPY, // KEY_COPY + /* 134, 0x086 */ SDL_SCANCODE_AC_OPEN, // KEY_OPEN + /* 135, 0x087 */ SDL_SCANCODE_PASTE, // KEY_PASTE + /* 136, 0x088 */ SDL_SCANCODE_FIND, // KEY_FIND + /* 137, 0x089 */ SDL_SCANCODE_CUT, // KEY_CUT + /* 138, 0x08a */ SDL_SCANCODE_HELP, // KEY_HELP + /* 139, 0x08b */ SDL_SCANCODE_MENU, // KEY_MENU + /* 140, 0x08c */ SDL_SCANCODE_UNKNOWN, // KEY_CALC + /* 141, 0x08d */ SDL_SCANCODE_UNKNOWN, // KEY_SETUP + /* 142, 0x08e */ SDL_SCANCODE_SLEEP, // KEY_SLEEP + /* 143, 0x08f */ SDL_SCANCODE_UNKNOWN, // KEY_WAKEUP + /* 144, 0x090 */ SDL_SCANCODE_UNKNOWN, // KEY_FILE + /* 145, 0x091 */ SDL_SCANCODE_UNKNOWN, // KEY_SENDFILE + /* 146, 0x092 */ SDL_SCANCODE_UNKNOWN, // KEY_DELETEFILE + /* 147, 0x093 */ SDL_SCANCODE_UNKNOWN, // KEY_XFER + /* 148, 0x094 */ SDL_SCANCODE_UNKNOWN, // KEY_PROG1 + /* 149, 0x095 */ SDL_SCANCODE_UNKNOWN, // KEY_PROG2 + /* 150, 0x096 */ SDL_SCANCODE_UNKNOWN, // KEY_WWW + /* 151, 0x097 */ SDL_SCANCODE_UNKNOWN, // KEY_MSDOS + /* 152, 0x098 */ SDL_SCANCODE_UNKNOWN, // KEY_COFFEE + /* 153, 0x099 */ SDL_SCANCODE_UNKNOWN, // KEY_ROTATE_DISPLAY + /* 154, 0x09a */ SDL_SCANCODE_UNKNOWN, // KEY_CYCLEWINDOWS + /* 155, 0x09b */ SDL_SCANCODE_UNKNOWN, // KEY_MAIL + /* 156, 0x09c */ SDL_SCANCODE_AC_BOOKMARKS, // KEY_BOOKMARKS + /* 157, 0x09d */ SDL_SCANCODE_UNKNOWN, // KEY_COMPUTER + /* 158, 0x09e */ SDL_SCANCODE_AC_BACK, // KEY_BACK + /* 159, 0x09f */ SDL_SCANCODE_AC_FORWARD, // KEY_FORWARD + /* 160, 0x0a0 */ SDL_SCANCODE_UNKNOWN, // KEY_CLOSECD + /* 161, 0x0a1 */ SDL_SCANCODE_MEDIA_EJECT, // KEY_EJECTCD + /* 162, 0x0a2 */ SDL_SCANCODE_MEDIA_EJECT, // KEY_EJECTCLOSECD + /* 163, 0x0a3 */ SDL_SCANCODE_MEDIA_NEXT_TRACK, // KEY_NEXTSONG + /* 164, 0x0a4 */ SDL_SCANCODE_MEDIA_PLAY_PAUSE, // KEY_PLAYPAUSE + /* 165, 0x0a5 */ SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, // KEY_PREVIOUSSONG + /* 166, 0x0a6 */ SDL_SCANCODE_MEDIA_STOP, // KEY_STOPCD + /* 167, 0x0a7 */ SDL_SCANCODE_MEDIA_RECORD, // KEY_RECORD + /* 168, 0x0a8 */ SDL_SCANCODE_MEDIA_REWIND, // KEY_REWIND + /* 169, 0x0a9 */ SDL_SCANCODE_UNKNOWN, // KEY_PHONE + /* 170, 0x0aa */ SDL_SCANCODE_UNKNOWN, // KEY_ISO + /* 171, 0x0ab */ SDL_SCANCODE_UNKNOWN, // KEY_CONFIG + /* 172, 0x0ac */ SDL_SCANCODE_AC_HOME, // KEY_HOMEPAGE + /* 173, 0x0ad */ SDL_SCANCODE_AC_REFRESH, // KEY_REFRESH + /* 174, 0x0ae */ SDL_SCANCODE_AC_EXIT, // KEY_EXIT + /* 175, 0x0af */ SDL_SCANCODE_UNKNOWN, // KEY_MOVE + /* 176, 0x0b0 */ SDL_SCANCODE_UNKNOWN, // KEY_EDIT + /* 177, 0x0b1 */ SDL_SCANCODE_UNKNOWN, // KEY_SCROLLUP + /* 178, 0x0b2 */ SDL_SCANCODE_UNKNOWN, // KEY_SCROLLDOWN + /* 179, 0x0b3 */ SDL_SCANCODE_KP_LEFTPAREN, // KEY_KPLEFTPAREN + /* 180, 0x0b4 */ SDL_SCANCODE_KP_RIGHTPAREN, // KEY_KPRIGHTPAREN + /* 181, 0x0b5 */ SDL_SCANCODE_AC_NEW, // KEY_NEW + /* 182, 0x0b6 */ SDL_SCANCODE_AGAIN, // KEY_REDO + /* 183, 0x0b7 */ SDL_SCANCODE_F13, // KEY_F13 + /* 184, 0x0b8 */ SDL_SCANCODE_F14, // KEY_F14 + /* 185, 0x0b9 */ SDL_SCANCODE_F15, // KEY_F15 + /* 186, 0x0ba */ SDL_SCANCODE_F16, // KEY_F16 + /* 187, 0x0bb */ SDL_SCANCODE_F17, // KEY_F17 + /* 188, 0x0bc */ SDL_SCANCODE_F18, // KEY_F18 + /* 189, 0x0bd */ SDL_SCANCODE_F19, // KEY_F19 + /* 190, 0x0be */ SDL_SCANCODE_F20, // KEY_F20 + /* 191, 0x0bf */ SDL_SCANCODE_F21, // KEY_F21 + /* 192, 0x0c0 */ SDL_SCANCODE_F22, // KEY_F22 + /* 193, 0x0c1 */ SDL_SCANCODE_F23, // KEY_F23 + /* 194, 0x0c2 */ SDL_SCANCODE_F24, // KEY_F24 /* 195, 0x0c3 */ SDL_SCANCODE_UNKNOWN, /* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, /* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, /* 198, 0x0c6 */ SDL_SCANCODE_UNKNOWN, /* 199, 0x0c7 */ SDL_SCANCODE_UNKNOWN, - /* 200, 0x0c8 */ SDL_SCANCODE_MEDIA_PLAY, /* KEY_PLAYCD */ - /* 201, 0x0c9 */ SDL_SCANCODE_MEDIA_PAUSE, /* KEY_PAUSECD */ - /* 202, 0x0ca */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 */ - /* 203, 0x0cb */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 */ - /* 204, 0x0cc */ SDL_SCANCODE_UNKNOWN, /* KEY_ALL_APPLICATIONS */ - /* 205, 0x0cd */ SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND */ - /* 206, 0x0ce */ SDL_SCANCODE_AC_CLOSE, /* KEY_CLOSE */ - /* 207, 0x0cf */ SDL_SCANCODE_MEDIA_PLAY, /* KEY_PLAY */ - /* 208, 0x0d0 */ SDL_SCANCODE_MEDIA_FAST_FORWARD, /* KEY_FASTFORWARD */ - /* 209, 0x0d1 */ SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST */ - /* 210, 0x0d2 */ SDL_SCANCODE_PRINTSCREEN, /* KEY_PRINT */ - /* 211, 0x0d3 */ SDL_SCANCODE_UNKNOWN, /* KEY_HP */ - /* 212, 0x0d4 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA */ - /* 213, 0x0d5 */ SDL_SCANCODE_UNKNOWN, /* KEY_SOUND */ - /* 214, 0x0d6 */ SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION */ - /* 215, 0x0d7 */ SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL */ - /* 216, 0x0d8 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHAT */ - /* 217, 0x0d9 */ SDL_SCANCODE_AC_SEARCH, /* KEY_SEARCH */ - /* 218, 0x0da */ SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT */ - /* 219, 0x0db */ SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE */ - /* 220, 0x0dc */ SDL_SCANCODE_UNKNOWN, /* KEY_SPORT */ - /* 221, 0x0dd */ SDL_SCANCODE_UNKNOWN, /* KEY_SHOP */ - /* 222, 0x0de */ SDL_SCANCODE_ALTERASE, /* KEY_ALTERASE */ - /* 223, 0x0df */ SDL_SCANCODE_CANCEL, /* KEY_CANCEL */ - /* 224, 0x0e0 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSDOWN */ - /* 225, 0x0e1 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSUP */ - /* 226, 0x0e2 */ SDL_SCANCODE_MEDIA_SELECT, /* KEY_MEDIA */ - /* 227, 0x0e3 */ SDL_SCANCODE_UNKNOWN, /* KEY_SWITCHVIDEOMODE */ - /* 228, 0x0e4 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMTOGGLE */ - /* 229, 0x0e5 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMDOWN */ - /* 230, 0x0e6 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMUP */ - /* 231, 0x0e7 */ SDL_SCANCODE_UNKNOWN, /* KEY_SEND */ - /* 232, 0x0e8 */ SDL_SCANCODE_UNKNOWN, /* KEY_REPLY */ - /* 233, 0x0e9 */ SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL */ - /* 234, 0x0ea */ SDL_SCANCODE_AC_SAVE, /* KEY_SAVE */ - /* 235, 0x0eb */ SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */ - /* 236, 0x0ec */ SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */ - /* 237, 0x0ed */ SDL_SCANCODE_UNKNOWN, /* KEY_BLUETOOTH */ - /* 238, 0x0ee */ SDL_SCANCODE_UNKNOWN, /* KEY_WLAN */ - /* 239, 0x0ef */ SDL_SCANCODE_UNKNOWN, /* KEY_UWB */ - /* 240, 0x0f0 */ SDL_SCANCODE_UNKNOWN, /* KEY_UNKNOWN */ - /* 241, 0x0f1 */ SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_NEXT */ - /* 242, 0x0f2 */ SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_PREV */ - /* 243, 0x0f3 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_CYCLE */ - /* 244, 0x0f4 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_AUTO */ - /* 245, 0x0f5 */ SDL_SCANCODE_UNKNOWN, /* KEY_DISPLAY_OFF */ - /* 246, 0x0f6 */ SDL_SCANCODE_UNKNOWN, /* KEY_WWAN */ - /* 247, 0x0f7 */ SDL_SCANCODE_UNKNOWN, /* KEY_RFKILL */ - /* 248, 0x0f8 */ SDL_SCANCODE_UNKNOWN, /* KEY_MICMUTE */ + /* 200, 0x0c8 */ SDL_SCANCODE_MEDIA_PLAY, // KEY_PLAYCD + /* 201, 0x0c9 */ SDL_SCANCODE_MEDIA_PAUSE, // KEY_PAUSECD + /* 202, 0x0ca */ SDL_SCANCODE_UNKNOWN, // KEY_PROG3 + /* 203, 0x0cb */ SDL_SCANCODE_UNKNOWN, // KEY_PROG4 + /* 204, 0x0cc */ SDL_SCANCODE_UNKNOWN, // KEY_ALL_APPLICATIONS + /* 205, 0x0cd */ SDL_SCANCODE_UNKNOWN, // KEY_SUSPEND + /* 206, 0x0ce */ SDL_SCANCODE_AC_CLOSE, // KEY_CLOSE + /* 207, 0x0cf */ SDL_SCANCODE_MEDIA_PLAY, // KEY_PLAY + /* 208, 0x0d0 */ SDL_SCANCODE_MEDIA_FAST_FORWARD, // KEY_FASTFORWARD + /* 209, 0x0d1 */ SDL_SCANCODE_UNKNOWN, // KEY_BASSBOOST + /* 210, 0x0d2 */ SDL_SCANCODE_PRINTSCREEN, // KEY_PRINT + /* 211, 0x0d3 */ SDL_SCANCODE_UNKNOWN, // KEY_HP + /* 212, 0x0d4 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA + /* 213, 0x0d5 */ SDL_SCANCODE_UNKNOWN, // KEY_SOUND + /* 214, 0x0d6 */ SDL_SCANCODE_UNKNOWN, // KEY_QUESTION + /* 215, 0x0d7 */ SDL_SCANCODE_UNKNOWN, // KEY_EMAIL + /* 216, 0x0d8 */ SDL_SCANCODE_UNKNOWN, // KEY_CHAT + /* 217, 0x0d9 */ SDL_SCANCODE_AC_SEARCH, // KEY_SEARCH + /* 218, 0x0da */ SDL_SCANCODE_UNKNOWN, // KEY_CONNECT + /* 219, 0x0db */ SDL_SCANCODE_UNKNOWN, // KEY_FINANCE + /* 220, 0x0dc */ SDL_SCANCODE_UNKNOWN, // KEY_SPORT + /* 221, 0x0dd */ SDL_SCANCODE_UNKNOWN, // KEY_SHOP + /* 222, 0x0de */ SDL_SCANCODE_ALTERASE, // KEY_ALTERASE + /* 223, 0x0df */ SDL_SCANCODE_CANCEL, // KEY_CANCEL + /* 224, 0x0e0 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESSDOWN + /* 225, 0x0e1 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESSUP + /* 226, 0x0e2 */ SDL_SCANCODE_MEDIA_SELECT, // KEY_MEDIA + /* 227, 0x0e3 */ SDL_SCANCODE_UNKNOWN, // KEY_SWITCHVIDEOMODE + /* 228, 0x0e4 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDILLUMTOGGLE + /* 229, 0x0e5 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDILLUMDOWN + /* 230, 0x0e6 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDILLUMUP + /* 231, 0x0e7 */ SDL_SCANCODE_UNKNOWN, // KEY_SEND + /* 232, 0x0e8 */ SDL_SCANCODE_UNKNOWN, // KEY_REPLY + /* 233, 0x0e9 */ SDL_SCANCODE_UNKNOWN, // KEY_FORWARDMAIL + /* 234, 0x0ea */ SDL_SCANCODE_AC_SAVE, // KEY_SAVE + /* 235, 0x0eb */ SDL_SCANCODE_UNKNOWN, // KEY_DOCUMENTS + /* 236, 0x0ec */ SDL_SCANCODE_UNKNOWN, // KEY_BATTERY + /* 237, 0x0ed */ SDL_SCANCODE_UNKNOWN, // KEY_BLUETOOTH + /* 238, 0x0ee */ SDL_SCANCODE_UNKNOWN, // KEY_WLAN + /* 239, 0x0ef */ SDL_SCANCODE_UNKNOWN, // KEY_UWB + /* 240, 0x0f0 */ SDL_SCANCODE_UNKNOWN, // KEY_UNKNOWN + /* 241, 0x0f1 */ SDL_SCANCODE_UNKNOWN, // KEY_VIDEO_NEXT + /* 242, 0x0f2 */ SDL_SCANCODE_UNKNOWN, // KEY_VIDEO_PREV + /* 243, 0x0f3 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESS_CYCLE + /* 244, 0x0f4 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESS_AUTO + /* 245, 0x0f5 */ SDL_SCANCODE_UNKNOWN, // KEY_DISPLAY_OFF + /* 246, 0x0f6 */ SDL_SCANCODE_UNKNOWN, // KEY_WWAN + /* 247, 0x0f7 */ SDL_SCANCODE_UNKNOWN, // KEY_RFKILL + /* 248, 0x0f8 */ SDL_SCANCODE_UNKNOWN, // KEY_MICMUTE /* 249, 0x0f9 */ SDL_SCANCODE_UNKNOWN, /* 250, 0x0fa */ SDL_SCANCODE_UNKNOWN, /* 251, 0x0fb */ SDL_SCANCODE_UNKNOWN, @@ -282,7 +282,7 @@ static SDL_Scancode const linux_scancode_table[] = { /* 253, 0x0fd */ SDL_SCANCODE_UNKNOWN, /* 254, 0x0fe */ SDL_SCANCODE_UNKNOWN, /* 255, 0x0ff */ SDL_SCANCODE_UNKNOWN, -#if 0 /* We don't have any mapped scancodes after this point (yet) */ +#if 0 // We don't have any mapped scancodes after this point (yet) /* 256, 0x100 */ SDL_SCANCODE_UNKNOWN, /* 257, 0x101 */ SDL_SCANCODE_UNKNOWN, /* 258, 0x102 */ SDL_SCANCODE_UNKNOWN, @@ -379,106 +379,106 @@ static SDL_Scancode const linux_scancode_table[] = { /* 349, 0x15d */ SDL_SCANCODE_UNKNOWN, /* 350, 0x15e */ SDL_SCANCODE_UNKNOWN, /* 351, 0x15f */ SDL_SCANCODE_UNKNOWN, - /* 352, 0x160 */ SDL_SCANCODE_UNKNOWN, /* KEY_OK */ - /* 353, 0x161 */ SDL_SCANCODE_UNKNOWN, /* KEY_SELECT */ - /* 354, 0x162 */ SDL_SCANCODE_UNKNOWN, /* KEY_GOTO */ - /* 355, 0x163 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLEAR */ - /* 356, 0x164 */ SDL_SCANCODE_UNKNOWN, /* KEY_POWER2 */ - /* 357, 0x165 */ SDL_SCANCODE_UNKNOWN, /* KEY_OPTION */ - /* 358, 0x166 */ SDL_SCANCODE_UNKNOWN, /* KEY_INFO */ - /* 359, 0x167 */ SDL_SCANCODE_UNKNOWN, /* KEY_TIME */ - /* 360, 0x168 */ SDL_SCANCODE_UNKNOWN, /* KEY_VENDOR */ - /* 361, 0x169 */ SDL_SCANCODE_UNKNOWN, /* KEY_ARCHIVE */ - /* 362, 0x16a */ SDL_SCANCODE_UNKNOWN, /* KEY_PROGRAM */ - /* 363, 0x16b */ SDL_SCANCODE_UNKNOWN, /* KEY_CHANNEL */ - /* 364, 0x16c */ SDL_SCANCODE_UNKNOWN, /* KEY_FAVORITES */ - /* 365, 0x16d */ SDL_SCANCODE_UNKNOWN, /* KEY_EPG */ - /* 366, 0x16e */ SDL_SCANCODE_UNKNOWN, /* KEY_PVR */ - /* 367, 0x16f */ SDL_SCANCODE_UNKNOWN, /* KEY_MHP */ - /* 368, 0x170 */ SDL_SCANCODE_UNKNOWN, /* KEY_LANGUAGE */ - /* 369, 0x171 */ SDL_SCANCODE_UNKNOWN, /* KEY_TITLE */ - /* 370, 0x172 */ SDL_SCANCODE_UNKNOWN, /* KEY_SUBTITLE */ - /* 371, 0x173 */ SDL_SCANCODE_UNKNOWN, /* KEY_ANGLE */ - /* 372, 0x174 */ SDL_SCANCODE_UNKNOWN, /* KEY_FULL_SCREEN */ - /* 373, 0x175 */ SDL_SCANCODE_UNKNOWN, /* KEY_MODE */ - /* 374, 0x176 */ SDL_SCANCODE_UNKNOWN, /* KEY_KEYBOARD */ - /* 375, 0x177 */ SDL_SCANCODE_UNKNOWN, /* KEY_ASPECT_RATIO */ - /* 376, 0x178 */ SDL_SCANCODE_UNKNOWN, /* KEY_PC */ - /* 377, 0x179 */ SDL_SCANCODE_UNKNOWN, /* KEY_TV */ - /* 378, 0x17a */ SDL_SCANCODE_UNKNOWN, /* KEY_TV2 */ - /* 379, 0x17b */ SDL_SCANCODE_UNKNOWN, /* KEY_VCR */ - /* 380, 0x17c */ SDL_SCANCODE_UNKNOWN, /* KEY_VCR2 */ - /* 381, 0x17d */ SDL_SCANCODE_UNKNOWN, /* KEY_SAT */ - /* 382, 0x17e */ SDL_SCANCODE_UNKNOWN, /* KEY_SAT2 */ - /* 383, 0x17f */ SDL_SCANCODE_UNKNOWN, /* KEY_CD */ - /* 384, 0x180 */ SDL_SCANCODE_UNKNOWN, /* KEY_TAPE */ - /* 385, 0x181 */ SDL_SCANCODE_UNKNOWN, /* KEY_RADIO */ - /* 386, 0x182 */ SDL_SCANCODE_UNKNOWN, /* KEY_TUNER */ - /* 387, 0x183 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAYER */ - /* 388, 0x184 */ SDL_SCANCODE_UNKNOWN, /* KEY_TEXT */ - /* 389, 0x185 */ SDL_SCANCODE_UNKNOWN, /* KEY_DVD */ - /* 390, 0x186 */ SDL_SCANCODE_UNKNOWN, /* KEY_AUX */ - /* 391, 0x187 */ SDL_SCANCODE_UNKNOWN, /* KEY_MP3 */ - /* 392, 0x188 */ SDL_SCANCODE_UNKNOWN, /* KEY_AUDIO */ - /* 393, 0x189 */ SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO */ - /* 394, 0x18a */ SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTORY */ - /* 395, 0x18b */ SDL_SCANCODE_UNKNOWN, /* KEY_LIST */ - /* 396, 0x18c */ SDL_SCANCODE_UNKNOWN, /* KEY_MEMO */ - /* 397, 0x18d */ SDL_SCANCODE_UNKNOWN, /* KEY_CALENDAR */ - /* 398, 0x18e */ SDL_SCANCODE_UNKNOWN, /* KEY_RED */ - /* 399, 0x18f */ SDL_SCANCODE_UNKNOWN, /* KEY_GREEN */ - /* 400, 0x190 */ SDL_SCANCODE_UNKNOWN, /* KEY_YELLOW */ - /* 401, 0x191 */ SDL_SCANCODE_UNKNOWN, /* KEY_BLUE */ - /* 402, 0x192 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHANNELUP */ - /* 403, 0x193 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHANNELDOWN */ - /* 404, 0x194 */ SDL_SCANCODE_UNKNOWN, /* KEY_FIRST */ - /* 405, 0x195 */ SDL_SCANCODE_UNKNOWN, /* KEY_LAST */ - /* 406, 0x196 */ SDL_SCANCODE_UNKNOWN, /* KEY_AB */ - /* 407, 0x197 */ SDL_SCANCODE_UNKNOWN, /* KEY_NEXT */ - /* 408, 0x198 */ SDL_SCANCODE_UNKNOWN, /* KEY_RESTART */ - /* 409, 0x199 */ SDL_SCANCODE_UNKNOWN, /* KEY_SLOW */ - /* 410, 0x19a */ SDL_SCANCODE_UNKNOWN, /* KEY_SHUFFLE */ - /* 411, 0x19b */ SDL_SCANCODE_UNKNOWN, /* KEY_BREAK */ - /* 412, 0x19c */ SDL_SCANCODE_UNKNOWN, /* KEY_PREVIOUS */ - /* 413, 0x19d */ SDL_SCANCODE_UNKNOWN, /* KEY_DIGITS */ - /* 414, 0x19e */ SDL_SCANCODE_UNKNOWN, /* KEY_TEEN */ - /* 415, 0x19f */ SDL_SCANCODE_UNKNOWN, /* KEY_TWEN */ - /* 416, 0x1a0 */ SDL_SCANCODE_UNKNOWN, /* KEY_VIDEOPHONE */ - /* 417, 0x1a1 */ SDL_SCANCODE_UNKNOWN, /* KEY_GAMES */ - /* 418, 0x1a2 */ SDL_SCANCODE_UNKNOWN, /* KEY_ZOOMIN */ - /* 419, 0x1a3 */ SDL_SCANCODE_UNKNOWN, /* KEY_ZOOMOUT */ - /* 420, 0x1a4 */ SDL_SCANCODE_UNKNOWN, /* KEY_ZOOMRESET */ - /* 421, 0x1a5 */ SDL_SCANCODE_UNKNOWN, /* KEY_WORDPROCESSOR */ - /* 422, 0x1a6 */ SDL_SCANCODE_UNKNOWN, /* KEY_EDITOR */ - /* 423, 0x1a7 */ SDL_SCANCODE_UNKNOWN, /* KEY_SPREADSHEET */ - /* 424, 0x1a8 */ SDL_SCANCODE_UNKNOWN, /* KEY_GRAPHICSEDITOR */ - /* 425, 0x1a9 */ SDL_SCANCODE_UNKNOWN, /* KEY_PRESENTATION */ - /* 426, 0x1aa */ SDL_SCANCODE_UNKNOWN, /* KEY_DATABASE */ - /* 427, 0x1ab */ SDL_SCANCODE_UNKNOWN, /* KEY_NEWS */ - /* 428, 0x1ac */ SDL_SCANCODE_UNKNOWN, /* KEY_VOICEMAIL */ - /* 429, 0x1ad */ SDL_SCANCODE_UNKNOWN, /* KEY_ADDRESSBOOK */ - /* 430, 0x1ae */ SDL_SCANCODE_UNKNOWN, /* KEY_MESSENGER */ - /* 431, 0x1af */ SDL_SCANCODE_UNKNOWN, /* KEY_DISPLAYTOGGLE */ - /* 432, 0x1b0 */ SDL_SCANCODE_UNKNOWN, /* KEY_SPELLCHECK */ - /* 433, 0x1b1 */ SDL_SCANCODE_UNKNOWN, /* KEY_LOGOFF */ - /* 434, 0x1b2 */ SDL_SCANCODE_UNKNOWN, /* KEY_DOLLAR */ - /* 435, 0x1b3 */ SDL_SCANCODE_UNKNOWN, /* KEY_EURO */ - /* 436, 0x1b4 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRAMEBACK */ - /* 437, 0x1b5 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRAMEFORWARD */ - /* 438, 0x1b6 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONTEXT_MENU */ - /* 439, 0x1b7 */ SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA_REPEAT */ - /* 440, 0x1b8 */ SDL_SCANCODE_UNKNOWN, /* KEY_10CHANNELSUP */ - /* 441, 0x1b9 */ SDL_SCANCODE_UNKNOWN, /* KEY_10CHANNELSDOWN */ - /* 442, 0x1ba */ SDL_SCANCODE_UNKNOWN, /* KEY_IMAGES */ + /* 352, 0x160 */ SDL_SCANCODE_UNKNOWN, // KEY_OK + /* 353, 0x161 */ SDL_SCANCODE_UNKNOWN, // KEY_SELECT + /* 354, 0x162 */ SDL_SCANCODE_UNKNOWN, // KEY_GOTO + /* 355, 0x163 */ SDL_SCANCODE_UNKNOWN, // KEY_CLEAR + /* 356, 0x164 */ SDL_SCANCODE_UNKNOWN, // KEY_POWER2 + /* 357, 0x165 */ SDL_SCANCODE_UNKNOWN, // KEY_OPTION + /* 358, 0x166 */ SDL_SCANCODE_UNKNOWN, // KEY_INFO + /* 359, 0x167 */ SDL_SCANCODE_UNKNOWN, // KEY_TIME + /* 360, 0x168 */ SDL_SCANCODE_UNKNOWN, // KEY_VENDOR + /* 361, 0x169 */ SDL_SCANCODE_UNKNOWN, // KEY_ARCHIVE + /* 362, 0x16a */ SDL_SCANCODE_UNKNOWN, // KEY_PROGRAM + /* 363, 0x16b */ SDL_SCANCODE_UNKNOWN, // KEY_CHANNEL + /* 364, 0x16c */ SDL_SCANCODE_UNKNOWN, // KEY_FAVORITES + /* 365, 0x16d */ SDL_SCANCODE_UNKNOWN, // KEY_EPG + /* 366, 0x16e */ SDL_SCANCODE_UNKNOWN, // KEY_PVR + /* 367, 0x16f */ SDL_SCANCODE_UNKNOWN, // KEY_MHP + /* 368, 0x170 */ SDL_SCANCODE_UNKNOWN, // KEY_LANGUAGE + /* 369, 0x171 */ SDL_SCANCODE_UNKNOWN, // KEY_TITLE + /* 370, 0x172 */ SDL_SCANCODE_UNKNOWN, // KEY_SUBTITLE + /* 371, 0x173 */ SDL_SCANCODE_UNKNOWN, // KEY_ANGLE + /* 372, 0x174 */ SDL_SCANCODE_UNKNOWN, // KEY_FULL_SCREEN + /* 373, 0x175 */ SDL_SCANCODE_UNKNOWN, // KEY_MODE + /* 374, 0x176 */ SDL_SCANCODE_UNKNOWN, // KEY_KEYBOARD + /* 375, 0x177 */ SDL_SCANCODE_UNKNOWN, // KEY_ASPECT_RATIO + /* 376, 0x178 */ SDL_SCANCODE_UNKNOWN, // KEY_PC + /* 377, 0x179 */ SDL_SCANCODE_UNKNOWN, // KEY_TV + /* 378, 0x17a */ SDL_SCANCODE_UNKNOWN, // KEY_TV2 + /* 379, 0x17b */ SDL_SCANCODE_UNKNOWN, // KEY_VCR + /* 380, 0x17c */ SDL_SCANCODE_UNKNOWN, // KEY_VCR2 + /* 381, 0x17d */ SDL_SCANCODE_UNKNOWN, // KEY_SAT + /* 382, 0x17e */ SDL_SCANCODE_UNKNOWN, // KEY_SAT2 + /* 383, 0x17f */ SDL_SCANCODE_UNKNOWN, // KEY_CD + /* 384, 0x180 */ SDL_SCANCODE_UNKNOWN, // KEY_TAPE + /* 385, 0x181 */ SDL_SCANCODE_UNKNOWN, // KEY_RADIO + /* 386, 0x182 */ SDL_SCANCODE_UNKNOWN, // KEY_TUNER + /* 387, 0x183 */ SDL_SCANCODE_UNKNOWN, // KEY_PLAYER + /* 388, 0x184 */ SDL_SCANCODE_UNKNOWN, // KEY_TEXT + /* 389, 0x185 */ SDL_SCANCODE_UNKNOWN, // KEY_DVD + /* 390, 0x186 */ SDL_SCANCODE_UNKNOWN, // KEY_AUX + /* 391, 0x187 */ SDL_SCANCODE_UNKNOWN, // KEY_MP3 + /* 392, 0x188 */ SDL_SCANCODE_UNKNOWN, // KEY_AUDIO + /* 393, 0x189 */ SDL_SCANCODE_UNKNOWN, // KEY_VIDEO + /* 394, 0x18a */ SDL_SCANCODE_UNKNOWN, // KEY_DIRECTORY + /* 395, 0x18b */ SDL_SCANCODE_UNKNOWN, // KEY_LIST + /* 396, 0x18c */ SDL_SCANCODE_UNKNOWN, // KEY_MEMO + /* 397, 0x18d */ SDL_SCANCODE_UNKNOWN, // KEY_CALENDAR + /* 398, 0x18e */ SDL_SCANCODE_UNKNOWN, // KEY_RED + /* 399, 0x18f */ SDL_SCANCODE_UNKNOWN, // KEY_GREEN + /* 400, 0x190 */ SDL_SCANCODE_UNKNOWN, // KEY_YELLOW + /* 401, 0x191 */ SDL_SCANCODE_UNKNOWN, // KEY_BLUE + /* 402, 0x192 */ SDL_SCANCODE_UNKNOWN, // KEY_CHANNELUP + /* 403, 0x193 */ SDL_SCANCODE_UNKNOWN, // KEY_CHANNELDOWN + /* 404, 0x194 */ SDL_SCANCODE_UNKNOWN, // KEY_FIRST + /* 405, 0x195 */ SDL_SCANCODE_UNKNOWN, // KEY_LAST + /* 406, 0x196 */ SDL_SCANCODE_UNKNOWN, // KEY_AB + /* 407, 0x197 */ SDL_SCANCODE_UNKNOWN, // KEY_NEXT + /* 408, 0x198 */ SDL_SCANCODE_UNKNOWN, // KEY_RESTART + /* 409, 0x199 */ SDL_SCANCODE_UNKNOWN, // KEY_SLOW + /* 410, 0x19a */ SDL_SCANCODE_UNKNOWN, // KEY_SHUFFLE + /* 411, 0x19b */ SDL_SCANCODE_UNKNOWN, // KEY_BREAK + /* 412, 0x19c */ SDL_SCANCODE_UNKNOWN, // KEY_PREVIOUS + /* 413, 0x19d */ SDL_SCANCODE_UNKNOWN, // KEY_DIGITS + /* 414, 0x19e */ SDL_SCANCODE_UNKNOWN, // KEY_TEEN + /* 415, 0x19f */ SDL_SCANCODE_UNKNOWN, // KEY_TWEN + /* 416, 0x1a0 */ SDL_SCANCODE_UNKNOWN, // KEY_VIDEOPHONE + /* 417, 0x1a1 */ SDL_SCANCODE_UNKNOWN, // KEY_GAMES + /* 418, 0x1a2 */ SDL_SCANCODE_UNKNOWN, // KEY_ZOOMIN + /* 419, 0x1a3 */ SDL_SCANCODE_UNKNOWN, // KEY_ZOOMOUT + /* 420, 0x1a4 */ SDL_SCANCODE_UNKNOWN, // KEY_ZOOMRESET + /* 421, 0x1a5 */ SDL_SCANCODE_UNKNOWN, // KEY_WORDPROCESSOR + /* 422, 0x1a6 */ SDL_SCANCODE_UNKNOWN, // KEY_EDITOR + /* 423, 0x1a7 */ SDL_SCANCODE_UNKNOWN, // KEY_SPREADSHEET + /* 424, 0x1a8 */ SDL_SCANCODE_UNKNOWN, // KEY_GRAPHICSEDITOR + /* 425, 0x1a9 */ SDL_SCANCODE_UNKNOWN, // KEY_PRESENTATION + /* 426, 0x1aa */ SDL_SCANCODE_UNKNOWN, // KEY_DATABASE + /* 427, 0x1ab */ SDL_SCANCODE_UNKNOWN, // KEY_NEWS + /* 428, 0x1ac */ SDL_SCANCODE_UNKNOWN, // KEY_VOICEMAIL + /* 429, 0x1ad */ SDL_SCANCODE_UNKNOWN, // KEY_ADDRESSBOOK + /* 430, 0x1ae */ SDL_SCANCODE_UNKNOWN, // KEY_MESSENGER + /* 431, 0x1af */ SDL_SCANCODE_UNKNOWN, // KEY_DISPLAYTOGGLE + /* 432, 0x1b0 */ SDL_SCANCODE_UNKNOWN, // KEY_SPELLCHECK + /* 433, 0x1b1 */ SDL_SCANCODE_UNKNOWN, // KEY_LOGOFF + /* 434, 0x1b2 */ SDL_SCANCODE_UNKNOWN, // KEY_DOLLAR + /* 435, 0x1b3 */ SDL_SCANCODE_UNKNOWN, // KEY_EURO + /* 436, 0x1b4 */ SDL_SCANCODE_UNKNOWN, // KEY_FRAMEBACK + /* 437, 0x1b5 */ SDL_SCANCODE_UNKNOWN, // KEY_FRAMEFORWARD + /* 438, 0x1b6 */ SDL_SCANCODE_UNKNOWN, // KEY_CONTEXT_MENU + /* 439, 0x1b7 */ SDL_SCANCODE_UNKNOWN, // KEY_MEDIA_REPEAT + /* 440, 0x1b8 */ SDL_SCANCODE_UNKNOWN, // KEY_10CHANNELSUP + /* 441, 0x1b9 */ SDL_SCANCODE_UNKNOWN, // KEY_10CHANNELSDOWN + /* 442, 0x1ba */ SDL_SCANCODE_UNKNOWN, // KEY_IMAGES /* 443, 0x1bb */ SDL_SCANCODE_UNKNOWN, - /* 444, 0x1bc */ SDL_SCANCODE_UNKNOWN, /* KEY_NOTIFICATION_CENTER */ - /* 445, 0x1bd */ SDL_SCANCODE_UNKNOWN, /* KEY_PICKUP_PHONE */ - /* 446, 0x1be */ SDL_SCANCODE_UNKNOWN, /* KEY_HANGUP_PHONE */ + /* 444, 0x1bc */ SDL_SCANCODE_UNKNOWN, // KEY_NOTIFICATION_CENTER + /* 445, 0x1bd */ SDL_SCANCODE_UNKNOWN, // KEY_PICKUP_PHONE + /* 446, 0x1be */ SDL_SCANCODE_UNKNOWN, // KEY_HANGUP_PHONE /* 447, 0x1bf */ SDL_SCANCODE_UNKNOWN, - /* 448, 0x1c0 */ SDL_SCANCODE_UNKNOWN, /* KEY_DEL_EOL */ - /* 449, 0x1c1 */ SDL_SCANCODE_UNKNOWN, /* KEY_DEL_EOS */ - /* 450, 0x1c2 */ SDL_SCANCODE_UNKNOWN, /* KEY_INS_LINE */ - /* 451, 0x1c3 */ SDL_SCANCODE_UNKNOWN, /* KEY_DEL_LINE */ + /* 448, 0x1c0 */ SDL_SCANCODE_UNKNOWN, // KEY_DEL_EOL + /* 449, 0x1c1 */ SDL_SCANCODE_UNKNOWN, // KEY_DEL_EOS + /* 450, 0x1c2 */ SDL_SCANCODE_UNKNOWN, // KEY_INS_LINE + /* 451, 0x1c3 */ SDL_SCANCODE_UNKNOWN, // KEY_DEL_LINE /* 452, 0x1c4 */ SDL_SCANCODE_UNKNOWN, /* 453, 0x1c5 */ SDL_SCANCODE_UNKNOWN, /* 454, 0x1c6 */ SDL_SCANCODE_UNKNOWN, @@ -491,28 +491,28 @@ static SDL_Scancode const linux_scancode_table[] = { /* 461, 0x1cd */ SDL_SCANCODE_UNKNOWN, /* 462, 0x1ce */ SDL_SCANCODE_UNKNOWN, /* 463, 0x1cf */ SDL_SCANCODE_UNKNOWN, - /* 464, 0x1d0 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN */ - /* 465, 0x1d1 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_ESC */ - /* 466, 0x1d2 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F1 */ - /* 467, 0x1d3 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F2 */ - /* 468, 0x1d4 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F3 */ - /* 469, 0x1d5 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F4 */ - /* 470, 0x1d6 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F5 */ - /* 471, 0x1d7 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F6 */ - /* 472, 0x1d8 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F7 */ - /* 473, 0x1d9 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F8 */ - /* 474, 0x1da */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F9 */ - /* 475, 0x1db */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F10 */ - /* 476, 0x1dc */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F11 */ - /* 477, 0x1dd */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F12 */ - /* 478, 0x1de */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_1 */ - /* 479, 0x1df */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_2 */ - /* 480, 0x1e0 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_D */ - /* 481, 0x1e1 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_E */ - /* 482, 0x1e2 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_F */ - /* 483, 0x1e3 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_S */ - /* 484, 0x1e4 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_B */ - /* 485, 0x1e5 */ SDL_SCANCODE_UNKNOWN, /* KEY_FN_RIGHT_SHIFT */ + /* 464, 0x1d0 */ SDL_SCANCODE_UNKNOWN, // KEY_FN + /* 465, 0x1d1 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_ESC + /* 466, 0x1d2 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F1 + /* 467, 0x1d3 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F2 + /* 468, 0x1d4 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F3 + /* 469, 0x1d5 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F4 + /* 470, 0x1d6 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F5 + /* 471, 0x1d7 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F6 + /* 472, 0x1d8 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F7 + /* 473, 0x1d9 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F8 + /* 474, 0x1da */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F9 + /* 475, 0x1db */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F10 + /* 476, 0x1dc */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F11 + /* 477, 0x1dd */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F12 + /* 478, 0x1de */ SDL_SCANCODE_UNKNOWN, // KEY_FN_1 + /* 479, 0x1df */ SDL_SCANCODE_UNKNOWN, // KEY_FN_2 + /* 480, 0x1e0 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_D + /* 481, 0x1e1 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_E + /* 482, 0x1e2 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_F + /* 483, 0x1e3 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_S + /* 484, 0x1e4 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_B + /* 485, 0x1e5 */ SDL_SCANCODE_UNKNOWN, // KEY_FN_RIGHT_SHIFT /* 486, 0x1e6 */ SDL_SCANCODE_UNKNOWN, /* 487, 0x1e7 */ SDL_SCANCODE_UNKNOWN, /* 488, 0x1e8 */ SDL_SCANCODE_UNKNOWN, @@ -524,52 +524,52 @@ static SDL_Scancode const linux_scancode_table[] = { /* 494, 0x1ee */ SDL_SCANCODE_UNKNOWN, /* 495, 0x1ef */ SDL_SCANCODE_UNKNOWN, /* 496, 0x1f0 */ SDL_SCANCODE_UNKNOWN, - /* 497, 0x1f1 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT1 */ - /* 498, 0x1f2 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT2 */ - /* 499, 0x1f3 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT3 */ - /* 500, 0x1f4 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT4 */ - /* 501, 0x1f5 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT5 */ - /* 502, 0x1f6 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT6 */ - /* 503, 0x1f7 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT7 */ - /* 504, 0x1f8 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT8 */ - /* 505, 0x1f9 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT9 */ - /* 506, 0x1fa */ SDL_SCANCODE_UNKNOWN, /* KEY_BRL_DOT10 */ + /* 497, 0x1f1 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT1 + /* 498, 0x1f2 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT2 + /* 499, 0x1f3 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT3 + /* 500, 0x1f4 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT4 + /* 501, 0x1f5 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT5 + /* 502, 0x1f6 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT6 + /* 503, 0x1f7 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT7 + /* 504, 0x1f8 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT8 + /* 505, 0x1f9 */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT9 + /* 506, 0x1fa */ SDL_SCANCODE_UNKNOWN, // KEY_BRL_DOT10 /* 507, 0x1fb */ SDL_SCANCODE_UNKNOWN, /* 508, 0x1fc */ SDL_SCANCODE_UNKNOWN, /* 509, 0x1fd */ SDL_SCANCODE_UNKNOWN, /* 510, 0x1fe */ SDL_SCANCODE_UNKNOWN, /* 511, 0x1ff */ SDL_SCANCODE_UNKNOWN, - /* 512, 0x200 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_0 */ - /* 513, 0x201 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_1 */ - /* 514, 0x202 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_2 */ - /* 515, 0x203 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_3 */ - /* 516, 0x204 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_4 */ - /* 517, 0x205 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_5 */ - /* 518, 0x206 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_6 */ - /* 519, 0x207 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_7 */ - /* 520, 0x208 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_8 */ - /* 521, 0x209 */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_9 */ - /* 522, 0x20a */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_STAR */ - /* 523, 0x20b */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_POUND */ - /* 524, 0x20c */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_A */ - /* 525, 0x20d */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_B */ - /* 526, 0x20e */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_C */ - /* 527, 0x20f */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_D */ - /* 528, 0x210 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_FOCUS */ - /* 529, 0x211 */ SDL_SCANCODE_UNKNOWN, /* KEY_WPS_BUTTON */ - /* 530, 0x212 */ SDL_SCANCODE_UNKNOWN, /* KEY_TOUCHPAD_TOGGLE */ - /* 531, 0x213 */ SDL_SCANCODE_UNKNOWN, /* KEY_TOUCHPAD_ON */ - /* 532, 0x214 */ SDL_SCANCODE_UNKNOWN, /* KEY_TOUCHPAD_OFF */ - /* 533, 0x215 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_ZOOMIN */ - /* 534, 0x216 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_ZOOMOUT */ - /* 535, 0x217 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_UP */ - /* 536, 0x218 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_DOWN */ - /* 537, 0x219 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_LEFT */ - /* 538, 0x21a */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA_RIGHT */ - /* 539, 0x21b */ SDL_SCANCODE_UNKNOWN, /* KEY_ATTENDANT_ON */ - /* 540, 0x21c */ SDL_SCANCODE_UNKNOWN, /* KEY_ATTENDANT_OFF */ - /* 541, 0x21d */ SDL_SCANCODE_UNKNOWN, /* KEY_ATTENDANT_TOGGLE */ - /* 542, 0x21e */ SDL_SCANCODE_UNKNOWN, /* KEY_LIGHTS_TOGGLE */ + /* 512, 0x200 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_0 + /* 513, 0x201 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_1 + /* 514, 0x202 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_2 + /* 515, 0x203 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_3 + /* 516, 0x204 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_4 + /* 517, 0x205 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_5 + /* 518, 0x206 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_6 + /* 519, 0x207 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_7 + /* 520, 0x208 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_8 + /* 521, 0x209 */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_9 + /* 522, 0x20a */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_STAR + /* 523, 0x20b */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_POUND + /* 524, 0x20c */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_A + /* 525, 0x20d */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_B + /* 526, 0x20e */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_C + /* 527, 0x20f */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_D + /* 528, 0x210 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_FOCUS + /* 529, 0x211 */ SDL_SCANCODE_UNKNOWN, // KEY_WPS_BUTTON + /* 530, 0x212 */ SDL_SCANCODE_UNKNOWN, // KEY_TOUCHPAD_TOGGLE + /* 531, 0x213 */ SDL_SCANCODE_UNKNOWN, // KEY_TOUCHPAD_ON + /* 532, 0x214 */ SDL_SCANCODE_UNKNOWN, // KEY_TOUCHPAD_OFF + /* 533, 0x215 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_ZOOMIN + /* 534, 0x216 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_ZOOMOUT + /* 535, 0x217 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_UP + /* 536, 0x218 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_DOWN + /* 537, 0x219 */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_LEFT + /* 538, 0x21a */ SDL_SCANCODE_UNKNOWN, // KEY_CAMERA_RIGHT + /* 539, 0x21b */ SDL_SCANCODE_UNKNOWN, // KEY_ATTENDANT_ON + /* 540, 0x21c */ SDL_SCANCODE_UNKNOWN, // KEY_ATTENDANT_OFF + /* 541, 0x21d */ SDL_SCANCODE_UNKNOWN, // KEY_ATTENDANT_TOGGLE + /* 542, 0x21e */ SDL_SCANCODE_UNKNOWN, // KEY_LIGHTS_TOGGLE /* 543, 0x21f */ SDL_SCANCODE_UNKNOWN, /* 544, 0x220 */ SDL_SCANCODE_UNKNOWN, /* 545, 0x221 */ SDL_SCANCODE_UNKNOWN, @@ -587,8 +587,8 @@ static SDL_Scancode const linux_scancode_table[] = { /* 557, 0x22d */ SDL_SCANCODE_UNKNOWN, /* 558, 0x22e */ SDL_SCANCODE_UNKNOWN, /* 559, 0x22f */ SDL_SCANCODE_UNKNOWN, - /* 560, 0x230 */ SDL_SCANCODE_UNKNOWN, /* KEY_ALS_TOGGLE */ - /* 561, 0x231 */ SDL_SCANCODE_UNKNOWN, /* KEY_ROTATE_LOCK_TOGGLE */ + /* 560, 0x230 */ SDL_SCANCODE_UNKNOWN, // KEY_ALS_TOGGLE + /* 561, 0x231 */ SDL_SCANCODE_UNKNOWN, // KEY_ROTATE_LOCK_TOGGLE /* 562, 0x232 */ SDL_SCANCODE_UNKNOWN, /* 563, 0x233 */ SDL_SCANCODE_UNKNOWN, /* 564, 0x234 */ SDL_SCANCODE_UNKNOWN, @@ -603,24 +603,24 @@ static SDL_Scancode const linux_scancode_table[] = { /* 573, 0x23d */ SDL_SCANCODE_UNKNOWN, /* 574, 0x23e */ SDL_SCANCODE_UNKNOWN, /* 575, 0x23f */ SDL_SCANCODE_UNKNOWN, - /* 576, 0x240 */ SDL_SCANCODE_UNKNOWN, /* KEY_BUTTONCONFIG */ - /* 577, 0x241 */ SDL_SCANCODE_UNKNOWN, /* KEY_TASKMANAGER */ - /* 578, 0x242 */ SDL_SCANCODE_UNKNOWN, /* KEY_JOURNAL */ - /* 579, 0x243 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONTROLPANEL */ - /* 580, 0x244 */ SDL_SCANCODE_UNKNOWN, /* KEY_APPSELECT */ - /* 581, 0x245 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCREENSAVER */ - /* 582, 0x246 */ SDL_SCANCODE_UNKNOWN, /* KEY_VOICECOMMAND */ - /* 583, 0x247 */ SDL_SCANCODE_UNKNOWN, /* KEY_ASSISTANT */ - /* 584, 0x248 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LAYOUT_NEXT */ - /* 585, 0x249 */ SDL_SCANCODE_UNKNOWN, /* KEY_EMOJI_PICKER */ - /* 586, 0x24a */ SDL_SCANCODE_UNKNOWN, /* KEY_DICTATE */ + /* 576, 0x240 */ SDL_SCANCODE_UNKNOWN, // KEY_BUTTONCONFIG + /* 577, 0x241 */ SDL_SCANCODE_UNKNOWN, // KEY_TASKMANAGER + /* 578, 0x242 */ SDL_SCANCODE_UNKNOWN, // KEY_JOURNAL + /* 579, 0x243 */ SDL_SCANCODE_UNKNOWN, // KEY_CONTROLPANEL + /* 580, 0x244 */ SDL_SCANCODE_UNKNOWN, // KEY_APPSELECT + /* 581, 0x245 */ SDL_SCANCODE_UNKNOWN, // KEY_SCREENSAVER + /* 582, 0x246 */ SDL_SCANCODE_UNKNOWN, // KEY_VOICECOMMAND + /* 583, 0x247 */ SDL_SCANCODE_UNKNOWN, // KEY_ASSISTANT + /* 584, 0x248 */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LAYOUT_NEXT + /* 585, 0x249 */ SDL_SCANCODE_UNKNOWN, // KEY_EMOJI_PICKER + /* 586, 0x24a */ SDL_SCANCODE_UNKNOWN, // KEY_DICTATE /* 587, 0x24b */ SDL_SCANCODE_UNKNOWN, /* 588, 0x24c */ SDL_SCANCODE_UNKNOWN, /* 589, 0x24d */ SDL_SCANCODE_UNKNOWN, /* 590, 0x24e */ SDL_SCANCODE_UNKNOWN, /* 591, 0x24f */ SDL_SCANCODE_UNKNOWN, - /* 592, 0x250 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_MIN */ - /* 593, 0x251 */ SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_MAX */ + /* 592, 0x250 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESS_MIN + /* 593, 0x251 */ SDL_SCANCODE_UNKNOWN, // KEY_BRIGHTNESS_MAX /* 594, 0x252 */ SDL_SCANCODE_UNKNOWN, /* 595, 0x253 */ SDL_SCANCODE_UNKNOWN, /* 596, 0x254 */ SDL_SCANCODE_UNKNOWN, @@ -635,33 +635,33 @@ static SDL_Scancode const linux_scancode_table[] = { /* 605, 0x25d */ SDL_SCANCODE_UNKNOWN, /* 606, 0x25e */ SDL_SCANCODE_UNKNOWN, /* 607, 0x25f */ SDL_SCANCODE_UNKNOWN, - /* 608, 0x260 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_PREV */ - /* 609, 0x261 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_NEXT */ - /* 610, 0x262 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_PREVGROUP */ - /* 611, 0x263 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_NEXTGROUP */ - /* 612, 0x264 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_ACCEPT */ - /* 613, 0x265 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBDINPUTASSIST_CANCEL */ - /* 614, 0x266 */ SDL_SCANCODE_UNKNOWN, /* KEY_RIGHT_UP */ - /* 615, 0x267 */ SDL_SCANCODE_UNKNOWN, /* KEY_RIGHT_DOWN */ - /* 616, 0x268 */ SDL_SCANCODE_UNKNOWN, /* KEY_LEFT_UP */ - /* 617, 0x269 */ SDL_SCANCODE_UNKNOWN, /* KEY_LEFT_DOWN */ - /* 618, 0x26a */ SDL_SCANCODE_UNKNOWN, /* KEY_ROOT_MENU */ - /* 619, 0x26b */ SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA_TOP_MENU */ - /* 620, 0x26c */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_11 */ - /* 621, 0x26d */ SDL_SCANCODE_UNKNOWN, /* KEY_NUMERIC_12 */ - /* 622, 0x26e */ SDL_SCANCODE_UNKNOWN, /* KEY_AUDIO_DESC */ - /* 623, 0x26f */ SDL_SCANCODE_UNKNOWN, /* KEY_3D_MODE */ - /* 624, 0x270 */ SDL_SCANCODE_UNKNOWN, /* KEY_NEXT_FAVORITE */ - /* 625, 0x271 */ SDL_SCANCODE_UNKNOWN, /* KEY_STOP_RECORD */ - /* 626, 0x272 */ SDL_SCANCODE_UNKNOWN, /* KEY_PAUSE_RECORD */ - /* 627, 0x273 */ SDL_SCANCODE_UNKNOWN, /* KEY_VOD */ - /* 628, 0x274 */ SDL_SCANCODE_UNKNOWN, /* KEY_UNMUTE */ - /* 629, 0x275 */ SDL_SCANCODE_UNKNOWN, /* KEY_FASTREVERSE */ - /* 630, 0x276 */ SDL_SCANCODE_UNKNOWN, /* KEY_SLOWREVERSE */ - /* 631, 0x277 */ SDL_SCANCODE_UNKNOWN, /* KEY_DATA */ - /* 632, 0x278 */ SDL_SCANCODE_UNKNOWN, /* KEY_ONSCREEN_KEYBOARD */ - /* 633, 0x279 */ SDL_SCANCODE_UNKNOWN, /* KEY_PRIVACY_SCREEN_TOGGLE */ - /* 634, 0x27a */ SDL_SCANCODE_UNKNOWN, /* KEY_SELECTIVE_SCREENSHOT */ + /* 608, 0x260 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_PREV + /* 609, 0x261 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_NEXT + /* 610, 0x262 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_PREVGROUP + /* 611, 0x263 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_NEXTGROUP + /* 612, 0x264 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_ACCEPT + /* 613, 0x265 */ SDL_SCANCODE_UNKNOWN, // KEY_KBDINPUTASSIST_CANCEL + /* 614, 0x266 */ SDL_SCANCODE_UNKNOWN, // KEY_RIGHT_UP + /* 615, 0x267 */ SDL_SCANCODE_UNKNOWN, // KEY_RIGHT_DOWN + /* 616, 0x268 */ SDL_SCANCODE_UNKNOWN, // KEY_LEFT_UP + /* 617, 0x269 */ SDL_SCANCODE_UNKNOWN, // KEY_LEFT_DOWN + /* 618, 0x26a */ SDL_SCANCODE_UNKNOWN, // KEY_ROOT_MENU + /* 619, 0x26b */ SDL_SCANCODE_UNKNOWN, // KEY_MEDIA_TOP_MENU + /* 620, 0x26c */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_11 + /* 621, 0x26d */ SDL_SCANCODE_UNKNOWN, // KEY_NUMERIC_12 + /* 622, 0x26e */ SDL_SCANCODE_UNKNOWN, // KEY_AUDIO_DESC + /* 623, 0x26f */ SDL_SCANCODE_UNKNOWN, // KEY_3D_MODE + /* 624, 0x270 */ SDL_SCANCODE_UNKNOWN, // KEY_NEXT_FAVORITE + /* 625, 0x271 */ SDL_SCANCODE_UNKNOWN, // KEY_STOP_RECORD + /* 626, 0x272 */ SDL_SCANCODE_UNKNOWN, // KEY_PAUSE_RECORD + /* 627, 0x273 */ SDL_SCANCODE_UNKNOWN, // KEY_VOD + /* 628, 0x274 */ SDL_SCANCODE_UNKNOWN, // KEY_UNMUTE + /* 629, 0x275 */ SDL_SCANCODE_UNKNOWN, // KEY_FASTREVERSE + /* 630, 0x276 */ SDL_SCANCODE_UNKNOWN, // KEY_SLOWREVERSE + /* 631, 0x277 */ SDL_SCANCODE_UNKNOWN, // KEY_DATA + /* 632, 0x278 */ SDL_SCANCODE_UNKNOWN, // KEY_ONSCREEN_KEYBOARD + /* 633, 0x279 */ SDL_SCANCODE_UNKNOWN, // KEY_PRIVACY_SCREEN_TOGGLE + /* 634, 0x27a */ SDL_SCANCODE_UNKNOWN, // KEY_SELECTIVE_SCREENSHOT /* 635, 0x27b */ SDL_SCANCODE_UNKNOWN, /* 636, 0x27c */ SDL_SCANCODE_UNKNOWN, /* 637, 0x27d */ SDL_SCANCODE_UNKNOWN, @@ -683,51 +683,51 @@ static SDL_Scancode const linux_scancode_table[] = { /* 653, 0x28d */ SDL_SCANCODE_UNKNOWN, /* 654, 0x28e */ SDL_SCANCODE_UNKNOWN, /* 655, 0x28f */ SDL_SCANCODE_UNKNOWN, - /* 656, 0x290 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO1 */ - /* 657, 0x291 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO2 */ - /* 658, 0x292 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO3 */ - /* 659, 0x293 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO4 */ - /* 660, 0x294 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO5 */ - /* 661, 0x295 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO6 */ - /* 662, 0x296 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO7 */ - /* 663, 0x297 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO8 */ - /* 664, 0x298 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO9 */ - /* 665, 0x299 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO10 */ - /* 666, 0x29a */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO11 */ - /* 667, 0x29b */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO12 */ - /* 668, 0x29c */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO13 */ - /* 669, 0x29d */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO14 */ - /* 670, 0x29e */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO15 */ - /* 671, 0x29f */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO16 */ - /* 672, 0x2a0 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO17 */ - /* 673, 0x2a1 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO18 */ - /* 674, 0x2a2 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO19 */ - /* 675, 0x2a3 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO20 */ - /* 676, 0x2a4 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO21 */ - /* 677, 0x2a5 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO22 */ - /* 678, 0x2a6 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO23 */ - /* 679, 0x2a7 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO24 */ - /* 680, 0x2a8 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO25 */ - /* 681, 0x2a9 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO26 */ - /* 682, 0x2aa */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO27 */ - /* 683, 0x2ab */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO28 */ - /* 684, 0x2ac */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO29 */ - /* 685, 0x2ad */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO30 */ + /* 656, 0x290 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO1 + /* 657, 0x291 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO2 + /* 658, 0x292 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO3 + /* 659, 0x293 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO4 + /* 660, 0x294 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO5 + /* 661, 0x295 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO6 + /* 662, 0x296 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO7 + /* 663, 0x297 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO8 + /* 664, 0x298 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO9 + /* 665, 0x299 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO10 + /* 666, 0x29a */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO11 + /* 667, 0x29b */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO12 + /* 668, 0x29c */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO13 + /* 669, 0x29d */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO14 + /* 670, 0x29e */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO15 + /* 671, 0x29f */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO16 + /* 672, 0x2a0 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO17 + /* 673, 0x2a1 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO18 + /* 674, 0x2a2 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO19 + /* 675, 0x2a3 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO20 + /* 676, 0x2a4 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO21 + /* 677, 0x2a5 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO22 + /* 678, 0x2a6 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO23 + /* 679, 0x2a7 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO24 + /* 680, 0x2a8 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO25 + /* 681, 0x2a9 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO26 + /* 682, 0x2aa */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO27 + /* 683, 0x2ab */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO28 + /* 684, 0x2ac */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO29 + /* 685, 0x2ad */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO30 /* 686, 0x2ae */ SDL_SCANCODE_UNKNOWN, /* 687, 0x2af */ SDL_SCANCODE_UNKNOWN, - /* 688, 0x2b0 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_RECORD_START */ - /* 689, 0x2b1 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_RECORD_STOP */ - /* 690, 0x2b2 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_PRESET_CYCLE */ - /* 691, 0x2b3 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_PRESET1 */ - /* 692, 0x2b4 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_PRESET2 */ - /* 693, 0x2b5 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO_PRESET3 */ + /* 688, 0x2b0 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_RECORD_START + /* 689, 0x2b1 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_RECORD_STOP + /* 690, 0x2b2 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_PRESET_CYCLE + /* 691, 0x2b3 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_PRESET1 + /* 692, 0x2b4 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_PRESET2 + /* 693, 0x2b5 */ SDL_SCANCODE_UNKNOWN, // KEY_MACRO_PRESET3 /* 694, 0x2b6 */ SDL_SCANCODE_UNKNOWN, /* 695, 0x2b7 */ SDL_SCANCODE_UNKNOWN, - /* 696, 0x2b8 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LCD_MENU1 */ - /* 697, 0x2b9 */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LCD_MENU2 */ - /* 698, 0x2ba */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LCD_MENU3 */ - /* 699, 0x2bb */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LCD_MENU4 */ - /* 700, 0x2bc */ SDL_SCANCODE_UNKNOWN, /* KEY_KBD_LCD_MENU5 */ + /* 696, 0x2b8 */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LCD_MENU1 + /* 697, 0x2b9 */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LCD_MENU2 + /* 698, 0x2ba */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LCD_MENU3 + /* 699, 0x2bb */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LCD_MENU4 + /* 700, 0x2bc */ SDL_SCANCODE_UNKNOWN, // KEY_KBD_LCD_MENU5 /* 701, 0x2bd */ SDL_SCANCODE_UNKNOWN, /* 702, 0x2be */ SDL_SCANCODE_UNKNOWN, /* 703, 0x2bf */ SDL_SCANCODE_UNKNOWN, @@ -794,11 +794,11 @@ static SDL_Scancode const linux_scancode_table[] = { /* 764, 0x2fc */ SDL_SCANCODE_UNKNOWN, /* 765, 0x2fd */ SDL_SCANCODE_UNKNOWN, /* 766, 0x2fe */ SDL_SCANCODE_UNKNOWN, - /* 767, 0x2ff */ SDL_SCANCODE_UNKNOWN, /* KEY_MAX */ -#endif /* 0 */ + /* 767, 0x2ff */ SDL_SCANCODE_UNKNOWN, // KEY_MAX +#endif // 0 }; -#if 0 /* A shell script to update the Linux key names in this file */ +#if 0 // A shell script to update the Linux key names in this file #!/bin/bash function get_keyname @@ -823,9 +823,9 @@ grep -F SDL_SCANCODE scancodes_linux.h | while read line; do fi echo " $line" done -#endif /* end script */ +#endif // end script -#if 0 /* A shell script to get comments from the Linux header for these keys */ +#if 0 // A shell script to get comments from the Linux header for these keys #!/bin/bash function get_comment @@ -842,7 +842,7 @@ grep -F SDL_SCANCODE scancodes_linux.h | while read line; do echo " $line $comment" fi done -#endif /* end script */ +#endif // end script -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/events/scancodes_windows.h b/src/events/scancodes_windows.h index 92157b33a8..3d00d9dc51 100644 --- a/src/events/scancodes_windows.h +++ b/src/events/scancodes_windows.h @@ -24,7 +24,7 @@ * Windows scancode to SDL scancode mapping table * https://learn.microsoft.com/windows/win32/inputdev/about-keyboard-input#scan-codes */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static const SDL_Scancode windows_scancode_table[] = { /*0x00*/ SDL_SCANCODE_UNKNOWN, /*0x01*/ SDL_SCANCODE_ESCAPE, @@ -187,7 +187,7 @@ static const SDL_Scancode windows_scancode_table[] = { /*0xe01e*/ SDL_SCANCODE_UNKNOWN, /*0xe01f*/ SDL_SCANCODE_UNKNOWN, /*0xe020*/ SDL_SCANCODE_MUTE, - /*0xe021*/ SDL_SCANCODE_UNKNOWN, /* LaunchApp2 */ + /*0xe021*/ SDL_SCANCODE_UNKNOWN, // LaunchApp2 /*0xe022*/ SDL_SCANCODE_MEDIA_PLAY_PAUSE, /*0xe023*/ SDL_SCANCODE_UNKNOWN, /*0xe024*/ SDL_SCANCODE_MEDIA_STOP, @@ -261,8 +261,8 @@ static const SDL_Scancode windows_scancode_table[] = { /*0xe068*/ SDL_SCANCODE_AC_STOP, /*0xe069*/ SDL_SCANCODE_AC_FORWARD, /*0xe06a*/ SDL_SCANCODE_AC_BACK, - /*0xe06b*/ SDL_SCANCODE_UNKNOWN, /* LaunchApp1 */ - /*0xe06c*/ SDL_SCANCODE_UNKNOWN, /* LaunchMail */ + /*0xe06b*/ SDL_SCANCODE_UNKNOWN, // LaunchApp1 + /*0xe06c*/ SDL_SCANCODE_UNKNOWN, // LaunchMail /*0xe06d*/ SDL_SCANCODE_MEDIA_SELECT, /*0xe06e*/ SDL_SCANCODE_UNKNOWN, /*0xe06f*/ SDL_SCANCODE_UNKNOWN, @@ -283,4 +283,4 @@ static const SDL_Scancode windows_scancode_table[] = { /*0xe07e*/ SDL_SCANCODE_UNKNOWN, /*0xe07f*/ SDL_SCANCODE_UNKNOWN }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index 2083dc613a..beefffbd16 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -27,7 +27,7 @@ Sources: - atKeyNames.h from XFree86 source code */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static const SDL_Scancode xfree86_scancode_table[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, @@ -122,7 +122,7 @@ static const SDL_Scancode xfree86_scancode_table[] = { /* 90 */ SDL_SCANCODE_UP, /* 91 */ SDL_SCANCODE_PAGEUP, /* 92 */ SDL_SCANCODE_LEFT, - /* 93 */ SDL_SCANCODE_UNKNOWN, /* on PowerBook G4 / KEY_Begin */ + /* 93 */ SDL_SCANCODE_UNKNOWN, // on PowerBook G4 / KEY_Begin /* 94 */ SDL_SCANCODE_RIGHT, /* 95 */ SDL_SCANCODE_END, /* 96 */ SDL_SCANCODE_DOWN, @@ -135,7 +135,7 @@ static const SDL_Scancode xfree86_scancode_table[] = { /* 103 */ SDL_SCANCODE_PRINTSCREEN, /* 104 */ SDL_SCANCODE_KP_DIVIDE, /* 105 */ SDL_SCANCODE_RALT, - /* 106 */ SDL_SCANCODE_UNKNOWN, /* BREAK */ + /* 106 */ SDL_SCANCODE_UNKNOWN, // BREAK /* 107 */ SDL_SCANCODE_LGUI, /* 108 */ SDL_SCANCODE_RGUI, /* 109 */ SDL_SCANCODE_APPLICATION, @@ -144,17 +144,17 @@ static const SDL_Scancode xfree86_scancode_table[] = { /* 112 */ SDL_SCANCODE_F15, /* 113 */ SDL_SCANCODE_F16, /* 114 */ SDL_SCANCODE_F17, - /* 115 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */ + /* 115 */ SDL_SCANCODE_INTERNATIONAL1, // \_ /* 116 */ SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */ /* 117 */ SDL_SCANCODE_UNKNOWN, /* 118 */ SDL_SCANCODE_KP_EQUALS, /* 119 */ SDL_SCANCODE_UNKNOWN, /* 120 */ SDL_SCANCODE_UNKNOWN, - /* 121 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */ + /* 121 */ SDL_SCANCODE_INTERNATIONAL4, // Henkan_Mode /* 122 */ SDL_SCANCODE_UNKNOWN, - /* 123 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */ + /* 123 */ SDL_SCANCODE_INTERNATIONAL5, // Muhenkan /* 124 */ SDL_SCANCODE_UNKNOWN, - /* 125 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */ + /* 125 */ SDL_SCANCODE_INTERNATIONAL3, // Yen /* 126 */ SDL_SCANCODE_UNKNOWN, /* 127 */ SDL_SCANCODE_UNKNOWN, /* 128 */ SDL_SCANCODE_UNKNOWN, @@ -168,276 +168,276 @@ static const SDL_Scancode xfree86_scancode_table[] = { /* 136 */ SDL_SCANCODE_HELP, /* 137 */ SDL_SCANCODE_STOP, /* 138 */ SDL_SCANCODE_AGAIN, - /* 139 */ SDL_SCANCODE_UNKNOWN, /* PROPS */ + /* 139 */ SDL_SCANCODE_UNKNOWN, // PROPS /* 140 */ SDL_SCANCODE_UNDO, - /* 141 */ SDL_SCANCODE_UNKNOWN, /* FRONT */ + /* 141 */ SDL_SCANCODE_UNKNOWN, // FRONT /* 142 */ SDL_SCANCODE_COPY, - /* 143 */ SDL_SCANCODE_UNKNOWN, /* OPEN */ + /* 143 */ SDL_SCANCODE_UNKNOWN, // OPEN /* 144 */ SDL_SCANCODE_PASTE, /* 145 */ SDL_SCANCODE_FIND, /* 146 */ SDL_SCANCODE_CUT, }; -/* This is largely identical to the Linux keycode mapping */ +// This is largely identical to the Linux keycode mapping static const SDL_Scancode xfree86_scancode_table2[] = { - /* 0, 0x000 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 1, 0x001 */ SDL_SCANCODE_ESCAPE, /* Escape */ - /* 2, 0x002 */ SDL_SCANCODE_1, /* 1 */ - /* 3, 0x003 */ SDL_SCANCODE_2, /* 2 */ - /* 4, 0x004 */ SDL_SCANCODE_3, /* 3 */ - /* 5, 0x005 */ SDL_SCANCODE_4, /* 4 */ - /* 6, 0x006 */ SDL_SCANCODE_5, /* 5 */ - /* 7, 0x007 */ SDL_SCANCODE_6, /* 6 */ - /* 8, 0x008 */ SDL_SCANCODE_7, /* 7 */ - /* 9, 0x009 */ SDL_SCANCODE_8, /* 8 */ - /* 10, 0x00a */ SDL_SCANCODE_9, /* 9 */ - /* 11, 0x00b */ SDL_SCANCODE_0, /* 0 */ - /* 12, 0x00c */ SDL_SCANCODE_MINUS, /* minus */ - /* 13, 0x00d */ SDL_SCANCODE_EQUALS, /* equal */ - /* 14, 0x00e */ SDL_SCANCODE_BACKSPACE, /* BackSpace */ - /* 15, 0x00f */ SDL_SCANCODE_TAB, /* Tab */ - /* 16, 0x010 */ SDL_SCANCODE_Q, /* q */ - /* 17, 0x011 */ SDL_SCANCODE_W, /* w */ - /* 18, 0x012 */ SDL_SCANCODE_E, /* e */ - /* 19, 0x013 */ SDL_SCANCODE_R, /* r */ - /* 20, 0x014 */ SDL_SCANCODE_T, /* t */ - /* 21, 0x015 */ SDL_SCANCODE_Y, /* y */ - /* 22, 0x016 */ SDL_SCANCODE_U, /* u */ - /* 23, 0x017 */ SDL_SCANCODE_I, /* i */ - /* 24, 0x018 */ SDL_SCANCODE_O, /* o */ - /* 25, 0x019 */ SDL_SCANCODE_P, /* p */ - /* 26, 0x01a */ SDL_SCANCODE_LEFTBRACKET, /* bracketleft */ - /* 27, 0x01b */ SDL_SCANCODE_RIGHTBRACKET, /* bracketright */ - /* 28, 0x01c */ SDL_SCANCODE_RETURN, /* Return */ - /* 29, 0x01d */ SDL_SCANCODE_LCTRL, /* Control_L */ - /* 30, 0x01e */ SDL_SCANCODE_A, /* a */ - /* 31, 0x01f */ SDL_SCANCODE_S, /* s */ - /* 32, 0x020 */ SDL_SCANCODE_D, /* d */ - /* 33, 0x021 */ SDL_SCANCODE_F, /* f */ - /* 34, 0x022 */ SDL_SCANCODE_G, /* g */ - /* 35, 0x023 */ SDL_SCANCODE_H, /* h */ - /* 36, 0x024 */ SDL_SCANCODE_J, /* j */ - /* 37, 0x025 */ SDL_SCANCODE_K, /* k */ - /* 38, 0x026 */ SDL_SCANCODE_L, /* l */ - /* 39, 0x027 */ SDL_SCANCODE_SEMICOLON, /* semicolon */ - /* 40, 0x028 */ SDL_SCANCODE_APOSTROPHE, /* apostrophe */ - /* 41, 0x029 */ SDL_SCANCODE_GRAVE, /* grave */ - /* 42, 0x02a */ SDL_SCANCODE_LSHIFT, /* Shift_L */ - /* 43, 0x02b */ SDL_SCANCODE_BACKSLASH, /* backslash */ - /* 44, 0x02c */ SDL_SCANCODE_Z, /* z */ - /* 45, 0x02d */ SDL_SCANCODE_X, /* x */ - /* 46, 0x02e */ SDL_SCANCODE_C, /* c */ - /* 47, 0x02f */ SDL_SCANCODE_V, /* v */ - /* 48, 0x030 */ SDL_SCANCODE_B, /* b */ - /* 49, 0x031 */ SDL_SCANCODE_N, /* n */ - /* 50, 0x032 */ SDL_SCANCODE_M, /* m */ - /* 51, 0x033 */ SDL_SCANCODE_COMMA, /* comma */ - /* 52, 0x034 */ SDL_SCANCODE_PERIOD, /* period */ - /* 53, 0x035 */ SDL_SCANCODE_SLASH, /* slash */ - /* 54, 0x036 */ SDL_SCANCODE_RSHIFT, /* Shift_R */ - /* 55, 0x037 */ SDL_SCANCODE_KP_MULTIPLY, /* KP_Multiply */ - /* 56, 0x038 */ SDL_SCANCODE_LALT, /* Alt_L */ - /* 57, 0x039 */ SDL_SCANCODE_SPACE, /* space */ - /* 58, 0x03a */ SDL_SCANCODE_CAPSLOCK, /* Caps_Lock */ - /* 59, 0x03b */ SDL_SCANCODE_F1, /* F1 */ - /* 60, 0x03c */ SDL_SCANCODE_F2, /* F2 */ - /* 61, 0x03d */ SDL_SCANCODE_F3, /* F3 */ - /* 62, 0x03e */ SDL_SCANCODE_F4, /* F4 */ - /* 63, 0x03f */ SDL_SCANCODE_F5, /* F5 */ - /* 64, 0x040 */ SDL_SCANCODE_F6, /* F6 */ - /* 65, 0x041 */ SDL_SCANCODE_F7, /* F7 */ - /* 66, 0x042 */ SDL_SCANCODE_F8, /* F8 */ - /* 67, 0x043 */ SDL_SCANCODE_F9, /* F9 */ - /* 68, 0x044 */ SDL_SCANCODE_F10, /* F10 */ - /* 69, 0x045 */ SDL_SCANCODE_NUMLOCKCLEAR, /* Num_Lock */ - /* 70, 0x046 */ SDL_SCANCODE_SCROLLLOCK, /* Scroll_Lock */ - /* 71, 0x047 */ SDL_SCANCODE_KP_7, /* KP_Home */ - /* 72, 0x048 */ SDL_SCANCODE_KP_8, /* KP_Up */ - /* 73, 0x049 */ SDL_SCANCODE_KP_9, /* KP_Prior */ - /* 74, 0x04a */ SDL_SCANCODE_KP_MINUS, /* KP_Subtract */ - /* 75, 0x04b */ SDL_SCANCODE_KP_4, /* KP_Left */ - /* 76, 0x04c */ SDL_SCANCODE_KP_5, /* KP_Begin */ - /* 77, 0x04d */ SDL_SCANCODE_KP_6, /* KP_Right */ - /* 78, 0x04e */ SDL_SCANCODE_KP_PLUS, /* KP_Add */ - /* 79, 0x04f */ SDL_SCANCODE_KP_1, /* KP_End */ - /* 80, 0x050 */ SDL_SCANCODE_KP_2, /* KP_Down */ - /* 81, 0x051 */ SDL_SCANCODE_KP_3, /* KP_Next */ - /* 82, 0x052 */ SDL_SCANCODE_KP_0, /* KP_Insert */ - /* 83, 0x053 */ SDL_SCANCODE_KP_PERIOD, /* KP_Delete */ - /* 84, 0x054 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift */ - /* 85, 0x055 */ SDL_SCANCODE_MODE, /* ???? */ - /* 86, 0x056 */ SDL_SCANCODE_NONUSBACKSLASH, /* less */ - /* 87, 0x057 */ SDL_SCANCODE_F11, /* F11 */ - /* 88, 0x058 */ SDL_SCANCODE_F12, /* F12 */ - /* 89, 0x059 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */ - /* 90, 0x05a */ SDL_SCANCODE_LANG3, /* Katakana */ - /* 91, 0x05b */ SDL_SCANCODE_LANG4, /* Hiragana */ - /* 92, 0x05c */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */ - /* 93, 0x05d */ SDL_SCANCODE_INTERNATIONAL2, /* Hiragana_Katakana */ - /* 94, 0x05e */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */ - /* 95, 0x05f */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 96, 0x060 */ SDL_SCANCODE_KP_ENTER, /* KP_Enter */ - /* 97, 0x061 */ SDL_SCANCODE_RCTRL, /* Control_R */ - /* 98, 0x062 */ SDL_SCANCODE_KP_DIVIDE, /* KP_Divide */ - /* 99, 0x063 */ SDL_SCANCODE_PRINTSCREEN, /* Print */ - /* 100, 0x064 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */ - /* 101, 0x065 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */ - /* 102, 0x066 */ SDL_SCANCODE_HOME, /* Home */ - /* 103, 0x067 */ SDL_SCANCODE_UP, /* Up */ - /* 104, 0x068 */ SDL_SCANCODE_PAGEUP, /* Prior */ - /* 105, 0x069 */ SDL_SCANCODE_LEFT, /* Left */ - /* 106, 0x06a */ SDL_SCANCODE_RIGHT, /* Right */ - /* 107, 0x06b */ SDL_SCANCODE_END, /* End */ - /* 108, 0x06c */ SDL_SCANCODE_DOWN, /* Down */ - /* 109, 0x06d */ SDL_SCANCODE_PAGEDOWN, /* Next */ - /* 110, 0x06e */ SDL_SCANCODE_INSERT, /* Insert */ - /* 111, 0x06f */ SDL_SCANCODE_DELETE, /* Delete */ - /* 112, 0x070 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 113, 0x071 */ SDL_SCANCODE_MUTE, /* XF86AudioMute */ - /* 114, 0x072 */ SDL_SCANCODE_VOLUMEDOWN, /* XF86AudioLowerVolume */ - /* 115, 0x073 */ SDL_SCANCODE_VOLUMEUP, /* XF86AudioRaiseVolume */ - /* 116, 0x074 */ SDL_SCANCODE_POWER, /* XF86PowerOff */ - /* 117, 0x075 */ SDL_SCANCODE_KP_EQUALS, /* KP_Equal */ - /* 118, 0x076 */ SDL_SCANCODE_KP_PLUSMINUS, /* plusminus */ - /* 119, 0x077 */ SDL_SCANCODE_PAUSE, /* Pause */ - /* 120, 0x078 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */ - /* 121, 0x079 */ SDL_SCANCODE_KP_PERIOD, /* KP_Decimal */ - /* 122, 0x07a */ SDL_SCANCODE_LANG1, /* Hangul */ - /* 123, 0x07b */ SDL_SCANCODE_LANG2, /* Hangul_Hanja */ - /* 124, 0x07c */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */ - /* 125, 0x07d */ SDL_SCANCODE_LGUI, /* Super_L */ - /* 126, 0x07e */ SDL_SCANCODE_RGUI, /* Super_R */ - /* 127, 0x07f */ SDL_SCANCODE_APPLICATION, /* Menu */ - /* 128, 0x080 */ SDL_SCANCODE_CANCEL, /* Cancel */ - /* 129, 0x081 */ SDL_SCANCODE_AGAIN, /* Redo */ - /* 130, 0x082 */ SDL_SCANCODE_UNKNOWN, /* SunProps */ - /* 131, 0x083 */ SDL_SCANCODE_UNDO, /* Undo */ - /* 132, 0x084 */ SDL_SCANCODE_UNKNOWN, /* SunFront */ - /* 133, 0x085 */ SDL_SCANCODE_COPY, /* XF86Copy */ - /* 134, 0x086 */ SDL_SCANCODE_UNKNOWN, /* SunOpen, XF86Open */ - /* 135, 0x087 */ SDL_SCANCODE_PASTE, /* XF86Paste */ - /* 136, 0x088 */ SDL_SCANCODE_FIND, /* Find */ - /* 137, 0x089 */ SDL_SCANCODE_CUT, /* XF86Cut */ - /* 138, 0x08a */ SDL_SCANCODE_HELP, /* Help */ - /* 139, 0x08b */ SDL_SCANCODE_MENU, /* XF86MenuKB */ - /* 140, 0x08c */ SDL_SCANCODE_UNKNOWN, /* XF86Calculator */ - /* 141, 0x08d */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 142, 0x08e */ SDL_SCANCODE_SLEEP, /* XF86Sleep */ - /* 143, 0x08f */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */ - /* 144, 0x090 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */ - /* 145, 0x091 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ - /* 146, 0x092 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 147, 0x093 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */ - /* 148, 0x094 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch1 */ - /* 149, 0x095 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch2 */ - /* 150, 0x096 */ SDL_SCANCODE_UNKNOWN, /* XF86WWW */ - /* 151, 0x097 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */ - /* 152, 0x098 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */ - /* 153, 0x099 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ - /* 154, 0x09a */ SDL_SCANCODE_UNKNOWN, /* XF86TaskPane */ - /* 155, 0x09b */ SDL_SCANCODE_UNKNOWN, /* XF86Mail */ - /* 156, 0x09c */ SDL_SCANCODE_AC_BOOKMARKS, /* XF86Favorites */ - /* 157, 0x09d */ SDL_SCANCODE_UNKNOWN, /* XF86MyComputer */ - /* 158, 0x09e */ SDL_SCANCODE_AC_BACK, /* XF86Back */ - /* 159, 0x09f */ SDL_SCANCODE_AC_FORWARD, /* XF86Forward */ - /* 160, 0x0a0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 161, 0x0a1 */ SDL_SCANCODE_MEDIA_EJECT, /* XF86Eject */ - /* 162, 0x0a2 */ SDL_SCANCODE_MEDIA_EJECT, /* XF86Eject */ - /* 163, 0x0a3 */ SDL_SCANCODE_MEDIA_NEXT_TRACK, /* XF86AudioNext */ - /* 164, 0x0a4 */ SDL_SCANCODE_MEDIA_PLAY_PAUSE, /* XF86AudioPlay */ - /* 165, 0x0a5 */ SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, /* XF86AudioPrev */ - /* 166, 0x0a6 */ SDL_SCANCODE_MEDIA_STOP, /* XF86AudioStop */ - /* 167, 0x0a7 */ SDL_SCANCODE_MEDIA_RECORD, /* XF86AudioRecord */ - /* 168, 0x0a8 */ SDL_SCANCODE_MEDIA_REWIND, /* XF86AudioRewind */ - /* 169, 0x0a9 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */ - /* 170, 0x0aa */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 171, 0x0ab */ SDL_SCANCODE_F13, /* XF86Tools */ - /* 172, 0x0ac */ SDL_SCANCODE_AC_HOME, /* XF86HomePage */ - /* 173, 0x0ad */ SDL_SCANCODE_AC_REFRESH, /* XF86Reload */ - /* 174, 0x0ae */ SDL_SCANCODE_UNKNOWN, /* XF86Close */ - /* 175, 0x0af */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 176, 0x0b0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 177, 0x0b1 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */ - /* 178, 0x0b2 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */ - /* 179, 0x0b3 */ SDL_SCANCODE_KP_LEFTPAREN, /* parenleft */ - /* 180, 0x0b4 */ SDL_SCANCODE_KP_RIGHTPAREN, /* parenright */ - /* 181, 0x0b5 */ SDL_SCANCODE_AC_NEW, /* XF86New */ - /* 182, 0x0b6 */ SDL_SCANCODE_AGAIN, /* Redo */ - /* 183, 0x0b7 */ SDL_SCANCODE_F13, /* XF86Tools */ - /* 184, 0x0b8 */ SDL_SCANCODE_F14, /* XF86Launch5 */ - /* 185, 0x0b9 */ SDL_SCANCODE_F15, /* XF86Launch6 */ - /* 186, 0x0ba */ SDL_SCANCODE_F16, /* XF86Launch7 */ - /* 187, 0x0bb */ SDL_SCANCODE_F17, /* XF86Launch8 */ - /* 188, 0x0bc */ SDL_SCANCODE_F18, /* XF86Launch9 */ - /* 189, 0x0bd */ SDL_SCANCODE_F19, /* NoSymbol */ - /* 190, 0x0be */ SDL_SCANCODE_F20, /* XF86AudioMicMute */ - /* 191, 0x0bf */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */ - /* 192, 0x0c0 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadOn */ - /* 193, 0x0c1 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadOff */ - /* 194, 0x0c2 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 195, 0x0c3 */ SDL_SCANCODE_MODE, /* Mode_switch */ - /* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 198, 0x0c6 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 199, 0x0c7 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 200, 0x0c8 */ SDL_SCANCODE_MEDIA_PLAY, /* XF86AudioPlay */ - /* 201, 0x0c9 */ SDL_SCANCODE_MEDIA_PAUSE, /* XF86AudioPause */ - /* 202, 0x0ca */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */ - /* 203, 0x0cb */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */ - /* 204, 0x0cc */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */ - /* 205, 0x0cd */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */ - /* 206, 0x0ce */ SDL_SCANCODE_AC_CLOSE, /* XF86Close */ - /* 207, 0x0cf */ SDL_SCANCODE_MEDIA_PLAY, /* XF86AudioPlay */ - /* 208, 0x0d0 */ SDL_SCANCODE_MEDIA_FAST_FORWARD, /* XF86AudioForward */ - /* 209, 0x0d1 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 210, 0x0d2 */ SDL_SCANCODE_PRINTSCREEN, /* Print */ - /* 211, 0x0d3 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 212, 0x0d4 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */ - /* 213, 0x0d5 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPreset */ - /* 214, 0x0d6 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 215, 0x0d7 */ SDL_SCANCODE_UNKNOWN, /* XF86Mail */ - /* 216, 0x0d8 */ SDL_SCANCODE_UNKNOWN, /* XF86Messenger */ - /* 217, 0x0d9 */ SDL_SCANCODE_AC_SEARCH, /* XF86Search */ - /* 218, 0x0da */ SDL_SCANCODE_UNKNOWN, /* XF86Go */ - /* 219, 0x0db */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */ - /* 220, 0x0dc */ SDL_SCANCODE_UNKNOWN, /* XF86Game */ - /* 221, 0x0dd */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */ - /* 222, 0x0de */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 223, 0x0df */ SDL_SCANCODE_CANCEL, /* Cancel */ - /* 224, 0x0e0 */ SDL_SCANCODE_UNKNOWN, /* XF86MonBrightnessDown */ - /* 225, 0x0e1 */ SDL_SCANCODE_UNKNOWN, /* XF86MonBrightnessUp */ - /* 226, 0x0e2 */ SDL_SCANCODE_MEDIA_SELECT, /* XF86AudioMedia */ - /* 227, 0x0e3 */ SDL_SCANCODE_UNKNOWN, /* XF86Display */ - /* 228, 0x0e4 */ SDL_SCANCODE_UNKNOWN, /* XF86KbdLightOnOff */ - /* 229, 0x0e5 */ SDL_SCANCODE_UNKNOWN, /* XF86KbdBrightnessDown */ - /* 230, 0x0e6 */ SDL_SCANCODE_UNKNOWN, /* XF86KbdBrightnessUp */ - /* 231, 0x0e7 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ - /* 232, 0x0e8 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */ - /* 233, 0x0e9 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */ - /* 234, 0x0ea */ SDL_SCANCODE_UNKNOWN, /* XF86Save */ - /* 235, 0x0eb */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */ - /* 236, 0x0ec */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */ - /* 237, 0x0ed */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */ - /* 238, 0x0ee */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */ - /* 239, 0x0ef */ SDL_SCANCODE_UNKNOWN, /* XF86UWB */ - /* 240, 0x0f0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */ - /* 241, 0x0f1 */ SDL_SCANCODE_UNKNOWN, /* XF86Next_VMode */ - /* 242, 0x0f2 */ SDL_SCANCODE_UNKNOWN, /* XF86Prev_VMode */ - /* 243, 0x0f3 */ SDL_SCANCODE_UNKNOWN, /* XF86MonBrightnessCycle */ - /* 244, 0x0f4 */ SDL_SCANCODE_UNKNOWN, /* XF86BrightnessAuto */ - /* 245, 0x0f5 */ SDL_SCANCODE_UNKNOWN, /* XF86DisplayOff */ - /* 246, 0x0f6 */ SDL_SCANCODE_UNKNOWN, /* XF86WWAN */ - /* 247, 0x0f7 */ SDL_SCANCODE_UNKNOWN, /* XF86RFKill */ + /* 0, 0x000 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 1, 0x001 */ SDL_SCANCODE_ESCAPE, // Escape + /* 2, 0x002 */ SDL_SCANCODE_1, // 1 + /* 3, 0x003 */ SDL_SCANCODE_2, // 2 + /* 4, 0x004 */ SDL_SCANCODE_3, // 3 + /* 5, 0x005 */ SDL_SCANCODE_4, // 4 + /* 6, 0x006 */ SDL_SCANCODE_5, // 5 + /* 7, 0x007 */ SDL_SCANCODE_6, // 6 + /* 8, 0x008 */ SDL_SCANCODE_7, // 7 + /* 9, 0x009 */ SDL_SCANCODE_8, // 8 + /* 10, 0x00a */ SDL_SCANCODE_9, // 9 + /* 11, 0x00b */ SDL_SCANCODE_0, // 0 + /* 12, 0x00c */ SDL_SCANCODE_MINUS, // minus + /* 13, 0x00d */ SDL_SCANCODE_EQUALS, // equal + /* 14, 0x00e */ SDL_SCANCODE_BACKSPACE, // BackSpace + /* 15, 0x00f */ SDL_SCANCODE_TAB, // Tab + /* 16, 0x010 */ SDL_SCANCODE_Q, // q + /* 17, 0x011 */ SDL_SCANCODE_W, // w + /* 18, 0x012 */ SDL_SCANCODE_E, // e + /* 19, 0x013 */ SDL_SCANCODE_R, // r + /* 20, 0x014 */ SDL_SCANCODE_T, // t + /* 21, 0x015 */ SDL_SCANCODE_Y, // y + /* 22, 0x016 */ SDL_SCANCODE_U, // u + /* 23, 0x017 */ SDL_SCANCODE_I, // i + /* 24, 0x018 */ SDL_SCANCODE_O, // o + /* 25, 0x019 */ SDL_SCANCODE_P, // p + /* 26, 0x01a */ SDL_SCANCODE_LEFTBRACKET, // bracketleft + /* 27, 0x01b */ SDL_SCANCODE_RIGHTBRACKET, // bracketright + /* 28, 0x01c */ SDL_SCANCODE_RETURN, // Return + /* 29, 0x01d */ SDL_SCANCODE_LCTRL, // Control_L + /* 30, 0x01e */ SDL_SCANCODE_A, // a + /* 31, 0x01f */ SDL_SCANCODE_S, // s + /* 32, 0x020 */ SDL_SCANCODE_D, // d + /* 33, 0x021 */ SDL_SCANCODE_F, // f + /* 34, 0x022 */ SDL_SCANCODE_G, // g + /* 35, 0x023 */ SDL_SCANCODE_H, // h + /* 36, 0x024 */ SDL_SCANCODE_J, // j + /* 37, 0x025 */ SDL_SCANCODE_K, // k + /* 38, 0x026 */ SDL_SCANCODE_L, // l + /* 39, 0x027 */ SDL_SCANCODE_SEMICOLON, // semicolon + /* 40, 0x028 */ SDL_SCANCODE_APOSTROPHE, // apostrophe + /* 41, 0x029 */ SDL_SCANCODE_GRAVE, // grave + /* 42, 0x02a */ SDL_SCANCODE_LSHIFT, // Shift_L + /* 43, 0x02b */ SDL_SCANCODE_BACKSLASH, // backslash + /* 44, 0x02c */ SDL_SCANCODE_Z, // z + /* 45, 0x02d */ SDL_SCANCODE_X, // x + /* 46, 0x02e */ SDL_SCANCODE_C, // c + /* 47, 0x02f */ SDL_SCANCODE_V, // v + /* 48, 0x030 */ SDL_SCANCODE_B, // b + /* 49, 0x031 */ SDL_SCANCODE_N, // n + /* 50, 0x032 */ SDL_SCANCODE_M, // m + /* 51, 0x033 */ SDL_SCANCODE_COMMA, // comma + /* 52, 0x034 */ SDL_SCANCODE_PERIOD, // period + /* 53, 0x035 */ SDL_SCANCODE_SLASH, // slash + /* 54, 0x036 */ SDL_SCANCODE_RSHIFT, // Shift_R + /* 55, 0x037 */ SDL_SCANCODE_KP_MULTIPLY, // KP_Multiply + /* 56, 0x038 */ SDL_SCANCODE_LALT, // Alt_L + /* 57, 0x039 */ SDL_SCANCODE_SPACE, // space + /* 58, 0x03a */ SDL_SCANCODE_CAPSLOCK, // Caps_Lock + /* 59, 0x03b */ SDL_SCANCODE_F1, // F1 + /* 60, 0x03c */ SDL_SCANCODE_F2, // F2 + /* 61, 0x03d */ SDL_SCANCODE_F3, // F3 + /* 62, 0x03e */ SDL_SCANCODE_F4, // F4 + /* 63, 0x03f */ SDL_SCANCODE_F5, // F5 + /* 64, 0x040 */ SDL_SCANCODE_F6, // F6 + /* 65, 0x041 */ SDL_SCANCODE_F7, // F7 + /* 66, 0x042 */ SDL_SCANCODE_F8, // F8 + /* 67, 0x043 */ SDL_SCANCODE_F9, // F9 + /* 68, 0x044 */ SDL_SCANCODE_F10, // F10 + /* 69, 0x045 */ SDL_SCANCODE_NUMLOCKCLEAR, // Num_Lock + /* 70, 0x046 */ SDL_SCANCODE_SCROLLLOCK, // Scroll_Lock + /* 71, 0x047 */ SDL_SCANCODE_KP_7, // KP_Home + /* 72, 0x048 */ SDL_SCANCODE_KP_8, // KP_Up + /* 73, 0x049 */ SDL_SCANCODE_KP_9, // KP_Prior + /* 74, 0x04a */ SDL_SCANCODE_KP_MINUS, // KP_Subtract + /* 75, 0x04b */ SDL_SCANCODE_KP_4, // KP_Left + /* 76, 0x04c */ SDL_SCANCODE_KP_5, // KP_Begin + /* 77, 0x04d */ SDL_SCANCODE_KP_6, // KP_Right + /* 78, 0x04e */ SDL_SCANCODE_KP_PLUS, // KP_Add + /* 79, 0x04f */ SDL_SCANCODE_KP_1, // KP_End + /* 80, 0x050 */ SDL_SCANCODE_KP_2, // KP_Down + /* 81, 0x051 */ SDL_SCANCODE_KP_3, // KP_Next + /* 82, 0x052 */ SDL_SCANCODE_KP_0, // KP_Insert + /* 83, 0x053 */ SDL_SCANCODE_KP_PERIOD, // KP_Delete + /* 84, 0x054 */ SDL_SCANCODE_RALT, // ISO_Level3_Shift + /* 85, 0x055 */ SDL_SCANCODE_MODE, // ???? + /* 86, 0x056 */ SDL_SCANCODE_NONUSBACKSLASH, // less + /* 87, 0x057 */ SDL_SCANCODE_F11, // F11 + /* 88, 0x058 */ SDL_SCANCODE_F12, // F12 + /* 89, 0x059 */ SDL_SCANCODE_INTERNATIONAL1, // \_ + /* 90, 0x05a */ SDL_SCANCODE_LANG3, // Katakana + /* 91, 0x05b */ SDL_SCANCODE_LANG4, // Hiragana + /* 92, 0x05c */ SDL_SCANCODE_INTERNATIONAL4, // Henkan_Mode + /* 93, 0x05d */ SDL_SCANCODE_INTERNATIONAL2, // Hiragana_Katakana + /* 94, 0x05e */ SDL_SCANCODE_INTERNATIONAL5, // Muhenkan + /* 95, 0x05f */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 96, 0x060 */ SDL_SCANCODE_KP_ENTER, // KP_Enter + /* 97, 0x061 */ SDL_SCANCODE_RCTRL, // Control_R + /* 98, 0x062 */ SDL_SCANCODE_KP_DIVIDE, // KP_Divide + /* 99, 0x063 */ SDL_SCANCODE_PRINTSCREEN, // Print + /* 100, 0x064 */ SDL_SCANCODE_RALT, // ISO_Level3_Shift, ALTGR, RALT + /* 101, 0x065 */ SDL_SCANCODE_UNKNOWN, // Linefeed + /* 102, 0x066 */ SDL_SCANCODE_HOME, // Home + /* 103, 0x067 */ SDL_SCANCODE_UP, // Up + /* 104, 0x068 */ SDL_SCANCODE_PAGEUP, // Prior + /* 105, 0x069 */ SDL_SCANCODE_LEFT, // Left + /* 106, 0x06a */ SDL_SCANCODE_RIGHT, // Right + /* 107, 0x06b */ SDL_SCANCODE_END, // End + /* 108, 0x06c */ SDL_SCANCODE_DOWN, // Down + /* 109, 0x06d */ SDL_SCANCODE_PAGEDOWN, // Next + /* 110, 0x06e */ SDL_SCANCODE_INSERT, // Insert + /* 111, 0x06f */ SDL_SCANCODE_DELETE, // Delete + /* 112, 0x070 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 113, 0x071 */ SDL_SCANCODE_MUTE, // XF86AudioMute + /* 114, 0x072 */ SDL_SCANCODE_VOLUMEDOWN, // XF86AudioLowerVolume + /* 115, 0x073 */ SDL_SCANCODE_VOLUMEUP, // XF86AudioRaiseVolume + /* 116, 0x074 */ SDL_SCANCODE_POWER, // XF86PowerOff + /* 117, 0x075 */ SDL_SCANCODE_KP_EQUALS, // KP_Equal + /* 118, 0x076 */ SDL_SCANCODE_KP_PLUSMINUS, // plusminus + /* 119, 0x077 */ SDL_SCANCODE_PAUSE, // Pause + /* 120, 0x078 */ SDL_SCANCODE_UNKNOWN, // XF86LaunchA + /* 121, 0x079 */ SDL_SCANCODE_KP_PERIOD, // KP_Decimal + /* 122, 0x07a */ SDL_SCANCODE_LANG1, // Hangul + /* 123, 0x07b */ SDL_SCANCODE_LANG2, // Hangul_Hanja + /* 124, 0x07c */ SDL_SCANCODE_INTERNATIONAL3, // Yen + /* 125, 0x07d */ SDL_SCANCODE_LGUI, // Super_L + /* 126, 0x07e */ SDL_SCANCODE_RGUI, // Super_R + /* 127, 0x07f */ SDL_SCANCODE_APPLICATION, // Menu + /* 128, 0x080 */ SDL_SCANCODE_CANCEL, // Cancel + /* 129, 0x081 */ SDL_SCANCODE_AGAIN, // Redo + /* 130, 0x082 */ SDL_SCANCODE_UNKNOWN, // SunProps + /* 131, 0x083 */ SDL_SCANCODE_UNDO, // Undo + /* 132, 0x084 */ SDL_SCANCODE_UNKNOWN, // SunFront + /* 133, 0x085 */ SDL_SCANCODE_COPY, // XF86Copy + /* 134, 0x086 */ SDL_SCANCODE_UNKNOWN, // SunOpen, XF86Open + /* 135, 0x087 */ SDL_SCANCODE_PASTE, // XF86Paste + /* 136, 0x088 */ SDL_SCANCODE_FIND, // Find + /* 137, 0x089 */ SDL_SCANCODE_CUT, // XF86Cut + /* 138, 0x08a */ SDL_SCANCODE_HELP, // Help + /* 139, 0x08b */ SDL_SCANCODE_MENU, // XF86MenuKB + /* 140, 0x08c */ SDL_SCANCODE_UNKNOWN, // XF86Calculator + /* 141, 0x08d */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 142, 0x08e */ SDL_SCANCODE_SLEEP, // XF86Sleep + /* 143, 0x08f */ SDL_SCANCODE_UNKNOWN, // XF86WakeUp + /* 144, 0x090 */ SDL_SCANCODE_UNKNOWN, // XF86Explorer + /* 145, 0x091 */ SDL_SCANCODE_UNKNOWN, // XF86Send + /* 146, 0x092 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 147, 0x093 */ SDL_SCANCODE_UNKNOWN, // XF86Xfer + /* 148, 0x094 */ SDL_SCANCODE_UNKNOWN, // XF86Launch1 + /* 149, 0x095 */ SDL_SCANCODE_UNKNOWN, // XF86Launch2 + /* 150, 0x096 */ SDL_SCANCODE_UNKNOWN, // XF86WWW + /* 151, 0x097 */ SDL_SCANCODE_UNKNOWN, // XF86DOS + /* 152, 0x098 */ SDL_SCANCODE_UNKNOWN, // XF86ScreenSaver + /* 153, 0x099 */ SDL_SCANCODE_UNKNOWN, // XF86RotateWindows + /* 154, 0x09a */ SDL_SCANCODE_UNKNOWN, // XF86TaskPane + /* 155, 0x09b */ SDL_SCANCODE_UNKNOWN, // XF86Mail + /* 156, 0x09c */ SDL_SCANCODE_AC_BOOKMARKS, // XF86Favorites + /* 157, 0x09d */ SDL_SCANCODE_UNKNOWN, // XF86MyComputer + /* 158, 0x09e */ SDL_SCANCODE_AC_BACK, // XF86Back + /* 159, 0x09f */ SDL_SCANCODE_AC_FORWARD, // XF86Forward + /* 160, 0x0a0 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 161, 0x0a1 */ SDL_SCANCODE_MEDIA_EJECT, // XF86Eject + /* 162, 0x0a2 */ SDL_SCANCODE_MEDIA_EJECT, // XF86Eject + /* 163, 0x0a3 */ SDL_SCANCODE_MEDIA_NEXT_TRACK, // XF86AudioNext + /* 164, 0x0a4 */ SDL_SCANCODE_MEDIA_PLAY_PAUSE, // XF86AudioPlay + /* 165, 0x0a5 */ SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, // XF86AudioPrev + /* 166, 0x0a6 */ SDL_SCANCODE_MEDIA_STOP, // XF86AudioStop + /* 167, 0x0a7 */ SDL_SCANCODE_MEDIA_RECORD, // XF86AudioRecord + /* 168, 0x0a8 */ SDL_SCANCODE_MEDIA_REWIND, // XF86AudioRewind + /* 169, 0x0a9 */ SDL_SCANCODE_UNKNOWN, // XF86Phone + /* 170, 0x0aa */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 171, 0x0ab */ SDL_SCANCODE_F13, // XF86Tools + /* 172, 0x0ac */ SDL_SCANCODE_AC_HOME, // XF86HomePage + /* 173, 0x0ad */ SDL_SCANCODE_AC_REFRESH, // XF86Reload + /* 174, 0x0ae */ SDL_SCANCODE_UNKNOWN, // XF86Close + /* 175, 0x0af */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 176, 0x0b0 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 177, 0x0b1 */ SDL_SCANCODE_UNKNOWN, // XF86ScrollUp + /* 178, 0x0b2 */ SDL_SCANCODE_UNKNOWN, // XF86ScrollDown + /* 179, 0x0b3 */ SDL_SCANCODE_KP_LEFTPAREN, // parenleft + /* 180, 0x0b4 */ SDL_SCANCODE_KP_RIGHTPAREN, // parenright + /* 181, 0x0b5 */ SDL_SCANCODE_AC_NEW, // XF86New + /* 182, 0x0b6 */ SDL_SCANCODE_AGAIN, // Redo + /* 183, 0x0b7 */ SDL_SCANCODE_F13, // XF86Tools + /* 184, 0x0b8 */ SDL_SCANCODE_F14, // XF86Launch5 + /* 185, 0x0b9 */ SDL_SCANCODE_F15, // XF86Launch6 + /* 186, 0x0ba */ SDL_SCANCODE_F16, // XF86Launch7 + /* 187, 0x0bb */ SDL_SCANCODE_F17, // XF86Launch8 + /* 188, 0x0bc */ SDL_SCANCODE_F18, // XF86Launch9 + /* 189, 0x0bd */ SDL_SCANCODE_F19, // NoSymbol + /* 190, 0x0be */ SDL_SCANCODE_F20, // XF86AudioMicMute + /* 191, 0x0bf */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadToggle + /* 192, 0x0c0 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOn + /* 193, 0x0c1 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOff + /* 194, 0x0c2 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 195, 0x0c3 */ SDL_SCANCODE_MODE, // Mode_switch + /* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 198, 0x0c6 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 199, 0x0c7 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 200, 0x0c8 */ SDL_SCANCODE_MEDIA_PLAY, // XF86AudioPlay + /* 201, 0x0c9 */ SDL_SCANCODE_MEDIA_PAUSE, // XF86AudioPause + /* 202, 0x0ca */ SDL_SCANCODE_UNKNOWN, // XF86Launch3 + /* 203, 0x0cb */ SDL_SCANCODE_UNKNOWN, // XF86Launch4 + /* 204, 0x0cc */ SDL_SCANCODE_UNKNOWN, // XF86LaunchB + /* 205, 0x0cd */ SDL_SCANCODE_UNKNOWN, // XF86Suspend + /* 206, 0x0ce */ SDL_SCANCODE_AC_CLOSE, // XF86Close + /* 207, 0x0cf */ SDL_SCANCODE_MEDIA_PLAY, // XF86AudioPlay + /* 208, 0x0d0 */ SDL_SCANCODE_MEDIA_FAST_FORWARD, // XF86AudioForward + /* 209, 0x0d1 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 210, 0x0d2 */ SDL_SCANCODE_PRINTSCREEN, // Print + /* 211, 0x0d3 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 212, 0x0d4 */ SDL_SCANCODE_UNKNOWN, // XF86WebCam + /* 213, 0x0d5 */ SDL_SCANCODE_UNKNOWN, // XF86AudioPreset + /* 214, 0x0d6 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 215, 0x0d7 */ SDL_SCANCODE_UNKNOWN, // XF86Mail + /* 216, 0x0d8 */ SDL_SCANCODE_UNKNOWN, // XF86Messenger + /* 217, 0x0d9 */ SDL_SCANCODE_AC_SEARCH, // XF86Search + /* 218, 0x0da */ SDL_SCANCODE_UNKNOWN, // XF86Go + /* 219, 0x0db */ SDL_SCANCODE_UNKNOWN, // XF86Finance + /* 220, 0x0dc */ SDL_SCANCODE_UNKNOWN, // XF86Game + /* 221, 0x0dd */ SDL_SCANCODE_UNKNOWN, // XF86Shop + /* 222, 0x0de */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 223, 0x0df */ SDL_SCANCODE_CANCEL, // Cancel + /* 224, 0x0e0 */ SDL_SCANCODE_UNKNOWN, // XF86MonBrightnessDown + /* 225, 0x0e1 */ SDL_SCANCODE_UNKNOWN, // XF86MonBrightnessUp + /* 226, 0x0e2 */ SDL_SCANCODE_MEDIA_SELECT, // XF86AudioMedia + /* 227, 0x0e3 */ SDL_SCANCODE_UNKNOWN, // XF86Display + /* 228, 0x0e4 */ SDL_SCANCODE_UNKNOWN, // XF86KbdLightOnOff + /* 229, 0x0e5 */ SDL_SCANCODE_UNKNOWN, // XF86KbdBrightnessDown + /* 230, 0x0e6 */ SDL_SCANCODE_UNKNOWN, // XF86KbdBrightnessUp + /* 231, 0x0e7 */ SDL_SCANCODE_UNKNOWN, // XF86Send + /* 232, 0x0e8 */ SDL_SCANCODE_UNKNOWN, // XF86Reply + /* 233, 0x0e9 */ SDL_SCANCODE_UNKNOWN, // XF86MailForward + /* 234, 0x0ea */ SDL_SCANCODE_UNKNOWN, // XF86Save + /* 235, 0x0eb */ SDL_SCANCODE_UNKNOWN, // XF86Documents + /* 236, 0x0ec */ SDL_SCANCODE_UNKNOWN, // XF86Battery + /* 237, 0x0ed */ SDL_SCANCODE_UNKNOWN, // XF86Bluetooth + /* 238, 0x0ee */ SDL_SCANCODE_UNKNOWN, // XF86WLAN + /* 239, 0x0ef */ SDL_SCANCODE_UNKNOWN, // XF86UWB + /* 240, 0x0f0 */ SDL_SCANCODE_UNKNOWN, // NoSymbol + /* 241, 0x0f1 */ SDL_SCANCODE_UNKNOWN, // XF86Next_VMode + /* 242, 0x0f2 */ SDL_SCANCODE_UNKNOWN, // XF86Prev_VMode + /* 243, 0x0f3 */ SDL_SCANCODE_UNKNOWN, // XF86MonBrightnessCycle + /* 244, 0x0f4 */ SDL_SCANCODE_UNKNOWN, // XF86BrightnessAuto + /* 245, 0x0f5 */ SDL_SCANCODE_UNKNOWN, // XF86DisplayOff + /* 246, 0x0f6 */ SDL_SCANCODE_UNKNOWN, // XF86WWAN + /* 247, 0x0f7 */ SDL_SCANCODE_UNKNOWN, // XF86RFKill }; -/* Xvnc / Xtightvnc scancodes from xmodmap -pk */ +// Xvnc / Xtightvnc scancodes from xmodmap -pk static const SDL_Scancode xvnc_scancode_table[] = { /* 0 */ SDL_SCANCODE_LCTRL, /* 1 */ SDL_SCANCODE_RCTRL, /* 2 */ SDL_SCANCODE_LSHIFT, /* 3 */ SDL_SCANCODE_RSHIFT, - /* 4 */ SDL_SCANCODE_UNKNOWN, /* Meta_L */ - /* 5 */ SDL_SCANCODE_UNKNOWN, /* Meta_R */ + /* 4 */ SDL_SCANCODE_UNKNOWN, // Meta_L + /* 5 */ SDL_SCANCODE_UNKNOWN, // Meta_R /* 6 */ SDL_SCANCODE_LALT, /* 7 */ SDL_SCANCODE_RALT, /* 8 */ SDL_SCANCODE_SPACE, @@ -515,6 +515,6 @@ static const SDL_Scancode xvnc_scancode_table[] = { /* 80 */ SDL_SCANCODE_F12, }; -#endif /* scancodes_xfree86_h_ */ +#endif // scancodes_xfree86_h_ -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/file/SDL_iostream.c b/src/file/SDL_iostream.c index 7b7b309349..42c7727e46 100644 --- a/src/file/SDL_iostream.c +++ b/src/file/SDL_iostream.c @@ -47,7 +47,7 @@ struct SDL_IOStream #ifdef SDL_PLATFORM_3DS #include "n3ds/SDL_iostreamromfs.h" -#endif /* SDL_PLATFORM_3DS */ +#endif // SDL_PLATFORM_3DS #ifdef SDL_PLATFORM_ANDROID #include @@ -66,7 +66,7 @@ typedef struct IOStreamWindowsData } IOStreamWindowsData; -/* Functions to read/write Win32 API file pointers */ +// Functions to read/write Win32 API file pointers #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif @@ -84,14 +84,14 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi int a_mode; SDL_zerop(iodata); - iodata->h = INVALID_HANDLE_VALUE; /* mark this as unusable */ + iodata->h = INVALID_HANDLE_VALUE; // mark this as unusable - /* "r" = reading, file must exist */ - /* "w" = writing, truncate existing, file may not exist */ - /* "r+"= reading or writing, file must exist */ - /* "a" = writing, append file may not exist */ - /* "a+"= append + read, file may not exist */ - /* "w+" = read, write, truncate. file may not exist */ + // "r" = reading, file must exist + // "w" = writing, truncate existing, file may not exist + // "r+"= reading or writing, file must exist + // "a" = writing, append file may not exist + // "a+"= append + read, file may not exist + // "w+" = read, write, truncate. file may not exist must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; @@ -100,16 +100,16 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0; if (!r_right && !w_right) { - return -1; /* inconsistent mode */ + return -1; // inconsistent mode } - /* failed (invalid call) */ + // failed (invalid call) iodata->data = (char *)SDL_malloc(READAHEAD_BUFFER_SIZE); if (!iodata->data) { return -1; } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) - /* Do not open a dialog box if failure */ + // Do not open a dialog box if failure old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); #endif @@ -139,7 +139,7 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) - /* restore old behavior */ + // restore old behavior SetErrorMode(old_error_mode); #endif @@ -147,12 +147,12 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi SDL_free(iodata->data); iodata->data = NULL; SDL_SetError("Couldn't open %s", filename); - return -2; /* failed (CreateFile) */ + return -2; // failed (CreateFile) } iodata->h = h; iodata->append = a_mode ? SDL_TRUE : SDL_FALSE; - return 0; /* ok */ + return 0; // ok } static Sint64 SDLCALL windows_file_size(void *userdata) @@ -258,7 +258,7 @@ static size_t SDLCALL windows_file_write(void *userdata, const void *ptr, size_t iodata->left = 0; } - /* if in append mode, we must go to the EOF before write */ + // if in append mode, we must go to the EOF before write if (iodata->append) { LARGE_INTEGER windowsoffset; windowsoffset.QuadPart = 0; @@ -281,17 +281,17 @@ static int SDLCALL windows_file_close(void *userdata) IOStreamWindowsData *iodata = (IOStreamWindowsData *) userdata; if (iodata->h != INVALID_HANDLE_VALUE) { CloseHandle(iodata->h); - iodata->h = INVALID_HANDLE_VALUE; /* to be sure */ + iodata->h = INVALID_HANDLE_VALUE; // to be sure } SDL_free(iodata->data); SDL_free(iodata); return 0; } -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #if defined(HAVE_STDIO_H) && !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) -/* Functions to read/write stdio file pointers. Not used for windows. */ +// Functions to read/write stdio file pointers. Not used for windows. typedef struct IOStreamStdioData { @@ -360,7 +360,7 @@ static Sint64 SDLCALL stdio_seek(void *userdata, Sint64 offset, SDL_IOWhence whe } #endif - /* don't make a possibly-costly API call for the noop seek from SDL_TellIO */ + // don't make a possibly-costly API call for the noop seek from SDL_TellIO const SDL_bool is_noop = (whence == SDL_IO_SEEK_CUR) && (offset == 0); if (is_noop || fseek(iodata->fp, (fseek_off_t)offset, stdiowhence) == 0) { @@ -436,9 +436,9 @@ static SDL_IOStream *SDL_IOFromFP(FILE *fp, SDL_bool autoclose) return iostr; } -#endif /* !HAVE_STDIO_H && !(SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK) */ +#endif // !HAVE_STDIO_H && !(SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK) -/* Functions to read/write memory pointers */ +// Functions to read/write memory pointers typedef struct IOStreamMemData { @@ -511,7 +511,7 @@ static int SDLCALL mem_close(void *userdata) return 0; } -/* Functions to create SDL_IOStream structures from various data sources */ +// Functions to create SDL_IOStream structures from various data sources #if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINDOWS) static SDL_bool IsRegularFileOrPipe(FILE *f) @@ -547,7 +547,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) #ifdef SDL_PLATFORM_ANDROID #ifdef HAVE_STDIO_H - /* Try to open the file on the filesystem first */ + // Try to open the file on the filesystem first if (*file == '/') { FILE *fp = fopen(file, mode); if (fp) { @@ -559,10 +559,10 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) return SDL_IOFromFP(fp, 1); } } else if (SDL_strncmp(file, "content://", 10) == 0) { - /* Try opening content:// URI */ + // Try opening content:// URI int fd = Android_JNI_OpenFileDescriptor(file, mode); if (fd == -1) { - /* SDL error is already set. */ + // SDL error is already set. return NULL; } @@ -575,7 +575,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) return SDL_IOFromFP(fp, SDL_TRUE); } else { - /* Try opening it from internal storage if it's a relative path */ + // Try opening it from internal storage if it's a relative path char *path = NULL; SDL_asprintf(&path, "%s/%s", SDL_GetAndroidInternalStoragePath(), file); if (path) { @@ -591,9 +591,9 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) } } } -#endif /* HAVE_STDIO_H */ +#endif // HAVE_STDIO_H - /* Try to open the file from the asset system */ + // Try to open the file from the asset system void *iodata = NULL; if (Android_JNI_FileOpen(&iodata, file, mode) < 0) { @@ -671,7 +671,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) #else SDL_SetError("SDL not compiled with stdio support"); -#endif /* !HAVE_STDIO_H */ +#endif // !HAVE_STDIO_H return iostr; } @@ -884,7 +884,7 @@ int SDL_CloseIO(SDL_IOStream *iostr) return retval; } -/* Load all the data from an SDL data stream */ +// Load all the data from an SDL data stream void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio) { const int FILE_CHUNK_SIZE = 1024; @@ -936,7 +936,7 @@ void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio) continue; } - /* The stream status will remain set for the caller to check */ + // The stream status will remain set for the caller to check break; } @@ -1098,7 +1098,7 @@ size_t SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char return bytes; } -/* Functions for dynamically reading and writing endian-specific values */ +// Functions for dynamically reading and writing endian-specific values SDL_bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value) { diff --git a/src/file/n3ds/SDL_iostreamromfs.c b/src/file/n3ds/SDL_iostreamromfs.c index 3af006b4bc..7829639136 100644 --- a/src/file/n3ds/SDL_iostreamromfs.c +++ b/src/file/n3ds/SDL_iostreamromfs.c @@ -21,10 +21,10 @@ #include "SDL_iostreamromfs.h" -/* Checks if the mode is a kind of reading */ +// Checks if the mode is a kind of reading static SDL_bool IsReadMode(const char *mode); -/* Checks if the file starts with the given prefix */ +// Checks if the file starts with the given prefix static SDL_bool HasPrefix(const char *file, const char *prefix); static FILE *TryOpenFile(const char *file, const char *mode); @@ -37,12 +37,12 @@ static FILE *TryOpenInRomfs(const char *file, const char *mode); */ FILE *N3DS_FileOpen(const char *file, const char *mode) { - /* romfs are read-only */ + // romfs are read-only if (!IsReadMode(mode)) { return fopen(file, mode); } - /* If the path has an explicit prefix, we skip the guess work */ + // If the path has an explicit prefix, we skip the guess work if (HasPrefix(file, "romfs:/") || HasPrefix(file, "sdmc:/")) { return fopen(file, mode); } diff --git a/src/file/n3ds/SDL_iostreamromfs.h b/src/file/n3ds/SDL_iostreamromfs.h index 4f8827fab3..251d4803b3 100644 --- a/src/file/n3ds/SDL_iostreamromfs.h +++ b/src/file/n3ds/SDL_iostreamromfs.h @@ -25,4 +25,4 @@ FILE *N3DS_FileOpen(const char *file, const char *mode); -#endif /* SDL_iostreamromfs_h_ */ +#endif // SDL_iostreamromfs_h_ diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c index 6248792dec..ebe9c2db92 100644 --- a/src/filesystem/SDL_filesystem.c +++ b/src/filesystem/SDL_filesystem.c @@ -55,7 +55,7 @@ int SDL_CopyFile(const char *oldpath, const char *newpath) int SDL_CreateDirectory(const char *path) { - /* TODO: Recursively create subdirectories */ + // TODO: Recursively create subdirectories if (!path) { return SDL_InvalidParamError("path"); } diff --git a/src/filesystem/android/SDL_sysfilesystem.c b/src/filesystem/android/SDL_sysfilesystem.c index 350ee06278..b97bda2be4 100644 --- a/src/filesystem/android/SDL_sysfilesystem.c +++ b/src/filesystem/android/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_ANDROID /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -31,7 +31,7 @@ char *SDL_SYS_GetBasePath(void) { - /* The current working directory is / on Android */ + // The current working directory is / on Android SDL_Unsupported(); return NULL; } @@ -59,4 +59,4 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) return NULL; } -#endif /* SDL_FILESYSTEM_ANDROID */ +#endif // SDL_FILESYSTEM_ANDROID diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index e01c52c023..58913bd10e 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_COCOA /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -47,7 +47,7 @@ char *SDL_SYS_GetBasePath(void) } 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 */ + // this returns the exedir for non-bundled and the resourceDir for bundled apps base = [[bundle resourcePath] fileSystemRepresentation]; } @@ -97,9 +97,9 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) } array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS - if ([array count] > 0) { /* we only want the first item in the list. */ + 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) { @@ -233,8 +233,8 @@ append_slash: } return retval; -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS } } -#endif /* SDL_FILESYSTEM_COCOA */ +#endif // SDL_FILESYSTEM_COCOA diff --git a/src/filesystem/dummy/SDL_sysfilesystem.c b/src/filesystem/dummy/SDL_sysfilesystem.c index e7d32b3198..0c74b5986b 100644 --- a/src/filesystem/dummy/SDL_sysfilesystem.c +++ b/src/filesystem/dummy/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #if defined(SDL_FILESYSTEM_DUMMY) || defined(SDL_FILESYSTEM_DISABLED) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -45,4 +45,4 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) return NULL; } -#endif /* SDL_FILESYSTEM_DUMMY || SDL_FILESYSTEM_DISABLED */ +#endif // SDL_FILESYSTEM_DUMMY || SDL_FILESYSTEM_DISABLED diff --git a/src/filesystem/dummy/SDL_sysfsops.c b/src/filesystem/dummy/SDL_sysfsops.c index 2b34a185cf..802a12a79e 100644 --- a/src/filesystem/dummy/SDL_sysfsops.c +++ b/src/filesystem/dummy/SDL_sysfsops.c @@ -24,7 +24,7 @@ #if defined(SDL_FSOPS_DUMMY) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" diff --git a/src/filesystem/emscripten/SDL_sysfilesystem.c b/src/filesystem/emscripten/SDL_sysfilesystem.c index 4e4d03c996..31190ec67f 100644 --- a/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_EMSCRIPTEN /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -113,4 +113,4 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) return retval; } -#endif /* SDL_FILESYSTEM_EMSCRIPTEN */ +#endif // SDL_FILESYSTEM_EMSCRIPTEN diff --git a/src/filesystem/gdk/SDL_sysfilesystem.cpp b/src/filesystem/gdk/SDL_sysfilesystem.cpp index 1295a29b5b..c035bdd88a 100644 --- a/src/filesystem/gdk/SDL_sysfilesystem.cpp +++ b/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -21,7 +21,7 @@ #include "SDL_internal.h" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines extern "C" { #include "../SDL_sysfilesystem.h" @@ -54,13 +54,13 @@ SDL_SYS_GetBasePath(void) path = (CHAR *)ptr; len = GetModuleFileNameA(NULL, path, buflen); - /* if it truncated, then len >= buflen - 1 */ - /* if there was enough room (or failure), len < buflen - 1 */ + // if it truncated, then len >= buflen - 1 + // if there was enough room (or failure), len < buflen - 1 if (len < buflen - 1) { break; } - /* buffer too small? Try again. */ + // buffer too small? Try again. buflen *= 2; } @@ -76,8 +76,8 @@ SDL_SYS_GetBasePath(void) } } - 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. return path; } @@ -89,20 +89,20 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) char *folderPath; HRESULT result; const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID"); - + if (!app) { SDL_InvalidParamError("app"); return NULL; } - /* This should be set before calling SDL_GetPrefPath! */ + // This should be set before calling SDL_GetPrefPath! if (!csid) { SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!"); return SDL_strdup("T:\\"); } if (SDL_GetGDKDefaultUser(&user) < 0) { - /* Error already set, just return */ + // Error already set, just return return NULL; } @@ -135,11 +135,11 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return folderPath; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); return NULL; } -/* vi: set ts=4 sw=4 expandtab: */ +// vi: set ts=4 sw=4 expandtab: diff --git a/src/filesystem/haiku/SDL_sysfilesystem.cc b/src/filesystem/haiku/SDL_sysfilesystem.cc index 3324627b36..5a94f65b75 100644 --- a/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_HAIKU /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines extern "C" { #include "../SDL_sysfilesystem.h" @@ -46,9 +46,9 @@ char *SDL_SYS_GetBasePath(void) BEntry entry(name, true); BPath path; - status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */ + status_t rc = entry.GetPath(&path); // (path) now has binary's path. SDL_assert(rc == B_OK); - rc = path.GetParent(&path); /* chop filename, keep directory. */ + rc = path.GetParent(&path); // chop filename, keep directory. SDL_assert(rc == B_OK); const char *str = path.Path(); SDL_assert(str != NULL); @@ -123,7 +123,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) return retval; - /* TODO: Is Haiku's desktop folder always ~/Desktop/ ? */ + // TODO: Is Haiku's desktop folder always ~/Desktop/ ? case SDL_FOLDER_DESKTOP: retval = (char *) SDL_malloc(SDL_strlen(home) + 10); if (!retval) { @@ -153,4 +153,4 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) } } -#endif /* SDL_FILESYSTEM_HAIKU */ +#endif // SDL_FILESYSTEM_HAIKU diff --git a/src/filesystem/n3ds/SDL_sysfilesystem.c b/src/filesystem/n3ds/SDL_sysfilesystem.c index c8d3665d17..a45eb3f078 100644 --- a/src/filesystem/n3ds/SDL_sysfilesystem.c +++ b/src/filesystem/n3ds/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_N3DS /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -61,7 +61,7 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return pref_path; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); @@ -87,4 +87,4 @@ static int CreatePrefPathDir(const char *pref) return 0; } -#endif /* SDL_FILESYSTEM_N3DS */ +#endif // SDL_FILESYSTEM_N3DS diff --git a/src/filesystem/posix/SDL_sysfsops.c b/src/filesystem/posix/SDL_sysfsops.c index 80c040c449..97749b6aea 100644 --- a/src/filesystem/posix/SDL_sysfsops.c +++ b/src/filesystem/posix/SDL_sysfsops.c @@ -24,7 +24,7 @@ #if defined(SDL_FSOPS_POSIX) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -180,7 +180,7 @@ int SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info) } #if defined(HAVE_ST_MTIM) - /* POSIX.1-2008 standard */ + // POSIX.1-2008 standard info->create_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_ctim.tv_sec) + statbuf.st_ctim.tv_nsec; info->modify_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_mtim.tv_sec) + statbuf.st_mtim.tv_nsec; info->access_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_atim.tv_sec) + statbuf.st_atim.tv_nsec; diff --git a/src/filesystem/ps2/SDL_sysfilesystem.c b/src/filesystem/ps2/SDL_sysfilesystem.c index a1c7e46d08..1feb1f93ce 100644 --- a/src/filesystem/ps2/SDL_sysfilesystem.c +++ b/src/filesystem/ps2/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_PS2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -46,7 +46,7 @@ char *SDL_SYS_GetBasePath(void) return retval; } -/* Do a recursive mkdir of parents folders */ +// Do a recursive mkdir of parents folders static void recursive_mkdir(const char *dir) { char tmp[FILENAME_MAX]; @@ -109,11 +109,11 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return retval; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); return NULL; } -#endif /* SDL_FILESYSTEM_PS2 */ +#endif // SDL_FILESYSTEM_PS2 diff --git a/src/filesystem/psp/SDL_sysfilesystem.c b/src/filesystem/psp/SDL_sysfilesystem.c index 37cc65e44b..35ce8d24d2 100644 --- a/src/filesystem/psp/SDL_sysfilesystem.c +++ b/src/filesystem/psp/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_PSP /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -79,11 +79,11 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return retval; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); return NULL; } -#endif /* SDL_FILESYSTEM_PSP */ +#endif // SDL_FILESYSTEM_PSP diff --git a/src/filesystem/riscos/SDL_sysfilesystem.c b/src/filesystem/riscos/SDL_sysfilesystem.c index ac5c3c0c70..c3d3cfca07 100644 --- a/src/filesystem/riscos/SDL_sysfilesystem.c +++ b/src/filesystem/riscos/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_RISCOS /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -31,10 +31,10 @@ #include #include -/* Wrapper around __unixify_std that uses SDL's memory allocators */ +// 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) { - const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */ + const char *const in_buf = buffer; // = NULL if we allocate the buffer. if (!buffer) { /* This matches the logic in __unixify, with an additional byte for the @@ -141,7 +141,7 @@ char *SDL_SYS_GetBasePath(void) return NULL; } - /* chop off filename. */ + // chop off filename. ptr = SDL_strrchr(canon, '.'); if (ptr) { *ptr = '\0'; @@ -198,11 +198,11 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return retval; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); return NULL; } -#endif /* SDL_FILESYSTEM_RISCOS */ +#endif // SDL_FILESYSTEM_RISCOS diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index d05d936d5c..44b6d7061c 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_UNIX /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -58,13 +58,13 @@ static char *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); @@ -97,28 +97,28 @@ static char *search_path_for_binary(const char *bin) 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'; } - /* build full binary path... */ + // build full binary path... SDL_snprintf(exe, alloc_size, "%s%s%s", start, (ptr && (ptr[-1] == '/')) ? "" : "/", bin); - if (access(exe, X_OK) == 0) { /* Exists as executable? We're done. */ + if (access(exe, X_OK) == 0) { // Exists as executable? We're done. SDL_free(envr); return exe; } } - start = ptr + 1; /* start points to beginning of next element. */ + start = ptr + 1; // start points to beginning of next element. } while (ptr); 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 @@ -138,7 +138,7 @@ char *SDL_SYS_GetBasePath(void) } #endif #ifdef SDL_PLATFORM_OPENBSD - /* Please note that this will fail if the process was launched with a relative path and $PWD + the cwd have changed, or argv is altered. So don't do that. Or add a new sysctl to OpenBSD. */ + // Please note that this will fail if the process was launched with a relative path and $PWD + the cwd have changed, or argv is altered. So don't do that. Or add a new sysctl to OpenBSD. char **cmdline; size_t len; const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; @@ -159,7 +159,7 @@ char *SDL_SYS_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 == '.') { @@ -195,7 +195,7 @@ char *SDL_SYS_GetBasePath(void) } #endif - /* is a Linux-style /proc filesystem available? */ + // is a Linux-style /proc filesystem available? if (!retval && (access("/proc", F_OK) == 0)) { /* !!! FIXME: after 2.0.6 ships, let's delete this code and just use the /proc/%llu version. There's no reason to have @@ -207,9 +207,9 @@ char *SDL_SYS_GetBasePath(void) #elif defined(SDL_PLATFORM_SOLARIS) retval = readSymLink("/proc/self/path/a.out"); #else - retval = readSymLink("/proc/self/exe"); /* linux. */ + retval = readSymLink("/proc/self/exe"); // linux. if (!retval) { - /* older kernels don't have /proc/self ... try PID version... */ + // older kernels don't have /proc/self ... try PID version... char path[64]; const int rc = SDL_snprintf(path, sizeof(path), "/proc/%llu/exe", @@ -221,10 +221,10 @@ char *SDL_SYS_GetBasePath(void) #endif } -#ifdef SDL_PLATFORM_SOLARIS /* try this as a fallback if /proc didn't pan out */ +#ifdef SDL_PLATFORM_SOLARIS // try this as a fallback if /proc didn't pan out if (!retval) { const char *path = getexecname(); - if ((path) && (path[0] == '/')) { /* must be absolute path... */ + if ((path) && (path[0] == '/')) { // must be absolute path... retval = SDL_strdup(path); if (!retval) { return NULL; @@ -235,21 +235,21 @@ char *SDL_SYS_GetBasePath(void) /* If we had access to argv[0] here, we could check it for a path, or troll through $PATH looking for it, too. */ - if (retval) { /* chop off filename. */ + if (retval) { // chop off filename. char *ptr = SDL_strrchr(retval, '/'); if (ptr) { *(ptr + 1) = '\0'; - } else { /* shouldn't happen, but just in case... */ + } else { // shouldn't happen, but just in case... SDL_free(retval); retval = NULL; } } if (retval) { - /* try to shrink buffer... */ + // try to shrink buffer... char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1); if (ptr) { - retval = ptr; /* oh well if it failed. */ + retval = ptr; // oh well if it failed. } } @@ -280,10 +280,10 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) } if (!envr) { - /* You end up with "$HOME/.local/share/Game Name 2" */ + // You end up with "$HOME/.local/share/Game Name 2" envr = SDL_getenv("HOME"); if (!envr) { - /* we could take heroic measures with /etc/passwd, but oh well. */ + // we could take heroic measures with /etc/passwd, but oh well. SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; } @@ -403,7 +403,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa user_dir = NULL; while (fgets (buffer, sizeof (buffer), file)) { - /* Remove newline at end */ + // Remove newline at end len = SDL_strlen (buffer); if (len > 0 && buffer[len-1] == '\n') buffer[len-1] = 0; @@ -500,7 +500,7 @@ static char *xdg_user_dir_lookup (const char *type) if (!home_dir) return NULL; - /* Special case desktop for historical compatibility */ + // Special case desktop for historical compatibility if (SDL_strcmp(type, "DESKTOP") == 0) { size_t length = SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1; user_dir = (char*) SDL_malloc(length); @@ -615,4 +615,4 @@ append_slash: return retval; } -#endif /* SDL_FILESYSTEM_UNIX */ +#endif // SDL_FILESYSTEM_UNIX diff --git a/src/filesystem/vita/SDL_sysfilesystem.c b/src/filesystem/vita/SDL_sysfilesystem.c index fb6000d3d7..884aa05897 100644 --- a/src/filesystem/vita/SDL_sysfilesystem.c +++ b/src/filesystem/vita/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_VITA /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -82,11 +82,11 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) return retval; } -/* TODO */ +// TODO char *SDL_SYS_GetUserFolder(SDL_Folder folder) { SDL_Unsupported(); return NULL; } -#endif /* SDL_FILESYSTEM_VITA */ +#endif // SDL_FILESYSTEM_VITA diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index 8c591a88fb..e3e9c62cd2 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -23,7 +23,7 @@ #ifdef SDL_FILESYSTEM_WINDOWS /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../SDL_sysfilesystem.h" @@ -31,7 +31,7 @@ #include #include -/* These aren't all defined in older SDKs, so define them here */ +// These aren't all defined in older SDKs, so define them here DEFINE_GUID(SDL_FOLDERID_Profile, 0x5E6C858F, 0x0E22, 0x4760, 0x9A, 0xFE, 0xEA, 0x33, 0x17, 0xB6, 0x71, 0x73); DEFINE_GUID(SDL_FOLDERID_Desktop, 0xB4BFCC3A, 0xDB2C, 0x424C, 0xB0, 0x29, 0x7F, 0xE9, 0x9A, 0x87, 0xC6, 0x41); DEFINE_GUID(SDL_FOLDERID_Documents, 0xFDD39AD0, 0x238F, 0x46AF, 0xAD, 0xB4, 0x6C, 0x85, 0x48, 0x03, 0x69, 0xC7); @@ -61,13 +61,13 @@ char *SDL_SYS_GetBasePath(void) path = (WCHAR *)ptr; len = GetModuleFileNameW(NULL, path, buflen); - /* if it truncated, then len >= buflen - 1 */ - /* if there was enough room (or failure), len < buflen - 1 */ + // if it truncated, then len >= buflen - 1 + // if there was enough room (or failure), len < buflen - 1 if (len < buflen - 1) { break; } - /* buffer too small? Try again. */ + // buffer too small? Try again. buflen *= 2; } @@ -83,8 +83,8 @@ char *SDL_SYS_GetBasePath(void) } } - 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); @@ -188,7 +188,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) } if (pSHGetKnownFolderPath) { - GUID type; /* KNOWNFOLDERID */ + GUID type; // KNOWNFOLDERID HRESULT result; wchar_t *path; @@ -304,11 +304,11 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) goto done; }; - /* Create the OS-specific folder if it doesn't already exist */ + // Create the OS-specific folder if it doesn't already exist type |= CSIDL_FLAG_CREATE; #if 0 - /* Apparently the oldest, but not supported in modern Windows */ + // Apparently the oldest, but not supported in modern Windows HRESULT result = SHGetSpecialFolderPath(NULL, path, type, TRUE); #endif @@ -316,7 +316,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) available), available in Wine (tested 6.0.3) */ result = SHGetFolderPathW(NULL, type, NULL, SHGFP_TYPE_CURRENT, path); - /* use `== TRUE` for SHGetSpecialFolderPath */ + // use `== TRUE` for SHGetSpecialFolderPath if (SUCCEEDED(result)) { retval = WIN_StringToUTF8W(path); } else { @@ -329,7 +329,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) if (!newretval) { SDL_free(retval); - retval = NULL; /* will be returned */ + retval = NULL; // will be returned goto done; } @@ -343,4 +343,4 @@ done: } return retval; } -#endif /* SDL_FILESYSTEM_WINDOWS */ +#endif // SDL_FILESYSTEM_WINDOWS diff --git a/src/filesystem/windows/SDL_sysfsops.c b/src/filesystem/windows/SDL_sysfsops.c index b4e9b4db9f..621ae9e839 100644 --- a/src/filesystem/windows/SDL_sysfsops.c +++ b/src/filesystem/windows/SDL_sysfsops.c @@ -24,7 +24,7 @@ #if defined(SDL_FSOPS_WINDOWS) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines #include "../../core/windows/SDL_windows.h" #include "../SDL_sysfilesystem.h" diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index df16663e07..d2f35c2025 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -26,7 +26,7 @@ #ifdef SDL_PLATFORM_WINRT /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent filesystem routines */ +// System dependent filesystem routines extern "C" { #include "../../core/windows/SDL_windows.h" @@ -46,8 +46,8 @@ static const wchar_t *SDL_GetWinRTFSPathUNICODE(SDL_WinRT_Path pathType) { 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 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 { @@ -259,4 +259,4 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder) return WIN_StringToUTF8W(wpath.c_str()); } -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index e392a2aa35..7945b50598 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -22,7 +22,7 @@ #include "SDL_syshaptic.h" #include "SDL_haptic_c.h" -#include "../joystick/SDL_joystick_c.h" /* For SDL_IsJoystickValid */ +#include "../joystick/SDL_joystick_c.h" // For SDL_IsJoystickValid static SDL_Haptic *SDL_haptics = NULL; @@ -127,13 +127,13 @@ SDL_Haptic *SDL_OpenHaptic(SDL_HapticID instance_id) hapticlist = hapticlist->next; } - /* Create the haptic device */ + // Create the haptic device haptic = (SDL_Haptic *)SDL_calloc(1, sizeof(*haptic)); if (!haptic) { return NULL; } - /* Initialize the haptic device */ + // Initialize the haptic device SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_TRUE); haptic->instance_id = instance_id; haptic->rumble_id = -1; @@ -149,13 +149,13 @@ SDL_Haptic *SDL_OpenHaptic(SDL_HapticID instance_id) } } - /* Add haptic to list */ + // Add haptic to list ++haptic->ref_count; - /* Link the haptic in the list */ + // Link the haptic in the list haptic->next = SDL_haptics; SDL_haptics = haptic; - /* Disable autocenter and set gain to max. */ + // Disable autocenter and set gain to max. if (haptic->supported & SDL_HAPTIC_GAIN) { SDL_SetHapticGain(haptic, 100); } @@ -220,7 +220,7 @@ SDL_bool SDL_IsJoystickHaptic(SDL_Joystick *joystick) SDL_LockJoysticks(); { - /* Must be a valid joystick */ + // Must be a valid joystick if (SDL_IsJoystickValid(joystick) && !SDL_IsGamepad(SDL_GetJoystickID(joystick))) { result = SDL_SYS_JoystickIsHaptic(joystick); @@ -238,14 +238,14 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick) SDL_LockJoysticks(); { - /* Must be a valid joystick */ + // Must be a valid joystick if (!SDL_IsJoystickValid(joystick)) { SDL_SetError("Haptic: Joystick isn't valid."); SDL_UnlockJoysticks(); return NULL; } - /* Joystick must be haptic */ + // Joystick must be haptic if (SDL_IsGamepad(SDL_GetJoystickID(joystick)) || SDL_SYS_JoystickIsHaptic(joystick) <= 0) { SDL_SetError("Haptic: Joystick isn't a haptic device."); @@ -254,7 +254,7 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick) } hapticlist = SDL_haptics; - /* Check to see if joystick's haptic is already open */ + // Check to see if joystick's haptic is already open while (hapticlist) { if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) { haptic = hapticlist; @@ -265,7 +265,7 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick) hapticlist = hapticlist->next; } - /* Create the haptic device */ + // Create the haptic device haptic = (SDL_Haptic *)SDL_calloc(1, sizeof(*haptic)); if (!haptic) { SDL_UnlockJoysticks(); @@ -286,9 +286,9 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick) } SDL_UnlockJoysticks(); - /* Add haptic to list */ + // Add haptic to list ++haptic->ref_count; - /* Link the haptic in the list */ + // Link the haptic in the list haptic->next = SDL_haptics; SDL_haptics = haptic; @@ -303,12 +303,12 @@ void SDL_CloseHaptic(SDL_Haptic *haptic) CHECK_HAPTIC_MAGIC(haptic,); - /* Check if it's still in use */ + // Check if it's still in use if (--haptic->ref_count > 0) { return; } - /* Close it, properly removing effects if needed */ + // Close it, properly removing effects if needed for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect != NULL) { SDL_DestroyHapticEffect(haptic, i); @@ -317,13 +317,13 @@ void SDL_CloseHaptic(SDL_Haptic *haptic) SDL_SYS_HapticClose(haptic); SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_FALSE); - /* Remove from the list */ + // Remove from the list hapticlist = SDL_haptics; hapticlistprev = NULL; while (hapticlist) { if (haptic == hapticlist) { if (hapticlistprev) { - /* unlink this entry */ + // unlink this entry hapticlistprev->next = hapticlist->next; } else { SDL_haptics = haptic->next; @@ -335,7 +335,7 @@ void SDL_CloseHaptic(SDL_Haptic *haptic) hapticlist = hapticlist->next; } - /* Free the data associated with this device */ + // Free the data associated with this device SDL_free(haptic->name); SDL_free(haptic); } @@ -401,18 +401,18 @@ int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect) return SDL_InvalidParamError("effect"); } - /* Check to see if effect is supported */ + // Check to see if effect is supported if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) { return SDL_SetError("Haptic: Effect not supported by haptic device."); } - /* See if there's a free slot */ + // See if there's a free slot for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect == NULL) { - /* Now let the backend create the real effect */ + // 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 */ + return -1; // Backend failed to create effect } SDL_memcpy(&haptic->effects[i].effect, effect, @@ -445,12 +445,12 @@ int SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffec return SDL_InvalidParamError("data"); } - /* Can't change type dynamically. */ + // Can't change type dynamically. if (data->type != haptic->effects[effect].effect.type) { return SDL_SetError("Haptic: Updating effect type is illegal."); } - /* Updates the effect */ + // Updates the effect if (SDL_SYS_HapticUpdateEffect(haptic, &haptic->effects[effect], data) < 0) { return -1; @@ -469,7 +469,7 @@ int SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations) return -1; } - /* Run the effect */ + // Run the effect if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations) < 0) { return -1; } @@ -485,7 +485,7 @@ int SDL_StopHapticEffect(SDL_Haptic *haptic, int effect) return -1; } - /* Stop the effect */ + // Stop the effect if (SDL_SYS_HapticStopEffect(haptic, &haptic->effects[effect]) < 0) { return -1; } @@ -501,7 +501,7 @@ void SDL_DestroyHapticEffect(SDL_Haptic *haptic, int effect) return; } - /* Not allocated */ + // Not allocated if (haptic->effects[effect].hweffect == NULL) { return; } @@ -539,19 +539,19 @@ int SDL_SetHapticGain(SDL_Haptic *haptic, int gain) return SDL_SetError("Haptic: Gain must be between 0 and 100."); } - /* The user can use an environment variable to override the max gain. */ + // The user can use an environment variable to override the max gain. env = SDL_getenv("SDL_HAPTIC_GAIN_MAX"); if (env) { max_gain = SDL_atoi(env); - /* Check for sanity. */ + // Check for sanity. if (max_gain < 0) { max_gain = 0; } else if (max_gain > 100) { max_gain = 100; } - /* We'll scale it linearly with SDL_HAPTIC_GAIN_MAX */ + // We'll scale it linearly with SDL_HAPTIC_GAIN_MAX real_gain = (gain * max_gain) / 100; } else { real_gain = gain; @@ -599,7 +599,7 @@ int SDL_ResumeHaptic(SDL_Haptic *haptic) CHECK_HAPTIC_MAGIC(haptic, -1); if (!(haptic->supported & SDL_HAPTIC_PAUSE)) { - 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); @@ -616,7 +616,7 @@ SDL_bool SDL_HapticRumbleSupported(SDL_Haptic *haptic) { CHECK_HAPTIC_MAGIC(haptic, SDL_FALSE); - /* Most things can use SINE, but XInput only has LEFTRIGHT. */ + // Most things can use SINE, but XInput only has LEFTRIGHT. return (haptic->supported & (SDL_HAPTIC_SINE | SDL_HAPTIC_LEFTRIGHT)) != 0; } @@ -626,7 +626,7 @@ int SDL_InitHapticRumble(SDL_Haptic *haptic) CHECK_HAPTIC_MAGIC(haptic, -1); - /* Already allocated. */ + // Already allocated. if (haptic->rumble_id >= 0) { return 0; } @@ -640,7 +640,7 @@ int SDL_InitHapticRumble(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; @@ -667,7 +667,7 @@ int SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length) return SDL_SetError("Haptic: Rumble effect not initialized on haptic device"); } - /* Clamp strength. */ + // Clamp strength. if (strength > 1.0f) { strength = 1.0f; } else if (strength < 0.0f) { diff --git a/src/haptic/SDL_haptic_c.h b/src/haptic/SDL_haptic_c.h index 06ef1be092..0044fbfa87 100644 --- a/src/haptic/SDL_haptic_c.h +++ b/src/haptic/SDL_haptic_c.h @@ -25,4 +25,4 @@ extern int SDL_InitHaptics(void); extern void SDL_QuitHaptics(void); -#endif /* SDL_haptic_c_h_ */ +#endif // SDL_haptic_c_h_ diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index aac73bbe74..a14a55e3c5 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -24,15 +24,15 @@ #ifndef SDL_syshaptic_h_ #define SDL_syshaptic_h_ -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif 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 }; /* @@ -40,21 +40,21 @@ struct haptic_effect */ struct SDL_Haptic { - SDL_HapticID instance_id; /* Device instance, monotonically increasing from 0 */ - char *name; /* Device name - system dependent */ + SDL_HapticID instance_id; // Device instance, monotonically increasing from 0 + char *name; // Device name - system dependent - struct haptic_effect *effects; /* Allocated effects */ - int neffects; /* Maximum amount of effects */ - int nplaying; /* Maximum amount of effects to play at the same time */ - Uint32 supported; /* Supported effects and features */ - 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 + Uint32 supported; // Supported effects and features + 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. */ - SDL_HapticEffect rumble_effect; /* Rumble effect. */ - struct SDL_Haptic *next; /* pointer to next haptic we have allocated */ + 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 }; /* @@ -64,7 +64,7 @@ struct SDL_Haptic */ extern int SDL_SYS_HapticInit(void); -/* Function to return the number of haptic devices plugged in right now */ +// Function to return the number of haptic devices plugged in right now extern int SDL_SYS_NumHaptics(void); /* @@ -208,9 +208,9 @@ extern int SDL_SYS_HapticUnpause(SDL_Haptic *haptic); */ extern int SDL_SYS_HapticStopAll(SDL_Haptic *haptic); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_syshaptic_h_ */ +#endif // SDL_syshaptic_h_ diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index e7de6da05d..7dc901554b 100644 --- a/src/haptic/android/SDL_syshaptic.c +++ b/src/haptic/android/SDL_syshaptic.c @@ -277,7 +277,7 @@ int Android_RemoveHaptic(int device_id) SDL_hapticlist_item *prev = NULL; for (item = SDL_hapticlist; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (device_id == item->device_id) { const int retval = item->haptic ? 0 : -1; @@ -291,9 +291,9 @@ int Android_RemoveHaptic(int device_id) SDL_hapticlist_tail = prev; } - /* Need to decrement the haptic count */ + // Need to decrement the haptic count --numhaptics; - /* !!! TODO: Send a haptic remove event? */ + // !!! TODO: Send a haptic remove event? SDL_free(item->name); SDL_free(item); @@ -304,4 +304,4 @@ int Android_RemoveHaptic(int device_id) return -1; } -#endif /* SDL_HAPTIC_ANDROID */ +#endif // SDL_HAPTIC_ANDROID diff --git a/src/haptic/android/SDL_syshaptic_c.h b/src/haptic/android/SDL_syshaptic_c.h index f07f4e1ded..2359fc38a9 100644 --- a/src/haptic/android/SDL_syshaptic_c.h +++ b/src/haptic/android/SDL_syshaptic_c.h @@ -25,4 +25,4 @@ extern int Android_AddHaptic(int device_id, const char *name); extern int Android_RemoveHaptic(int device_id); -#endif /* SDL_HAPTIC_ANDROID */ +#endif // SDL_HAPTIC_ANDROID diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 897c45c1c3..3f770781ec 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -23,8 +23,8 @@ #ifdef SDL_HAPTIC_IOKIT #include "../SDL_syshaptic.h" -#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ -#include "../../joystick/darwin/SDL_iokitjoystick_c.h" /* For joystick hwdata */ +#include "../../joystick/SDL_sysjoystick.h" // For the real SDL_Joystick +#include "../../joystick/darwin/SDL_iokitjoystick_c.h" // For joystick hwdata #include "SDL_syshaptic_c.h" #include @@ -43,12 +43,12 @@ typedef struct SDL_hapticlist_item { SDL_HapticID instance_id; - 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. */ + // Usage pages for determining if it's a mouse or not. long usage; long usagePage; @@ -60,7 +60,7 @@ typedef struct SDL_hapticlist_item */ struct haptic_hwdata { - FFDeviceObjectReference device; /* Hardware device. */ + FFDeviceObjectReference device; // Hardware device. UInt8 axes[3]; }; @@ -69,8 +69,8 @@ struct haptic_hwdata */ struct haptic_hweffect { - FFEffectObjectReference ref; /* Reference. */ - struct FFEFFECT effect; /* Hardware effect. */ + FFEffectObjectReference ref; // Reference. + struct FFEFFECT effect; // Hardware effect. }; /* @@ -91,7 +91,7 @@ static const char *FFStrError(unsigned int err) switch (err) { case FFERR_DEVICEFULL: return "device full"; - /* This should be valid, but for some reason isn't defined... */ + // This should be valid, but for some reason isn't defined... /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: @@ -153,26 +153,26 @@ int SDL_SYS_HapticInit(void) } numhaptics = 0; - /* Get HID devices. */ + // Get HID devices. match = IOServiceMatching(kIOHIDDeviceKey); if (!match) { return SDL_SetError("Haptic: Failed to get IOServiceMatching."); } - /* Now search I/O Registry for matching devices. */ + // Now search I/O Registry for matching devices. result = IOServiceGetMatchingServices(kIOMainPortDefault, match, &iter); if (result != kIOReturnSuccess) { return SDL_SetError("Haptic: Couldn't create a HID object iterator."); } - /* IOServiceGetMatchingServices consumes dictionary. */ + // IOServiceGetMatchingServices consumes dictionary. - if (!IOIteratorIsValid(iter)) { /* No iterator. */ + if (!IOIteratorIsValid(iter)) { // No iterator. return 0; } while ((device = IOIteratorNext(iter)) != IO_OBJECT_NULL) { MacHaptic_MaybeAddDevice(device); - /* always release as the AddDevice will retain IF it's a forcefeedback device */ + // always release as the AddDevice will retain IF it's a forcefeedback device IOObjectRelease(device); } IOObjectRelease(iter); @@ -221,18 +221,18 @@ int MacHaptic_MaybeAddDevice(io_object_t device) SDL_hapticlist_item *item; if (numhaptics == -1) { - 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. } - /* Check for force feedback. */ + // Check for force feedback. if (FFIsForceFeedback(device) != FF_OK) { return -1; } - /* Make sure we don't already have it */ + // Make sure we don't already have it for (item = SDL_hapticlist; item; item = item->next) { if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { - /* Already added */ + // Already added return -1; } } @@ -243,14 +243,14 @@ int MacHaptic_MaybeAddDevice(io_object_t device) } item->instance_id = SDL_GetNextObjectID(); - /* retain it as we are going to keep it around a while */ + // retain it as we are going to keep it around a while IOObjectRetain(device); - /* Set basic device data. */ + // Set basic device data. HIDGetDeviceProduct(device, item->name); item->dev = device; - /* Set usage pages. */ + // Set usage pages. hidProperties = 0; refCF = 0; result = IORegistryEntryCreateCFProperties(device, @@ -282,7 +282,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device) SDL_hapticlist_tail = item; } - /* Device has been added. */ + // Device has been added. ++numhaptics; return numhaptics; @@ -294,11 +294,11 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device) SDL_hapticlist_item *prev = NULL; if (numhaptics == -1) { - return -1; /* not initialized. ignore this. */ + return -1; // not initialized. ignore this. } for (item = SDL_hapticlist; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { const int retval = item->haptic ? 0 : -1; @@ -312,9 +312,9 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device) SDL_hapticlist_tail = prev; } - /* Need to decrement the haptic count */ + // Need to decrement the haptic count --numhaptics; - /* !!! TODO: Send a haptic remove event? */ + // !!! TODO: Send a haptic remove event? IOObjectRelease(item->dev); SDL_free(item); @@ -383,7 +383,7 @@ static int HIDGetDeviceProduct(io_service_t dev, char *name) * try hid dictionary first, if fail then go to USB dictionary */ - /* Get product name */ + // Get product name refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); if (!refCF) { refCF = CFDictionaryGetValue(usbProperties, @@ -401,7 +401,7 @@ static int HIDGetDeviceProduct(io_service_t dev, char *name) return SDL_SetError("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties."); } - /* Release stuff. */ + // Release stuff. if (kIOReturnSuccess != IOObjectRelease(parent2)) { SDL_SetError("Haptic: IOObjectRelease error with parent2."); } @@ -438,11 +438,11 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic) supported = 0; - /* Get maximum effects. */ + // Get maximum effects. haptic->neffects = features.storageCapacity; haptic->nplaying = features.playbackCapacity; - /* Test for effects. */ + // Test for effects. FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); @@ -456,7 +456,7 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic) FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION); FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM); - /* Check if supports gain. */ + // Check if supports gain. ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN, &val, sizeof(val)); if (ret == FF_OK) { @@ -466,7 +466,7 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic) FFStrError(ret)); } - /* Checks if supports autocenter. */ + // Checks if supports autocenter. ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER, &val, sizeof(val)); if (ret == FF_OK) { @@ -476,13 +476,13 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic) FFStrError(ret)); } - /* Check for axes, we have an artificial limit on axes */ + // Check for axes, we have an artificial limit on axes haptic->naxes = ((features.numFfAxes) > 3) ? 3 : features.numFfAxes; - /* Actually store the axes we want to use */ + // Actually store the axes we want to use SDL_memcpy(haptic->hwdata->axes, features.ffAxes, haptic->naxes * sizeof(Uint8)); - /* Always supported features. */ + // Always supported features. supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; haptic->supported = supported; @@ -497,26 +497,26 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic HRESULT ret; int ret2; - /* Allocate the hwdata */ + // Allocate the hwdata haptic->hwdata = (struct haptic_hwdata *) SDL_calloc(1, sizeof(*haptic->hwdata)); if (!haptic->hwdata) { goto creat_err; } - /* Open the device */ + // Open the device ret = FFCreateDevice(service, &haptic->hwdata->device); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to create device from service: %s.", FFStrError(ret)); goto creat_err; } - /* Get supported features. */ + // Get supported features. ret2 = GetSupportedFeatures(haptic); if (ret2 < 0) { goto open_err; } - /* Reset and then enable actuators. */ + // Reset and then enable actuators. ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_RESET); if (ret != FF_OK) { @@ -531,19 +531,19 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic goto open_err; } - /* Allocate effects memory. */ + // Allocate effects memory. haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (!haptic->effects) { goto open_err; } - /* Clear the memory */ + // Clear the memory SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; - /* Error handling */ + // Error handling open_err: FFReleaseDevice(haptic->hwdata->device); creat_err: @@ -653,15 +653,15 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { - /* Free Effects. */ + // Free Effects. SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; - /* Clean up */ + // Clean up FFReleaseDevice(haptic->hwdata->device); - /* Free */ + // Free SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -680,7 +680,7 @@ void SDL_SYS_HapticQuit(void) /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ - /* Free the io_service_t */ + // Free the io_service_t IOObjectRelease(item->dev); SDL_free(item); } @@ -713,14 +713,14 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, const SDL_HapticDirection *dir { LONG *rglDir; - /* Handle no axes a part. */ + // 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; } - /* Has axes. */ + // Has axes. rglDir = SDL_malloc(sizeof(LONG) * naxes); if (!rglDir) { return -1; @@ -763,9 +763,9 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, const SDL_HapticDirection *dir } } -/* Clamps and converts. */ +// Clamps and converts. #define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) -/* Just converts. */ +// Just converts. #define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the FFEFFECT from a SDL_HapticEffect. @@ -775,7 +775,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt 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; @@ -786,22 +786,22 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt const SDL_HapticCustom *hap_custom = NULL; DWORD *axes = NULL; - /* Set global stuff. */ + // 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. envelope = SDL_calloc(1, sizeof(FFENVELOPE)); if (!envelope) { return -1; } dest->lpEnvelope = envelope; - envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ + envelope->dwSize = sizeof(FFENVELOPE); // Always should be this. - /* Axes. */ + // Axes. if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) { dest->cAxes = 1; } else { @@ -812,7 +812,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt if (!axes) { return -1; } - 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]; } @@ -822,7 +822,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt dest->rgdwAxes = axes; } - /* The big type handling switch, even bigger then Linux's version. */ + // The big type handling switch, even bigger then Linux's version. switch (src->type) { case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; @@ -831,23 +831,23 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt return -1; } - /* Specifics */ + // Specifics constant->lMagnitude = CONVERT(hap_constant->level); dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); dest->lpvTypeSpecificParams = constant; - /* Generics */ - dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ + // Generics + 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. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; @@ -871,7 +871,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt return -1; } - /* Specifics */ + // Specifics periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); periodic->dwPhase = @@ -880,18 +880,18 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt dest->cbTypeSpecificParams = sizeof(FFPERIODIC); dest->lpvTypeSpecificParams = periodic; - /* Generics */ - dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ + // Generics + 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. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; @@ -915,7 +915,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt return -1; } - /* Specifics */ + // Specifics for (i = 0; i < dest->cAxes; i++) { condition[i].lOffset = CONVERT(hap_condition->center[i]); condition[i].lPositiveCoefficient = @@ -933,18 +933,18 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; - /* Generics */ - dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ + // Generics + 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. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } - /* Envelope - Not actually supported by most CONDITION implementations. */ + // Envelope - Not actually supported by most CONDITION implementations. SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -957,24 +957,24 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt return -1; } - /* Specifics */ + // Specifics ramp->lStart = CONVERT(hap_ramp->start); ramp->lEnd = CONVERT(hap_ramp->end); dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE); dest->lpvTypeSpecificParams = ramp; - /* Generics */ - dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ + // Generics + 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. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; @@ -994,31 +994,31 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt return -1; } - /* Specifics */ + // Specifics custom->cChannels = hap_custom->channels; custom->dwSamplePeriod = hap_custom->period * 1000; 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. */ + // Generics + 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. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; @@ -1050,7 +1050,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type) SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams) { - if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ + if (type == SDL_HAPTIC_CUSTOM) { // Must free the custom data. custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; @@ -1120,25 +1120,25 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, HRESULT ret; CFUUIDRef type; - /* Alloc the effect. */ + // Alloc the effect. effect->hweffect = (struct haptic_hweffect *) SDL_calloc(1, sizeof(struct haptic_hweffect)); if (!effect->hweffect) { goto err_hweffect; } - /* Get the type. */ + // Get the type. type = SDL_SYS_HapticEffectType(base->type); if (!type) { goto err_hweffect; } - /* Get the effect. */ + // Get the effect. if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) { goto err_effectdone; } - /* Create the actual effect. */ + // Create the actual effect. ret = FFDeviceCreateEffect(haptic->hwdata->device, type, &effect->hweffect->effect, &effect->hweffect->ref); @@ -1168,7 +1168,7 @@ int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, FFEffectParameterFlag flags; FFEFFECT temp; - /* Get the effect. */ + // Get the effect. SDL_memset(&temp, 0, sizeof(FFEFFECT)); if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) { goto err_update; @@ -1183,14 +1183,14 @@ int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, FFEP_TRIGGERBUTTON | FFEP_TRIGGERREPEATINTERVAL | FFEP_TYPESPECIFICPARAMS; - /* Create the actual effect. */ + // Create the actual effect. ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret)); goto err_update; } - /* Copy it over. */ + // Copy it over. SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type); SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT)); @@ -1210,14 +1210,14 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, HRESULT ret; Uint32 iter; - /* Check if it's infinite. */ + // Check if it's infinite. if (iterations == SDL_HAPTIC_INFINITY) { iter = FF_INFINITE; } else { iter = iterations; } - /* Run the effect. */ + // Run the effect. ret = FFEffectStart(effect->hweffect->ref, iter, 0); if (ret != FF_OK) { return SDL_SetError("Haptic: Unable to run the effect: %s.", @@ -1279,7 +1279,7 @@ int 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. } /* @@ -1290,7 +1290,7 @@ int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain) HRESULT ret; Uint32 val; - val = gain * 100; /* macOS uses 0 to 10,000 */ + val = gain * 100; // macOS uses 0 to 10,000 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, FFPROP_FFGAIN, &val); if (ret != FF_OK) { @@ -1308,7 +1308,7 @@ int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) HRESULT ret; Uint32 val; - /* macOS only has 0 (off) and 1 (on) */ + // macOS only has 0 (off) and 1 (on) if (autocenter == 0) { val = 0; } else { @@ -1373,4 +1373,4 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) return 0; } -#endif /* SDL_HAPTIC_IOKIT */ +#endif // SDL_HAPTIC_IOKIT diff --git a/src/haptic/darwin/SDL_syshaptic_c.h b/src/haptic/darwin/SDL_syshaptic_c.h index 67bc86358d..13682ffd17 100644 --- a/src/haptic/darwin/SDL_syshaptic_c.h +++ b/src/haptic/darwin/SDL_syshaptic_c.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ +// Things named "Master" were renamed to "Main" in macOS 12.0's SDK. #include #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 #define kIOMainPortDefault kIOMasterPortDefault diff --git a/src/haptic/dummy/SDL_syshaptic.c b/src/haptic/dummy/SDL_syshaptic.c index 6a0f89ee8a..3c1115da75 100644 --- a/src/haptic/dummy/SDL_syshaptic.c +++ b/src/haptic/dummy/SDL_syshaptic.c @@ -147,4 +147,4 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) return SDL_SYS_LogicError(); } -#endif /* SDL_HAPTIC_DUMMY || SDL_HAPTIC_DISABLED */ +#endif // SDL_HAPTIC_DUMMY || SDL_HAPTIC_DISABLED diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 6664c1788c..b9afe56b6d 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -23,26 +23,26 @@ #ifdef SDL_HAPTIC_LINUX #include "../SDL_syshaptic.h" -#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ -#include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */ +#include "../../joystick/SDL_sysjoystick.h" // For the real SDL_Joystick +#include "../../joystick/linux/SDL_sysjoystick_c.h" // For joystick hwdata #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 */ -#include /* strerror */ -#include /* stat */ +#include // close +#include // Force feedback linux stuff. +#include // O_RDWR +#include // INT_MAX +#include // errno +#include // strerror +#include // stat -#define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */ +#define MAX_HAPTICS 32 // It's doubtful someone has more then 32 evdev static int MaybeAddDevice(const char *path); #ifdef SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char *path); static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV /* * List of available haptic devices. @@ -50,8 +50,8 @@ static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, typedef struct SDL_hapticlist_item { SDL_HapticID instance_id; - 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; @@ -61,8 +61,8 @@ typedef struct SDL_hapticlist_item */ 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. }; /* @@ -70,7 +70,7 @@ struct haptic_hwdata */ 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; @@ -90,14 +90,14 @@ static int EV_IsHaptic(int fd) unsigned int ret; unsigned long features[1 + FF_MAX / sizeof(unsigned long)]; - /* Ask device for what it has. */ + // Ask device for what it has. ret = 0; if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(features)), features) < 0) { return SDL_SetError("Haptic: Unable to get device's features: %s", strerror(errno)); } - /* Convert supported features to SDL_HAPTIC platform-neutral features. */ + // Convert supported features to SDL_HAPTIC platform-neutral features. EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_SINE, SDL_HAPTIC_SINE); EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); @@ -114,7 +114,7 @@ static int EV_IsHaptic(int fd) EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER); EV_TEST(FF_RUMBLE, SDL_HAPTIC_LEFTRIGHT); - /* Return what it supports. */ + // Return what it supports. return ret; } @@ -125,12 +125,12 @@ static int EV_IsMouse(int fd) { unsigned long argp[40]; - /* Ask for supported features. */ + // Ask for supported features. if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(argp)), argp) < 0) { return -1; } - /* Currently we only test for BTN_MOUSE which can give fake positives. */ + // Currently we only test for BTN_MOUSE which can give fake positives. if (test_bit(BTN_MOUSE, argp) != 0) { return 1; } @@ -167,9 +167,9 @@ int SDL_SYS_HapticInit(void) return SDL_SetError("Could not setup haptic <-> udev callback"); } - /* Force a scan to build the initial device list */ + // Force a scan to build the initial device list SDL_UDEV_Scan(); -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV return numhaptics; } @@ -227,7 +227,7 @@ static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, break; } } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV static int MaybeAddDevice(const char *path) { @@ -240,23 +240,23 @@ static int MaybeAddDevice(const char *path) return -1; } - /* try to open */ + // try to open fd = open(path, O_RDWR | O_CLOEXEC, 0); if (fd < 0) { return -1; } - /* get file status */ + // get file status if (fstat(fd, &sb) != 0) { close(fd); return -1; } - /* check for duplicates */ + // check for duplicates for (item = SDL_hapticlist; item; item = item->next) { if (item->dev_num == sb.st_rdev) { close(fd); - return -1; /* duplicate. */ + return -1; // duplicate. } } @@ -264,7 +264,7 @@ static int MaybeAddDevice(const char *path) printf("Checking %s\n", path); #endif - /* see if it works */ + // see if it works success = EV_IsHaptic(fd); close(fd); if (success <= 0) { @@ -285,7 +285,7 @@ static int MaybeAddDevice(const char *path) item->dev_num = sb.st_rdev; - /* TODO: should we add instance IDs? */ + // TODO: should we add instance IDs? if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { @@ -295,7 +295,7 @@ static int MaybeAddDevice(const char *path) ++numhaptics; - /* !!! TODO: Send a haptic add event? */ + // !!! TODO: Send a haptic add event? return numhaptics; } @@ -311,7 +311,7 @@ static int MaybeRemoveDevice(const char *path) } for (item = SDL_hapticlist; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (SDL_strcmp(path, item->fname) == 0) { const int retval = item->haptic ? 0 : -1; @@ -325,9 +325,9 @@ static int MaybeRemoveDevice(const char *path) SDL_hapticlist_tail = prev; } - /* Need to decrement the haptic count */ + // Need to decrement the haptic count --numhaptics; - /* !!! TODO: Send a haptic remove event? */ + // !!! TODO: Send a haptic remove event? SDL_free(item->fname); SDL_free(item); @@ -338,7 +338,7 @@ static int MaybeRemoveDevice(const char *path) return -1; } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV /* * Return the instance ID of a haptic device, does not need to be opened. @@ -361,7 +361,7 @@ static const char *SDL_SYS_HapticNameFromFD(int fd) { static char namebuf[128]; - /* We use the evdev name ioctl. */ + // We use the evdev name ioctl. if (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) { return NULL; } @@ -380,14 +380,14 @@ const char *SDL_SYS_HapticName(int index) item = HapticByDevIndex(index); if (item) { - /* Open the haptic device. */ + // Open the haptic device. fd = open(item->fname, O_RDONLY | O_CLOEXEC, 0); if (fd >= 0) { name = SDL_SYS_HapticNameFromFD(fd); if (!name) { - /* No name found, return device character device */ + // No name found, return device character device name = item->fname; } close(fd); @@ -401,37 +401,37 @@ const char *SDL_SYS_HapticName(int index) */ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) { - /* Allocate the hwdata */ + // Allocate the hwdata haptic->hwdata = (struct haptic_hwdata *) SDL_calloc(1, sizeof(*haptic->hwdata)); if (!haptic->hwdata) { goto open_err; } - /* Set the data. */ + // 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 */ + // Set the effects if (ioctl(fd, EVIOCGEFFECTS, &haptic->neffects) < 0) { SDL_SetError("Haptic: Unable to query device memory: %s", 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) { goto open_err; } - /* Clear the memory */ + // Clear the memory SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; - /* Error handling */ + // Error handling open_err: close(fd); if (haptic->hwdata) { @@ -451,20 +451,20 @@ int SDL_SYS_HapticOpen(SDL_Haptic *haptic) SDL_hapticlist_item *item; item = HapticByInstanceID(haptic->instance_id); - /* Open the character device */ + // Open the character device fd = open(item->fname, O_RDWR | O_CLOEXEC, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", item->fname, strerror(errno)); } - /* Try to create the haptic. */ - ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */ + // Try to create the haptic. + ret = SDL_SYS_HapticOpenFromFD(haptic, fd); // Already closes on error. if (ret < 0) { return -1; } - /* Set the fname. */ + // Set the fname. haptic->hwdata->fname = SDL_strdup(item->fname); return 0; } @@ -479,14 +479,14 @@ int SDL_SYS_HapticMouse(void) SDL_hapticlist_item *item; for (item = SDL_hapticlist; item; item = item->next) { - /* Open the device. */ + // Open the device. fd = open(item->fname, O_RDWR | O_CLOEXEC, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", item->fname, strerror(errno)); } - /* Is it a mouse? */ + // Is it a mouse? if (EV_IsMouse(fd)) { close(fd); return device_index; @@ -554,7 +554,7 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) if (joystick->driver != &SDL_LINUX_JoystickDriver) { return -1; } - /* Find the joystick in the haptic list. */ + // Find the joystick in the haptic list. for (item = SDL_hapticlist; item; item = item->next) { if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) { haptic->instance_id = item->instance_id; @@ -567,7 +567,7 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) return SDL_SetError("Haptic: Unable to open %s: %s", joystick->hwdata->fname, strerror(errno)); } - ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */ + ret = SDL_SYS_HapticOpenFromFD(haptic, fd); // Already closes on error. if (ret < 0) { return -1; } @@ -591,21 +591,21 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { - /* Free effects. */ + // Free effects. SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; - /* Clean up */ + // Clean up close(haptic->hwdata->fd); - /* Free */ + // Free SDL_free(haptic->hwdata->fname); SDL_free(haptic->hwdata); haptic->hwdata = NULL; } - /* Clear the rest. */ + // Clear the rest. SDL_memset(haptic, 0, sizeof(SDL_Haptic)); } @@ -628,7 +628,7 @@ void SDL_SYS_HapticQuit(void) #ifdef SDL_USE_LIBUDEV SDL_UDEV_DelCallback(haptic_udev_callback); SDL_UDEV_Quit(); -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV numhaptics = 0; SDL_hapticlist = NULL; @@ -664,7 +664,7 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src) switch (src->type) { case SDL_HAPTIC_POLAR: - tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ + tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; // convert to range [0,0xFFFF] *dest = (Uint16)tmp; break; @@ -677,8 +677,8 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src) --> 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] */ + tmp = ((src->dir[0]) + 9000) % 36000; // Convert to polars + tmp = (tmp * 0x8000) / 18000; // convert to range [0,0xFFFF] *dest = (Uint16)tmp; break; @@ -688,7 +688,7 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src) } else if (!src->dir[0]) { *dest = (src->dir[1] >= 0 ? 0x8000 : 0); } else { - float f = SDL_atan2f(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ + float f = SDL_atan2f(src->dir[1], src->dir[0]); // Ideally we'd use fixed point math instead of floats... /* SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - Y-axis-value is the second coordinate (from center to SOUTH) @@ -700,7 +700,7 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src) --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ tmp = (((Sint32)(f * 18000.0 / SDL_PI_D)) + 45000) % 36000; - tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ + tmp = (tmp * 0x8000) / 18000; // convert to range [0,0xFFFF] *dest = (Uint16)tmp; } break; @@ -727,31 +727,31 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr const SDL_HapticRamp *ramp; const SDL_HapticLeftRight *leftright; - /* Clear up */ + // Clear up SDL_memset(dest, 0, sizeof(struct ff_effect)); switch (src->type) { case SDL_HAPTIC_CONSTANT: constant = &src->constant; - /* Header */ + // Header dest->type = FF_CONSTANT; if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1) { return -1; } - /* Replay */ + // Replay dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(constant->length); dest->replay.delay = CLAMP(constant->delay); - /* Trigger */ + // Trigger dest->trigger.button = SDL_SYS_ToButton(constant->button); dest->trigger.interval = CLAMP(constant->interval); - /* Constant */ + // Constant dest->u.constant.level = constant->level; - /* Envelope */ + // Envelope dest->u.constant.envelope.attack_length = CLAMP(constant->attack_length); dest->u.constant.envelope.attack_level = @@ -768,21 +768,21 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr case SDL_HAPTIC_SAWTOOTHDOWN: periodic = &src->periodic; - /* Header */ + // Header dest->type = FF_PERIODIC; if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1) { return -1; } - /* Replay */ + // Replay dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(periodic->length); dest->replay.delay = CLAMP(periodic->delay); - /* Trigger */ + // Trigger dest->trigger.button = SDL_SYS_ToButton(periodic->button); dest->trigger.interval = CLAMP(periodic->interval); - /* Periodic */ + // Periodic if (periodic->type == SDL_HAPTIC_SINE) { dest->u.periodic.waveform = FF_SINE; } else if (periodic->type == SDL_HAPTIC_SQUARE) { @@ -797,10 +797,10 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr dest->u.periodic.period = CLAMP(periodic->period); dest->u.periodic.magnitude = periodic->magnitude; dest->u.periodic.offset = periodic->offset; - /* Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. */ + // Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. dest->u.periodic.phase = ((Uint32)periodic->phase * 0x10000U) / 36000; - /* Envelope */ + // Envelope dest->u.periodic.envelope.attack_length = CLAMP(periodic->attack_length); dest->u.periodic.envelope.attack_level = @@ -816,7 +816,7 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr case SDL_HAPTIC_FRICTION: condition = &src->condition; - /* Header */ + // Header if (condition->type == SDL_HAPTIC_SPRING) { dest->type = FF_SPRING; } else if (condition->type == SDL_HAPTIC_DAMPER) { @@ -827,25 +827,25 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr dest->type = FF_FRICTION; } - dest->direction = 0; /* Handled by the condition-specifics. */ + dest->direction = 0; // Handled by the condition-specifics. - /* Replay */ + // Replay dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(condition->length); dest->replay.delay = CLAMP(condition->delay); - /* Trigger */ + // Trigger dest->trigger.button = SDL_SYS_ToButton(condition->button); dest->trigger.interval = CLAMP(condition->interval); - /* Condition */ - /* X axis */ + // Condition + // X axis dest->u.condition[0].right_saturation = condition->right_sat[0]; dest->u.condition[0].left_saturation = condition->left_sat[0]; dest->u.condition[0].right_coeff = condition->right_coeff[0]; dest->u.condition[0].left_coeff = condition->left_coeff[0]; dest->u.condition[0].deadband = condition->deadband[0]; dest->u.condition[0].center = condition->center[0]; - /* Y axis */ + // Y axis dest->u.condition[1].right_saturation = condition->right_sat[1]; dest->u.condition[1].left_saturation = condition->left_sat[1]; dest->u.condition[1].right_coeff = condition->right_coeff[1]; @@ -862,25 +862,25 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr case SDL_HAPTIC_RAMP: ramp = &src->ramp; - /* Header */ + // Header dest->type = FF_RAMP; if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1) { return -1; } - /* Replay */ + // Replay dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(ramp->length); dest->replay.delay = CLAMP(ramp->delay); - /* Trigger */ + // Trigger dest->trigger.button = SDL_SYS_ToButton(ramp->button); dest->trigger.interval = CLAMP(ramp->interval); - /* Ramp */ + // Ramp dest->u.ramp.start_level = ramp->start; dest->u.ramp.end_level = ramp->end; - /* Envelope */ + // Envelope dest->u.ramp.envelope.attack_length = CLAMP(ramp->attack_length); dest->u.ramp.envelope.attack_level = CLAMP(ramp->attack_level); dest->u.ramp.envelope.fade_length = CLAMP(ramp->fade_length); @@ -891,18 +891,18 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, const SDL_HapticEffect *sr case SDL_HAPTIC_LEFTRIGHT: leftright = &src->leftright; - /* Header */ + // Header dest->type = FF_RUMBLE; dest->direction = 0; - /* Replay */ + // Replay dest->replay.length = (leftright->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(leftright->length); - /* Trigger */ + // Trigger dest->trigger.button = 0; dest->trigger.interval = 0; - /* Rumble (Linux expects 0-65535, so multiply by 2) */ + // Rumble (Linux expects 0-65535, so multiply by 2) dest->u.rumble.strong_magnitude = CLAMP(leftright->large_magnitude) * 2; dest->u.rumble.weak_magnitude = CLAMP(leftright->small_magnitude) * 2; @@ -923,21 +923,21 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, { struct ff_effect *linux_effect; - /* Allocate the hardware effect */ + // Allocate the hardware effect effect->hweffect = (struct haptic_hweffect *) SDL_calloc(1, sizeof(struct haptic_hweffect)); if (!effect->hweffect) { return -1; } - /* Prepare the ff_effect */ + // Prepare the ff_effect linux_effect = &effect->hweffect->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 */ + // Upload the effect if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) { SDL_SetError("Haptic: Error uploading effect to the device: %s", strerror(errno)); @@ -964,19 +964,19 @@ int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, { struct ff_effect linux_effect; - /* Create the new effect */ + // Create the new effect if (SDL_SYS_ToFFEffect(&linux_effect, data) != 0) { return -1; } linux_effect.id = effect->hweffect->effect.id; - /* See if it can be uploaded. */ + // See if it can be uploaded. if (ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) < 0) { return SDL_SetError("Haptic: Error updating the effect: %s", strerror(errno)); } - /* Copy the new effect into memory. */ + // Copy the new effect into memory. SDL_memcpy(&effect->hweffect->effect, &linux_effect, sizeof(struct ff_effect)); @@ -991,10 +991,10 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, { struct input_event run; - /* Prepare to run the effect */ + // Prepare to run the effect run.type = EV_FF; run.code = effect->hweffect->effect.id; - /* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */ + // 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) { @@ -1042,7 +1042,7 @@ void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effec 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; @@ -1118,7 +1118,7 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) { int i, ret; - /* Linux does not support this natively so we have to loop. */ + // Linux does not support this natively so we have to loop. for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect != NULL) { ret = SDL_SYS_HapticStopEffect(haptic, &haptic->effects[i]); @@ -1130,4 +1130,4 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) return 0; } -#endif /* SDL_HAPTIC_LINUX */ +#endif // SDL_HAPTIC_LINUX diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 8a36993a31..d9ed3b0698 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -58,7 +58,7 @@ static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *pdidInstance, V { (void)pContext; SDL_DINPUT_HapticMaybeAddDevice(pdidInstance); - return DIENUM_CONTINUE; /* continue enumerating */ + return DIENUM_CONTINUE; // continue enumerating } int SDL_DINPUT_HapticInit(void) @@ -67,12 +67,12 @@ int SDL_DINPUT_HapticInit(void) HINSTANCE instance; DWORD devClass; - if (dinput != NULL) { /* Already open. */ + if (dinput != NULL) { // Already open. return SDL_SetError("Haptic: SubSystem already open."); } if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, SDL_TRUE)) { - /* In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. */ + // In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. return 0; } @@ -90,7 +90,7 @@ int SDL_DINPUT_HapticInit(void) return DI_SetError("CoCreateInstance", ret); } - /* Because we used CoCreateInstance, we need to Initialize it, first. */ + // Because we used CoCreateInstance, we need to Initialize it, first. instance = GetModuleHandle(NULL); if (!instance) { SDL_SYS_HapticQuit(); @@ -103,10 +103,10 @@ int SDL_DINPUT_HapticInit(void) return DI_SetError("Initializing DirectInput device", ret); } - /* Look for haptic devices. */ + // Look for haptic devices. for (devClass = DI8DEVCLASS_DEVICE; devClass <= DI8DEVCLASS_GAMECTRL; devClass++) { if (devClass == DI8DEVCLASS_GAMECTRL && SDL_WasInit(SDL_INIT_JOYSTICK)) { - /* The joystick subsystem will manage adding DInput joystick haptic devices */ + // The joystick subsystem will manage adding DInput joystick haptic devices continue; } @@ -134,35 +134,35 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) SDL_hapticlist_item *item = NULL; if (!dinput) { - 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 */ + // Make sure we don't already have it for (item = SDL_hapticlist; item; item = item->next) { if (SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) { - return -1; /* Already added */ + return -1; // Already added } } - /* Open the device */ + // Open the device ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance, &device, NULL); if (FAILED(ret)) { - /* DI_SetError("Creating DirectInput device",ret); */ + // DI_SetError("Creating DirectInput device",ret); return -1; } - /* Get capabilities. */ + // Get capabilities. SDL_zero(capabilities); capabilities.dwSize = sizeof(DIDEVCAPS); ret = IDirectInputDevice8_GetCapabilities(device, &capabilities); IDirectInputDevice8_Release(device); if (FAILED(ret)) { - /* DI_SetError("Getting device capabilities",ret); */ + // DI_SetError("Getting device capabilities",ret); return -1; } 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)); @@ -177,7 +177,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) return -1; } - /* Copy the instance over, useful for creating devices. */ + // Copy the instance over, useful for creating devices. SDL_memcpy(&item->instance, pdidInstance, sizeof(DIDEVICEINSTANCE)); SDL_memcpy(&item->capabilities, &capabilities, sizeof(capabilities)); @@ -190,12 +190,12 @@ int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance) SDL_hapticlist_item *prev = NULL; if (!dinput) { - return -1; /* not initialized, ignore this. */ + return -1; // not initialized, ignore this. } for (item = SDL_hapticlist; item; item = item->next) { if (SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) { - /* found it, remove it. */ + // found it, remove it. return SDL_SYS_RemoveHapticDevice(prev, item); } prev = item; @@ -226,13 +226,13 @@ static BOOL CALLBACK DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVO } 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; haptic->naxes++; - /* Currently using the artificial limit of 3 axes. */ + // Currently using the artificial limit of 3 axes. if (haptic->naxes >= 3) { return DIENUM_STOP; } @@ -249,10 +249,10 @@ static BOOL CALLBACK DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVO haptic->supported |= (s) static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) { - /* Prepare the haptic device. */ + // Prepare the haptic device. SDL_Haptic *haptic = (SDL_Haptic *)pv; - /* Get supported. */ + // Get supported. EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING); EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER); EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA); @@ -266,7 +266,7 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP); - /* Check for more. */ + // Check for more. return DIENUM_CONTINUE; } @@ -285,13 +285,13 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI HRESULT ret; DIPROPDWORD dipdw; - /* Allocate the hwdata */ + // Allocate the hwdata haptic->hwdata = (struct haptic_hwdata *)SDL_calloc(1, sizeof(*haptic->hwdata)); if (!haptic->hwdata) { return -1; } - /* We'll use the device8 from now on. */ + // We'll use the device8 from now on. haptic->hwdata->device = device8; haptic->hwdata->is_joystick = is_joystick; @@ -302,8 +302,8 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI !!! 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. */ - /* Grab it exclusively to use force feedback stuff. */ + 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 | @@ -313,7 +313,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI goto acquire_err; } - /* Set data format. */ + // Set data format. ret = IDirectInputDevice8_SetDataFormat(haptic->hwdata->device, &SDL_c_dfDIJoystick2); if (FAILED(ret)) { @@ -321,7 +321,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI goto acquire_err; } - /* Acquire the device. */ + // Acquire the device. ret = IDirectInputDevice8_Acquire(haptic->hwdata->device); if (FAILED(ret)) { DI_SetError("Acquiring DirectInput device", ret); @@ -329,7 +329,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI } } - /* Get number of axes. */ + // Get number of axes. ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device, DI_DeviceObjectCallback, haptic, DIDFT_AXIS); @@ -338,7 +338,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI goto acquire_err; } - /* Reset all actuators - just in case. */ + // Reset all actuators - just in case. ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_RESET); if (FAILED(ret)) { @@ -346,7 +346,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI goto acquire_err; } - /* Enabling actuators. */ + // Enabling actuators. ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_SETACTUATORSON); if (FAILED(ret)) { @@ -354,7 +354,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI goto acquire_err; } - /* Get supported effects. */ + // Get supported effects. ret = IDirectInputDevice8_EnumEffects(haptic->hwdata->device, DI_EffectCallback, haptic, DIEFT_ALL); @@ -362,12 +362,12 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI 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; } - /* Check autogain and autocenter. */ + // Check autogain and autocenter. dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; @@ -375,7 +375,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI 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; @@ -383,33 +383,33 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI 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; } - /* Status is always supported. */ + // Status is always supported. haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; - /* Check maximum effects. */ + // 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->nplaying = 128; // Even more impossible to get this then neffects. - /* Prepare effects memory. */ + // Prepare effects memory. haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (!haptic->effects) { goto acquire_err; } - /* Clear the memory */ + // Clear the memory SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; - /* Error handling */ + // Error handling acquire_err: IDirectInputDevice8_Unacquire(haptic->hwdata->device); return -1; @@ -420,7 +420,7 @@ int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) HRESULT ret; LPDIRECTINPUTDEVICE8 device; - /* Open the device */ + // Open the device ret = IDirectInput8_CreateDevice(dinput, &item->instance.guidInstance, &device, NULL); if (FAILED(ret)) { @@ -443,7 +443,7 @@ int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) hap_instance.dwSize = sizeof(DIDEVICEINSTANCE); joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); - /* Get the device instances. */ + // Get the device instances. ret = IDirectInputDevice8_GetDeviceInfo(haptic->hwdata->device, &hap_instance); if (FAILED(ret)) { @@ -470,7 +470,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick return -1; } - /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ + // Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. for (item = SDL_hapticlist; item; item = item->next) { if (WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) { haptic->instance_id = item->instance_id; @@ -486,7 +486,7 @@ void SDL_DINPUT_HapticClose(SDL_Haptic *haptic) { IDirectInputDevice8_Unacquire(haptic->hwdata->device); - /* Only release if isn't grabbed by a joystick. */ + // Only release if isn't grabbed by a joystick. if (haptic->hwdata->is_joystick == 0) { IDirectInputDevice8_Release(haptic->hwdata->device); } @@ -528,14 +528,14 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, const SDL_HapticDirection *dir { LONG *rglDir; - /* Handle no axes a part. */ + // 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; } - /* Has axes. */ + // Has axes. rglDir = (LONG *)SDL_malloc(sizeof(LONG) * naxes); if (!rglDir) { return -1; @@ -578,9 +578,9 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, const SDL_HapticDirection *dir } } -/* Clamps and converts. */ +// Clamps and converts. #define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) -/* Just converts. */ +// Just converts. #define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the DIEFFECT from a SDL_HapticEffect. @@ -591,7 +591,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, 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; @@ -602,22 +602,22 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, const SDL_HapticCustom *hap_custom; DWORD *axes; - /* Set global stuff. */ + // 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. envelope = (DIENVELOPE *)SDL_calloc(1, sizeof(DIENVELOPE)); if (!envelope) { return -1; } dest->lpEnvelope = envelope; - envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ + envelope->dwSize = sizeof(DIENVELOPE); // Always should be this. - /* Axes. */ + // Axes. if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) { dest->cAxes = 1; } else { @@ -628,7 +628,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, if (!axes) { return -1; } - 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]; } @@ -638,7 +638,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, dest->rgdwAxes = axes; } - /* The big type handling switch, even bigger than Linux's version. */ + // The big type handling switch, even bigger than Linux's version. switch (src->type) { case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; @@ -647,23 +647,23 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, return -1; } - /* Specifics */ + // Specifics constant->lMagnitude = CONVERT(hap_constant->level); dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE); dest->lpvTypeSpecificParams = constant; - /* Generics */ - dest->dwDuration = hap_constant->length * 1000UL; /* In microseconds. */ + // Generics + dest->dwDuration = hap_constant->length * 1000UL; // In microseconds. dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button); dest->dwTriggerRepeatInterval = hap_constant->interval; - dest->dwStartDelay = hap_constant->delay * 1000UL; /* In microseconds. */ + dest->dwStartDelay = hap_constant->delay * 1000UL; // In microseconds. - /* Direction. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -687,7 +687,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, return -1; } - /* Specifics */ + // Specifics periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); periodic->dwPhase = @@ -696,18 +696,18 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, dest->cbTypeSpecificParams = sizeof(DIPERIODIC); dest->lpvTypeSpecificParams = periodic; - /* Generics */ - dest->dwDuration = hap_periodic->length * 1000UL; /* In microseconds. */ + // Generics + dest->dwDuration = hap_periodic->length * 1000UL; // In microseconds. dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button); dest->dwTriggerRepeatInterval = hap_periodic->interval; - dest->dwStartDelay = hap_periodic->delay * 1000UL; /* In microseconds. */ + dest->dwStartDelay = hap_periodic->delay * 1000UL; // In microseconds. - /* Direction. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -730,7 +730,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, return -1; } - /* Specifics */ + // Specifics for (i = 0; i < (int)dest->cAxes; i++) { condition[i].lOffset = CONVERT(hap_condition->center[i]); condition[i].lPositiveCoefficient = @@ -746,18 +746,18 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; - /* Generics */ - dest->dwDuration = hap_condition->length * 1000UL; /* In microseconds. */ + // Generics + dest->dwDuration = hap_condition->length * 1000UL; // In microseconds. dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button); dest->dwTriggerRepeatInterval = hap_condition->interval; - dest->dwStartDelay = hap_condition->delay * 1000UL; /* In microseconds. */ + dest->dwStartDelay = hap_condition->delay * 1000UL; // In microseconds. - /* Direction. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } - /* Envelope - Not actually supported by most CONDITION implementations. */ + // Envelope - Not actually supported by most CONDITION implementations. SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -770,24 +770,24 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, return -1; } - /* Specifics */ + // Specifics ramp->lStart = CONVERT(hap_ramp->start); ramp->lEnd = CONVERT(hap_ramp->end); dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE); dest->lpvTypeSpecificParams = ramp; - /* Generics */ - dest->dwDuration = hap_ramp->length * 1000UL; /* In microseconds. */ + // Generics + dest->dwDuration = hap_ramp->length * 1000UL; // In microseconds. dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button); dest->dwTriggerRepeatInterval = hap_ramp->interval; - dest->dwStartDelay = hap_ramp->delay * 1000UL; /* In microseconds. */ + dest->dwStartDelay = hap_ramp->delay * 1000UL; // In microseconds. - /* Direction. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -807,29 +807,29 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, return -1; } - /* Specifics */ + // Specifics custom->cChannels = hap_custom->channels; custom->dwSamplePeriod = hap_custom->period * 1000UL; custom->cSamples = hap_custom->samples; custom->rglForceData = (LPLONG)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 * 1000UL; /* In microseconds. */ + // Generics + dest->dwDuration = hap_custom->length * 1000UL; // In microseconds. dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button); dest->dwTriggerRepeatInterval = hap_custom->interval; - dest->dwStartDelay = hap_custom->delay * 1000UL; /* In microseconds. */ + dest->dwStartDelay = hap_custom->delay * 1000UL; // In microseconds. - /* Direction. */ + // Direction. if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { return -1; } - /* Envelope */ + // Envelope if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; @@ -861,7 +861,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type) SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams) { - if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ + if (type == SDL_HAPTIC_CUSTOM) { // Must free the custom data. custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; @@ -876,7 +876,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type) /* * Gets the effect type from the generic SDL haptic effect wrapper. */ -/* NOLINTNEXTLINE(readability-const-return-type): Can't fix Windows' headers */ +// NOLINTNEXTLINE(readability-const-return-type): Can't fix Windows' headers static REFGUID SDL_SYS_HapticEffectType(const SDL_HapticEffect *effect) { switch (effect->type) { @@ -929,12 +929,12 @@ int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, return SDL_SetError("Haptic: Unknown effect type."); } - /* Get the effect. */ + // Get the effect. if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) { goto err_effectdone; } - /* Create the actual effect. */ + // Create the actual effect. ret = IDirectInputDevice8_CreateEffect(haptic->hwdata->device, type, &effect->hweffect->effect, &effect->hweffect->ref, NULL); @@ -956,7 +956,7 @@ int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effe DWORD flags; DIEFFECT temp; - /* Get the effect. */ + // Get the effect. SDL_memset(&temp, 0, sizeof(DIEFFECT)); if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) { goto err_update; @@ -971,7 +971,7 @@ int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effe DIEP_TRIGGERBUTTON | DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS; - /* Create the actual effect. */ + // Create the actual effect. ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); if (ret == DIERR_NOTEXCLUSIVEACQUIRED) { @@ -992,7 +992,7 @@ int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effe goto err_update; } - /* Copy it over. */ + // Copy it over. SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type); SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT)); @@ -1008,14 +1008,14 @@ int SDL_DINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, HRESULT ret; DWORD iter; - /* Check if it's infinite. */ + // Check if it's infinite. if (iterations == SDL_HAPTIC_INFINITY) { iter = INFINITE; } else { iter = iterations; } - /* Run the effect. */ + // Run the effect. ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0); if (FAILED(ret)) { return DI_SetError("Running the effect", ret); @@ -1066,14 +1066,14 @@ int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) HRESULT ret; DIPROPDWORD dipdw; - /* Create the weird structure thingy. */ + // Create the weird structure thingy. dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = (DWORD)gain * 100; /* 0 to 10,000 */ + dipdw.dwData = (DWORD)gain * 100; // 0 to 10,000 - /* Try to set the autocenter. */ + // Try to set the autocenter. ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_FFGAIN, &dipdw.diph); if (FAILED(ret)) { @@ -1087,14 +1087,14 @@ int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter) HRESULT ret; DIPROPDWORD dipdw; - /* Create the weird structure thingy. */ + // Create the weird structure thingy. dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF : DIPROPAUTOCENTER_ON; - /* Try to set the autocenter. */ + // Try to set the autocenter. ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_AUTOCENTER, &dipdw.diph); if (FAILED(ret)) { @@ -1107,7 +1107,7 @@ int SDL_DINPUT_HapticPause(SDL_Haptic *haptic) { HRESULT ret; - /* Pause the device. */ + // Pause the device. ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_PAUSE); if (FAILED(ret)) { @@ -1120,7 +1120,7 @@ int SDL_DINPUT_HapticUnpause(SDL_Haptic *haptic) { HRESULT ret; - /* Unpause the device. */ + // Unpause the device. ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_CONTINUE); if (FAILED(ret)) { @@ -1133,7 +1133,7 @@ int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic) { HRESULT ret; - /* Try to stop the effects. */ + // Try to stop the effects. ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_STOPALL); if (FAILED(ret)) { @@ -1142,7 +1142,7 @@ int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic) return 0; } -#else /* !SDL_HAPTIC_DINPUT */ +#else // !SDL_HAPTIC_DINPUT typedef struct DIDEVICEINSTANCE DIDEVICEINSTANCE; typedef struct SDL_hapticlist_item SDL_hapticlist_item; @@ -1239,4 +1239,4 @@ int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic) return SDL_Unsupported(); } -#endif /* SDL_HAPTIC_DINPUT */ +#endif // SDL_HAPTIC_DINPUT diff --git a/src/haptic/windows/SDL_dinputhaptic_c.h b/src/haptic/windows/SDL_dinputhaptic_c.h index 1075a542f4..11deecdd53 100644 --- a/src/haptic/windows/SDL_dinputhaptic_c.h +++ b/src/haptic/windows/SDL_dinputhaptic_c.h @@ -22,7 +22,7 @@ #include "SDL_windowshaptic_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -47,7 +47,7 @@ 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++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 37d0af3587..868676452e 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -23,14 +23,14 @@ #ifdef SDL_HAPTIC_DINPUT #include "../SDL_syshaptic.h" -#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ -#include "../../joystick/windows/SDL_windowsjoystick_c.h" /* For joystick hwdata */ -#include "../../joystick/windows/SDL_xinputjoystick_c.h" /* For xinput rumble */ +#include "../../joystick/SDL_sysjoystick.h" // For the real SDL_Joystick +#include "../../joystick/windows/SDL_windowsjoystick_c.h" // For joystick hwdata +#include "../../joystick/windows/SDL_xinputjoystick_c.h" // For xinput rumble #include "SDL_windowshaptic_c.h" #include "SDL_dinputhaptic_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -74,7 +74,7 @@ int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) SDL_hapticlist_tail = item; } - /* Device has been added. */ + // Device has been added. ++numhaptics; return numhaptics; @@ -93,7 +93,7 @@ int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *i SDL_hapticlist_tail = prev; } --numhaptics; - /* !!! TODO: Send a haptic remove event? */ + // !!! TODO: Send a haptic remove event? SDL_free(item); return retval; } @@ -166,14 +166,14 @@ int SDL_SYS_HapticMouse(void) SDL_hapticlist_item *item; int index = 0; - /* Grab the first mouse haptic device we find. */ + // Grab the first mouse haptic device we find. for (item = SDL_hapticlist; item; item = item->next) { if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) { return index; } ++index; } -#endif /* SDL_HAPTIC_DINPUT */ +#endif // SDL_HAPTIC_DINPUT return -1; } @@ -219,15 +219,15 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic) { if (haptic->hwdata) { - /* Free effects. */ + // Free effects. SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; - /* Clean up */ + // Clean up SDL_DINPUT_HapticClose(haptic); - /* Free */ + // Free SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -244,7 +244,7 @@ void SDL_SYS_HapticQuit(void) for (item = SDL_hapticlist; item; item = next) { /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ - /* !!! FIXME: (...is leaking on purpose a good idea?) - No, of course not. */ + // !!! FIXME: (...is leaking on purpose a good idea?) - No, of course not. next = item->next; SDL_free(item->name); SDL_free(item); @@ -265,7 +265,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, { int result; - /* Alloc the effect. */ + // Alloc the effect. effect->hweffect = (struct haptic_hweffect *) SDL_calloc(1, sizeof(struct haptic_hweffect)); if (!effect->hweffect) { return -1; @@ -361,9 +361,9 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic) return SDL_DINPUT_HapticStopAll(haptic); } -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_HAPTIC_DINPUT */ +#endif // SDL_HAPTIC_DINPUT diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h index 5c93edd7f3..d1167ca964 100644 --- a/src/haptic/windows/SDL_windowshaptic_c.h +++ b/src/haptic/windows/SDL_windowshaptic_c.h @@ -27,7 +27,7 @@ #include "../../core/windows/SDL_directx.h" #include "../../core/windows/SDL_xinput.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -40,8 +40,8 @@ struct haptic_hwdata #ifdef SDL_HAPTIC_DINPUT LPDIRECTINPUTDEVICE8 device; #endif - DWORD axes[3]; /* Axes to use. */ - SDL_bool is_joystick; /* Device is loaded as joystick. */ + DWORD axes[3]; // Axes to use. + SDL_bool is_joystick; // Device is loaded as joystick. SDL_Thread *thread; SDL_Mutex *mutex; Uint64 stopTicks; @@ -79,9 +79,9 @@ extern SDL_hapticlist_item *SDL_hapticlist; extern int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item); extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_windowshaptic_c_h_ */ +#endif // SDL_windowshaptic_c_h_ diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index 3a51c8ab5e..07cd281673 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -34,8 +34,8 @@ #include "../joystick/usb_ids.h" #include "../SDL_hints_c.h" -/* Initial type declarations */ -#define HID_API_NO_EXPORT_DEFINE /* do not export hidapi procedures */ +// Initial type declarations +#define HID_API_NO_EXPORT_DEFINE // do not export hidapi procedures #include "hidapi/hidapi.h" #ifndef SDL_HIDAPI_DISABLED @@ -51,7 +51,7 @@ #include #include #include -/* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ +// Things named "Master" were renamed to "Main" in macOS 12.0's SDK. #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 #define kIOMainPortDefault kIOMasterPortDefault #endif @@ -64,10 +64,10 @@ #endif #ifdef HAVE_INOTIFY -#include /* strerror */ -#include /* errno */ +#include // strerror +#include // errno #include -#include /* For the definition of NAME_MAX */ +#include // For the definition of NAME_MAX #include #endif @@ -139,13 +139,13 @@ typedef struct _DEV_BROADCAST_DEVICEINTERFACE_A } 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_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 */ +#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); @@ -167,19 +167,19 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam return DefWindowProc(hwnd, message, wParam, lParam); } -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #ifdef SDL_PLATFORM_MACOS static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) { - /* Must drain the iterator, or we won't receive new notifications */ + // Must drain the iterator, or we won't receive new notifications io_object_t entry; while ((entry = IOIteratorNext(portIterator)) != 0) { IOObjectRelease(entry); ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; } } -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS #ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY_INIT1 @@ -221,7 +221,7 @@ static int StrIsInteger(const char *string) return 1; } -#endif /* HAVE_INOTIFY */ +#endif // HAVE_INOTIFY static void HIDAPI_InitializeDiscovery(void) { @@ -236,7 +236,7 @@ static void HIDAPI_InitializeDiscovery(void) 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); @@ -257,7 +257,7 @@ static void HIDAPI_InitializeDiscovery(void) 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(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #ifdef SDL_PLATFORM_MACOS SDL_HIDAPI_discovery.m_notificationPort = IONotificationPortCreate(kIOMainPortDefault); @@ -272,7 +272,7 @@ static void HIDAPI_InitializeDiscovery(void) CallbackIOServiceFunc, NULL, &portIterator); if (result == 0) { - /* Must drain the existing iterator, or we won't receive new notifications */ + // Must drain the existing iterator, or we won't receive new notifications while ((entry = IOIteratorNext(portIterator)) != 0) { IOObjectRelease(entry); } @@ -291,7 +291,7 @@ static void HIDAPI_InitializeDiscovery(void) CallbackIOServiceFunc, NULL, &portIterator); if (result == 0) { - /* Must drain the existing iterator, or we won't receive new notifications */ + // Must drain the existing iterator, or we won't receive new notifications while ((entry = IOIteratorNext(portIterator)) != 0) { IOObjectRelease(entry); } @@ -309,7 +309,7 @@ static void HIDAPI_InitializeDiscovery(void) SDL_HIDAPI_discovery.m_bCanGetNotifications = (SDL_HIDAPI_discovery.m_notificationMach != MACH_PORT_NULL); -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS #ifdef SDL_USE_LIBUDEV if (linux_enumeration_method == ENUMERATION_LIBUDEV) { @@ -330,7 +330,7 @@ static void HIDAPI_InitializeDiscovery(void) } } } else -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV { #ifdef HAVE_INOTIFY inotify_fd = SDL_inotify_init1(); @@ -358,7 +358,7 @@ static void HIDAPI_InitializeDiscovery(void) } SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; -#endif /* HAVE_INOTIFY */ +#endif // HAVE_INOTIFY } } @@ -369,7 +369,7 @@ static void HIDAPI_UpdateDiscovery(void) } 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 Uint64 now = SDL_GetTicks(); if (!SDL_HIDAPI_discovery.m_unLastDetect || now >= (SDL_HIDAPI_discovery.m_unLastDetect + SDL_HIDAPI_DETECT_INTERVAL_MS)) { ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; @@ -379,8 +379,8 @@ static void HIDAPI_UpdateDiscovery(void) } #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) -#if 0 /* just let the usual SDL_PumpEvents loop dispatch these, fixing bug 4286. --ryan. */ - /* We'll only get messages on the same thread that created the window */ +#if 0 // just let the usual SDL_PumpEvents loop dispatch these, fixing bug 4286. --ryan. + // We'll only get messages on the same thread that created the window if (SDL_GetCurrentThreadID() == SDL_HIDAPI_discovery.m_nThreadID) { MSG msg; while (PeekMessage(&msg, SDL_HIDAPI_discovery.m_hwndMsg, 0, 0, PM_NOREMOVE)) { @@ -391,7 +391,7 @@ static void HIDAPI_UpdateDiscovery(void) } } #endif -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #ifdef SDL_PLATFORM_MACOS if (SDL_HIDAPI_discovery.m_notificationPort) { @@ -436,7 +436,7 @@ static void HIDAPI_UpdateDiscovery(void) } } } else -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV { #ifdef HAVE_INOTIFY if (inotify_fd >= 0) { @@ -475,7 +475,7 @@ static void HIDAPI_UpdateDiscovery(void) } } } -#endif /* HAVE_INOTIFY */ +#endif // HAVE_INOTIFY } } @@ -516,7 +516,7 @@ static void HIDAPI_ShutdownDiscovery(void) usyms = NULL; } } else -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV { #ifdef HAVE_INOTIFY if (inotify_fd >= 0) { @@ -529,7 +529,7 @@ static void HIDAPI_ShutdownDiscovery(void) SDL_HIDAPI_discovery.m_bInitialized = SDL_FALSE; } -/* Platform HIDAPI Implementation */ +// Platform HIDAPI Implementation #define HIDAPI_USING_SDL_RUNTIME #define HIDAPI_IGNORE_DEVICE(BUS, VID, PID, USAGE_PAGE, USAGE) \ @@ -626,7 +626,7 @@ typedef struct PLATFORM_hid_device_ PLATFORM_hid_device; #ifdef HAVE_DRIVER_BACKEND -/* DRIVER HIDAPI Implementation */ +// DRIVER HIDAPI Implementation struct DRIVER_hid_device_; typedef struct DRIVER_hid_device_ DRIVER_hid_device; @@ -685,19 +685,19 @@ typedef struct DRIVER_hid_device_ DRIVER_hid_device; #undef hid_set_nonblocking #undef hid_write -#endif /* HAVE_DRIVER_BACKEND */ +#endif // HAVE_DRIVER_BACKEND #ifdef HAVE_LIBUSB -/* libusb HIDAPI Implementation */ +// libusb HIDAPI Implementation -/* Include this now, for our dynamically-loaded libusb context */ +// Include this now, for our dynamically-loaded libusb context #include static struct { void *libhandle; - /* *INDENT-OFF* */ /* clang-format off */ + /* *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); @@ -747,7 +747,7 @@ 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 */ +/* *INDENT-ON* */ // clang-format on } libusb_ctx; @@ -888,7 +888,7 @@ static const struct { Uint16 vendor; Uint16 product; } SDL_libusb_whitelist[] = { - { 0x057e, 0x0337 } /* Nintendo WUP-028, Wii U/Switch GameCube Adapter */ + { 0x057e, 0x0337 } // Nintendo WUP-028, Wii U/Switch GameCube Adapter }; static SDL_bool IsInWhitelist(Uint16 vendor, Uint16 product) @@ -903,21 +903,21 @@ static SDL_bool IsInWhitelist(Uint16 vendor, Uint16 product) return SDL_FALSE; } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB -#endif /* !SDL_HIDAPI_DISABLED */ +#endif // !SDL_HIDAPI_DISABLED #if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) -/* We have another way to get HID devices, so use the whitelist to get devices where libusb is preferred */ +// We have another way to get HID devices, so use the whitelist to get devices where libusb is preferred #define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT SDL_TRUE #else -/* libusb is the only way to get HID devices, so don't use the whitelist, get them all */ +// libusb is the only way to get HID devices, so don't use the whitelist, get them all #define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT SDL_FALSE -#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */ +#endif // HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND static SDL_bool use_libusb_whitelist = SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT; -/* Shared HIDAPI Implementation */ +// Shared HIDAPI Implementation struct hidapi_backend { @@ -956,7 +956,7 @@ static const struct hidapi_backend PLATFORM_Backend = { (void *)PLATFORM_hid_get_report_descriptor, (void *)PLATFORM_hid_error }; -#endif /* HAVE_PLATFORM_BACKEND */ +#endif // HAVE_PLATFORM_BACKEND #ifdef HAVE_DRIVER_BACKEND static const struct hidapi_backend DRIVER_Backend = { @@ -976,7 +976,7 @@ static const struct hidapi_backend DRIVER_Backend = { (void *)DRIVER_hid_get_report_descriptor, (void *)DRIVER_hid_error }; -#endif /* HAVE_DRIVER_BACKEND */ +#endif // HAVE_DRIVER_BACKEND #ifdef HAVE_LIBUSB static const struct hidapi_backend LIBUSB_Backend = { @@ -996,7 +996,7 @@ static const struct hidapi_backend LIBUSB_Backend = { (void *)LIBUSB_hid_get_report_descriptor, (void *)LIBUSB_hid_error }; -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB struct SDL_hid_device { @@ -1017,7 +1017,7 @@ static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_ return wrapper; } -#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */ +#endif // HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB static void DeleteHIDDeviceWrapper(SDL_hid_device *wrapper) { @@ -1093,15 +1093,15 @@ static void SDLCALL IgnoredDevicesChanged(void *userdata, const char *name, cons SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage) { - /* See if there are any devices we should skip in enumeration */ + // See if there are any devices we should skip in enumeration if (SDL_hidapi_only_controllers && usage_page) { if (vendor_id == USB_VENDOR_VALVE) { - /* Ignore the mouse/keyboard interface on Steam Controllers */ + // Ignore the mouse/keyboard interface on Steam Controllers if ( #ifdef SDL_PLATFORM_WIN32 - /* Check the usage page and usage on both USB and Bluetooth */ + // Check the usage page and usage on both USB and Bluetooth #else - /* Only check the usage page and usage on USB */ + // Only check the usage page and usage on USB bus == HID_API_BUS_USB && #endif usage_page == USB_USAGEPAGE_GENERIC_DESKTOP && @@ -1110,7 +1110,7 @@ SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product } } else if (usage_page == USB_USAGEPAGE_GENERIC_DESKTOP && (usage == USB_USAGE_GENERIC_JOYSTICK || usage == USB_USAGE_GENERIC_GAMEPAD || usage == USB_USAGE_GENERIC_MULTIAXISCONTROLLER)) { - /* This is a controller */ + // This is a controller } else { return SDL_TRUE; } @@ -1216,7 +1216,7 @@ int SDL_hid_init(void) SDL_UnloadObject(libusb_ctx.libhandle); #endif libusb_ctx.libhandle = NULL; - /* SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, SDL_LIBUSB_DYNAMIC " found but could not load function"); */ + // SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, SDL_LIBUSB_DYNAMIC " found but could not load function"); } else if (LIBUSB_hid_init() < 0) { #ifdef SDL_LIBUSB_DYNAMIC SDL_UnloadObject(libusb_ctx.libhandle); @@ -1227,17 +1227,17 @@ int SDL_hid_init(void) } } } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB #ifdef HAVE_PLATFORM_BACKEND ++attempts; #ifdef SDL_PLATFORM_LINUX udev_ctx = SDL_UDEV_GetUdevSyms(); -#endif /* __LINUX __ */ +#endif // __LINUX __ if (udev_ctx && PLATFORM_hid_init() == 0) { ++success; } -#endif /* HAVE_PLATFORM_BACKEND */ +#endif // HAVE_PLATFORM_BACKEND if (attempts > 0 && success == 0) { return -1; @@ -1274,8 +1274,8 @@ int SDL_hid_exit(void) } #ifdef SDL_PLATFORM_LINUX SDL_UDEV_ReleaseUdevSyms(); -#endif /* __LINUX __ */ -#endif /* HAVE_PLATFORM_BACKEND */ +#endif // __LINUX __ +#endif // HAVE_PLATFORM_BACKEND #ifdef HAVE_LIBUSB if (libusb_ctx.libhandle) { @@ -1285,7 +1285,7 @@ int SDL_hid_exit(void) #endif libusb_ctx.libhandle = NULL; } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB SDL_DelHintCallback(SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS, OnlyControllersChanged, NULL); SDL_DelHintCallback(SDL_HINT_HIDAPI_IGNORE_DEVICES, IgnoredDevicesChanged, NULL); @@ -1310,12 +1310,12 @@ Uint32 SDL_hid_device_change_count(void) HIDAPI_UpdateDiscovery(); if (SDL_HIDAPI_discovery.m_unDeviceChangeCounter == 0) { - /* Counter wrapped! */ + // Counter wrapped! ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; } counter = SDL_HIDAPI_discovery.m_unDeviceChangeCounter; -#endif /* !SDL_HIDAPI_DISABLED */ +#endif // !SDL_HIDAPI_DISABLED return counter; } @@ -1333,7 +1333,7 @@ static void AddDeviceToEnumeration(const char *driver_name, struct hid_device_in new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); if (new_dev == NULL) { - /* Don't bother returning an error, get as many devices as possible */ + // Don't bother returning an error, get as many devices as possible return; } CopyHIDDeviceInfo(dev, new_dev); @@ -1376,7 +1376,7 @@ static void RemoveDeviceFromEnumeration(const char *driver_name, struct hid_devi last = curr; } } -#endif /* HAVE_LIBUSB || HAVE_PLATFORM_BACKEND */ +#endif // HAVE_LIBUSB || HAVE_PLATFORM_BACKEND #ifdef HAVE_LIBUSB static void RemoveNonWhitelistedDevicesFromEnumeration(struct hid_device_info **devs, void (*free_device_info)(struct hid_device_info *)) @@ -1404,7 +1404,7 @@ static void RemoveNonWhitelistedDevicesFromEnumeration(struct hid_device_info ** last = curr; } } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id) { @@ -1418,7 +1418,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned return NULL; } - /* Collect the available devices */ + // Collect the available devices #ifdef HAVE_DRIVER_BACKEND driver_devs = DRIVER_hid_enumerate(vendor_id, product_id); #endif @@ -1431,7 +1431,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned RemoveNonWhitelistedDevicesFromEnumeration(&usb_devs, LIBUSB_hid_free_enumeration); } } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB #ifdef HAVE_PLATFORM_BACKEND if (udev_ctx) { @@ -1439,7 +1439,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned } #endif - /* Highest priority are custom driver devices */ + // Highest priority are custom driver devices for (dev = driver_devs; dev; dev = dev->next) { AddDeviceToEnumeration("driver", dev, &devs, &last); #ifdef HAVE_LIBUSB @@ -1450,7 +1450,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned #endif } - /* If whitelist is in effect, libusb has priority, otherwise raw devices do */ + // If whitelist is in effect, libusb has priority, otherwise raw devices do if (use_libusb_whitelist) { for (dev = usb_devs; dev; dev = dev->next) { AddDeviceToEnumeration("libusb", dev, &devs, &last); @@ -1515,14 +1515,14 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend); } } -#endif /* HAVE_PLATFORM_BACKEND */ +#endif // HAVE_PLATFORM_BACKEND #ifdef HAVE_DRIVER_BACKEND pDevice = DRIVER_hid_open(vendor_id, product_id, serial_number); if (pDevice != NULL) { return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend); } -#endif /* HAVE_DRIVER_BACKEND */ +#endif // HAVE_DRIVER_BACKEND #ifdef HAVE_LIBUSB if (libusb_ctx.libhandle != NULL) { @@ -1531,9 +1531,9 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend); } } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB -#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */ +#endif // HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB return NULL; } @@ -1554,14 +1554,14 @@ SDL_hid_device *SDL_hid_open_path(const char *path) return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend); } } -#endif /* HAVE_PLATFORM_BACKEND */ +#endif // HAVE_PLATFORM_BACKEND #ifdef HAVE_DRIVER_BACKEND pDevice = DRIVER_hid_open_path(path); if (pDevice != NULL) { return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend); } -#endif /* HAVE_DRIVER_BACKEND */ +#endif // HAVE_DRIVER_BACKEND #ifdef HAVE_LIBUSB if (libusb_ctx.libhandle != NULL) { @@ -1570,9 +1570,9 @@ SDL_hid_device *SDL_hid_open_path(const char *path) return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend); } } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB -#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */ +#endif // HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB return NULL; } @@ -1694,7 +1694,7 @@ void SDL_hid_ble_scan(SDL_bool active) } #ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS -/* This is needed to enable input for Nyko and EVORETRO GameCube adaptors */ +// This is needed to enable input for Nyko and EVORETRO GameCube adaptors void SDL_EnableGameCubeAdaptors(void) { #ifdef HAVE_LIBUSB @@ -1746,6 +1746,6 @@ void SDL_EnableGameCubeAdaptors(void) libusb_ctx.exit(context); } -#endif /* HAVE_LIBUSB */ +#endif // HAVE_LIBUSB } -#endif /* HAVE_ENABLE_GAMECUBE_ADAPTORS */ +#endif // HAVE_ENABLE_GAMECUBE_ADAPTORS diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index d08d83b24a..e7e2481920 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the gamepad API for Simple DirectMedia Layer */ +// This is the gamepad API for Simple DirectMedia Layer #include "SDL_sysjoystick.h" #include "SDL_joystick_c.h" @@ -37,15 +37,15 @@ #ifdef SDL_PLATFORM_ANDROID #endif -/* Many gamepads turn the center button into an instantaneous button press */ +// Many gamepads turn the center button into an instantaneous button press #define SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS 250 #define SDL_GAMEPAD_CRC_FIELD "crc:" -#define SDL_GAMEPAD_CRC_FIELD_SIZE 4 /* hard-coded for speed */ +#define SDL_GAMEPAD_CRC_FIELD_SIZE 4 // hard-coded for speed #define SDL_GAMEPAD_TYPE_FIELD "type:" #define SDL_GAMEPAD_TYPE_FIELD_SIZE SDL_strlen(SDL_GAMEPAD_TYPE_FIELD) #define SDL_GAMEPAD_FACE_FIELD "face:" -#define SDL_GAMEPAD_FACE_FIELD_SIZE 5 /* hard-coded for speed */ +#define SDL_GAMEPAD_FACE_FIELD_SIZE 5 // hard-coded for speed #define SDL_GAMEPAD_PLATFORM_FIELD "platform:" #define SDL_GAMEPAD_PLATFORM_FIELD_SIZE SDL_strlen(SDL_GAMEPAD_PLATFORM_FIELD) #define SDL_GAMEPAD_HINT_FIELD "hint:" @@ -58,7 +58,7 @@ static SDL_bool SDL_gamepads_initialized; static SDL_Gamepad *SDL_gamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL; -/* The face button style of a gamepad */ +// The face button style of a gamepad typedef enum { SDL_GAMEPAD_FACE_STYLE_UNKNOWN, @@ -67,7 +67,7 @@ typedef enum SDL_GAMEPAD_FACE_STYLE_SONY, } SDL_GamepadFaceStyle; -/* our hard coded list of mapping support */ +// our hard coded list of mapping support typedef enum { SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT, @@ -108,10 +108,10 @@ static SDL_HashTable *s_gamepadInstanceIDs SDL_GUARDED_BY(SDL_joystick_lock) = N #define _guarded SDL_GUARDED_BY(SDL_joystick_lock) -/* The SDL gamepad structure */ +// The SDL gamepad structure struct SDL_Gamepad { - SDL_Joystick *joystick _guarded; /* underlying joystick device */ + SDL_Joystick *joystick _guarded; // underlying joystick device int ref_count _guarded; const char *name _guarded; @@ -124,7 +124,7 @@ struct SDL_Gamepad Uint8 *last_hat_mask _guarded; Uint64 guide_button_down _guarded; - struct SDL_Gamepad *next _guarded; /* pointer to next gamepad we have allocated */ + struct SDL_Gamepad *next _guarded; // pointer to next gamepad we have allocated }; #undef _guarded @@ -208,7 +208,7 @@ static void HandleJoystickAxis(Uint64 timestamp, SDL_Gamepad *gamepad, int axis, } if (last_match && (!match || !HasSameOutput(last_match, match))) { - /* Clear the last input that this axis generated */ + // Clear the last input that this axis generated ResetOutput(timestamp, gamepad, last_match); } @@ -487,7 +487,7 @@ static void PushMappingChangeTracking(void) s_mappingChangeTracker = (MappingChangeTracker *)SDL_calloc(1, sizeof(*tracker)); s_mappingChangeTracker->refcount = 1; - /* Save the list of joysticks and associated mappings */ + // Save the list of joysticks and associated mappings tracker = s_mappingChangeTracker; tracker->joysticks = SDL_GetJoysticks(&num_joysticks); if (!tracker->joysticks) { @@ -553,10 +553,10 @@ static void PopMappingChangeTracking(void) } s_mappingChangeTracker = NULL; - /* Now check to see what gamepads changed because of the mapping changes */ + // Now check to see what gamepads changed because of the mapping changes if (tracker->joysticks && tracker->joystick_mappings) { for (i = 0; tracker->joysticks[i]; ++i) { - /* Looking up the new mapping might create one and associate it with the gamepad (and generate events) */ + // Looking up the new mapping might create one and associate it with the gamepad (and generate events) SDL_JoystickID joystick = tracker->joysticks[i]; SDL_Gamepad *gamepad = SDL_GetGamepadFromID(joystick); GamepadMapping_t *new_mapping = SDL_PrivateGetGamepadMapping(joystick, SDL_FALSE); @@ -603,11 +603,11 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) button_mask = SDL_Swap16LE(*(Uint16 *)(&guid.data[sizeof(guid.data) - 4])); axis_mask = SDL_Swap16LE(*(Uint16 *)(&guid.data[sizeof(guid.data) - 2])); if (!button_mask && !axis_mask) { - /* Accelerometer, shouldn't have a gamepad mapping */ + // Accelerometer, shouldn't have a gamepad mapping return NULL; } if (!(button_mask & face_button_mask)) { - /* We don't know what buttons or axes are supported, don't make up a mapping */ + // We don't know what buttons or axes are supported, don't make up a mapping return NULL; } @@ -619,7 +619,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) if (button_mask & (1 << SDL_GAMEPAD_BUTTON_EAST)) { SDL_strlcat(mapping_string, "b:b1,", sizeof(mapping_string)); } else if (button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) { - /* Use the back button as "B" for easy UI navigation with TV remotes */ + // Use the back button as "B" for easy UI navigation with TV remotes SDL_strlcat(mapping_string, "b:b4,", sizeof(mapping_string)); button_mask &= ~(1 << SDL_GAMEPAD_BUTTON_BACK); } @@ -633,7 +633,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) SDL_strlcat(mapping_string, "back:b4,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_GAMEPAD_BUTTON_GUIDE)) { - /* The guide button generally isn't functional (or acts as a home button) on most Android gamepads before Android 11 */ + // The guide button generally isn't functional (or acts as a home button) on most Android gamepads before Android 11 if (SDL_GetAndroidSDKVersion() >= 30 /* Android 11 */) { SDL_strlcat(mapping_string, "guide:b5,", sizeof(mapping_string)); } @@ -686,7 +686,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT); } -#endif /* SDL_PLATFORM_ANDROID */ +#endif // SDL_PLATFORM_ANDROID /* * Helper function to guess at a mapping for HIDAPI gamepads @@ -706,7 +706,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) (vendor == USB_VENDOR_DRAGONRISE && (product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 || product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2))) { - /* GameCube driver has 12 buttons and 6 axes */ + // GameCube driver has 12 buttons and 6 axes SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b2,y:b3,", sizeof(mapping_string)); } else if (vendor == USB_VENDOR_NINTENDO && (guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft || @@ -745,7 +745,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) break; case k_eWiiExtensionControllerType_Nunchuk: { - /* FIXME: Should we map this to the left or right side? */ + // 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) { @@ -756,14 +756,14 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) } break; default: if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, SDL_FALSE)) { - /* Vertical mode */ + // Vertical mode if (guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConLeft) { SDL_strlcat(mapping_string, "back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,misc1:b11,paddle2:b13,paddle4:b15,", sizeof(mapping_string)); } else { SDL_strlcat(mapping_string, "a:b0,b:b1,guide:b5,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,paddle1:b12,paddle3:b14,", sizeof(mapping_string)); } } else { - /* Mini gamepad mode */ + // Mini gamepad mode if (guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConLeft) { SDL_strlcat(mapping_string, "a:b0,b:b1,guide:b5,leftshoulder:b9,leftstick:b7,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b2,y:b3,paddle2:b13,paddle4:b15,", sizeof(mapping_string)); } else { @@ -773,56 +773,56 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) break; } } else { - /* All other gamepads have the standard set of 19 buttons and 6 axes */ + // All other gamepads have the standard set of 19 buttons and 6 axes SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,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,", sizeof(mapping_string)); if (SDL_IsJoystickXboxSeriesX(vendor, product)) { - /* XBox Series X Controllers have a share button under the guide button */ + // XBox Series X Controllers have a share button under the guide button SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string)); } else if (SDL_IsJoystickXboxOneElite(vendor, product)) { - /* XBox One Elite Controllers have 4 back paddle buttons */ + // XBox One Elite Controllers have 4 back paddle buttons SDL_strlcat(mapping_string, "paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,", sizeof(mapping_string)); } else if (SDL_IsJoystickSteamController(vendor, product)) { - /* Steam controllers have 2 back paddle buttons */ + // Steam controllers have 2 back paddle buttons SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,", sizeof(mapping_string)); } else if (SDL_IsJoystickNintendoSwitchPro(vendor, product) || SDL_IsJoystickNintendoSwitchProInputOnly(vendor, product)) { - /* Nintendo Switch Pro controllers have a screenshot button */ + // Nintendo Switch Pro controllers have a screenshot button SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string)); } else if (SDL_IsJoystickNintendoSwitchJoyConPair(vendor, product)) { - /* The Nintendo Switch Joy-Con combined controllers has a share button and paddles */ + // The Nintendo Switch Joy-Con combined controllers has a share button and paddles SDL_strlcat(mapping_string, "misc1:b11,paddle1:b12,paddle2:b13,paddle3:b14,paddle4:b15,", sizeof(mapping_string)); } else if (SDL_IsJoystickAmazonLunaController(vendor, product)) { - /* Amazon Luna Controller has a mic button under the guide button */ + // Amazon Luna Controller has a mic button under the guide button SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string)); } else if (SDL_IsJoystickGoogleStadiaController(vendor, product)) { - /* The Google Stadia controller has a share button and a Google Assistant button */ + // The Google Stadia controller has a share button and a Google Assistant button SDL_strlcat(mapping_string, "misc1:b11,misc2:b12", sizeof(mapping_string)); } else if (SDL_IsJoystickNVIDIASHIELDController(vendor, product)) { - /* The NVIDIA SHIELD controller has a share button between back and start buttons */ + // The NVIDIA SHIELD controller has a share button between back and start buttons SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string)); if (product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) { - /* The original SHIELD controller has a touchpad and plus/minus buttons as well */ + // The original SHIELD controller has a touchpad and plus/minus buttons as well SDL_strlcat(mapping_string, "touchpad:b12,misc2:b13,misc3:b14", sizeof(mapping_string)); } } else { switch (SDL_GetGamepadTypeFromGUID(guid, NULL)) { case SDL_GAMEPAD_TYPE_PS4: - /* PS4 controllers have an additional touchpad button */ + // PS4 controllers have an additional touchpad button SDL_strlcat(mapping_string, "touchpad:b11,", sizeof(mapping_string)); break; case SDL_GAMEPAD_TYPE_PS5: - /* PS5 controllers have a microphone button and an additional touchpad button */ + // PS5 controllers have a microphone button and an additional touchpad button SDL_strlcat(mapping_string, "touchpad:b11,misc1:b12,", sizeof(mapping_string)); - /* DualSense Edge controllers have paddles */ + // DualSense Edge controllers have paddles if (SDL_IsJoystickDualSenseEdge(vendor, product)) { SDL_strlcat(mapping_string, "paddle1:b16,paddle2:b15,paddle3:b14,paddle4:b13,", sizeof(mapping_string)); } break; default: if (vendor == 0 && product == 0) { - /* This is a Bluetooth Nintendo Switch Pro controller */ + // This is a Bluetooth Nintendo Switch Pro controller SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string)); } break; @@ -877,7 +877,7 @@ static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, SD SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc); - /* Clear the CRC from the GUID for matching, the mappings never include it in the GUID */ + // Clear the CRC from the GUID for matching, the mappings never include it in the GUID SDL_SetJoystickGUIDCRC(&guid, 0); if (!match_version) { @@ -901,11 +901,11 @@ static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, SD if (crc_string) { Uint16 mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_GAMEPAD_CRC_FIELD_SIZE, NULL, 16); if (mapping_crc != crc) { - /* This mapping specified a CRC and they don't match */ + // This mapping specified a CRC and they don't match continue; } - /* An exact match, including CRC */ + // An exact match, including CRC return mapping; } @@ -930,14 +930,14 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_ } if (adding_mapping) { - /* We didn't find an existing mapping */ + // We didn't find an existing mapping return NULL; } - /* Try harder to get the best match, or create a mapping */ + // Try harder to get the best match, or create a mapping if (SDL_JoystickGUIDUsesVersion(guid)) { - /* Try again, ignoring the version */ + // Try again, ignoring the version mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_FALSE); if (mapping) { return mapping; @@ -946,7 +946,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_ #ifdef SDL_JOYSTICK_XINPUT if (SDL_IsJoystickXInput(guid)) { - /* This is an XInput device */ + // This is an XInput device return s_pXInputMapping; } #endif @@ -957,7 +957,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_ } else if (SDL_IsJoystickWGI(guid)) { mapping = SDL_CreateMappingForWGIGamepad(guid); } else if (SDL_IsJoystickVIRTUAL(guid)) { - /* We'll pick up a robust mapping in VIRTUAL_JoystickGetGamepadMapping */ + // We'll pick up a robust mapping in VIRTUAL_JoystickGetGamepadMapping #ifdef SDL_PLATFORM_ANDROID } else { mapping = SDL_CreateMappingForAndroidGamepad(guid); @@ -1103,7 +1103,7 @@ static SDL_GamepadButton SDL_PrivateGetGamepadButtonFromString(const char *str, for (i = 0; i < SDL_arraysize(map_StringForGamepadButton); ++i) { if (SDL_strcasecmp(str, map_StringForGamepadButton[i]) == 0) { if (baxy) { - /* Need to swap face buttons */ + // Need to swap face buttons switch (i) { case SDL_GAMEPAD_BUTTON_SOUTH: return SDL_GAMEPAD_BUTTON_EAST; @@ -1233,7 +1233,7 @@ static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char for (i = 0; i < gamepad->num_bindings; ++i) { if (SDL_memcmp(&gamepad->bindings[i], &bind, sizeof(bind)) == 0) { - /* We already have this binding, could be different face button names? */ + // We already have this binding, could be different face button names? return SDL_TRUE; } } @@ -1296,7 +1296,7 @@ static int SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char pchPos++; } - /* No more values if the string was terminated by a comma. Don't report an error. */ + // No more values if the string was terminated by a comma. Don't report an error. if (szGameButton[0] != '\0' || szJoystickButton[0] != '\0') { SDL_PrivateParseGamepadElement(gamepad, szGameButton, szJoystickButton); } @@ -1381,7 +1381,7 @@ static void SDL_UpdateGamepadFaceStyle(SDL_Gamepad *gamepad) if (gamepad->face_style == SDL_GAMEPAD_FACE_STYLE_UNKNOWN && SDL_strstr(gamepad->mapping->mapping, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS") != NULL) { - /* This controller uses Nintendo button style */ + // This controller uses Nintendo button style gamepad->face_style = SDL_GAMEPAD_FACE_STYLE_BAYX; } if (gamepad->face_style == SDL_GAMEPAD_FACE_STYLE_UNKNOWN) { @@ -1411,7 +1411,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t SDL_PrivateParseGamepadConfigString(gamepad, pGamepadMapping->mapping); - /* Set the zero point for triggers */ + // Set the zero point for triggers for (i = 0; i < gamepad->num_bindings; ++i) { SDL_GamepadBinding *binding = &gamepad->bindings[i]; if (binding->input_type == SDL_GAMEPAD_BINDTYPE_AXIS && @@ -1440,7 +1440,7 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping) SDL_memcpy(pchGUID, pMapping, pFirstComma - pMapping); pchGUID[pFirstComma - pMapping] = '\0'; - /* Convert old style GUIDs to the new style in 2.0.5 */ + // Convert old style GUIDs to the new style in 2.0.5 #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) { @@ -1509,14 +1509,14 @@ static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping) return NULL; } - /* Skip whitespace */ + // Skip whitespace while (SDL_isspace(pSecondComma[1])) { ++pSecondComma; } - result = SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */ + result = SDL_strdup(pSecondComma + 1); // mapping is everything after the 3rd comma - /* Trim whitespace */ + // Trim whitespace length = SDL_strlen(result); while (length > 0 && SDL_isspace(result[length - 1])) { --length; @@ -1551,10 +1551,10 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char return NULL; } - /* Fix up the GUID and the mapping with the CRC, if needed */ + // Fix up the GUID and the mapping with the CRC, if needed SDL_GetJoystickGUIDInfo(jGUID, NULL, NULL, NULL, &crc); if (crc) { - /* Make sure the mapping has the CRC */ + // Make sure the mapping has the CRC char *new_mapping; const char *optional_comma; size_t mapping_length; @@ -1570,7 +1570,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *crc_string = '\0'; } - /* Make sure there's a comma before the CRC */ + // Make sure there's a comma before the CRC mapping_length = SDL_strlen(pchMapping); if (mapping_length == 0 || pchMapping[mapping_length - 1] == ',') { optional_comma = ""; @@ -1583,7 +1583,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char pchMapping = new_mapping; } } else { - /* Make sure the GUID has the CRC, for matching purposes */ + // Make sure the GUID has the CRC, for matching purposes char *crc_string = SDL_strstr(pchMapping, SDL_GAMEPAD_CRC_FIELD); if (crc_string) { crc = (Uint16)SDL_strtol(crc_string + SDL_GAMEPAD_CRC_FIELD_SIZE, NULL, 16); @@ -1597,9 +1597,9 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char pGamepadMapping = SDL_PrivateGetGamepadMappingForGUID(jGUID, SDL_TRUE); if (pGamepadMapping) { - /* Only overwrite the mapping if the priority is the same or higher. */ + // Only overwrite the mapping if the priority is the same or higher. if (pGamepadMapping->priority <= priority) { - /* Update existing mapping */ + // Update existing mapping SDL_free(pGamepadMapping->name); pGamepadMapping->name = pchName; SDL_free(pGamepadMapping->mapping); @@ -1621,7 +1621,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char SDL_free(pchMapping); return NULL; } - /* Clear the CRC, we've already added it to the mapping */ + // Clear the CRC, we've already added it to the mapping if (crc) { SDL_SetJoystickGUIDCRC(&jGUID, 0); } @@ -1632,13 +1632,13 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char pGamepadMapping->priority = priority; if (s_pSupportedGamepads) { - /* Add the mapping to the end of the list */ + // Add the mapping to the end of the list GamepadMapping_t *pCurrMapping, *pPrevMapping; for (pPrevMapping = s_pSupportedGamepads, pCurrMapping = pPrevMapping->next; pCurrMapping; pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next) { - /* continue; */ + // continue; } pPrevMapping->next = pGamepadMapping; } else { @@ -1667,14 +1667,14 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * #ifdef SDL_PLATFORM_LINUX if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { - /* The Linux driver xpad.c maps the wireless dpad to buttons */ + // 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_GAMEPAD_MAPPING_PRIORITY_DEFAULT); } } -#endif /* SDL_PLATFORM_LINUX */ +#endif // SDL_PLATFORM_LINUX return mapping; } @@ -1721,7 +1721,7 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char * char name_string[128]; char mapping[1024]; - /* Remove any commas in the name */ + // Remove any commas in the name SDL_strlcpy(name_string, name, sizeof(name_string)); { char *spot; @@ -1825,7 +1825,7 @@ int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool closeio) line_end = buf + db_size; } - /* Extract and verify the platform */ + // Extract and verify the platform tmp = SDL_strstr(line, SDL_GAMEPAD_PLATFORM_FIELD); if (tmp) { tmp += SDL_GAMEPAD_PLATFORM_FIELD_SIZE; @@ -1882,7 +1882,7 @@ int SDL_ReloadGamepadMappings(void) static char *SDL_ConvertMappingToPositional(const char *mapping) { - /* Add space for '!' and null terminator */ + // Add space for '!' and null terminator size_t length = SDL_strlen(mapping) + 1 + 1; char *remapped = (char *)SDL_malloc(length); if (remapped) { @@ -1940,7 +1940,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa return SDL_InvalidParamError("mappingString"); } - { /* Extract and verify the hint field */ + { // Extract and verify the hint field const char *tmp; tmp = SDL_strstr(mappingString, SDL_GAMEPAD_HINT_FIELD); @@ -1972,11 +1972,11 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa } if (SDL_strcmp(hint, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS") == 0) { - /* This hint is used to signal whether the mapping uses positional buttons or not */ + // This hint is used to signal whether the mapping uses positional buttons or not if (negate) { - /* This mapping uses positional buttons, we can use it as-is */ + // This mapping uses positional buttons, we can use it as-is } else { - /* This mapping uses labeled buttons, we need to swap them to positional */ + // This mapping uses labeled buttons, we need to swap them to positional remapped = SDL_ConvertMappingToPositional(mappingString); if (!remapped) { goto done; @@ -1997,7 +1997,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa } #ifdef ANDROID - { /* Extract and verify the SDK version */ + { // Extract and verify the SDK version const char *tmp; tmp = SDL_strstr(mappingString, SDL_GAMEPAD_SDKGE_FIELD); @@ -2085,11 +2085,11 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_GUID guid) SDL_GUIDToString(guid, pchGUID, sizeof(pchGUID)); - /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ + // allocate enough memory for GUID + ',' + name + ',' + mapping + \0 needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; if (!SDL_strstr(mapping->mapping, SDL_GAMEPAD_PLATFORM_FIELD)) { - /* add memory for ',' + platform:PLATFORM */ + // add memory for ',' + platform:PLATFORM need_platform = SDL_TRUE; if (mapping->mapping[SDL_strlen(mapping->mapping) - 1] != ',') { needed += 1; @@ -2114,7 +2114,7 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_GUID guid) SDL_strlcat(pMappingString, ",", needed); } - /* Make sure multiple platform strings haven't made their way into the mapping */ + // Make sure multiple platform strings haven't made their way into the mapping pPlatformString = SDL_strstr(pMappingString, SDL_GAMEPAD_PLATFORM_FIELD); if (pPlatformString) { pPlatformString = SDL_strstr(pPlatformString + 1, SDL_GAMEPAD_PLATFORM_FIELD); @@ -2344,7 +2344,7 @@ int SDL_InitGamepadMappings(void) SDL_AddGamepadMappingsFromFile(szGamepadMapPath); } - /* load in any user supplied config */ + // load in any user supplied config SDL_LoadGamepadHints(); SDL_LoadVIDPIDList(&SDL_allowed_gamepads); @@ -2362,10 +2362,10 @@ int SDL_InitGamepads(void) SDL_gamepads_initialized = SDL_TRUE; - /* Watch for joystick events and fire gamepad ones if needed */ + // Watch for joystick events and fire gamepad ones if needed SDL_AddEventWatch(SDL_GamepadEventWatcher, NULL); - /* Send added events for gamepads currently attached */ + // Send added events for gamepads currently attached joysticks = SDL_GetJoysticks(NULL); if (joysticks) { for (i = 0; joysticks[i]; ++i) { @@ -2599,24 +2599,24 @@ SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid) #ifdef SDL_PLATFORM_LINUX if (SDL_endswith(name, " Motion Sensors")) { - /* Don't treat the PS3 and PS4 motion controls as a separate gamepad */ + // Don't treat the PS3 and PS4 motion controls as a separate gamepad return SDL_TRUE; } if (SDL_strncmp(name, "Nintendo ", 9) == 0 && SDL_strstr(name, " IMU") != NULL) { - /* Don't treat the Nintendo IMU as a separate gamepad */ + // Don't treat the Nintendo IMU as a separate gamepad return SDL_TRUE; } if (SDL_endswith(name, " Accelerometer") || SDL_endswith(name, " IR") || SDL_endswith(name, " Motion Plus") || SDL_endswith(name, " Nunchuk")) { - /* Don't treat the Wii extension controls as a separate gamepad */ + // Don't treat the Wii extension controls as a separate gamepad return SDL_TRUE; } #endif if (name && SDL_strcmp(name, "uinput-fpc") == 0) { - /* The Google Pixel fingerprint sensor reports itself as a joystick */ + // The Google Pixel fingerprint sensor reports itself as a joystick return SDL_TRUE; } @@ -2628,15 +2628,15 @@ SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid) SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL); if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) { - /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real gamepads so it can remap input for the virtual gamepad */ - /* https://partner.steamgames.com/doc/features/steam_gamepad/steam_input_gamepad_emulation_bestpractices */ + // We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real gamepads so it can remap input for the virtual gamepad + // https://partner.steamgames.com/doc/features/steam_gamepad/steam_input_gamepad_emulation_bestpractices SDL_bool bSteamVirtualGamepad = SDL_FALSE; #ifdef SDL_PLATFORM_LINUX bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD); #elif defined(SDL_PLATFORM_MACOS) bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0); #elif defined(SDL_PLATFORM_WIN32) - /* We can't tell on Windows, but Steam will block others in input hooks */ + // We can't tell on Windows, but Steam will block others in input hooks bSteamVirtualGamepad = SDL_TRUE; #endif if (bSteamVirtualGamepad) { @@ -2671,7 +2671,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) SDL_LockJoysticks(); gamepadlist = SDL_gamepads; - /* If the gamepad is already open, return it */ + // If the gamepad is already open, return it while (gamepadlist) { if (instance_id == gamepadlist->joystick->instance_id) { gamepad = gamepadlist; @@ -2682,7 +2682,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) gamepadlist = gamepadlist->next; } - /* Find a gamepad mapping */ + // Find a gamepad mapping pSupportedGamepad = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); if (!pSupportedGamepad) { SDL_SetError("Couldn't find mapping for device (%" SDL_PRIu32 ")", instance_id); @@ -2690,7 +2690,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) return NULL; } - /* Create and initialize the gamepad */ + // Create and initialize the gamepad gamepad = (SDL_Gamepad *)SDL_calloc(1, sizeof(*gamepad)); if (!gamepad) { SDL_UnlockJoysticks(); @@ -2727,9 +2727,9 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) SDL_PrivateLoadButtonMapping(gamepad, pSupportedGamepad); - /* Add the gamepad to list */ + // Add the gamepad to list ++gamepad->ref_count; - /* Link the gamepad in the list */ + // Link the gamepad in the list gamepad->next = SDL_gamepads; SDL_gamepads = gamepad; @@ -2743,7 +2743,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) */ void SDL_UpdateGamepads(void) { - /* Just for API completeness; the joystick API does all the work. */ + // Just for API completeness; the joystick API does all the work. SDL_UpdateJoysticks(); } @@ -2825,7 +2825,7 @@ Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis) } else { valid_output_range = (value >= binding->output.axis.axis_max && value <= binding->output.axis.axis_min); } - /* If the value is zero, there might be another binding that makes it non-zero */ + // If the value is zero, there might be another binding that makes it non-zero if (value != 0 && valid_output_range) { retval = (Sint16)value; break; @@ -3377,7 +3377,7 @@ int SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index) SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); if (!joystick) { - /* SDL_SetError() will have been called already by SDL_GetGamepadJoystick() */ + // SDL_SetError() will have been called already by SDL_GetGamepadJoystick() return -1; } return SDL_SetJoystickPlayerIndex(joystick, player_index); @@ -3631,7 +3631,7 @@ void SDL_CloseGamepad(SDL_Gamepad *gamepad) return; } - /* First decrement ref count */ + // First decrement ref count if (--gamepad->ref_count > 0) { SDL_UnlockJoysticks(); return; @@ -3644,7 +3644,7 @@ void SDL_CloseGamepad(SDL_Gamepad *gamepad) while (gamepadlist) { if (gamepad == gamepadlist) { if (gamepadlistprev) { - /* unlink this entry */ + // unlink this entry gamepadlistprev->next = gamepadlist->next; } else { SDL_gamepads = gamepad->next; @@ -3721,7 +3721,7 @@ static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gamep SDL_AssertJoysticksLocked(); - /* translate the event, if desired */ + // translate the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_GAMEPAD_AXIS_MOTION)) { SDL_Event event; @@ -3757,7 +3757,7 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam event.type = SDL_EVENT_GAMEPAD_BUTTON_UP; break; default: - /* Invalid state -- bail */ + // Invalid state -- bail return 0; } @@ -3767,7 +3767,7 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam gamepad->guide_button_down = now; if (gamepad->joystick->delayed_guide_button) { - /* Skip duplicate press */ + // Skip duplicate press return 0; } } else { @@ -3779,7 +3779,7 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam } } - /* translate the event, if desired */ + // translate the event, if desired posted = 0; if (SDL_EventEnabled(event.type)) { event.common.timestamp = timestamp; @@ -3837,7 +3837,7 @@ void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick) if (gamepad->joystick == joystick) { SDL_SendGamepadButton(0, gamepad, SDL_GAMEPAD_BUTTON_GUIDE, SDL_RELEASED); - /* Make sure we send an update complete event for this change */ + // Make sure we send an update complete event for this change if (!gamepad->joystick->update_complete) { gamepad->joystick->update_complete = SDL_GetTicksNS(); } diff --git a/src/joystick/SDL_gamepad_c.h b/src/joystick/SDL_gamepad_c.h index d67c611914..918ccd6981 100644 --- a/src/joystick/SDL_gamepad_c.h +++ b/src/joystick/SDL_gamepad_c.h @@ -24,9 +24,9 @@ #include "SDL_internal.h" -/* Useful functions and variables from SDL_gamepad.c */ +// Useful functions and variables from SDL_gamepad.c -/* Initialization and shutdown functions */ +// Initialization and shutdown functions extern int SDL_InitGamepadMappings(void); extern void SDL_QuitGamepadMappings(void); extern int SDL_InitGamepads(void); @@ -35,16 +35,16 @@ extern void SDL_QuitGamepads(void); extern void SDL_PrivateGamepadAdded(SDL_JoystickID instance_id); extern void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id); -/* Function to return whether a joystick name and GUID is a gamepad */ +// Function to return whether a joystick name and GUID is a gamepad extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid); -/* Function to return whether a gamepad should be ignored */ +// Function to return whether a gamepad should be ignored extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid); -/* Handle delayed guide button on a gamepad */ +// Handle delayed guide button on a gamepad extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick); -/* Handle system sensor data */ +// Handle system sensor data extern void SDL_GamepadSensorWatcher(Uint64 timestamp, SDL_SensorID sensor, Uint64 sensor_timestamp, float *data, int num_values); -#endif /* SDL_gamepad_c_h_ */ +#endif // SDL_gamepad_c_h_ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 10f75b6d24..8bf211270f 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the joystick API for Simple DirectMedia Layer */ +// This is the joystick API for Simple DirectMedia Layer #include "SDL_sysjoystick.h" #include "../SDL_hints_c.h" @@ -33,14 +33,14 @@ #include "../sensor/SDL_sensor_c.h" #include "hidapi/SDL_hidapijoystick_c.h" -/* This is included in only one place because it has a large static list of controllers */ +// This is included in only one place because it has a large static list of controllers #include "controller_type.h" #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) -/* Needed for checking for input remapping programs */ +// 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 @@ -49,10 +49,10 @@ #endif static SDL_JoystickDriver *SDL_joystick_drivers[] = { -#ifdef SDL_JOYSTICK_HIDAPI /* Highest priority driver for supported devices */ +#ifdef SDL_JOYSTICK_HIDAPI // Highest priority driver for supported devices &SDL_HIDAPI_JoystickDriver, #endif -#ifdef SDL_JOYSTICK_GAMEINPUT /* Higher priority than other Windows drivers */ +#ifdef SDL_JOYSTICK_GAMEINPUT // Higher priority than other Windows drivers &SDL_GAMEINPUT_JoystickDriver, #endif #ifdef SDL_JOYSTICK_RAWINPUT @@ -111,7 +111,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifndef SDL_THREAD_SAFETY_ANALYSIS static #endif -SDL_Mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ +SDL_Mutex *SDL_joystick_lock = NULL; // This needs to support recursive locks static SDL_AtomicInt SDL_joystick_lock_pending; static int SDL_joysticks_locked; static SDL_bool SDL_joysticks_initialized; @@ -123,38 +123,38 @@ static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; static Uint32 initial_arcadestick_devices[] = { - 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(0x146b, 0x0604), /* NACON Daija Arcade Stick */ - 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(0x146b, 0x0604), // NACON Daija Arcade Stick + 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 }; static SDL_vidpid_list arcadestick_devices = { SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES, 0, 0, NULL, @@ -167,113 +167,113 @@ static SDL_vidpid_list arcadestick_devices = { https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py */ static Uint32 initial_blacklist_devices[] = { - /* Microsoft Microsoft Wireless Optical Desktop 2.10 */ - /* Microsoft Wireless Desktop - Comfort Edition */ + // Microsoft Microsoft Wireless Optical Desktop 2.10 + // Microsoft Wireless Desktop - Comfort Edition MAKE_VIDPID(0x045e, 0x009d), - /* Microsoft Microsoft Digital Media Pro Keyboard */ - /* Microsoft Corp. Digital Media Pro Keyboard */ + // Microsoft Microsoft Digital Media Pro Keyboard + // Microsoft Corp. Digital Media Pro Keyboard MAKE_VIDPID(0x045e, 0x00b0), - /* Microsoft Microsoft Digital Media Keyboard */ - /* Microsoft Corp. Digital Media Keyboard 1.0A */ + // Microsoft Microsoft Digital Media Keyboard + // Microsoft Corp. Digital Media Keyboard 1.0A MAKE_VIDPID(0x045e, 0x00b4), - /* Microsoft Microsoft Digital Media Keyboard 3000 */ + // Microsoft Microsoft Digital Media Keyboard 3000 MAKE_VIDPID(0x045e, 0x0730), - /* Microsoft Microsoft 2.4GHz Transceiver v6.0 */ - /* Microsoft Microsoft 2.4GHz Transceiver v8.0 */ - /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */ - /* Microsoft Wireless Mobile Mouse 1000 */ - /* Microsoft Wireless Desktop 3000 */ + // Microsoft Microsoft 2.4GHz Transceiver v6.0 + // Microsoft Microsoft 2.4GHz Transceiver v8.0 + // Microsoft Corp. Nano Transceiver v1.0 for Bluetooth + // Microsoft Wireless Mobile Mouse 1000 + // Microsoft Wireless Desktop 3000 MAKE_VIDPID(0x045e, 0x0745), - /* Microsoft SideWinder(TM) 2.4GHz Transceiver */ + // Microsoft SideWinder(TM) 2.4GHz Transceiver MAKE_VIDPID(0x045e, 0x0748), - /* Microsoft Corp. Wired Keyboard 600 */ + // Microsoft Corp. Wired Keyboard 600 MAKE_VIDPID(0x045e, 0x0750), - /* Microsoft Corp. Sidewinder X4 keyboard */ + // Microsoft Corp. Sidewinder X4 keyboard MAKE_VIDPID(0x045e, 0x0768), - /* Microsoft Corp. Arc Touch Mouse Transceiver */ + // Microsoft Corp. Arc Touch Mouse Transceiver MAKE_VIDPID(0x045e, 0x0773), - /* Microsoft 2.4GHz Transceiver v9.0 */ - /* Microsoft Nano Transceiver v2.1 */ - /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */ + // Microsoft 2.4GHz Transceiver v9.0 + // Microsoft Nano Transceiver v2.1 + // Microsoft Sculpt Ergonomic Keyboard (5KV-00001) MAKE_VIDPID(0x045e, 0x07a5), - /* Microsoft Nano Transceiver v1.0 */ - /* Microsoft Wireless Keyboard 800 */ + // Microsoft Nano Transceiver v1.0 + // Microsoft Wireless Keyboard 800 MAKE_VIDPID(0x045e, 0x07b2), - /* Microsoft Nano Transceiver v2.0 */ + // 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 */ + // 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(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 */ + // 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 Huntsman V2 Analog, non-functional DInput device */ - MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntsman 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 Huntsman V2 Analog, non-functional DInput device + MAKE_VIDPID(0x1532, 0x0282), // Razer Huntsman 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 SDL_vidpid_list blacklist_devices = { SDL_HINT_JOYSTICK_BLACKLIST_DEVICES, 0, 0, NULL, @@ -283,13 +283,13 @@ static SDL_vidpid_list blacklist_devices = { }; static Uint32 initial_flightstick_devices[] = { - 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(0x362c, 0x0001), /* Yawman Arrow */ + 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(0x362c, 0x0001), // Yawman Arrow }; static SDL_vidpid_list flightstick_devices = { SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES, 0, 0, NULL, @@ -299,8 +299,8 @@ static SDL_vidpid_list flightstick_devices = { }; static Uint32 initial_gamecube_devices[] = { - MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */ - MAKE_VIDPID(0x20d6, 0xa711), /* PowerA Wired Controller Nintendo GameCube Style */ + MAKE_VIDPID(0x0e6f, 0x0185), // PDP Wired Fight Pad Pro for Nintendo Switch + MAKE_VIDPID(0x20d6, 0xa711), // PowerA Wired Controller Nintendo GameCube Style }; static SDL_vidpid_list gamecube_devices = { SDL_HINT_JOYSTICK_GAMECUBE_DEVICES, 0, 0, NULL, @@ -310,13 +310,13 @@ static SDL_vidpid_list gamecube_devices = { }; static Uint32 initial_rog_gamepad_mice[] = { - MAKE_VIDPID(0x0b05, 0x1906), /* ROG Pugio II */ - 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, 0x1906), // ROG Pugio II + 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 }; static SDL_vidpid_list rog_gamepad_mice = { SDL_HINT_ROG_GAMEPAD_MICE, 0, 0, NULL, @@ -326,8 +326,8 @@ static SDL_vidpid_list rog_gamepad_mice = { }; static Uint32 initial_throttle_devices[] = { - 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 }; static SDL_vidpid_list throttle_devices = { SDL_HINT_JOYSTICK_THROTTLE_DEVICES, 0, 0, NULL, @@ -337,66 +337,66 @@ static SDL_vidpid_list throttle_devices = { }; static Uint32 initial_wheel_devices[] = { - MAKE_VIDPID(0x0079, 0x1864), /* DragonRise Inc. Wired Wheel (active mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ - 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, 0xc268), /* Logitech PRO Racing Wheel (PC mode) */ - MAKE_VIDPID(0x046d, 0xc269), /* Logitech PRO Racing Wheel (PS4/PS5 mode) */ - MAKE_VIDPID(0x046d, 0xc272), /* Logitech PRO Racing Wheel for Xbox (PC mode) */ - MAKE_VIDPID(0x046d, 0xc26d), /* Logitech G923 (Xbox) */ - MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */ - MAKE_VIDPID(0x046d, 0xc266), /* Logitech G923 for Playstation 4 and PC (PC mode) */ - MAKE_VIDPID(0x046d, 0xc267), /* Logitech G923 for Playstation 4 and PC (PS4 mode)*/ - 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(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */ - MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */ - MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */ - MAKE_VIDPID(0x0483, 0xa355), /* VRS DirectForce Pro Wheel Base */ - MAKE_VIDPID(0x0eb7, 0x0001), /* Fanatec ClubSport Wheel Base V2 */ - MAKE_VIDPID(0x0eb7, 0x0004), /* Fanatec ClubSport Wheel Base V2.5 */ - MAKE_VIDPID(0x0eb7, 0x0005), /* Fanatec CSL Elite Wheel Base+ (PS4) */ - MAKE_VIDPID(0x0eb7, 0x0006), /* Fanatec Podium Wheel Base DD1 */ - MAKE_VIDPID(0x0eb7, 0x0007), /* Fanatec Podium Wheel Base DD2 */ - MAKE_VIDPID(0x0eb7, 0x0011), /* Fanatec Forza Motorsport (CSR Wheel / CSR Elite Wheel) */ - MAKE_VIDPID(0x0eb7, 0x0020), /* Fanatec generic wheel / CSL DD / GT DD Pro */ - MAKE_VIDPID(0x0eb7, 0x0197), /* Fanatec Porsche Wheel (Turbo / GT3 RS / Turbo S / GT3 V2 / GT2) */ - MAKE_VIDPID(0x0eb7, 0x038e), /* Fanatec ClubSport Wheel Base V1 */ - MAKE_VIDPID(0x0eb7, 0x0e03), /* Fanatec CSL Elite Wheel Base */ - MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ - MAKE_VIDPID(0x1209, 0xffb0), /* Generic FFBoard OpenFFBoard universal forcefeedback wheel */ - MAKE_VIDPID(0x16d0, 0x0d5a), /* Simucube 1 Wheelbase */ - MAKE_VIDPID(0x16d0, 0x0d5f), /* Simucube 2 Ultimate Wheelbase */ - MAKE_VIDPID(0x16d0, 0x0d60), /* Simucube 2 Pro Wheelbase */ - MAKE_VIDPID(0x16d0, 0x0d61), /* Simucube 2 Sport Wheelbase */ - MAKE_VIDPID(0x2433, 0xf300), /* Asetek SimSports Invicta Wheelbase */ - MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */ - MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ - MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ - MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */ - MAKE_VIDPID(0x3416, 0x0302), /* Cammus C12 Wheelbase */ - MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */ - MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */ - MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */ - MAKE_VIDPID(0x346e, 0x0005), /* Moza R3 Wheelbase */ - MAKE_VIDPID(0x346e, 0x0006), /* Moza R12 Wheelbase */ + MAKE_VIDPID(0x0079, 0x1864), // DragonRise Inc. Wired Wheel (active mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) + 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, 0xc268), // Logitech PRO Racing Wheel (PC mode) + MAKE_VIDPID(0x046d, 0xc269), // Logitech PRO Racing Wheel (PS4/PS5 mode) + MAKE_VIDPID(0x046d, 0xc272), // Logitech PRO Racing Wheel for Xbox (PC mode) + MAKE_VIDPID(0x046d, 0xc26d), // Logitech G923 (Xbox) + MAKE_VIDPID(0x046d, 0xc26e), // Logitech G923 + MAKE_VIDPID(0x046d, 0xc266), // Logitech G923 for Playstation 4 and PC (PC mode) + MAKE_VIDPID(0x046d, 0xc267), // Logitech G923 for Playstation 4 and PC (PS4 mode) + 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(0x044f, 0xb691), // Thrustmaster TS-XW (initial mode) + MAKE_VIDPID(0x044f, 0xb692), // Thrustmaster TS-XW (active mode) + MAKE_VIDPID(0x0483, 0x0522), // Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) + MAKE_VIDPID(0x0483, 0xa355), // VRS DirectForce Pro Wheel Base + MAKE_VIDPID(0x0eb7, 0x0001), // Fanatec ClubSport Wheel Base V2 + MAKE_VIDPID(0x0eb7, 0x0004), // Fanatec ClubSport Wheel Base V2.5 + MAKE_VIDPID(0x0eb7, 0x0005), // Fanatec CSL Elite Wheel Base+ (PS4) + MAKE_VIDPID(0x0eb7, 0x0006), // Fanatec Podium Wheel Base DD1 + MAKE_VIDPID(0x0eb7, 0x0007), // Fanatec Podium Wheel Base DD2 + MAKE_VIDPID(0x0eb7, 0x0011), // Fanatec Forza Motorsport (CSR Wheel / CSR Elite Wheel) + MAKE_VIDPID(0x0eb7, 0x0020), // Fanatec generic wheel / CSL DD / GT DD Pro + MAKE_VIDPID(0x0eb7, 0x0197), // Fanatec Porsche Wheel (Turbo / GT3 RS / Turbo S / GT3 V2 / GT2) + MAKE_VIDPID(0x0eb7, 0x038e), // Fanatec ClubSport Wheel Base V1 + MAKE_VIDPID(0x0eb7, 0x0e03), // Fanatec CSL Elite Wheel Base + MAKE_VIDPID(0x11ff, 0x0511), // DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) + MAKE_VIDPID(0x1209, 0xffb0), // Generic FFBoard OpenFFBoard universal forcefeedback wheel + MAKE_VIDPID(0x16d0, 0x0d5a), // Simucube 1 Wheelbase + MAKE_VIDPID(0x16d0, 0x0d5f), // Simucube 2 Ultimate Wheelbase + MAKE_VIDPID(0x16d0, 0x0d60), // Simucube 2 Pro Wheelbase + MAKE_VIDPID(0x16d0, 0x0d61), // Simucube 2 Sport Wheelbase + MAKE_VIDPID(0x2433, 0xf300), // Asetek SimSports Invicta Wheelbase + MAKE_VIDPID(0x2433, 0xf301), // Asetek SimSports Forte Wheelbase + MAKE_VIDPID(0x2433, 0xf303), // Asetek SimSports La Prima Wheelbase + MAKE_VIDPID(0x2433, 0xf306), // Asetek SimSports Tony Kannan Wheelbase + MAKE_VIDPID(0x3416, 0x0301), // Cammus C5 Wheelbase + MAKE_VIDPID(0x3416, 0x0302), // Cammus C12 Wheelbase + MAKE_VIDPID(0x346e, 0x0000), // Moza R16/R21 Wheelbase + MAKE_VIDPID(0x346e, 0x0002), // Moza R9 Wheelbase + MAKE_VIDPID(0x346e, 0x0004), // Moza R5 Wheelbase + MAKE_VIDPID(0x346e, 0x0005), // Moza R3 Wheelbase + MAKE_VIDPID(0x346e, 0x0006), // Moza R12 Wheelbase }; static SDL_vidpid_list wheel_devices = { SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL, @@ -406,8 +406,8 @@ static SDL_vidpid_list wheel_devices = { }; static Uint32 initial_zero_centered_devices[] = { - 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 }; static SDL_vidpid_list zero_centered_devices = { SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES, 0, 0, NULL, @@ -449,7 +449,7 @@ void SDL_UnlockJoysticks(void) --SDL_joysticks_locked; if (!SDL_joysticks_initialized) { - /* NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks */ + // NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks if (!SDL_joysticks_locked && SDL_AtomicGet(&SDL_joystick_lock_pending) == 0) { last_unlock = SDL_TRUE; } @@ -572,11 +572,11 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID SDL_memset(&SDL_joystick_players[SDL_joystick_player_count], 0, (player_index - SDL_joystick_player_count + 1) * sizeof(SDL_joystick_players[0])); SDL_joystick_player_count = player_index + 1; } else if (player_index >= 0 && SDL_joystick_players[player_index] == instance_id) { - /* Joystick is already assigned the requested player index */ + // Joystick is already assigned the requested player index return SDL_TRUE; } - /* Clear the old player index */ + // Clear the old player index existing_player_index = SDL_GetPlayerIndexForJoystickID(instance_id); if (existing_player_index >= 0) { SDL_joystick_players[existing_player_index] = 0; @@ -586,12 +586,12 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID SDL_joystick_players[player_index] = instance_id; } - /* Update the driver with the new index */ + // Update the driver with the new index if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) { driver->SetDevicePlayerIndex(device_index, player_index); } - /* Move any existing joystick to another slot */ + // Move any existing joystick to another slot if (existing_instance > 0) { SDL_SetJoystickIDForPlayerIndex(SDL_FindFreePlayerIndex(), existing_instance); } @@ -611,7 +611,7 @@ int SDL_InitJoysticks(void) { int i, status; - /* Create the joystick list lock */ + // Create the joystick list lock if (SDL_joystick_lock == NULL) { SDL_joystick_lock = SDL_CreateMutex(); } @@ -635,7 +635,7 @@ int SDL_InitJoysticks(void) SDL_LoadVIDPIDList(&wheel_devices); SDL_LoadVIDPIDList(&zero_centered_devices); - /* See if we should allow joystick events while in the background */ + // See if we should allow joystick events while in the background SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); @@ -682,7 +682,7 @@ SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, U { for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { if (driver == SDL_joystick_drivers[i]) { - /* Higher priority drivers do not have this device */ + // Higher priority drivers do not have this device break; } if (SDL_joystick_drivers[i]->IsDevicePresent(vendor_id, product_id, version, name)) { @@ -835,15 +835,15 @@ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) #ifdef SDL_PLATFORM_WINRT return SDL_TRUE; #else - /*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/ + // printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes); if (joystick->naxes == 2) { - /* Assume D-pad or thumbstick style axes are centered at 0 */ + // Assume D-pad or thumbstick style axes are centered at 0 return SDL_TRUE; } return SDL_VIDPIDInList(SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick), &zero_centered_devices); -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT } static SDL_bool IsROGAlly(SDL_Joystick *joystick) @@ -851,10 +851,10 @@ static SDL_bool IsROGAlly(SDL_Joystick *joystick) Uint16 vendor, product; SDL_GUID guid = SDL_GetJoystickGUID(joystick); - /* The ROG Ally controller spoofs an Xbox 360 controller */ + // The ROG Ally controller spoofs an Xbox 360 controller SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER) { - /* Check to see if this system has the expected sensors */ + // Check to see if this system has the expected sensors SDL_bool has_ally_accel = SDL_FALSE; SDL_bool has_ally_gyro = SDL_FALSE; @@ -898,12 +898,12 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve *invert_sensors = SDL_FALSE; - /* The SDL controller sensor API is only available for gamepads (at the moment) */ + // The SDL controller sensor API is only available for gamepads (at the moment) if (!SDL_IsGamepad(joystick->instance_id)) { return SDL_FALSE; } - /* If the controller already has sensors, use those */ + // If the controller already has sensors, use those if (joystick->nsensors > 0) { return SDL_FALSE; } @@ -924,7 +924,7 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve SDL_bool enabled; SDL_zero(gamepads); - /* See if the gamepad is in our list of devices to enable */ + // See if the gamepad is in our list of devices to enable guid = SDL_GetJoystickGUID(joystick); SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); SDL_LoadVIDPIDListFromHints(&gamepads, hint, NULL); @@ -935,7 +935,7 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve } } - /* See if this is another known wraparound gamepad */ + // See if this is another known wraparound gamepad if (joystick->name && (SDL_strstr(joystick->name, "Backbone One") || SDL_strstr(joystick->name, "Kishi"))) { @@ -968,14 +968,14 @@ static void AttemptSensorFusion(SDL_Joystick *joystick, SDL_bool invert_sensors) SDL_SensorID sensor = sensors[i]; if (!joystick->accel_sensor && SDL_GetSensorTypeForID(sensor) == SDL_SENSOR_ACCEL) { - /* Increment the sensor subsystem reference count */ + // Increment the sensor subsystem reference count SDL_InitSubSystem(SDL_INIT_SENSOR); joystick->accel_sensor = sensor; SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f); } if (!joystick->gyro_sensor && SDL_GetSensorTypeForID(sensor) == SDL_SENSOR_GYRO) { - /* Increment the sensor subsystem reference count */ + // Increment the sensor subsystem reference count SDL_InitSubSystem(SDL_INIT_SENSOR); joystick->gyro_sensor = sensor; @@ -1034,7 +1034,7 @@ static void CleanupSensorFusion(SDL_Joystick *joystick) } joystick->accel_sensor = 0; - /* Decrement the sensor subsystem reference count */ + // Decrement the sensor subsystem reference count SDL_QuitSubSystem(SDL_INIT_SENSOR); } if (joystick->gyro_sensor) { @@ -1044,7 +1044,7 @@ static void CleanupSensorFusion(SDL_Joystick *joystick) } joystick->gyro_sensor = 0; - /* Decrement the sensor subsystem reference count */ + // Decrement the sensor subsystem reference count SDL_QuitSubSystem(SDL_INIT_SENSOR); } } @@ -1089,7 +1089,7 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) joysticklist = joysticklist->next; } - /* Create and initialize the joystick */ + // Create and initialize the joystick joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); if (!joystick) { SDL_UnlockJoysticks(); @@ -1142,7 +1142,7 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) return NULL; } - /* If this joystick is known to have all zero centered axes, skip the auto-centering code */ + // If this joystick is known to have all zero centered axes, skip the auto-centering code if (SDL_JoystickAxesCenteredAtZero(joystick)) { int i; @@ -1151,20 +1151,20 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) } } - /* Get the Steam Input API handle */ + // Get the Steam Input API handle info = SDL_GetJoystickVirtualGamepadInfoForID(instance_id); if (info) { joystick->steam_handle = info->handle; } - /* Use system gyro and accelerometer if the gamepad doesn't have built-in sensors */ + // Use system gyro and accelerometer if the gamepad doesn't have built-in sensors if (ShouldAttemptSensorFusion(joystick, &invert_sensors)) { AttemptSensorFusion(joystick, invert_sensors); } - /* Add joystick to list */ + // Add joystick to list ++joystick->ref_count; - /* Link the joystick in the list */ + // Link the joystick in the list joystick->next = SDL_joysticks; SDL_joysticks = joystick; @@ -1730,7 +1730,7 @@ int SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint if (low_frequency_rumble == joystick->low_frequency_rumble && high_frequency_rumble == joystick->high_frequency_rumble) { - /* Just update the expiration */ + // Just update the expiration retval = 0; } else { retval = joystick->driver->Rumble(joystick, low_frequency_rumble, high_frequency_rumble); @@ -1773,7 +1773,7 @@ int SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1 CHECK_JOYSTICK_MAGIC(joystick, -1); if (left_rumble == joystick->left_trigger_rumble && right_rumble == joystick->right_trigger_rumble) { - /* Just update the expiration */ + // Just update the expiration retval = 0; } else { retval = joystick->driver->RumbleTriggers(joystick, left_rumble, right_rumble); @@ -1812,11 +1812,11 @@ int SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blu retval = joystick->driver->SetLED(joystick, red, green, blue); joystick->led_expiration = SDL_GetTicks() + SDL_LED_MIN_REPEAT_MS; } else { - /* Avoid spamming the driver */ + // Avoid spamming the driver retval = 0; } - /* Save the LED value regardless of success, so we don't spam the driver */ + // Save the LED value regardless of success, so we don't spam the driver joystick->led_red = red; joystick->led_green = green; joystick->led_blue = blue; @@ -1854,7 +1854,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick) { CHECK_JOYSTICK_MAGIC(joystick,); - /* First decrement ref count */ + // First decrement ref count if (--joystick->ref_count > 0) { SDL_UnlockJoysticks(); return; @@ -1880,7 +1880,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick) while (joysticklist) { if (joystick == joysticklist) { if (joysticklistprev) { - /* unlink this entry */ + // unlink this entry joysticklistprev->next = joysticklist->next; } else { SDL_joysticks = joystick->next; @@ -1891,7 +1891,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick) joysticklist = joysticklist->next; } - /* Free the data associated with this joystick */ + // Free the data associated with this joystick SDL_free(joystick->name); SDL_free(joystick->path); SDL_free(joystick->serial); @@ -1932,7 +1932,7 @@ void SDL_QuitJoysticks(void) SDL_CloseJoystick(SDL_joysticks); } - /* Quit drivers in reverse order to avoid breaking dependencies between drivers */ + // 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(); } @@ -1974,13 +1974,13 @@ static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent(void) } if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) { - /* We have windows but we don't have focus, ignore the event. */ + // We have windows but we don't have focus, ignore the event. return SDL_TRUE; } return SDL_FALSE; } -/* These are global for SDL_sysjoystick.c and SDL_events.c */ +// These are global for SDL_sysjoystick.c and SDL_events.c void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers) { @@ -1999,7 +1999,7 @@ void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers) touchpad->nfingers = nfingers; touchpad->fingers = fingers; } else { - /* Out of memory, this touchpad won't be active */ + // Out of memory, this touchpad won't be active touchpad->nfingers = 0; touchpad->fingers = NULL; } @@ -2100,7 +2100,7 @@ void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - /* Tell the app that everything is centered/unpressed... */ + // Tell the app that everything is centered/unpressed... for (i = 0; i < joystick->naxes; i++) { if (joystick->axes[i].has_initial_value) { SDL_SendJoystickAxis(timestamp, joystick, i, joystick->axes[i].zero); @@ -2132,7 +2132,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id) SDL_AssertJoysticksLocked(); - /* Find this joystick... */ + // Find this joystick... for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->instance_id == instance_id) { SDL_PrivateJoystickForceRecentering(joystick); @@ -2166,7 +2166,7 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S SDL_AssertJoysticksLocked(); - /* Make sure we're not getting garbage or duplicate events */ + // Make sure we're not getting garbage or duplicate events if (axis >= joystick->naxes) { return 0; } @@ -2184,8 +2184,8 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S info->has_second_value = SDL_TRUE; } 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 */ + // 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 if (SDL_abs(value - info->value) <= MAX_ALLOWED_JITTER && !SDL_IsJoystickVIRTUAL(joystick->guid)) { return 0; @@ -2207,12 +2207,12 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S } } - /* Update internal joystick state */ + // Update internal joystick state SDL_assert(timestamp != 0); info->value = value; joystick->update_complete = timestamp; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_JOYSTICK_AXIS_MOTION)) { SDL_Event event; @@ -2232,21 +2232,21 @@ int SDL_SendJoystickBall(Uint64 timestamp, SDL_Joystick *joystick, Uint8 ball, S SDL_AssertJoysticksLocked(); - /* Make sure we're not getting garbage events */ + // Make sure we're not getting garbage events if (ball >= joystick->nballs) { return 0; } - /* We ignore events if we don't have keyboard focus. */ + // We ignore events if we don't have keyboard focus. if (SDL_PrivateJoystickShouldIgnoreEvent()) { return 0; } - /* Update internal mouse state */ + // Update internal mouse state joystick->balls[ball].dx += xrel; joystick->balls[ball].dy += yrel; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_JOYSTICK_BALL_MOTION)) { SDL_Event event; @@ -2267,7 +2267,7 @@ int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uin SDL_AssertJoysticksLocked(); - /* Make sure we're not getting garbage or duplicate events */ + // Make sure we're not getting garbage or duplicate events if (hat >= joystick->nhats) { return 0; } @@ -2284,12 +2284,12 @@ int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uin } } - /* Update internal joystick state */ + // Update internal joystick state SDL_assert(timestamp != 0); joystick->hats[hat] = value; joystick->update_complete = timestamp; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_JOYSTICK_HAT_MOTION)) { SDL_Event event; @@ -2318,11 +2318,11 @@ int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butto event.type = SDL_EVENT_JOYSTICK_BUTTON_UP; break; default: - /* Invalid state -- bail */ + // Invalid state -- bail return 0; } - /* Make sure we're not getting garbage or duplicate events */ + // Make sure we're not getting garbage or duplicate events if (button >= joystick->nbuttons) { return 0; } @@ -2338,12 +2338,12 @@ int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butto } } - /* Update internal joystick state */ + // Update internal joystick state SDL_assert(timestamp != 0); joystick->buttons[button] = state; joystick->update_complete = timestamp; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(event.type)) { event.common.timestamp = timestamp; @@ -2360,7 +2360,7 @@ static void SendSteamHandleUpdateEvents(void) SDL_Joystick *joystick; const SDL_SteamVirtualGamepadInfo *info; - /* Check to see if any Steam handles changed */ + // Check to see if any Steam handles changed for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { SDL_bool changed = SDL_FALSE; @@ -2409,9 +2409,9 @@ void SDL_UpdateJoysticks(void) } #ifdef SDL_JOYSTICK_HIDAPI - /* Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks */ + // Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks HIDAPI_UpdateDevices(); -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (!joystick->attached) { @@ -2630,7 +2630,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n } else if (*product_name) { name = SDL_strdup(product_name); } else if (vendor || product) { - /* Couldn't find a controller name, try to give it one based on device type */ + // Couldn't find a controller name, try to give it one based on device type switch (SDL_GetGamepadTypeFromVIDPID(vendor, product, NULL, SDL_TRUE)) { case SDL_GAMEPAD_TYPE_XBOX360: name = SDL_strdup("Xbox 360 Controller"); @@ -2666,13 +2666,13 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n return NULL; } - /* Trim trailing whitespace */ + // Trim trailing whitespace for (len = SDL_strlen(name); (len > 0 && name[len - 1] == ' '); --len) { - /* continue */ + // continue } name[len] = '\0'; - /* Compress duplicate spaces */ + // Compress duplicate spaces for (i = 0; i < (len - 1);) { if (name[i] == ' ' && name[i + 1] == ' ') { SDL_memmove(&name[i], &name[i + 1], (len - i)); @@ -2682,7 +2682,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n } } - /* Perform any manufacturer replacements */ + // Perform any manufacturer replacements for (i = 0; i < SDL_arraysize(replacements); ++i) { size_t prefixlen = SDL_strlen(replacements[i].prefix); if (SDL_strncasecmp(name, replacements[i].prefix, prefixlen) == 0) { @@ -2692,7 +2692,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n SDL_memmove(name + replacementlen, name + prefixlen, (len - prefixlen) + 1); len -= (prefixlen - replacementlen); } else { - /* FIXME: Need to handle the expand case by reallocating the string */ + // FIXME: Need to handle the expand case by reallocating the string } break; } @@ -2711,7 +2711,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n --matchlen; } if (matchlen > 0) { - /* We matched the manufacturer's name and removed it */ + // We matched the manufacturer's name and removed it break; } } @@ -2735,8 +2735,8 @@ SDL_GUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint1 crc = SDL_crc16(crc, product_name, SDL_strlen(product_name)); } - /* We only need 16 bits for each of these; space them out to fill 128. */ - /* Byteswap so devices get same GUID on little/big endian platforms. */ + // We only need 16 bits for each of these; space them out to fill 128. + // Byteswap so devices get same GUID on little/big endian platforms. *guid16++ = SDL_Swap16LE(bus); *guid16++ = SDL_Swap16LE(crc); @@ -2801,12 +2801,12 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons SDL_GamepadType type = SDL_GAMEPAD_TYPE_STANDARD; if (vendor == 0x0000 && product == 0x0000) { - /* Some devices are only identifiable by their name */ + // Some devices are only identifiable by their name if (name && (SDL_strcmp(name, "Lic Pro Controller") == 0 || SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 || SDL_strcmp(name, "Wireless Gamepad") == 0)) { - /* HORI or PowerA Switch Pro Controller clone */ + // HORI or PowerA Switch Pro Controller clone type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO; } @@ -2818,7 +2818,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons } else if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) { if (name && SDL_strstr(name, "NES Controller") != NULL) { - /* We don't have a type for the Nintendo Online NES Controller */ + // We don't have a type for the Nintendo Online NES Controller type = SDL_GAMEPAD_TYPE_STANDARD; } else { type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT; @@ -2835,7 +2835,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR; } else if (forUI && SDL_IsJoystickGameCube(vendor, product)) { - /* We don't have a type for the Nintendo GameCube controller */ + // We don't have a type for the Nintendo GameCube controller type = SDL_GAMEPAD_TYPE_STANDARD; } else { @@ -2889,14 +2889,14 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name) type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, SDL_TRUE); if (type == SDL_GAMEPAD_TYPE_STANDARD) { if (SDL_IsJoystickXInput(guid)) { - /* This is probably an Xbox One controller */ + // This is probably an Xbox One controller return SDL_GAMEPAD_TYPE_XBOXONE; } #ifdef SDL_JOYSTICK_HIDAPI if (SDL_IsJoystickHIDAPI(guid)) { return HIDAPI_GetGamepadTypeFromGUID(guid); } -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI } return type; } @@ -2906,7 +2906,7 @@ SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid) Uint16 vendor, product; if (SDL_IsJoystickMFI(guid)) { - /* The version bits are used as button capability mask */ + // The version bits are used as button capability mask return SDL_FALSE; } @@ -3195,25 +3195,25 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_GUID guid) } if (SDL_IsJoystickXInput(guid)) { - /* XInput GUID, get the type based on the XInput device subtype */ + // 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_GAMEPAD; - 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; @@ -3232,7 +3232,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_GUID guid) if (SDL_IsJoystickHIDAPI(guid)) { return HIDAPI_GetJoystickTypeFromGUID(guid); } -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI if (GuessControllerType(vendor, product) != k_eControllerType_UnknownNonSteamController) { return SDL_JOYSTICK_TYPE_GAMEPAD; @@ -3248,7 +3248,7 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid) SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); - /* Check the joystick blacklist */ + // Check the joystick blacklist if (SDL_VIDPIDInList(vendor, product, &blacklist_devices)) { return SDL_TRUE; } @@ -3265,7 +3265,7 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid) return SDL_FALSE; } -/* return the guid for this index */ +// return the guid for this index SDL_GUID SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id) { SDL_JoystickDriver *driver; @@ -3583,14 +3583,14 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch event_type = SDL_EVENT_GAMEPAD_TOUCHPAD_UP; } - /* We ignore events if we don't have keyboard focus, except for touch release */ + // We ignore events if we don't have keyboard focus, except for touch release if (SDL_PrivateJoystickShouldIgnoreEvent()) { if (event_type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP) { return 0; } } - /* Update internal joystick state */ + // Update internal joystick state SDL_assert(timestamp != 0); finger_info->state = state; finger_info->x = x; @@ -3598,7 +3598,7 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch finger_info->pressure = pressure; joystick->update_complete = timestamp; - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(event_type)) { SDL_Event event; @@ -3622,7 +3622,7 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT SDL_AssertJoysticksLocked(); - /* We ignore events if we don't have keyboard focus */ + // We ignore events if we don't have keyboard focus if (SDL_PrivateJoystickShouldIgnoreEvent()) { return 0; } @@ -3634,11 +3634,11 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT if (sensor->enabled) { num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); - /* Update internal sensor state */ + // Update internal sensor state SDL_memcpy(sensor->data, data, num_values * sizeof(*data)); joystick->update_complete = timestamp; - /* Post the event, if desired */ + // Post the event, if desired if (SDL_EventEnabled(SDL_EVENT_GAMEPAD_SENSOR_UPDATE)) { SDL_Event event; event.type = SDL_EVENT_GAMEPAD_SENSOR_UPDATE; @@ -3690,7 +3690,7 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, int *num_entries, int * int new_max_entries = *max_entries + 16; Uint32 *new_entries = (Uint32 *)SDL_realloc(*entries, new_max_entries * sizeof(**entries)); if (!new_entries) { - /* Out of memory, go with what we have already */ + // Out of memory, go with what we have already break; } *entries = new_entries; @@ -3706,11 +3706,11 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, int *num_entries, int * void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list) { - /* Empty the list */ + // Empty the list list->num_included_entries = 0; list->num_excluded_entries = 0; - /* Add the initial entries */ + // Add the initial entries if (list->num_initial_entries > 0) { if (list->num_included_entries < list->num_initial_entries) { Uint32 *entries = (Uint32 *)SDL_malloc(list->num_initial_entries * sizeof(*entries)); @@ -3723,10 +3723,10 @@ void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_lis } } - /* Add the included entries from the hint */ + // Add the included entries from the hint SDL_LoadVIDPIDListFromHint(included_list, &list->num_included_entries, &list->max_included_entries, &list->included_entries); - /* Add the excluded entries from the hint */ + // Add the excluded entries from the hint SDL_LoadVIDPIDListFromHint(excluded_list, &list->num_excluded_entries, &list->max_excluded_entries, &list->excluded_entries); } diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h index 3675089989..44ec8c3ffb 100644 --- a/src/joystick/SDL_joystick_c.h +++ b/src/joystick/SDL_joystick_c.h @@ -24,9 +24,9 @@ #include "SDL_internal.h" -/* Useful functions and variables from SDL_joystick.c */ +// Useful functions and variables from SDL_joystick.c -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -34,26 +34,26 @@ extern "C" { struct SDL_JoystickDriver; struct SDL_SteamVirtualGamepadInfo; -/* Initialization and shutdown functions */ +// Initialization and shutdown functions extern int SDL_InitJoysticks(void); extern void SDL_QuitJoysticks(void); -/* Return whether the joystick system is currently initialized */ +// Return whether the joystick system is currently initialized extern SDL_bool SDL_JoysticksInitialized(void); -/* Return whether the joystick system is shutting down */ +// Return whether the joystick system is shutting down extern SDL_bool SDL_JoysticksQuitting(void); -/* Return whether the joysticks are currently locked */ +// Return whether the joysticks are currently locked extern SDL_bool SDL_JoysticksLocked(void); -/* Make sure we currently have the joysticks locked */ +// Make sure we currently have the joysticks locked extern void SDL_AssertJoysticksLocked(void) SDL_ASSERT_CAPABILITY(SDL_joystick_lock); -/* Function to return whether there are any joysticks opened by the application */ +// Function to return whether there are any joysticks opened by the application extern SDL_bool SDL_JoysticksOpened(void); -/* Function to determine whether a device is currently detected by this driver */ +// Function to determine whether a device is currently detected by this driver extern SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); /* Function to standardize the name for a controller @@ -61,51 +61,51 @@ extern SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *dr */ extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name); -/* Function to create a GUID for a joystick based on the VID/PID and name */ +// Function to create a GUID for a joystick based on the VID/PID and name extern SDL_GUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data); -/* Function to create a GUID for a joystick based on the name, with no VID/PID information */ +// Function to create a GUID for a joystick based on the name, with no VID/PID information extern SDL_GUID SDL_CreateJoystickGUIDForName(const char *name); -/* Function to set the vendor field of a joystick GUID */ +// Function to set the vendor field of a joystick GUID extern void SDL_SetJoystickGUIDVendor(SDL_GUID *guid, Uint16 vendor); -/* Function to set the product field of a joystick GUID */ +// Function to set the product field of a joystick GUID extern void SDL_SetJoystickGUIDProduct(SDL_GUID *guid, Uint16 product); -/* Function to set the version field of a joystick GUID */ +// Function to set the version field of a joystick GUID extern void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version); -/* Function to set the CRC field of a joystick GUID */ +// Function to set the CRC field of a joystick GUID extern void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc); -/* Function to return the type of a controller */ +// Function to return the type of a controller extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI); extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name); -/* Function to return whether a joystick GUID uses the version field */ +// Function to return whether a joystick GUID uses the version field extern SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid); -/* Function to return whether a joystick is an Xbox One controller */ +// Function to return whether a joystick is an Xbox One controller extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is an Xbox One Elite controller */ +// Function to return whether a joystick is an Xbox One Elite controller extern SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is an Xbox Series X controller */ +// Function to return whether a joystick is an Xbox Series X controller extern SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is an Xbox One controller connected via Bluetooth */ +// Function to return whether a joystick is an Xbox One controller connected via Bluetooth extern SDL_bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a PS4 controller */ +// Function to return whether a joystick is a PS4 controller extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a PS5 controller */ +// Function to return whether a joystick is a PS5 controller extern SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a Nintendo Switch Pro controller */ +// Function to return whether a joystick is a Nintendo Switch Pro controller extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); @@ -114,46 +114,46 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a Nintendo GameCube style controller */ +// Function to return whether a joystick is a Nintendo GameCube style controller extern SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is an Amazon Luna controller */ +// Function to return whether a joystick is an Amazon Luna controller extern SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a Google Stadia controller */ +// Function to return whether a joystick is a Google Stadia controller extern SDL_bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is an NVIDIA SHIELD controller */ +// Function to return whether a joystick is an NVIDIA SHIELD controller extern SDL_bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a Steam Controller */ +// Function to return whether a joystick is a Steam Controller extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick is a Steam Deck */ +// Function to return whether a joystick is a Steam Deck extern SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); -/* Function to return whether a joystick guid comes from the XInput driver */ +// Function to return whether a joystick guid comes from the XInput driver extern SDL_bool SDL_IsJoystickXInput(SDL_GUID guid); -/* Function to return whether a joystick guid comes from the WGI driver */ +// Function to return whether a joystick guid comes from the WGI driver extern SDL_bool SDL_IsJoystickWGI(SDL_GUID guid); -/* Function to return whether a joystick guid comes from the HIDAPI driver */ +// Function to return whether a joystick guid comes from the HIDAPI driver extern SDL_bool SDL_IsJoystickHIDAPI(SDL_GUID guid); -/* Function to return whether a joystick guid comes from the MFI driver */ +// Function to return whether a joystick guid comes from the MFI driver extern SDL_bool SDL_IsJoystickMFI(SDL_GUID guid); -/* Function to return whether a joystick guid comes from the RAWINPUT driver */ +// Function to return whether a joystick guid comes from the RAWINPUT driver extern SDL_bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); -/* Function to return whether a joystick guid comes from the Virtual driver */ +// Function to return whether a joystick guid comes from the Virtual driver extern SDL_bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); -/* Function to return whether a joystick should be ignored */ +// Function to return whether a joystick should be ignored extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid); -/* Internal event queueing functions */ +// Internal event queueing functions extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate); extern void SDL_PrivateJoystickSensorRate(SDL_Joystick *joystick, SDL_SensorType type, float rate); @@ -169,10 +169,10 @@ extern int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, in extern int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent); -/* Function to get the Steam virtual gamepad info for a joystick */ +// Function to get the Steam virtual gamepad info for a joystick extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickVirtualGamepadInfoForID(SDL_JoystickID instance_id); -/* Internal sanity checking functions */ +// Internal sanity checking functions extern SDL_bool SDL_IsJoystickValid(SDL_Joystick *joystick); typedef enum @@ -228,7 +228,7 @@ typedef struct SDL_GamepadMapping SDL_InputMapping touchpad; } SDL_GamepadMapping; -/* Function to get autodetected gamepad controller mapping from the driver */ +// Function to get autodetected gamepad controller mapping from the driver extern SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, SDL_GamepadMapping *out); @@ -256,9 +256,9 @@ extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *inclu extern SDL_bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_joystick_c_h_ */ +#endif // SDL_joystick_c_h_ diff --git a/src/joystick/SDL_steam_virtual_gamepad.c b/src/joystick/SDL_steam_virtual_gamepad.c index 602c3d8050..667ada77ad 100644 --- a/src/joystick/SDL_steam_virtual_gamepad.c +++ b/src/joystick/SDL_steam_virtual_gamepad.c @@ -108,7 +108,7 @@ static void AddVirtualGamepadInfo(int slot, SDL_SteamVirtualGamepadInfo *info) } if (SDL_steam_virtual_gamepad_info[slot]) { - /* We already have this slot info */ + // We already have this slot info return; } diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 7871412ee1..35f785d1cc 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -23,25 +23,25 @@ #ifndef SDL_sysjoystick_h_ #define SDL_sysjoystick_h_ -/* This is the system specific header for the SDL joystick API */ +// This is the system specific header for the SDL joystick API #include "SDL_joystick_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* The SDL joystick structure */ +// 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 */ - SDL_bool sending_initial_value; /* Whether we are sending 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; typedef struct SDL_JoystickBallData @@ -69,37 +69,37 @@ typedef struct SDL_JoystickSensorInfo SDL_SensorType type; SDL_bool enabled; float rate; - float data[3]; /* If this needs to expand, update SDL_GamepadSensorEvent */ + float data[3]; // If this needs to expand, update SDL_GamepadSensorEvent } SDL_JoystickSensorInfo; #define _guarded SDL_GUARDED_BY(SDL_joystick_lock) struct SDL_Joystick { - SDL_JoystickID instance_id _guarded; /* Device instance, monotonically increasing from 0 */ - char *name _guarded; /* Joystick name - system dependent */ - char *path _guarded; /* Joystick path - system dependent */ - char *serial _guarded; /* Joystick serial */ - SDL_GUID guid _guarded; /* Joystick guid */ - Uint16 firmware_version _guarded; /* Firmware version, if available */ - Uint64 steam_handle _guarded; /* Steam controller API handle */ + SDL_JoystickID instance_id _guarded; // Device instance, monotonically increasing from 0 + char *name _guarded; // Joystick name - system dependent + char *path _guarded; // Joystick path - system dependent + char *serial _guarded; // Joystick serial + SDL_GUID guid _guarded; // Joystick guid + Uint16 firmware_version _guarded; // Firmware version, if available + Uint64 steam_handle _guarded; // Steam controller API handle - int naxes _guarded; /* Number of axis controls on the joystick */ + int naxes _guarded; // Number of axis controls on the joystick SDL_JoystickAxisInfo *axes _guarded; - int nballs _guarded; /* Number of trackballs on the joystick */ - SDL_JoystickBallData *balls _guarded; /* Current ball motion deltas */ + int nballs _guarded; // Number of trackballs on the joystick + SDL_JoystickBallData *balls _guarded; // Current ball motion deltas - int nhats _guarded; /* Number of hats on the joystick */ - Uint8 *hats _guarded; /* Current hat states */ + int nhats _guarded; // Number of hats on the joystick + Uint8 *hats _guarded; // Current hat states - int nbuttons _guarded; /* Number of buttons on the joystick */ - Uint8 *buttons _guarded; /* Current button states */ + int nbuttons _guarded; // Number of buttons on the joystick + Uint8 *buttons _guarded; // Current button states - int ntouchpads _guarded; /* Number of touchpads on the joystick */ - SDL_JoystickTouchpadInfo *touchpads _guarded; /* Current touchpad states */ + int ntouchpads _guarded; // Number of touchpads on the joystick + SDL_JoystickTouchpadInfo *touchpads _guarded; // Current touchpad states - int nsensors _guarded; /* Number of sensors on the joystick */ + int nsensors _guarded; // Number of sensors on the joystick int nsensors_enabled _guarded; SDL_JoystickSensorInfo *sensors _guarded; @@ -122,7 +122,7 @@ struct SDL_Joystick SDL_PowerState battery_state _guarded; int battery_percent _guarded; - SDL_bool delayed_guide_button _guarded; /* SDL_TRUE if this device has the guide button event delayed */ + SDL_bool delayed_guide_button _guarded; // SDL_TRUE if this device has the guide button event delayed SDL_SensorID accel_sensor _guarded; SDL_Sensor *accel _guarded; @@ -134,24 +134,24 @@ struct SDL_Joystick struct SDL_JoystickDriver *driver _guarded; - struct joystick_hwdata *hwdata _guarded; /* Driver dependent information */ + struct joystick_hwdata *hwdata _guarded; // Driver dependent information SDL_PropertiesID props _guarded; - int ref_count _guarded; /* Reference count for multiple opens */ + int ref_count _guarded; // Reference count for multiple opens - struct SDL_Joystick *next _guarded; /* pointer to next joystick we have allocated */ + struct SDL_Joystick *next _guarded; // pointer to next joystick we have allocated }; #undef _guarded -/* Device bus definitions */ +// 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 -/* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ +// Macro to combine a USB vendor ID and product ID into a single Uint32 value #define MAKE_VIDPID(VID, PID) (((Uint32)(VID)) << 16 | (PID)) typedef struct SDL_JoystickDriver @@ -162,34 +162,34 @@ typedef struct SDL_JoystickDriver */ int (*Init)(void); - /* Function to return the number of joystick devices plugged in right now */ + // Function to return the number of joystick devices plugged in right now int (*GetCount)(void); - /* Function to cause any queued joystick insertions to be processed */ + // Function to cause any queued joystick insertions to be processed void (*Detect)(void); - /* Function to determine whether a device is currently detected by this driver */ + // Function to determine whether a device is currently detected by this driver SDL_bool (*IsDevicePresent)(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); - /* Function to get the device-dependent name of a joystick */ + // Function to get the device-dependent name of a joystick const char *(*GetDeviceName)(int device_index); - /* Function to get the device-dependent path of a joystick */ + // Function to get the device-dependent path of a joystick const char *(*GetDevicePath)(int device_index); - /* Function to get the Steam virtual gamepad slot of a joystick */ + // Function to get the Steam virtual gamepad slot of a joystick int (*GetDeviceSteamVirtualGamepadSlot)(int device_index); - /* Function to get the player index of a joystick */ + // Function to get the player index of a joystick int (*GetDevicePlayerIndex)(int device_index); - /* Function to set the player index of a joystick */ + // Function to set the player index of a joystick void (*SetDevicePlayerIndex)(int device_index, int player_index); - /* Function to return the stable GUID for a plugged in device */ + // Function to return the stable GUID for a plugged in device SDL_GUID (*GetDeviceGUID)(int device_index); - /* Function to get the current instance id of the joystick located at device_index */ + // Function to get the current instance id of the joystick located at device_index SDL_JoystickID (*GetDeviceInstanceID)(int device_index); /* Function to open a joystick for use. @@ -199,17 +199,17 @@ typedef struct SDL_JoystickDriver */ int (*Open)(SDL_Joystick *joystick, int device_index); - /* Rumble functionality */ + // Rumble functionality int (*Rumble)(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); int (*RumbleTriggers)(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble); - /* LED functionality */ + // LED functionality int (*SetLED)(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); - /* General effects */ + // General effects int (*SendEffect)(SDL_Joystick *joystick, const void *data, int size); - /* Sensor functionality */ + // Sensor functionality int (*SetSensorsEnabled)(SDL_Joystick *joystick, SDL_bool enabled); /* Function to update the state of a joystick - called as a device poll. @@ -219,18 +219,18 @@ typedef struct SDL_JoystickDriver */ void (*Update)(SDL_Joystick *joystick); - /* Function to close a joystick after use */ + // Function to close a joystick after use void (*Close)(SDL_Joystick *joystick); - /* Function to perform any system-specific joystick related cleanup */ + // Function to perform any system-specific joystick related cleanup void (*Quit)(void); - /* Function to get the autodetected controller mapping; returns false if there isn't any. */ + // Function to get the autodetected controller mapping; returns false if there isn't any. 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 */ +// 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 /* Dualshock4 only rumbles for about 5 seconds max, resend rumble command every 2 seconds @@ -239,7 +239,7 @@ typedef struct SDL_JoystickDriver #define SDL_LED_MIN_REPEAT_MS 5000 -/* The available joystick drivers */ +// The available joystick drivers extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; extern SDL_JoystickDriver SDL_BSD_JoystickDriver; extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver; @@ -260,9 +260,9 @@ extern SDL_JoystickDriver SDL_VITA_JoystickDriver; extern SDL_JoystickDriver SDL_N3DS_JoystickDriver; extern SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver; -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_sysjoystick_h_ */ +#endif // SDL_sysjoystick_h_ diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index da1a109f5a..37bae4a0f6 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_ANDROID -#include /* For the definition of NULL */ +#include // For the definition of NULL #include "SDL_sysjoystick_c.h" #include "../SDL_joystick_c.h" @@ -32,7 +32,7 @@ #include "android/keycodes.h" -/* As of platform android-14, android/keycodes.h is missing these defines */ +// 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 @@ -66,10 +66,10 @@ static int numjoysticks = 0; */ static int keycode_to_SDL(int keycode) { - /* FIXME: If this function gets too unwieldy in the future, replace with a lookup table */ + // 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) */ + // Some gamepad buttons (API 9) case AKEYCODE_BUTTON_A: button = SDL_GAMEPAD_BUTTON_SOUTH; break; @@ -118,7 +118,7 @@ static int keycode_to_SDL(int keycode) button = 18; break; - /* D-Pad key codes (API 1) */ + // D-Pad key codes (API 1) case AKEYCODE_DPAD_UP: button = SDL_GAMEPAD_BUTTON_DPAD_UP; break; @@ -132,12 +132,12 @@ static int keycode_to_SDL(int keycode) button = SDL_GAMEPAD_BUTTON_DPAD_RIGHT; break; case AKEYCODE_DPAD_CENTER: - /* This is handled better by applications as the A button */ - /*button = 19;*/ + // This is handled better by applications as the A button + // button = 19; button = SDL_GAMEPAD_BUTTON_SOUTH; break; - /* More gamepad buttons (API 12), these get mapped to 20...35*/ + // More gamepad buttons (API 12), these get mapped to 20...35 case AKEYCODE_BUTTON_1: case AKEYCODE_BUTTON_2: case AKEYCODE_BUTTON_3: @@ -159,7 +159,7 @@ static int keycode_to_SDL(int keycode) default: return -1; - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break } /* This is here in case future generations, probably with six fingers per hand, @@ -190,7 +190,7 @@ static SDL_Scancode button_to_scancode(int button) return SDL_SCANCODE_RIGHT; } - /* Unsupported button */ + // Unsupported button return SDL_SCANCODE_UNKNOWN; } @@ -237,7 +237,7 @@ int Android_OnPadUp(int device_id, int keycode) int Android_OnJoy(int device_id, int axis, float value) { Uint64 timestamp = SDL_GetTicksNS(); - /* Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] */ + // Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] SDL_joylist_item *item; SDL_LockJoysticks(); @@ -311,7 +311,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v SDL_LockJoysticks(); if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { - /* Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input */ + // Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input if (naxes < 2 && nhats < 1) { goto done; } @@ -330,7 +330,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v #endif if (nhats > 0) { - /* Hat is translated into DPAD buttons */ + // Hat is translated into DPAD buttons button_mask |= ((1 << SDL_GAMEPAD_BUTTON_DPAD_UP) | (1 << SDL_GAMEPAD_BUTTON_DPAD_DOWN) | (1 << SDL_GAMEPAD_BUTTON_DPAD_LEFT) | @@ -340,7 +340,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor_id, product_id, 0, NULL, desc, 0, 0); - /* Update the GUID with capability bits */ + // Update the GUID with capability bits { Uint16 *guid16 = (Uint16 *)guid.data; guid16[6] = SDL_Swap16LE(button_mask); @@ -381,7 +381,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v SDL_joylist_tail = item; } - /* Need to increment the joystick count before we post the event */ + // Need to increment the joystick count before we post the event ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); @@ -406,7 +406,7 @@ int Android_RemoveJoystick(int device_id) SDL_LockJoysticks(); - /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ + // Don't call JoystickByDeviceId here or there'll be an infinite loop! while (item) { if (item->device_id == device_id) { break; @@ -433,7 +433,7 @@ int Android_RemoveJoystick(int device_id) SDL_joylist_tail = prev; } - /* Need to decrement the joystick count before we post the event */ + // Need to decrement the joystick count before we post the event --numjoysticks; SDL_PrivateJoystickRemoved(item->device_instance); @@ -482,7 +482,7 @@ static void ANDROID_JoystickDetect(void) static SDL_bool ANDROID_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -514,7 +514,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) item = item->next; } - /* Joystick not found, try adding it */ + // Joystick not found, try adding it ANDROID_JoystickDetect(); while (item) { @@ -652,7 +652,7 @@ static void ANDROID_JoystickQuit(void) SDL_joylist = SDL_joylist_tail = NULL; numjoysticks = 0; -#endif /* 0 */ +#endif // 0 } static SDL_bool ANDROID_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) @@ -684,4 +684,4 @@ SDL_JoystickDriver SDL_ANDROID_JoystickDriver = { ANDROID_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID diff --git a/src/joystick/android/SDL_sysjoystick_c.h b/src/joystick/android/SDL_sysjoystick_c.h index 96a90f5210..f107856577 100644 --- a/src/joystick/android/SDL_sysjoystick_c.h +++ b/src/joystick/android/SDL_sysjoystick_c.h @@ -35,12 +35,12 @@ extern int Android_OnHat(int device_id, int hat_id, int x, int y); extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, SDL_bool can_rumble); extern int Android_RemoveJoystick(int device_id); -/* A linked list of available joysticks */ +// A linked list of available joysticks typedef struct SDL_joylist_item { int device_instance; - int device_id; /* Android's device id */ - char *name; /* "SideWinder 3D Pro" or whatever */ + int device_id; // Android's device id + char *name; // "SideWinder 3D Pro" or whatever SDL_GUID guid; SDL_Joystick *joystick; int nbuttons, naxes, nhats; @@ -52,6 +52,6 @@ typedef struct SDL_joylist_item typedef SDL_joylist_item joystick_hwdata; -#endif /* SDL_sysjoystick_c_h_ */ +#endif // SDL_sysjoystick_c_h_ -#endif /* SDL_JOYSTICK_ANDROID */ +#endif // SDL_JOYSTICK_ANDROID diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m index 892e1a0150..8c05f496dd 100644 --- a/src/joystick/apple/SDL_mfijoystick.m +++ b/src/joystick/apple/SDL_mfijoystick.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the iOS implementation of the SDL joystick API */ +// This is the iOS implementation of the SDL joystick API #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" @@ -40,7 +40,7 @@ #ifndef NSAppKitVersionNumber10_15 #define NSAppKitVersionNumber10_15 1894 #endif -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS #ifdef SDL_JOYSTICK_MFI #import @@ -109,7 +109,7 @@ static id disconnectObserver = nil; #import #endif -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI static SDL_JoystickDeviceItem *deviceList = NULL; @@ -312,28 +312,28 @@ static BOOL ElementAlreadyHandled(SDL_JoystickDeviceItem *device, NSString *elem [element isEqualToString:@"Touchpad 2 Right"] || [element isEqualToString:@"Touchpad 2 Up"] || [element isEqualToString:@"Touchpad 2 Down"]) { - /* The touchpad is handled separately */ + // The touchpad is handled separately return TRUE; } if ([element isEqualToString:@"Button Home"]) { if (device->is_switch_joycon_pair) { - /* The Nintendo Switch JoyCon home button doesn't ever show as being held down */ + // The Nintendo Switch JoyCon home button doesn't ever show as being held down return TRUE; } #ifdef SDL_PLATFORM_TVOS - /* The OS uses the home button, it's not available to apps */ + // The OS uses the home button, it's not available to apps return TRUE; #endif } if ([element isEqualToString:@"Button Share"]) { if (device->is_backbone_one) { - /* The Backbone app uses share button */ + // The Backbone app uses share button return TRUE; } } return FALSE; } -#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ +#endif // ENABLE_PHYSICAL_INPUT_PROFILE static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller) { @@ -400,14 +400,14 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle (device->is_stadia && HIDAPI_IsDevicePresent(USB_VENDOR_GOOGLE, USB_PRODUCT_GOOGLE_STADIA_CONTROLLER, 0, "")) || (device->is_switch_joyconL && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT, 0, "")) || (device->is_switch_joyconR && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT, 0, ""))) { - /* The HIDAPI driver is taking care of this device */ + // The HIDAPI driver is taking care of this device return FALSE; } #endif CheckControllerSiriRemote(controller, &device->is_siri_remote); if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { - /* Ignore remotes, they'll be handled as keyboard input */ + // Ignore remotes, they'll be handled as keyboard input return SDL_FALSE; } @@ -435,17 +435,17 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle } else if (device->is_xbox) { vendor = USB_VENDOR_MICROSOFT; if (device->has_xbox_paddles) { - /* Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID */ + // Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID product = USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH; } else if (device->has_xbox_share_button) { - /* Assume Xbox Series X Controller unless/until GCController flows VID/PID */ + // Assume Xbox Series X Controller unless/until GCController flows VID/PID product = USB_PRODUCT_XBOX_SERIES_X_BLE; } else { - /* Assume Xbox One S Bluetooth Controller unless/until GCController flows VID/PID */ + // Assume Xbox One S Bluetooth Controller unless/until GCController flows VID/PID product = USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH; } } else if (device->is_ps4) { - /* Assume DS4 Slim unless/until GCController flows VID/PID */ + // Assume DS4 Slim unless/until GCController flows VID/PID vendor = USB_VENDOR_SONY; product = USB_PRODUCT_SONY_DS4_SLIM; if (device->has_dualshock_touchpad) { @@ -489,7 +489,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle subtype = 3; #endif } else { - /* We don't know how to get input events from this device */ + // We don't know how to get input events from this device return SDL_FALSE; } @@ -497,7 +497,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { NSDictionary *elements = controller.physicalInputProfile.elements; - /* Provide both axes and analog buttons as SDL axes */ + // Provide both axes and analog buttons as SDL axes NSArray *axes = [[[elements allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *bindings) { if (ElementAlreadyHandled(device, (NSString *)object, elements)) { @@ -541,10 +541,10 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle for (id key in device->axes) { NSLog(@"\tAxis: %@\n", key); } -#endif /* DEBUG_CONTROLLER_PROFILE */ +#endif // DEBUG_CONTROLLER_PROFILE #ifdef SDL_PLATFORM_TVOS - /* tvOS turns the menu button into a system gesture, so we grab it here instead */ + // tvOS turns the menu button into a system gesture, so we grab it here instead if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) { device->pause_button_index = (int)[device->buttons indexOfObject:GCInputButtonMenu]; } @@ -556,7 +556,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle int nbuttons = 0; BOOL has_direct_menu = FALSE; - /* These buttons are part of the original MFi spec */ + // These buttons are part of the original MFi spec device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH); device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST); device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST); @@ -565,7 +565,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER); nbuttons += 6; - /* These buttons are available on some newer controllers */ + // These buttons are available on some newer controllers if (@available(macOS 10.14.1, iOS 12.1, tvOS 12.1, *)) { if (gamepad.leftThumbstickButton) { device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_STICK); @@ -591,7 +591,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle } } #ifdef SDL_PLATFORM_TVOS - /* The single menu button isn't very reliable, at least as of tvOS 16.1 */ + // The single menu button isn't very reliable, at least as of tvOS 16.1 if ((device->button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) == 0) { has_direct_menu = FALSE; } @@ -600,14 +600,14 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->pause_button_index = (nbuttons - 1); } - device->naxes = 6; /* 2 thumbsticks and 2 triggers */ - device->nhats = 1; /* d-pad */ + device->naxes = 6; // 2 thumbsticks and 2 triggers + device->nhats = 1; // d-pad device->nbuttons = nbuttons; } else if (controller.gamepad) { int nbuttons = 0; - /* These buttons are part of the original MFi spec */ + // These buttons are part of the original MFi spec device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH); device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST); device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST); @@ -618,8 +618,8 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle nbuttons += 7; device->pause_button_index = (nbuttons - 1); - device->naxes = 0; /* no traditional analog inputs */ - device->nhats = 1; /* d-pad */ + device->naxes = 0; // no traditional analog inputs + device->nhats = 1; // d-pad device->nbuttons = nbuttons; } #ifdef SDL_PLATFORM_TVOS @@ -627,20 +627,20 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle int nbuttons = 0; device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH); - device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST); /* Button X on microGamepad */ + device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST); // Button X on microGamepad device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST); nbuttons += 3; device->pause_button_index = (nbuttons - 1); - device->naxes = 2; /* treat the touch surface as two axes */ - device->nhats = 0; /* apparently the touch surface-as-dpad is buggy */ + device->naxes = 2; // treat the touch surface as two axes + device->nhats = 0; // apparently the touch surface-as-dpad is buggy device->nbuttons = nbuttons; controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_FALSE); } #endif else { - /* We don't know how to get input events from this device */ + // We don't know how to get input events from this device return SDL_FALSE; } @@ -670,7 +670,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle controller.playerIndex = -1; return TRUE; } -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI #if defined(SDL_JOYSTICK_MFI) static void IOS_AddJoystickDevice(GCController *controller) @@ -702,7 +702,7 @@ static void IOS_AddJoystickDevice(GCController *controller) #else SDL_free(device); return; -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI } if (deviceList == NULL) { @@ -719,7 +719,7 @@ static void IOS_AddJoystickDevice(GCController *controller) SDL_PrivateJoystickAdded(device->instance_id); } -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device) { @@ -741,7 +741,7 @@ static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem * item = item->next; } - /* Unlink the device item from the device list. */ + // Unlink the device item from the device list. if (prev) { prev->next = device->next; } else if (device == deviceList) { @@ -754,7 +754,7 @@ static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem * #ifdef SDL_JOYSTICK_MFI @autoreleasepool { - /* These were explicitly retained in the struct, so they should be explicitly released before freeing the struct. */ + // These were explicitly retained in the struct, so they should be explicitly released before freeing the struct. if (device->controller) { GCController *controller = CFBridgingRelease((__bridge CFTypeRef)(device->controller)); controller.controllerPausedHandler = nil; @@ -769,7 +769,7 @@ static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem * device->buttons = nil; } } -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI --numjoysticks; @@ -794,7 +794,7 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char } } } -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS static int IOS_JoystickInit(void) { @@ -805,12 +805,12 @@ static int IOS_JoystickInit(void) #ifdef SDL_PLATFORM_MACOS #if SDL_HAS_BUILTIN(__builtin_available) if (@available(macOS 10.16, *)) { - /* Continue with initialization on macOS 11+ */ + // Continue with initialization on macOS 11+ } else { return 0; } #else - /* No @available, must be an older macOS version */ + // No @available, must be an older macOS version return 0; #endif #endif @@ -821,7 +821,7 @@ static int IOS_JoystickInit(void) #endif #ifdef SDL_JOYSTICK_MFI - /* GameController.framework was added in iOS 7. */ + // GameController.framework was added in iOS 7. if (![GCController class]) { return 0; } @@ -835,7 +835,7 @@ static int IOS_JoystickInit(void) #ifdef SDL_PLATFORM_TVOS SDL_AddHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_AppleTVRemoteRotationHintChanged, NULL); -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS center = [NSNotificationCenter defaultCenter]; @@ -864,7 +864,7 @@ static int IOS_JoystickInit(void) } SDL_UnlockJoysticks(); }]; -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI } return 0; @@ -881,7 +881,7 @@ static void IOS_JoystickDetect(void) static SDL_bool IOS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers through this method */ + // We don't override any other drivers through this method return SDL_FALSE; } @@ -981,7 +981,7 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f); } } -#endif /* ENABLE_MFI_SENSORS */ +#endif // ENABLE_MFI_SENSORS #ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -993,7 +993,7 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) } } } -#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */ +#endif // ENABLE_MFI_SYSTEM_GESTURE_STATE if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { GCController *controller = device->controller; @@ -1015,7 +1015,7 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) } #endif } -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI } if (device->is_siri_remote) { ++SDL_AppleTVRemoteOpenedAsJoystick; @@ -1084,7 +1084,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } } } -#endif /* DEBUG_CONTROLLER_STATE */ +#endif // DEBUG_CONTROLLER_STATE #ifdef ENABLE_PHYSICAL_INPUT_PROFILE if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1119,7 +1119,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_bool isstack; GCExtendedGamepad *gamepad = controller.extendedGamepad; - /* Axis order matches the XInput Windows mappings. */ + // Axis order matches the XInput Windows mappings. Sint16 axes[] = { (Sint16)(gamepad.leftThumbstick.xAxis.value * 32767), (Sint16)(gamepad.leftThumbstick.yAxis.value * -32767), @@ -1129,7 +1129,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) (Sint16)((gamepad.rightTrigger.value * 65535) - 32768), }; - /* Button order matches the XInput Windows mappings. */ + // Button order matches the XInput Windows mappings. Uint8 *buttons = SDL_small_alloc(Uint8, joystick->nbuttons, &isstack); int button_count = 0; @@ -1137,7 +1137,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) return; } - /* These buttons are part of the original MFi spec */ + // These buttons are part of the original MFi spec buttons[button_count++] = gamepad.buttonA.isPressed; buttons[button_count++] = gamepad.buttonB.isPressed; buttons[button_count++] = gamepad.buttonX.isPressed; @@ -1145,7 +1145,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) buttons[button_count++] = gamepad.leftShoulder.isPressed; buttons[button_count++] = gamepad.rightShoulder.isPressed; - /* These buttons are available on some newer controllers */ + // These buttons are available on some newer controllers if (@available(macOS 10.14.1, iOS 12.1, tvOS 12.1, *)) { if (device->button_mask & (1 << SDL_GAMEPAD_BUTTON_LEFT_STICK)) { buttons[button_count++] = gamepad.leftThumbstickButton.isPressed; @@ -1161,7 +1161,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } if (device->button_mask & (1 << SDL_GAMEPAD_BUTTON_START)) { if (device->pause_button_index >= 0) { - /* Guaranteed if buttonMenu is not supported on this OS */ + // Guaranteed if buttonMenu is not supported on this OS buttons[button_count++] = (device->pause_button_pressed > 0); } else { if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { @@ -1185,7 +1185,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_bool isstack; GCGamepad *gamepad = controller.gamepad; - /* Button order matches the XInput Windows mappings. */ + // Button order matches the XInput Windows mappings. Uint8 *buttons = SDL_small_alloc(Uint8, joystick->nbuttons, &isstack); int button_count = 0; @@ -1232,14 +1232,14 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]); } } -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS if (joystick->nhats > 0) { SDL_SendJoystickHat(timestamp, joystick, 0, hatstate); } if (device->pause_button_pressed) { - /* The pause callback is instantaneous, so we extend the duration to allow "holding down" by pressing it repeatedly */ + // The pause callback is instantaneous, so we extend the duration to allow "holding down" by pressing it repeatedly const int PAUSE_BUTTON_PRESS_DURATION_MS = 250; if (SDL_GetTicks() >= device->pause_button_pressed + PAUSE_BUTTON_PRESS_DURATION_MS) { device->pause_button_pressed = 0; @@ -1266,7 +1266,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } } } -#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ +#endif // ENABLE_PHYSICAL_INPUT_PROFILE #ifdef ENABLE_MFI_SENSORS if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1290,7 +1290,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } } } -#endif /* ENABLE_MFI_SENSORS */ +#endif // ENABLE_MFI_SENSORS #ifdef ENABLE_MFI_BATTERY if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1316,9 +1316,9 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_SendJoystickPowerInfo(joystick, state, percent); } } -#endif /* ENABLE_MFI_BATTERY */ +#endif // ENABLE_MFI_BATTERY } -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI } #ifdef ENABLE_MFI_RUMBLE @@ -1517,7 +1517,7 @@ static SDL3_RumbleContext *IOS_JoystickInitRumble(GCController *controller) return nil; } -#endif /* ENABLE_MFI_RUMBLE */ +#endif // ENABLE_MFI_RUMBLE static int IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { @@ -1598,7 +1598,7 @@ static int IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Ui } } } -#endif /* ENABLE_MFI_LIGHT */ +#endif // ENABLE_MFI_LIGHT return SDL_Unsupported(); } @@ -1627,7 +1627,7 @@ static int IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enable } } } -#endif /* ENABLE_MFI_SENSORS */ +#endif // ENABLE_MFI_SENSORS return SDL_Unsupported(); } @@ -1664,7 +1664,7 @@ static void IOS_JoystickClose(SDL_Joystick *joystick) CFRelease(device->rumble); device->rumble = NULL; } -#endif /* ENABLE_MFI_RUMBLE */ +#endif // ENABLE_MFI_RUMBLE if (device->controller) { #ifdef SDL_JOYSTICK_MFI @@ -1681,9 +1681,9 @@ static void IOS_JoystickClose(SDL_Joystick *joystick) } } } -#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */ +#endif // ENABLE_MFI_SYSTEM_GESTURE_STATE -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_JOYSTICK_MFI } } if (device->is_siri_remote) { @@ -1710,8 +1710,8 @@ static void IOS_JoystickQuit(void) #ifdef SDL_PLATFORM_TVOS SDL_DelHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_AppleTVRemoteRotationHintChanged, NULL); -#endif /* SDL_PLATFORM_TVOS */ -#endif /* SDL_JOYSTICK_MFI */ +#endif // SDL_PLATFORM_TVOS +#endif // SDL_JOYSTICK_MFI while (deviceList != NULL) { IOS_RemoveJoystickDevice(deviceList); @@ -1766,7 +1766,7 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi if ([(NSString *)key isEqualToString:GCInputButtonA]) { if (device->is_siri_remote > 1) { - /* GCInputButtonA is triggered for any D-Pad press, ignore it in favor of "Button Center" */ + // GCInputButtonA is triggered for any D-Pad press, ignore it in favor of "Button Center" } else if (device->has_nintendo_buttons) { mapping = &out->b; } else { @@ -1856,7 +1856,7 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi return SDL_TRUE; } -#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ +#endif // ENABLE_PHYSICAL_INPUT_PROFILE return SDL_FALSE; } @@ -1875,7 +1875,7 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) return SDL_TRUE; } - /* The framework may not have seen the device yet */ + // The framework may not have seen the device yet SDL_Delay(10); } } @@ -1914,7 +1914,7 @@ static GCControllerDirectionPad *GetDirectionalPadForController(GCController *co return nil; } -#endif /* SDL_JOYSTICK_MFI && ENABLE_PHYSICAL_INPUT_PROFILE */ +#endif // SDL_JOYSTICK_MFI && ENABLE_PHYSICAL_INPUT_PROFILE const char *IOS_GetAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button) { diff --git a/src/joystick/apple/SDL_mfijoystick_c.h b/src/joystick/apple/SDL_mfijoystick_c.h index 72d36a1915..abfde8eb8d 100644 --- a/src/joystick/apple/SDL_mfijoystick_c.h +++ b/src/joystick/apple/SDL_mfijoystick_c.h @@ -70,4 +70,4 @@ typedef struct joystick_hwdata typedef joystick_hwdata SDL_JoystickDeviceItem; -#endif /* SDL_JOYSTICK_IOS_H */ +#endif // SDL_JOYSTICK_IOS_H diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 0ffe8d8b89..801b482764 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -103,14 +103,14 @@ struct report { #if defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 900000) || \ defined(__DragonFly__) - void *buf; /* Buffer */ + void *buf; // Buffer #elif defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 800063) - struct usb_gen_descriptor *buf; /* Buffer */ + struct usb_gen_descriptor *buf; // Buffer #else - struct usb_ctl_report *buf; /* Buffer */ + 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, @@ -155,8 +155,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; @@ -167,12 +167,12 @@ struct joystick_hwdata int axis_map[JOYAXE_count]; /* map present JOYAXE_* to 0,1,.. */ }; -/* A linked list of available joysticks */ +// A linked list of available joysticks 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_GUID guid; dev_t devnum; struct SDL_joylist_item *next; @@ -302,7 +302,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; @@ -372,10 +372,10 @@ CreateHwData(const char *path) } } - /* The poll blocks the event thread. */ + // The poll blocks the event thread. fcntl(fd, F_SETFL, O_NONBLOCK); #ifdef SDL_PLATFORM_NETBSD - /* Flush pending events */ + // Flush pending events if (rep) { while (read(fd, REP_BUF_DATA(rep), rep->size) == rep->size) ; @@ -405,10 +405,10 @@ static int MaybeAddDevice(const char *path) return -1; } - /* Check to make sure it's not already in list. */ + // Check to make sure it's not already in list. for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { - return -1; /* already have this one */ + return -1; // already have this one } } @@ -434,7 +434,7 @@ static int MaybeAddDevice(const char *path) return -1; } } -#endif /* USB_GET_DEVICEINFO */ +#endif // USB_GET_DEVICEINFO } if (!name) { name = SDL_strdup(path); @@ -466,7 +466,7 @@ static int MaybeAddDevice(const char *path) SDL_joylist_tail = item; } - /* Need to increment the joystick count before we post the event */ + // Need to increment the joystick count before we post the event ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); @@ -492,9 +492,9 @@ static int BSD_JoystickInit(void) SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); MaybeAddDevice(s); } -#endif /* SUPPORT_JOY_GAMEPORT */ +#endif // SUPPORT_JOY_GAMEPORT - /* Read the default USB HID usage table. */ + // Read the default USB HID usage table. hid_init(NULL); return numjoysticks; @@ -511,7 +511,7 @@ static void BSD_JoystickDetect(void) static SDL_bool BSD_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -561,7 +561,7 @@ static SDL_GUID BSD_JoystickGetDeviceGUID(int device_index) return GetJoystickByDevIndex(device_index)->guid; } -/* Function to perform the mapping from device index to the instance id for this index */ +// Function to perform the mapping from device index to the instance id for this index static SDL_JoystickID BSD_JoystickGetDeviceInstanceID(int device_index) { return GetJoystickByDevIndex(device_index)->device_instance; @@ -656,7 +656,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) } return; } -#endif /* SUPPORT_JOY_GAMEPORT */ +#endif // SUPPORT_JOY_GAMEPORT rep = &joy->hwdata->inreport; @@ -667,7 +667,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif if (!hdata) { - /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ + // fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path); continue; } @@ -681,7 +681,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) int joyaxe = usage_to_joyaxe(usage); if (joyaxe >= 0) { naxe = joy->hwdata->axis_map[joyaxe]; - /* scaleaxe */ + // 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_SendJoystickAxis(timestamp, joy, naxe, v); @@ -720,7 +720,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) } case HUP_BUTTON: v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem); - nbutton = HID_USAGE(hitem.usage) - 1; /* SDL buttons are zero-based */ + nbutton = HID_USAGE(hitem.usage) - 1; // SDL buttons are zero-based SDL_SendJoystickButton(timestamp, joy, nbutton, v); break; default: @@ -735,7 +735,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void BSD_JoystickClose(SDL_Joystick *joy) { if (joy->hwdata) { @@ -866,4 +866,4 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver = { BSD_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_USBHID */ +#endif // SDL_JOYSTICK_USBHID diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h index 7bfa58cb91..f178c1d5c3 100644 --- a/src/joystick/controller_list.h +++ b/src/joystick/controller_list.h @@ -485,7 +485,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0xe6f, 0x2a8 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x79, 0x18a1 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller - /* Added from Minidumps 10-9-19 */ + // Added from Minidumps 10-9-19 { MAKE_CONTROLLER_ID( 0x0, 0x6686 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x11ff, 0x511 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x12ab, 0x304 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller diff --git a/src/joystick/darwin/SDL_iokitjoystick.c b/src/joystick/darwin/SDL_iokitjoystick.c index 6e539e6a0a..3fe955bc55 100644 --- a/src/joystick/darwin/SDL_iokitjoystick.c +++ b/src/joystick/darwin/SDL_iokitjoystick.c @@ -26,16 +26,16 @@ #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) -/* The base object of the HID Manager API */ +// The base object of the HID Manager API static IOHIDManagerRef hidman = NULL; -/* Linked list of all available devices */ +// Linked list of all available devices static recDevice *gpDeviceList = NULL; void FreeRumbleEffectData(FFEFFECT *effect) @@ -54,7 +54,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) FFEFFECT *effect; FFPERIODIC *periodic; - /* Create the effect */ + // Create the effect effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect)); if (!effect) { return NULL; @@ -62,7 +62,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwSize = sizeof(*effect); effect->dwGain = 10000; effect->dwFlags = FFEFF_OBJECTOFFSETS; - effect->dwDuration = SDL_MAX_RUMBLE_DURATION_MS * 1000; /* In microseconds. */ + effect->dwDuration = SDL_MAX_RUMBLE_DURATION_MS * 1000; // In microseconds. effect->dwTriggerButton = FFEB_NOTRIGGER; effect->cAxes = 2; @@ -145,7 +145,7 @@ static recDevice *FreeDevice(recDevice *removeDevice) } SDL_UnlockJoysticks(); - /* save next device prior to disposing of this device */ + // save next device prior to disposing of this device pDeviceNext = removeDevice->pNext; if (gpDeviceList == removeDevice) { @@ -162,7 +162,7 @@ static recDevice *FreeDevice(recDevice *removeDevice) } removeDevice->pNext = NULL; - /* free element lists */ + // free element lists FreeElementList(removeDevice->firstAxis); FreeElementList(removeDevice->firstButton); FreeElementList(removeDevice->firstHat); @@ -182,7 +182,7 @@ static SDL_bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SIn if (IOHIDDeviceGetValue(pDevice->deviceRef, pElement->elementRef, &valueRef) == kIOReturnSuccess) { value = (SInt32)IOHIDValueGetIntegerValue(valueRef); - /* record min and max for auto calibration */ + // record min and max for auto calibration if (value < pElement->minReport) { pElement->minReport = value; } @@ -204,7 +204,7 @@ static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pEle 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 = (Sint32)(((*pValue - pElement->minReport) * deviceScale / readScale) + min); returnValue = SDL_TRUE; @@ -244,7 +244,7 @@ static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *s static void AddHIDElement(const void *value, void *parameter); -/* Call AddHIDElement() on all elements in an array of IOHIDElementRefs */ +// Call AddHIDElement() on all elements in an array of IOHIDElementRefs static void AddHIDElements(CFArrayRef array, recDevice *pDevice) { const CFRange range = { 0, CFArrayGetCount(array) }; @@ -262,7 +262,7 @@ static SDL_bool ElementAlreadyAdded(const IOHIDElementCookie cookie, const recEl return SDL_FALSE; } -/* See if we care about this HID element, and if so, note it in our recDevice. */ +// See if we care about this HID element, and if so, note it in our recDevice. static void AddHIDElement(const void *value, void *parameter) { recDevice *pDevice = (recDevice *)parameter; @@ -276,13 +276,13 @@ static void AddHIDElement(const void *value, void *parameter) recElement *element = NULL; recElement **headElement = NULL; - /* look at types of interest */ + // 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 */ + switch (usagePage) { // only interested in kHIDPage_GenericDesktop and kHIDPage_Button case kHIDPage_GenericDesktop: switch (usage) { case kHIDUsage_GD_X: @@ -351,7 +351,7 @@ static void AddHIDElement(const void *value, void *parameter) break; case kHIDPage_Button: - case kHIDPage_Consumer: /* e.g. 'pause' button on Steelseries MFi gamepads. */ + 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) { @@ -378,7 +378,7 @@ static void AddHIDElement(const void *value, void *parameter) break; } - if (element && headElement) { /* add to list */ + if (element && headElement) { // add to list recElement *elementPrevious = NULL; recElement *elementCurrent = *headElement; while (elementCurrent && usage >= elementCurrent->usage) { @@ -410,7 +410,7 @@ static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const int slot = -1; if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER) { - /* Gamepad name is "GamePad-N", where N is slot + 1 */ + // Gamepad name is "GamePad-N", where N is slot + 1 if (SDL_sscanf(product_string, "GamePad-%d", &slot) == 1) { slot -= 1; } @@ -429,13 +429,13 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) CFTypeRef refCF = NULL; CFArrayRef array = NULL; - /* get usage page and usage */ + // get usage page and usage refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usagePage); } if (pDevice->usagePage != kHIDPage_GenericDesktop) { - return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ + return SDL_FALSE; // Filter device list to non-keyboard/mouse stuff } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsageKey)); @@ -446,7 +446,7 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) if ((pDevice->usage != kHIDUsage_GD_Joystick && pDevice->usage != kHIDUsage_GD_GamePad && pDevice->usage != kHIDUsage_GD_MultiAxisController)) { - return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ + return SDL_FALSE; // Filter device list to non-keyboard/mouse stuff } /* Make sure we retain the use of the IOKit-provided device-object, @@ -475,7 +475,7 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) CFNumberGetValue(refCF, kCFNumberSInt32Type, &version); } - /* get device name */ + // get device name refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey)); if ((!refCF) || (!CFStringGetCString(refCF, manufacturer_string, sizeof(manufacturer_string), kCFStringEncodingUTF8))) { manufacturer_string[0] = '\0'; @@ -535,7 +535,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } if (JoystickAlreadyKnown(ioHIDDeviceObject)) { - return; /* IOKit sent us a duplicate. */ + return; // IOKit sent us a duplicate. } device = (recDevice *)SDL_calloc(1, sizeof(recDevice)); @@ -545,7 +545,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender 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)) { @@ -553,15 +553,15 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender return; } - /* Get notified when this device is disconnected. */ + // Get notified when this device is disconnected. IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device); IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); device->runLoopAttached = SDL_TRUE; - /* Allocate an instance ID for this device */ + // Allocate an instance ID for this device device->instance_id = SDL_GetNextObjectID(); - /* We have to do some storage of the io_service_t for SDL_OpenHapticFromJoystick */ + // We have to do some storage of the io_service_t for SDL_OpenHapticFromJoystick ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { device->ffservice = ioservice; @@ -570,7 +570,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender #endif } - /* Add device to the end of the list */ + // Add device to the end of the list if (!gpDeviceList) { gpDeviceList = device; } else { @@ -599,12 +599,12 @@ static SDL_bool ConfigHIDManager(CFArrayRef matchingArray) IOHIDManagerScheduleWithRunLoop(hidman, runloop, SDL_JOYSTICK_RUNLOOP_MODE); while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { - /* no-op. Callback fires once per existing device. */ + // no-op. Callback fires once per existing device. } - /* future hotplug events will come through SDL_JOYSTICK_RUNLOOP_MODE now. */ + // 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) @@ -706,14 +706,14 @@ static void 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) { - /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ + // no-op. Pending callbacks will fire in CFRunLoopRunInMode(). } } } static SDL_bool DARWIN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -788,7 +788,7 @@ static const char *FFStrError(unsigned int err) switch (err) { case FFERR_DEVICEFULL: return "device full"; - /* This should be valid, but for some reason isn't defined... */ + // This should be valid, but for some reason isn't defined... /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: @@ -846,7 +846,7 @@ static int DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude) } } - /* Reset and then enable actuators */ + // Reset and then enable actuators result = FFDeviceSendForceFeedbackCommand(device->ffdevice, FFSFFC_RESET); if (result != FF_OK) { return SDL_SetError("Unable to reset force feedback device: %s", FFStrError(result)); @@ -857,7 +857,7 @@ static int DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude) return SDL_SetError("Unable to enable force feedback actuators: %s", FFStrError(result)); } - /* Create the effect */ + // Create the effect device->ffeffect = CreateRumbleEffectData(magnitude); if (!device->ffeffect) { return -1; @@ -876,7 +876,7 @@ static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ru HRESULT result; recDevice *device = joystick->hwdata; - /* Scale and average the two rumble strengths */ + // Scale and average the two rumble strengths Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); if (!device) { @@ -942,7 +942,7 @@ static void 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; } @@ -967,7 +967,7 @@ static void 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_SendJoystickButton(timestamp, joystick, i, value); @@ -987,9 +987,9 @@ static void 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) { @@ -1045,7 +1045,7 @@ static void DARWIN_JoystickClose(SDL_Joystick *joystick) static void DARWIN_JoystickQuit(void) { while (FreeDevice(gpDeviceList)) { - /* spin */ + // spin } if (hidman) { @@ -1085,4 +1085,4 @@ SDL_JoystickDriver SDL_DARWIN_JoystickDriver = { DARWIN_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_IOKIT */ +#endif // SDL_JOYSTICK_IOKIT diff --git a/src/joystick/darwin/SDL_iokitjoystick_c.h b/src/joystick/darwin/SDL_iokitjoystick_c.h index 899efa8707..08bbedbc01 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 */ + // runtime variables used for auto-calibration + 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,14 +67,14 @@ 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_GUID guid; int steam_virtual_gamepad_slot; - struct joystick_hwdata *pNext; /* next device */ + struct joystick_hwdata *pNext; // next device }; typedef struct joystick_hwdata recDevice; -#endif /* SDL_JOYSTICK_IOKIT_H */ +#endif // SDL_JOYSTICK_IOKIT_H diff --git a/src/joystick/dummy/SDL_sysjoystick.c b/src/joystick/dummy/SDL_sysjoystick.c index dcb320ae0a..b9ea111744 100644 --- a/src/joystick/dummy/SDL_sysjoystick.c +++ b/src/joystick/dummy/SDL_sysjoystick.c @@ -22,7 +22,7 @@ #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) -/* This is the dummy implementation of the SDL joystick API */ +// This is the dummy implementation of the SDL joystick API #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" @@ -153,4 +153,4 @@ SDL_JoystickDriver SDL_DUMMY_JoystickDriver = { DUMMY_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */ +#endif // SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index 1ecd3983b4..a285f282b0 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -23,7 +23,7 @@ #ifdef SDL_JOYSTICK_EMSCRIPTEN -#include /* For the definition of NULL */ +#include // For the definition of NULL #include "SDL_sysjoystick_c.h" #include "../SDL_joystick_c.h" @@ -132,7 +132,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa SDL_joylist_tail = prev; } - /* Need to decrement the joystick count before we post the event */ + // Need to decrement the joystick count before we post the event --numjoysticks; SDL_PrivateJoystickRemoved(item->device_instance); @@ -146,7 +146,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa return 1; } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void EMSCRIPTEN_JoystickQuit(void) { SDL_joylist_item *item = NULL; @@ -179,14 +179,14 @@ static int EMSCRIPTEN_JoystickInit(void) retval = emscripten_sample_gamepad_data(); - /* Check if gamepad is supported by browser */ + // Check if gamepad is supported by browser if (retval == EMSCRIPTEN_RESULT_NOT_SUPPORTED) { return SDL_SetError("Gamepads not supported"); } numjs = emscripten_get_num_gamepads(); - /* handle already connected gamepads */ + // handle already connected gamepads if (numjs > 0) { for (i = 0; i < numjs; i++) { retval = emscripten_get_gamepad_status(i, &gamepadState); @@ -218,7 +218,7 @@ static int EMSCRIPTEN_JoystickInit(void) return 0; } -/* Returns item matching given SDL device index. */ +// Returns item matching given SDL device index. static SDL_joylist_item *JoystickByDeviceIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; @@ -231,7 +231,7 @@ static SDL_joylist_item *JoystickByDeviceIndex(int device_index) return item; } -/* Returns item matching given HTML gamepad index. */ +// Returns item matching given HTML gamepad index. static SDL_joylist_item *JoystickByIndex(int index) { SDL_joylist_item *item = SDL_joylist; @@ -261,7 +261,7 @@ static void EMSCRIPTEN_JoystickDetect(void) static SDL_bool EMSCRIPTEN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -314,7 +314,7 @@ static int EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->hwdata = (struct joystick_hwdata *)item; item->joystick = joystick; - /* HTML5 Gamepad API doesn't say anything about these */ + // HTML5 Gamepad API doesn't say anything about these joystick->nhats = 0; joystick->nbuttons = item->nbuttons; @@ -347,19 +347,19 @@ static void EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) SDL_SendJoystickButton(timestamp, item->joystick, i, buttonState); } - /* store values to compare them in the next update */ + // store values to compare them in the next update item->analogButton[i] = gamepadState.analogButton[i]; item->digitalButton[i] = gamepadState.digitalButton[i]; } for (i = 0; i < item->naxes; i++) { if (item->axis[i] != gamepadState.axis[i]) { - /* do we need to do conversion? */ + // do we need to do conversion? SDL_SendJoystickAxis(timestamp, item->joystick, i, (Sint16)(32767. * gamepadState.axis[i])); } - /* store to compare in next update */ + // store to compare in next update item->axis[i] = gamepadState.axis[i]; } @@ -369,7 +369,7 @@ static void EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick) { SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; @@ -380,7 +380,7 @@ static void EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick) static SDL_GUID EMSCRIPTEN_JoystickGetDeviceGUID(int device_index) { - /* the GUID is just the name for now */ + // the GUID is just the name for now const char *name = EMSCRIPTEN_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } @@ -439,4 +439,4 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver = { EMSCRIPTEN_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_EMSCRIPTEN */ +#endif // SDL_JOYSTICK_EMSCRIPTEN diff --git a/src/joystick/emscripten/SDL_sysjoystick_c.h b/src/joystick/emscripten/SDL_sysjoystick_c.h index 9ba6b35e23..321bbcc09b 100644 --- a/src/joystick/emscripten/SDL_sysjoystick_c.h +++ b/src/joystick/emscripten/SDL_sysjoystick_c.h @@ -26,7 +26,7 @@ #include -/* A linked list of available joysticks */ +// A linked list of available joysticks typedef struct SDL_joylist_item { int index; @@ -46,4 +46,4 @@ typedef struct SDL_joylist_item typedef SDL_joylist_item joystick_hwdata; -#endif /* SDL_JOYSTICK_EMSCRIPTEN */ +#endif // SDL_JOYSTICK_EMSCRIPTEN diff --git a/src/joystick/gdk/SDL_gameinputjoystick.c b/src/joystick/gdk/SDL_gameinputjoystick.c index 63b233a11d..14372530b1 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.c +++ b/src/joystick/gdk/SDL_gameinputjoystick.c @@ -39,8 +39,8 @@ typedef struct GAMEINPUT_InternalDevice IGameInputDevice *device; char path[(APP_LOCAL_DEVICE_ID_SIZE * 2) + 1]; char *name; - SDL_GUID guid; /* generated by SDL */ - SDL_JoystickID device_instance; /* generated by SDL */ + SDL_GUID guid; // generated by SDL + SDL_JoystickID device_instance; // generated by SDL const GameInputDeviceInfo *info; SDL_bool isAdded; SDL_bool isDeleteRequested; @@ -108,7 +108,7 @@ static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) for (idx = 0; idx < g_GameInputList.count; ++idx) { elem = g_GameInputList.devices[idx]; if (elem && elem->device == pDevice) { - /* we're already added */ + // we're already added elem->isDeleteRequested = SDL_FALSE; return 0; } @@ -125,18 +125,18 @@ static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) return -1; } - /* Generate a device path */ + // Generate a device path for (idx = 0; idx < APP_LOCAL_DEVICE_ID_SIZE; ++idx) { SDL_snprintf(tmp, SDL_arraysize(tmp), "%02hhX", info->deviceId.value[idx]); SDL_strlcat(elem->path, tmp, SDL_arraysize(tmp)); } if (info->deviceStrings) { - /* In theory we could get the manufacturer and product strings here, but they're NULL for all the controllers I've tested */ + // In theory we could get the manufacturer and product strings here, but they're NULL for all the controllers I've tested } if (info->displayName) { - /* This could give us a product string, but it's NULL for all the controllers I've tested */ + // This could give us a product string, but it's NULL for all the controllers I've tested } IGameInputDevice_AddRef(pDevice); @@ -173,7 +173,7 @@ static int GAMEINPUT_InternalRemoveByIndex(int idx) g_GameInputList.devices[idx] = NULL; if (g_GameInputList.count == 1) { - /* last element in the list, free the entire list then */ + // last element in the list, free the entire list then SDL_free(g_GameInputList.devices); g_GameInputList.devices = NULL; } else { @@ -183,13 +183,13 @@ static int GAMEINPUT_InternalRemoveByIndex(int idx) } } - /* decrement the count and return */ + // decrement the count and return return g_GameInputList.count--; } static GAMEINPUT_InternalDevice *GAMEINPUT_InternalFindByIndex(int idx) { - /* We're guaranteed that the index is in range when this is called */ + // We're guaranteed that the index is in range when this is called SDL_AssertJoysticksLocked(); return g_GameInputList.devices[idx]; } @@ -206,7 +206,7 @@ static void CALLBACK GAMEINPUT_InternalJoystickDeviceCallback( GAMEINPUT_InternalDevice *elem = NULL; if (!device) { - /* This should never happen, but ignore it if it does */ + // This should never happen, but ignore it if it does return; } @@ -218,7 +218,7 @@ static void CALLBACK GAMEINPUT_InternalJoystickDeviceCallback( for (idx = 0; idx < g_GameInputList.count; ++idx) { elem = g_GameInputList.devices[idx]; if (elem && elem->device == device) { - /* will be deleted on the next Detect call */ + // will be deleted on the next Detect call elem->isDeleteRequested = SDL_TRUE; break; } @@ -319,7 +319,7 @@ static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produ if (g_pGameInput) { if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) { - /* The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle */ + // The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle return SDL_TRUE; } @@ -340,13 +340,13 @@ static const char *GAMEINPUT_JoystickGetDeviceName(int device_index) static const char *GAMEINPUT_JoystickGetDevicePath(int device_index) { - /* APP_LOCAL_DEVICE_ID as a hex string, since it's required for some association callbacks */ + // APP_LOCAL_DEVICE_ID as a hex string, since it's required for some association callbacks return GAMEINPUT_InternalFindByIndex(device_index)->path; } static int GAMEINPUT_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) { - /* Steamworks API is not available in GDK */ + // Steamworks API is not available in GDK return -1; } @@ -484,7 +484,7 @@ static int GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (info->supportedInput & GameInputKindMotion) { - /* FIXME: What's the sensor update rate? */ + // FIXME: What's the sensor update rate? SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 250.0f); SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 250.0f); } @@ -499,7 +499,7 @@ static int GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) static int GAMEINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { - /* don't check for caps here, since SetRumbleState doesn't return any result - we don't need to check it */ + // don't check for caps here, since SetRumbleState doesn't return any result - we don't need to check it GAMEINPUT_InternalJoystickHwdata *hwdata = joystick->hwdata; GameInputRumbleParams *params = &hwdata->rumbleParams; params->lowFrequency = (float)low_frequency_rumble / (float)SDL_MAX_UINT16; @@ -510,7 +510,7 @@ static int GAMEINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency static int GAMEINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { - /* don't check for caps here, since SetRumbleState doesn't return any result - we don't need to check it */ + // don't check for caps here, since SetRumbleState doesn't return any result - we don't need to check it GAMEINPUT_InternalJoystickHwdata *hwdata = joystick->hwdata; GameInputRumbleParams *params = &hwdata->rumbleParams; params->leftTrigger = (float)left_rumble / (float)SDL_MAX_UINT16; @@ -547,7 +547,7 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick) hR = IGameInput_GetCurrentReading(g_pGameInput, info->supportedInput, device, &reading); if (FAILED(hR)) { - /* don't SetError here since there can be a legitimate case when there's no reading avail */ + // don't SetError here since there can be a legitimate case when there's no reading avail return; } @@ -555,17 +555,17 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick) if (GAMEINPUT_InternalIsGamepad(info)) { static WORD s_XInputButtons[] = { - GameInputGamepadA, /* SDL_GAMEPAD_BUTTON_SOUTH */ - GameInputGamepadB, /* SDL_GAMEPAD_BUTTON_EAST */ - GameInputGamepadX, /* SDL_GAMEPAD_BUTTON_WEST */ - GameInputGamepadY, /* SDL_GAMEPAD_BUTTON_NORTH */ - GameInputGamepadView, /* SDL_GAMEPAD_BUTTON_BACK */ - 0, /* The guide button is not available */ - GameInputGamepadMenu, /* SDL_GAMEPAD_BUTTON_START */ - GameInputGamepadLeftThumbstick, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ - GameInputGamepadRightThumbstick, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ - GameInputGamepadLeftShoulder, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - GameInputGamepadRightShoulder, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ + GameInputGamepadA, // SDL_GAMEPAD_BUTTON_SOUTH + GameInputGamepadB, // SDL_GAMEPAD_BUTTON_EAST + GameInputGamepadX, // SDL_GAMEPAD_BUTTON_WEST + GameInputGamepadY, // SDL_GAMEPAD_BUTTON_NORTH + GameInputGamepadView, // SDL_GAMEPAD_BUTTON_BACK + 0, // The guide button is not available + GameInputGamepadMenu, // SDL_GAMEPAD_BUTTON_START + GameInputGamepadLeftThumbstick, // SDL_GAMEPAD_BUTTON_LEFT_STICK + GameInputGamepadRightThumbstick, // SDL_GAMEPAD_BUTTON_RIGHT_STICK + GameInputGamepadLeftShoulder, // SDL_GAMEPAD_BUTTON_LEFT_SHOULDER + GameInputGamepadRightShoulder, // SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER }; Uint8 btnidx = 0, btnstate = 0, hat = 0; @@ -636,7 +636,7 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick) uint32_t touch_count = IGameInputReading_GetTouchState(reading, info->touchPointCount, touch_state); for (i = 0; i < touch_count; ++i) { GameInputTouchState *touch = &touch_state[i]; - /* FIXME: We should use touch->touchId to track fingers instead of using i below */ + // FIXME: We should use touch->touchId to track fingers instead of using i below SDL_SendJoystickTouchpad(timestamp, joystick, 0, i, SDL_PRESSED, touch->positionX * info->touchSensorInfo[i].resolutionX, touch->positionY * info->touchSensorInfo[0].resolutionY, touch->pressure); } SDL_stack_free(touch_state); @@ -647,13 +647,13 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick) GameInputMotionState motion_state; if (IGameInputReading_GetMotionState(reading, &motion_state)) { - /* FIXME: How do we interpret the motion data? */ + // FIXME: How do we interpret the motion data? } } IGameInputReading_Release(reading); - /* FIXME: We can poll this at a much lower rate */ + // FIXME: We can poll this at a much lower rate GAMEINPUT_UpdatePowerInfo(joystick, device); } @@ -672,11 +672,11 @@ static void GAMEINPUT_JoystickClose(SDL_Joystick* joystick) static void GAMEINPUT_JoystickQuit(void) { if (g_pGameInput) { - /* free the callback */ + // free the callback IGameInput_UnregisterCallback(g_pGameInput, g_GameInputCallbackToken, /*timeoutInUs:*/ 10000); g_GameInputCallbackToken = GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE; - /* free the list */ + // free the list while (g_GameInputList.count > 0) { GAMEINPUT_InternalRemoveByIndex(0); } @@ -801,4 +801,4 @@ SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver = }; -#endif /* SDL_JOYSTICK_GAMEINPUT */ +#endif // SDL_JOYSTICK_GAMEINPUT diff --git a/src/joystick/haiku/SDL_haikujoystick.cc b/src/joystick/haiku/SDL_haikujoystick.cc index 8cf62f9b5e..e2a050ad25 100644 --- a/src/joystick/haiku/SDL_haikujoystick.cc +++ b/src/joystick/haiku/SDL_haikujoystick.cc @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_HAIKU -/* This is the Haiku implementation of the SDL joystick API */ +// This is the Haiku implementation of the SDL joystick API #include #include @@ -34,14 +34,14 @@ extern "C" #include "../SDL_joystick_c.h" -/* The maximum number of joysticks we'll detect */ +// The maximum number of joysticks we'll detect #define MAX_JOYSTICKS 16 -/* A list of available joysticks */ +// A list of available joysticks static char *SDL_joyport[MAX_JOYSTICKS]; static char *SDL_joyname[MAX_JOYSTICKS]; -/* The private structure used to keep track of a joystick */ +// The private structure used to keep track of a joystick struct joystick_hwdata { BJoystick *stick; @@ -62,7 +62,7 @@ extern "C" int32 nports; char name[B_OS_NAME_LENGTH]; - /* Search for attached joysticks */ + // Search for attached joysticks nports = joystick.CountDevices(); numjoysticks = 0; SDL_memset(SDL_joyport, 0, sizeof(SDL_joyport)); @@ -95,7 +95,7 @@ extern "C" static SDL_bool HAIKU_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -123,7 +123,7 @@ extern "C" { } -/* Function to perform the mapping from device index to the instance id for this index */ +// Function to perform the mapping from device index to the instance id for this index static SDL_JoystickID HAIKU_JoystickGetDeviceInstanceID(int device_index) { return device_index + 1; @@ -140,7 +140,7 @@ extern "C" { BJoystick *stick; - /* Create the joystick data structure */ + // Create the joystick data structure joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { return -1; @@ -148,16 +148,16 @@ extern "C" stick = new BJoystick; joystick->hwdata->stick = stick; - /* Open the requested joystick for use */ + // Open the requested joystick for use if (stick->Open(SDL_joyport[device_index]) == B_ERROR) { HAIKU_JoystickClose(joystick); return SDL_SetError("Unable to open joystick"); } - /* Set the joystick to calibrated mode */ + // Set the joystick to calibrated mode stick->EnableCalibration(); - /* Get the number of buttons, hats, and axes on the joystick */ + // Get the number of buttons, hats, and axes on the joystick joystick->nbuttons = stick->CountButtons(); joystick->naxes = stick->CountAxes(); joystick->nhats = stick->CountHats(); @@ -169,7 +169,7 @@ extern "C" return -1; } - /* We're done! */ + // We're done! return 0; } @@ -199,35 +199,35 @@ extern "C" uint32 buttons; Uint64 timestamp = SDL_GetTicksNS(); - /* Set up data pointers */ + // Set up data pointers stick = joystick->hwdata->stick; axes = joystick->hwdata->new_axes; hats = joystick->hwdata->new_hats; - /* Get the new joystick state */ + // Get the new joystick state stick->Update(); stick->GetAxisValues(axes); stick->GetHatValues(hats); buttons = stick->ButtonValues(); - /* Generate axis motion events */ + // Generate axis motion events for (i = 0; i < joystick->naxes; ++i) { SDL_SendJoystickAxis(timestamp, joystick, i, axes[i]); } - /* Generate hat change events */ + // Generate hat change events for (i = 0; i < joystick->nhats; ++i) { SDL_SendJoystickHat(timestamp, joystick, i, hat_map[hats[i]]); } - /* Generate button events */ + // Generate button events for (i = 0; i < joystick->nbuttons; ++i) { SDL_SendJoystickButton(timestamp, joystick, i, (buttons & 0x01)); buttons >>= 1; } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void HAIKU_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata) { @@ -239,7 +239,7 @@ extern "C" } } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void HAIKU_JoystickQuit(void) { int i; @@ -257,7 +257,7 @@ extern "C" static SDL_GUID HAIKU_JoystickGetDeviceGUID(int device_index) { - /* the GUID is just the name for now */ + // the GUID is just the name for now const char *name = HAIKU_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } @@ -322,4 +322,4 @@ extern "C" } // extern "C" -#endif /* SDL_JOYSTICK_HAIKU */ +#endif // SDL_JOYSTICK_HAIKU diff --git a/src/joystick/hidapi/SDL_hidapi_combined.c b/src/joystick/hidapi/SDL_hidapi_combined.c index 3d090242e0..e1b7844e72 100644 --- a/src/joystick/hidapi/SDL_hidapi_combined.c +++ b/src/joystick/hidapi/SDL_hidapi_combined.c @@ -18,7 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -/* This driver supports the Nintendo Switch Joy-Cons pair controllers */ +// This driver supports the Nintendo Switch Joy-Cons pair controllers #include "SDL_internal.h" #ifdef SDL_JOYSTICK_HIDAPI @@ -41,7 +41,7 @@ static SDL_bool HIDAPI_DriverCombined_IsEnabled(void) static SDL_bool HIDAPI_DriverCombined_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType 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 */ + // This is always explicitly created for combined devices return SDL_FALSE; } @@ -80,7 +80,7 @@ static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SD return SDL_FALSE; } - /* Extend the serial number with the child serial number */ + // Extend the serial number with the child serial number if (joystick->serial) { new_length = serial_length + 1 + SDL_strlen(joystick->serial); new_serial = (char *)SDL_realloc(serial, new_length); @@ -99,7 +99,7 @@ static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SD } } - /* Update the joystick with the combined serial numbers */ + // Update the joystick with the combined serial numbers if (joystick->serial) { SDL_free(joystick->serial); } @@ -231,4 +231,4 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined = { HIDAPI_DriverCombined_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index a61ea0a0c1..76b8690f36 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -30,8 +30,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_GAMECUBE_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_GAMECUBE_PROTOCOL #define MAX_CONTROLLERS 4 @@ -44,7 +44,7 @@ typedef struct Uint8 max_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_MAX]; Uint8 rumbleAllowed[MAX_CONTROLLERS]; Uint8 rumble[1 + MAX_CONTROLLERS]; - /* Without this variable, hid_write starts to lag a TON */ + // Without this variable, hid_write starts to lag a TON SDL_bool rumbleUpdate; SDL_bool useRumbleBrake; } SDL_DriverGameCube_Context; @@ -69,13 +69,13 @@ static SDL_bool HIDAPI_DriverGameCube_IsEnabled(void) static SDL_bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType 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 */ + // Nintendo Co., Ltd. Wii U GameCube Controller Adapter return SDL_TRUE; } if (vendor_id == USB_VENDOR_DRAGONRISE && (product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 || product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2)) { - /* EVORETRO GameCube Controller Adapter */ + // EVORETRO GameCube Controller Adapter return SDL_TRUE; } return SDL_FALSE; @@ -86,7 +86,7 @@ static void ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) SDL_memset(&ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX], 128 - 88, SDL_GAMEPAD_AXIS_MAX); SDL_memset(&ctx->max_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX], 128 + 88, SDL_GAMEPAD_AXIS_MAX); - /* Trigger axes may have a higher resting value */ + // Trigger axes may have a higher resting value ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX + SDL_GAMEPAD_AXIS_LEFT_TRIGGER] = 40; ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX + SDL_GAMEPAD_AXIS_RIGHT_TRIGGER] = 40; } @@ -136,34 +136,34 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); } } else { - /* This is all that's needed to initialize the device. Really! */ + // This is all that's needed to initialize the device. Really! if (SDL_hid_write(device->dev, &initMagic, sizeof(initMagic)) != sizeof(initMagic)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverGameCube_InitDevice(): Couldn't initialize WUP-028"); return SDL_FALSE; } - /* Wait for the adapter to initialize */ + // Wait for the adapter to initialize SDL_Delay(10); - /* Add all the applicable joysticks */ + // Add all the applicable joysticks 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); #endif if (size < 37 || packet[0] != 0x21) { - continue; /* Nothing to do yet...? */ + continue; // Nothing to do yet...? } - /* Go through all 4 slots */ + // Go through all 4 slots curSlot = packet + 1; for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { ctx->wireless[i] = (curSlot[0] & 0x20) != 0; - /* Only allow rumble if the adapter's second USB cable is connected */ + // Only allow rumble if the adapter's second USB cable is connected ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) && !ctx->wireless[i]; - if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ + if (curSlot[0] & 0x30) { // 0x10 - Wired, 0x20 - Wireless if (ctx->joysticks[i] == 0) { ResetAxisRange(ctx, i); HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); @@ -212,17 +212,17 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device Uint64 timestamp = SDL_GetTicksNS(); if (size != 10) { - return; /* How do we handle this packet? */ + return; // How do we handle this packet? } i = packet[0] - 1; if (i >= MAX_CONTROLLERS) { - return; /* How do we handle this packet? */ + return; // How do we handle this packet? } joystick = SDL_GetJoystickFromID(ctx->joysticks[i]); if (!joystick) { - /* Hasn't been opened yet, skip */ + // Hasn't been opened yet, skip return; } @@ -232,22 +232,22 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device joystick, \ button, \ (packet[off] & flag) ? SDL_PRESSED : SDL_RELEASED); - READ_BUTTON(1, 0x02, 0) /* A */ - READ_BUTTON(1, 0x04, 1) /* B */ - READ_BUTTON(1, 0x08, 3) /* Y */ - READ_BUTTON(1, 0x01, 2) /* X */ - READ_BUTTON(2, 0x80, 4) /* DPAD_LEFT */ - READ_BUTTON(2, 0x20, 5) /* DPAD_RIGHT */ - READ_BUTTON(2, 0x40, 6) /* DPAD_DOWN */ - READ_BUTTON(2, 0x10, 7) /* DPAD_UP */ - READ_BUTTON(2, 0x02, 8) /* START */ - READ_BUTTON(1, 0x80, 9) /* RIGHTSHOULDER */ + READ_BUTTON(1, 0x02, 0) // A + READ_BUTTON(1, 0x04, 1) // B + READ_BUTTON(1, 0x08, 3) // Y + READ_BUTTON(1, 0x01, 2) // X + READ_BUTTON(2, 0x80, 4) // DPAD_LEFT + READ_BUTTON(2, 0x20, 5) // DPAD_RIGHT + READ_BUTTON(2, 0x40, 6) // DPAD_DOWN + READ_BUTTON(2, 0x10, 7) // DPAD_UP + READ_BUTTON(2, 0x02, 8) // START + READ_BUTTON(1, 0x80, 9) // RIGHTSHOULDER /* These two buttons are for the bottoms of the analog triggers. * More than likely, you're going to want to read the axes instead! * -flibit */ - READ_BUTTON(1, 0x20, 10) /* TRIGGERRIGHT */ - READ_BUTTON(1, 0x10, 11) /* TRIGGERLEFT */ + READ_BUTTON(1, 0x20, 10) // TRIGGERRIGHT + READ_BUTTON(1, 0x10, 11) // TRIGGERLEFT #undef READ_BUTTON #define READ_AXIS(off, axis, invert) \ @@ -279,25 +279,25 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device Uint64 timestamp = SDL_GetTicksNS(); if (size < 37 || packet[0] != 0x21) { - return; /* Nothing to do right now...? */ + return; // Nothing to do right now...? } - /* Go through all 4 slots */ + // Go through all 4 slots curSlot = packet + 1; for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { ctx->wireless[i] = (curSlot[0] & 0x20) != 0; - /* Only allow rumble if the adapter's second USB cable is connected */ + // Only allow rumble if the adapter's second USB cable is connected ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) && !ctx->wireless[i]; - if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ + if (curSlot[0] & 0x30) { // 0x10 - Wired, 0x20 - Wireless if (ctx->joysticks[i] == 0) { ResetAxisRange(ctx, i); HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); } joystick = SDL_GetJoystickFromID(ctx->joysticks[i]); - /* Hasn't been opened yet, skip */ + // Hasn't been opened yet, skip if (!joystick) { continue; } @@ -315,22 +315,22 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device joystick, \ button, \ (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED); - READ_BUTTON(1, 0x01, 0) /* A */ - READ_BUTTON(1, 0x02, 1) /* B */ - READ_BUTTON(1, 0x04, 2) /* X */ - READ_BUTTON(1, 0x08, 3) /* Y */ - READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */ - READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */ - READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */ - READ_BUTTON(1, 0x80, 7) /* DPAD_UP */ - READ_BUTTON(2, 0x01, 8) /* START */ - READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */ + READ_BUTTON(1, 0x01, 0) // A + READ_BUTTON(1, 0x02, 1) // B + READ_BUTTON(1, 0x04, 2) // X + READ_BUTTON(1, 0x08, 3) // Y + READ_BUTTON(1, 0x10, 4) // DPAD_LEFT + READ_BUTTON(1, 0x20, 5) // DPAD_RIGHT + READ_BUTTON(1, 0x40, 6) // DPAD_DOWN + READ_BUTTON(1, 0x80, 7) // DPAD_UP + READ_BUTTON(2, 0x01, 8) // START + READ_BUTTON(2, 0x02, 9) // RIGHTSHOULDER /* These two buttons are for the bottoms of the analog triggers. * More than likely, you're going to want to read the axes instead! * -flibit */ - READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */ - READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */ + READ_BUTTON(2, 0x04, 10) // TRIGGERRIGHT + READ_BUTTON(2, 0x08, 11) // TRIGGERLEFT #undef READ_BUTTON #define READ_AXIS(off, axis) \ @@ -359,7 +359,7 @@ static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) Uint8 packet[USB_PACKET_LENGTH]; int size; - /* Read input packet */ + // 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); @@ -371,13 +371,13 @@ static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) } } - /* Write rumble packet */ + // Write rumble packet if (ctx->rumbleUpdate) { SDL_HIDAPI_SendRumble(device, ctx->rumble, sizeof(ctx->rumble)); ctx->rumbleUpdate = SDL_FALSE; } - /* If we got here, nothing bad happened! */ + // If we got here, nothing bad happened! return SDL_TRUE; } @@ -400,7 +400,7 @@ static SDL_bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SD return SDL_TRUE; } } - return SDL_FALSE; /* Should never get here! */ + 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) @@ -424,11 +424,11 @@ static int HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J } if (ctx->useRumbleBrake) { if (low_frequency_rumble == 0 && high_frequency_rumble > 0) { - val = 0; /* if only low is 0 we want to do a regular stop*/ + val = 0; // if only low is 0 we want to do a regular stop } else if (low_frequency_rumble == 0 && high_frequency_rumble == 0) { - val = 2; /* if both frequencies are 0 we want to do a hard stop */ + val = 2; // if both frequencies are 0 we want to do a hard stop } else { - val = 1; /* normal rumble */ + val = 1; // normal rumble } } else { val = (low_frequency_rumble > 0 || high_frequency_rumble > 0); @@ -441,7 +441,7 @@ static int HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J } } - /* Should never get here! */ + // Should never get here! return SDL_SetError("Couldn't find joystick"); } @@ -492,7 +492,7 @@ static void HIDAPI_DriverGameCube_CloseJoystick(SDL_HIDAPI_Device *device, SDL_J { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; - /* Stop rumble activity */ + // Stop rumble activity if (ctx->rumbleUpdate) { SDL_HIDAPI_SendRumble(device, ctx->rumble, sizeof(ctx->rumble)); ctx->rumbleUpdate = SDL_FALSE; @@ -529,6 +529,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube = { HIDAPI_DriverGameCube_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_GAMECUBE */ +#endif // SDL_JOYSTICK_HIDAPI_GAMECUBE -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 6a1c82de40..1730ac623f 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -28,10 +28,10 @@ #ifdef SDL_JOYSTICK_HIDAPI_LUNA -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_LUNA_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_LUNA_PROTOCOL -/* Sending rumble on macOS blocks for a long time and eventually fails */ +// Sending rumble on macOS blocks for a long time and eventually fails #ifndef SDL_PLATFORM_MACOS #define ENABLE_LUNA_BLUETOOTH_RUMBLE #endif @@ -99,7 +99,7 @@ static SDL_bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo SDL_zeroa(ctx->last_state); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_LUNA_BUTTONS; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; @@ -111,10 +111,10 @@ static int HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joyst { #ifdef ENABLE_LUNA_BLUETOOTH_RUMBLE if (device->product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER) { - /* Same packet as on Xbox One controllers connected via Bluetooth */ + // Same packet as on Xbox One controllers connected via Bluetooth Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xEB }; - /* Magnitude is 1..100 so scale the 16-bit input here */ + // Magnitude is 1..100 so scale the 16-bit input here rumble_packet[4] = (Uint8)(low_frequency_rumble / 655); rumble_packet[5] = (Uint8)(high_frequency_rumble / 655); @@ -124,9 +124,9 @@ static int HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joyst return 0; } -#endif /* ENABLE_LUNA_BLUETOOTH_RUMBLE */ +#endif // ENABLE_LUNA_BLUETOOTH_RUMBLE - /* There is currently no rumble packet over USB */ + // There is currently no rumble packet over USB return SDL_Unsupported(); } @@ -251,20 +251,20 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, Uint64 timestamp = SDL_GetTicksNS(); if (size >= 2 && data[0] == 0x02) { - /* Home button has dedicated report */ + // Home button has dedicated report SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x1) ? SDL_PRESSED : SDL_RELEASED); return; } if (size >= 2 && data[0] == 0x04) { - /* Battery level report */ + // Battery level report int percent = (int)SDL_roundf((data[1] / 255.0f) * 100.0f); SDL_SendJoystickPowerInfo(joystick, SDL_POWERSTATE_ON_BATTERY, percent); return; } if (size < 17 || data[0] != 0x01) { - /* We don't know how to handle this report */ + // We don't know how to handle this report return; } @@ -380,7 +380,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -416,6 +416,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna = { HIDAPI_DriverLuna_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_LUNA */ +#endif // SDL_JOYSTICK_HIDAPI_LUNA -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_nintendo.h b/src/joystick/hidapi/SDL_hidapi_nintendo.h index e12c61aaa5..cfd308e170 100644 --- a/src/joystick/hidapi/SDL_hidapi_nintendo.h +++ b/src/joystick/hidapi/SDL_hidapi_nintendo.h @@ -19,9 +19,9 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* These are values used in the controller type byte of the controller GUID */ +// 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 */ +// These values come directly out of the hardware, so don't change them typedef enum { k_eSwitchDeviceInfoControllerType_Unknown = 0, @@ -38,7 +38,7 @@ typedef enum k_eSwitchDeviceInfoControllerType_SEGA_Genesis = 13, } ESwitchDeviceInfoControllerType; -/* These values are used internally but can be updated as needed */ +// These values are used internally but can be updated as needed typedef enum { k_eWiiExtensionControllerType_Unknown = 0, diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index d48db313f3..f99024552f 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -29,8 +29,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_PS3 -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_PS3_PROTOCOL*/ +// 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)) @@ -46,32 +46,32 @@ typedef enum k_EPS3SonySixaxisReportIdEffects = 0, } EPS3SonySixaxisReportId; -/* Commands for Sony's sixaxis.sys Windows driver */ -/* All commands must be sent using 49-byte buffer containing output report */ -/* Byte 0 indicates reportId and must always be 0 */ -/* Byte 1 indicates a command, supported values are specified below: */ +// Commands for Sony's sixaxis.sys Windows driver +// All commands must be sent using 49-byte buffer containing output report +// Byte 0 indicates reportId and must always be 0 +// Byte 1 indicates a command, supported values are specified below: typedef enum { - /* This command allows to set user LEDs. */ - /* Bytes 5,6.7.8 contain mode for corresponding LED: 0 - LED is off, 1 - LED in on, 2 - LED is flashing. */ - /* Bytes 9-16 specify 64-bit LED flash period in 100 ns units if some LED is flashing, otherwise not used. */ + // This command allows to set user LEDs. + // Bytes 5,6.7.8 contain mode for corresponding LED: 0 - LED is off, 1 - LED in on, 2 - LED is flashing. + // Bytes 9-16 specify 64-bit LED flash period in 100 ns units if some LED is flashing, otherwise not used. k_EPS3SixaxisCommandSetLEDs = 1, - /* This command allows to set left and right motors. */ - /* Byte 5 is right motor duration (0-255) and byte 6, if not zero, activates right motor. Zero value disables right motor. */ - /* Byte 7 is left motor duration (0-255) and byte 8 is left motor amplitude (0-255). */ + // This command allows to set left and right motors. + // Byte 5 is right motor duration (0-255) and byte 6, if not zero, activates right motor. Zero value disables right motor. + // Byte 7 is left motor duration (0-255) and byte 8 is left motor amplitude (0-255). k_EPS3SixaxisCommandSetMotors = 2, - /* This command allows to block/unblock setting device LEDs by applications. */ - /* Byte 5 is used as parameter - any non-zero value blocks LEDs, zero value will unblock LEDs. */ + // This command allows to block/unblock setting device LEDs by applications. + // Byte 5 is used as parameter - any non-zero value blocks LEDs, zero value will unblock LEDs. k_EPS3SixaxisCommandBlockLEDs = 3, - /* This command refreshes driver settings. No parameters used. */ - /* When sixaxis driver loads it reads 'CurrentDriverSetting' binary value from 'HKLM\System\CurrentControlSet\Services\sixaxis\Parameters' registry key. */ - /* If the key is not present then default values are used. Sending this command forces sixaxis driver to re-read the registry and update driver settings. */ + // This command refreshes driver settings. No parameters used. + // When sixaxis driver loads it reads 'CurrentDriverSetting' binary value from 'HKLM\System\CurrentControlSet\Services\sixaxis\Parameters' registry key. + // If the key is not present then default values are used. Sending this command forces sixaxis driver to re-read the registry and update driver settings. k_EPS3SixaxisCommandRefreshDriverSetting = 9, - /* This command clears current bluetooth pairing. No parameters used. */ + // This command clears current bluetooth pairing. No parameters used. k_EPS3SixaxisCommandClearPairing = 10 } EPS3SixaxisDriverCommands; @@ -106,7 +106,7 @@ static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) SDL_bool default_value; #ifdef SDL_PLATFORM_MACOS - /* This works well on macOS */ + // This works well on macOS default_value = SDL_TRUE; #elif defined(SDL_PLATFORM_WIN32) /* For official Sony driver (sixaxis.sys) use SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER. @@ -123,7 +123,7 @@ static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) */ default_value = SDL_FALSE; #else - /* Untested, default off */ + // Untested, default off default_value = SDL_FALSE; #endif @@ -180,14 +180,14 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) device->context = ctx; - /* Set the controller into report mode over Bluetooth */ + // Set the controller into report mode over Bluetooth if (device->is_bluetooth) { Uint8 data[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 }; SendFeatureReport(device->dev, data, sizeof(data)); } - /* Set the controller into report mode over USB */ + // Set the controller into report mode over USB if (!device->is_bluetooth) { Uint8 data[USB_PACKET_LENGTH]; @@ -210,7 +210,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_DumpPacket("PS3 0xF5 packet: size = %d", data, size); #endif if (!ctx->is_shanwan) { - /* An output report could cause ShanWan controllers to rumble non-stop */ + // An output report could cause ShanWan controllers to rumble non-stop SDL_hid_write(device->dev, data, 1); } } @@ -258,7 +258,7 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL ctx->player_index = player_index; - /* This will set the new LED state based on the new player index */ + // This will set the new LED state based on the new player index HIDAPI_DriverPS3_UpdateEffects(device); } @@ -274,10 +274,10 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->rumble_right = 0; SDL_zeroa(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; joystick->naxes = 6; if (ctx->has_analog_buttons) { @@ -344,7 +344,7 @@ static int HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, static float HIDAPI_DriverPS3_ScaleAccel(Sint16 value) { - /* Accelerometer values are in big endian order */ + // Accelerometer values are in big endian order value = SDL_Swap16BE(value); return ((float)(value - 511) / 113.0f) * SDL_STANDARD_GRAVITY; } @@ -471,31 +471,31 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive axis = ((int)data[9] * 257) - 32768; SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis); - /* Buttons are mapped as axes in the order they appear in the button enumeration */ + // Buttons are mapped as axes in the order they appear in the button enumeration if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { - 24, /* SDL_GAMEPAD_BUTTON_SOUTH */ - 23, /* SDL_GAMEPAD_BUTTON_EAST */ - 25, /* SDL_GAMEPAD_BUTTON_WEST */ - 22, /* SDL_GAMEPAD_BUTTON_NORTH */ - 0, /* SDL_GAMEPAD_BUTTON_BACK */ - 0, /* SDL_GAMEPAD_BUTTON_GUIDE */ - 0, /* SDL_GAMEPAD_BUTTON_START */ - 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ - 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ - 20, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 21, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ - 14, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ - 16, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ - 17, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ - 15, /* SDL_GAMEPAD_BUTTON_DPAD_RIGHT */ + 24, // SDL_GAMEPAD_BUTTON_SOUTH + 23, // SDL_GAMEPAD_BUTTON_EAST + 25, // SDL_GAMEPAD_BUTTON_WEST + 22, // SDL_GAMEPAD_BUTTON_NORTH + 0, // SDL_GAMEPAD_BUTTON_BACK + 0, // SDL_GAMEPAD_BUTTON_GUIDE + 0, // SDL_GAMEPAD_BUTTON_START + 0, // SDL_GAMEPAD_BUTTON_LEFT_STICK + 0, // SDL_GAMEPAD_BUTTON_RIGHT_STICK + 20, // SDL_GAMEPAD_BUTTON_LEFT_SHOULDER + 21, // SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER + 14, // SDL_GAMEPAD_BUTTON_DPAD_UP + 16, // SDL_GAMEPAD_BUTTON_DPAD_DOWN + 17, // SDL_GAMEPAD_BUTTON_DPAD_LEFT + 15, // SDL_GAMEPAD_BUTTON_DPAD_RIGHT }; Uint8 i, axis_index = 6; for (i = 0; i < SDL_arraysize(button_axis_offsets); ++i) { int offset = button_axis_offsets[i]; if (!offset) { - /* This button doesn't report as an axis */ + // This button doesn't report as an axis continue; } @@ -539,10 +539,10 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) } if (size == 7) { - /* Seen on a ShanWan PS2 -> PS3 USB converter */ + // Seen on a ShanWan PS2 -> PS3 USB converter HIDAPI_DriverPS3_HandleMiniStatePacket(joystick, ctx, data, size); - /* Wait for the first report to set the LED state after the controller stops blinking */ + // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateEffects(device); ctx->effects_updated = SDL_TRUE; @@ -553,12 +553,12 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) switch (data[0]) { case k_EPS3ReportIdState: if (data[1] == 0xFF) { - /* Invalid data packet, ignore */ + // Invalid data packet, ignore break; } HIDAPI_DriverPS3_HandleStatePacket(joystick, ctx, data, size); - /* Wait for the first report to set the LED state after the controller stops blinking */ + // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateEffects(device); ctx->effects_updated = SDL_TRUE; @@ -573,7 +573,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -634,13 +634,13 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device * if (device && device->dev) { size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data)); if (size == 8 && data[2] == 0x26) { - /* Supported third party controller */ + // Supported third party controller return SDL_TRUE; } else { return SDL_FALSE; } } else { - /* Might be supported by this driver, enumerate and find out */ + // Might be supported by this driver, enumerate and find out return SDL_TRUE; } } @@ -692,7 +692,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic ctx->joystick = joystick; SDL_zeroa(ctx->last_state); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; joystick->naxes = 6; if (ctx->has_analog_buttons) { @@ -805,31 +805,31 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic axis = ((int)data[5] * 257) - 32768; SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis); - /* Buttons are mapped as axes in the order they appear in the button enumeration */ + // Buttons are mapped as axes in the order they appear in the button enumeration if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { - 12, /* SDL_GAMEPAD_BUTTON_SOUTH */ - 11, /* SDL_GAMEPAD_BUTTON_EAST */ - 13, /* SDL_GAMEPAD_BUTTON_WEST */ - 10, /* SDL_GAMEPAD_BUTTON_NORTH */ - 0, /* SDL_GAMEPAD_BUTTON_BACK */ - 0, /* SDL_GAMEPAD_BUTTON_GUIDE */ - 0, /* SDL_GAMEPAD_BUTTON_START */ - 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ - 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ - 14, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 15, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ - 8, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ - 9, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ - 7, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ - 6, /* SDL_GAMEPAD_BUTTON_DPAD_RIGHT */ + 12, // SDL_GAMEPAD_BUTTON_SOUTH + 11, // SDL_GAMEPAD_BUTTON_EAST + 13, // SDL_GAMEPAD_BUTTON_WEST + 10, // SDL_GAMEPAD_BUTTON_NORTH + 0, // SDL_GAMEPAD_BUTTON_BACK + 0, // SDL_GAMEPAD_BUTTON_GUIDE + 0, // SDL_GAMEPAD_BUTTON_START + 0, // SDL_GAMEPAD_BUTTON_LEFT_STICK + 0, // SDL_GAMEPAD_BUTTON_RIGHT_STICK + 14, // SDL_GAMEPAD_BUTTON_LEFT_SHOULDER + 15, // SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER + 8, // SDL_GAMEPAD_BUTTON_DPAD_UP + 9, // SDL_GAMEPAD_BUTTON_DPAD_DOWN + 7, // SDL_GAMEPAD_BUTTON_DPAD_LEFT + 6, // SDL_GAMEPAD_BUTTON_DPAD_RIGHT }; Uint8 i, axis_index = 6; for (i = 0; i < SDL_arraysize(button_axis_offsets); ++i) { int offset = button_axis_offsets[i]; if (!offset) { - /* This button doesn't report as an axis */ + // This button doesn't report as an axis continue; } @@ -865,7 +865,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic } if (ctx->device->vendor_id == USB_VENDOR_SAITEK && ctx->device->product_id == USB_PRODUCT_SAITEK_CYBORG_V3) { - /* Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead */ + // Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead Uint8 hat = 0; if (data[7]) { @@ -939,31 +939,31 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic axis = ((int)data[6] * 257) - 32768; SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis); - /* Buttons are mapped as axes in the order they appear in the button enumeration */ + // Buttons are mapped as axes in the order they appear in the button enumeration if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { - 13, /* SDL_GAMEPAD_BUTTON_SOUTH */ - 12, /* SDL_GAMEPAD_BUTTON_EAST */ - 14, /* SDL_GAMEPAD_BUTTON_WEST */ - 11, /* SDL_GAMEPAD_BUTTON_NORTH */ - 0, /* SDL_GAMEPAD_BUTTON_BACK */ - 0, /* SDL_GAMEPAD_BUTTON_GUIDE */ - 0, /* SDL_GAMEPAD_BUTTON_START */ - 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ - 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ - 15, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 16, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ - 9, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ - 10, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ - 8, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ - 7, /* SDL_GAMEPAD_BUTTON_DPAD_RIGHT */ + 13, // SDL_GAMEPAD_BUTTON_SOUTH + 12, // SDL_GAMEPAD_BUTTON_EAST + 14, // SDL_GAMEPAD_BUTTON_WEST + 11, // SDL_GAMEPAD_BUTTON_NORTH + 0, // SDL_GAMEPAD_BUTTON_BACK + 0, // SDL_GAMEPAD_BUTTON_GUIDE + 0, // SDL_GAMEPAD_BUTTON_START + 0, // SDL_GAMEPAD_BUTTON_LEFT_STICK + 0, // SDL_GAMEPAD_BUTTON_RIGHT_STICK + 15, // SDL_GAMEPAD_BUTTON_LEFT_SHOULDER + 16, // SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER + 9, // SDL_GAMEPAD_BUTTON_DPAD_UP + 10, // SDL_GAMEPAD_BUTTON_DPAD_DOWN + 8, // SDL_GAMEPAD_BUTTON_DPAD_LEFT + 7, // SDL_GAMEPAD_BUTTON_DPAD_RIGHT }; Uint8 i, axis_index = 6; for (i = 0; i < SDL_arraysize(button_axis_offsets); ++i) { int offset = button_axis_offsets[i]; if (!offset) { - /* This button doesn't report as an axis */ + // This button doesn't report as an axis continue; } @@ -1000,7 +1000,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic if (size >= 19) { HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(joystick, ctx, data, size); } else if (size == 18) { - /* This packet format was seen with the Logitech ChillStream */ + // This packet format was seen with the Logitech ChillStream HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(joystick, ctx, data, size); } else { #ifdef DEBUG_JOYSTICK @@ -1010,7 +1010,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1134,7 +1134,7 @@ static void HIDAPI_DriverPS3SonySixaxis_SetDevicePlayerIndex(SDL_HIDAPI_Device * ctx->player_index = player_index; - /* This will set the new LED state based on the new player index */ + // This will set the new LED state based on the new player index HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(device); } @@ -1150,10 +1150,10 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_OpenJoystick(SDL_HIDAPI_Device *devi ctx->rumble_right = 0; SDL_zeroa(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; joystick->naxes = 6; if (ctx->has_analog_buttons) { @@ -1201,7 +1201,7 @@ static int HIDAPI_DriverPS3SonySixaxis_SendJoystickEffect(SDL_HIDAPI_Device *dev data[0] = k_EPS3SonySixaxisReportIdEffects; report_size = sizeof(data); - /* No offset with Sony sixaxis.sys driver*/ + // No offset with Sony sixaxis.sys driver SDL_memcpy(&data, effect, SDL_min(sizeof(data), (size_t)size)); if (SDL_HIDAPI_SendRumble(device, data, report_size) != report_size) { @@ -1273,31 +1273,31 @@ static void HIDAPI_DriverPS3SonySixaxis_HandleStatePacket(SDL_Joystick *joystick axis = ((int)data[9] * 257) - 32768; SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis); - /* Buttons are mapped as axes in the order they appear in the button enumeration */ + // Buttons are mapped as axes in the order they appear in the button enumeration if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { - 24, /* SDL_GAMEPAD_BUTTON_SOUTH */ - 23, /* SDL_GAMEPAD_BUTTON_EAST */ - 25, /* SDL_GAMEPAD_BUTTON_WEST */ - 22, /* SDL_GAMEPAD_BUTTON_NORTH */ - 0, /* SDL_GAMEPAD_BUTTON_BACK */ - 0, /* SDL_GAMEPAD_BUTTON_GUIDE */ - 0, /* SDL_GAMEPAD_BUTTON_START */ - 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ - 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ - 20, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 21, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ - 14, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ - 16, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ - 17, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ - 15, /* SDL_GAMEPAD_BUTTON_DPAD_RIGHT */ + 24, // SDL_GAMEPAD_BUTTON_SOUTH + 23, // SDL_GAMEPAD_BUTTON_EAST + 25, // SDL_GAMEPAD_BUTTON_WEST + 22, // SDL_GAMEPAD_BUTTON_NORTH + 0, // SDL_GAMEPAD_BUTTON_BACK + 0, // SDL_GAMEPAD_BUTTON_GUIDE + 0, // SDL_GAMEPAD_BUTTON_START + 0, // SDL_GAMEPAD_BUTTON_LEFT_STICK + 0, // SDL_GAMEPAD_BUTTON_RIGHT_STICK + 20, // SDL_GAMEPAD_BUTTON_LEFT_SHOULDER + 21, // SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER + 14, // SDL_GAMEPAD_BUTTON_DPAD_UP + 16, // SDL_GAMEPAD_BUTTON_DPAD_DOWN + 17, // SDL_GAMEPAD_BUTTON_DPAD_LEFT + 15, // SDL_GAMEPAD_BUTTON_DPAD_RIGHT }; Uint8 i, axis_index = 6; for (i = 0; i < SDL_arraysize(button_axis_offsets); ++i) { int offset = button_axis_offsets[i]; if (!offset) { - /* This button doesn't report as an axis */ + // This button doesn't report as an axis continue; } @@ -1336,7 +1336,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi return SDL_FALSE; } - /* With sixaxis.sys driver we need to use hid_get_feature_report instead of hid_read */ + // With sixaxis.sys driver we need to use hid_get_feature_report instead of hid_read size = ReadFeatureReport(device->dev, 0x0, data, sizeof(data)); if (size < 0) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, @@ -1346,9 +1346,9 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi switch (data[0]) { case k_EPS3SonySixaxisReportIdState: - HIDAPI_DriverPS3SonySixaxis_HandleStatePacket(joystick, ctx, &data[1], size - 1); /* report data starts in data[1] */ + HIDAPI_DriverPS3SonySixaxis_HandleStatePacket(joystick, ctx, &data[1], size - 1); // report data starts in data[1] - /* Wait for the first report to set the LED state after the controller stops blinking */ + // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(device); ctx->effects_updated = SDL_TRUE; @@ -1363,7 +1363,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1385,17 +1385,17 @@ static int HIDAPI_DriverPS3_UpdateRumbleSonySixaxis(SDL_HIDAPI_Device *device) SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; Uint8 effects[] = { - 0x0, /* Report Id */ - k_EPS3SixaxisCommandSetMotors, /* 2 = Set Motors */ - 0x00, 0x00, 0x00, /* padding */ - 0xff, /* Small Motor duration - 0xff is forever */ - 0x00, /* Small Motor off/on (0 or 1) */ - 0xff, /* Large Motor duration - 0xff is forever */ - 0x00 /* Large Motor force (0 to 255) */ + 0x0, // Report Id + k_EPS3SixaxisCommandSetMotors, // 2 = Set Motors + 0x00, 0x00, 0x00, // padding + 0xff, // Small Motor duration - 0xff is forever + 0x00, // Small Motor off/on (0 or 1) + 0xff, // Large Motor duration - 0xff is forever + 0x00 // Large Motor force (0 to 255) }; - effects[6] = ctx->rumble_right ? 1 : 0; /* Small motor */ - effects[8] = ctx->rumble_left; /* Large motor */ + effects[6] = ctx->rumble_right ? 1 : 0; // Small motor + effects[8] = ctx->rumble_left; // Large motor return HIDAPI_DriverPS3SonySixaxis_SendJoystickEffect(device, ctx->joystick, effects, sizeof(effects)); } @@ -1405,13 +1405,13 @@ static int HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(SDL_HIDAPI_Device *device) SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; Uint8 effects[] = { - 0x0, /* Report Id */ - k_EPS3SixaxisCommandSetLEDs, /* 1 = Set LEDs */ - 0x00, 0x00, 0x00, /* padding */ - 0x00, 0x00, 0x00, 0x00 /* LED #4, LED #3, LED #2, LED #1 (0 = Off, 1 = On, 2 = Flashing) */ + 0x0, // Report Id + k_EPS3SixaxisCommandSetLEDs, // 1 = Set LEDs + 0x00, 0x00, 0x00, // padding + 0x00, 0x00, 0x00, 0x00 // LED #4, LED #3, LED #2, LED #1 (0 = Off, 1 = On, 2 = Flashing) }; - /* Turn on LED light on DS3 Controller for relevant player (player_index 0 lights up LED #1, player_index 1 lights up LED #2, etc) */ + // Turn on LED light on DS3 Controller for relevant player (player_index 0 lights up LED #1, player_index 1 lights up LED #2, etc) if (ctx->player_index < 4) { effects[8 - ctx->player_index] = 1; } @@ -1441,6 +1441,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3SonySixaxis = { HIDAPI_DriverPS3SonySixaxis_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_PS3 */ +#endif // SDL_JOYSTICK_HIDAPI_PS3 -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index 2722c949ea..01ea841a6b 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -32,12 +32,12 @@ #ifdef SDL_JOYSTICK_HIDAPI_PS4 -/* Define this if you want to log all packets from the controller */ +// Define this if you want to log all packets from the controller #if 0 #define DEBUG_PS4_PROTOCOL #endif -/* Define this if you want to log calibration data */ +// Define this if you want to log calibration data #if 0 #define DEBUG_PS4_CALIBRATION #endif @@ -178,7 +178,7 @@ typedef struct Uint16 accel_denominator; Uint64 sensor_ticks; Uint16 last_tick; - Uint16 valid_crc_packets; /* wrapping counter */ + Uint16 valid_crc_packets; // wrapping counter PS4StatePacket_t last_state; } SDL_DriverPS4_Context; @@ -219,13 +219,13 @@ static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, co if (device && device->dev) { size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data)); if (size == 48 && data[2] == 0x27) { - /* Supported third party controller */ + // Supported third party controller return SDL_TRUE; } else { return SDL_FALSE; } } else { - /* Might be supported by this driver, enumerate and find out */ + // Might be supported by this driver, enumerate and find out return SDL_TRUE; } } @@ -239,13 +239,13 @@ static void SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) The first 4 values correspond to what the PS4 assigns. */ static const Uint8 colors[7][3] = { - { 0x00, 0x00, 0x40 }, /* Blue */ - { 0x40, 0x00, 0x00 }, /* Red */ - { 0x00, 0x40, 0x00 }, /* Green */ - { 0x20, 0x00, 0x20 }, /* Pink */ - { 0x02, 0x01, 0x00 }, /* Orange */ - { 0x00, 0x01, 0x01 }, /* Teal */ - { 0x01, 0x01, 0x01 } /* White */ + { 0x00, 0x00, 0x40 }, // Blue + { 0x40, 0x00, 0x00 }, // Red + { 0x00, 0x40, 0x00 }, // Green + { 0x20, 0x00, 0x20 }, // Pink + { 0x02, 0x01, 0x00 }, // Orange + { 0x00, 0x01, 0x01 }, // Teal + { 0x01, 0x01, 0x01 } // White }; if (player_index >= 0) { @@ -309,7 +309,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) serial[0] = '\0'; } - /* Check for type of connection */ + // Check for type of connection ctx->is_dongle = (device->vendor_id == USB_VENDOR_SONY && device->product_id == USB_PRODUCT_SONY_DS4_DONGLE); if (ctx->is_dongle) { ReadWiredSerial(device, serial, sizeof(serial)); @@ -319,7 +319,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) } else if (device->vendor_id == USB_VENDOR_SONY) { if (device->is_bluetooth) { - /* Read a report to see if we're in enhanced mode */ + // Read a report to see if we're in enhanced mode size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16); #ifdef DEBUG_PS4_PROTOCOL if (size > 0) { @@ -338,7 +338,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) ctx->enhanced_reports = SDL_TRUE; } } else { - /* Third party controllers appear to all be wired */ + // Third party controllers appear to all be wired ctx->enhanced_reports = SDL_TRUE; } @@ -349,9 +349,9 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) ctx->vibration_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; } else { - /* Third party controller capability request */ + // Third party controller capability request size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data)); - /* Get the device capabilities */ + // Get the device capabilities if (size == 48 && data[2] == 0x27) { Uint8 capabilities = data[4]; Uint8 device_type = data[5]; @@ -412,7 +412,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) ctx->accel_denominator = accel_denominator; } } else if (device->vendor_id == USB_VENDOR_RAZER) { - /* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */ + // The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration ctx->vibration_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; } @@ -441,7 +441,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) } HIDAPI_SetDeviceSerial(device, serial); - /* Prefer the USB device over the Bluetooth device */ + // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { return SDL_TRUE; @@ -450,7 +450,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_DisconnectBluetoothDevice(device->serial); } if ((ctx->is_dongle || ctx->is_nacon_dongle) && serial[0] == '\0') { - /* Not yet connected */ + // Not yet connected return SDL_TRUE; } return HIDAPI_JoystickConnected(device, NULL); @@ -476,7 +476,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * } for (tries = 0; tries < 5; ++tries) { - /* For Bluetooth controllers, this report switches them into advanced report mode */ + // For Bluetooth controllers, this report switches them into advanced report mode size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdGyroCalibration_USB, data, sizeof(data)); if (size < 35) { #ifdef DEBUG_PS4_CALIBRATION @@ -495,7 +495,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * } } - /* In some cases this report returns all zeros. Usually immediately after connection with the PS4 Dongle */ + // In some cases this report returns all zeros. Usually immediately after connection with the PS4 Dongle for (i = 0; i < size; ++i) { if (data[i]) { have_data = SDL_TRUE; @@ -594,7 +594,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * #ifdef DEBUG_PS4_CALIBRATION SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].scale); #endif - /* Some controllers have a bad calibration */ + // Some controllers have a bad calibration if (SDL_abs(ctx->calibration[i].bias) > 1024 || SDL_fabsf(1.0f - ctx->calibration[i].scale) > 0.5f) { #ifdef DEBUG_PS4_CALIBRATION SDL_Log("invalid calibration, ignoring\n"); @@ -622,7 +622,7 @@ static void HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) } } - /* Scale the raw data to the units expected by SDL */ + // Scale the raw data to the units expected by SDL for (i = 0; i < SDL_arraysize(ctx->calibration); ++i) { double scale = ctx->calibration[i].scale; @@ -631,7 +631,7 @@ static void HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device) if (device->vendor_id == USB_VENDOR_SONY && device->product_id == USB_PRODUCT_SONY_DS4_STRIKEPAD) { - /* The Armor-X Pro seems to only deliver half the rotation it should */ + // The Armor-X Pro seems to only deliver half the rotation it should scale *= 2.0; } } else { @@ -667,7 +667,7 @@ static int HIDAPI_DriverPS4_UpdateEffects(SDL_DriverPS4_Context *ctx, SDL_bool a } if (ctx->lightbar_supported) { - /* Populate the LED state with the appropriate color from our lookup table */ + // Populate the LED state with the appropriate color from our lookup table if (ctx->color_set) { effects.ucLedRed = ctx->led_red; effects.ucLedGreen = ctx->led_green; @@ -684,13 +684,13 @@ static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; if (ctx->enhanced_reports) { - /* This is just a dummy packet that should have no effect, since we don't set the CRC */ + // This is just a dummy packet that should have no effect, since we don't set the CRC Uint8 data[78]; 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)); @@ -699,7 +699,7 @@ static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) #if 0 /* The 8BitDo Zero 2 has perfect emulation of a PS4 controllers, except it * only sends reports when the state changes, so we can't disconnect here. */ - /* We can't even send an invalid effects packet, or it will put the controller in enhanced mode */ + // We can't even send an invalid effects packet, or it will put the controller in enhanced mode if (device->num_joysticks > 0) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } @@ -737,7 +737,7 @@ static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_DriverPS4_Context *ctx) if (!ctx->enhanced_mode) { ctx->enhanced_mode = SDL_TRUE; - /* Switch into enhanced report mode */ + // Switch into enhanced report mode HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE); } } @@ -751,7 +751,7 @@ static void HIDAPI_DriverPS4_SetRumbleHintMode(SDL_DriverPS4_Context *ctx, SDL_P } break; case PS4_RUMBLE_HINT_OFF: - /* Nothing to do, enhanced mode is a one-way ticket */ + // Nothing to do, enhanced mode is a one-way ticket break; case PS4_RUMBLE_HINT_ON: HIDAPI_DriverPS4_SetEnhancedMode(ctx); @@ -835,8 +835,8 @@ static void HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL ctx->player_index = player_index; - /* This will set the new LED state based on the new player index */ - /* SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode */ + // This will set the new LED state based on the new player index + // SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE); } @@ -855,10 +855,10 @@ static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->color_set = SDL_FALSE; SDL_zero(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; if (ctx->touchpad_supported) { joystick->nbuttons += 1; @@ -931,7 +931,7 @@ static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ct int report_size, offset; if (!ctx->effects_supported) { - /* We shouldn't be sending packets to this controller */ + // We shouldn't be sending packets to this controller return SDL_Unsupported(); } @@ -941,7 +941,7 @@ static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ct } if (!ctx->enhanced_mode) { - /* We're not in enhanced mode, effects aren't allowed */ + // We're not in enhanced mode, effects aren't allowed return SDL_Unsupported(); } } @@ -950,14 +950,14 @@ static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ct if (ctx->device->is_bluetooth && ctx->official_controller) { data[0] = k_EPS4ReportIdBluetoothEffects; - data[1] = 0xC0 | ctx->report_interval; /* Magic value HID + CRC, also sets update interval */ - data[3] = 0x03; /* 0x1 is rumble, 0x2 is lightbar, 0x4 is the blink interval */ + data[1] = 0xC0 | ctx->report_interval; // Magic value HID + CRC, also sets update interval + 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; @@ -966,8 +966,8 @@ static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ct SDL_memcpy(&data[offset], effect, SDL_min((sizeof(data) - offset), (size_t)size)); if (ctx->device->is_bluetooth) { - /* Bluetooth reports need a CRC at the end of the packet (at least on Linux) */ - Uint8 ubHdr = 0xA2; /* hidp header is part of the CRC calculation */ + // Bluetooth reports need a CRC at the end of the packet (at least on Linux) + Uint8 ubHdr = 0xA2; // hidp header is part of the CRC calculation Uint32 unCRC; unCRC = SDL_crc32(0, &ubHdr, 1); unCRC = SDL_crc32(unCRC, data, (size_t)(report_size - sizeof(unCRC))); @@ -1008,7 +1008,7 @@ static int HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverPS4_Context *ctx, PS4StatePacket_t *packet, int size) { 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; @@ -1150,7 +1150,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d ctx->sensor_ticks += delta; ctx->last_tick = tick; - /* Sensor timestamp is in 5.33us units */ + // Sensor timestamp is in 5.33us units sensor_timestamp = (ctx->sensor_ticks * SDL_NS_PER_US * 16) / 3; data[0] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1])); @@ -1169,7 +1169,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d static SDL_bool VerifyCRC(Uint8 *data, int size) { - Uint8 ubHdr = 0xA1; /* hidp header is part of the CRC calculation */ + Uint8 ubHdr = 0xA1; // hidp header is part of the CRC calculation Uint32 unCRC, unPacketCRC; Uint8 *packetCRC = data + size - sizeof(unPacketCRC); unCRC = SDL_crc32(0, &ubHdr, 1); @@ -1187,12 +1187,12 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 switch (data[0]) { case k_EPS4ReportIdUsbState: if (size == 10) { - /* This is non-enhanced mode, this packet is fine */ + // This is non-enhanced mode, this packet is fine return SDL_TRUE; } if (ctx->is_nacon_dongle && size >= (1 + sizeof(PS4StatePacket_t))) { - /* The report timestamp doesn't change when the controller isn't connected */ + // The report timestamp doesn't change when the controller isn't connected PS4StatePacket_t *packet = (PS4StatePacket_t *)&data[1]; if (SDL_memcmp(packet->rgucTimestamp, ctx->last_state.rgucTimestamp, sizeof(packet->rgucTimestamp)) == 0) { return SDL_FALSE; @@ -1200,7 +1200,7 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 if (ctx->last_state.rgucAccelX[0] == 0 && ctx->last_state.rgucAccelX[1] == 0 && ctx->last_state.rgucAccelY[0] == 0 && ctx->last_state.rgucAccelY[1] == 0 && ctx->last_state.rgucAccelZ[0] == 0 && ctx->last_state.rgucAccelZ[1] == 0) { - /* We don't have any state to compare yet, go ahead and copy it */ + // We don't have any state to compare yet, go ahead and copy it SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS4StatePacket_t)); return SDL_FALSE; } @@ -1224,7 +1224,7 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 case k_EPS4ReportIdBluetoothState7: case k_EPS4ReportIdBluetoothState8: case k_EPS4ReportIdBluetoothState9: - /* Bluetooth state packets have two additional bytes at the beginning, the first notes if HID data is present */ + // Bluetooth state packets have two additional bytes at the beginning, the first notes if HID data is present if (size >= 78 && (data[1] & 0x80)) { if (VerifyCRC(data, 78)) { ++ctx->valid_crc_packets; @@ -1233,7 +1233,7 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 --ctx->valid_crc_packets; } if (ctx->valid_crc_packets >= 3) { - /* We're generally getting valid CRC, but failed one */ + // We're generally getting valid CRC, but failed one return SDL_FALSE; } } @@ -1287,10 +1287,10 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) case k_EPS4ReportIdBluetoothState7: case k_EPS4ReportIdBluetoothState8: case k_EPS4ReportIdBluetoothState9: - /* This is the extended report, we can enable effects now in default mode */ + // This is the extended report, we can enable effects now in default mode HIDAPI_DriverPS4_UpdateEnhancedModeOnEnhancedReport(ctx); - /* Bluetooth state packets have two additional bytes at the beginning, the first notes if HID is present */ + // 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], size - 3); break; default: @@ -1303,13 +1303,13 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) if (device->is_bluetooth) { if (packet_count == 0) { - /* Check to see if it looks like the device disconnected */ + // Check to see if it looks like the device disconnected if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { - /* Send an empty output report to tickle the Bluetooth stack */ + // Send an empty output report to tickle the Bluetooth stack HIDAPI_DriverPS4_TickleBluetooth(device); } } else { - /* Reconnect the Bluetooth device once the USB device is gone */ + // Reconnect the Bluetooth device once the USB device is gone if (device->num_joysticks == 0 && !HIDAPI_HasConnectedUSBDevice(device->serial)) { HIDAPI_JoystickConnected(device, NULL); @@ -1320,7 +1320,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) if (ctx->is_dongle || ctx->is_nacon_dongle) { if (packet_count == 0) { if (device->num_joysticks > 0) { - /* Check to see if it looks like the device disconnected */ + // Check to see if it looks like the device disconnected if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } @@ -1340,7 +1340,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) } if (packet_count == 0 && size < 0 && device->num_joysticks > 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1384,6 +1384,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 = { HIDAPI_DriverPS4_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_PS4 */ +#endif // SDL_JOYSTICK_HIDAPI_PS4 -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index ed66e4f98a..6811aea73e 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -29,12 +29,12 @@ #ifdef SDL_JOYSTICK_HIDAPI_PS5 -/* Define this if you want to log all packets from the controller */ +// Define this if you want to log all packets from the controller #if 0 #define DEBUG_PS5_PROTOCOL #endif -/* Define this if you want to log calibration data */ +// Define this if you want to log calibration data #if 0 #define DEBUG_PS5_CALIBRATION #endif @@ -88,107 +88,107 @@ 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 - 16/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 - 16/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 */ + // 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[2]; /* 27 - 16 bit little endian */ - Uint8 ucBatteryLevel; /* 29 */ - Uint8 ucUnknown; /* 30 */ - 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[2]; // 27 - 16 bit little endian + Uint8 ucBatteryLevel; // 29 + Uint8 ucUnknown; // 30 + 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 */ + // 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 @@ -309,13 +309,13 @@ static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, co if (device && device->dev) { size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data)); if (size == 48 && data[2] == 0x28) { - /* Supported third party controller */ + // Supported third party controller return SDL_TRUE; } else { return SDL_FALSE; } } else { - /* Might be supported by this driver, enumerate and find out */ + // Might be supported by this driver, enumerate and find out return SDL_TRUE; } } @@ -328,13 +328,13 @@ static void SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) The first 4 values correspond to what the PS4 assigns. */ static const Uint8 colors[7][3] = { - { 0x00, 0x00, 0x40 }, /* Blue */ - { 0x40, 0x00, 0x00 }, /* Red */ - { 0x00, 0x40, 0x00 }, /* Green */ - { 0x20, 0x00, 0x20 }, /* Pink */ - { 0x20, 0x10, 0x00 }, /* Orange */ - { 0x00, 0x10, 0x10 }, /* Teal */ - { 0x10, 0x10, 0x10 } /* White */ + { 0x00, 0x00, 0x40 }, // Blue + { 0x40, 0x00, 0x00 }, // Red + { 0x00, 0x40, 0x00 }, // Green + { 0x20, 0x00, 0x20 }, // Pink + { 0x20, 0x10, 0x00 }, // Orange + { 0x00, 0x10, 0x10 }, // Teal + { 0x10, 0x10, 0x10 } // White }; if (player_index >= 0) { @@ -359,7 +359,7 @@ static void SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index }; if (player_index >= 0) { - /* Bitmask, 0x1F enables all lights, 0x20 changes instantly instead of fade */ + // Bitmask, 0x1F enables all lights, 0x20 changes instantly instead of fade player_index %= SDL_arraysize(lights); effects->ucPadLights = lights[player_index] | 0x20; } else { @@ -398,7 +398,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) serial[0] = '\0'; } - /* Read a report to see what mode we're in */ + // Read a report to see what mode we're in size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16); #ifdef DEBUG_PS5_PROTOCOL if (size > 0) { @@ -408,13 +408,13 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) } #endif if (size == 64) { - /* Connected over USB */ + // Connected over USB ctx->enhanced_reports = SDL_TRUE; } else if (size > 0 && data[0] == k_EPS5ReportIdBluetoothEffects) { - /* Connected over Bluetooth, using enhanced reports */ + // Connected over Bluetooth, using enhanced reports ctx->enhanced_reports = SDL_TRUE; } else { - /* Connected over Bluetooth, using simple reports (DirectInput enabled) */ + // Connected over Bluetooth, using simple reports (DirectInput enabled) } if (device->vendor_id == USB_VENDOR_SONY && ctx->enhanced_reports) { @@ -434,7 +434,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) } } - /* Get the device capabilities */ + // Get the device capabilities if (device->vendor_id == USB_VENDOR_SONY) { ctx->sensors_supported = SDL_TRUE; ctx->lightbar_supported = SDL_TRUE; @@ -442,7 +442,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) ctx->playerled_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; } else { - /* Third party controller capability request */ + // Third party controller capability request size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data)); if (size == 48 && data[2] == 0x28) { Uint8 capabilities = data[4]; @@ -497,19 +497,19 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) if (device->vendor_id == USB_VENDOR_NACON_ALT && (device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRED || device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS)) { - /* This doesn't report vibration capability, but it can do rumble */ + // This doesn't report vibration capability, but it can do rumble ctx->vibration_supported = SDL_TRUE; } } else if (device->vendor_id == USB_VENDOR_RAZER && (device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRED || device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS)) { - /* The Razer Wolverine V2 Pro doesn't respond to the detection protocol, but has a touchpad and sensors and no vibration */ + // The Razer Wolverine V2 Pro doesn't respond to the detection protocol, but has a touchpad and sensors and no vibration ctx->sensors_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; ctx->use_alternate_report = SDL_TRUE; } else if (device->vendor_id == USB_VENDOR_RAZER && device->product_id == USB_PRODUCT_RAZER_KITSUNE) { - /* The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad */ + // The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK; ctx->touchpad_supported = SDL_TRUE; ctx->use_alternate_report = SDL_TRUE; @@ -534,11 +534,11 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceSerial(device, serial); if (ctx->is_nacon_dongle) { - /* We don't know if this is connected yet, wait for reports */ + // We don't know if this is connected yet, wait for reports return SDL_TRUE; } - /* Prefer the USB device over the Bluetooth device */ + // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { return SDL_TRUE; @@ -635,7 +635,7 @@ static void HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS5_CALIBRATION SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].sensitivity); #endif - /* Some controllers have a bad calibration */ + // Some controllers have a bad calibration if ((SDL_abs(ctx->calibration[i].bias) > 1024) || (SDL_fabsf(1.0f - ctx->calibration[i].sensitivity / divisor) > 0.5f)) { #ifdef DEBUG_PS5_CALIBRATION SDL_Log("invalid calibration, ignoring\n"); @@ -660,7 +660,7 @@ static float HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, i result = value; } - /* Convert the raw data to the units expected by SDL */ + // Convert the raw data to the units expected by SDL if (index < 3) { result = (result / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; } else { @@ -673,7 +673,7 @@ static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect { DS5EffectsState_t effects; - /* Make sure the Bluetooth connection sequence has completed before sending LED color change */ + // Make sure the Bluetooth connection sequence has completed before sending LED color change if (ctx->device->is_bluetooth && ctx->enhanced_reports && (effect_mask & (k_EDS5EffectLED | k_EDS5EffectPadLights)) != 0) { if (ctx->led_reset_state != k_EDS5LEDResetStateComplete) { @@ -687,37 +687,37 @@ static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect if (ctx->vibration_supported) { if (ctx->rumble_left || ctx->rumble_right) { if (ctx->firmware_version < 0x0224) { - effects.ucEnableBits1 |= 0x01; /* Enable rumble emulation */ + effects.ucEnableBits1 |= 0x01; // Enable rumble emulation - /* Shift to reduce effective rumble strength to match Xbox controllers */ + // Shift to reduce effective rumble strength to match Xbox controllers effects.ucRumbleLeft = ctx->rumble_left >> 1; effects.ucRumbleRight = ctx->rumble_right >> 1; } else { - effects.ucEnableBits3 |= 0x04; /* Enable improved rumble emulation on 2.24 firmware and newer */ + effects.ucEnableBits3 |= 0x04; // Enable improved rumble emulation on 2.24 firmware and newer effects.ucRumbleLeft = ctx->rumble_left; effects.ucRumbleRight = ctx->rumble_right; } - effects.ucEnableBits1 |= 0x02; /* Disable audio haptics */ + effects.ucEnableBits1 |= 0x02; // Disable audio haptics } else { - /* Leaving emulated rumble bits off will restore audio haptics */ + // Leaving emulated rumble bits off will restore audio haptics } if ((effect_mask & k_EDS5EffectRumbleStart) != 0) { - effects.ucEnableBits1 |= 0x02; /* Disable audio haptics */ + effects.ucEnableBits1 |= 0x02; // Disable audio haptics } if ((effect_mask & k_EDS5EffectRumble) != 0) { - /* Already handled above */ + // Already handled above } } if (ctx->lightbar_supported) { if ((effect_mask & k_EDS5EffectLEDReset) != 0) { - effects.ucEnableBits2 |= 0x08; /* Reset LED state */ + effects.ucEnableBits2 |= 0x08; // Reset LED state } if ((effect_mask & k_EDS5EffectLED) != 0) { - effects.ucEnableBits2 |= 0x04; /* Enable LED color */ + effects.ucEnableBits2 |= 0x04; // Enable LED color - /* Populate the LED state with the appropriate color from our lookup table */ + // Populate the LED state with the appropriate color from our lookup table if (ctx->color_set) { effects.ucLedRed = ctx->led_red; effects.ucLedGreen = ctx->led_green; @@ -729,7 +729,7 @@ static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect } if (ctx->playerled_supported) { if ((effect_mask & k_EDS5EffectPadLights) != 0) { - effects.ucEnableBits2 |= 0x10; /* Enable touchpad lights */ + effects.ucEnableBits2 |= 0x10; // Enable touchpad lights if (ctx->player_lights) { SetLightsForPlayerIndex(&effects, ctx->player_index); @@ -739,9 +739,9 @@ static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect } } if ((effect_mask & k_EDS5EffectMicLight) != 0) { - effects.ucEnableBits2 |= 0x01; /* Enable microphone light */ + 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_InternalSendJoystickEffect(ctx, &effects, sizeof(effects), application_usage); @@ -754,7 +754,7 @@ static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_DriverPS5_Context *ctx) if (ctx->enhanced_reports && ctx->sensors_supported && !ctx->use_alternate_report) { const PS5StatePacketCommon_t *packet = &ctx->last_state.state; - /* Check the timer to make sure the Bluetooth connection LED animation is complete */ + // Check the timer to make sure the Bluetooth connection LED animation is complete const Uint32 connection_complete = 10200000; Uint32 timestamp = LOAD32(packet->rgucSensorTimestamp[0], packet->rgucSensorTimestamp[1], @@ -764,7 +764,7 @@ static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_DriverPS5_Context *ctx) led_reset_complete = SDL_TRUE; } } else { - /* We don't know how to check the timer, just assume it's complete for now */ + // We don't know how to check the timer, just assume it's complete for now led_reset_complete = SDL_TRUE; } @@ -782,19 +782,19 @@ static void HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; if (ctx->enhanced_reports) { - /* This is just a dummy packet that should have no effect, since we don't set the CRC */ + // This is just a dummy packet that should have no effect, since we don't set the CRC Uint8 data[78]; 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)); } } else { - /* We can't even send an invalid effects packet, or it will put the controller in enhanced mode */ + // We can't even send an invalid effects packet, or it will put the controller in enhanced mode if (device->num_joysticks > 0) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } @@ -812,7 +812,7 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx if (ctx->sensors_supported) { if (ctx->device->is_bluetooth) { - /* Bluetooth sensor update rate appears to be 1000 Hz */ + // Bluetooth sensor update rate appears to be 1000 Hz SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_GYRO, 1000.0f); SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, 1000.0f); } else { @@ -835,10 +835,10 @@ static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_DriverPS5_Context *ctx) if (!ctx->enhanced_mode && ctx->enhanced_mode_available) { ctx->enhanced_mode = SDL_TRUE; - /* Switch into enhanced report mode */ + // Switch into enhanced report mode HIDAPI_DriverPS5_UpdateEffects(ctx, 0, SDL_FALSE); - /* Update the light effects */ + // Update the light effects HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), SDL_FALSE); } } @@ -852,7 +852,7 @@ static void HIDAPI_DriverPS5_SetRumbleHintMode(SDL_DriverPS5_Context *ctx, SDL_P } break; case PS5_RUMBLE_HINT_OFF: - /* Nothing to do, enhanced mode is a one-way ticket */ + // Nothing to do, enhanced mode is a one-way ticket break; case PS5_RUMBLE_HINT_ON: HIDAPI_DriverPS5_SetEnhancedMode(ctx); @@ -925,8 +925,8 @@ static void HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL ctx->player_index = player_index; - /* This will set the new LED state based on the new player index */ - /* SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode */ + // This will set the new LED state based on the new player index + // SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), SDL_FALSE); } @@ -946,15 +946,15 @@ static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->led_reset_state = k_EDS5LEDResetStateNone; SDL_zero(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, SDL_TRUE); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities if (SDL_IsJoystickDualSenseEdge(device->vendor_id, device->product_id)) { - joystick->nbuttons = 17; /* paddles and touchpad and microphone */ + joystick->nbuttons = 17; // paddles and touchpad and microphone } else if (ctx->touchpad_supported) { - joystick->nbuttons = 13; /* touchpad and microphone */ + joystick->nbuttons = 13; // touchpad and microphone } else { joystick->nbuttons = 11; } @@ -1038,7 +1038,7 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct int maximum_size; if (!ctx->effects_supported) { - /* We shouldn't be sending packets to this controller */ + // We shouldn't be sending packets to this controller return SDL_Unsupported(); } @@ -1048,7 +1048,7 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct } if (!ctx->enhanced_mode) { - /* We're not in enhanced mode, effects aren't allowed */ + // We're not in enhanced mode, effects aren't allowed return SDL_Unsupported(); } } @@ -1057,7 +1057,7 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct if (ctx->device->is_bluetooth) { data[0] = k_EPS5ReportIdBluetoothEffects; - data[1] = 0x02; /* Magic value */ + data[1] = 0x02; // Magic value report_size = 78; offset = 2; @@ -1071,8 +1071,8 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct SDL_memcpy(&data[offset], effect, SDL_min((sizeof(data) - offset), (size_t)size)); if (ctx->device->is_bluetooth) { - /* Bluetooth reports need a CRC at the end of the packet (at least on Linux) */ - Uint8 ubHdr = 0xA2; /* hidp header is part of the CRC calculation */ + // Bluetooth reports need a CRC at the end of the packet (at least on Linux) + Uint8 ubHdr = 0xA2; // hidp header is part of the CRC calculation Uint32 unCRC; unCRC = SDL_crc32(0, &ubHdr, 1); unCRC = SDL_crc32(unCRC, data, (size_t)(report_size - sizeof(unCRC))); @@ -1083,14 +1083,14 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct return -1; } - /* See if we can update an existing pending request */ + // See if we can update an existing pending request if (SDL_HIDAPI_GetPendingRumbleLocked(ctx->device, &pending_data, &pending_size, &maximum_size)) { DS5EffectsState_t *effects = (DS5EffectsState_t *)&data[offset]; DS5EffectsState_t *pending_effects = (DS5EffectsState_t *)&pending_data[offset]; if (report_size == *pending_size && effects->ucEnableBits1 == pending_effects->ucEnableBits1 && effects->ucEnableBits2 == pending_effects->ucEnableBits2) { - /* We're simply updating the data for this request */ + // We're simply updating the data for this request SDL_memcpy(pending_data, data, report_size); SDL_HIDAPI_UnlockRumble(); return 0; @@ -1320,7 +1320,7 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL float data[3]; if (ctx->use_alternate_report) { - /* 16-bit timestamp */ + // 16-bit timestamp Uint32 delta; Uint16 tick = LOAD16(packet->rgucSensorTimestamp[0], packet->rgucSensorTimestamp[1]); @@ -1332,10 +1332,10 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL ctx->last_tick = tick; ctx->sensor_ticks += delta; - /* Sensor timestamp is in 1us units */ + // Sensor timestamp is in 1us units sensor_timestamp = SDL_US_TO_NS(ctx->sensor_ticks); } else { - /* 32-bit timestamp */ + // 32-bit timestamp Uint32 delta; Uint32 tick = LOAD32(packet->rgucSensorTimestamp[0], packet->rgucSensorTimestamp[1], @@ -1349,7 +1349,7 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL ctx->last_tick = tick; ctx->sensor_ticks += delta; - /* Sensor timestamp is in 0.33us units */ + // Sensor timestamp is in 0.33us units sensor_timestamp = (ctx->sensor_ticks * SDL_NS_PER_US) / 3; } @@ -1438,7 +1438,7 @@ static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hi static SDL_bool VerifyCRC(Uint8 *data, int size) { - Uint8 ubHdr = 0xA1; /* hidp header is part of the CRC calculation */ + Uint8 ubHdr = 0xA1; // hidp header is part of the CRC calculation Uint32 unCRC, unPacketCRC; Uint8 *packetCRC = data + size - sizeof(unPacketCRC); unCRC = SDL_crc32(0, &ubHdr, 1); @@ -1456,7 +1456,7 @@ static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 switch (data[0]) { case k_EPS5ReportIdState: if (ctx->is_nacon_dongle && size >= (1 + sizeof(PS5StatePacketAlt_t))) { - /* The report timestamp doesn't change when the controller isn't connected */ + // The report timestamp doesn't change when the controller isn't connected PS5StatePacketAlt_t *packet = (PS5StatePacketAlt_t *)&data[1]; if (SDL_memcmp(packet->rgucPacketSequence, ctx->last_state.state.rgucPacketSequence, sizeof(packet->rgucPacketSequence)) == 0) { return SDL_FALSE; @@ -1464,7 +1464,7 @@ static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 if (ctx->last_state.alt_state.rgucAccelX[0] == 0 && ctx->last_state.alt_state.rgucAccelX[1] == 0 && ctx->last_state.alt_state.rgucAccelY[0] == 0 && ctx->last_state.alt_state.rgucAccelY[1] == 0 && ctx->last_state.alt_state.rgucAccelZ[0] == 0 && ctx->last_state.alt_state.rgucAccelZ[1] == 0) { - /* We don't have any state to compare yet, go ahead and copy it */ + // We don't have any state to compare yet, go ahead and copy it SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS5StatePacketAlt_t)); return SDL_FALSE; } @@ -1526,7 +1526,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) } break; case k_EPS5ReportIdBluetoothState: - /* This is the extended report, we can enable effects now in default mode */ + // This is the extended report, we can enable effects now in default mode HIDAPI_DriverPS5_UpdateEnhancedModeOnEnhancedReport(ctx); HIDAPI_DriverPS5_HandleStatePacketCommon(joystick, device->dev, ctx, (PS5StatePacketCommon_t *)&data[2], timestamp); @@ -1549,13 +1549,13 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) if (device->is_bluetooth) { if (packet_count == 0) { - /* Check to see if it looks like the device disconnected */ + // Check to see if it looks like the device disconnected if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { - /* Send an empty output report to tickle the Bluetooth stack */ + // Send an empty output report to tickle the Bluetooth stack HIDAPI_DriverPS5_TickleBluetooth(device); } } else { - /* Reconnect the Bluetooth device once the USB device is gone */ + // Reconnect the Bluetooth device once the USB device is gone if (device->num_joysticks == 0 && !HIDAPI_HasConnectedUSBDevice(device->serial)) { HIDAPI_JoystickConnected(device, NULL); @@ -1566,7 +1566,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) if (ctx->is_nacon_dongle) { if (packet_count == 0) { if (device->num_joysticks > 0) { - /* Check to see if it looks like the device disconnected */ + // Check to see if it looks like the device disconnected if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } @@ -1579,7 +1579,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) } if (packet_count == 0 && size < 0 && device->num_joysticks > 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1624,6 +1624,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 = { HIDAPI_DriverPS5_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_PS5 */ +#endif // SDL_JOYSTICK_HIDAPI_PS5 -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index 44daf18730..78121c259f 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_HIDAPI -/* Handle rumble on a separate thread so it doesn't block the application */ +// Handle rumble on a separate thread so it doesn't block the application #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" @@ -31,7 +31,7 @@ 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; @@ -91,7 +91,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *data) (void)SDL_AtomicDecRef(&request->device->rumble_pending); SDL_free(request); - /* Make sure we're not starving report reads when there's lots of rumble */ + // Make sure we're not starving report reads when there's lots of rumble SDL_Delay(10); } } @@ -233,7 +233,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const } ctx->requests_head = request; - /* Make sure we unlock before posting the semaphore so the rumble thread can run immediately */ + // Make sure we unlock before posting the semaphore so the rumble thread can run immediately SDL_HIDAPI_UnlockRumble(); SDL_SignalSemaphore(ctx->request_sem); @@ -260,7 +260,7 @@ int SDL_HIDAPI_SendRumble(SDL_HIDAPI_Device *device, const Uint8 *data, int size return -1; } - /* check if there is a pending request for the device and update it */ + // check if there is a pending request for the device and update it if (SDL_HIDAPI_GetPendingRumbleLocked(device, &pending_data, &pending_size, &maximum_size) && size == *pending_size && data[0] == pending_data[0]) { SDL_memcpy(pending_data, data, size); @@ -280,4 +280,4 @@ void SDL_HIDAPI_QuitRumble(void) } } -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.h b/src/joystick/hidapi/SDL_hidapi_rumble.h index 0a1ccb9dfb..2c9bc85761 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.h +++ b/src/joystick/hidapi/SDL_hidapi_rumble.h @@ -22,9 +22,9 @@ #ifdef SDL_JOYSTICK_HIDAPI -/* Handle rumble on a separate thread so it doesn't block the application */ +// Handle rumble on a separate thread so it doesn't block the application -/* Advanced API */ +// Advanced API #ifdef SDL_THREAD_SAFETY_ANALYSIS extern SDL_Mutex *SDL_HIDAPI_rumble_lock; #endif @@ -35,8 +35,8 @@ typedef void (*SDL_HIDAPI_RumbleSentCallback)(void *userdata); int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const Uint8 *data, int size, SDL_HIDAPI_RumbleSentCallback callback, void *userdata) SDL_RELEASE(SDL_HIDAPI_rumble_lock); void SDL_HIDAPI_UnlockRumble(void) SDL_RELEASE(SDL_HIDAPI_rumble_lock); -/* Simple API, will replace any pending rumble with the new data */ +// Simple API, will replace any pending rumble with the new data int SDL_HIDAPI_SendRumble(SDL_HIDAPI_Device *device, const Uint8 *data, int size); void SDL_HIDAPI_QuitRumble(void); -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index d44a80082b..6251d1c789 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -28,20 +28,20 @@ #ifdef SDL_JOYSTICK_HIDAPI_SHIELD -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_SHIELD_PROTOCOL*/ +// 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 -/* Milliseconds between polls of battery state */ +// Milliseconds between polls of battery state #define BATTERY_POLL_INTERVAL_MS 60000 -/* Milliseconds between retransmission of rumble to keep motors running */ +// Milliseconds between retransmission of rumble to keep motors running #define RUMBLE_REFRESH_INTERVAL_MS 500 -/* Reports that are too small are dropped over Bluetooth */ +// Reports that are too small are dropped over Bluetooth #define HID_REPORT_SIZE 33 enum @@ -63,7 +63,7 @@ typedef enum k_ShieldReportIdCommandRequest = 0x04, } EShieldReportId; -/* This same report structure is used for both requests and responses */ +// This same report structure is used for both requests and responses typedef struct { Uint8 report_id; @@ -156,7 +156,7 @@ static int HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, SDL_memcpy(cmd_pkt.payload, data, size); } - /* Zero unused data in the payload */ + // Zero unused data in the payload if (size != sizeof(cmd_pkt.payload)) { SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size); } @@ -181,7 +181,7 @@ static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->last_rumble_time = 0; SDL_zeroa(ctx->last_state); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities if (device->product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) { joystick->nbuttons = SDL_GAMEPAD_NUM_SHIELD_V103_BUTTONS; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; @@ -194,7 +194,7 @@ static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ joystick->nhats = 1; } - /* Request battery and charging info */ + // Request battery and charging info ctx->last_battery_query_time = SDL_GetTicks(); HIDAPI_DriverShield_SendCommand(device, CMD_CHARGE_STATE, NULL, 0); HIDAPI_DriverShield_SendCommand(device, CMD_BATTERY_STATE, NULL, 0); @@ -211,7 +211,7 @@ static int HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) return 0; } - rumble_data[0] = 0x01; /* enable */ + rumble_data[0] = 0x01; // enable rumble_data[1] = ctx->left_motor_amplitude; rumble_data[2] = ctx->right_motor_amplitude; @@ -237,13 +237,13 @@ static int HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy } else { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; - /* The rumble motors are quite intense, so tone down the intensity like the official driver does */ + // The rumble motors are quite intense, so tone down the intensity like the official driver does ctx->left_motor_amplitude = low_frequency_rumble >> 11; ctx->right_motor_amplitude = high_frequency_rumble >> 11; ctx->rumble_update_pending = SDL_TRUE; if (ctx->rumble_report_pending) { - /* We will service this after the hardware acknowledges the previous request */ + // We will service this after the hardware acknowledges the previous request return 0; } @@ -271,10 +271,10 @@ static int HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL const Uint8 *data_bytes = (const Uint8 *)data; if (size > 1) { - /* Single command byte followed by a variable length payload */ + // Single command byte followed by a variable length payload return HIDAPI_DriverShield_SendCommand(device, data_bytes[0], &data_bytes[1], size - 1); } else if (size == 1) { - /* Single command byte with no payload */ + // Single command byte with no payload return HIDAPI_DriverShield_SendCommand(device, data_bytes[0], NULL, 0); } else { return SDL_SetError("Effect data must at least contain a command byte"); @@ -368,7 +368,7 @@ static void HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SD SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SHIELD_V103_TOUCHPAD, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED); - /* It's a triangular pad, but just use the center as the usable touch area */ + // It's a triangular pad, but just use the center as the usable touch area touchpad_state = !(data[1] & 0x80) ? SDL_PRESSED : SDL_RELEASED; touchpad_x = clamp((float)(data[2] - 0x70) / 0x50, 0.0f, 1.0f); touchpad_y = clamp((float)(data[4] - 0x40) / 0x15, 0.0f, 1.0f); @@ -481,7 +481,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) HIDAPI_DumpPacket("NVIDIA SHIELD packet: size = %d", data, size); #endif - /* Byte 0 is HID report ID */ + // Byte 0 is HID report ID switch (data[0]) { case k_ShieldReportIdControllerState: if (!joystick) { @@ -521,13 +521,13 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) } } - /* Ask for battery state again if we're due for an update */ + // Ask for battery state again if we're due for an update if (joystick && SDL_GetTicks() >= (ctx->last_battery_query_time + BATTERY_POLL_INTERVAL_MS)) { ctx->last_battery_query_time = SDL_GetTicks(); HIDAPI_DriverShield_SendCommand(device, CMD_BATTERY_STATE, NULL, 0); } - /* Retransmit rumble packets if they've lasted longer than the hardware supports */ + // Retransmit rumble packets if they've lasted longer than the hardware supports if ((ctx->left_motor_amplitude != 0 || ctx->right_motor_amplitude != 0) && SDL_GetTicks() >= (ctx->last_rumble_time + RUMBLE_REFRESH_INTERVAL_MS)) { ctx->rumble_update_pending = SDL_TRUE; @@ -535,7 +535,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -571,6 +571,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverShield = { HIDAPI_DriverShield_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_SHIELD */ +#endif // SDL_JOYSTICK_HIDAPI_SHIELD -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index c66e8b6018..8584a1e38f 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -28,8 +28,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_STADIA -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_STADIA_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_STADIA_PROTOCOL enum { @@ -74,7 +74,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) } device->context = ctx; - /* Check whether rumble is supported */ + // Check whether rumble is supported { Uint8 rumble_packet[] = { 0x05, 0x00, 0x00, 0x00, 0x00 }; @@ -105,7 +105,7 @@ static SDL_bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ SDL_zeroa(ctx->last_state); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_STADIA_BUTTONS; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; @@ -173,7 +173,7 @@ static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr // 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 */ + // We don't know how to handle this report return; } @@ -283,7 +283,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -319,6 +319,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia = { HIDAPI_DriverStadia_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_STADIA */ +#endif // SDL_JOYSTICK_HIDAPI_STADIA -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 75f6467509..08b22a84dc 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -107,22 +107,22 @@ typedef struct SteamControllerStateInternal_t short sPrevLeftStick[2]; } SteamControllerStateInternal_t; -/* Defines for ulButtons in 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_NORTH_MASK 0x00000010 /* Y */ -#define STEAM_BUTTON_EAST_MASK 0x00000020 /* B */ -#define STEAM_BUTTON_WEST_MASK 0x00000040 /* X */ -#define STEAM_BUTTON_SOUTH_MASK 0x00000080 /* A */ -#define STEAM_DPAD_UP_MASK 0x00000100 /* DPAD UP */ -#define STEAM_DPAD_RIGHT_MASK 0x00000200 /* DPAD RIGHT */ -#define STEAM_DPAD_LEFT_MASK 0x00000400 /* DPAD LEFT */ -#define STEAM_DPAD_DOWN_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_NORTH_MASK 0x00000010 // Y +#define STEAM_BUTTON_EAST_MASK 0x00000020 // B +#define STEAM_BUTTON_WEST_MASK 0x00000040 // X +#define STEAM_BUTTON_SOUTH_MASK 0x00000080 // A +#define STEAM_DPAD_UP_MASK 0x00000100 // DPAD UP +#define STEAM_DPAD_RIGHT_MASK 0x00000200 // DPAD RIGHT +#define STEAM_DPAD_LEFT_MASK 0x00000400 // DPAD LEFT +#define STEAM_DPAD_DOWN_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 @@ -217,7 +217,7 @@ static void ResetSteamControllerPacketAssembler(SteamControllerPacketAssembler * static void InitializeSteamControllerPacketAssembler(SteamControllerPacketAssembler *pAssembler) { - /* We only support BLE devices right now */ + // We only support BLE devices right now pAssembler->bIsBle = true; ResetSteamControllerPacketAssembler(pAssembler); } @@ -982,11 +982,11 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) #ifdef SDL_PLATFORM_WIN32 if (device->serial) { - /* We get a garbage serial number on Windows */ + // We get a garbage serial number on Windows SDL_free(device->serial); device->serial = NULL; } -#endif /* SDL_PLATFORM_WIN32 */ +#endif // SDL_PLATFORM_WIN32 HIDAPI_SetDeviceName(device, "Steam Controller"); @@ -1024,7 +1024,7 @@ static SDL_bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_J InitializeSteamControllerPacketAssembler(&ctx->m_assembler); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_STEAM_BUTTONS; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; @@ -1037,7 +1037,7 @@ static SDL_bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_J 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 */ + // You should use the full Steam Input API for rumble support return SDL_Unsupported(); } @@ -1048,13 +1048,13 @@ static int HIDAPI_DriverSteam_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, static Uint32 HIDAPI_DriverSteam_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - /* You should use the full Steam Input API for extended capabilities */ + // 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) { - /* You should use the full Steam Input API for LED support */ + // You should use the full Steam Input API for LED support return SDL_Unsupported(); } @@ -1201,7 +1201,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) } if (r <= 0) { - /* Failed to read from controller */ + // Failed to read from controller HIDAPI_JoystickDisconnected(device, device->joysticks[0]); return SDL_FALSE; } @@ -1240,6 +1240,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam = { HIDAPI_DriverSteam_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_STEAM */ +#endif // SDL_JOYSTICK_HIDAPI_STEAM -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_steamdeck.c b/src/joystick/hidapi/SDL_hidapi_steamdeck.c index abcf0f61c7..c3673a76d5 100644 --- a/src/joystick/hidapi/SDL_hidapi_steamdeck.c +++ b/src/joystick/hidapi/SDL_hidapi_steamdeck.c @@ -337,7 +337,7 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) r = SDL_hid_read(device->dev, data, sizeof(data)); if (r < 0) { - /* Failed to read from controller */ + // Failed to read from controller HIDAPI_JoystickDisconnected(device, device->joysticks[0]); return SDL_FALSE; } else if (r == 64 && @@ -446,6 +446,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteamDeck = { HIDAPI_DriverSteamDeck_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_STEAMDECK */ +#endif // SDL_JOYSTICK_HIDAPI_STEAMDECK -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 8d95c46e10..6f67d8358d 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -33,18 +33,18 @@ #ifdef SDL_JOYSTICK_HIDAPI_SWITCH -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_SWITCH_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_SWITCH_PROTOCOL -/* Define this to get log output for rumble logic */ -/*#define DEBUG_RUMBLE*/ +// Define this to get log output for rumble logic +// #define DEBUG_RUMBLE /* The initialization sequence doesn't appear to work correctly on Windows unless the reads and writes are on the same thread. ... and now I can't reproduce this, so I'm leaving it in, but disabled for now. */ -/*#define SWITCH_SYNCHRONOUS_WRITES*/ +// #define SWITCH_SYNCHRONOUS_WRITES /* How often you can write rumble commands to the controller. If you send commands more frequently than this, you can turn off the controller @@ -52,7 +52,7 @@ */ #define RUMBLE_WRITE_FREQUENCY_MS 30 -/* How often you have to refresh a long duration rumble to keep the motors running */ +// 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 @@ -339,14 +339,14 @@ static int ReadInput(SDL_DriverSwitch_Context *ctx) { int result; - /* Make sure we don't try to read at the same time a write is happening */ + // Make sure we don't try to read at the same time a write is happening if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) { return 0; } result = SDL_hid_read_timeout(ctx->device->dev, ctx->m_rgucReadBuffer, sizeof(ctx->m_rgucReadBuffer), 0); - /* See if we can guess the initial input mode */ + // See if we can guess the initial input mode if (result > 0 && !ctx->m_bInputOnly && !ctx->m_nInitialInputMode) { switch (ctx->m_rgucReadBuffer[0]) { case k_eSwitchInputReportIDs_FullControllerState: @@ -366,17 +366,17 @@ static int WriteOutput(SDL_DriverSwitch_Context *ctx, const Uint8 *data, int siz #ifdef SWITCH_SYNCHRONOUS_WRITES return SDL_hid_write(ctx->device->dev, data, size); #else - /* Use the rumble thread for general asynchronous writes */ + // Use the rumble thread for general asynchronous writes if (SDL_HIDAPI_LockRumble() != 0) { return -1; } return SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size); -#endif /* SWITCH_SYNCHRONOUS_WRITES */ +#endif // SWITCH_SYNCHRONOUS_WRITES } static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs expectedID) { - /* Average response time for messages is ~30ms */ + // Average response time for messages is ~30ms Uint64 endTicks = SDL_GetTicks() + 100; int nRead = 0; @@ -401,7 +401,7 @@ static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Conte static SDL_bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchProprietaryCommandIDs expectedID) { - /* Average response time for messages is ~30ms */ + // Average response time for messages is ~30ms Uint64 endTicks = SDL_GetTicks() + 100; int nRead = 0; @@ -581,7 +581,7 @@ static SDL_bool WriteRumble(SDL_DriverSwitch_Context *ctx) ctx->m_RumblePacket.ucPacketNumber = ctx->m_nCommandNumber; ctx->m_nCommandNumber = (ctx->m_nCommandNumber + 1) & 0xF; - /* Refresh the rumble state periodically */ + // Refresh the rumble state periodically ctx->m_ulRumbleSent = SDL_GetTicks(); return WritePacket(ctx, (Uint8 *)&ctx->m_RumblePacket, sizeof(ctx->m_RumblePacket)); @@ -591,14 +591,14 @@ static ESwitchDeviceInfoControllerType CalculateControllerType(SDL_DriverSwitch_ { SDL_HIDAPI_Device *device = ctx->device; - /* The N64 controller reports as a Pro controller over USB */ + // The N64 controller reports as a Pro controller over USB if (eControllerType == k_eSwitchDeviceInfoControllerType_ProController && device->product_id == USB_PRODUCT_NINTENDO_N64_CONTROLLER) { eControllerType = k_eSwitchDeviceInfoControllerType_N64; } if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown) { - /* This might be a Joy-Con that's missing from a charging grip slot */ + // This might be a Joy-Con that's missing from a charging grip slot if (device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP) { if (device->interface_number == 1) { eControllerType = k_eSwitchDeviceInfoControllerType_JoyConLeft; @@ -652,12 +652,12 @@ static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) return SDL_FALSE; } if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_HighSpeed, NULL, 0, SDL_TRUE)) { - /* The 8BitDo M30 and SF30 Pro don't respond to this command, but otherwise work correctly */ - /*return SDL_FALSE;*/ + // The 8BitDo M30 and SF30 Pro don't respond to this command, but otherwise work correctly + // return SDL_FALSE; } if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) { - /* This fails on the right Joy-Con when plugged into the charging grip */ - /*return SDL_FALSE;*/ + // This fails on the right Joy-Con when plugged into the charging grip + // return SDL_FALSE; } if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE)) { return SDL_FALSE; @@ -700,10 +700,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); } @@ -757,7 +757,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c static void GetInitialInputMode(SDL_DriverSwitch_Context *ctx) { if (!ctx->m_nInitialInputMode) { - /* This will set the initial input mode if it can */ + // This will set the initial input mode if it can ReadInput(ctx); } } @@ -766,7 +766,7 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) { Uint8 input_mode; - /* Determine the desired input mode */ + // Determine the desired input mode if (ctx->m_nInitialInputMode) { input_mode = ctx->m_nInitialInputMode; } else { @@ -783,7 +783,7 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) * battery level over Bluetooth anyway. */ if (ctx->device->vendor_id == USB_VENDOR_NINTENDO) { - /* However, switching to full controller state breaks DirectInput, so let's not do that */ + // However, switching to full controller state breaks DirectInput, so let's not do that #if 0 input_mode = k_eSwitchInputReportIDs_FullControllerState; #endif @@ -803,7 +803,7 @@ static Uint8 GetSensorInputMode(SDL_DriverSwitch_Context *ctx) { Uint8 input_mode; - /* Determine the desired input mode */ + // Determine the desired input mode if (!ctx->m_nInitialInputMode || ctx->m_nInitialInputMode == k_eSwitchInputReportIDs_SimpleControllerState) { input_mode = k_eSwitchInputReportIDs_FullControllerState; @@ -829,14 +829,14 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) SwitchSPIOpData_t readUserParams; SwitchSPIOpData_t readFactoryParams; - /* Read User Calibration Info */ + // Read User Calibration Info readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset; readUserParams.ucLength = k_unSPIStickUserCalibrationLength; - /* This isn't readable on all controllers, so ignore failure */ + // This isn't readable on all controllers, so ignore failure WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readUserParams, sizeof(readUserParams), &user_reply); - /* Read Factory Calibration Info */ + // Read Factory Calibration Info readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset; readFactoryParams.ucLength = k_unSPIStickFactoryCalibrationLength; @@ -844,7 +844,7 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) return SDL_FALSE; } - /* Automatically select the user calibration if magic bytes are set */ + // Automatically select the user calibration if magic bytes are set if (user_reply && user_reply->stickUserCalibration.rgucLeftMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucLeftMagic[1] == 0xA1) { pLeftStickCal = user_reply->stickUserCalibration.rgucLeftCalibration; } else { @@ -863,23 +863,23 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) * Right: X-Center, Y-Center, X-Min, Y-Min, X-Max, Y-Max */ - /* Left stick */ - ctx->m_StickCalData[0].axis[0].sMax = ((pLeftStickCal[1] << 8) & 0xF00) | pLeftStickCal[0]; /* X Axis max above center */ - ctx->m_StickCalData[0].axis[1].sMax = (pLeftStickCal[2] << 4) | (pLeftStickCal[1] >> 4); /* Y Axis max above center */ - ctx->m_StickCalData[0].axis[0].sCenter = ((pLeftStickCal[4] << 8) & 0xF00) | pLeftStickCal[3]; /* X Axis center */ - ctx->m_StickCalData[0].axis[1].sCenter = (pLeftStickCal[5] << 4) | (pLeftStickCal[4] >> 4); /* Y Axis center */ - ctx->m_StickCalData[0].axis[0].sMin = ((pLeftStickCal[7] << 8) & 0xF00) | pLeftStickCal[6]; /* X Axis min below center */ - ctx->m_StickCalData[0].axis[1].sMin = (pLeftStickCal[8] << 4) | (pLeftStickCal[7] >> 4); /* Y Axis min below center */ + // Left stick + ctx->m_StickCalData[0].axis[0].sMax = ((pLeftStickCal[1] << 8) & 0xF00) | pLeftStickCal[0]; // X Axis max above center + ctx->m_StickCalData[0].axis[1].sMax = (pLeftStickCal[2] << 4) | (pLeftStickCal[1] >> 4); // Y Axis max above center + ctx->m_StickCalData[0].axis[0].sCenter = ((pLeftStickCal[4] << 8) & 0xF00) | pLeftStickCal[3]; // X Axis center + ctx->m_StickCalData[0].axis[1].sCenter = (pLeftStickCal[5] << 4) | (pLeftStickCal[4] >> 4); // Y Axis center + ctx->m_StickCalData[0].axis[0].sMin = ((pLeftStickCal[7] << 8) & 0xF00) | pLeftStickCal[6]; // X Axis min below center + ctx->m_StickCalData[0].axis[1].sMin = (pLeftStickCal[8] << 4) | (pLeftStickCal[7] >> 4); // Y Axis min below center - /* Right stick */ - ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; /* X Axis center */ - ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); /* Y Axis center */ - ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; /* X Axis min below center */ - ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); /* Y Axis min below center */ - ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; /* X Axis max above center */ - ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); /* Y Axis max above center */ + // Right stick + ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; // X Axis center + ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); // Y Axis center + ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; // X Axis min below center + ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); // Y Axis min below center + ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; // X Axis max above center + ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); // Y Axis max above center - /* Filter out any values that were uninitialized (0xFFF) in the SPI read */ + // Filter out any values that were uninitialized (0xFFF) in the SPI read for (stick = 0; stick < 2; ++stick) { for (axis = 0; axis < 2; ++axis) { if (ctx->m_StickCalData[stick].axis[axis].sCenter == 0xFFF) { @@ -915,7 +915,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) { SwitchSubcommandInputPacket_t *reply = NULL; - /* Read Calibration Info */ + // Read Calibration Info SwitchSPIOpData_t readParams; readParams.unAddress = k_unSPIIMUScaleStartOffset; readParams.ucLength = k_unSPIIMUScaleLength; @@ -924,7 +924,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) Uint8 *pIMUScale; Sint16 sAccelRawX, sAccelRawY, sAccelRawZ, sGyroRawX, sGyroRawY, sGyroRawZ; - /* IMU scale gives us multipliers for converting raw values to real world values */ + // IMU scale gives us multipliers for converting raw values to real world values pIMUScale = reply->spiReadData.rgucReadData; sAccelRawX = (pIMUScale[1] << 8) | pIMUScale[0]; @@ -935,7 +935,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) sGyroRawY = (pIMUScale[15] << 8) | pIMUScale[14]; sGyroRawZ = (pIMUScale[17] << 8) | pIMUScale[16]; - /* Check for user calibration data. If it's present and set, it'll override the factory settings */ + // 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) { @@ -950,18 +950,18 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) sGyroRawZ = (pIMUScale[19] << 8) | pIMUScale[18]; } - /* Accelerometer scale */ + // Accelerometer scale ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawX) * SDL_STANDARD_GRAVITY; ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawY) * SDL_STANDARD_GRAVITY; ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY; - /* Gyro scale */ + // Gyro scale ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * SDL_PI_F / 180.0f; ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * SDL_PI_F / 180.0f; ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_PI_F / 180.0f; } else { - /* Use default values */ + // Use default values const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE; const float gyroScale = SDL_PI_F / 180.0f / SWITCH_GYRO_SCALE; @@ -992,7 +992,7 @@ static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, i static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue) { - /* 0x8000 is the neutral value for all joystick axes */ + // 0x8000 is the neutral value for all joystick axes const Uint16 usJoystickCenter = 0x8000; sRawValue -= usJoystickCenter; @@ -1010,7 +1010,7 @@ static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nSt static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button) { if (ctx->m_bUseButtonLabels) { - /* Use button labels instead of positions, e.g. Nintendo Online Classic controllers */ + // Use button labels instead of positions, e.g. Nintendo Online Classic controllers switch (button) { case SDL_GAMEPAD_BUTTON_SOUTH: return SDL_GAMEPAD_BUTTON_EAST; @@ -1031,7 +1031,7 @@ static int GetMaxWriteAttempts(SDL_HIDAPI_Device *device) { if (device->vendor_id == USB_VENDOR_NINTENDO && device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP) { - /* This device is a little slow and we know we're always on USB */ + // This device is a little slow and we know we're always on USB return 20; } else { return 5; @@ -1041,10 +1041,10 @@ static int GetMaxWriteAttempts(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 */ + const int MAX_ATTEMPTS = 1; // Don't try too long, in case this is a zombie Bluetooth controller int attempts = 0; - /* Create enough of a context to read the controller type from the device */ + // Create enough of a context to read the controller type from the device SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); if (ctx) { ctx->device = device; @@ -1067,7 +1067,7 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic } } if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown && attempts < MAX_ATTEMPTS) { - /* Wait a bit and try again */ + // Wait a bit and try again SDL_Delay(100); continue; } @@ -1083,23 +1083,23 @@ static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx) Uint16 vendor_id = ctx->device->vendor_id; Uint16 product_id = ctx->device->product_id; - /* The Power A Nintendo Switch Pro controllers don't have a Home LED */ + // The Power A Nintendo Switch Pro controllers don't have a Home LED if (vendor_id == 0 && product_id == 0) { return SDL_FALSE; } - /* HORI Wireless Switch Pad */ + // HORI Wireless Switch Pad if (vendor_id == 0x0f0d && product_id == 0x00f6) { return SDL_FALSE; } - /* Third party controllers don't have a home LED and will shut off if we try to set it */ + // Third party controllers don't have a home LED and will shut off if we try to set it if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_Unknown || ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_LicProController) { return SDL_FALSE; } - /* The Nintendo Online classic controllers don't have a Home LED */ + // The Nintendo Online classic controllers don't have a Home LED if (vendor_id == USB_VENDOR_NINTENDO && ctx->m_eControllerType > k_eSwitchDeviceInfoControllerType_ProController) { return SDL_FALSE; @@ -1110,7 +1110,7 @@ static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx) static SDL_bool AlwaysUsesLabels(Uint16 vendor_id, Uint16 product_id, ESwitchDeviceInfoControllerType eControllerType) { - /* Some controllers don't have a diamond button configuration, so should always use labels */ + // Some controllers don't have a diamond button configuration, so should always use labels if (SDL_IsJoystickGameCube(vendor_id, product_id)) { return SDL_TRUE; } @@ -1187,7 +1187,7 @@ static SDL_bool HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device { if (vendor_id == USB_VENDOR_NINTENDO) { if (product_id == USB_PRODUCT_NINTENDO_SWITCH_PRO && device && device->dev) { - /* This might be a Kinvoca Joy-Con that reports VID/PID as a Switch Pro controller */ + // This might be a Kinvoca Joy-Con that reports VID/PID as a Switch Pro controller ESwitchDeviceInfoControllerType eControllerType = ReadJoyConControllerType(device); if (eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft || eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { @@ -1231,7 +1231,7 @@ static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, return SDL_FALSE; } - /* If it's handled by another driver, it's not handled here */ + // If it's handled by another driver, it's not handled here if (HIDAPI_DriverNintendoClassic_IsSupportedDevice(device, name, type, vendor_id, product_id, version, interface_number, interface_class, interface_subclass, interface_protocol) || HIDAPI_DriverJoyCons_IsSupportedDevice(device, name, type, vendor_id, product_id, version, interface_number, interface_class, interface_subclass, interface_protocol)) { return SDL_FALSE; @@ -1300,7 +1300,7 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) device->type = SDL_GAMEPAD_TYPE_STANDARD; break; case k_eSwitchDeviceInfoControllerType_Unknown: - /* We couldn't read the device info for this controller, might not be fully compliant */ + // We couldn't read the device info for this controller, might not be fully compliant if (device->vendor_id == USB_VENDOR_NINTENDO) { switch (device->product_id) { case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT: @@ -1354,10 +1354,10 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device); ctx->m_bSyncWrite = SDL_TRUE; - /* Find out whether or not we can send output reports */ + // Find out whether or not we can send output reports ctx->m_bInputOnly = SDL_IsJoystickNintendoSwitchProInputOnly(device->vendor_id, device->product_id); if (!ctx->m_bInputOnly) { - /* Initialize rumble data, important for reading device info on the MOBAPAD M073 */ + // Initialize rumble data, important for reading device info on the MOBAPAD M073 SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]); SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]); @@ -1365,7 +1365,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) } UpdateDeviceIdentity(device); - /* Prefer the USB device over the Bluetooth device */ + // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { return SDL_TRUE; @@ -1408,7 +1408,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ GetInitialInputMode(ctx); ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode; - /* Initialize rumble data */ + // Initialize rumble data SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]); SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]); @@ -1432,7 +1432,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_N64 && ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SEGA_Genesis) { if (LoadIMUCalibration(ctx)) { - /* Use the right sensor in the combined Joy-Con pair */ + // Use the right sensor in the combined Joy-Con pair if (!device->parent || ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 200.0f); @@ -1456,22 +1456,22 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ return SDL_FALSE; } - /* Set desired input mode */ + // Set desired input mode if (!SetInputMode(ctx, GetDefaultInputMode(ctx))) { SDL_SetError("Couldn't set input mode"); return SDL_FALSE; } - /* Start sending USB reports */ + // Start sending USB reports if (!device->is_bluetooth) { - /* ForceUSB doesn't generate an ACK, so don't wait for a reply */ + // ForceUSB doesn't generate an ACK, so don't wait for a reply if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE)) { SDL_SetError("Couldn't start USB reports"); return SDL_FALSE; } } - /* Set the LED state */ + // Set the LED state if (HasHomeLED(ctx)) { if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft || ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { @@ -1488,7 +1488,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->m_bUseButtonLabels = SDL_TRUE; } - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->m_nPlayerIndex = SDL_GetJoystickPlayerIndex(joystick); ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED, SDL_TRUE); UpdateSlotLED(ctx); @@ -1496,17 +1496,17 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED, SDL_PlayerLEDHintChanged, ctx); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_SWITCH_BUTTONS; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; - /* Set up for input */ + // Set up for input ctx->m_bSyncWrite = SDL_FALSE; ctx->m_ulLastIMUReset = ctx->m_ulLastInput = SDL_GetTicks(); - ctx->m_ulIMUUpdateIntervalNS = SDL_MS_TO_NS(5); /* Start off at 5 ms update rate */ + ctx->m_ulIMUUpdateIntervalNS = SDL_MS_TO_NS(5); // Start off at 5 ms update rate - /* Set up for vertical mode */ + // Set up for vertical mode ctx->m_bVerticalMode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, SDL_FALSE); return SDL_TRUE; @@ -1582,10 +1582,10 @@ static int HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy if (device->parent) { if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft) { - /* Just handle low frequency rumble */ + // Just handle low frequency rumble high_frequency_rumble = 0; } else if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { - /* Just handle high frequency rumble */ + // Just handle high frequency rumble low_frequency_rumble = 0; } } @@ -1600,14 +1600,14 @@ static int HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy if (low_frequency_rumble || high_frequency_rumble) { Uint32 unRumblePending = ((Uint32)low_frequency_rumble << 16) | high_frequency_rumble; - /* Keep the highest rumble intensity in the given interval */ + // Keep the highest rumble intensity in the given interval if (unRumblePending > ctx->m_unRumblePending) { ctx->m_unRumblePending = unRumblePending; } ctx->m_bRumblePending = SDL_TRUE; ctx->m_bRumbleZeroPending = SDL_FALSE; } else { - /* When rumble is complete, turn it off */ + // When rumble is complete, turn it off ctx->m_bRumbleZeroPending = SDL_TRUE; } return 0; @@ -1635,7 +1635,7 @@ static Uint32 HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *dev } if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_ProController && !ctx->m_bInputOnly) { - /* Doesn't have an RGB LED, so don't return SDL_JOYSTICK_CAP_RGB_LED here */ + // Doesn't have an RGB LED, so don't return SDL_JOYSTICK_CAP_RGB_LED here result |= SDL_JOYSTICK_CAP_RUMBLE; } else if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft || ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { @@ -1666,7 +1666,7 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL return -1; } - /* This overwrites any internal rumble */ + // This overwrites any internal rumble ctx->m_bRumblePending = SDL_FALSE; ctx->m_bRumbleZeroPending = SDL_FALSE; return 0; @@ -1675,11 +1675,11 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL ESwitchSubcommandIDs cmd = (ESwitchSubcommandIDs)payload[0]; if (cmd == k_eSwitchSubcommandIDs_SetInputReportMode && !device->is_bluetooth) { - /* Going into simple mode over USB disables input reports, so don't do that */ + // Going into simple mode over USB disables input reports, so don't do that return 0; } if (cmd == k_eSwitchSubcommandIDs_SetHomeLight && !HasHomeLED(ctx)) { - /* Setting the home LED when it's not supported can cause the controller to reset */ + // Setting the home LED when it's not supported can cause the controller to reset return 0; } @@ -2183,7 +2183,7 @@ static void SendSensorUpdate(Uint64 timestamp, SDL_Joystick *joystick, SDL_Drive data[2] = -(ctx->m_IMUScaleData.fAccelScaleX * (float)values[0]); } - /* Right Joy-Con flips some axes, so let's flip them back for consistency */ + // Right Joy-Con flips some axes, so let's flip them back for consistency if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { data[0] = -data[0]; data[1] = -data[1]; @@ -2191,7 +2191,7 @@ static void SendSensorUpdate(Uint64 timestamp, SDL_Joystick *joystick, SDL_Drive if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft && !ctx->device->parent && !ctx->m_bVerticalMode) { - /* Mini-gamepad mode, swap some axes around */ + // Mini-gamepad mode, swap some axes around float tmp = data[2]; data[2] = -data[0]; data[0] = tmp; @@ -2199,7 +2199,7 @@ static void SendSensorUpdate(Uint64 timestamp, SDL_Joystick *joystick, SDL_Drive if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight && !ctx->device->parent && !ctx->m_bVerticalMode) { - /* Mini-gamepad mode, swap some axes around */ + // Mini-gamepad mode, swap some axes around float tmp = data[2]; data[2] = data[0]; data[0] = -tmp; @@ -2350,7 +2350,7 @@ static void HandleMiniControllerStateR(Uint64 timestamp, SDL_Joystick *joystick, SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis); } -static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet) SDL_NO_THREAD_SAFETY_ANALYSIS /* We unlock and lock the device lock to be able to change IMU state */ +static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet) SDL_NO_THREAD_SAFETY_ANALYSIS // We unlock and lock the device lock to be able to change IMU state { Uint64 timestamp = SDL_GetTicksNS(); @@ -2470,7 +2470,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C ctx->m_bHasSensorData = SDL_TRUE; - /* We got three IMU samples, calculate the IMU update rate and timestamps */ + // We got three IMU samples, calculate the IMU update rate and timestamps ctx->m_unIMUSamples += 3; if (ctx->m_unIMUSamples >= IMU_UPDATE_RATE_SAMPLE_FREQUENCY) { Uint64 now = SDL_GetTicksNS(); @@ -2526,7 +2526,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C } } else if (ctx->m_bHasSensorData) { - /* Uh oh, someone turned off the IMU? */ + // Uh oh, someone turned off the IMU? const int IMU_RESET_DELAY_MS = 3000; Uint64 now = SDL_GetTicks(); @@ -2546,7 +2546,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C } } else { - /* We have never gotten IMU data, probably not supported on this device */ + // We have never gotten IMU data, probably not supported on this device } } @@ -2605,7 +2605,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) ctx->device->product_id != USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP) { const int INPUT_WAIT_TIMEOUT_MS = 100; if (now >= (ctx->m_ulLastInput + INPUT_WAIT_TIMEOUT_MS)) { - /* Steam may have put the controller back into non-reporting mode */ + // Steam may have put the controller back into non-reporting mode SDL_bool wasSyncWrite = ctx->m_bSyncWrite; ctx->m_bSyncWrite = SDL_TRUE; @@ -2616,7 +2616,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) ctx->m_nCurrentInputMode != k_eSwitchInputReportIDs_SimpleControllerState) { const int INPUT_WAIT_TIMEOUT_MS = 3000; if (now >= (ctx->m_ulLastInput + INPUT_WAIT_TIMEOUT_MS)) { - /* Bluetooth may have disconnected, try reopening the controller */ + // Bluetooth may have disconnected, try reopening the controller size = -1; } } @@ -2633,14 +2633,14 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) } } - /* Reconnect the Bluetooth device once the USB device is gone */ + // Reconnect the Bluetooth device once the USB device is gone if (device->num_joysticks == 0 && device->is_bluetooth && packet_count > 0 && !HIDAPI_HasConnectedUSBDevice(device->serial)) { HIDAPI_JoystickConnected(device, NULL); } if (size < 0 && device->num_joysticks > 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -2651,7 +2651,7 @@ static void HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; if (!ctx->m_bInputOnly) { - /* Restore simple input mode for other applications */ + // Restore simple input mode for other applications if (!ctx->m_nInitialInputMode || ctx->m_nInitialInputMode == k_eSwitchInputReportIDs_SimpleControllerState) { SetInputMode(ctx, k_eSwitchInputReportIDs_SimpleControllerState); @@ -2743,6 +2743,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch = { HIDAPI_DriverSwitch_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_SWITCH */ +#endif // SDL_JOYSTICK_HIDAPI_SWITCH -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 62ce9721f3..62556b8f49 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -30,8 +30,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_WII -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_WII_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_WII_PROTOCOL #define ENABLE_CONTINUOUS_REPORTING SDL_TRUE @@ -95,9 +95,9 @@ 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 */ + 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 @@ -170,7 +170,7 @@ static void HIDAPI_DriverWii_UnregisterHints(SDL_HintCallback callback, void *us static SDL_bool HIDAPI_DriverWii_IsEnabled(void) { -#if 1 /* This doesn't work with the dolphinbar, so don't enable by default right now */ +#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, @@ -193,7 +193,7 @@ static int ReadInput(SDL_DriverWii_Context *ctx) { int size; - /* Make sure we don't try to read at the same time a write is happening */ + // Make sure we don't try to read at the same time a write is happening if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) { return 0; } @@ -217,7 +217,7 @@ static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int s if (sync) { return SDL_hid_write(ctx->device->dev, data, size) >= 0; } else { - /* Use the rumble thread for general asynchronous writes */ + // Use the rumble thread for general asynchronous writes if (SDL_HIDAPI_LockRumble() < 0) { return SDL_FALSE; } @@ -227,7 +227,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 *)) { - Uint64 endTicks = SDL_GetTicks() + 250; /* Seeing successful reads after about 200 ms */ + Uint64 endTicks = SDL_GetTicks() + 250; // Seeing successful reads after about 200 ms int nRead = 0; while ((nRead = ReadInput(ctx)) != -1) { @@ -269,7 +269,7 @@ static SDL_bool WriteRegister(SDL_DriverWii_Context *ctx, Uint32 address, const return SDL_FALSE; } if (sync) { - /* Wait for response */ + // Wait for response if (!ReadInputSync(ctx, k_eWiiInputReportIDs_Acknowledge, IsWriteMemoryResponse)) { return SDL_FALSE; } @@ -299,8 +299,8 @@ static SDL_bool ReadRegister(SDL_DriverWii_Context *ctx, Uint32 address, int siz return SDL_FALSE; } if (sync) { - SDL_assert(size <= 16); /* Only waiting for one packet is supported right now */ - /* Wait for response */ + SDL_assert(size <= 16); // Only waiting for one packet is supported right now + // Wait for response if (!ReadInputSync(ctx, k_eWiiInputReportIDs_ReadMemory, NULL)) { return SDL_FALSE; } @@ -331,7 +331,7 @@ static SDL_bool ParseExtensionIdentifyResponse(SDL_DriverWii_Context *ctx, Uint1 Uint8 error = (ctx->m_rgucReadBuffer[3] & 0xF); if (error == 7) { - /* The extension memory isn't mapped */ + // The extension memory isn't mapped *extension = WII_EXTENSION_NONE; return SDL_TRUE; } @@ -374,7 +374,7 @@ static SDL_bool SendExtensionReset(SDL_DriverWii_Context *ctx, SDL_bool sync) Uint8 data = 0x55; result = result && WriteRegister(ctx, 0xA400F0, &data, sizeof(data), sync); } - /* This write will fail if there is no extension connected, that's fine */ + // This write will fail if there is no extension connected, that's fine { Uint8 data = 0x00; (void)WriteRegister(ctx, 0xA400FB, &data, sizeof(data), sync); @@ -394,14 +394,14 @@ static SDL_bool GetMotionPlusState(SDL_DriverWii_Context *ctx, SDL_bool *connect } if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_WiiUPro) { - /* The Wii U Pro controller never has the Motion Plus extension */ + // The Wii U Pro controller never has the Motion Plus extension return SDL_TRUE; } if (SendExtensionIdentify(ctx, SDL_TRUE) && ParseExtensionIdentifyResponse(ctx, &extension)) { if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { - /* Motion Plus is currently active */ + // Motion Plus is currently active if (connected) { *connected = SDL_TRUE; } @@ -415,7 +415,7 @@ static SDL_bool GetMotionPlusState(SDL_DriverWii_Context *ctx, SDL_bool *connect if (ReadRegister(ctx, 0xA600FE, 2, SDL_TRUE) && ParseExtensionIdentifyResponse(ctx, &extension)) { if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { - /* Motion Plus is currently connected */ + // Motion Plus is currently connected if (connected) { *connected = SDL_TRUE; } @@ -423,19 +423,19 @@ static SDL_bool GetMotionPlusState(SDL_DriverWii_Context *ctx, SDL_bool *connect return SDL_TRUE; } - /* Failed to read the register or parse the response */ + // Failed to read the register or parse the response return SDL_FALSE; } static SDL_bool NeedsPeriodicMotionPlusCheck(SDL_DriverWii_Context *ctx, SDL_bool status_update) { if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_WiiUPro) { - /* The Wii U Pro controller never has the Motion Plus extension */ + // The Wii U Pro controller never has the Motion Plus extension return SDL_FALSE; } if (ctx->m_ucMotionPlusMode != WII_MOTIONPLUS_MODE_NONE && !status_update) { - /* We'll get a status update when Motion Plus is disconnected */ + // We'll get a status update when Motion Plus is disconnected return SDL_FALSE; } @@ -464,14 +464,14 @@ static void ActivateMotionPlusWithMode(SDL_DriverWii_Context *ctx, Uint8 mode) WriteRegister(ctx, 0xA600FE, &mode, sizeof(mode), SDL_TRUE); ctx->m_ucMotionPlusMode = mode; -#endif /* LINUX */ +#endif // LINUX } static void ActivateMotionPlus(SDL_DriverWii_Context *ctx) { Uint8 mode = WII_MOTIONPLUS_MODE_STANDARD; - /* Pick the pass-through mode based on the connected controller */ + // Pick the pass-through mode based on the connected controller if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_Nunchuk) { mode = WII_MOTIONPLUS_MODE_NUNCHUK; } else if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_Gamepad) { @@ -485,7 +485,7 @@ static void DeactivateMotionPlus(SDL_DriverWii_Context *ctx) Uint8 data = 0x55; WriteRegister(ctx, 0xA400F0, &data, sizeof(data), SDL_TRUE); - /* Wait for the deactivation status message */ + // Wait for the deactivation status message ReadInputSync(ctx, k_eWiiInputReportIDs_Status, NULL); ctx->m_ucMotionPlusMode = WII_MOTIONPLUS_MODE_NONE; @@ -573,7 +573,7 @@ static SDL_bool RequestButtonPacketType(SDL_DriverWii_Context *ctx, EWiiInputRep Uint8 data[3]; Uint8 tt = (Uint8)ctx->m_bRumbleActive; - /* Continuous reporting off, tt & 4 == 0 */ + // Continuous reporting off, tt & 4 == 0 if (ENABLE_CONTINUOUS_REPORTING) { tt |= 4; } @@ -634,11 +634,11 @@ static void UpdateSlotLED(SDL_DriverWii_Context *ctx) Uint8 leds; Uint8 data[2]; - /* The lowest bit needs to have the rumble status */ + // The lowest bit needs to have the rumble status leds = (Uint8)ctx->m_bRumbleActive; if (ctx->m_bPlayerLights) { - /* Use the same LED codes as Smash 8-player for 5-7 */ + // Use the same LED codes as Smash 8-player for 5-7 if (ctx->m_nPlayerIndex == 0 || ctx->m_nPlayerIndex > 3) { leds |= k_eWiiPlayerLEDs_P1; } @@ -651,7 +651,7 @@ static void UpdateSlotLED(SDL_DriverWii_Context *ctx) if (ctx->m_nPlayerIndex == 3 || ctx->m_nPlayerIndex == 6) { leds |= k_eWiiPlayerLEDs_P4; } - /* Turn on all lights for other player indexes */ + // Turn on all lights for other player indexes if (ctx->m_nPlayerIndex < 0 || ctx->m_nPlayerIndex > 6) { leds |= k_eWiiPlayerLEDs_P1 | k_eWiiPlayerLEDs_P2 | k_eWiiPlayerLEDs_P3 | k_eWiiPlayerLEDs_P4; } @@ -681,7 +681,7 @@ static EWiiExtensionControllerType ReadExtensionControllerType(SDL_HIDAPI_Device const int MAX_ATTEMPTS = 20; int attempts = 0; - /* Create enough of a context to read the controller type from the device */ + // Create enough of a context to read the controller type from the device for (attempts = 0; attempts < MAX_ATTEMPTS; ++attempts) { Uint16 extension; if (SendExtensionIdentify(ctx, SDL_TRUE) && @@ -699,7 +699,7 @@ static EWiiExtensionControllerType ReadExtensionControllerType(SDL_HIDAPI_Device eExtensionControllerType = GetExtensionType(extension); - /* Reset the Motion Plus controller if needed */ + // Reset the Motion Plus controller if needed if (motion_plus_mode) { ActivateMotionPlusWithMode(ctx, motion_plus_mode); } @@ -798,7 +798,7 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy } } - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->m_nPlayerIndex = SDL_GetJoystickPlayerIndex(joystick); ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, SDL_TRUE); UpdateSlotLED(ctx); @@ -806,11 +806,11 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, SDL_PlayerLEDHintChanged, ctx); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_WiiUPro) { joystick->nbuttons = 15; } else { - /* Maximum is Classic Controller + Wiimote */ + // Maximum is Classic Controller + Wiimote joystick->nbuttons = k_eWiiButtons_Max; } joystick->naxes = SDL_GAMEPAD_AXIS_MAX; @@ -881,7 +881,7 @@ static void PostStickCalibrated(Uint64 timestamp, SDL_Joystick *joystick, StickC { Sint16 value = 0; if (!calibration->center) { - /* Center on first read */ + // Center on first read calibration->center = data; return; } @@ -1034,22 +1034,22 @@ static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *jo return; } - /* Buttons */ + // Buttons PostPackedButtonData(ctx->timestamp, joystick, buttons, data->rgucExtension + 8, 3, SDL_RELEASED, SDL_PRESSED); - /* Triggers */ + // Triggers zl = data->rgucExtension[9] & 0x80; zr = data->rgucExtension[9] & 0x04; SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); - /* Sticks */ + // Sticks for (i = 0; i < 4; i++) { Uint16 value = data->rgucExtension[i * 2] | (data->rgucExtension[i * 2 + 1] << 8); PostStickCalibrated(ctx->timestamp, joystick, &ctx->m_StickCalibrationData[i], axes[i], value); } - /* Power */ + // Power UpdatePowerLevelWiiU(joystick, data->rgucExtension[10]); } @@ -1062,19 +1062,19 @@ static void HandleGamepadControllerButtonData(SDL_DriverWii_Context *ctx, SDL_Jo return; } - /* Buttons */ + // Buttons PostPackedButtonData(ctx->timestamp, joystick, buttons, data->rgucExtension + 4, 2, SDL_RELEASED, SDL_PRESSED); if (ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) { PostPackedButtonData(ctx->timestamp, joystick, MP_FIXUP_DPAD_BUTTON_DEFS, data->rgucExtension, 2, SDL_RELEASED, SDL_PRESSED); } - /* Triggers */ + // Triggers zl = data->rgucExtension[5] & 0x80; zr = data->rgucExtension[5] & 0x04; SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX); - /* Sticks */ + // Sticks if (ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) { lx = data->rgucExtension[0] & 0x3E; ly = data->rgucExtension[1] & 0x3E; @@ -1215,24 +1215,24 @@ static void HandleMotionPlusData(SDL_DriverWii_Context *ctx, SDL_Joystick *joyst z = (data->rgucExtension[2] | ((data->rgucExtension[5] << 6) & 0xFF00)) - 8192; if (data->rgucExtension[3] & 0x02) { - /* Slow rotation rate: 8192/440 units per deg/s */ + // Slow rotation rate: 8192/440 units per deg/s x *= 440; } else { - /* Fast rotation rate: 8192/2000 units per deg/s */ + // Fast rotation rate: 8192/2000 units per deg/s x *= 2000; } if (data->rgucExtension[4] & 0x02) { - /* Slow rotation rate: 8192/440 units per deg/s */ + // Slow rotation rate: 8192/440 units per deg/s y *= 440; } else { - /* Fast rotation rate: 8192/2000 units per deg/s */ + // Fast rotation rate: 8192/2000 units per deg/s y *= 2000; } if (data->rgucExtension[3] & 0x01) { - /* Slow rotation rate: 8192/440 units per deg/s */ + // Slow rotation rate: 8192/440 units per deg/s z *= 440; } else { - /* Fast rotation rate: 8192/2000 units per deg/s */ + // Fast rotation rate: 8192/2000 units per deg/s z *= 2000; } @@ -1273,18 +1273,18 @@ static void HandleButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, if (ctx->m_ucMotionPlusMode != WII_MOTIONPLUS_MODE_NONE && data->ucNExtensionBytes > 5) { if (data->rgucExtension[5] & 0x01) { - /* The data is invalid, possibly during a hotplug */ + // The data is invalid, possibly during a hotplug return; } if (data->rgucExtension[4] & 0x01) { if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_None) { - /* Something was plugged into the extension port, reinitialize to get new state */ + // Something was plugged into the extension port, reinitialize to get new state ctx->m_bDisconnected = SDL_TRUE; } } else { if (ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None) { - /* Something was removed from the extension port, reinitialize to get new state */ + // Something was removed from the extension port, reinitialize to get new state ctx->m_bDisconnected = SDL_TRUE; } } @@ -1292,7 +1292,7 @@ static void HandleButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, if (data->rgucExtension[5] & 0x02) { HandleMotionPlusData(ctx, joystick, data); - /* The extension data is consumed */ + // The extension data is consumed data->ucNExtensionBytes = 0; } } @@ -1357,11 +1357,11 @@ static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) HandleButtonData(ctx, joystick, &data); if (ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_WiiUPro) { - /* Wii U has separate battery level tracking */ + // Wii U has separate battery level tracking UpdatePowerLevelWii(joystick, ctx->m_rgucReadBuffer[6]); } - /* The report data format has been reset, need to update it */ + // The report data format has been reset, need to update it ResetButtonPacketType(ctx); SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Status update, extension %s\n", hasExtension ? "CONNECTED" : "DISCONNECTED"); @@ -1379,7 +1379,7 @@ static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) } } else if (hadExtension != hasExtension) { - /* Reinitialize to get new state */ + // Reinitialize to get new state ctx->m_bDisconnected = SDL_TRUE; } } @@ -1403,27 +1403,27 @@ static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) Uint16 extension = 0; if (ParseExtensionIdentifyResponse(ctx, &extension)) { if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { - /* Motion Plus is currently active */ + // 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 */ + // 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 */ + // 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 */ + // 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 */ + // Reinitialize to get new sensor availability ctx->m_bDisconnected = SDL_TRUE; } ctx->m_eCommState = k_eWiiCommunicationState_None; @@ -1431,7 +1431,7 @@ static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) } } break; default: - /* Should never happen */ + // Should never happen break; } } @@ -1441,45 +1441,45 @@ static void HandleButtonPacket(SDL_DriverWii_Context *ctx, SDL_Joystick *joystic EWiiInputReportIDs eExpectedReport = GetButtonPacketType(ctx); WiiButtonData data; - /* FIXME: This should see if the data format is compatible rather than equal */ + // FIXME: This should see if the data format is compatible rather than equal if (eExpectedReport != ctx->m_rgucReadBuffer[0]) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI Wii: Resetting report mode to %d\n", eExpectedReport); RequestButtonPacketType(ctx, eExpectedReport); } - /* IR camera data is not supported */ + // IR camera data is not supported SDL_zero(data); switch (ctx->m_rgucReadBuffer[0]) { - case k_eWiiInputReportIDs_ButtonData0: /* 30 BB BB */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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: @@ -1495,7 +1495,7 @@ static void HandleInput(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) { EWiiInputReportIDs type = (EWiiInputReportIDs)ctx->m_rgucReadBuffer[0]; - /* Set up for handling input */ + // Set up for handling input ctx->timestamp = SDL_GetTicksNS(); if (type == k_eWiiInputReportIDs_Status) { @@ -1538,15 +1538,15 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) SDL_COMPILE_TIME_ASSERT(ENABLE_CONTINUOUS_REPORTING, ENABLE_CONTINUOUS_REPORTING); } if (now >= (ctx->m_ulLastInput + INPUT_WAIT_TIMEOUT_MS)) { - /* Bluetooth may have disconnected, try reopening the controller */ + // Bluetooth may have disconnected, try reopening the controller size = -1; } if (joystick) { - /* These checks aren't needed on the Wii U Pro Controller */ + // These checks aren't needed on the Wii U Pro Controller if (ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_WiiUPro) { - /* Check to see if the Motion Plus extension status has changed */ + // Check to see if the Motion Plus extension status has changed if (ctx->m_ulNextMotionPlusCheck && now >= ctx->m_ulNextMotionPlusCheck) { CheckMotionPlusConnection(ctx); if (NeedsPeriodicMotionPlusCheck(ctx, SDL_FALSE)) { @@ -1556,7 +1556,7 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) } } - /* Request a status update periodically to make sure our battery value is up to date */ + // Request a status update periodically to make sure our battery value is up to date if (!ctx->m_ulLastStatus || now >= (ctx->m_ulLastStatus + STATUS_UPDATE_TIME_MS)) { Uint8 data[2]; @@ -1570,7 +1570,7 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0 || ctx->m_bDisconnected) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1612,6 +1612,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverWii = { HIDAPI_DriverWii_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_WII */ +#endif // SDL_JOYSTICK_HIDAPI_WII -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index 8e4aef3c16..5793045399 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -29,8 +29,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_XBOX360 -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_XBOX_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_XBOX_PROTOCOL typedef struct { @@ -61,28 +61,28 @@ static SDL_bool HIDAPI_DriverXbox360_IsEnabled(void) static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType 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 */ + const int XB360W_IFACE_PROTOCOL = 129; // Wireless if (vendor_id == USB_VENDOR_ASTRO && product_id == USB_PRODUCT_ASTRO_C40_XBOX360) { - /* This is the ASTRO C40 in Xbox 360 mode */ + // This is the ASTRO C40 in Xbox 360 mode return SDL_TRUE; } if (vendor_id == USB_VENDOR_NVIDIA) { - /* This is the NVIDIA Shield controller which doesn't talk Xbox controller protocol */ + // This is the NVIDIA Shield controller which doesn't talk Xbox controller protocol return SDL_FALSE; } if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY2 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER)) || (type == SDL_GAMEPAD_TYPE_XBOX360 && interface_protocol == XB360W_IFACE_PROTOCOL)) { - /* This is the wireless dongle, which talks a different protocol */ + // This is the wireless dongle, which talks a different protocol return SDL_FALSE; } if (interface_number > 0) { - /* This is the chatpad or other input interface, not the Xbox 360 interface */ + // This is the chatpad or other input interface, not the Xbox 360 interface return SDL_FALSE; } #ifdef SDL_PLATFORM_MACOS if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0) { - /* This is the Steam Virtual Gamepad, which isn't supported by this driver */ + // This is the Steam Virtual Gamepad, which isn't supported by this driver return SDL_FALSE; } /* Wired Xbox One controllers are handled by this driver, interfacing with @@ -179,7 +179,7 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL ctx->joystick = joystick; SDL_zeroa(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_TRUE); UpdateSlotLED(ctx); @@ -187,7 +187,7 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_PlayerLEDHintChanged, ctx); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; @@ -356,7 +356,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -398,6 +398,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 = { HIDAPI_DriverXbox360_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_XBOX360 */ +#endif // SDL_JOYSTICK_HIDAPI_XBOX360 -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index fc7fe94536..674f6cdc4f 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -29,8 +29,8 @@ #ifdef SDL_JOYSTICK_HIDAPI_XBOX360 -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_XBOX_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_XBOX_PROTOCOL typedef struct { @@ -63,7 +63,7 @@ static SDL_bool HIDAPI_DriverXbox360W_IsEnabled(void) static SDL_bool HIDAPI_DriverXbox360W_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType 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 */ + const int XB360W_IFACE_PROTOCOL = 129; // Wireless if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY2 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY1 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER) && interface_protocol == 0) || (type == SDL_GAMEPAD_TYPE_XBOX360 && interface_protocol == XB360W_IFACE_PROTOCOL)) { @@ -117,7 +117,7 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360W_Context *ctx; - /* Requests controller presence information from the wireless dongle */ + // Requests controller presence information from the wireless dongle const Uint8 init_packet[] = { 0x08, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; HIDAPI_SetDeviceName(device, "Xbox 360 Wireless Controller"); @@ -166,7 +166,7 @@ static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SD SDL_zeroa(ctx->last_state); - /* Initialize player index (needed for setting LEDs) */ + // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_TRUE); UpdateSlotLED(ctx); @@ -174,7 +174,7 @@ static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SD SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_PlayerLEDHintChanged, ctx); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 15; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; @@ -319,7 +319,7 @@ static SDL_bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) } } } else if (size == 29 && data[0] == 0x00 && data[1] == 0x0f && data[2] == 0x00 && data[3] == 0xf0) { - /* Serial number is data[7-13] */ + // Serial number is data[7-13] #ifdef DEBUG_JOYSTICK SDL_Log("Battery status (initial): %d\n", data[17]); #endif @@ -341,7 +341,7 @@ static SDL_bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) } if (size < 0 && device->num_joysticks > 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -381,6 +381,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W = { HIDAPI_DriverXbox360W_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_XBOX360 */ +#endif // SDL_JOYSTICK_HIDAPI_XBOX360 -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index ff03f5d563..b3b9eb6424 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -29,11 +29,11 @@ #ifdef SDL_JOYSTICK_HIDAPI_XBOXONE -/* Define this if you want verbose logging of the init sequence */ -/*#define DEBUG_JOYSTICK*/ +// Define this if you want verbose logging of the init sequence +// #define DEBUG_JOYSTICK -/* Define this if you want to log all packets from the controller */ -/*#define DEBUG_XBOX_PROTOCOL*/ +// Define this if you want to log all packets from the controller +// #define DEBUG_XBOX_PROTOCOL #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #define XBOX_ONE_DRIVER_ACTIVE 1 @@ -44,34 +44,34 @@ #define CONTROLLER_IDENTIFY_TIMEOUT_MS 100 #define CONTROLLER_PREPARE_INPUT_TIMEOUT_MS 50 -/* Deadzone thresholds */ +// Deadzone thresholds #define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 #define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 -#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD -25058 /* Uint8 30 scaled to Sint16 full range */ +#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD -25058 // Uint8 30 scaled to Sint16 full range enum { SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON = 11 }; -/* Power on */ +// Power on static const Uint8 xbox_init_power_on[] = { 0x05, 0x20, 0x00, 0x01, 0x00 }; -/* Enable LED */ +// Enable LED static const Uint8 xbox_init_enable_led[] = { 0x0A, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14 }; -/* This controller passed security check */ +// This controller passed security check static const Uint8 xbox_init_security_passed[] = { 0x06, 0x20, 0x00, 0x02, 0x01, 0x00 }; -/* Some PowerA controllers need to actually start the rumble motors */ +// Some PowerA controllers need to actually start the rumble motors static const Uint8 xbox_init_powera_rumble[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x1D, 0x1D, 0xFF, 0x00, 0x00 }; -/* Setup rumble (not needed for Microsoft controllers, but it doesn't hurt) */ +// Setup rumble (not needed for Microsoft controllers, but it doesn't hurt) static const Uint8 xbox_init_rumble[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xEB @@ -157,7 +157,7 @@ static SDL_bool ControllerHasPaddles(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 */ + // All the Microsoft Xbox One controllers have trigger rumble if (vendor_id == USB_VENDOR_MICROSOFT) { return SDL_TRUE; } @@ -267,7 +267,7 @@ static SDL_bool SendSerialRequest(SDL_DriverXboxOne_Context *ctx) static SDL_bool ControllerSendsAnnouncement(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_PDP && product_id == 0x0246) { - /* The PDP Rock Candy (PID 0x0246) doesn't send the announce packet on Linux for some reason */ + // The PDP Rock Candy (PID 0x0246) doesn't send the announce packet on Linux for some reason return SDL_FALSE; } return SDL_TRUE; @@ -275,7 +275,7 @@ static SDL_bool ControllerSendsAnnouncement(Uint16 vendor_id, Uint16 product_id) static SDL_bool SendIdentificationRequest(SDL_DriverXboxOne_Context *ctx) { - /* Request identification, sent in response to announce packet */ + // Request identification, sent in response to announce packet Uint8 packet[] = { 0x04, 0x20, 0x00, 0x00 }; @@ -311,7 +311,7 @@ static SDL_bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) init_packet[2] = GetNextPacketSequence(ctx); if (init_packet[0] == 0x0A) { - /* Get the initial brightness value */ + // Get the initial brightness value int brightness = GetHomeLEDBrightness(SDL_GetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED)); init_packet[5] = (brightness > 0) ? 0x01 : 0x00; init_packet[6] = (Uint8)brightness; @@ -322,7 +322,7 @@ static SDL_bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) return SDL_FALSE; } - /* Wait to process the rumble packet */ + // Wait to process the rumble packet if (packet->data == xbox_init_powera_rumble) { SDL_Delay(10); } @@ -351,7 +351,7 @@ static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void) static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { #ifdef SDL_PLATFORM_MACOS - /* Wired Xbox One controllers are handled by the 360Controller driver */ + // Wired Xbox One controllers are handled by the 360Controller driver if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { return SDL_FALSE; } @@ -380,9 +380,9 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) ctx->has_trigger_rumble = ControllerHasTriggerRumble(ctx->vendor_id, ctx->product_id); ctx->has_share_button = ControllerHasShareButton(ctx->vendor_id, ctx->product_id); - /* Assume that the controller is correctly initialized when we start */ + // Assume that the controller is correctly initialized when we start if (!ControllerSendsAnnouncement(device->vendor_id, device->product_id)) { - /* Jump into the startup sequence for this controller */ + // Jump into the startup sequence for this controller ctx->init_state = XBOX_ONE_INIT_STATE_STARTUP; } else { ctx->init_state = XBOX_ONE_INIT_STATE_COMPLETE; @@ -421,7 +421,7 @@ static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL ctx->rumble_pending = SDL_FALSE; SDL_zeroa(ctx->last_state); - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities joystick->nbuttons = 11; if (ctx->has_share_button) { joystick->nbuttons += 1; @@ -467,7 +467,7 @@ static int HIDAPI_DriverXboxOne_UpdateRumble(SDL_DriverXboxOne_Context *ctx) return 0; } - /* We're no longer pending, even if we fail to send the rumble below */ + // We're no longer pending, even if we fail to send the rumble below ctx->rumble_pending = SDL_FALSE; if (SDL_HIDAPI_LockRumble() < 0) { @@ -507,7 +507,7 @@ static int HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Jo { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; - /* Magnitude is 1..100 so scale the 16-bit input here */ + // Magnitude is 1..100 so scale the 16-bit input here ctx->low_frequency_rumble = (Uint8)(low_frequency_rumble / 655); ctx->high_frequency_rumble = (Uint8)(high_frequency_rumble / 655); ctx->rumble_pending = SDL_TRUE; @@ -523,7 +523,7 @@ static int HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device return SDL_Unsupported(); } - /* Magnitude is 1..100 so scale the 16-bit input here */ + // Magnitude is 1..100 so scale the 16-bit input here ctx->left_trigger_rumble = (Uint8)(left_rumble / 655); ctx->right_trigger_rumble = (Uint8)(right_rumble / 655); ctx->rumble_pending = SDL_TRUE; @@ -555,7 +555,7 @@ static int HIDAPI_DriverXboxOne_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Jo if (ctx->has_color_led) { Uint8 led_packet[] = { 0x0E, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; - led_packet[5] = 0x00; /* Whiteness? Sets white intensity when RGB is 0, seems additive */ + led_packet[5] = 0x00; // Whiteness? Sets white intensity when RGB is 0, seems additive led_packet[6] = red; led_packet[7] = green; led_packet[8] = blue; @@ -595,7 +595,7 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic Uint64 timestamp = SDL_GetTicksNS(); if (size == 17) { - /* XBox One Elite Series 2 */ + // XBox One Elite Series 2 paddle_index = 14; button1_bit = 0x01; button2_bit = 0x02; @@ -606,15 +606,15 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic if (profile == 0) { paddles_mapped = SDL_FALSE; } else if (SDL_memcmp(&data[0], &ctx->last_state[0], 14) == 0) { - /* We're using a profile, but paddles aren't mapped */ + // We're using a profile, but paddles aren't mapped paddles_mapped = SDL_FALSE; } else { - /* Something is mapped, we can't use the paddles */ + // Something is mapped, we can't use the paddles paddles_mapped = SDL_TRUE; } } else { - /* Unknown format */ + // Unknown format return; } #ifdef DEBUG_XBOX_PROTOCOL @@ -627,12 +627,12 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic #endif if (paddles_mapped) { - /* Respect that the paddles are being used for other controls and don't pass them on to the app */ + // Respect that the paddles are being used for other controls and don't pass them on to the app data[paddle_index] = 0; } if (ctx->last_paddle_state != data[paddle_index]) { - Uint8 nButton = (Uint8)(SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON + ctx->has_share_button); /* Next available button */ + Uint8 nButton = (Uint8)(SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON + ctx->has_share_button); // Next available button SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED); @@ -647,7 +647,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D Sint16 axis; Uint64 timestamp = SDL_GetTicksNS(); - /* Enable paddles on the Xbox Elite controller when connected over USB */ + // Enable paddles on the Xbox Elite controller when connected over USB if (ctx->has_paddles && !ctx->has_unmapped_state && size == 46) { Uint8 packet[] = { 0x4d, 0x00, 0x00, 0x02, 0x07, 0x00 }; @@ -684,7 +684,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D SDL_SendJoystickHat(timestamp, joystick, 0, hat); if (ctx->vendor_id == USB_VENDOR_RAZER && ctx->product_id == USB_PRODUCT_RAZER_ATROX) { - /* The Razer Atrox has the right and left shoulder bits reversed */ + // The Razer Atrox has the right and left shoulder bits reversed SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED); } else { @@ -748,18 +748,18 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D SDL_bool paddles_mapped; if (size == 29) { - /* XBox One Elite Series 1 */ + // XBox One Elite Series 1 paddle_index = 28; button1_bit = 0x02; button2_bit = 0x08; button3_bit = 0x01; button4_bit = 0x04; - /* The mapped controller state is at offset 0, the raw state is at offset 14, compare them to see if the paddles are mapped */ + // The mapped controller state is at offset 0, the raw state is at offset 14, compare them to see if the paddles are mapped paddles_mapped = (SDL_memcmp(&data[0], &data[14], 2) != 0); } else if (size == 34) { - /* XBox One Elite Series 2 */ + // XBox One Elite Series 2 paddle_index = 14; button1_bit = 0x01; button2_bit = 0x02; @@ -768,7 +768,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D paddles_mapped = (data[15] != 0); } else if (size == 46) { - /* XBox One Elite Series 2 */ + // XBox One Elite Series 2 paddle_index = 18; button1_bit = 0x01; button2_bit = 0x02; @@ -776,7 +776,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D button4_bit = 0x08; paddles_mapped = (data[19] != 0); } else /* if (size == 47) */ { - /* XBox One Elite Series 2 */ + // XBox One Elite Series 2 paddle_index = 14; button1_bit = 0x01; button2_bit = 0x02; @@ -794,12 +794,12 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D #endif if (paddles_mapped) { - /* Respect that the paddles are being used for other controls and don't pass them on to the app */ + // Respect that the paddles are being used for other controls and don't pass them on to the app data[paddle_index] = 0; } if (ctx->last_paddle_state != data[paddle_index]) { - Uint8 nButton = (Uint8)(SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON + ctx->has_share_button); /* Next available button */ + Uint8 nButton = (Uint8)(SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON + ctx->has_share_button); // Next available button SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED); @@ -837,7 +837,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); - /* We don't have the unmapped state for this packet */ + // We don't have the unmapped state for this packet ctx->has_unmapped_state = SDL_FALSE; } @@ -926,7 +926,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo SDL_bool paddles_mapped; if (size == 55) { - /* Initial firmware for the Xbox Elite Series 2 controller */ + // Initial firmware for the Xbox Elite Series 2 controller paddle_index = 33; button1_bit = 0x01; button2_bit = 0x02; @@ -934,7 +934,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo button4_bit = 0x08; paddles_mapped = (data[35] != 0); } else if (size == 39) { - /* Updated firmware for the Xbox Elite Series 2 controller */ + // Updated firmware for the Xbox Elite Series 2 controller paddle_index = 17; button1_bit = 0x01; button2_bit = 0x02; @@ -942,7 +942,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo button4_bit = 0x08; paddles_mapped = (data[19] != 0); } else /* if (size == 20) */ { - /* Updated firmware for the Xbox Elite Series 2 controller (5.13+) */ + // Updated firmware for the Xbox Elite Series 2 controller (5.13+) paddle_index = 19; button1_bit = 0x01; button2_bit = 0x02; @@ -961,12 +961,12 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo #endif if (paddles_mapped) { - /* Respect that the paddles are being used for other controls and don't pass them on to the app */ + // Respect that the paddles are being used for other controls and don't pass them on to the app data[paddle_index] = 0; } if (ctx->last_paddle_state != data[paddle_index]) { - Uint8 nButton = SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON; /* Next available button */ + Uint8 nButton = SDL_GAMEPAD_BUTTON_XBOX_SHARE_BUTTON; // Next available button SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED); SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED); @@ -982,7 +982,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joysti Uint64 timestamp = SDL_GetTicksNS(); if (size == 16) { - /* Original Xbox One S, with separate report for guide button */ + // Original Xbox One S, with separate report for guide button HIDAPI_DriverXboxOneBluetooth_HandleButtons16(timestamp, joystick, ctx, data, size); } else if (size > 16) { HIDAPI_DriverXboxOneBluetooth_HandleButtons(timestamp, joystick, ctx, data, size); @@ -1116,7 +1116,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * switch (ctx->init_state) { case XBOX_ONE_INIT_STATE_ANNOUNCED: if (XBOX_ONE_DRIVER_ACTIVE) { - /* The driver is taking care of identification */ + // The driver is taking care of identification SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE); } else { SendIdentificationRequest(ctx); @@ -1125,7 +1125,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * break; case XBOX_ONE_INIT_STATE_IDENTIFYING: if (SDL_GetTicks() >= (ctx->send_time + CONTROLLER_IDENTIFY_TIMEOUT_MS)) { - /* We haven't heard anything, let's move on */ + // We haven't heard anything, let's move on #ifdef DEBUG_JOYSTICK SDL_Log("Identification request timed out after %llu ms\n", (SDL_GetTicks() - ctx->send_time)); #endif @@ -1134,7 +1134,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * break; case XBOX_ONE_INIT_STATE_STARTUP: if (XBOX_ONE_DRIVER_ACTIVE) { - /* The driver is taking care of startup */ + // The driver is taking care of startup SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE); } else { SendControllerStartup(ctx); @@ -1164,7 +1164,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * */ #define GIP_HEADER_MIN_LENGTH 3 -/* Internal commands */ +// Internal commands #define GIP_CMD_ACKNOWLEDGE 0x01 #define GIP_CMD_ANNOUNCE 0x02 #define GIP_CMD_STATUS 0x03 @@ -1179,12 +1179,12 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * #define GIP_CMD_SERIAL_NUMBER 0x1E #define GIP_CMD_AUDIO_SAMPLES 0x60 -/* External commands */ +// External commands #define GIP_CMD_RUMBLE 0x09 #define GIP_CMD_UNMAPPED_STATE 0x0C #define GIP_CMD_INPUT 0x20 -/* Header option flags */ +// Header option flags #define GIP_OPT_ACKNOWLEDGE 0x10 #define GIP_OPT_INTERNAL 0x20 #define GIP_OPT_CHUNK_START 0x40 @@ -1270,7 +1270,7 @@ static int HIDAPI_GIP_GetHeaderLength(struct gip_header *hdr) { int len = HIDAPI_GIP_GetActualHeaderLength(hdr); - /* Header length must be even */ + // Header length must be even return len + (len % 2); } @@ -1284,7 +1284,7 @@ static void HIDAPI_GIP_EncodeHeader(struct gip_header *hdr, Uint8 *buf) hdr_len += EncodeVariableInt(buf + hdr_len, hdr->packet_length); - /* Header length must be even */ + // Header length must be even if (HIDAPI_GIP_GetActualHeaderLength(hdr) % 2) { buf[hdr_len - 1] |= 0x80; buf[hdr_len++] = 0; @@ -1344,7 +1344,7 @@ static SDL_bool HIDAPI_GIP_SendPacket(SDL_DriverXboxOne_Context *ctx, struct gip static SDL_bool HIDAPI_GIP_AcknowledgePacket(SDL_DriverXboxOne_Context *ctx, struct gip_header *ack) { if (XBOX_ONE_DRIVER_ACTIVE) { - /* The driver is taking care of acks */ + // The driver is taking care of acks return SDL_TRUE; } else { struct gip_header hdr; @@ -1372,17 +1372,17 @@ static SDL_bool HIDAPI_GIP_AcknowledgePacket(SDL_DriverXboxOne_Context *ctx, str static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data, Uint32 size) { if ((hdr->options & 0x0F) != 0) { - /* This is a packet for a device plugged into the controller, skip it */ + // This is a packet for a device plugged into the controller, skip it return SDL_TRUE; } if (hdr->options & GIP_OPT_INTERNAL) { switch (hdr->command) { case GIP_CMD_ACKNOWLEDGE: - /* Ignore this packet */ + // Ignore this packet break; case GIP_CMD_ANNOUNCE: - /* Controller is connected and waiting for initialization */ + // Controller is connected and waiting for initialization /* The data bytes are: 0x02 0x20 NN 0x1c, where NN is the packet sequence then 6 bytes of wireless MAC address @@ -1400,7 +1400,7 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox SetInitState(ctx, XBOX_ONE_INIT_STATE_ANNOUNCED); break; case GIP_CMD_STATUS: - /* Controller status update */ + // Controller status update HIDAPI_DriverXboxOne_HandleStatusPacket(ctx, data, size); break; case GIP_CMD_IDENTIFY: @@ -1413,10 +1413,10 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox SetInitState(ctx, XBOX_ONE_INIT_STATE_STARTUP); break; case GIP_CMD_POWER: - /* Ignore this packet */ + // Ignore this packet break; case GIP_CMD_AUTHENTICATE: - /* Ignore this packet */ + // Ignore this packet break; case GIP_CMD_VIRTUAL_KEY: if (!joystick) { @@ -1448,7 +1448,7 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox if (ctx->init_state < XBOX_ONE_INIT_STATE_COMPLETE) { SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE); - /* Ignore the first input, it may be spurious */ + // Ignore the first input, it may be spurious #ifdef DEBUG_JOYSTICK SDL_Log("Controller ignoring spurious input\n"); #endif @@ -1624,7 +1624,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) HIDAPI_DriverXboxOne_UpdateRumble(ctx); if (size < 0) { - /* Read error, device is disconnected */ + // Read error, device is disconnected HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } return size >= 0; @@ -1667,6 +1667,6 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne = { HIDAPI_DriverXboxOne_FreeDevice, }; -#endif /* SDL_JOYSTICK_HIDAPI_XBOXONE */ +#endif // SDL_JOYSTICK_HIDAPI_XBOXONE -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index dbf59ddcb9..1def0181aa 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -160,7 +160,7 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) return SDL_FALSE; case USB_VENDOR_MADCATZ: if (product == USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK) { - /* This is not a Playstation compatible device */ + // This is not a Playstation compatible device return SDL_FALSE; } return SDL_TRUE; @@ -214,46 +214,46 @@ static SDL_GamepadType SDL_GetJoystickGameControllerProtocol(const char *name, U { 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 XB360W_IFACE_PROTOCOL = 129; /* Wireless */ + 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; SDL_GamepadType type = SDL_GAMEPAD_TYPE_STANDARD; - /* This code should match the checks in libusb/hid.c and HIDDeviceManager.java */ + // This code should match the checks in libusb/hid.c and HIDDeviceManager.java if (interface_class == LIBUSB_CLASS_VENDOR_SPEC && interface_subclass == XB360_IFACE_SUBCLASS && (interface_protocol == XB360_IFACE_PROTOCOL || interface_protocol == XB360W_IFACE_PROTOCOL)) { static const int SUPPORTED_VENDORS[] = { - 0x0079, /* GPD Win 2 */ - 0x044f, /* Thrustmaster */ - 0x045e, /* Microsoft */ - 0x046d, /* Logitech */ - 0x056e, /* Elecom */ - 0x06a3, /* Saitek */ - 0x0738, /* Mad Catz */ - 0x07ff, /* Mad Catz */ - 0x0e6f, /* PDP */ - 0x0f0d, /* Hori */ - 0x1038, /* SteelSeries */ - 0x11c9, /* Nacon */ - 0x12ab, /* Unknown */ - 0x1430, /* RedOctane */ - 0x146b, /* BigBen */ - 0x1532, /* Razer */ - 0x15e4, /* Numark */ - 0x162e, /* Joytech */ - 0x1689, /* Razer Onza */ - 0x1949, /* Lab126, Inc. */ - 0x1bad, /* Harmonix */ - 0x20d6, /* PowerA */ - 0x24c6, /* PowerA */ - 0x2c22, /* Qanba */ - 0x2dc8, /* 8BitDo */ - 0x9886, /* ASTRO Gaming */ + 0x0079, // GPD Win 2 + 0x044f, // Thrustmaster + 0x045e, // Microsoft + 0x046d, // Logitech + 0x056e, // Elecom + 0x06a3, // Saitek + 0x0738, // Mad Catz + 0x07ff, // Mad Catz + 0x0e6f, // PDP + 0x0f0d, // Hori + 0x1038, // SteelSeries + 0x11c9, // Nacon + 0x12ab, // Unknown + 0x1430, // RedOctane + 0x146b, // BigBen + 0x1532, // Razer + 0x15e4, // Numark + 0x162e, // Joytech + 0x1689, // Razer Onza + 0x1949, // Lab126, Inc. + 0x1bad, // Harmonix + 0x20d6, // PowerA + 0x24c6, // PowerA + 0x2c22, // Qanba + 0x2dc8, // 8BitDo + 0x9886, // ASTRO Gaming }; int i; @@ -271,20 +271,20 @@ static SDL_GamepadType SDL_GetJoystickGameControllerProtocol(const char *name, U interface_protocol == XBONE_IFACE_PROTOCOL) { static const int SUPPORTED_VENDORS[] = { - 0x03f0, /* HP */ - 0x044f, /* Thrustmaster */ - 0x045e, /* Microsoft */ - 0x0738, /* Mad Catz */ - 0x0b05, /* ASUS */ - 0x0e6f, /* PDP */ - 0x0f0d, /* Hori */ - 0x10f5, /* Turtle Beach */ - 0x1532, /* Razer */ - 0x20d6, /* PowerA */ - 0x24c6, /* PowerA */ - 0x2dc8, /* 8BitDo */ - 0x2e24, /* Hyperkin */ - 0x3537, /* GameSir */ + 0x03f0, // HP + 0x044f, // Thrustmaster + 0x045e, // Microsoft + 0x0738, // Mad Catz + 0x0b05, // ASUS + 0x0e6f, // PDP + 0x0f0d, // Hori + 0x10f5, // Turtle Beach + 0x1532, // Razer + 0x20d6, // PowerA + 0x24c6, // PowerA + 0x2dc8, // 8BitDo + 0x2e24, // Hyperkin + 0x3537, // GameSir }; int i; @@ -391,10 +391,10 @@ static SDL_HIDAPI_Device *HIDAPI_GetJoystickByInfo(const char *path, Uint16 vend static void HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) { if (!device->driver) { - return; /* Already cleaned up */ + return; // Already cleaned up } - /* Disconnect any joysticks */ + // Disconnect any joysticks while (device->num_joysticks && device->joysticks) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } @@ -417,7 +417,7 @@ static void HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) SDL_UnlockMutex(device->dev_lock); } -static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) SDL_NO_THREAD_SAFETY_ANALYSIS /* We unlock the joystick lock to be able to open the HID device on Android */ +static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) SDL_NO_THREAD_SAFETY_ANALYSIS // We unlock the joystick lock to be able to open the HID device on Android { *removed = SDL_FALSE; @@ -443,15 +443,15 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove if (!enabled) { HIDAPI_CleanupDeviceDriver(device); } - return; /* Already setup */ + return; // Already setup } if (HIDAPI_GetDeviceDriver(device)) { - /* We might have a device driver for this device, try opening it and see */ + // We might have a device driver for this device, try opening it and see if (device->num_children == 0) { SDL_hid_device *dev; - /* Wait a little bit for the device to initialize */ + // Wait a little bit for the device to initialize SDL_Delay(10); #ifdef SDL_PLATFORM_ANDROID @@ -480,7 +480,7 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove } SDL_free(path); - /* Make sure the device didn't get removed while opening the HID path */ + // Make sure the device didn't get removed while opening the HID path for (curr = SDL_HIDAPI_devices; curr && curr != device; curr = curr->next) { continue; } @@ -519,13 +519,13 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove device->driver = HIDAPI_GetDeviceDriver(device); - /* Initialize the device, which may cause a connected event */ + // Initialize the device, which may cause a connected event if (device->driver && !device->driver->InitDevice(device)) { HIDAPI_CleanupDeviceDriver(device); } if (!device->driver && device->dev) { - /* No driver claimed this device, go ahead and close it */ + // No driver claimed this device, go ahead and close it SDL_hid_close(device->dev); device->dev = NULL; } @@ -668,7 +668,7 @@ void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 vendor_id, Uint16 product_id) { - /* Don't set the device product ID directly, or we'll constantly re-enumerate this device */ + // Don't set the device product ID directly, or we'll constantly re-enumerate this device device->guid = SDL_CreateJoystickGUID(device->guid.data[0], vendor_id, product_id, device->version, device->manufacturer_string, device->product_string, 'h', 0); } @@ -828,7 +828,7 @@ void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joyst SDL_LockJoysticks(); if (!HIDAPI_JoystickInstanceIsUnique(device, joystickID)) { - /* Disconnecting a child always disconnects the parent */ + // Disconnecting a child always disconnects the parent device = device->parent; } @@ -854,7 +854,7 @@ void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joyst } } - /* Rescan the device list in case device state has changed */ + // Rescan the device list in case device state has changed SDL_HIDAPI_change_count = 0; SDL_UnlockJoysticks(); @@ -948,7 +948,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf device->is_bluetooth = (info->bus_type == SDL_HID_API_BUS_BLUETOOTH); device->dev_lock = SDL_CreateMutex(); - /* Need the device name before getting the driver to know whether to ignore this device */ + // Need the device name before getting the driver to know whether to ignore this device { char *serial_number = HIDAPI_ConvertString(info->serial_number); @@ -991,7 +991,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } } - /* Add it to the list */ + // Add it to the list if (last) { last->next = device; } else { @@ -1032,7 +1032,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) HIDAPI_CleanupDeviceDriver(device); - /* Make sure the rumble thread is done with this device */ + // Make sure the rumble thread is done with this device while (SDL_AtomicGet(&device->rumble_pending) > 0) { SDL_Delay(10); } @@ -1070,11 +1070,11 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void) Uint16 vendor, product; if (!device->driver) { - /* Unsupported device */ + // Unsupported device continue; } if (device->parent) { - /* This device is already part of a combined device */ + // This device is already part of a combined device continue; } @@ -1139,7 +1139,7 @@ static void HIDAPI_UpdateDeviceList(void) SDL_HIDAPI_hints_changed = SDL_FALSE; } - /* Prepare the existing device list */ + // Prepare the existing device list for (device = SDL_HIDAPI_devices; device; device = device->next) { if (device->children) { continue; @@ -1147,7 +1147,7 @@ static void HIDAPI_UpdateDeviceList(void) device->seen = SDL_FALSE; } - /* Enumerate the devices */ + // Enumerate the devices if (SDL_HIDAPI_numdrivers > 0) { devs = SDL_hid_enumerate(0, 0); if (devs) { @@ -1156,7 +1156,7 @@ static void HIDAPI_UpdateDeviceList(void) if (device) { device->seen = SDL_TRUE; - /* Check to see if the serial number is available now */ + // Check to see if the serial number is available now if(HIDAPI_SerialIsEmpty(device)) { HIDAPI_SetDeviceSerialW(device, info->serial_number); } @@ -1168,7 +1168,7 @@ static void HIDAPI_UpdateDeviceList(void) } } - /* Remove any devices that weren't seen or have been disconnected due to read errors */ + // Remove any devices that weren't seen or have been disconnected due to read errors check_removed: device = SDL_HIDAPI_devices; while (device) { @@ -1177,7 +1177,7 @@ check_removed: if (!device->seen || ((device->driver || device->children) && device->num_joysticks == 0 && !device->dev)) { if (device->parent) { - /* When a child device goes away, so does the parent */ + // When a child device goes away, so does the parent int i; device = device->parent; for (i = 0; i < device->num_children; ++i) { @@ -1185,22 +1185,22 @@ check_removed: } HIDAPI_DelDevice(device); - /* Update the device list again to pick up any children left */ + // Update the device list again to pick up any children left SDL_HIDAPI_change_count = 0; - /* We deleted more than one device here, restart the loop */ + // We deleted more than one device here, restart the loop goto check_removed; } else { HIDAPI_DelDevice(device); - /* Update the device list again in case this device comes back */ + // Update the device list again in case this device comes back SDL_HIDAPI_change_count = 0; } } device = next; } - /* See if we can create any combined Joy-Con controllers */ + // See if we can create any combined Joy-Con controllers while (HIDAPI_CreateCombinedJoyCons()) { } @@ -1214,18 +1214,18 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, } if (vendor_id == USB_VENDOR_MICROSOFT) { - /* If we're looking for the wireless XBox 360 controller, also look for the dongle */ + // If we're looking for the wireless XBox 360 controller, also look for the dongle if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER && device->product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER) { return SDL_TRUE; } - /* If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller */ + // If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller if (product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER && device->type == SDL_GAMEPAD_TYPE_XBOXONE) { return SDL_TRUE; } - /* If we're looking for an XInput controller, match it against any other Xbox controller */ + // If we're looking for an XInput controller, match it against any other Xbox controller if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER) { if (device->type == SDL_GAMEPAD_TYPE_XBOX360 || device->type == SDL_GAMEPAD_TYPE_XBOXONE) { return SDL_TRUE; @@ -1234,7 +1234,7 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, } if (vendor_id == USB_VENDOR_NVIDIA) { - /* If we're looking for the NVIDIA SHIELD controller Xbox interface, match it against any NVIDIA SHIELD controller */ + // If we're looking for the NVIDIA SHIELD controller Xbox interface, match it against any NVIDIA SHIELD controller if (product_id == 0xb400 && SDL_IsJoystickNVIDIASHIELDController(vendor_id, product_id)) { return SDL_TRUE; @@ -1248,7 +1248,7 @@ SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type) SDL_HIDAPI_Device *device; SDL_bool result = SDL_FALSE; - /* Make sure we're initialized, as this could be called from other drivers during startup */ + // Make sure we're initialized, as this could be called from other drivers during startup if (HIDAPI_JoystickInit() < 0) { return SDL_FALSE; } @@ -1279,7 +1279,7 @@ SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 vers SDL_bool supported = SDL_FALSE; SDL_bool result = SDL_FALSE; - /* Make sure we're initialized, as this could be called from other drivers during startup */ + // Make sure we're initialized, as this could be called from other drivers during startup if (HIDAPI_JoystickInit() < 0) { return SDL_FALSE; } @@ -1296,7 +1296,7 @@ SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 vers (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box") || SDL_strstr(name, "XBOX"))) { supported = SDL_TRUE; } -#endif /* SDL_JOYSTICK_HIDAPI_XBOX360 || SDL_JOYSTICK_HIDAPI_XBOXONE */ +#endif // SDL_JOYSTICK_HIDAPI_XBOX360 || SDL_JOYSTICK_HIDAPI_XBOXONE if (supported) { if (SDL_TryLockSpinlock(&SDL_HIDAPI_spinlock)) { HIDAPI_UpdateDeviceList(); @@ -1376,9 +1376,9 @@ void HIDAPI_UpdateDevices(void) SDL_AssertJoysticksLocked(); - /* Update the devices, which may change connected joysticks and send events */ + // Update the devices, which may change connected joysticks and send events - /* Prepare the existing device list */ + // Prepare the existing device list if (SDL_TryLockSpinlock(&SDL_HIDAPI_spinlock)) { for (device = SDL_HIDAPI_devices; device; device = device->next) { if (device->parent) { @@ -1404,7 +1404,7 @@ static const char *HIDAPI_JoystickGetDeviceName(int device_index) device = HIDAPI_GetDeviceByIndex(device_index, NULL); if (device) { - /* FIXME: The device could be freed after this name is returned... */ + // FIXME: The device could be freed after this name is returned... name = device->name; } @@ -1418,7 +1418,7 @@ static const char *HIDAPI_JoystickGetDevicePath(int device_index) device = HIDAPI_GetDeviceByIndex(device_index, NULL); if (device) { - /* FIXME: The device could be freed after this path is returned... */ + // FIXME: The device could be freed after this path is returned... path = device->path; } @@ -1486,7 +1486,7 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); if (!device || !device->driver) { - /* This should never happen - validated before being called */ + // This should never happen - validated before being called return SDL_SetError("Couldn't find HIDAPI device at index %d\n", device_index); } @@ -1496,20 +1496,20 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) } hwdata->device = device; - /* Process any pending reports before opening the device */ + // Process any pending reports before opening the device SDL_LockMutex(device->dev_lock); device->updating = SDL_TRUE; device->driver->UpdateDevice(device); device->updating = SDL_FALSE; SDL_UnlockMutex(device->dev_lock); - /* UpdateDevice() may have called HIDAPI_JoystickDisconnected() if the device went away */ + // UpdateDevice() may have called HIDAPI_JoystickDisconnected() if the device went away if (device->num_joysticks == 0) { SDL_free(hwdata); return SDL_SetError("HIDAPI device disconnected while opening"); } - /* Set the default connection state, can be overridden below */ + // Set the default connection state, can be overridden below if (device->is_bluetooth) { joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS; } else { @@ -1517,7 +1517,7 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (!device->driver->OpenJoystick(device, joystick)) { - /* The open failed, mark this device as disconnected and update devices */ + // The open failed, mark this device as disconnected and update devices HIDAPI_JoystickDisconnected(device, joystickID); SDL_free(hwdata); return -1; @@ -1618,10 +1618,10 @@ static int HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool ena static void HIDAPI_JoystickUpdate(SDL_Joystick *joystick) { - /* This is handled in SDL_HIDAPI_UpdateDevices() */ + // This is handled in SDL_HIDAPI_UpdateDevices() } -static void HIDAPI_JoystickClose(SDL_Joystick *joystick) SDL_NO_THREAD_SAFETY_ANALYSIS /* We unlock the device lock so rumble can complete */ +static void HIDAPI_JoystickClose(SDL_Joystick *joystick) SDL_NO_THREAD_SAFETY_ANALYSIS // We unlock the device lock so rumble can complete { SDL_AssertJoysticksLocked(); @@ -1629,9 +1629,9 @@ static void HIDAPI_JoystickClose(SDL_Joystick *joystick) SDL_NO_THREAD_SAFETY_AN SDL_HIDAPI_Device *device = joystick->hwdata->device; int i; - /* Wait up to 30 ms for pending rumble to complete */ + // Wait up to 30 ms for pending rumble to complete if (device->updating) { - /* Unlock the device so rumble can complete */ + // Unlock the device so rumble can complete SDL_UnlockMutex(device->dev_lock); } for (i = 0; i < 3; ++i) { @@ -1640,7 +1640,7 @@ static void HIDAPI_JoystickClose(SDL_Joystick *joystick) SDL_NO_THREAD_SAFETY_AN } } if (device->updating) { - /* Relock the device */ + // Relock the device SDL_LockMutex(device->dev_lock); } @@ -1664,7 +1664,7 @@ static void HIDAPI_JoystickQuit(void) while (SDL_HIDAPI_devices) { SDL_HIDAPI_Device *device = SDL_HIDAPI_devices; if (device->parent) { - /* When a child device goes away, so does the parent */ + // When a child device goes away, so does the parent device = device->parent; for (i = 0; i < device->num_children; ++i) { HIDAPI_DelDevice(device->children[i]); @@ -1675,7 +1675,7 @@ static void HIDAPI_JoystickQuit(void) } } - /* Make sure the drivers cleaned up properly */ + // Make sure the drivers cleaned up properly SDL_assert(SDL_HIDAPI_numjoysticks == 0); for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) { @@ -1723,4 +1723,4 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = { HIDAPI_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index 42f160d58b..d5c243ea0a 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -25,14 +25,14 @@ #include "../usb_ids.h" -/* This is the full set of HIDAPI drivers available */ +// This is the full set of HIDAPI drivers available #define SDL_JOYSTICK_HIDAPI_GAMECUBE #define SDL_JOYSTICK_HIDAPI_LUNA #define SDL_JOYSTICK_HIDAPI_PS3 #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_STEAMDECK #define SDL_JOYSTICK_HIDAPI_SWITCH #define SDL_JOYSTICK_HIDAPI_WII @@ -40,28 +40,28 @@ #define SDL_JOYSTICK_HIDAPI_XBOXONE #define SDL_JOYSTICK_HIDAPI_SHIELD -/* Joystick capability definitions */ +// Joystick capability definitions #define SDL_JOYSTICK_CAP_MONO_LED 0x00000001 #define SDL_JOYSTICK_CAP_RGB_LED 0x00000002 #define SDL_JOYSTICK_CAP_PLAYER_LED 0x00000004 #define SDL_JOYSTICK_CAP_RUMBLE 0x00000010 #define SDL_JOYSTICK_CAP_TRIGGER_RUMBLE 0x00000020 -/* Whether HIDAPI is enabled by default */ +// Whether HIDAPI is enabled by default #if defined(SDL_PLATFORM_ANDROID) || \ defined(SDL_PLATFORM_IOS) || \ defined(SDL_PLATFORM_TVOS) || \ defined(SDL_PLATFORM_VISIONOS) -/* On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers, so we'll leave it off by default. */ +// On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers, so we'll leave it off by default. #define SDL_HIDAPI_DEFAULT SDL_FALSE #else #define SDL_HIDAPI_DEFAULT SDL_TRUE #endif -/* The maximum size of a USB packet for HID devices */ +// The maximum size of a USB packet for HID devices #define USB_PACKET_LENGTH 64 -/* Forward declaration */ +// Forward declaration struct SDL_HIDAPI_DeviceDriver; typedef struct SDL_HIDAPI_Device @@ -75,12 +75,12 @@ typedef struct SDL_HIDAPI_Device Uint16 version; char *serial; SDL_GUID 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; - Uint16 usage_page; /* Available on Windows and macOS */ - Uint16 usage; /* Available on Windows and macOS */ + Uint16 usage_page; // Available on Windows and macOS + Uint16 usage; // Available on Windows and macOS SDL_bool is_bluetooth; SDL_JoystickType joystick_type; SDL_GamepadType type; @@ -93,10 +93,10 @@ typedef struct SDL_HIDAPI_Device int num_joysticks; SDL_JoystickID *joysticks; - /* Used during scanning for device changes */ + // Used during scanning for device changes SDL_bool seen; - /* Used to flag that the device is being updated */ + // Used to flag that the device is being updated SDL_bool updating; struct SDL_HIDAPI_Device *parent; @@ -130,7 +130,7 @@ typedef struct SDL_HIDAPI_DeviceDriver } SDL_HIDAPI_DeviceDriver; -/* HIDAPI device support */ +// HIDAPI device support extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons; @@ -151,16 +151,16 @@ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne; -/* Return true if a HID device is present and supported as a joystick of the given type */ +// Return true if a HID device is present and supported as a joystick of the given type extern SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type); -/* Return true if a HID device is present and supported as a joystick */ +// Return true if a HID device is present and supported as a joystick extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); -/* Return the type of a joystick if it's present and supported */ +// Return the type of a joystick if it's present and supported extern SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_GUID guid); -/* Return the type of a game controller if it's present and supported */ +// Return the type of a game controller if it's present and supported extern SDL_GamepadType HIDAPI_GetGamepadTypeFromGUID(SDL_GUID guid); extern void HIDAPI_UpdateDevices(void); @@ -179,4 +179,4 @@ extern SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 produc extern float HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max); -#endif /* SDL_JOYSTICK_HIDAPI_H */ +#endif // SDL_JOYSTICK_HIDAPI_H diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index cf45d47321..c81ff250cf 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -26,15 +26,15 @@ #error SDL now requires a Linux 2.4+ kernel with /dev/input/event support. #endif -/* This is the Linux implementation of the SDL joystick API */ +// 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 -#include /* strerror */ +#include // strerror #endif #include #include @@ -50,7 +50,7 @@ #include "SDL_sysjoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" -/* This isn't defined in older Linux kernel headers */ +// This isn't defined in older Linux kernel headers #ifndef MSC_TIMESTAMP #define MSC_TIMESTAMP 0x05 #endif @@ -147,29 +147,29 @@ static SDL_bool IsJoystickJSNode(const char *node); static void MaybeAddDevice(const char *path); static void MaybeRemoveDevice(const char *path); -/* A linked list of available joysticks */ +// A linked list of available joysticks 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_GUID guid; dev_t devnum; int steam_virtual_gamepad_slot; struct joystick_hwdata *hwdata; struct SDL_joylist_item *next; - /* Steam Controller support */ + // Steam Controller support SDL_bool m_bSteamController; SDL_bool checked_mapping; SDL_GamepadMapping *mapping; } SDL_joylist_item; -/* A linked list of available gamepad sensors */ +// A linked list of available gamepad sensors typedef struct SDL_sensorlist_item { - char *path; /* "/dev/input/event2" or whatever */ + char *path; // "/dev/input/event2" or whatever dev_t devnum; struct joystick_hwdata *hwdata; struct SDL_sensorlist_item *next; @@ -188,13 +188,13 @@ static time_t last_input_dir_mtime; 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 */ + // This is a Microsoft Xbox One Elite Series 2 controller unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; - /* The first version of the firmware duplicated all the inputs */ + // The first version of the firmware duplicated all the inputs if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) && test_bit(0x2c0, keybit)) { - /* Change the version to 0x0902, so we can map it differently */ + // Change the version to 0x0902, so we can map it differently inpid->version = 0x0902; } } @@ -212,12 +212,12 @@ static SDL_bool IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, { if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_S && version == 0 && SDL_strcmp(name, "Xbox One S Controller") == 0) { - /* This is the virtual device created by the xow driver */ + // This is the virtual device created by the xow driver return SDL_TRUE; } return SDL_FALSE; } -#endif /* SDL_JOYSTICK_HIDAPI */ +#endif // SDL_JOYSTICK_HIDAPI static SDL_bool GetSteamVirtualGamepadSlot(int fd, int *slot) { @@ -285,7 +285,7 @@ static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *ven SDL_zero(inpid); #ifdef SDL_USE_LIBUDEV - /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + // Opening input devices can generate synchronous device I/O, so avoid it if we can if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && !(class & SDL_UDEV_DEVICE_JOYSTICK)) { return 0; @@ -300,12 +300,12 @@ static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *ven } if (ioctl(*fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) { - /* When udev enumeration or classification, we only got joysticks here, so no need to test */ + // When udev enumeration or classification, we only got joysticks here, so no need to test if (enumeration_method != ENUMERATION_LIBUDEV && !class && !GuessIsJoystick(*fd)) { return 0; } - /* Could have vendor and product already from udev, but should agree with evdev */ + // Could have vendor and product already from udev, but should agree with evdev if (ioctl(*fd, EVIOCGID, &inpid) < 0) { return 0; } @@ -351,7 +351,7 @@ static int IsSensor(const char *path, int *fd) SDL_zero(inpid); #ifdef SDL_USE_LIBUDEV - /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + // Opening input devices can generate synchronous device I/O, so avoid it if we can if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && !(class & SDL_UDEV_DEVICE_ACCELEROMETER)) { return 0; @@ -374,8 +374,8 @@ static int IsSensor(const char *path, int *fd) } if (inpid.vendor == USB_VENDOR_NINTENDO && inpid.product == USB_PRODUCT_NINTENDO_WII_REMOTE) { - /* Wii extension controls */ - /* These may create 3 sensor devices but we only support reading from 1: ignore them */ + // Wii extension controls + // These may create 3 sensor devices but we only support reading from 1: ignore them return 0; } @@ -404,7 +404,7 @@ static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_clas } } - /* Wait a bit for the hidraw udev node to initialize */ + // Wait a bit for the hidraw udev node to initialize SDL_Delay(10); MaybeAddDevice(devpath); @@ -418,7 +418,7 @@ static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_clas break; } } -#endif /* SDL_USE_LIBUDEV */ +#endif // SDL_USE_LIBUDEV static void FreeJoylistItem(SDL_joylist_item *item) { @@ -460,15 +460,15 @@ static void MaybeAddDevice(const char *path) SDL_LockJoysticks(); - /* Check to make sure it's not already in list. */ + // Check to make sure it's not already in list. for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { - goto done; /* already have this one */ + goto done; // already have this one } } for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { if (sb.st_rdev == item_sensor->devnum) { - goto done; /* already have this one */ + goto done; // already have this one } } @@ -510,7 +510,7 @@ static void MaybeAddDevice(const char *path) SDL_joylist_tail = item; } - /* Need to increment the joystick count before we post the event */ + // Need to increment the joystick count before we post the event ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); @@ -562,7 +562,7 @@ static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) SDL_joylist_tail = prev; } - /* Need to decrement the joystick count before we post the event */ + // Need to decrement the joystick count before we post the event --numjoysticks; SDL_PrivateJoystickRemoved(item->device_instance); @@ -602,7 +602,7 @@ static void MaybeRemoveDevice(const char *path) SDL_LockJoysticks(); for (item = SDL_joylist; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (SDL_strcmp(path, item->path) == 0) { RemoveJoylistItem(item, prev); goto done; @@ -610,7 +610,7 @@ static void MaybeRemoveDevice(const char *path) prev = item; } for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { - /* found it, remove it. */ + // found it, remove it. if (SDL_strcmp(path, item_sensor->path) == 0) { RemoveSensorlistItem(item_sensor, prev_sensor); goto done; @@ -691,7 +691,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid SDL_joylist_tail = item; } - /* Need to increment the joystick count before we post the event */ + // Need to increment the joystick count before we post the event ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); @@ -707,7 +707,7 @@ static void SteamControllerDisconnectedCallback(SDL_JoystickID device_instance) SDL_LockJoysticks(); for (item = SDL_joylist; item; item = item->next) { - /* found it, remove it. */ + // found it, remove it. if (item->device_instance == device_instance) { RemoveJoylistItem(item, prev); break; @@ -825,7 +825,7 @@ static void LINUX_InotifyJoystickDetect(void) } } } -#endif /* HAVE_INOTIFY */ +#endif // HAVE_INOTIFY static int get_event_joystick_index(int event) { @@ -840,9 +840,9 @@ static int get_event_joystick_index(int event) if (SDL_strncmp(entries[i]->d_name, "js", 2) == 0) { joystick_index = SDL_atoi(entries[i]->d_name + 2); } - free(entries[i]); /* This should NOT be SDL_free() */ + free(entries[i]); // This should NOT be SDL_free() } - free(entries); /* This should NOT be SDL_free() */ + free(entries); // This should NOT be SDL_free() return joystick_index; } @@ -863,15 +863,15 @@ static int SDLCALL sort_entries(const void *_a, const void *_b) int offset; if (SDL_classic_joysticks) { - offset = 2; /* strlen("js") */ + offset = 2; // strlen("js") numA = SDL_atoi((*a)->d_name + offset); numB = SDL_atoi((*b)->d_name + offset); } else { - offset = 5; /* strlen("event") */ + offset = 5; // strlen("event") numA = SDL_atoi((*a)->d_name + offset); numB = SDL_atoi((*b)->d_name + offset); - /* See if we can get the joystick ordering */ + // See if we can get the joystick ordering { int jsA = get_event_joystick_index(numA); int jsB = get_event_joystick_index(numB); @@ -920,12 +920,12 @@ static void LINUX_ScanSteamVirtualGamepads(void) (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); #ifdef SDL_USE_LIBUDEV - /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + // Opening input devices can generate synchronous device I/O, so avoid it if we can class = 0; SDL_zero(inpid); if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && (inpid.vendor != USB_VENDOR_VALVE || inpid.product != USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) { - free(entries[i]); /* This should NOT be SDL_free() */ + free(entries[i]); // This should NOT be SDL_free() continue; } #endif @@ -951,9 +951,9 @@ static void LINUX_ScanSteamVirtualGamepads(void) } close(fd); } - free(entries[i]); /* This should NOT be SDL_free() */ + free(entries[i]); // This should NOT be SDL_free() } - free(entries); /* This should NOT be SDL_free() */ + free(entries); // This should NOT be SDL_free() if (num_virtual_gamepads > 1) { SDL_qsort(virtual_gamepads, num_virtual_gamepads, sizeof(*virtual_gamepads), sort_virtual_gamepads); @@ -979,22 +979,22 @@ static void LINUX_ScanInputDevices(void) (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); MaybeAddDevice(path); - free(entries[i]); /* This should NOT be SDL_free() */ + free(entries[i]); // This should NOT be SDL_free() } - free(entries); /* This should NOT be SDL_free() */ + free(entries); // This should NOT be SDL_free() } 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 Uint64 now = SDL_GetTicks(); if (!last_joy_detect_time || now >= (last_joy_detect_time + SDL_JOY_DETECT_INTERVAL_MS)) { struct stat sb; - /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + // Opening input devices can generate synchronous device I/O, so avoid it if we can if (stat("/dev/input", &sb) == 0 && sb.st_mtime != last_input_dir_mtime) { - /* Look for Steam virtual gamepads first, and sort by Steam controller slot */ + // Look for Steam virtual gamepads first, and sort by Steam controller slot LINUX_ScanSteamVirtualGamepads(); LINUX_ScanInputDevices(); @@ -1029,7 +1029,7 @@ static void LINUX_JoystickDetect(void) static SDL_bool LINUX_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -1044,7 +1044,7 @@ static int LINUX_JoystickInit(void) enumeration_method = ENUMERATION_UNSET; - /* First see if the user specified one or more joysticks to use */ + // First see if the user specified one or more joysticks to use if (devices) { char *envcopy, *envpath, *delim; envcopy = SDL_strdup(devices); @@ -1063,11 +1063,11 @@ static int LINUX_JoystickInit(void) SDL_InitSteamControllers(SteamControllerConnectedCallback, SteamControllerDisconnectedCallback); - /* Force immediate joystick detection if using fallback */ + // Force immediate joystick detection if using fallback last_joy_detect_time = 0; last_input_dir_mtime = 0; - /* Manually scan first, since we sort by device number and udev doesn't */ + // Manually scan first, since we sort by device number and udev doesn't LINUX_JoystickDetect(); #ifdef SDL_USE_LIBUDEV @@ -1090,13 +1090,13 @@ static int LINUX_JoystickInit(void) if (enumeration_method == ENUMERATION_LIBUDEV) { if (udev_status == 0) { - /* Set up the udev callback */ + // Set up the udev callback if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { SDL_UDEV_Quit(); return SDL_SetError("Could not set up joystick <-> udev callback"); } - /* Force a scan to build the initial device list */ + // Force a scan to build the initial device list SDL_UDEV_Scan(); } else { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, @@ -1129,7 +1129,7 @@ static int LINUX_JoystickInit(void) strerror(errno)); } } -#endif /* HAVE_INOTIFY */ +#endif // HAVE_INOTIFY } return 0; @@ -1191,7 +1191,7 @@ static SDL_GUID LINUX_JoystickGetDeviceGUID(int device_index) return GetJoystickByDevIndex(device_index)->guid; } -/* Function to perform the mapping from device index to the instance id for this index */ +// Function to perform the mapping from device index to the instance id for this index static SDL_JoystickID LINUX_JoystickGetDeviceInstanceID(int device_index) { return GetJoystickByDevIndex(device_index)->device_instance; @@ -1234,27 +1234,27 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct * joystick interface makes no distinction between digital hat axes and any * other continuous analog axis, so we have to guess. */ - /* If both axes are missing, they're not anything. */ + // If both axes are missing, they're not anything. if (!absinfo_x && !absinfo_y) { return SDL_FALSE; } - /* If the hint says so, treat all hats as digital. */ + // If the hint says so, treat all hats as digital. if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS, SDL_FALSE)) { return SDL_TRUE; } - /* If both axes have ranges constrained between -1 and 1, they're definitely digital. */ + // If both axes have ranges constrained between -1 and 1, they're definitely digital. if ((!absinfo_x || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (!absinfo_y || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { return SDL_TRUE; } - /* If both axes lack fuzz, flat, and resolution values, they're probably digital. */ + // If both axes lack fuzz, flat, and resolution values, they're probably digital. if ((!absinfo_x || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (!absinfo_y || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { return SDL_TRUE; } - /* Otherwise, treat them as analog. */ + // Otherwise, treat them as analog. return SDL_FALSE; } @@ -1271,12 +1271,12 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_AssertJoysticksLocked(); - /* See if this device uses the new unified event API */ + // See if this device uses the new unified event API if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) && (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) && (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0)) { - /* Get the number of buttons, axes, and other thingamajigs */ + // Get the number of buttons, axes, and other thingamajigs for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) { if (test_bit(i, keybit)) { #ifdef DEBUG_INPUT_EVENTS @@ -1324,7 +1324,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) absinfo_y.value, absinfo_y.minimum, absinfo_y.maximum, absinfo_y.fuzz, absinfo_y.flat, absinfo_y.resolution); } -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS joystick->hwdata->hats_indices[hat_index] = joystick->nhats; joystick->hwdata->has_hat[hat_index] = SDL_TRUE; correct->use_deadzones = use_hat_deadzones; @@ -1336,7 +1336,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) } } for (i = 0; i < ABS_MAX; ++i) { - /* Skip digital hats */ + // Skip digital hats if (i >= ABS_HAT0X && i <= ABS_HAT3Y && joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) { continue; } @@ -1352,7 +1352,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Values = { val:%d, min:%d, max:%d, fuzz:%d, flat:%d, res:%d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat, absinfo.resolution); -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS joystick->hwdata->abs_map[i] = joystick->naxes; joystick->hwdata->has_abs[i] = SDL_TRUE; @@ -1449,7 +1449,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) } } - /* Sensors are only available through the new unified event API */ + // Sensors are only available through the new unified event API if (fd_sensor >= 0 && (ioctl(fd_sensor, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0)) { if (test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) && test_bit(ABS_Z, absbit)) { joystick->hwdata->has_accelerometer = SDL_TRUE; @@ -1457,7 +1457,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) struct input_absinfo absinfo; if (ioctl(fd_sensor, EVIOCGABS(ABS_X + i), &absinfo) < 0) { joystick->hwdata->has_accelerometer = SDL_FALSE; - break; /* do not report an accelerometer if we can't read all axes */ + break; // do not report an accelerometer if we can't read all axes } joystick->hwdata->accelerometer_scale[i] = absinfo.resolution; #ifdef DEBUG_INPUT_EVENTS @@ -1465,7 +1465,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Values = { val:%d, min:%d, max:%d, fuzz:%d, flat:%d, res:%d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat, absinfo.resolution); -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS } } @@ -1475,7 +1475,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) struct input_absinfo absinfo; if (ioctl(fd_sensor, EVIOCGABS(ABS_RX + i), &absinfo) < 0) { joystick->hwdata->has_gyro = SDL_FALSE; - break; /* do not report a gyro if we can't read all axes */ + break; // do not report a gyro if we can't read all axes } joystick->hwdata->gyro_scale[i] = absinfo.resolution; #ifdef DEBUG_INPUT_EVENTS @@ -1483,12 +1483,12 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Values = { val:%d, min:%d, max:%d, fuzz:%d, flat:%d, res:%d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat, absinfo.resolution); -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS } } } - /* Allocate data to keep track of these thingamajigs */ + // Allocate data to keep track of these thingamajigs if (joystick->nballs > 0) { if (allocate_balldata(joystick) < 0) { joystick->nballs = 0; @@ -1535,16 +1535,16 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item, &joystick->nhats); } else { int fd = -1, fd_sensor = -1; - /* Try read-write first, so we can do rumble */ + // Try read-write first, so we can do rumble fd = open(item->path, O_RDWR | O_CLOEXEC, 0); if (fd < 0) { - /* Try read-only again, at least we'll get events in this case */ + // Try read-only again, at least we'll get events in this case fd = open(item->path, O_RDONLY | O_CLOEXEC, 0); } if (fd < 0) { return SDL_SetError("Unable to open %s", item->path); } - /* If opening sensor fail, continue with buttons and axes only */ + // If opening sensor fail, continue with buttons and axes only if (item_sensor) { fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0); } @@ -1560,13 +1560,13 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item, return -1; } - /* Set the joystick to non-blocking read mode */ + // Set the joystick to non-blocking read mode fcntl(fd, F_SETFL, O_NONBLOCK); if (fd_sensor >= 0) { fcntl(fd_sensor, F_SETFL, O_NONBLOCK); } - /* Get the number of buttons and axes on the joystick */ + // Get the number of buttons and axes on the joystick ConfigJoystick(joystick, fd, fd_sensor); } return 0; @@ -1595,13 +1595,13 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) close(fd_item); #ifdef DEBUG_INPUT_EVENTS SDL_Log("Joystick UNIQ: %s\n", uniq_item); -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { char uniq_sensor[128]; int fd_sensor = -1; if (item_sensor->hwdata) { - /* already associated with another joystick */ + // already associated with another joystick continue; } @@ -1617,7 +1617,7 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) close(fd_sensor); #ifdef DEBUG_INPUT_EVENTS SDL_Log("Sensor UNIQ: %s\n", uniq_sensor); -#endif /* DEBUG_INPUT_EVENTS */ +#endif // DEBUG_INPUT_EVENTS if (SDL_strcmp(uniq_item, uniq_sensor) == 0) { return item_sensor; @@ -1653,7 +1653,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) if (PrepareJoystickHwdata(joystick, item, item_sensor) == -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); @@ -1663,7 +1663,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) item_sensor->hwdata = joystick->hwdata; } - /* mark joystick as fresh and ready */ + // mark joystick as fresh and ready joystick->hwdata->fresh = SDL_TRUE; if (joystick->hwdata->has_gyro) { @@ -1673,7 +1673,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f); } if (joystick->hwdata->fd_sensor >= 0) { - /* Don't keep fd_sensor opened while sensor is disabled */ + // Don't keep fd_sensor opened while sensor is disabled close(joystick->hwdata->fd_sensor); joystick->hwdata->fd_sensor = -1; } @@ -1698,7 +1698,7 @@ static int LINUX_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rum effect->u.rumble.strong_magnitude = low_frequency_rumble; effect->u.rumble.weak_magnitude = high_frequency_rumble; } else if (joystick->hwdata->ff_sine) { - /* Scale and average the two rumble strengths */ + // Scale and average the two rumble strengths Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); struct ff_effect *effect = &joystick->hwdata->effect; @@ -1711,7 +1711,7 @@ static int LINUX_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rum } if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) { - /* The kernel may have lost this effect, try to allocate a new one */ + // The kernel may have lost this effect, try to allocate a new one joystick->hwdata->effect.id = -1; if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) { return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno)); @@ -1851,7 +1851,7 @@ static int AxisCorrect(SDL_Joystick *joystick, int which, int value) } } - /* Clamp and return */ + // Clamp and return if (value < SDL_JOYSTICK_AXIS_MIN) { return SDL_JOYSTICK_AXIS_MIN; } @@ -1869,9 +1869,9 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - /* Poll all axis */ + // Poll all axis for (i = ABS_X; i < ABS_MAX; i++) { - /* We don't need to test for digital hats here, they won't have has_abs[] set */ + // We don't need to test for digital hats here, they won't have has_abs[] set if (joystick->hwdata->has_abs[i]) { if (ioctl(joystick->hwdata->fd, EVIOCGABS(i), &absinfo) >= 0) { absinfo.value = AxisCorrect(joystick, i, absinfo.value); @@ -1887,12 +1887,12 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick) } } - /* Poll all digital hats */ + // Poll all digital hats for (i = ABS_HAT0X; i <= ABS_HAT3Y; i++) { const int baseaxis = i - ABS_HAT0X; const int hatidx = baseaxis / 2; SDL_assert(hatidx < SDL_arraysize(joystick->hwdata->has_hat)); - /* We don't need to test for analog axes here, they won't have has_hat[] set */ + // We don't need to test for analog axes here, they won't have has_hat[] set if (joystick->hwdata->has_hat[hatidx]) { if (ioctl(joystick->hwdata->fd, EVIOCGABS(i), &absinfo) >= 0) { const int hataxis = baseaxis % 2; @@ -1901,7 +1901,7 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick) } } - /* Poll all buttons */ + // Poll all buttons SDL_zeroa(keyinfo); if (ioctl(joystick->hwdata->fd, EVIOCGKEY(sizeof(keyinfo)), keyinfo) >= 0) { for (i = 0; i < KEY_MAX; i++) { @@ -1917,7 +1917,7 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick) } } - /* Joyballs are relative input, so there's no poll state. Events only! */ + // Joyballs are relative input, so there's no poll state. Events only! } static void PollAllSensors(Uint64 timestamp, SDL_Joystick *joystick) @@ -2048,7 +2048,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) case SYN_REPORT: if (joystick->hwdata->recovering_from_dropped) { joystick->hwdata->recovering_from_dropped = SDL_FALSE; - PollAllValues(SDL_GetTicksNS(), joystick); /* try to sync up to current state now */ + PollAllValues(SDL_GetTicksNS(), joystick); // try to sync up to current state now } break; default: @@ -2062,7 +2062,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) } if (errno == ENODEV) { - /* We have to wait until the JoystickDetect callback to remove this */ + // We have to wait until the JoystickDetect callback to remove this joystick->hwdata->gone = SDL_TRUE; errno = 0; } @@ -2131,7 +2131,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) case SYN_REPORT: if (joystick->hwdata->recovering_from_dropped_sensor) { joystick->hwdata->recovering_from_dropped_sensor = SDL_FALSE; - PollAllSensors(SDL_GetTicksNS(), joystick); /* try to sync up to current state now */ + PollAllSensors(SDL_GetTicksNS(), joystick); // try to sync up to current state now } else { Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event); SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, @@ -2154,7 +2154,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) } if (errno == ENODEV) { - /* We have to wait until the JoystickDetect callback to remove this */ + // We have to wait until the JoystickDetect callback to remove this joystick->hwdata->sensor_gone = SDL_TRUE; } } @@ -2223,7 +2223,7 @@ static void LINUX_JoystickUpdate(SDL_Joystick *joystick) HandleInputEvents(joystick); } - /* Deliver ball motion updates */ + // Deliver ball motion updates for (i = 0; i < joystick->nballs; ++i) { int xrel, yrel; @@ -2237,7 +2237,7 @@ static void LINUX_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void LINUX_JoystickClose(SDL_Joystick *joystick) { SDL_AssertJoysticksLocked(); @@ -2268,7 +2268,7 @@ static void LINUX_JoystickClose(SDL_Joystick *joystick) } } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void LINUX_JoystickQuit(void) { SDL_joylist_item *item = NULL; @@ -2363,19 +2363,19 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap item->checked_mapping = SDL_TRUE; if (PrepareJoystickHwdata(joystick, item, NULL) < 0) { - goto done; /* SDL_SetError will already have been called */ + goto done; // SDL_SetError will already have been called } - /* don't assign `item->hwdata` so it's not in any global state. */ + // don't assign `item->hwdata` so it's not in any global state. - /* it is now safe to call LINUX_JoystickClose on this fake joystick. */ + // it is now safe to call LINUX_JoystickClose on this fake joystick. if (!joystick->hwdata->has_key[BTN_GAMEPAD]) { - /* Not a gamepad according to the specs. */ + // Not a gamepad according to the specs. goto done; } - /* We have a gamepad, start filling out the mappings */ + // We have a gamepad, start filling out the mappings #ifdef DEBUG_GAMEPAD_MAPPING SDL_Log("Mapping %s (VID/PID 0x%.4x/0x%.4x)", item->name, SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick)); @@ -2397,7 +2397,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #endif } - /* Xbox controllers use BTN_X and BTN_Y, and PS4 controllers use BTN_WEST and BTN_NORTH */ + // Xbox controllers use BTN_X and BTN_Y, and PS4 controllers use BTN_WEST and BTN_NORTH if (SDL_GetJoystickVendor(joystick) == USB_VENDOR_SONY) { if (joystick->hwdata->has_key[BTN_WEST]) { out->x.kind = EMappingKind_Button; @@ -2477,7 +2477,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap can be digital, or analog, or both at the same time. */ - /* Prefer digital shoulder buttons, but settle for digital or analog hat. */ + // Prefer digital shoulder buttons, but settle for digital or analog hat. mapped = 0; if (joystick->hwdata->has_key[BTN_TL]) { @@ -2528,7 +2528,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #endif } - /* Prefer analog triggers, but settle for digital hat or buttons. */ + // Prefer analog triggers, but settle for digital hat or buttons. mapped = 0; /* Unfortunately there are several conventions for how analog triggers @@ -2543,7 +2543,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap * * We try each one in turn. */ if (joystick->hwdata->has_abs[ABS_HAT2Y]) { - /* Linux Gamepad Specification */ + // Linux Gamepad Specification out->lefttrigger.kind = EMappingKind_Axis; out->lefttrigger.target = joystick->hwdata->abs_map[ABS_HAT2Y]; mapped |= MAPPED_TRIGGER_LEFT; @@ -2551,7 +2551,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap SDL_Log("Mapped LEFTTRIGGER to axis %d (ABS_HAT2Y)", out->lefttrigger.target); #endif } else if (joystick->hwdata->has_abs[ABS_BRAKE]) { - /* Android convention */ + // Android convention out->lefttrigger.kind = EMappingKind_Axis; out->lefttrigger.target = joystick->hwdata->abs_map[ABS_BRAKE]; mapped |= MAPPED_TRIGGER_LEFT; @@ -2559,7 +2559,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap SDL_Log("Mapped LEFTTRIGGER to axis %d (ABS_BRAKE)", out->lefttrigger.target); #endif } else if (joystick->hwdata->has_abs[ABS_Z]) { - /* De facto standard for Xbox 360 and Playstation gamepads */ + // De facto standard for Xbox 360 and Playstation gamepads out->lefttrigger.kind = EMappingKind_Axis; out->lefttrigger.target = joystick->hwdata->abs_map[ABS_Z]; mapped |= MAPPED_TRIGGER_LEFT; @@ -2569,7 +2569,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap } if (joystick->hwdata->has_abs[ABS_HAT2X]) { - /* Linux Gamepad Specification */ + // Linux Gamepad Specification out->righttrigger.kind = EMappingKind_Axis; out->righttrigger.target = joystick->hwdata->abs_map[ABS_HAT2X]; mapped |= MAPPED_TRIGGER_RIGHT; @@ -2577,7 +2577,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap SDL_Log("Mapped RIGHTTRIGGER to axis %d (ABS_HAT2X)", out->righttrigger.target); #endif } else if (joystick->hwdata->has_abs[ABS_GAS]) { - /* Android convention */ + // Android convention out->righttrigger.kind = EMappingKind_Axis; out->righttrigger.target = joystick->hwdata->abs_map[ABS_GAS]; mapped |= MAPPED_TRIGGER_RIGHT; @@ -2585,7 +2585,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap SDL_Log("Mapped RIGHTTRIGGER to axis %d (ABS_GAS)", out->righttrigger.target); #endif } else if (joystick->hwdata->has_abs[ABS_RZ]) { - /* De facto standard for Xbox 360 and Playstation gamepads */ + // De facto standard for Xbox 360 and Playstation gamepads out->righttrigger.kind = EMappingKind_Axis; out->righttrigger.target = joystick->hwdata->abs_map[ABS_RZ]; mapped |= MAPPED_TRIGGER_RIGHT; @@ -2624,7 +2624,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #endif } - /* Prefer digital D-Pad buttons, but settle for digital or analog hat. */ + // Prefer digital D-Pad buttons, but settle for digital or analog hat. mapped = 0; if (joystick->hwdata->has_key[BTN_DPAD_UP]) { @@ -2715,7 +2715,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap * instead uses the Z axis as a secondary X axis, and the RZ axis as * a secondary Y axis. */ if (joystick->hwdata->has_abs[ABS_RX] && joystick->hwdata->has_abs[ABS_RY]) { - /* Linux Gamepad Specification, Xbox 360, Playstation etc. */ + // Linux Gamepad Specification, Xbox 360, Playstation etc. out->rightx.kind = EMappingKind_Axis; out->righty.kind = EMappingKind_Axis; out->rightx.target = joystick->hwdata->abs_map[ABS_RX]; @@ -2725,7 +2725,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap SDL_Log("Mapped RIGHTY to axis %d (ABS_RY)", out->righty.target); #endif } else if (joystick->hwdata->has_abs[ABS_Z] && joystick->hwdata->has_abs[ABS_RZ]) { - /* Android convention */ + // Android convention out->rightx.kind = EMappingKind_Axis; out->righty.kind = EMappingKind_Axis; out->rightx.target = joystick->hwdata->abs_map[ABS_Z]; @@ -2737,7 +2737,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap } if (SDL_GetJoystickVendor(joystick) == USB_VENDOR_MICROSOFT) { - /* The Xbox Elite controllers have the paddles as BTN_TRIGGER_HAPPY5 - BTN_TRIGGER_HAPPY8 */ + // The Xbox Elite controllers have the paddles as BTN_TRIGGER_HAPPY5 - BTN_TRIGGER_HAPPY8 if (joystick->hwdata->has_key[BTN_TRIGGER_HAPPY5] && joystick->hwdata->has_key[BTN_TRIGGER_HAPPY6] && joystick->hwdata->has_key[BTN_TRIGGER_HAPPY7] && @@ -2758,7 +2758,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #endif } - /* The Xbox Series X controllers have the Share button as KEY_RECORD */ + // The Xbox Series X controllers have the Share button as KEY_RECORD if (joystick->hwdata->has_key[KEY_RECORD]) { out->misc1.kind = EMappingKind_Button; out->misc1.target = joystick->hwdata->key_map[KEY_RECORD]; @@ -2768,7 +2768,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap } } - /* Cache the mapping for later */ + // Cache the mapping for later item->mapping = (SDL_GamepadMapping *)SDL_malloc(sizeof(*item->mapping)); if (item->mapping) { SDL_memcpy(item->mapping, out, sizeof(*out)); @@ -2810,4 +2810,4 @@ SDL_JoystickDriver SDL_LINUX_JoystickDriver = { LINUX_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_LINUX */ +#endif // SDL_JOYSTICK_LINUX diff --git a/src/joystick/linux/SDL_sysjoystick_c.h b/src/joystick/linux/SDL_sysjoystick_c.h index cf9a41f101..f7004b5c8e 100644 --- a/src/joystick/linux/SDL_sysjoystick_c.h +++ b/src/joystick/linux/SDL_sysjoystick_c.h @@ -27,35 +27,35 @@ struct SDL_joylist_item; struct SDL_sensorlist_item; -/* The private structure used to keep track of a joystick */ +// The private structure used to keep track of a joystick struct joystick_hwdata { int fd; - /* linux driver creates a separate device for gyro/accelerometer */ + // linux driver creates a separate device for gyro/accelerometer int fd_sensor; struct SDL_joylist_item *item; struct SDL_sensorlist_item *item_sensor; SDL_GUID guid; - char *fname; /* Used in haptic subsystem */ + char *fname; // Used in haptic subsystem SDL_bool ff_rumble; SDL_bool ff_sine; struct ff_effect effect; Uint32 effect_expiration; - /* The current Linux joystick driver maps balls to two axes */ + // The current Linux joystick driver maps balls to two axes struct hwdata_ball { int axis[2]; } *balls; - /* The current Linux joystick driver maps hats to two axes */ + // The current Linux joystick driver maps hats to two axes struct hwdata_hat { int axis[2]; } *hats; - /* Support for the Linux 2.4 unified input interface */ + // Support for the Linux 2.4 unified input interface Uint8 key_map[KEY_MAX]; Uint8 abs_map[ABS_MAX]; SDL_bool has_key[KEY_MAX]; @@ -63,7 +63,7 @@ struct joystick_hwdata SDL_bool has_accelerometer; SDL_bool has_gyro; - /* Support for the classic joystick interface */ + // Support for the classic joystick interface SDL_bool classic; Uint16 *key_pam; Uint8 *abs_pam; @@ -72,10 +72,10 @@ struct joystick_hwdata { SDL_bool use_deadzones; - /* Deadzone coefficients */ + // Deadzone coefficients int coef[3]; - /* Raw coordinate scale */ + // Raw coordinate scale int minimum; int maximum; float scale; @@ -96,10 +96,10 @@ struct joystick_hwdata SDL_bool recovering_from_dropped; SDL_bool recovering_from_dropped_sensor; - /* Steam Controller support */ + // Steam Controller support SDL_bool m_bSteamController; - /* 4 = (ABS_HAT3X-ABS_HAT0X)/2 (see input-event-codes.h in kernel) */ + // 4 = (ABS_HAT3X-ABS_HAT0X)/2 (see input-event-codes.h in kernel) int hats_indices[4]; SDL_bool has_hat[4]; struct hat_axis_correct @@ -109,9 +109,9 @@ struct joystick_hwdata int maximum[2]; } hat_correct[4]; - /* Set when gamepad is pending removal due to ENODEV read error */ + // Set when gamepad is pending removal due to ENODEV read error SDL_bool gone; SDL_bool sensor_gone; }; -#endif /* SDL_sysjoystick_c_h_ */ +#endif // SDL_sysjoystick_c_h_ diff --git a/src/joystick/n3ds/SDL_sysjoystick.c b/src/joystick/n3ds/SDL_sysjoystick.c index b6ba9e973b..1607475af8 100644 --- a/src/joystick/n3ds/SDL_sysjoystick.c +++ b/src/joystick/n3ds/SDL_sysjoystick.c @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_N3DS -/* This is the N3DS implementation of the SDL joystick API */ +// This is the N3DS implementation of the SDL joystick API #include <3ds.h> @@ -190,7 +190,7 @@ static void N3DS_JoystickQuit(void) static SDL_bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - /* There is only one possible mapping. */ + // There is only one possible mapping. *out = (SDL_GamepadMapping){ .a = { EMappingKind_Button, 0 }, .b = { EMappingKind_Button, 1 }, @@ -228,7 +228,7 @@ static void N3DS_JoystickDetect(void) static SDL_bool N3DS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -295,4 +295,4 @@ SDL_JoystickDriver SDL_N3DS_JoystickDriver = { N3DS_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_N3DS */ +#endif // SDL_JOYSTICK_N3DS diff --git a/src/joystick/ps2/SDL_sysjoystick.c b/src/joystick/ps2/SDL_sysjoystick.c index 05d379f7a5..0ee58d5afb 100644 --- a/src/joystick/ps2/SDL_sysjoystick.c +++ b/src/joystick/ps2/SDL_sysjoystick.c @@ -22,20 +22,20 @@ #ifdef SDL_JOYSTICK_PS2 -/* This is the PS2 implementation of the SDL joystick API */ +// This is the PS2 implementation of the SDL joystick API #include #include #include -#include /* For the definition of NULL */ +#include // For the definition of NULL #include #include #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" -#define PS2_MAX_PORT 2 /* each ps2 has 2 ports */ -#define PS2_MAX_SLOT 4 /* maximum - 4 slots in one multitap */ +#define PS2_MAX_PORT 2 // each ps2 has 2 ports +#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 @@ -101,7 +101,7 @@ static int PS2_JoystickInit(void) for (port = 0; port < PS2_MAX_PORT; port++) { mtapPortOpen(port); } - /* it can fail - we dont care, we will check it more strictly when padPortOpen */ + // it can fail - we dont care, we will check it more strictly when padPortOpen for (slot = 0; slot < PS2_MAX_SLOT; slot++) { for (port = 0; port < PS2_MAX_PORT; port++) { @@ -130,24 +130,24 @@ static int PS2_JoystickInit(void) return enabled_pads > 0 ? 0 : -1; } -/* Function to return the number of joystick devices plugged in right now */ +// Function to return the number of joystick devices plugged in right now static int PS2_JoystickGetCount(void) { return (int)enabled_pads; } -/* Function to cause any queued joystick insertions to be processed */ +// Function to cause any queued joystick insertions to be processed static void PS2_JoystickDetect(void) { } static SDL_bool PS2_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } -/* Function to get the device-dependent name of a joystick */ +// Function to get the device-dependent name of a joystick static const char *PS2_JoystickGetDeviceName(int index) { if (index >= 0 && index < enabled_pads) { @@ -158,38 +158,38 @@ static const char *PS2_JoystickGetDeviceName(int index) return NULL; } -/* Function to get the device-dependent path of a joystick */ +// Function to get the device-dependent path of a joystick static const char *PS2_JoystickGetDevicePath(int index) { return NULL; } -/* Function to get the Steam virtual gamepad slot of a joystick */ +// Function to get the Steam virtual gamepad slot of a joystick static int PS2_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) { return -1; } -/* Function to get the player index of a joystick */ +// Function to get the player index of a joystick static int PS2_JoystickGetDevicePlayerIndex(int device_index) { return -1; } -/* Function to set the player index of a joystick */ +// Function to set the player index of a joystick static void PS2_JoystickSetDevicePlayerIndex(int device_index, int player_index) { } -/* Function to return the stable GUID for a plugged in device */ +// Function to return the stable GUID for a plugged in device static SDL_GUID PS2_JoystickGetDeviceGUID(int device_index) { - /* the GUID is just the name for now */ + // the GUID is just the name for now const char *name = PS2_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } -/* Function to get the current instance id of the joystick located at device_index */ +// Function to get the current instance id of the joystick located at device_index static SDL_JoystickID PS2_JoystickGetDeviceInstanceID(int device_index) { return device_index + 1; @@ -221,7 +221,7 @@ static int PS2_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -/* Rumble functionality */ +// Rumble functionality static int PS2_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { char actAlign[6]; @@ -245,25 +245,25 @@ static int PS2_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl return res == 1 ? 0 : -1; } -/* Rumble functionality */ +// Rumble functionality static int PS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right) { return SDL_Unsupported(); } -/* LED functionality */ +// LED functionality static int PS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { return SDL_Unsupported(); } -/* General effects */ +// General effects static int PS2_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { return SDL_Unsupported(); } -/* Sensor functionality */ +// Sensor functionality static int PS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { return SDL_Unsupported(); @@ -287,9 +287,9 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick) Uint64 timestamp = SDL_GetTicksNS(); if (state != PAD_STATE_DISCONN && state != PAD_STATE_EXECCMD && state != PAD_STATE_ERROR) { - int ret = padRead(info->port, info->slot, &buttons); /* port, slot, buttons */ + int ret = padRead(info->port, info->slot, &buttons); // port, slot, buttons if (ret != 0) { - /* Buttons */ + // Buttons int32_t pressed_buttons = 0xffff ^ buttons.btns; ; if (info->btns != pressed_buttons) { @@ -304,7 +304,7 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick) } info->btns = pressed_buttons; - /* Analog */ + // Analog all_axis[0] = buttons.ljoy_h; all_axis[1] = buttons.ljoy_v; all_axis[2] = buttons.rjoy_h; @@ -323,7 +323,7 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void PS2_JoystickClose(SDL_Joystick *joystick) { int index = joystick->instance_id; @@ -332,7 +332,7 @@ static void PS2_JoystickClose(SDL_Joystick *joystick) info->opened = 0; } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void PS2_JoystickQuit(void) { deinit_joystick_driver(true); @@ -367,4 +367,4 @@ SDL_JoystickDriver SDL_PS2_JoystickDriver = { PS2_GetGamepadMapping, }; -#endif /* SDL_JOYSTICK_PS2 */ +#endif // SDL_JOYSTICK_PS2 diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index f10988401d..77c63d3993 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -22,16 +22,16 @@ #ifdef SDL_JOYSTICK_PSP -/* This is the PSP implementation of the SDL joystick API */ +// 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" #include "../SDL_joystick_c.h" -/* Current pad state */ +// Current pad state static SceCtrlData pad = { .Lx = 0, .Ly = 0, .Buttons = 0 }; static const enum PspCtrlButtons button_map[] = { PSP_CTRL_TRIANGLE, PSP_CTRL_CIRCLE, PSP_CTRL_CROSS, PSP_CTRL_SQUARE, @@ -39,31 +39,31 @@ static const enum PspCtrlButtons button_map[] = { 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 */ +static int analog_map[256]; // Map analog inputs to -32768 -> 32767 -/* 4 points define the bezier-curve. */ +// 4 points define the bezier-curve. static SDL_Point a = { 0, 0 }; static SDL_Point b = { 50, 0 }; static SDL_Point c = { 78, 32767 }; static SDL_Point d = { 128, 32767 }; -/* simple linear interpolation between two points */ +// simple linear interpolation between two points static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *pt_a, const SDL_Point *pt_b, float t) { dest->x = pt_a->x + (int)((pt_b->x - pt_a->x) * t); dest->y = pt_a->y + (int)((pt_b->y - pt_a->y) * t); } -/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ +// evaluate a point on a bezier-curve. t goes from 0 to 1.0 static int calc_bezier_y(float t) { SDL_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; } @@ -75,7 +75,7 @@ static int PSP_JoystickInit(void) { int i; - /* Setup input */ + // Setup input sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); @@ -103,11 +103,11 @@ static void PSP_JoystickDetect(void) static SDL_bool PSP_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } -/* Function to get the device-dependent name of a joystick */ +// Function to get the device-dependent name of a joystick static const char *PSP_JoystickGetDeviceName(int device_index) { if (device_index == 0) { @@ -139,12 +139,12 @@ static void PSP_JoystickSetDevicePlayerIndex(int device_index, int player_index) static SDL_GUID PSP_JoystickGetDeviceGUID(int device_index) { - /* the GUID is just the name for now */ + // the GUID is just the name for now const char *name = PSP_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } -/* Function to perform the mapping from device index to the instance id for this index */ +// Function to perform the mapping from device index to the instance id for this index static SDL_JoystickID PSP_JoystickGetDeviceInstanceID(int device_index) { return device_index + 1; @@ -211,7 +211,7 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick) x = pad.Lx; y = pad.Ly; - /* Axes */ + // Axes if (old_x != x) { SDL_SendJoystickAxis(timestamp, joystick, 0, analog_map[x]); old_x = x; @@ -221,7 +221,7 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick) old_y = y; } - /* Buttons */ + // Buttons changed = old_buttons ^ buttons; old_buttons = buttons; if (changed) { @@ -235,12 +235,12 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void PSP_JoystickClose(SDL_Joystick *joystick) { } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void PSP_JoystickQuit(void) { } @@ -274,4 +274,4 @@ SDL_JoystickDriver SDL_PSP_JoystickDriver = { PSP_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_PSP */ +#endif // SDL_JOYSTICK_PSP diff --git a/src/joystick/steam/SDL_steamcontroller.h b/src/joystick/steam/SDL_steamcontroller.h index 2636740dc1..f38f33d39f 100644 --- a/src/joystick/steam/SDL_steamcontroller.h +++ b/src/joystick/steam/SDL_steamcontroller.h @@ -34,4 +34,4 @@ void SDL_UpdateSteamControllers(void); void SDL_UpdateSteamController(SDL_Joystick *joystick); void SDL_QuitSteamControllers(void); -#endif /* SDL_steamcontroller_h_ */ +#endif // SDL_steamcontroller_h_ diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index d5dcc19d8c..3b03739ac0 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -22,7 +22,7 @@ #ifndef usb_ids_h_ #define usb_ids_h_ -/* Definitions of useful USB VID/PID values */ +// Definitions of useful USB VID/PID values #define USB_VENDOR_8BITDO 0x2dc8 #define USB_VENDOR_AMAZON 0x1949 @@ -59,8 +59,8 @@ #define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_ZEROPLUS 0x0c12 -#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 0x2002 /* Ultimate Wired Controller for Xbox */ -#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER2 0x3106 /* Ultimate Wireless / Pro 2 Wired Controller */ +#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 0x2002 // Ultimate Wired Controller for Xbox +#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER2 0x3106 // Ultimate Wireless / Pro 2 Wired Controller #define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 #define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024 #define USB_PRODUCT_BACKBONE_ONE_IOS 0x0103 @@ -87,7 +87,7 @@ #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_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 @@ -125,7 +125,7 @@ #define USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON 0x7009 #define USB_PRODUCT_VICTRIX_FS_PRO 0x0203 #define USB_PRODUCT_VICTRIX_FS_PRO_V2 0x0207 -#define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */ +#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_XBOX360_WIRELESS_RECEIVER_THIRDPARTY1 0x02a9 @@ -151,14 +151,14 @@ #define USB_PRODUCT_XBOX_SERIES_X_POWERA_MOGA_XP_ULTRA 0x890b #define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA 0x4002 #define USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT 0x02d6 -#define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff /* XBOXGIP driver software PID */ +#define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff // XBOXGIP driver software PID #define USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD 0x11ff -/* USB usage pages */ +// USB usage pages #define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001 #define USB_USAGEPAGE_BUTTON 0x0009 -/* USB usages for USAGE_PAGE_GENERIC_DESKTOP */ +// 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 @@ -183,4 +183,4 @@ #define BLUETOOTH_PRODUCT_LUNA_CONTROLLER 0x0419 -#endif /* usb_ids_h_ */ +#endif // usb_ids_h_ diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index b0d6f6a375..69f1ca34fa 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_VIRTUAL -/* This is the virtual implementation of the SDL joystick API */ +// This is the virtual implementation of the SDL joystick API #include "SDL_virtualjoystick_c.h" #include "../SDL_sysjoystick.h" @@ -70,7 +70,7 @@ static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata) return; } - /* Remove hwdata from SDL-global list */ + // Remove hwdata from SDL-global list for (cur = g_VJoys; cur; prev = cur, cur = cur->next) { if (hwdata == cur) { if (prev) { @@ -206,7 +206,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des } } - /* Find the trigger axes */ + // Find the trigger axes axis = 0; for (i = 0; axis < hwdata->desc.naxes && i < SDL_GAMEPAD_AXIS_MAX; ++i) { if (hwdata->desc.axis_mask & (1 << i)) { @@ -223,7 +223,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des hwdata->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_VIRTUAL, hwdata->desc.vendor_id, hwdata->desc.product_id, 0, NULL, name, 'v', (Uint8)hwdata->desc.type); - /* Allocate fields for different control-types */ + // Allocate fields for different control-types if (hwdata->desc.naxes > 0) { hwdata->axes = (Sint16 *)SDL_calloc(hwdata->desc.naxes, sizeof(*hwdata->axes)); if (!hwdata->axes) { @@ -231,7 +231,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des return 0; } - /* Trigger axes are at minimum value at rest */ + // Trigger axes are at minimum value at rest if (axis_triggerleft >= 0) { hwdata->axes[axis_triggerleft] = SDL_JOYSTICK_AXIS_MIN; } @@ -299,10 +299,10 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des } } - /* Allocate an instance ID for this device */ + // Allocate an instance ID for this device hwdata->instance_id = SDL_GetNextObjectID(); - /* Add virtual joystick to SDL-global lists */ + // Add virtual joystick to SDL-global lists if (g_VJoys) { joystick_hwdata *last; @@ -497,7 +497,7 @@ static void VIRTUAL_JoystickDetect(void) static SDL_bool VIRTUAL_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers... or do we? */ + // We don't override any other drivers... or do we? return SDL_FALSE; } @@ -977,4 +977,4 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = { VIRTUAL_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_VIRTUAL */ +#endif // SDL_JOYSTICK_VIRTUAL diff --git a/src/joystick/virtual/SDL_virtualjoystick_c.h b/src/joystick/virtual/SDL_virtualjoystick_c.h index cfb4a083f9..b453223f08 100644 --- a/src/joystick/virtual/SDL_virtualjoystick_c.h +++ b/src/joystick/virtual/SDL_virtualjoystick_c.h @@ -79,6 +79,6 @@ extern int SDL_SetJoystickVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 extern int SDL_SetJoystickVirtualTouchpadInner(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure); extern int SDL_SendJoystickVirtualSensorDataInner(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); -#endif /* SDL_JOYSTICK_VIRTUAL */ +#endif // SDL_JOYSTICK_VIRTUAL -#endif /* SDL_VIRTUALJOYSTICK_C_H */ +#endif // SDL_VIRTUALJOYSTICK_C_H diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c index 90257148c5..eccf950d60 100644 --- a/src/joystick/vita/SDL_sysjoystick.c +++ b/src/joystick/vita/SDL_sysjoystick.c @@ -22,18 +22,18 @@ #ifdef SDL_JOYSTICK_VITA -/* This is the PSVita implementation of the SDL joystick API */ +// This is the PSVita implementation of the SDL joystick API #include #include #include -#include /* For the definition of NULL */ +#include // For the definition of NULL #include #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" -/* Current pad state */ +// Current pad state static SceCtrlData pad0 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; static SceCtrlData pad1 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; static SceCtrlData pad2 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; @@ -62,32 +62,32 @@ 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 -/* 4 points define the bezier-curve. */ -/* The Vita has a good amount of analog travel, so use a linear curve */ +// 4 points define the bezier-curve. +// The Vita has a good amount of analog travel, so use a linear curve static SDL_Point a = { 0, 0 }; static SDL_Point b = { 0, 0 }; static SDL_Point c = { 128, 32767 }; static SDL_Point d = { 128, 32767 }; -/* simple linear interpolation between two points */ +// simple linear interpolation between two points static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *first, const SDL_Point *second, float t) { dest->x = first->x + (int)((second->x - first->x) * t); dest->y = first->y + (int)((second->y - first->y) * t); } -/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ +// evaluate a point on a bezier-curve. t goes from 0 to 1.0 static int calc_bezier_y(float t) { SDL_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; } @@ -100,7 +100,7 @@ static int VITA_JoystickInit(void) int i; SceCtrlPortInfo myPortInfo; - /* Setup input */ + // Setup input sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); sceCtrlSetSamplingModeExt(SCE_CTRL_MODE_ANALOG_WIDE); @@ -145,11 +145,11 @@ static void VITA_JoystickDetect(void) static SDL_bool VITA_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } -/* Function to perform the mapping from device index to the instance id for this index */ +// Function to perform the mapping from device index to the instance id for this index static SDL_JoystickID VITA_JoystickGetDeviceInstanceID(int device_index) { return device_index + 1; @@ -308,19 +308,19 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void VITA_JoystickClose(SDL_Joystick *joystick) { } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup static void VITA_JoystickQuit(void) { } static SDL_GUID VITA_JoystickGetDeviceGUID(int device_index) { - /* the GUID is just the name for now */ + // the GUID is just the name for now const char *name = VITA_JoystickGetDeviceName(device_index); return SDL_CreateJoystickGUIDForName(name); } @@ -398,4 +398,4 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver = { VITA_JoystickGetGamepadMapping, }; -#endif /* SDL_JOYSTICK_VITA */ +#endif // SDL_JOYSTICK_VITA diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index f96a65151e..a80fe2197d 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -34,23 +34,23 @@ #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) -/* external variables referenced. */ +// external variables referenced. #ifdef SDL_VIDEO_DRIVER_WINDOWS extern HWND SDL_HelperWindow; #else static const HWND SDL_HelperWindow = NULL; #endif -/* local variables */ +// local variables static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT8 dinput = NULL; -/* Taken from Wine - Thanks! */ +// Taken from Wine - Thanks! static DIOBJECTDATAFORMAT dfDIJoystick2[] = { { &GUID_XAxis, DIJOFS_X, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, { &GUID_YAxis, DIJOFS_Y, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, @@ -198,7 +198,7 @@ static DIOBJECTDATAFORMAT dfDIJoystick2[] = { { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lVRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lVRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lVRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, - /* note: dwOfs value matches Windows */ + // note: dwOfs value matches Windows { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lAX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, @@ -207,7 +207,7 @@ static DIOBJECTDATAFORMAT dfDIJoystick2[] = { { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lARx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lARy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lARz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, - /* note: dwOfs value matches Windows */ + // note: dwOfs value matches Windows { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lFX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, @@ -216,7 +216,7 @@ static DIOBJECTDATAFORMAT dfDIJoystick2[] = { { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lFRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lFRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lFRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, - /* note: dwOfs value matches Windows */ + // note: dwOfs value matches Windows { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, }; @@ -230,7 +230,7 @@ const DIDATAFORMAT SDL_c_dfDIJoystick2 = { dfDIJoystick2 }; -/* Convert a DirectInput return code to a text message */ +// Convert a DirectInput return code to a text message static int SetDIerror(const char *function, HRESULT code) { return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code); @@ -241,7 +241,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const ch #if defined(SDL_JOYSTICK_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT) SDL_GamepadType type; - /* XInput and RawInput backends will pick up XInput-compatible devices */ + // XInput and RawInput backends will pick up XInput-compatible devices if (!SDL_XINPUT_Enabled() #ifdef SDL_JOYSTICK_RAWINPUT && !RAWINPUT_IsEnabled() @@ -250,8 +250,8 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const ch return SDL_FALSE; } - /* If device path contains "IG_" then its an XInput device */ - /* See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput */ + // If device path contains "IG_" then its an XInput device + // See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput if (SDL_strstr(hidPath, "IG_") != NULL) { return SDL_TRUE; } @@ -262,7 +262,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const ch (vendor_id == USB_VENDOR_VALVE && product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) { return SDL_TRUE; } -#endif /* SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT */ +#endif // SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT return SDL_FALSE; } @@ -308,7 +308,7 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) *device_path = WIN_StringToUTF8W(dippath.wszPath); - /* Normalize path to upper case. */ + // Normalize path to upper case. SDL_strupr(*device_path); return SDL_TRUE; @@ -354,7 +354,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) DIEFFECT *effect; DIPERIODIC *periodic; - /* Create the effect */ + // Create the effect effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect)); if (!effect) { return NULL; @@ -362,7 +362,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwSize = sizeof(*effect); effect->dwGain = 10000; effect->dwFlags = DIEFF_OBJECTOFFSETS; - effect->dwDuration = SDL_MAX_RUMBLE_DURATION_MS * 1000; /* In microseconds. */ + effect->dwDuration = SDL_MAX_RUMBLE_DURATION_MS * 1000; // In microseconds. effect->dwTriggerButton = DIEB_NOTRIGGER; effect->cAxes = 2; @@ -399,7 +399,7 @@ int SDL_DINPUT_JoystickInit(void) HINSTANCE instance; if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, SDL_TRUE)) { - /* In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. */ + // In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. dinput = NULL; return 0; } @@ -418,7 +418,7 @@ int SDL_DINPUT_JoystickInit(void) return SetDIerror("CoCreateInstance", result); } - /* Because we used CoCreateInstance, we need to Initialize it, first. */ + // Because we used CoCreateInstance, we need to Initialize it, first. instance = GetModuleHandle(NULL); if (!instance) { IDirectInput8_Release(dinput); @@ -446,7 +446,7 @@ static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const return slot; } -/* helper function for direct input, gets called for each connected joystick */ +// helper function for direct input, gets called for each connected joystick static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) { #define CHECK(expression) \ @@ -463,7 +463,7 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta char *name = NULL; LPDIRECTINPUTDEVICE8 device = NULL; - /* We are only supporting HID devices. */ + // We are only supporting HID devices. CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID); CHECK(SUCCEEDED(IDirectInput8_CreateDevice(dinput, &pDeviceInstance->guidInstance, &device, NULL))); @@ -475,16 +475,16 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta pNewJoystick = *(JoyStick_DeviceData **)pContext; while (pNewJoystick) { - /* update GUIDs of joysticks with matching paths, in case they're not open yet */ + // 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 we are replacing the front of the list then update it if (pNewJoystick == *(JoyStick_DeviceData **)pContext) { *(JoyStick_DeviceData **)pContext = pNewJoystick->pNext; } else if (pPrevJoystick) { pPrevJoystick->pNext = pNewJoystick->pNext; } - /* Update with new guid/etc, if it has changed */ + // Update with new guid/etc, if it has changed SDL_memcpy(&pNewJoystick->dxdevice, pDeviceInstance, sizeof(DIDEVICEINSTANCE)); pNewJoystick->pNext = SYS_Joystick; @@ -534,7 +534,7 @@ err: IDirectInputDevice8_Release(device); } - return DIENUM_CONTINUE; /* get next device, please */ + return DIENUM_CONTINUE; // get next device, please #undef CHECK } @@ -547,7 +547,7 @@ void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickDetectCallback, pContext, DIEDFL_ATTACHEDONLY); } -/* helper function for direct input, gets called for each connected joystick */ +// helper function for direct input, gets called for each connected joystick typedef struct { Uint16 vendor; @@ -568,7 +568,7 @@ static BOOL CALLBACK EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInst LPDIRECTINPUTDEVICE8 device = NULL; BOOL result = DIENUM_CONTINUE; - /* We are only supporting HID devices. */ + // We are only supporting HID devices. CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID); CHECK(SUCCEEDED(IDirectInput8_CreateDevice(dinput, &pDeviceInstance->guidInstance, &device, NULL))); @@ -576,7 +576,7 @@ static BOOL CALLBACK EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInst if (vendor == pData->vendor && product == pData->product) { pData->present = SDL_TRUE; - result = DIENUM_STOP; /* found it */ + result = DIENUM_STOP; // found it } err: @@ -641,7 +641,7 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj in->ofs = DIJOFS_SLIDER(joystick->hwdata->NumSliders); ++joystick->hwdata->NumSliders; } else { - return DIENUM_CONTINUE; /* not an axis we can grok */ + return DIENUM_CONTINUE; // not an axis we can grok } diprg.diph.dwSize = sizeof(diprg); @@ -655,10 +655,10 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, 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. */ + // Set dead zone to 0. dilong.diph.dwSize = sizeof(dilong); dilong.diph.dwHeaderSize = sizeof(dilong.diph); dilong.diph.dwObj = pDeviceObject->dwType; @@ -668,19 +668,19 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, 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++; } else { - /* not supported at this time */ + // not supported at this time return DIENUM_CONTINUE; } joystick->hwdata->NumInputs++; if (joystick->hwdata->NumInputs == MAX_INPUTS) { - return DIENUM_STOP; /* too many */ + return DIENUM_STOP; // too many } return DIENUM_CONTINUE; @@ -703,7 +703,7 @@ static int SDLCALL SortDevFunc(const void *a, const void *b) return 0; } -/* Sort the input objects and recalculate the indices for each input. */ +// Sort the input objects and recalculate the indices for each input. static void SortDevObjects(SDL_Joystick *joystick) { input_t *inputs = joystick->hwdata->Inputs; @@ -765,7 +765,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result); } - /* Use the extended data structure: DIJOYSTATE2. */ + // Use the extended data structure: DIJOYSTATE2. result = IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice, &SDL_c_dfDIJoystick2); @@ -773,7 +773,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic return SetDIerror("IDirectInputDevice8::SetDataFormat", result); } - /* Get device capabilities */ + // Get device capabilities result = IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice, &joystick->hwdata->Capabilities); @@ -781,14 +781,14 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic return SetDIerror("IDirectInputDevice8::GetCapabilities", result); } - /* Force capable? */ + // Force capable? if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::Acquire", result); } - /* reset all actuators. */ + // reset all actuators. result = IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata->InputDevice, DISFFC_RESET); @@ -824,7 +824,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); } - /* What buttons and axes does it have? */ + // What buttons and axes does it have? IDirectInputDevice8_EnumObjects(joystick->hwdata->InputDevice, EnumDevObjectsCallback, joystick, DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); @@ -837,7 +837,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = INPUT_QSIZE; - /* Set the buffer size */ + // Set the buffer size result = IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, DIPROP_BUFFERSIZE, &dipdw.diph); @@ -851,7 +851,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic } joystick->hwdata->first_update = SDL_TRUE; - /* Poll and wait for initial device state to be populated */ + // Poll and wait for initial device state to be populated result = IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); @@ -866,7 +866,7 @@ static int SDL_DINPUT_JoystickInitRumble(SDL_Joystick *joystick, Sint16 magnitud { HRESULT result; - /* Reset and then enable actuators */ + // Reset and then enable actuators result = IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata->InputDevice, DISFFC_RESET); if (result == DIERR_INPUTLOST || result == DIERR_NOTEXCLUSIVEACQUIRED) { result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); @@ -883,7 +883,7 @@ static int SDL_DINPUT_JoystickInitRumble(SDL_Joystick *joystick, Sint16 magnitud return SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand(DISFFC_SETACTUATORSON)", result); } - /* Create the effect */ + // Create the effect joystick->hwdata->ffeffect = CreateRumbleEffectData(magnitude); if (!joystick->hwdata->ffeffect) { return -1; @@ -901,7 +901,7 @@ int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl { HRESULT result; - /* Scale and average the two rumble strengths */ + // Scale and average the two rumble strengths Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); if (!(joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK)) { @@ -959,13 +959,13 @@ static Uint8 TranslatePOV(DWORD value) return SDL_HAT_CENTERED; } - /* Round the value up: */ + // Round the value up: value += 4500 / 2; value %= 36000; value /= 4500; if (value >= 8) { - return SDL_HAT_CENTERED; /* shouldn't happen */ + return SDL_HAT_CENTERED; // shouldn't happen } return HAT_VALS[value]; @@ -997,7 +997,7 @@ static void UpdateDINPUTJoystickState_Polled(SDL_Joystick *joystick) return; } - /* Set each known axis, button and POV. */ + // Set each known axis, button and POV. for (i = 0; i < joystick->hwdata->NumInputs; ++i) { const input_t *in = &joystick->hwdata->Inputs[i]; @@ -1066,7 +1066,7 @@ static void UpdateDINPUTJoystickState_Buffered(SDL_Joystick *joystick) evtbuf, &numevents, 0); } - /* Handle the events or punt */ + // Handle the events or punt if (FAILED(result)) { return; } @@ -1117,7 +1117,7 @@ void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick) } if (joystick->hwdata->first_update) { - /* Poll to get the initial state of the joystick */ + // Poll to get the initial state of the joystick UpdateDINPUTJoystickState_Polled(joystick); joystick->hwdata->first_update = SDL_FALSE; return; @@ -1158,7 +1158,7 @@ void SDL_DINPUT_JoystickQuit(void) } } -#else /* !SDL_JOYSTICK_DINPUT */ +#else // !SDL_JOYSTICK_DINPUT typedef struct JoyStick_DeviceData JoyStick_DeviceData; @@ -1198,4 +1198,4 @@ void SDL_DINPUT_JoystickQuit(void) { } -#endif /* SDL_JOYSTICK_DINPUT */ +#endif // SDL_JOYSTICK_DINPUT diff --git a/src/joystick/windows/SDL_dinputjoystick_c.h b/src/joystick/windows/SDL_dinputjoystick_c.h index 780f6a3634..614f783781 100644 --- a/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/src/joystick/windows/SDL_dinputjoystick_c.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -34,7 +34,7 @@ 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++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 59e48061a5..7801537376 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -139,7 +139,7 @@ struct joystick_hwdata USHORT trigger_hack_index; #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING - Uint64 match_state; /* Lowest 16 bits for button states, higher 24 for 6 4bit axes */ + Uint64 match_state; // Lowest 16 bits for button states, higher 24 for 6 4bit axes Uint64 last_state_packet; #endif @@ -213,20 +213,20 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state }; */ for (ii = 0; ii < 4; ii++) { state->match_axes[ii] = (SHORT)((match_state & (0x000F0000ull << (ii * 4))) >> (4 + ii * 4)); - any_axes_data |= ((Uint32)(state->match_axes[ii] + 0x1000) > 0x2000); /* match_state bit is not 0xF, 0x1, or 0x2 */ + any_axes_data |= ((Uint32)(state->match_axes[ii] + 0x1000) > 0x2000); // match_state bit is not 0xF, 0x1, or 0x2 } -#endif /* SDL_JOYSTICK_RAWINPUT_MATCH_AXES */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCH_AXES #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS for (; ii < SDL_JOYSTICK_RAWINPUT_MATCH_COUNT; ii++) { state->match_axes[ii] = (SHORT)((match_state & (0x000F0000ull << (ii * 4))) >> (4 + ii * 4)); any_axes_data |= (state->match_axes[ii] != SDL_MIN_SINT16); } -#endif /* SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS state->any_data = any_axes_data; #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 */ + // 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 && \ @@ -239,7 +239,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state SDL_abs((Sint8)((gamepad.sThumbRX & 0xF000) >> 8) - ((match_state & 0x0F000000) >> 20)) <= 0x10 && \ SDL_abs((Sint8)((~gamepad.sThumbRY & 0xF000) >> 8) - ((match_state & 0xF0000000) >> 24)) <= 0x10) */ - /* Can only match trigger values if a single trigger has a value. */ + // 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)) || \ @@ -247,7 +247,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state ((Uint32)((((int)gamepad.bRightTrigger * 257) - 32768) - state->match_axes[5]) <= 0x2fff)) state->xinput_buttons = - /* Bitwise map .RLDUWVQTS.KYXBA -> YXBA..WVQTKSRLDU */ + // Bitwise map .RLDUWVQTS.KYXBA -> YXBA..WVQTKSRLDU (WORD)(match_state << 12 | (match_state & 0x0780) >> 1 | (match_state & 0x0010) << 1 | (match_state & 0x0040) >> 2 | (match_state & 0x7800) >> 11); /* Explicit ((match_state & (1<match_axes[0] + 0x1000) <= 0x2fff && \ (Uint16)((~(Sint16)(gamepad.LeftThumbstickY * SDL_MAX_SINT16) & 0xF000) - state->match_axes[1] + 0x1000) <= 0x2fff && \ @@ -286,8 +286,8 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state ((Uint16)((((int)(gamepad.RightTrigger * SDL_MAX_UINT16)) - 32768) - state->match_axes[5]) <= 0x2fff)) state->wgi_buttons = - /* Bitwise map .RLD UWVQ TS.K YXBA -> ..QT WVRL DUYX BAKS */ - /* RStick/LStick (QT) RShould/LShould (WV) DPad R/L/D/U YXBA bac(K) (S)tart */ + // Bitwise map .RLD UWVQ TS.K YXBA -> ..QT WVRL DUYX BAKS + // RStick/LStick (QT) RShould/LShould (WV) DPad R/L/D/U YXBA bac(K) (S)tart (match_state & 0x0180) << 5 | (match_state & 0x0600) << 1 | (match_state & 0x7800) >> 5 | (match_state & 0x000F) << 2 | (match_state & 0x0010) >> 3 | (match_state & 0x0040) >> 6; /* Explicit ((match_state & (1<refcount, -1) - 1; - /* Should never free the static delegate objects */ + // Should never free the static delegate objects SDL_assert(rc > 0); return rc; } @@ -519,8 +519,8 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_InvokeRemoved(__FIEv #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable : 4028) /* formal parameter 3 different from declaration, when using older buggy WGI headers */ -#pragma warning(disable : 4113) /* X differs in parameter lists from Y, when using older buggy WGI headers */ +#pragma warning(disable : 4028) // formal parameter 3 different from declaration, when using older buggy WGI headers +#pragma warning(disable : 4113) // X differs in parameter lists from Y, when using older buggy WGI headers #endif static __FIEventHandler_1_Windows__CGaming__CInput__CGamepadVtbl gamepad_added_vtbl = { @@ -615,7 +615,7 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) } } if (!found) { - /* New device, add it */ + // New device, add it WindowsGamingInputGamepadState *gamepad_state; WindowsGamingInputGamepadState **new_per_gamepad; gamepad_state = SDL_calloc(1, sizeof(*gamepad_state)); @@ -633,7 +633,7 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) gamepad_state->gamepad = gamepad; gamepad_state->connected = SDL_TRUE; } else { - /* Already tracked */ + // Already tracked __x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(gamepad); } } @@ -641,7 +641,7 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) for (ii = wgi_state.per_gamepad_count - 1; ii >= 0; ii--) { WindowsGamingInputGamepadState *gamepad_state = wgi_state.per_gamepad[ii]; if (!gamepad_state->connected) { - /* Device missing, must be disconnected */ + // Device missing, must be disconnected if (gamepad_state->correlated_context) { gamepad_state->correlated_context->wgi_correlated = SDL_FALSE; gamepad_state->correlated_context->wgi_slot = NULL; @@ -655,12 +655,12 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) } __FIVectorView_1_Windows__CGaming__CInput__CGamepad_Release(gamepads); } - } /* need_device_list_update */ + } // need_device_list_update for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { HRESULT hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_GetCurrentReading(wgi_state.per_gamepad[ii]->gamepad, &wgi_state.per_gamepad[ii]->state); if (!SUCCEEDED(hr)) { - wgi_state.per_gamepad[ii]->connected = SDL_FALSE; /* Not used by anything, currently */ + wgi_state.per_gamepad[ii]->connected = SDL_FALSE; // Not used by anything, currently } } return 0; @@ -765,7 +765,7 @@ static SDL_bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *st if (RAWINPUT_WindowsGamingInputSlotMatches(state, gamepad_state, xinput_correlated)) { ++match_count; *slot = gamepad_state; - /* Incrementing correlation_id for any match, as negative evidence for others being correlated */ + // Incrementing correlation_id for any match, as negative evidence for others being correlated *correlation_id = ++gamepad_state->correlation_id; } } @@ -802,7 +802,7 @@ static void RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) } } -#endif /* SDL_JOYSTICK_RAWINPUT_WGI */ +#endif // SDL_JOYSTICK_RAWINPUT_WGI static SDL_RAWINPUT_Device *RAWINPUT_AcquireDevice(SDL_RAWINPUT_Device *device) { @@ -821,7 +821,7 @@ static void RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) ctx->xinput_correlated = SDL_FALSE; } } -#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT_XINPUT if (SDL_AtomicDecRef(&device->refcount)) { SDL_free(device->preparsed_data); @@ -870,21 +870,21 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) char dev_name[MAX_PATH] = { 0 }; HANDLE hFile = INVALID_HANDLE_VALUE; - /* Make sure we're not trying to add the same device twice */ + // Make sure we're not trying to add the same device twice if (RAWINPUT_DeviceFromHandle(hDevice)) { return; } - /* Figure out what kind of device it is */ + // Figure out what kind of device it is size = sizeof(rdi); SDL_zero(rdi); CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_DEVICEINFO, &rdi, &size) != (UINT)-1); CHECK(rdi.dwType == RIM_TYPEHID); - /* Get the device "name" (HID Path) */ + // Get the device "name" (HID Path) size = SDL_arraysize(dev_name); CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_DEVICENAME, dev_name, &size) != (UINT)-1); - /* Only take XInput-capable devices */ + // Only take XInput-capable devices CHECK(SDL_strstr(dev_name, "IG_") != NULL); CHECK(!SDL_JoystickHandledByAnotherDriver(&SDL_RAWINPUT_JoystickDriver, (Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, "")); device = (SDL_RAWINPUT_Device *)SDL_calloc(1, sizeof(SDL_RAWINPUT_Device)); @@ -897,7 +897,7 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) device->is_xboxone = SDL_IsJoystickXboxOne(device->vendor_id, device->product_id); device->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(device->vendor_id, device->product_id, dev_name); - /* Get HID Top-Level Collection Preparsed Data */ + // Get HID Top-Level Collection Preparsed Data size = 0; CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, NULL, &size) != (UINT)-1); device->preparsed_data = (PHIDP_PREPARSED_DATA)SDL_calloc(size, sizeof(BYTE)); @@ -941,7 +941,7 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) SDL_Log("Adding RAWINPUT device '%s' VID 0x%.4x, PID 0x%.4x, version %d, handle 0x%.8x\n", device->name, device->vendor_id, device->product_id, device->version, device->hDevice); #endif - /* Add it to the list */ + // Add it to the list RAWINPUT_AcquireDevice(device); for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) { } @@ -1034,7 +1034,7 @@ static int RAWINPUT_JoystickInit(void) } if (!WIN_IsWindowsVistaOrGreater()) { - /* According to bug 6400, this doesn't work on Windows XP */ + // According to bug 6400, this doesn't work on Windows XP return -1; } @@ -1114,7 +1114,7 @@ static void RAWINPUT_PostUpdate(void) } guide_button_candidate.joystick = NULL; -#endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCHING } static void RAWINPUT_JoystickDetect(void) @@ -1146,7 +1146,7 @@ static SDL_bool RAWINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produc { SDL_RAWINPUT_Device *device; - /* If we're being asked about a device, that means another API just detected one, so rescan */ + // If we're being asked about a device, that means another API just detected one, so rescan #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_device_change = SDL_TRUE; #endif @@ -1166,7 +1166,7 @@ static SDL_bool RAWINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produc return SDL_TRUE; } - /* The Xbox One controller shows up as a hardcoded raw input VID/PID */ + // The Xbox One controller shows up as a hardcoded raw input VID/PID if (name && SDL_strcmp(name, "Xbox One Game Controller") == 0 && device->vendor_id == USB_VENDOR_MICROSOFT && device->product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) { @@ -1230,7 +1230,7 @@ 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; - /* Sort by Usage for single values, or UsageMax for range of values */ + // Sort by Usage for single values, or UsageMax for range of values return (int)capsA->NotRange.Usage - capsB->NotRange.Usage; } @@ -1253,7 +1253,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) device->joystick = joystick; if (device->is_xinput) { - /* We'll try to get guide button and trigger axes from XInput */ + // We'll try to get guide button and trigger axes from XInput #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_device_change = SDL_TRUE; ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE); @@ -1270,7 +1270,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ctx->is_xinput = device->is_xinput; ctx->is_xboxone = device->is_xboxone; #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING - ctx->match_state = 0x0000008800000000ULL; /* Trigger axes at rest */ + ctx->match_state = 0x0000008800000000ULL; // Trigger axes at rest #endif ctx->preparsed_data = device->preparsed_data; ctx->max_data_length = SDL_HidP_MaxDataListLength(HidP_Input, ctx->preparsed_data); @@ -1297,7 +1297,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) return SDL_SetError("Couldn't get device value capabilities"); } - /* Sort the axes by usage, so X comes before Y, etc. */ + // Sort the axes by usage, so X comes before Y, etc. SDL_qsort(value_caps, caps.NumberInputValueCaps, sizeof(*value_caps), RAWINPUT_SortValueCaps); for (i = 0; i < caps.NumberInputButtonCaps; ++i) { @@ -1452,7 +1452,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ SDL_bool rumbled = SDL_FALSE; #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - /* Prefer XInput over WGI because it allows rumble in the background */ + // Prefer XInput over WGI because it allows rumble in the background if (!rumbled && ctx->xinput_correlated) { XINPUT_VIBRATION XVibration; @@ -1468,7 +1468,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ return SDL_SetError("XInputSetState() failed"); } } -#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!rumbled && ctx->wgi_correlated) { @@ -1535,12 +1535,12 @@ static HIDP_DATA *GetData(USHORT index, HIDP_DATA *data, ULONG length) { ULONG i; - /* Check to see if the data is at the expected offset */ + // Check to see if the data is at the expected offset if (index < length && data[index].DataIndex == index) { return &data[index]; } - /* Loop through the data to find it */ + // Loop through the data to find it for (i = 0; i < length; ++i) { if (data[i].DataIndex == index) { return &data[i]; @@ -1559,7 +1559,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int { RAWINPUT_DeviceContext *ctx = joystick->hwdata; #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING - /* Map new buttons and axes into game controller controls */ + // Map new buttons and axes into game controller controls static const int button_map[] = { SDL_GAMEPAD_BUTTON_SOUTH, SDL_GAMEPAD_BUTTON_EAST, @@ -1586,7 +1586,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int 0, }; Uint64 match_state = ctx->match_state; - /* Update match_state with button bit, then fall through */ + // Update match_state with button bit, then fall through #define SDL_SendJoystickButton(timestamp, joystick, button, state) \ if (button < SDL_arraysize(button_map)) { \ Uint64 button_bit = 1ull << button_map[button]; \ @@ -1594,7 +1594,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int } \ SDL_SendJoystickButton(timestamp, joystick, button, state) #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES - /* Grab high 4 bits of value, then fall through */ + // 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); \ @@ -1604,7 +1604,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int AddAxisToMatchState(axis, value); \ SDL_SendJoystickAxis(timestamp, joystick, axis, value) #endif -#endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCHING ULONG data_length = ctx->max_data_length; int i; @@ -1677,7 +1677,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int int match_axis = axis + SDL_JOYSTICK_RAWINPUT_MATCH_COUNT - joystick->naxes; \ AddAxisToMatchState(match_axis, value); \ } -#endif /* SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS if (ctx->trigger_hack) { SDL_bool has_trigger_data = SDL_FALSE; @@ -1685,17 +1685,17 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int int right_trigger = joystick->naxes - 1; #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - /* Prefer XInput over WindowsGamingInput, it continues to provide data in the background */ + // Prefer XInput over WindowsGamingInput, it continues to provide data in the background if (!has_trigger_data && ctx->xinput_enabled && ctx->xinput_correlated) { has_trigger_data = SDL_TRUE; } -#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!has_trigger_data && ctx->wgi_correlated) { has_trigger_data = SDL_TRUE; } -#endif /* SDL_JOYSTICK_RAWINPUT_WGI */ +#endif // SDL_JOYSTICK_RAWINPUT_WGI #ifndef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS if (!has_trigger_data) @@ -1711,7 +1711,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int AddTriggerToMatchState(left_trigger, left_value); AddTriggerToMatchState(right_trigger, right_value); if (!has_trigger_data) -#endif /* SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS { SDL_SendJoystickAxis(timestamp, joystick, (Uint8)left_trigger, left_value); SDL_SendJoystickAxis(timestamp, joystick, (Uint8)right_trigger, right_value); @@ -1757,12 +1757,12 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) #else xinput_correlated = SDL_FALSE; #endif - /* Parallel logic to WINDOWS_XINPUT below */ + // Parallel logic to WINDOWS_XINPUT below RAWINPUT_UpdateWindowsGamingInput(); if (ctx->wgi_correlated && !joystick->low_frequency_rumble && !joystick->high_frequency_rumble && !joystick->left_trigger_rumble && !joystick->right_trigger_rumble) { - /* We have been previously correlated, ensure we are still matching, see comments in XINPUT section */ + // We have been previously correlated, ensure we are still matching, see comments in XINPUT section if (RAWINPUT_WindowsGamingInputSlotMatches(&match_state_xinput, ctx->wgi_slot, xinput_correlated)) { ctx->wgi_uncorrelate_count = 0; } else { @@ -1778,7 +1778,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) RAWINPUT_MarkWindowsGamingInputSlotFree(ctx->wgi_slot); ctx->wgi_correlated = SDL_FALSE; ctx->wgi_correlation_count = 0; - /* Force release of Guide button, it can't possibly be down on this device now. */ + // Force release of Guide button, it can't possibly be down on this device now. /* It gets left down if we were actually correlated incorrectly and it was released on the WindowsGamingInput device but we didn't get a state packet. */ if (ctx->guide_hack) { @@ -1793,23 +1793,23 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) Uint8 correlation_id = 0; WindowsGamingInputGamepadState *slot_idx = NULL; if (RAWINPUT_GuessWindowsGamingInputSlot(&match_state_xinput, &correlation_id, &slot_idx, xinput_correlated)) { - /* we match exactly one WindowsGamingInput device */ + // we match exactly one WindowsGamingInput device /* Probably can do without wgi_correlation_count, just check and clear wgi_slot to NULL, unless we need even more frames to be sure. */ if (ctx->wgi_correlation_count && ctx->wgi_slot == slot_idx) { - /* was correlated previously, and still the same device */ + // was correlated previously, and still the same device if (ctx->wgi_correlation_id + 1 == correlation_id) { - /* no one else was correlated in the meantime */ + // no one else was correlated in the meantime new_correlation_count = ctx->wgi_correlation_count + 1; if (new_correlation_count == 2) { - /* correlation stayed steady and uncontested across multiple frames, guaranteed match */ + // correlation stayed steady and uncontested across multiple frames, guaranteed match ctx->wgi_correlated = SDL_TRUE; #ifdef DEBUG_RAWINPUT SDL_Log("Correlated joystick %d to WindowsGamingInput device #%d\n", joystick->instance_id, slot_idx); #endif correlated = SDL_TRUE; RAWINPUT_MarkWindowsGamingInputSlotUsed(ctx->wgi_slot, ctx); - /* If the generalized Guide button was using us, it doesn't need to anymore */ + // If the generalized Guide button was using us, it doesn't need to anymore if (guide_button_candidate.joystick == joystick) { guide_button_candidate.joystick = NULL; } @@ -1818,32 +1818,32 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) } } } else { - /* someone else also possibly correlated to this device, start over */ + // someone else also possibly correlated to this device, start over new_correlation_count = 1; } } else { - /* new possible correlation */ + // new possible correlation new_correlation_count = 1; ctx->wgi_slot = slot_idx; } ctx->wgi_correlation_id = correlation_id; } else { - /* Match multiple WindowsGamingInput devices, or none (possibly due to no buttons pressed) */ + // Match multiple WindowsGamingInput devices, or none (possibly due to no buttons pressed) } } ctx->wgi_correlation_count = new_correlation_count; } else { correlated = SDL_TRUE; } -#endif /* SDL_JOYSTICK_RAWINPUT_WGI */ +#endif // SDL_JOYSTICK_RAWINPUT_WGI #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - /* Parallel logic to WINDOWS_GAMING_INPUT above */ + // Parallel logic to WINDOWS_GAMING_INPUT above if (ctx->xinput_enabled) { RAWINPUT_UpdateXInput(); if (ctx->xinput_correlated && !joystick->low_frequency_rumble && !joystick->high_frequency_rumble) { - /* We have been previously correlated, ensure we are still matching */ + // We have been previously correlated, ensure we are still matching /* This is required to deal with two (mostly) un-preventable mis-correlation situations: A) Since the HID data stream does not provide an initial state (but polling XInput does), if we open 5 controllers (#1-4 XInput mapped, #5 is not), and controller 1 had the A button down (and we don't @@ -1874,7 +1874,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) RAWINPUT_MarkXInputSlotFree(ctx->xinput_slot); ctx->xinput_correlated = SDL_FALSE; ctx->xinput_correlation_count = 0; - /* Force release of Guide button, it can't possibly be down on this device now. */ + // Force release of Guide button, it can't possibly be down on this device now. /* It gets left down if we were actually correlated incorrectly and it was released on the XInput device but we didn't get a state packet. */ if (ctx->guide_hack) { @@ -1889,23 +1889,23 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) Uint8 correlation_id = 0; Uint8 slot_idx = 0; if (RAWINPUT_GuessXInputSlot(&match_state_xinput, &correlation_id, &slot_idx)) { - /* we match exactly one XInput device */ + // we match exactly one XInput device /* Probably can do without xinput_correlation_count, just check and clear xinput_slot to ANY, unless we need even more frames to be sure */ if (ctx->xinput_correlation_count && ctx->xinput_slot == slot_idx) { - /* was correlated previously, and still the same device */ + // was correlated previously, and still the same device if (ctx->xinput_correlation_id + 1 == correlation_id) { - /* no one else was correlated in the meantime */ + // no one else was correlated in the meantime new_correlation_count = ctx->xinput_correlation_count + 1; if (new_correlation_count == 2) { - /* correlation stayed steady and uncontested across multiple frames, guaranteed match */ + // correlation stayed steady and uncontested across multiple frames, guaranteed match ctx->xinput_correlated = SDL_TRUE; #ifdef DEBUG_RAWINPUT SDL_Log("Correlated joystick %d to XInput device #%d\n", joystick->instance_id, slot_idx); #endif correlated = SDL_TRUE; RAWINPUT_MarkXInputSlotUsed(ctx->xinput_slot); - /* If the generalized Guide button was using us, it doesn't need to anymore */ + // If the generalized Guide button was using us, it doesn't need to anymore if (guide_button_candidate.joystick == joystick) { guide_button_candidate.joystick = NULL; } @@ -1914,17 +1914,17 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) } } } else { - /* someone else also possibly correlated to this device, start over */ + // someone else also possibly correlated to this device, start over new_correlation_count = 1; } } else { - /* new possible correlation */ + // new possible correlation new_correlation_count = 1; ctx->xinput_slot = slot_idx; } ctx->xinput_correlation_id = correlation_id; } else { - /* Match multiple XInput devices, or none (possibly due to no buttons pressed) */ + // Match multiple XInput devices, or none (possibly due to no buttons pressed) } } ctx->xinput_correlation_count = new_correlation_count; @@ -1932,11 +1932,11 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) correlated = SDL_TRUE; } } -#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT_XINPUT - /* Poll for trigger data once (not per-state-packet) */ + // Poll for trigger data once (not per-state-packet) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - /* Prefer XInput over WindowsGamingInput, it continues to provide data in the background */ + // Prefer XInput over WindowsGamingInput, it continues to provide data in the background if (!has_trigger_data && ctx->xinput_enabled && ctx->xinput_correlated) { RAWINPUT_UpdateXInput(); if (xinput_state[ctx->xinput_slot].connected) { @@ -1946,7 +1946,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) if (ctx->guide_hack || ctx->trigger_hack) { timestamp = SDL_GetTicksNS(); } else { - /* timestamp won't be used */ + // timestamp won't be used timestamp = 0; } @@ -1991,19 +1991,19 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) SDL_SendJoystickPowerInfo(joystick, state, percent); } } -#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT_XINPUT #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 */ + RAWINPUT_UpdateWindowsGamingInput(); // May detect disconnect / cause uncorrelation + if (ctx->wgi_correlated) { // Still connected struct __x_ABI_CWindows_CGaming_CInput_CGamepadReading *state = &ctx->wgi_slot->state; Uint64 timestamp; if (ctx->guide_hack || ctx->trigger_hack) { timestamp = SDL_GetTicksNS(); } else { - /* timestamp won't be used */ + // timestamp won't be used timestamp = 0; } @@ -2017,7 +2017,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) has_trigger_data = SDL_TRUE; } } -#endif /* SDL_JOYSTICK_RAWINPUT_WGI */ +#endif // SDL_JOYSTICK_RAWINPUT_WGI if (!correlated) { if (!guide_button_candidate.joystick || @@ -2027,7 +2027,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) guide_button_candidate.last_state_packet = ctx->last_state_packet; } } -#endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */ +#endif // SDL_JOYSTICK_RAWINPUT_MATCHING } static void RAWINPUT_JoystickUpdate(SDL_Joystick *joystick) @@ -2092,7 +2092,7 @@ int RAWINPUT_RegisterNotifications(HWND hWnd) for (i = 0; i < SDL_arraysize(subscribed_devices); i++) { rid[i].usUsagePage = USB_USAGEPAGE_GENERIC_DESKTOP; rid[i].usUsage = subscribed_devices[i]; - rid[i].dwFlags = RIDEV_DEVNOTIFY | RIDEV_INPUTSINK; /* Receive messages when in background, including device add/remove */ + rid[i].dwFlags = RIDEV_DEVNOTIFY | RIDEV_INPUTSINK; // Receive messages when in background, including device add/remove rid[i].hwndTarget = hWnd; } @@ -2227,4 +2227,4 @@ SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = { RAWINPUT_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_RAWINPUT */ +#endif // SDL_JOYSTICK_RAWINPUT diff --git a/src/joystick/windows/SDL_rawinputjoystick_c.h b/src/joystick/windows/SDL_rawinputjoystick_c.h index 510bc8ae3a..de4fc11616 100644 --- a/src/joystick/windows/SDL_rawinputjoystick_c.h +++ b/src/joystick/windows/SDL_rawinputjoystick_c.h @@ -21,12 +21,12 @@ #include "SDL_internal.h" #include "../../core/windows/SDL_windows.h" -/* Return true if the RawInput driver is enabled */ +// Return true if the RawInput driver is enabled extern SDL_bool RAWINPUT_IsEnabled(); -/* Registers for input events */ +// Registers for input events extern int RAWINPUT_RegisterNotifications(HWND hWnd); extern int RAWINPUT_UnregisterNotifications(); -/* Returns 0 if message was handled */ +// Returns 0 if message was handled extern LRESULT CALLBACK RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index 9004441dff..8c1536ee11 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -35,7 +35,7 @@ #include #ifdef ____FIReference_1_INT32_INTERFACE_DEFINED__ -/* MinGW-64 uses __FIReference_1_INT32 instead of Microsoft's __FIReference_1_int */ +// MinGW-64 uses __FIReference_1_INT32 instead of Microsoft's __FIReference_1_int #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 @@ -115,7 +115,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) UINT i, raw_device_count = 0; LONG vidpid = MAKELONG(vendor, product); - /* XInput and RawInput backends will pick up XInput-compatible devices */ + // XInput and RawInput backends will pick up XInput-compatible devices if (!SDL_XINPUT_Enabled() #ifdef SDL_JOYSTICK_RAWINPUT && !RAWINPUT_IsEnabled() @@ -124,9 +124,9 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) return SDL_FALSE; } - /* Go through RAWINPUT (WinXP and later) to find HID devices. */ + // 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); @@ -138,7 +138,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) if (raw_device_count == (UINT)-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++) { @@ -156,11 +156,11 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) (GetRawInputDeviceInfoA(raw_devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) == ((UINT)-1)) || (GetRawInputDeviceInfoA(raw_devices[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) == ((UINT)-1)) || (SDL_strstr(devName, "IG_") == NULL)) { - /* Skip non-XInput devices */ + // Skip non-XInput devices continue; } - /* First check for a simple VID/PID match. This will work for Xbox 360 controllers. */ + // First check for a simple VID/PID match. This will work for Xbox 360 controllers. if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == vidpid) { SDL_free(raw_devices); return SDL_TRUE; @@ -169,13 +169,13 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) /* For Xbox One controllers, Microsoft doesn't propagate the VID/PID down to the HID stack. * We'll have to walk the device tree upwards searching for a match for our VID/PID. */ - /* Make sure the device interface string is something we know how to parse */ - /* Example: \\?\HID#VID_045E&PID_02FF&IG_00#9&2c203035&2&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} */ + // Make sure the device interface string is something we know how to parse + // Example: \\?\HID#VID_045E&PID_02FF&IG_00#9&2c203035&2&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} if ((SDL_strstr(devName, "\\\\?\\") != devName) || (SDL_strstr(devName, "#{") == NULL)) { continue; } - /* Unescape the backslashes in the string and terminate before the GUID portion */ + // Unescape the backslashes in the string and terminate before the GUID portion for (j = 0; devName[j] != '\0'; j++) { if (devName[j] == '#') { if (devName[j + 1] == '{') { @@ -200,7 +200,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) if ((CM_Get_Device_IDA(devNode, deviceId, SDL_arraysize(deviceId), 0) == CR_SUCCESS) && (SDL_strstr(deviceId, devVidPidString) != NULL)) { - /* The VID/PID matched a parent device */ + // The VID/PID matched a parent device SDL_free(raw_devices); return SDL_TRUE; } @@ -208,7 +208,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) } SDL_free(raw_devices); -#endif /* SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT */ +#endif // SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT return SDL_FALSE; } @@ -334,7 +334,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController_AddRef(This); return S_OK; } else if (WIN_IsEqualIID(riid, &IID_IMarshal)) { - /* This seems complicated. Let's hope it doesn't happen. */ + // This seems complicated. Let's hope it doesn't happen. return E_OUTOFMEMORY; } else { return E_NOINTERFACE; @@ -351,7 +351,7 @@ static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FI { RawGameControllerDelegate *self = (RawGameControllerDelegate *)This; int rc = SDL_AtomicAdd(&self->refcount, -1) - 1; - /* Should never free the static delegate objects */ + // Should never free the static delegate objects SDL_assert(rc > 0); return rc; } @@ -391,7 +391,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde SDL_LockJoysticks(); - /* We can get delayed calls to InvokeAdded() after WGI_JoystickQuit() */ + // We can get delayed calls to InvokeAdded() after WGI_JoystickQuit() if (SDL_JoysticksQuitting() || !SDL_JoysticksInitialized()) { SDL_UnlockJoysticks(); return S_OK; @@ -420,7 +420,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde if (SUCCEEDED(hr) && wireless) { bus = SDL_HARDWARE_BUS_BLUETOOTH; - /* Fixup for Wireless Xbox 360 Controller */ + // Fixup for Wireless Xbox 360 Controller if (product == 0) { vendor = USB_VENDOR_MICROSOFT; product = USB_PRODUCT_XBOX360_XUSB_CONTROLLER; @@ -452,7 +452,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } if (!ignore_joystick && SDL_IsXInputDevice(vendor, product)) { - /* This hasn't been detected by the RAWINPUT driver yet, but it will be picked up later. */ + // This hasn't been detected by the RAWINPUT driver yet, but it will be picked up later. ignore_joystick = SDL_TRUE; } @@ -469,7 +469,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } if (!ignore_joystick) { - /* New device, add it */ + // New device, add it WindowsGamingInputControllerState *controllers = SDL_realloc(wgi.controllers, sizeof(wgi.controllers[0]) * (wgi.controller_count + 1)); if (controllers) { WindowsGamingInputControllerState *state = &controllers[wgi.controller_count]; @@ -511,7 +511,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemo SDL_LockJoysticks(); - /* Can we get delayed calls to InvokeRemoved() after WGI_JoystickQuit()? */ + // Can we get delayed calls to InvokeRemoved() after WGI_JoystickQuit()? if (!SDL_JoysticksInitialized()) { SDL_UnlockJoysticks(); return S_OK; @@ -550,8 +550,8 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemo #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable : 4028) /* formal parameter 3 different from declaration, when using older buggy WGI headers */ -#pragma warning(disable : 4113) /* formal parameter 3 different from declaration (a more specific warning added in VS 2022), when using older buggy WGI headers */ +#pragma warning(disable : 4028) // formal parameter 3 different from declaration, when using older buggy WGI headers +#pragma warning(disable : 4113) // formal parameter 3 different from declaration (a more specific warning added in VS 2022), when using older buggy WGI headers #endif static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl controller_added_vtbl = { @@ -606,7 +606,7 @@ static int WGI_JoystickInit(void) RESOLVE(WindowsDeleteString); RESOLVE(WindowsGetStringRawBuffer); #undef RESOLVE -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT #ifndef SDL_PLATFORM_WINRT { @@ -675,7 +675,7 @@ static void WGI_JoystickDetect(void) static SDL_bool WGI_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - /* We don't override any other drivers */ + // We don't override any other drivers return SDL_FALSE; } @@ -738,7 +738,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) __x_ABI_CWindows_CGaming_CInput_CIGameController_get_IsWireless(hwdata->game_controller, &wireless); } - /* Initialize the joystick capabilities */ + // Initialize the joystick capabilities if (wireless) { joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS; } else { @@ -749,7 +749,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_SwitchCount(hwdata->controller, &joystick->nhats); if (hwdata->gamepad) { - /* FIXME: Can WGI even tell us if trigger rumble is supported? */ + // FIXME: Can WGI even tell us if trigger rumble is supported? SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); } @@ -763,7 +763,7 @@ static int WGI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl if (hwdata->gamepad) { HRESULT hr; - /* Note: reusing partially filled vibration data struct */ + // Note: reusing partially filled vibration data struct hwdata->vibration.LeftMotor = (DOUBLE)low_frequency_rumble / SDL_MAX_UINT16; hwdata->vibration.RightMotor = (DOUBLE)high_frequency_rumble / SDL_MAX_UINT16; hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_put_Vibration(hwdata->gamepad, hwdata->vibration); @@ -784,7 +784,7 @@ static int WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble if (hwdata->gamepad) { HRESULT hr; - /* Note: reusing partially filled vibration data struct */ + // Note: reusing partially filled vibration data struct hwdata->vibration.LeftTrigger = (DOUBLE)left_rumble / SDL_MAX_UINT16; hwdata->vibration.RightTrigger = (DOUBLE)right_rumble / SDL_MAX_UINT16; hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_put_Vibration(hwdata->gamepad, hwdata->vibration); @@ -866,7 +866,7 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick) hwdata->timestamp = timestamp; - /* The axes are all zero when the application loses focus */ + // The axes are all zero when the application loses focus if (naxes > 0) { all_zero = SDL_TRUE; for (i = 0; i < naxes; ++i) { @@ -879,7 +879,7 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick) if (all_zero) { SDL_PrivateJoystickForceRecentering(joystick); } else { - /* FIXME: What units are the timestamp we get from GetCurrentReading()? */ + // FIXME: What units are the timestamp we get from GetCurrentReading()? timestamp = SDL_GetTicksNS(); for (i = 0; i < nbuttons; ++i) { SDL_SendJoystickButton(timestamp, joystick, (Uint8)i, buttons[i]); @@ -1045,4 +1045,4 @@ SDL_JoystickDriver SDL_WGI_JoystickDriver = { WGI_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_WGI */ +#endif // SDL_JOYSTICK_WGI diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index abcbdb0207..d42d0218a2 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -40,19 +40,19 @@ #include #endif -#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */ +#define INITGUID // Only set here, if set twice will cause mingw32 to break. #include "SDL_windowsjoystick_c.h" #include "SDL_dinputjoystick_c.h" #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_dinputhaptic_c.h" // For haptic hot plugging #ifndef DEVICE_NOTIFY_WINDOW_HANDLE #define DEVICE_NOTIFY_WINDOW_HANDLE 0x00000000 #endif -/* local variables */ +// local variables static SDL_bool s_bJoystickThread = SDL_FALSE; static SDL_Condition *s_condJoystickThread = NULL; static SDL_Mutex *s_mutexJoyStickEnum = NULL; @@ -61,7 +61,7 @@ static SDL_bool s_bJoystickThreadQuit = SDL_FALSE; static Uint64 s_lastDeviceChange = 0; 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 static SDL_bool WindowsDeviceChanged(void) @@ -92,7 +92,7 @@ typedef struct #define IDT_SDL_DEVICE_CHANGE_TIMER_1 1200 #define IDT_SDL_DEVICE_CHANGE_TIMER_2 1201 -/* windowproc for our joystick detect thread message only window, to detect any USB device addition/removal */ +// 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) { switch (msg) { @@ -101,7 +101,7 @@ static LRESULT CALLBACK SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARA case DBT_DEVICEARRIVAL: case DBT_DEVICEREMOVECOMPLETE: if (((DEV_BROADCAST_HDR *)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { - /* notify 300ms and 2 seconds later to ensure all APIs have updated status */ + // 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); } @@ -156,7 +156,7 @@ static int 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.lpfnWndProc = SDL_PrivateJoystickDetectProc; // This function is called by windows data->wincl.cbSize = sizeof(WNDCLASSEX); if (!RegisterClassEx(&data->wincl)) { @@ -196,12 +196,12 @@ static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, int lastret = 1; if (!data->messageWindow) { - return SDL_FALSE; /* device notifications require a window */ + return SDL_FALSE; // device notifications require a window } SDL_UnlockMutex(mutex); while (lastret > 0 && !WindowsDeviceChanged()) { - lastret = GetMessage(&msg, NULL, 0, 0); /* WM_QUIT causes return value of 0 */ + lastret = GetMessage(&msg, NULL, 0, 0); // WM_QUIT causes return value of 0 if (lastret > 0) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -211,7 +211,7 @@ static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, return (lastret != -1); } -#endif /* !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifndef SDL_PLATFORM_WINRT @@ -219,7 +219,7 @@ static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, static SDL_DeviceNotificationData s_notification_data; #endif -/* Function/thread to scan the system for joysticks. */ +// Function/thread to scan the system for joysticks. static int SDLCALL SDL_JoystickThread(void *_data) { #ifdef SDL_JOYSTICK_XINPUT @@ -241,10 +241,10 @@ static int SDLCALL SDL_JoystickThread(void *_data) { #endif #ifdef SDL_JOYSTICK_XINPUT - /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */ + // WM_DEVICECHANGE not working, poll for new XINPUT controllers SDL_WaitConditionTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000); if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) { - /* scan for any change in XInput devices */ + // scan for any change in XInput devices Uint8 userId; for (userId = 0; userId < XUSER_MAX_COUNT; userId++) { XINPUT_CAPABILITIES capabilities; @@ -257,9 +257,9 @@ static int SDLCALL SDL_JoystickThread(void *_data) } } #else - /* WM_DEVICECHANGE not working, no XINPUT, no point in keeping thread alive */ + // WM_DEVICECHANGE not working, no XINPUT, no point in keeping thread alive break; -#endif /* SDL_JOYSTICK_XINPUT */ +#endif // SDL_JOYSTICK_XINPUT } } @@ -272,7 +272,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) return 1; } -/* spin up the thread to detect hotplug of devices */ +// spin up the thread to detect hotplug of devices static int SDL_StartJoystickThread(void) { s_mutexJoyStickEnum = SDL_CreateMutex(); @@ -301,14 +301,14 @@ static void SDL_StopJoystickThread(void) SDL_LockMutex(s_mutexJoyStickEnum); s_bJoystickThreadQuit = SDL_TRUE; - SDL_BroadcastCondition(s_condJoystickThread); /* signal the joystick thread to quit */ + SDL_BroadcastCondition(s_condJoystickThread); // signal the joystick thread to quit SDL_UnlockMutex(s_mutexJoyStickEnum); PostThreadMessage((DWORD)SDL_GetThreadID(s_joystickThread), WM_QUIT, 0, 0); - /* Unlock joysticks while the joystick thread finishes processing messages */ + // Unlock joysticks while the joystick thread finishes processing messages SDL_AssertJoysticksLocked(); SDL_UnlockJoysticks(); - SDL_WaitThread(s_joystickThread, NULL); /* wait for it to bugger off */ + SDL_WaitThread(s_joystickThread, NULL); // wait for it to bugger off SDL_LockJoysticks(); SDL_DestroyCondition(s_condJoystickThread); @@ -320,7 +320,7 @@ static void SDL_StopJoystickThread(void) s_joystickThread = NULL; } -#endif /* !defined(SDL_PLATFORM_WINRT) */ +#endif // !defined(SDL_PLATFORM_WINRT) void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device) { @@ -365,21 +365,21 @@ static int WINDOWS_JoystickInit(void) #endif #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - /* On Xbox, force create the joystick thread for device detection (since other methods don't work */ + // On Xbox, force create the joystick thread for device detection (since other methods don't work s_bJoystickThread = SDL_TRUE; if (SDL_StartJoystickThread() < 0) { return -1; } #endif - SetWindowsDeviceChanged(); /* force a scan of the system for joysticks this first time */ + SetWindowsDeviceChanged(); // force a scan of the system for joysticks this first time WINDOWS_JoystickDetect(); return 0; } -/* return the number of joysticks that are connected right now */ +// return the number of joysticks that are connected right now static int WINDOWS_JoystickGetCount(void) { int nJoysticks = 0; @@ -392,14 +392,14 @@ static int WINDOWS_JoystickGetCount(void) return nJoysticks; } -/* detect any new joysticks being inserted into the system */ +// detect any new joysticks being inserted into the system void WINDOWS_JoystickDetect(void) { JoyStick_DeviceData *pCurList = NULL; - /* only enum the devices if the joystick thread told us something changed */ + // only enum the devices if the joystick thread told us something changed if (!WindowsDeviceChanged()) { - return; /* thread hasn't signaled, nothing to do right now. */ + return; // thread hasn't signaled, nothing to do right now. } if (s_mutexJoyStickEnum) { @@ -411,10 +411,10 @@ void WINDOWS_JoystickDetect(void) pCurList = SYS_Joystick; SYS_Joystick = NULL; - /* Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. */ + // Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. SDL_DINPUT_JoystickDetect(&pCurList); - /* Look for XInput devices. Do this last, so they're first in the final list. */ + // Look for XInput devices. Do this last, so they're first in the final list. SDL_XINPUT_JoystickDetect(&pCurList); if (s_mutexJoyStickEnum) { @@ -498,7 +498,7 @@ static int WINDOWS_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) } if (device->bXInputDevice) { - /* The slot for XInput devices can change as controllers are seated */ + // The slot for XInput devices can change as controllers are seated return SDL_XINPUT_GetSteamVirtualGamepadSlot(device->XInputUserId); } else { return device->steam_virtual_gamepad_slot; @@ -521,7 +521,7 @@ static void WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_in { } -/* return the stable device guid for this device index */ +// return the stable device guid for this device index static SDL_GUID WINDOWS_JoystickGetDeviceGUID(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; @@ -534,7 +534,7 @@ static SDL_GUID WINDOWS_JoystickGetDeviceGUID(int device_index) return device->guid; } -/* Function to perform the mapping between current device instance and this joysticks instance id */ +// Function to perform the mapping between current device instance and this joysticks instance id static SDL_JoystickID WINDOWS_JoystickGetDeviceInstanceID(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; @@ -561,7 +561,7 @@ static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) device = device->pNext; } - /* allocate memory for system specific hardware data */ + // allocate memory for system specific hardware data joystick->hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(struct joystick_hwdata)); if (!joystick->hwdata) { return -1; @@ -617,7 +617,7 @@ static void WINDOWS_JoystickUpdate(SDL_Joystick *joystick) } } -/* Function to close a joystick after use */ +// Function to close a joystick after use static void WINDOWS_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata->bXInputDevice) { @@ -629,7 +629,7 @@ static void WINDOWS_JoystickClose(SDL_Joystick *joystick) SDL_free(joystick->hwdata); } -/* Function to perform any system-specific joystick related cleanup */ +// Function to perform any system-specific joystick related cleanup void WINDOWS_JoystickQuit(void) { JoyStick_DeviceData *device = SYS_Joystick; @@ -694,8 +694,8 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = { #else #ifdef SDL_JOYSTICK_RAWINPUT -/* The RAWINPUT driver needs the device notification setup above */ +// The RAWINPUT driver needs the device notification setup above #error SDL_JOYSTICK_RAWINPUT requires SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT #endif -#endif /* SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT */ +#endif // SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT diff --git a/src/joystick/windows/SDL_windowsjoystick_c.h b/src/joystick/windows/SDL_windowsjoystick_c.h index 4c8dcf28da..75f9c2a72f 100644 --- a/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/src/joystick/windows/SDL_windowsjoystick_c.h @@ -24,9 +24,9 @@ #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++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -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 { @@ -57,17 +57,17 @@ typedef enum Type typedef struct input_t { - /* DirectInput offset for this input type: */ + // DirectInput offset for this input type: DWORD ofs; - /* Button, axis or hat: */ + // Button, axis or hat: Type type; - /* SDL input offset: */ + // SDL input offset: Uint8 num; } input_t; -/* The private structure used to keep track of a joystick */ +// The private structure used to keep track of a joystick struct joystick_hwdata { SDL_GUID guid; @@ -85,9 +85,9 @@ struct joystick_hwdata LPDIRECTINPUTEFFECT ffeffect_ref; #endif - 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 */ + 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 DWORD dwPacketNumber; }; @@ -97,7 +97,7 @@ extern const DIDATAFORMAT SDL_c_dfDIJoystick2; extern void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 2489b7bb37..6b4a0d2bd4 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -29,7 +29,7 @@ #include "SDL_rawinputjoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -49,7 +49,7 @@ int SDL_XINPUT_JoystickInit(void) s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE); if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) { - s_bXInputEnabled = SDL_FALSE; /* oh well. */ + s_bXInputEnabled = SDL_FALSE; // oh well. } return 0; } @@ -97,7 +97,7 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui SDL_XINPUT_CAPABILITIES_EX capabilities; if (!XINPUTGETCAPABILITIESEX || XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) != ERROR_SUCCESS) { - /* Use a generic VID/PID representing an XInput controller */ + // Use a generic VID/PID representing an XInput controller if (pVID) { *pVID = USB_VENDOR_MICROSOFT; } @@ -107,7 +107,7 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui return SDL_FALSE; } - /* Fixup for Wireless Xbox 360 Controller */ + // Fixup for Wireless Xbox 360 Controller if (capabilities.ProductId == 0 && capabilities.Capabilities.Flags & XINPUT_CAPS_WIRELESS) { capabilities.VendorId = USB_VENDOR_MICROSOFT; capabilities.ProductId = USB_PRODUCT_XBOX360_XUSB_CONTROLLER; @@ -149,7 +149,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC #ifdef SDL_JOYSTICK_RAWINPUT if (RAWINPUT_IsEnabled()) { - /* The raw input driver handles more than 4 controllers, so prefer that when available */ + // The raw input driver handles more than 4 controllers, so prefer that when available /* We do this check here rather than at the top of SDL_XINPUT_JoystickDetect() because we need to check XInput state before RAWINPUT gets a hold of the device, otherwise when a controller is connected via the wireless adapter, it will shut down at the @@ -167,7 +167,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC while (pNewJoystick) { if (pNewJoystick->bXInputDevice && (pNewJoystick->XInputUserId == userid) && (pNewJoystick->SubType == SubType)) { - /* if we are replacing the front of the list then update it */ + // if we are replacing the front of the list then update it if (pNewJoystick == *pContext) { *pContext = pNewJoystick->pNext; } else if (pPrevJoystick) { @@ -176,7 +176,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - return; /* already in the list. */ + return; // already in the list. } pPrevJoystick = pNewJoystick; @@ -185,7 +185,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData)); if (!pNewJoystick) { - return; /* better luck next time? */ + return; // better luck next time? } name = GetXInputName(userid, SubType); @@ -194,7 +194,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name); if (!pNewJoystick->joystickname) { SDL_free(pNewJoystick); - return; /* better luck next time? */ + return; // better luck next time? } (void)SDL_snprintf(pNewJoystick->path, sizeof(pNewJoystick->path), "XInput#%u", userid); pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, vendor, product, version, NULL, name, 'x', SubType); @@ -222,7 +222,7 @@ void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) return; } - /* iterate in reverse, so these are in the final list in ascending numeric order. */ + // iterate in reverse, so these are in the final list in ascending numeric order. for (iuserid = XUSER_MAX_COUNT - 1; iuserid >= 0; iuserid--) { const Uint8 userid = (Uint8)iuserid; XINPUT_CAPABILITIES capabilities; @@ -240,7 +240,7 @@ SDL_bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 versio return SDL_FALSE; } - /* iterate in reverse, so these are in the final list in ascending numeric order. */ + // iterate in reverse, so these are in the final list in ascending numeric order. for (iuserid = 0; iuserid < XUSER_MAX_COUNT; ++iuserid) { const Uint8 userid = (Uint8)iuserid; Uint16 slot_vendor; @@ -277,7 +277,7 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS); joystick->hwdata->userid = userId; - /* The XInput API has a hard coded button/axis mapping, so we just match it */ + // The XInput API has a hard coded button/axis mapping, so we just match it joystick->naxes = 6; joystick->nbuttons = 11; joystick->nhats = 1; @@ -399,10 +399,10 @@ void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick) } #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - /* XInputOnGameInput doesn't ever change dwPacketNumber, so have to just update every frame */ + // XInputOnGameInput doesn't ever change dwPacketNumber, so have to just update every frame UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation); #else - /* only fire events if the data changed from last time */ + // only fire events if the data changed from last time if (XInputState.dwPacketNumber && XInputState.dwPacketNumber != joystick->hwdata->dwPacketNumber) { UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation); joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber; @@ -422,12 +422,12 @@ void SDL_XINPUT_JoystickQuit(void) } } -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#else /* !SDL_JOYSTICK_XINPUT */ +#else // !SDL_JOYSTICK_XINPUT typedef struct JoyStick_DeviceData JoyStick_DeviceData; @@ -472,4 +472,4 @@ void SDL_XINPUT_JoystickQuit(void) { } -#endif /* SDL_JOYSTICK_XINPUT */ +#endif // SDL_JOYSTICK_XINPUT diff --git a/src/joystick/windows/SDL_xinputjoystick_c.h b/src/joystick/windows/SDL_xinputjoystick_c.h index b244ced3b3..c7ce1bcb9f 100644 --- a/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/src/joystick/windows/SDL_xinputjoystick_c.h @@ -22,7 +22,7 @@ #include "../../core/windows/SDL_xinput.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -38,7 +38,7 @@ extern void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick); extern void SDL_XINPUT_JoystickQuit(void); extern int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index b7a37a4b25..e6f7012d95 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -23,7 +23,7 @@ #ifdef SDL_LOADSO_DLOPEN /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ +// System dependent library loading routines #include #include @@ -56,7 +56,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) { void *symbol = dlsym(handle, name); if (!symbol) { - /* prepend an underscore for platforms that need that. */ + // prepend an underscore for platforms that need that. SDL_bool isstack; size_t len = SDL_strlen(name) + 1; char *_name = SDL_small_alloc(char, len + 1, &isstack); @@ -79,4 +79,4 @@ void SDL_UnloadObject(void *handle) } } -#endif /* SDL_LOADSO_DLOPEN */ +#endif // SDL_LOADSO_DLOPEN diff --git a/src/loadso/dummy/SDL_sysloadso.c b/src/loadso/dummy/SDL_sysloadso.c index 476d844778..34de994b9e 100644 --- a/src/loadso/dummy/SDL_sysloadso.c +++ b/src/loadso/dummy/SDL_sysloadso.c @@ -23,7 +23,7 @@ #if defined(SDL_LOADSO_DUMMY) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ +// System dependent library loading routines void *SDL_LoadObject(const char *sofile) { @@ -41,7 +41,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - /* no-op. */ + // no-op. } -#endif /* SDL_LOADSO_DUMMY */ +#endif // SDL_LOADSO_DUMMY diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index 0c2b3e0d48..e4081af2ee 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -23,7 +23,7 @@ #ifdef SDL_LOADSO_WINDOWS /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ +// System dependent library loading routines #include "../../core/windows/SDL_windows.h" @@ -48,7 +48,7 @@ void *SDL_LoadObject(const char *sofile) #endif SDL_free(wstr); - /* Generate an error message if all loads failed */ + // Generate an error message if all loads failed if (!handle) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); @@ -77,4 +77,4 @@ void SDL_UnloadObject(void *handle) } } -#endif /* SDL_LOADSO_WINDOWS */ +#endif // SDL_LOADSO_WINDOWS diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index 6b3c802239..d14bad6517 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -39,22 +39,22 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) ++csv; } if (!csv || !*csv) { - return NULL; /* nothing to report */ + return NULL; // nothing to report } - num_locales = 1; /* at least one */ + num_locales = 1; // at least one for (ptr = csv; *ptr; ptr++) { if (*ptr == ',') { num_locales++; } } - slen = ((size_t)(ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */ + slen = ((size_t)(ptr - csv)) + 1; // SDL_strlen(csv) + 1 alloclen = ((num_locales + 1) * sizeof(SDL_Locale *)) + (num_locales * sizeof(SDL_Locale)) + slen; retval = (SDL_Locale **)SDL_calloc(1, alloclen); if (!retval) { - return NULL; /* oh well */ + return NULL; // oh well } loc = (SDL_Locale *)(retval + (num_locales + 1)); ptr = (char *)(loc + num_locales); @@ -62,9 +62,9 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) i = 0; retval[i++] = loc; - while (SDL_TRUE) { /* parse out the string */ + while (SDL_TRUE) { // parse out the string while (SDL_isspace(*ptr)) { - ptr++; /* skip whitespace. */ + ptr++; // skip whitespace. } if (*ptr == '\0') { @@ -77,7 +77,7 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) *(ptr++) = '\0'; loc->country = ptr; } else if (SDL_isspace(ch)) { - *(ptr++) = '\0'; /* trim ending whitespace and keep going. */ + *(ptr++) = '\0'; // trim ending whitespace and keep going. } else if (ch == ',') { *(ptr++) = '\0'; loc++; @@ -86,7 +86,7 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) } else if (ch == '\0') { break; } else { - ptr++; /* just keep going, still a valid string */ + ptr++; // just keep going, still a valid string } } } @@ -100,7 +100,7 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) SDL_Locale **SDL_GetPreferredLocales(int *count) { - 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)); diff --git a/src/locale/SDL_syslocale.h b/src/locale/SDL_syslocale.h index 0bcc0ad941..7ba69704dd 100644 --- a/src/locale/SDL_syslocale.h +++ b/src/locale/SDL_syslocale.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the system specific header for the SDL locale API */ +// This is the system specific header for the SDL locale API #ifdef __cplusplus extern "C" { diff --git a/src/locale/dummy/SDL_syslocale.c b/src/locale/dummy/SDL_syslocale.c index 769dcc8fd1..55980f8b29 100644 --- a/src/locale/dummy/SDL_syslocale.c +++ b/src/locale/dummy/SDL_syslocale.c @@ -24,6 +24,6 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { - /* dummy implementation. Caller already zero'd out buffer. */ + // dummy implementation. Caller already zero'd out buffer. return SDL_Unsupported(); } diff --git a/src/locale/emscripten/SDL_syslocale.c b/src/locale/emscripten/SDL_syslocale.c index fe06151a41..c9ee9a55bf 100644 --- a/src/locale/emscripten/SDL_syslocale.c +++ b/src/locale/emscripten/SDL_syslocale.c @@ -26,7 +26,7 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off EM_ASM({ var buf = $0; var buflen = $1; @@ -42,14 +42,14 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } if (list === undefined) { - return; /* we've got nothing. */ + return; // we've got nothing. } - var str = ""; /* Can't do list.join() because we need to fit in buflen. */ + var str = ""; // Can't do list.join() because we need to fit in buflen. for (var i = 0; i < list.length; i++) { var item = list[i]; if ((str.length + item.length + 1) > buflen) { - break; /* don't add, we're out of space. */ + break; // don't add, we're out of space. } if (str.length > 0) { str += ","; @@ -59,13 +59,13 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) str = str.replace(/-/g, "_"); if (buflen > str.length) { - buflen = str.length; /* clamp to size of string. */ + buflen = str.length; // clamp to size of string. } for (var i = 0; i < buflen; i++) { - setValue(buf + i, str.charCodeAt(i), "i8"); /* fill in C array. */ + setValue(buf + i, str.charCodeAt(i), "i8"); // fill in C array. } }, buf, buflen); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on return 0; } diff --git a/src/locale/n3ds/SDL_syslocale.c b/src/locale/n3ds/SDL_syslocale.c index 7bbde70d47..465e7c4e02 100644 --- a/src/locale/n3ds/SDL_syslocale.c +++ b/src/locale/n3ds/SDL_syslocale.c @@ -24,14 +24,14 @@ #include <3ds.h> -/* Used when the CFGU fails to work. */ +// Used when the CFGU fails to work. #define BAD_LOCALE 255 static u8 GetLocaleIndex(void); int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { - /* The 3DS only supports these 12 languages, only one can be active at a time */ + // 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", "it_IT", "es_ES", "zh_CN", "ko_KR", "nl_NL", "pt_PT", "ru_RU", "zh_TW" }; diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index a03849dd4b..639e1f30b8 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -26,24 +26,24 @@ 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) { *ptr = '\0'; } - ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ + ptr = SDL_strchr(str, '@'); // chop off extra bits if specified. if (ptr) { *ptr = '\0'; } - /* The "C" locale isn't useful for our needs, ignore it if you see it. */ + // The "C" locale isn't useful for our needs, ignore it if you see it. if ((str[0] == 'C') && (str[1] == '\0')) { return; } 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); } @@ -53,7 +53,7 @@ static void normalize_locales(char *dst, char *src, size_t buflen) { char *ptr; - /* entries are separated by colons */ + // entries are separated by colons while ((ptr = SDL_strchr(src, ':')) != NULL) { *ptr = '\0'; normalize_locale_str(dst, src, buflen); @@ -64,7 +64,7 @@ static void normalize_locales(char *dst, char *src, size_t buflen) int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { - /* !!! FIXME: should we be using setlocale()? Or some D-Bus thing? */ + // !!! FIXME: should we be using setlocale()? Or some D-Bus thing? SDL_bool isstack; const char *envr; char *tmp; @@ -77,13 +77,13 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) *tmp = '\0'; - /* LANG is the primary locale (maybe) */ + // LANG is the primary locale (maybe) envr = SDL_getenv("LANG"); if (envr) { SDL_strlcpy(tmp, envr, buflen); } - /* fallback languages */ + // fallback languages envr = SDL_getenv("LANGUAGE"); if (envr) { if (*tmp) { diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index ec8d44ad13..df3ae06e06 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -31,7 +31,7 @@ typedef BOOL(WINAPI *pfnGetUserPreferredUILanguages)(DWORD, PULONG, WCHAR *, PUL static pfnGetUserPreferredUILanguages pGetUserPreferredUILanguages = NULL; static HMODULE kernel32 = 0; -/* this is the fallback for WinXP...one language, not a list. */ +// this is the fallback for WinXP...one language, not a list. static void SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) { char lang[16]; @@ -53,7 +53,7 @@ static void SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) } } -/* this works on Windows Vista and later. */ +// this works on Windows Vista and later. static int SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) { ULONG numlangs = 0; @@ -70,23 +70,23 @@ static int 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); 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); @@ -103,9 +103,9 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } if (!pGetUserPreferredUILanguages) { - 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. } return 0; } diff --git a/src/locale/winrt/SDL_syslocale.c b/src/locale/winrt/SDL_syslocale.c index 8e0550d57e..6275556f9b 100644 --- a/src/locale/winrt/SDL_syslocale.c +++ b/src/locale/winrt/SDL_syslocale.c @@ -24,7 +24,7 @@ #include "../SDL_syslocale.h" -/*using namespace Windows::Graphics::Display;*/ +// using namespace Windows::Graphics::Display; #include int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) @@ -32,7 +32,7 @@ int 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? */ + // !!! FIXME: do we not have GetUserPreferredUILanguages on WinPhone or UWP? #if SDL_WINAPI_FAMILY_PHONE ret = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME, wbuffer, SDL_arraysize(wbuffer)); #else @@ -40,14 +40,14 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) #endif if (ret > 0) { - /* Need to convert LPWSTR to LPSTR, that is wide char to char. */ + // Need to convert LPWSTR to LPSTR, that is wide char to char. int i; 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. } } return 0; diff --git a/src/main/SDL_runapp.c b/src/main/SDL_runapp.c index 97bcf2821d..c23219893e 100644 --- a/src/main/SDL_runapp.c +++ b/src/main/SDL_runapp.c @@ -30,7 +30,7 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv if(!argv) { - /* make sure argv isn't NULL, in case some user code doesn't like that */ + // make sure argv isn't NULL, in case some user code doesn't like that static char dummyargv0[] = { 'S', 'D', 'L', '_', 'a', 'p', 'p', '\0' }; static char* argvdummy[2] = { dummyargv0, NULL }; argc = 1; diff --git a/src/main/gdk/SDL_sysmain_runapp.cpp b/src/main/gdk/SDL_sysmain_runapp.cpp index 911293ec25..6e8197d082 100644 --- a/src/main/gdk/SDL_sysmain_runapp.cpp +++ b/src/main/gdk/SDL_sysmain_runapp.cpp @@ -27,10 +27,10 @@ extern "C" { } #include #include -#include /* CommandLineToArgvW() */ +#include // CommandLineToArgvW() #include -/* Pop up an out of memory message, returns to Windows */ +// Pop up an out of memory message, returns to Windows static BOOL OutOfMemory(void) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); @@ -58,7 +58,7 @@ int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved) * SDL_free() to use the same allocator after SDL_main() returns. */ - /* Parse it into argv and argc */ + // Parse it into argv and argc argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); if (argv == NULL) { return OutOfMemory(); @@ -92,7 +92,7 @@ int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved) XTaskQueueSetCurrentProcessTaskQueue(taskQueue); - /* Try to get the title ID and initialize Xbox Live */ + // Try to get the title ID and initialize Xbox Live hr = XGameGetXboxTitleId(&titleid); if (SUCCEEDED(hr)) { SDL_zero(xblArgs); @@ -110,13 +110,13 @@ int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved) return -1; } - /* Run the application main() code */ + // Run the application main() code result = mainFunction(argc, argv); GDK_UnregisterChangeNotifications(); - /* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */ - /* Terminate the task queue and dispatch any pending tasks */ + // !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? + // Terminate the task queue and dispatch any pending tasks XTaskQueueTerminate(taskQueue, false, nullptr, nullptr); while (XTaskQueueDispatch(taskQueue, XTaskQueuePort::Completion, 0)) ; @@ -137,7 +137,7 @@ int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved) result = -1; } - /* Free argv, to avoid memory leak */ + // Free argv, to avoid memory leak for (i = 0; i < argc; ++i) { HeapFree(GetProcessHeap(), 0, argv[i]); } diff --git a/src/main/n3ds/SDL_sysmain_runapp.c b/src/main/n3ds/SDL_sysmain_runapp.c index 5486a21948..12c0143775 100644 --- a/src/main/n3ds/SDL_sysmain_runapp.c +++ b/src/main/n3ds/SDL_sysmain_runapp.c @@ -28,21 +28,21 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) { int result; - /* init */ + // init osSetSpeedupEnable(true); romfsInit(); SDL_SetMainReady(); result = mainFunction(argc, argv); - /* quit */ + // quit romfsExit(); return result; } #ifdef __cplusplus -} /* extern "C" */ +} // extern "C" #endif #endif diff --git a/src/main/ngage/SDL_sysmain_runapp.cpp b/src/main/ngage/SDL_sysmain_runapp.cpp index ebff5e863a..c675b13039 100644 --- a/src/main/ngage/SDL_sysmain_runapp.cpp +++ b/src/main/ngage/SDL_sysmain_runapp.cpp @@ -20,25 +20,25 @@ int SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * reserved) { (void)argc_; (void)argv_; (void)reserved; - /* Get the clean-up stack */ + // Get the clean-up stack CTrapCleanup *cleanup = CTrapCleanup::New(); - /* Arrange for multi-threaded operation */ + // Arrange for multi-threaded operation SpawnPosixServerThread(); - /* Get args and environment */ + // Get args and environment int argc = 0; char **argv = 0; char **envp = 0; __crt0(argc, argv, envp); - /* Start the application! */ + // Start the application! - /* Create stdlib */ + // Create stdlib _REENT; - /* Set process and thread priority and name */ + // Set process and thread priority and name RThread currentThread; RProcess thisProcess; @@ -48,7 +48,7 @@ int SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * rese currentThread.SetProcessPriority(EPriorityLow); currentThread.SetPriority(EPriorityMuchLess); - /* Increase heap size */ + // Increase heap size RHeap *newHeap = NULL; RHeap *oldHeap = NULL; TInt heapSize = 7500000; @@ -61,7 +61,7 @@ int SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * rese goto cleanup; } else { oldHeap = User::SwitchHeap(newHeap); - /* Call stdlib main */ + // Call stdlib main SDL_SetMainReady(); ret = mainFunction(argc, argv); } diff --git a/src/main/ps2/SDL_sysmain_runapp.c b/src/main/ps2/SDL_sysmain_runapp.c index 9bd627ac22..4e6d6a5ed1 100644 --- a/src/main/ps2/SDL_sysmain_runapp.c +++ b/src/main/ps2/SDL_sysmain_runapp.c @@ -23,7 +23,7 @@ #ifdef SDL_PLATFORM_PS2 -/* SDL_RunApp() code for PS2 based on SDL_ps2_main.c, fjtrujy@gmail.com */ +// SDL_RunApp() code for PS2 based on SDL_ps2_main.c, fjtrujy@gmail.com #include #include @@ -81,4 +81,4 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv return res; } -#endif /* SDL_PLATFORM_PS2 */ +#endif // SDL_PLATFORM_PS2 diff --git a/src/main/psp/SDL_sysmain_runapp.c b/src/main/psp/SDL_sysmain_runapp.c index 3247d5f991..9e5675d35f 100644 --- a/src/main/psp/SDL_sysmain_runapp.c +++ b/src/main/psp/SDL_sysmain_runapp.c @@ -23,7 +23,7 @@ #ifdef SDL_PLATFORM_PSP -/* SDL_RunApp() for PSP based on SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 */ +// SDL_RunApp() for PSP based on SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 #include #include @@ -79,4 +79,4 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv return mainFunction(argc, argv); } -#endif /* SDL_PLATFORM_PSP */ +#endif // SDL_PLATFORM_PSP diff --git a/src/main/windows/SDL_sysmain_runapp.c b/src/main/windows/SDL_sysmain_runapp.c index 426564e0cc..3ca4183b2f 100644 --- a/src/main/windows/SDL_sysmain_runapp.c +++ b/src/main/windows/SDL_sysmain_runapp.c @@ -27,9 +27,9 @@ /* Win32-specific SDL_RunApp(), which does most of the SDL_main work, based on SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98 */ -#include /* CommandLineToArgvW() */ +#include // CommandLineToArgvW() -/* Pop up an out of memory message, returns to Windows */ +// Pop up an out of memory message, returns to Windows static int OutOfMemory(void) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); @@ -57,7 +57,7 @@ int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_func mainFu * SDL_free() to use the same allocator after SDL_main() returns. */ - /* Parse it into argv and argc */ + // Parse it into argv and argc argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); if (!argv) { return OutOfMemory(); @@ -84,10 +84,10 @@ int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_func mainFu SDL_SetMainReady(); - /* Run the application main() code */ + // Run the application main() code result = mainFunction(argc, argv); - /* Free argv, to avoid memory leak */ + // Free argv, to avoid memory leak for (i = 0; i < argc; ++i) { HeapFree(GetProcessHeap(), 0, argv[i]); } @@ -96,4 +96,4 @@ int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_func mainFu return result; } -#endif /* SDL_PLATFORM_WIN32 */ +#endif // SDL_PLATFORM_WIN32 diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index 8038bc732f..eba867feb5 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -40,4 +40,4 @@ int SDL_SYS_OpenURL(const char *url) } } -#endif /* SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS diff --git a/src/misc/macos/SDL_sysurl.m b/src/misc/macos/SDL_sysurl.m index 9a098f6499..18b2891202 100644 --- a/src/misc/macos/SDL_sysurl.m +++ b/src/misc/macos/SDL_sysurl.m @@ -36,4 +36,4 @@ int SDL_SYS_OpenURL(const char *url) } } -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS diff --git a/src/misc/unix/SDL_sysurl.c b/src/misc/unix/SDL_sysurl.c index b9c910e07a..374463b459 100644 --- a/src/misc/unix/SDL_sysurl.c +++ b/src/misc/unix/SDL_sysurl.c @@ -36,34 +36,34 @@ extern char **environ; int SDL_SYS_OpenURL(const char *url) { const pid_t pid1 = fork(); - if (pid1 == 0) { /* child process */ + if (pid1 == 0) { // child process #ifdef USE_POSIX_SPAWN pid_t pid2; const char *args[] = { "xdg-open", url, NULL }; - /* Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam */ + // Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam unsetenv("LD_PRELOAD"); if (posix_spawnp(&pid2, args[0], NULL, NULL, (char **)args, environ) == 0) { - /* Child process doesn't wait for possibly-blocking grandchild. */ + // Child process doesn't wait for possibly-blocking grandchild. _exit(EXIT_SUCCESS); } else { _exit(EXIT_FAILURE); } #else pid_t pid2; - /* Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam */ + // Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam unsetenv("LD_PRELOAD"); - /* Notice this is vfork and not fork! */ + // 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. */ + // Child process doesn't wait for possibly-blocking grandchild. _exit(EXIT_SUCCESS); } -#endif /* USE_POSIX_SPAWN */ +#endif // USE_POSIX_SPAWN } else if (pid1 < 0) { return SDL_SetError("fork() failed: %s", strerror(errno)); } else { @@ -71,7 +71,7 @@ int SDL_SYS_OpenURL(const char *url) if (waitpid(pid1, &status, 0) == pid1) { if (WIFEXITED(status)) { if (WEXITSTATUS(status) == 0) { - return 0; /* success! */ + return 0; // success! } else { return SDL_SetError("xdg-open reported error or failed to launch: %d", WEXITSTATUS(status)); } diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index fe4c877bde..bb2272e0a3 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -28,17 +28,17 @@ #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) int SDL_SYS_OpenURL(const char *url) { - /* Not supported */ + // Not supported return SDL_Unsupported(); } #else -/* https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx */ +// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx int SDL_SYS_OpenURL(const char *url) { WCHAR *wurl; HINSTANCE rc; - /* MSDN says for safety's sake, make sure COM is initialized. */ + // MSDN says for safety's sake, make sure COM is initialized. const HRESULT hr = WIN_CoInitialize(); if (FAILED(hr)) { return WIN_SetErrorFromHRESULT("CoInitialize failed", hr); @@ -50,7 +50,7 @@ int SDL_SYS_OpenURL(const char *url) return -1; } - /* Success returns value greater than 32. Less is an error. */ + // Success returns value greater than 32. Less is an error. rc = ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL); SDL_free(wurl); WIN_CoUninitialize(); diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index af1e5bfbd1..9efe094e56 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -30,7 +30,7 @@ typedef SDL_bool (*SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, #ifndef SDL_POWER_DISABLED #ifdef SDL_POWER_HARDWIRED -/* This is for things that _never_ have a battery */ +// This is for things that _never_ have a battery static SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, int *percent) { *seconds = -1; @@ -41,40 +41,40 @@ static SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, #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 macOS, Darwin. */ +#ifdef SDL_POWER_MACOSX // handles macOS, 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 @@ -93,7 +93,7 @@ SDL_PowerState SDL_GetPowerInfo(int *seconds, int *percent) #endif int _seconds, _percent; - /* Make these never NULL for platform-specific implementations. */ + // Make these never NULL for platform-specific implementations. if (!seconds) { seconds = &_seconds; } @@ -109,7 +109,7 @@ SDL_PowerState SDL_GetPowerInfo(int *seconds, int *percent) } #endif - /* nothing was definitive. */ + // nothing was definitive. *seconds = -1; *percent = -1; return SDL_POWERSTATE_UNKNOWN; diff --git a/src/power/SDL_syspower.h b/src/power/SDL_syspower.h index 31328162b4..2be338f583 100644 --- a/src/power/SDL_syspower.h +++ b/src/power/SDL_syspower.h @@ -20,12 +20,12 @@ */ #include "SDL_internal.h" -/* These are functions that need to be implemented by a port of SDL */ +// These are functions that need to be implemented by a port of SDL #ifndef SDL_syspower_h_ #define SDL_syspower_h_ -/* Not all of these are available in a given build. Use #ifdefs, etc. */ +// Not all of these are available in a given build. Use #ifdefs, etc. SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *, int *, int *); @@ -41,7 +41,7 @@ SDL_bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); -/* this one is static in SDL_power.c */ +// this one is static in SDL_power.c /* SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *, int *, int *);*/ -#endif /* SDL_syspower_h_ */ +#endif // SDL_syspower_h_ diff --git a/src/power/android/SDL_syspower.c b/src/power/android/SDL_syspower.c index 0cae9d33ca..cf5b3a4609 100644 --- a/src/power/android/SDL_syspower.c +++ b/src/power/android/SDL_syspower.c @@ -56,5 +56,5 @@ SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *state, int *seconds, int *perc return SDL_TRUE; } -#endif /* SDL_POWER_ANDROID */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_ANDROID +#endif // SDL_POWER_DISABLED diff --git a/src/power/emscripten/SDL_syspower.c b/src/power/emscripten/SDL_syspower.c index dad87acb20..d2c5cd3297 100644 --- a/src/power/emscripten/SDL_syspower.c +++ b/src/power/emscripten/SDL_syspower.c @@ -55,5 +55,5 @@ SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *p return SDL_TRUE; } -#endif /* SDL_POWER_EMSCRIPTEN */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_EMSCRIPTEN +#endif // SDL_POWER_DISABLED diff --git a/src/power/haiku/SDL_syspower.c b/src/power/haiku/SDL_syspower.c index 14bf6423c2..4fb7e790dd 100644 --- a/src/power/haiku/SDL_syspower.c +++ b/src/power/haiku/SDL_syspower.c @@ -20,8 +20,8 @@ */ #include "SDL_internal.h" -/* uses BeOS euc.jp apm driver. */ -/* !!! FIXME: does this thing even work on Haiku? */ +// uses BeOS euc.jp apm driver. +// !!! FIXME: does this thing even work on Haiku? #ifndef SDL_POWER_DISABLED #ifdef SDL_POWER_HAIKU @@ -33,7 +33,7 @@ #include #include -/* These values are from apm.h ... */ +// These values are from apm.h ... #define APM_DEVICE_PATH "/dev/misc/apm" #define APM_FUNC_OFFSET 0x5300 #define APM_FUNC_GET_POWER_STATUS 10 @@ -53,7 +53,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen 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)); @@ -72,8 +72,8 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen battery_life = regs[2] & 0xFF; battery_time = (uint32)regs[3]; - /* in theory, _something_ should be set in battery_flags, right? */ - if (battery_flags == 0x00) { /* older APM BIOS? Less fields. */ + // in theory, _something_ should be set in battery_flags, right? + if (battery_flags == 0x00) { // older APM BIOS? Less fields. battery_time = 0xFFFF; if (battery_status == 0xFF) { battery_flags = 0xFF; @@ -83,22 +83,22 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen } if ((battery_time != 0xFFFF) && (battery_time & (1 << 15))) { - /* time is in minutes, not seconds */ + // time is in minutes, not seconds 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; } @@ -108,16 +108,16 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen const int pct = (int)battery_life; const int secs = (int)battery_time; - if (pct != 255) { /* 255 == unknown */ - *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ + 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 */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_HAIKU +#endif // SDL_POWER_DISABLED diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index e4a17a08fd..03a82aa60e 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -46,7 +46,7 @@ static int open_power_file(const char *base, const char *node, const char *key) const size_t pathlen = SDL_strlen(base) + SDL_strlen(node) + SDL_strlen(key) + 3; char *path = SDL_stack_alloc(char, pathlen); if (!path) { - return -1; /* oh well. */ + return -1; // oh well. } (void)SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key); @@ -68,7 +68,7 @@ static SDL_bool read_power_file(const char *base, const char *node, const char * if (br < 0) { return SDL_FALSE; } - buf[br] = '\0'; /* null-terminate the string. */ + buf[br] = '\0'; // null-terminate the string. return SDL_TRUE; } @@ -77,11 +77,11 @@ 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; @@ -91,17 +91,17 @@ static SDL_bool 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; @@ -111,10 +111,10 @@ static SDL_bool 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; } @@ -147,7 +147,7 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, *have_battery = SDL_TRUE; } } else if (SDL_strcasecmp(key, "charging state") == 0) { - /* !!! FIXME: what exactly _does_ charging/discharging mean? */ + // !!! FIXME: what exactly _does_ charging/discharging mean? if (SDL_strcasecmp(val, "charging/discharging") == 0) { charge = SDL_TRUE; } else if (SDL_strcasecmp(val, "charging") == 0) { @@ -182,7 +182,7 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, } } - /* !!! FIXME: calculate (secs). */ + // !!! FIXME: calculate (secs). /* * We pick the battery that claims to have the most minutes left. @@ -190,7 +190,7 @@ static void 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; @@ -242,7 +242,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i dirp = opendir(proc_acpi_battery_path); if (!dirp) { - 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; @@ -254,7 +254,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i dirp = opendir(proc_acpi_ac_adapter_path); if (!dirp) { - 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; @@ -273,7 +273,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i *state = SDL_POWERSTATE_ON_BATTERY; } - return SDL_TRUE; /* definitive answer. */ + return SDL_TRUE; // definitive answer. } static SDL_bool next_string(char **_ptr, char **_str) @@ -281,7 +281,7 @@ 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++; } @@ -310,7 +310,7 @@ static SDL_bool int_string(char *str, int *val) return (*str != '\0') && (*endptr == '\0'); } -/* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */ +// http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, int *percent) { SDL_bool need_details = SDL_FALSE; @@ -326,7 +326,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in 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); @@ -336,34 +336,34 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in 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] == '%') { @@ -373,27 +373,27 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in 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_strcasecmp(str, "min") == 0) { battery_time *= 60; } - if (battery_flag == 0xFF) { /* unknown 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; @@ -406,10 +406,10 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in const int pct = battery_percent; const int secs = battery_time; - if (pct >= 0) { /* -1 == unknown */ - *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ + 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; } } @@ -428,7 +428,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in 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; @@ -443,11 +443,11 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in int power; if ((SDL_strcmp(name, ".") == 0) || (SDL_strcmp(name, "..") == 0)) { - continue; /* skip these, of course. */ + 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; // Don't know _what_ we're looking at. Give up on it. } else if (SDL_strcasecmp(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 @@ -456,15 +456,15 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in assume it's a system battery if not specified. */ if (read_power_file(base, name, "scope", str, sizeof(str))) { if (SDL_strcasecmp(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. */ + // 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)) { st = SDL_POWERSTATE_NO_BATTERY; } else if (!read_power_file(base, name, "status", str, sizeof(str))) { - st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ + st = SDL_POWERSTATE_UNKNOWN; // uh oh } else if (SDL_strcasecmp(str, "Charging\n") == 0) { st = SDL_POWERSTATE_CHARGING; } else if (SDL_strcasecmp(str, "Discharging\n") == 0) { @@ -472,19 +472,19 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in } else if ((SDL_strcasecmp(str, "Full\n") == 0) || (SDL_strcasecmp(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))) { pct = -1; } else { pct = SDL_atoi(str); - pct = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ + pct = (pct > 100) ? 100 : pct; // clamp between 0%, 100% } 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; @@ -500,7 +500,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in */ 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; } @@ -516,10 +516,10 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in } 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. */ +// d-bus queries to org.freedesktop.UPower. #ifdef SDL_USE_LIBDBUS #define UPOWER_DBUS_NODE "org.freedesktop.UPower" #define UPOWER_DBUS_PATH "/org/freedesktop/UPower" @@ -537,13 +537,13 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe 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)) { @@ -558,8 +558,8 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe 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) || (ui32 == 6)) { /* 2 == discharging; @@ -574,22 +574,22 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe * lower than 100% threshold */ 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 = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ + 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 = (secs <= 0) ? -1 : secs; // 0 == unknown } /* @@ -598,7 +598,7 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe */ 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; } @@ -626,11 +626,11 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in if (!dbus || !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; @@ -639,10 +639,10 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in } dbus->free_string_array(paths); -#endif /* SDL_USE_LIBDBUS */ +#endif // SDL_USE_LIBDBUS return retval; } -#endif /* SDL_POWER_LINUX */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_LINUX +#endif // SDL_POWER_DISABLED diff --git a/src/power/macos/SDL_syspower.c b/src/power/macos/SDL_syspower.c index 13ea6f36b4..056263bec6 100644 --- a/src/power/macos/SDL_syspower.c +++ b/src/power/macos/SDL_syspower.c @@ -27,16 +27,16 @@ #include #include -/* CoreFoundation is so verbose... */ +// CoreFoundation is so verbose... #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. */ +// 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) { - CFStringRef strval; /* don't CFRelease() this. */ + CFStringRef strval; // don't CFRelease() this. CFBooleanRef bval; CFNumberRef numval; SDL_bool charge = SDL_FALSE; @@ -47,7 +47,7 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt int pct = -1; if ((GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse)) { - return; /* nothing to see here. */ + return; // nothing to see here. } if (!GETVAL(kIOPSPowerSourceStateKey, &strval)) { @@ -57,7 +57,7 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt 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)) { @@ -86,14 +86,14 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt SInt32 val = -1; CFNumberGetValue(numval, kCFNumberSInt32Type, &val); - /* macOS reports 0 minutes until empty if you're plugged in. :( */ + // macOS 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; if (secs > 0) { - secs *= 60; /* value is in minutes, so convert to seconds. */ + secs *= 60; // value is in minutes, so convert to seconds. } } @@ -117,7 +117,7 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt */ 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; @@ -147,7 +147,7 @@ SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *perce if (blob != NULL) { CFArrayRef list = IOPSCopyPowerSourcesList(blob); if (list != NULL) { - /* don't CFRelease() the list items, or dictionaries! */ + // don't CFRelease() the list items, or dictionaries! SDL_bool have_ac = SDL_FALSE; SDL_bool have_battery = SDL_FALSE; SDL_bool charging = SDL_FALSE; @@ -178,8 +178,8 @@ SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *perce CFRelease(blob); } - return SDL_TRUE; /* always the definitive answer on macOS. */ + return SDL_TRUE; // always the definitive answer on macOS. } -#endif /* SDL_POWER_MACOSX */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_MACOSX +#endif // SDL_POWER_DISABLED diff --git a/src/power/n3ds/SDL_syspower.c b/src/power/n3ds/SDL_syspower.c index 57a745b3df..ddac2b4ee9 100644 --- a/src/power/n3ds/SDL_syspower.c +++ b/src/power/n3ds/SDL_syspower.c @@ -36,7 +36,7 @@ SDL_bool SDL_GetPowerInfo_N3DS(SDL_PowerState *state, int *seconds, int *percent { *state = GetPowerState(); *percent = GetBatteryPercentage(); - *seconds = -1; /* libctru doesn't provide a way to estimate battery life */ + *seconds = -1; // libctru doesn't provide a way to estimate battery life return SDL_TRUE; } @@ -99,4 +99,4 @@ static int GetBatteryPercentage(void) return (int)SDL_round(data[0] + data[1] / 256.0); } -#endif /* !SDL_POWER_DISABLED && SDL_POWER_N3DS */ +#endif // !SDL_POWER_DISABLED && SDL_POWER_N3DS diff --git a/src/power/psp/SDL_syspower.c b/src/power/psp/SDL_syspower.c index 96d3792676..845905a79e 100644 --- a/src/power/psp/SDL_syspower.c +++ b/src/power/psp/SDL_syspower.c @@ -54,8 +54,8 @@ SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *state, int *seconds, int *percent) *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 */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_PSP +#endif // SDL_POWER_DISABLED diff --git a/src/power/uikit/SDL_syspower.h b/src/power/uikit/SDL_syspower.h index 8365c75b27..5215fb59ba 100644 --- a/src/power/uikit/SDL_syspower.h +++ b/src/power/uikit/SDL_syspower.h @@ -25,4 +25,4 @@ void SDL_UIKit_UpdateBatteryMonitoring(void); SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent); -#endif /* SDL_POWER_UIKIT */ +#endif // SDL_POWER_UIKIT diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index bca259f327..7cafee4ee1 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -28,7 +28,7 @@ #include "SDL_syspower.h" #ifndef SDL_PLATFORM_TVOS -/* turn off the battery monitor if it's been more than X ms since last check. */ +// turn off the battery monitor if it's been more than X ms since last check. static const int BATTERY_MONITORING_TIMEOUT = 3000; static Uint64 SDL_UIKitLastPowerInfoQuery = 0; @@ -46,9 +46,9 @@ void SDL_UIKit_UpdateBatteryMonitoring(void) #else void SDL_UIKit_UpdateBatteryMonitoring(void) { - /* Do nothing. */ + // Do nothing. } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent) { @@ -56,7 +56,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen *state = SDL_POWERSTATE_NO_BATTERY; *seconds = -1; *percent = -1; -#else /* SDL_PLATFORM_TVOS */ +#else // SDL_PLATFORM_TVOS @autoreleasepool { UIDevice *uidev = [UIDevice currentDevice]; @@ -72,7 +72,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen */ 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: @@ -96,10 +96,10 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen const float level = uidev.batteryLevel; *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); } -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS - return SDL_TRUE; /* always the definitive answer on iOS. */ + return SDL_TRUE; // always the definitive answer on iOS. } -#endif /* SDL_POWER_UIKIT */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_UIKIT +#endif // SDL_POWER_DISABLED diff --git a/src/power/vita/SDL_syspower.c b/src/power/vita/SDL_syspower.c index 5e216abe03..a8947b6114 100644 --- a/src/power/vita/SDL_syspower.c +++ b/src/power/vita/SDL_syspower.c @@ -54,8 +54,8 @@ SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *state, int *seconds, int *percent *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 */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_VITA +#endif // SDL_POWER_DISABLED diff --git a/src/power/windows/SDL_syspower.c b/src/power/windows/SDL_syspower.c index 4525c86762..d412935792 100644 --- a/src/power/windows/SDL_syspower.c +++ b/src/power/windows/SDL_syspower.c @@ -30,22 +30,22 @@ SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *perc SYSTEM_POWER_STATUS status; SDL_bool need_details = SDL_FALSE; - /* This API should exist back to Win95. */ + // This API should exist back to Win95. if (!GetSystemPowerStatus(&status)) { - /* !!! FIXME: push GetLastError() into SDL_GetError() */ + // !!! 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 */ + } else if (status.BatteryFlag & (1 << 7)) { // no battery *state = SDL_POWERSTATE_NO_BATTERY; - } else if (status.BatteryFlag & (1 << 3)) { /* charging */ + } else if (status.BatteryFlag & (1 << 3)) { // charging *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; } @@ -55,16 +55,16 @@ SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *perc const int pct = (int)status.BatteryLifePercent; const int secs = (int)status.BatteryLifeTime; - if (pct != 255) { /* 255 == unknown */ - *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ + 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 */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_WINDOWS +#endif // SDL_POWER_DISABLED diff --git a/src/power/winrt/SDL_syspower.cpp b/src/power/winrt/SDL_syspower.cpp index 4df727976a..3313f995f0 100644 --- a/src/power/winrt/SDL_syspower.cpp +++ b/src/power/winrt/SDL_syspower.cpp @@ -26,7 +26,7 @@ extern "C" SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *state, int *seconds, int *percent) { - /* TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement SDL_GetPowerInfo_WinRT as appropriate. */ + // TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement SDL_GetPowerInfo_WinRT as appropriate. /* Notes: - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ @@ -35,5 +35,5 @@ SDL_GetPowerInfo_WinRT(SDL_PowerState *state, int *seconds, int *percent) return SDL_FALSE; } -#endif /* SDL_POWER_WINRT */ -#endif /* SDL_POWER_DISABLED */ +#endif // SDL_POWER_WINRT +#endif // SDL_POWER_DISABLED diff --git a/src/render/SDL_d3dmath.c b/src/render/SDL_d3dmath.c index f22d3332ff..fbe58099c2 100644 --- a/src/render/SDL_d3dmath.c +++ b/src/render/SDL_d3dmath.c @@ -24,7 +24,7 @@ #include "SDL_d3dmath.h" -/* Direct3D matrix math functions */ +// Direct3D matrix math functions Float4X4 MatrixIdentity(void) { @@ -129,4 +129,4 @@ Float4X4 MatrixRotationZ(float r) return m; } -#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) */ +#endif // (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) diff --git a/src/render/SDL_d3dmath.h b/src/render/SDL_d3dmath.h index 5400ce369b..68a4efb770 100644 --- a/src/render/SDL_d3dmath.h +++ b/src/render/SDL_d3dmath.h @@ -22,12 +22,12 @@ #if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN) -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* Direct3D matrix math functions */ +// Direct3D matrix math functions typedef struct { @@ -73,9 +73,9 @@ extern Float4X4 MatrixRotationX(float r); extern Float4X4 MatrixRotationY(float r); extern Float4X4 MatrixRotationZ(float r); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN)*/ +#endif // (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index ab9a2ad611..5ebd8d26b8 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* The SDL 2D rendering system */ +// The SDL 2D rendering system #include "SDL_sysrender.h" #include "software/SDL_render_sw_c.h" @@ -66,7 +66,7 @@ this should probably be removed at some point in the future. --ryan. */ return retval; \ } -/* Predefined blend modes */ +// Predefined blend modes #define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, \ srcAlphaFactor, dstAlphaFactor, alphaOperation) \ (SDL_BlendMode)(((Uint32)(colorOperation) << 0) | \ @@ -140,7 +140,7 @@ static const SDL_RenderDriver *render_drivers[] = { &SW_RenderDriver #endif }; -#endif /* !SDL_RENDER_DISABLED */ +#endif // !SDL_RENDER_DISABLED static SDL_Renderer *SDL_renderers; @@ -314,7 +314,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (!renderer->render_commands) { /* nothing to do! */ + if (!renderer->render_commands) { // nothing to do! SDL_assert(renderer->vertex_data_used == 0); return 0; } @@ -323,7 +323,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) retval = renderer->RunCommandQueue(renderer, renderer->render_commands, renderer->vertex_data, renderer->vertex_data_used); - /* Move the whole render command queue to the unused pool so we can reuse them next time. */ + // Move the whole render command queue to the unused pool so we can reuse them next time. if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; renderer->render_commands_pool = renderer->render_commands; @@ -343,7 +343,7 @@ static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture) { SDL_Renderer *renderer = texture->renderer; if (texture->last_command_generation == renderer->render_command_generation) { - /* the current command queue depends on this texture, flush the queue now before it changes */ + // the current command queue depends on this texture, flush the queue now before it changes return FlushRenderCommands(renderer); } return 0; @@ -396,7 +396,7 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) { SDL_RenderCommand *retval = NULL; - /* !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. */ + // !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. retval = renderer->render_commands_pool; if (retval) { renderer->render_commands_pool = retval->next; @@ -447,7 +447,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); if (cmd) { 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. SDL_copyp(&cmd->data.viewport.rect, &viewport); retval = renderer->QueueSetViewport(renderer, cmd); if (retval < 0) { @@ -510,7 +510,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_FColor *color) if (cmd) { 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.color_scale = renderer->color_scale; cmd->data.color.color = *color; retval = renderer->QueueSetDrawColor(renderer, cmd); @@ -571,8 +571,8 @@ static SDL_RenderCommand *PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_Ren cmd = AllocateRenderCommand(renderer); if (cmd) { 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.color_scale = renderer->color_scale; cmd->data.draw.color = *color; cmd->data.draw.blend = blendMode; @@ -940,15 +940,15 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind refresh_num = mode->refresh_rate_numerator; refresh_den = mode->refresh_rate_denominator; } else { - /* Pick a good default refresh rate */ + // Pick a good default refresh rate refresh_num = 60; refresh_den = 1; } - /* Flip numerator and denominator to change from framerate to interval */ + // Flip numerator and denominator to change from framerate to interval renderer->simulate_vsync_interval_ns = (SDL_NS_PER_SECOND * refresh_den) / refresh_num; } -#endif /* !SDL_RENDER_DISABLED */ +#endif // !SDL_RENDER_DISABLED SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) @@ -1061,7 +1061,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) UpdatePixelClipRect(renderer, &renderer->main_view); UpdateMainViewDimensions(renderer); - /* Default value, if not specified by the renderer back-end */ + // Default value, if not specified by the renderer back-end if (renderer->rect_index_order[0] == 0 && renderer->rect_index_order[1] == 0) { renderer->rect_index_order[0] = 0; renderer->rect_index_order[1] = 1; @@ -1071,11 +1071,11 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) renderer->rect_index_order[5] = 3; } - /* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */ + // new textures start at zero, so we start at 1 so first render doesn't flush by accident. renderer->render_command_generation = 1; if (renderer->software) { - /* Software renderer always uses line method, for speed */ + // Software renderer always uses line method, for speed renderer->line_method = SDL_RENDERLINEMETHOD_LINES; } else { renderer->line_method = SDL_GetRenderLineMethod(); @@ -1184,7 +1184,7 @@ SDL_Renderer *SDL_CreateSoftwareRenderer(SDL_Surface *surface) #else SDL_SetError("SDL not built with rendering support"); return NULL; -#endif /* !SDL_RENDER_DISABLED */ +#endif // !SDL_RENDER_DISABLED } SDL_Renderer *SDL_GetRenderer(SDL_Window *window) @@ -1259,7 +1259,7 @@ int SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h) static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { switch (blendMode) { - /* These are required to be supported by all renderers */ + // These are required to be supported by all renderers case SDL_BLENDMODE_NONE: case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_BLEND_PREMULTIPLIED: @@ -1291,7 +1291,7 @@ static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat int i; if (SDL_ISPIXELFORMAT_FOURCC(format)) { - /* Look for an exact match */ + // Look for an exact match for (i = 0; i < renderer->num_texture_formats; ++i) { if (renderer->texture_formats[i] == format) { return renderer->texture_formats[i]; @@ -1313,7 +1313,7 @@ static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat } else { SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); - /* We just want to match the first format that has the same channels */ + // We just want to match the first format that has the same channels for (i = 0; i < renderer->num_texture_formats; ++i) { if (!SDL_ISPIXELFORMAT_FOURCC(renderer->texture_formats[i]) && SDL_ISPIXELFORMAT_ALPHA(renderer->texture_formats[i]) == hasAlpha) { @@ -1396,7 +1396,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert texture->SDR_white_point = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT, SDL_GetDefaultSDRWhitePoint(texture->colorspace)); texture->HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT, SDL_GetDefaultHDRHeadroom(texture->colorspace)); - /* FOURCC format cannot be used directly by renderer back-ends for target texture */ + // FOURCC format cannot be used directly by renderer back-ends for target texture texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(format)); if (!texture_is_fourcc_and_target && IsSupportedFormat(renderer, format)) { @@ -1434,7 +1434,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert SDL_SetPointerProperty(SDL_GetTextureProperties(texture->native), SDL_PROP_TEXTURE_PARENT_POINTER, texture); - /* Swap textures to have texture before texture->native in the list */ + // Swap textures to have texture before texture->native in the list texture->native->next = texture->next; if (texture->native->next) { texture->native->next->prev = texture->native; @@ -1458,7 +1458,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert return NULL; } } else if (access == SDL_TEXTUREACCESS_STREAMING) { - /* The pitch is 4 byte aligned */ + // The pitch is 4 byte aligned texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3); texture->pixels = SDL_calloc(1, (size_t)texture->pitch * h); if (!texture->pixels) { @@ -1468,7 +1468,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert } } - /* Now set the properties for the new texture */ + // Now set the properties for the new texture props = SDL_GetTextureProperties(texture); SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_COLORSPACE_NUMBER, texture->colorspace); SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_FORMAT_NUMBER, texture->format); @@ -1546,11 +1546,11 @@ static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SD * Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */ direct_update = SDL_FALSE; } else { - /* Update Texture directly */ + // Update Texture directly direct_update = SDL_TRUE; } } else { - /* Surface and Renderer formats are different, it needs an intermediate conversion. */ + // Surface and Renderer formats are different, it needs an intermediate conversion. direct_update = SDL_FALSE; } @@ -1565,7 +1565,7 @@ static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SD } else { SDL_Surface *temp = NULL; - /* Set up a destination surface for the texture update */ + // Set up a destination surface for the texture update temp = SDL_ConvertSurfaceAndColorspace(surface, tex_format, NULL, texture_colorspace, surface_props); if (temp) { SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); @@ -1586,7 +1586,7 @@ static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SD SDL_SetTextureAlphaMod(texture, a); if (SDL_SurfaceHasColorKey(surface)) { - /* We converted to a texture with alpha format */ + // We converted to a texture with alpha format SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); } else { SDL_GetSurfaceBlendMode(surface, &blendMode); @@ -1615,14 +1615,14 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s return NULL; } - /* See what the best texture format is */ + // See what the best texture format is if (SDL_ISPIXELFORMAT_ALPHA(surface->format) || SDL_SurfaceHasColorKey(surface)) { needAlpha = SDL_TRUE; } else { needAlpha = SDL_FALSE; } - /* If Palette contains alpha values, promotes to alpha format */ + // If Palette contains alpha values, promotes to alpha format palette = SDL_GetSurfacePalette(surface); if (palette) { SDL_bool is_opaque, has_alpha_channel; @@ -1634,8 +1634,8 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s texture_colorspace = SDL_GetSurfaceColorspace(surface); - /* Try to have the best pixel format for the texture */ - /* No alpha, but a colorkey => promote to alpha */ + // Try to have the best pixel format for the texture + // No alpha, but a colorkey => promote to alpha if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) { if (surface->format == SDL_PIXELFORMAT_XRGB8888) { for (i = 0; i < renderer->num_texture_formats; ++i) { @@ -1653,7 +1653,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s } } } else { - /* Exact match would be fine */ + // Exact match would be fine for (i = 0; i < renderer->num_texture_formats; ++i) { if (renderer->texture_formats[i] == surface->format) { format = surface->format; @@ -1662,7 +1662,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s } } - /* Look for 10-bit pixel formats if needed */ + // Look for 10-bit pixel formats if needed if (format == SDL_PIXELFORMAT_UNKNOWN && SDL_ISPIXELFORMAT_10BIT(surface->format)) { for (i = 0; i < renderer->num_texture_formats; ++i) { if (SDL_ISPIXELFORMAT_10BIT(renderer->texture_formats[i])) { @@ -1672,7 +1672,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s } } - /* Look for floating point pixel formats if needed */ + // Look for floating point pixel formats if needed if (format == SDL_PIXELFORMAT_UNKNOWN && (SDL_ISPIXELFORMAT_10BIT(surface->format) || SDL_ISPIXELFORMAT_FLOAT(surface->format))) { for (i = 0; i < renderer->num_texture_formats; ++i) { @@ -1683,7 +1683,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s } } - /* Fallback, choose a valid pixel format */ + // Fallback, choose a valid pixel format if (format == SDL_PIXELFORMAT_UNKNOWN) { format = renderer->texture_formats[0]; for (i = 0; i < renderer->num_texture_formats; ++i) { @@ -1982,7 +1982,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, rect = &full_rect; if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - /* We can lock the texture and copy to it */ + // We can lock the texture and copy to it void *native_pixels = NULL; int native_pitch = 0; @@ -1993,7 +1993,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, rect->w, rect->h, native_pixels, native_pitch); SDL_UnlockTexture(native); } else { - /* Use a temporary buffer for updating */ + // Use a temporary buffer for updating const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { @@ -2009,7 +2009,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, } return 0; } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch) @@ -2017,11 +2017,11 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, 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) { - /* We can lock the texture and copy to it */ + // We can lock the texture and copy to it void *native_pixels = NULL; int native_pitch = 0; @@ -2033,7 +2033,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, native->format, native_pixels, native_pitch); SDL_UnlockTexture(native); } else { - /* Use a temporary buffer for updating */ + // Use a temporary buffer for updating const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { @@ -2075,7 +2075,7 @@ int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pi } 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); @@ -2111,11 +2111,11 @@ static int 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) { - /* We can lock the texture and copy to it */ + // We can lock the texture and copy to it void *native_pixels = NULL; int native_pitch = 0; @@ -2126,7 +2126,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect rect->w, rect->h, native_pixels, native_pitch); SDL_UnlockTexture(native); } else { - /* Use a temporary buffer for updating */ + // Use a temporary buffer for updating const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { @@ -2161,11 +2161,11 @@ static int 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) { - /* We can lock the texture and copy to it */ + // We can lock the texture and copy to it void *native_pixels = NULL; int native_pitch = 0; @@ -2176,7 +2176,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, rect->w, rect->h, native_pixels, native_pitch); SDL_UnlockTexture(native); } else { - /* Use a temporary buffer for updating */ + // Use a temporary buffer for updating const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { @@ -2193,7 +2193,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, return 0; } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, @@ -2239,7 +2239,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) { @@ -2299,7 +2299,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) { @@ -2328,7 +2328,7 @@ static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, { return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch); } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch) @@ -2368,7 +2368,7 @@ int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, i } else #endif if (texture->native) { - /* Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. */ + // Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. return SDL_LockTextureNative(texture, rect, pixels, pitch); } else { SDL_Renderer *renderer = texture->renderer; @@ -2383,7 +2383,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Sur { SDL_Rect real_rect; void *pixels = NULL; - int pitch = 0; /* fix static analysis */ + int pitch = 0; // fix static analysis int ret; if (!texture || !surface) { @@ -2433,7 +2433,7 @@ static void SDL_UnlockTextureYUV(SDL_Texture *texture) rect.w, rect.h, native_pixels, native_pitch); SDL_UnlockTexture(native); } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV static void SDL_UnlockTextureNative(SDL_Texture *texture) { @@ -2480,7 +2480,7 @@ void SDL_UnlockTexture(SDL_Texture *texture) static int SDL_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *texture) { - /* texture == NULL is valid and means reset the target to the window */ + // texture == NULL is valid and means reset the target to the window if (texture) { CHECK_TEXTURE_MAGIC(texture, -1); if (renderer != texture->renderer) { @@ -2490,17 +2490,17 @@ static int SDL_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET"); } if (texture->native) { - /* Always render to the native texture */ + // Always render to the native texture texture = texture->native; } } if (texture == renderer->target) { - /* Nothing to do! */ + // Nothing to do! 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); @@ -2525,7 +2525,7 @@ static int SDL_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text return -1; } - /* All set! */ + // All set! return 0; } @@ -2559,7 +2559,7 @@ static int UpdateLogicalPresentation(SDL_Renderer *renderer) float scale; if (renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_DISABLED) { - /* All done! */ + // All done! return 0; } @@ -2577,9 +2577,9 @@ static int UpdateLogicalPresentation(SDL_Renderer *renderer) if (renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_INTEGER_SCALE) { if (want_aspect > real_aspect) { - scale = (float)((int)output_w / (int)logical_w); /* This an integer division! */ + scale = (float)((int)output_w / (int)logical_w); // This an integer division! } else { - scale = (float)((int)output_h / (int)logical_h); /* This an integer division! */ + scale = (float)((int)output_h / (int)logical_h); // This an integer division! } if (scale < 1.0f) { @@ -2600,13 +2600,13 @@ static int UpdateLogicalPresentation(SDL_Renderer *renderer) } else if (want_aspect > real_aspect) { if (renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_LETTERBOX) { - /* We want a wider aspect ratio than is available - letterbox it */ + // We want a wider aspect ratio than is available - letterbox it scale = output_w / logical_w; renderer->logical_dst_rect.x = 0.0f; renderer->logical_dst_rect.w = output_w; renderer->logical_dst_rect.h = SDL_floorf(logical_h * scale); renderer->logical_dst_rect.y = (output_h - renderer->logical_dst_rect.h) / 2.0f; - } else { /* renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_OVERSCAN */ + } else { // renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_OVERSCAN /* 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 @@ -2619,13 +2619,13 @@ static int UpdateLogicalPresentation(SDL_Renderer *renderer) } } else { if (renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_LETTERBOX) { - /* We want a narrower aspect ratio than is available - use side-bars */ + // We want a narrower aspect ratio than is available - use side-bars scale = output_h / logical_h; renderer->logical_dst_rect.y = 0.0f; renderer->logical_dst_rect.h = output_h; renderer->logical_dst_rect.w = SDL_floorf(logical_w * scale); renderer->logical_dst_rect.x = (output_w - renderer->logical_dst_rect.w) / 2.0f; - } else { /* renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_OVERSCAN */ + } else { // renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_OVERSCAN /* We want a narrower aspect ratio than is available - zoom so logical width matches the real width and the height will grow off the screen @@ -2821,11 +2821,11 @@ int SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, floa CHECK_RENDERER_MAGIC(renderer, -1); - /* Convert from window coordinates to pixels within the window */ + // Convert from window coordinates to pixels within the window render_x = window_x * renderer->dpi_scale.x; render_y = window_y * renderer->dpi_scale.y; - /* Convert from pixels within the window to pixels within the view */ + // Convert from pixels within the window to pixels within the view if (renderer->logical_target) { const SDL_FRect *src = &renderer->logical_src_rect; const SDL_FRect *dst = &renderer->logical_dst_rect; @@ -2833,7 +2833,7 @@ int SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, floa render_y = ((render_y - dst->y) * src->h) / dst->h; } - /* Convert from pixels within the view to render coordinates */ + // Convert from pixels within the view to render coordinates if (renderer->logical_target) { view = &renderer->logical_target->view; } else { @@ -2857,7 +2857,7 @@ int SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, floa CHECK_RENDERER_MAGIC(renderer, -1); - /* Convert from render coordinates to pixels within the view */ + // Convert from render coordinates to pixels within the view if (renderer->logical_target) { view = &renderer->logical_target->view; } else { @@ -2866,7 +2866,7 @@ int SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, floa x = (view->viewport.x + x) * view->scale.x; y = (view->viewport.y + y) * view->scale.y; - /* Convert from pixels within the view to pixels within the window */ + // Convert from pixels within the view to pixels within the window if (renderer->logical_target) { const SDL_FRect *src = &renderer->logical_src_rect; const SDL_FRect *dst = &renderer->logical_dst_rect; @@ -2874,7 +2874,7 @@ int SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, floa y = dst->y + ((y * dst->h) / src->h); } - /* Convert from pixels within the window to window coordinates */ + // Convert from pixels within the window to window coordinates x /= renderer->dpi_scale.x; y /= renderer->dpi_scale.y; @@ -2899,17 +2899,17 @@ int SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event if (event->motion.xrel != 0.0f) { SDL_RenderViewState *view; - /* Convert from window coordinates to pixels within the window */ + // Convert from window coordinates to pixels within the window float scale = renderer->dpi_scale.x; - /* Convert from pixels within the window to pixels within the view */ + // Convert from pixels within the window to pixels within the view if (renderer->logical_target) { const SDL_FRect *src = &renderer->logical_src_rect; const SDL_FRect *dst = &renderer->logical_dst_rect; scale = (scale * src->w) / dst->w; } - /* Convert from pixels within the view to render coordinates */ + // Convert from pixels within the view to render coordinates if (renderer->logical_target) { view = &renderer->logical_target->view; } else { @@ -2922,17 +2922,17 @@ int SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event if (event->motion.yrel != 0.0f) { SDL_RenderViewState *view; - /* Convert from window coordinates to pixels within the window */ + // Convert from window coordinates to pixels within the window float scale = renderer->dpi_scale.y; - /* Convert from pixels within the window to pixels within the view */ + // Convert from pixels within the window to pixels within the view if (renderer->logical_target) { const SDL_FRect *src = &renderer->logical_src_rect; const SDL_FRect *dst = &renderer->logical_dst_rect; scale = (scale * src->h) / dst->h; } - /* Convert from pixels within the view to render coordinates */ + // Convert from pixels within the view to render coordinates if (renderer->logical_target) { view = &renderer->logical_target->view; } else { @@ -2960,7 +2960,7 @@ int SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event } else if (event->type == SDL_EVENT_FINGER_DOWN || event->type == SDL_EVENT_FINGER_UP || event->type == SDL_EVENT_FINGER_MOTION) { - /* FIXME: Are these events guaranteed to be window relative? */ + // FIXME: Are these events guaranteed to be window relative? if (renderer->window) { int w, h; if (SDL_GetWindowSize(renderer->window, &w, &h) < 0) { @@ -3148,7 +3148,7 @@ int SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY) UpdatePixelViewport(renderer, renderer->view); UpdatePixelClipRect(renderer, renderer->view); - /* The scale affects the existing viewport and clip rectangle */ + // The scale affects the existing viewport and clip rectangle retval += QueueCmdSetViewport(renderer); retval += QueueCmdSetClipRect(renderer); return retval; @@ -3381,7 +3381,7 @@ int SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3588,7 +3588,7 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3615,7 +3615,7 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) const int size_indices = 4; int cur_index = -4; const int is_looping = (points[0].x == points[count - 1].x && points[0].y == points[count - 1].y); - SDL_FPoint p; /* previous point */ + SDL_FPoint p; // previous point p.x = p.y = 0.0f; /* p q @@ -3625,7 +3625,7 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) 3----2-------7----6 */ for (i = 0; i < count; ++i) { - SDL_FPoint q = points[i]; /* current point */ + SDL_FPoint q = points[i]; // current point q.x *= scale_x; q.y *= scale_y; @@ -3645,20 +3645,20 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) *ptr_indices++ = cur_index + (i3); \ num_indices += 3; - /* closed polyline, don´t draw twice the point */ + // closed polyline, don´t draw twice the point if (i || is_looping == 0) { ADD_TRIANGLE(4, 5, 6) ADD_TRIANGLE(4, 6, 7) } - /* first point only, no segment */ + // first point only, no segment if (i == 0) { p = q; cur_index += 4; continue; } - /* draw segment */ + // draw segment if (p.y == q.y) { if (p.x < q.x) { ADD_TRIANGLE(1, 4, 7) @@ -3732,7 +3732,7 @@ int SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); - /* If 'rect' == NULL, then outline the whole surface */ + // If 'rect' == NULL, then outline the whole surface if (!rect) { GetRenderViewportSize(renderer, &frect); rect = &frect; @@ -3765,7 +3765,7 @@ int SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3785,7 +3785,7 @@ int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); - /* If 'rect' == NULL, then fill the whole surface */ + // If 'rect' == NULL, then fill the whole surface if (!rect) { GetRenderViewportSize(renderer, &frect); rect = &frect; @@ -3810,7 +3810,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3911,7 +3911,7 @@ int SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FR } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3954,7 +3954,7 @@ int SDL_RenderTextureRotated(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_RenderTexture(renderer, texture, srcrect, dstrect); } @@ -3969,7 +3969,7 @@ int SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -3987,7 +3987,7 @@ int SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, } } - /* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */ + // We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? if (dstrect) { real_dstrect = *dstrect; } else { @@ -4071,16 +4071,16 @@ int SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, c_maxx = c * (maxx - centerx); c_maxy = c * (maxy - centery); - /* (minx, miny) */ + // (minx, miny) xy[0] = (c_minx - s_miny) + centerx; xy[1] = (s_minx + c_miny) + centery; - /* (maxx, miny) */ + // (maxx, miny) xy[2] = (c_maxx - s_miny) + centerx; xy[3] = (s_maxx + c_miny) + centery; - /* (maxx, maxy) */ + // (maxx, maxy) xy[4] = (c_maxx - s_maxy) + centerx; xy[5] = (s_maxx + c_maxy) + centery; - /* (minx, maxy) */ + // (minx, maxy) xy[6] = (c_minx - s_maxy) + centerx; xy[7] = (s_minx + c_maxy) + centery; @@ -4224,7 +4224,7 @@ int SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const S } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -4481,7 +4481,7 @@ static int remap_indices( } #define DEBUG_SW_RENDER_GEOMETRY 0 -/* For the software renderer, try to reinterpret triangles as SDL_Rect */ +// 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, @@ -4493,12 +4493,12 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, int i; int retval = 0; int count = indices ? num_indices : num_vertices; - int prev[3]; /* Previous triangle vertex indices */ + int prev[3]; // Previous triangle vertex indices float texw = 0.0f, texh = 0.0f; SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; float r = 0, g = 0, b = 0, a = 0; - /* Save */ + // Save SDL_GetRenderDrawBlendMode(renderer, &blendMode); SDL_GetRenderDrawColorFloat(renderer, &r, &g, &b, &a); @@ -4512,16 +4512,16 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, size_indices = indices ? size_indices : 0; for (i = 0; i < count; i += 3) { - int k0, k1, k2; /* Current triangle indices */ + int k0, k1, k2; // Current triangle indices int is_quad = 1; #if DEBUG_SW_RENDER_GEOMETRY int is_uniform = 1; int is_rectangle = 1; #endif - int A = -1; /* Top left vertex */ - int B = -1; /* Bottom right vertex */ - int C = -1; /* Third vertex of current triangle */ - int C2 = -1; /* Last, vertex of previous triangle */ + int A = -1; // Top left vertex + int B = -1; // Bottom right vertex + int C = -1; // Third vertex of current triangle + int C2 = -1; // Last, vertex of previous triangle if (size_indices == 4) { k0 = ((const Uint32 *)indices)[i]; @@ -4563,7 +4563,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, is_quad = (cnt == 2); } - /* Identify vertices */ + // Identify vertices if (is_quad) { const float *xy0_, *xy1_, *xy2_; float x0, x1, x2; @@ -4578,7 +4578,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, x2 = xy2_[0]; y2 = xy2_[1]; - /* Find top-left */ + // Find top-left if (x0 <= x1 && y0 <= y1) { if (x0 <= x2 && y0 <= y2) { A = k0; @@ -4593,7 +4593,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, } } - /* Find bottom-right */ + // Find bottom-right if (x0 >= x1 && y0 >= y1) { if (x0 >= x2 && y0 >= y2) { B = k0; @@ -4608,7 +4608,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, } } - /* Find C */ + // Find C if (k0 != A && k0 != B) { C = k0; } else if (k1 != A && k1 != B) { @@ -4617,7 +4617,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, C = k2; } - /* Find C2 */ + // Find C2 if (prev[0] != A && prev[0] != B) { C2 = prev[0]; } else if (prev[1] != A && prev[1] != B) { @@ -4636,9 +4636,9 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, x2 = xy2_[0]; y2 = xy2_[1]; - /* Check if triangle A B C is rectangle */ + // Check if triangle A B C is rectangle if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) { - /* ok */ + // ok } else { is_quad = 0; #if DEBUG_SW_RENDER_GEOMETRY @@ -4650,9 +4650,9 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, x2 = xy2_[0]; y2 = xy2_[1]; - /* Check if triangle A B C2 is rectangle */ + // Check if triangle A B C2 is rectangle if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) { - /* ok */ + // ok } else { is_quad = 0; #if DEBUG_SW_RENDER_GEOMETRY @@ -4661,7 +4661,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, } } - /* Check if uniformly colored */ + // Check if uniformly colored if (is_quad) { const SDL_FColor *col0_ = (const SDL_FColor *)((const char *)color + A * color_stride); const SDL_FColor *col1_ = (const SDL_FColor *)((const char *)color + B * color_stride); @@ -4670,7 +4670,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, if (SDL_memcmp(col0_, col1_, sizeof(*col0_)) == 0 && SDL_memcmp(col0_, col2_, sizeof(*col0_)) == 0 && SDL_memcmp(col0_, col3_, sizeof(*col0_)) == 0) { - /* ok */ + // ok } else { is_quad = 0; #if DEBUG_SW_RENDER_GEOMETRY @@ -4679,7 +4679,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, } } - /* Start rendering rect */ + // Start rendering rect if (is_quad) { SDL_FRect s; SDL_FRect d; @@ -4705,7 +4705,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, d.w = xy1_[0] - d.x; d.h = xy1_[1] - d.y; - /* Rect + texture */ + // Rect + texture if (texture && s.w != 0 && s.h != 0) { SDL_SetTextureAlphaModFloat(texture, col0_->a); SDL_SetTextureColorModFloat(texture, col0_->r, col0_->g, col0_->b); @@ -4730,7 +4730,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Log("Rect-COPY: RGB %f %f %f - Alpha:%f - texture=%p: src=(%d,%d, %d x %d) dst (%f, %f, %f x %f)", col0_->r, col0_->g, col0_->b, col0_->a, (void *)texture, s.x, s.y, s.w, s.h, d.x, d.y, d.w, d.h); #endif - } else if (d.w != 0.0f && d.h != 0.0f) { /* Rect, no texture */ + } else if (d.w != 0.0f && d.h != 0.0f) { // Rect, no texture SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawColorFloat(renderer, col0_->r, col0_->g, col0_->b, col0_->a); SDL_RenderFillRect(renderer, &d); @@ -4745,7 +4745,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, prev[0] = -1; } else { - /* Render triangles */ + // Render triangles if (prev[0] != -1) { #if DEBUG_SW_RENDER_GEOMETRY SDL_Log("Triangle %d %d %d - is_uniform:%d is_rectangle:%d", prev[0], prev[1], prev[2], is_uniform, is_rectangle); @@ -4764,10 +4764,10 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, prev[1] = k1; prev[2] = k2; } - } /* End for (), next triangle */ + } // End for (), next triangle if (prev[0] != -1) { - /* flush the last triangle */ + // flush the last triangle #if DEBUG_SW_RENDER_GEOMETRY SDL_Log("Last triangle %d %d %d", prev[0], prev[1], prev[2]); #endif @@ -4782,13 +4782,13 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer, } end: - /* Restore */ + // Restore SDL_SetRenderDrawBlendMode(renderer, blendMode); SDL_SetRenderDrawColorFloat(renderer, r, g, b, a); return retval; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW int SDL_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Texture *texture, @@ -4841,7 +4841,7 @@ int SDL_RenderGeometryRaw(SDL_Renderer *renderer, } #if DONT_DRAW_WHILE_HIDDEN - /* Don't draw while we're hidden */ + // Don't draw while we're hidden if (renderer->hidden) { return 0; } @@ -4889,7 +4889,7 @@ int SDL_RenderGeometryRaw(SDL_Renderer *renderer, texture->last_command_generation = renderer->render_command_generation; } - /* For the software renderer, try to reinterpret triangles as SDL_Rect */ + // For the software renderer, try to reinterpret triangles as SDL_Rect #if SDL_VIDEO_RENDER_SW if (renderer->software && texture_address_mode == SDL_TEXTURE_ADDRESS_CLAMP) { return SDL_SW_RenderGeometryRaw(renderer, texture, @@ -4918,7 +4918,7 @@ SDL_Surface *SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect) return NULL; } - FlushRenderCommands(renderer); /* we need to render before we read the results. */ + FlushRenderCommands(renderer); // we need to render before we read the results. real_rect = renderer->view->pixel_viewport; @@ -4953,7 +4953,7 @@ static void SDL_RenderApplyWindowShape(SDL_Renderer *renderer) } if (shape) { - /* There's nothing we can do if this fails, so just keep on going */ + // There's nothing we can do if this fails, so just keep on going renderer->shape_texture = SDL_CreateTextureFromSurface(renderer, shape); SDL_SetTextureBlendMode(renderer->shape_texture, @@ -4975,7 +4975,7 @@ static void SDL_SimulateRenderVSync(SDL_Renderer *renderer) const Uint64 interval = renderer->simulate_vsync_interval_ns; if (!interval) { - /* We can't do sub-ns delay, so just return here */ + // We can't do sub-ns delay, so just return here return; } @@ -4989,7 +4989,7 @@ static void SDL_SimulateRenderVSync(SDL_Renderer *renderer) elapsed = (now - renderer->last_present); if (!renderer->last_present || elapsed > SDL_MS_TO_NS(1000)) { - /* It's been too long, reset the presentation timeline */ + // It's been too long, reset the presentation timeline renderer->last_present = now; } else { renderer->last_present += (elapsed / interval) * interval; @@ -5011,10 +5011,10 @@ int SDL_RenderPresent(SDL_Renderer *renderer) SDL_RenderApplyWindowShape(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 */ + // Don't present while we're hidden if (renderer->hidden) { presented = SDL_FALSE; } else @@ -5044,13 +5044,13 @@ static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroyi renderer = texture->renderer; if (is_destroying) { - /* Renderer get destroyed, avoid to queue more commands */ + // Renderer get destroyed, avoid to queue more commands } else { if (texture == renderer->target) { - SDL_SetRenderTargetInternal(renderer, NULL); /* implies command queue flush */ + SDL_SetRenderTargetInternal(renderer, NULL); // implies command queue flush if (texture == renderer->logical_target) { - /* Complete any logical presentation */ + // Complete any logical presentation SDL_RenderLogicalPresentation(renderer); FlushRenderCommands(renderer); } @@ -5138,14 +5138,14 @@ void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer) SDL_DiscardAllCommands(renderer); - /* Free existing textures for this renderer */ + // Free existing textures for this renderer while (renderer->textures) { SDL_Texture *tex = renderer->textures; SDL_DestroyTextureInternal(renderer->textures, SDL_TRUE /* is_destroying */); - SDL_assert(tex != renderer->textures); /* satisfy static analysis. */ + SDL_assert(tex != renderer->textures); // satisfy static analysis. } - /* Clean up renderer-specific resources */ + // Clean up renderer-specific resources if (renderer->DestroyRenderer) { renderer->DestroyRenderer(renderer); } @@ -5204,7 +5204,7 @@ void *SDL_GetRenderMetalLayer(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; @@ -5215,7 +5215,7 @@ void *SDL_GetRenderMetalCommandEncoder(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; @@ -5335,7 +5335,7 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) renderer->wanted_vsync = vsync ? SDL_TRUE : SDL_FALSE; - /* for the software renderer, forward the call to the WindowTexture renderer */ + // for the software renderer, forward the call to the WindowTexture renderer #if SDL_VIDEO_RENDER_SW if (renderer->software) { if (!renderer->window) { diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index cdc7e1cb10..bb7441e790 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -25,7 +25,7 @@ #include "SDL_yuv_sw_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -48,11 +48,11 @@ typedef struct SDL_DRect double h; } SDL_DRect; -/* The SDL 2D rendering system */ +// The SDL 2D rendering system typedef struct SDL_RenderDriver SDL_RenderDriver; -/* Rendering view state */ +// Rendering view state typedef struct SDL_RenderViewState { int pixel_w; @@ -66,7 +66,7 @@ typedef struct SDL_RenderViewState } SDL_RenderViewState; -/* Define the SDL texture structure */ +// Define the SDL texture structure struct SDL_Texture { SDL_Colorspace colorspace; /**< The colorspace of the texture */ @@ -83,7 +83,7 @@ struct SDL_Texture SDL_Renderer *renderer; - /* Support for formats not supported directly by the renderer */ + // Support for formats not supported directly by the renderer SDL_Texture *native; SDL_SW_YUVTexture *yuv; void *pixels; @@ -91,7 +91,7 @@ struct SDL_Texture SDL_Rect locked_rect; SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */ - Uint32 last_command_generation; /* last command queue generation this texture was in. */ + Uint32 last_command_generation; // last command queue generation this texture was in. SDL_PropertiesID props; @@ -164,7 +164,7 @@ typedef enum SDL_RENDERLINEMETHOD_GEOMETRY, } SDL_RenderLineMethod; -/* Define the SDL renderer structure */ +// Define the SDL renderer structure struct SDL_Renderer { void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event); @@ -223,23 +223,23 @@ struct SDL_Renderer int (*AddVulkanRenderSemaphores)(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore); - /* The current renderer info */ + // The current renderer info const char *name; SDL_PixelFormat *texture_formats; int num_texture_formats; SDL_bool software; - /* The window associated with the renderer */ + // The window associated with the renderer SDL_Window *window; SDL_bool hidden; - /* Whether we should simulate vsync */ + // Whether we should simulate vsync SDL_bool wanted_vsync; SDL_bool simulate_vsync; Uint64 simulate_vsync_interval_ns; Uint64 last_present; - /* Support for logical output coordinates */ + // Support for logical output coordinates SDL_Texture *logical_target; SDL_RendererLogicalPresentation logical_presentation_mode; SDL_ScaleMode logical_scale_mode; @@ -249,16 +249,16 @@ struct SDL_Renderer SDL_RenderViewState *view; SDL_RenderViewState main_view; - /* The window pixel to point coordinate scale */ + // The window pixel to point coordinate scale SDL_FPoint dpi_scale; - /* The method of drawing lines */ + // The method of drawing lines SDL_RenderLineMethod line_method; - /* List of triangle indices to draw rects */ + // List of triangle indices to draw rects int rect_index_order[6]; - /* The list of textures */ + // The list of textures SDL_Texture *textures; SDL_Texture *target; SDL_Mutex *target_mutex; @@ -290,7 +290,7 @@ struct SDL_Renderer size_t vertex_data_used; size_t vertex_data_allocation; - /* Shaped window support */ + // Shaped window support SDL_bool transparent_window; SDL_Surface *shape_surface; SDL_Texture *shape_texture; @@ -304,7 +304,7 @@ struct SDL_Renderer SDL_Renderer *next; }; -/* Define the SDL render driver structure */ +// Define the SDL render driver structure struct SDL_RenderDriver { int (*CreateRenderer)(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID props); @@ -312,7 +312,7 @@ struct SDL_RenderDriver const char *name; }; -/* Not all of these are available in a given build. Use #ifdefs, etc. */ +// Not all of these are available in a given build. Use #ifdefs, etc. extern SDL_RenderDriver D3D_RenderDriver; extern SDL_RenderDriver D3D11_RenderDriver; extern SDL_RenderDriver D3D12_RenderDriver; @@ -325,21 +325,21 @@ extern SDL_RenderDriver PSP_RenderDriver; extern SDL_RenderDriver SW_RenderDriver; extern SDL_RenderDriver VITA_GXM_RenderDriver; -/* Clean up any renderers at shutdown */ +// Clean up any renderers at shutdown extern void SDL_QuitRender(void); -/* Add a supported texture format to a renderer */ +// Add a supported texture format to a renderer extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format); -/* Setup colorspace conversion */ +// Setup colorspace conversion extern void SDL_SetupRendererColorspace(SDL_Renderer *renderer, SDL_PropertiesID props); -/* Colorspace conversion functions */ +// Colorspace conversion functions extern SDL_bool SDL_RenderingLinearSpace(SDL_Renderer *renderer); extern void SDL_ConvertToLinear(SDL_FColor *color); extern void SDL_ConvertFromLinear(SDL_FColor *color); -/* Blend mode functions */ +// Blend mode functions extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode); extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode); extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode); @@ -355,9 +355,9 @@ extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t num // Let the video subsystem destroy a renderer without making its pointer invalid. extern void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_sysrender_h_ */ +#endif // SDL_sysrender_h_ diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index dd885fed72..8c8dec73d7 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the software implementation of the YUV texture support */ +// This is the software implementation of the YUV texture support #if SDL_HAVE_YUV @@ -68,7 +68,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h) } } - /* Find the pitch and offset values for the texture */ + // Find the pitch and offset values for the texture switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: @@ -99,7 +99,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h) break; } - /* We're all done.. */ + // We're all done.. return swdata; } @@ -126,7 +126,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, int row; size_t length; - /* Copy the Y plane */ + // Copy the Y plane src = (Uint8 *)pixels; dst = swdata->pixels + rect->y * swdata->w + rect->x; length = rect->w; @@ -136,7 +136,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, dst += swdata->w; } - /* Copy the next plane */ + // Copy the next plane src = (Uint8 *)pixels + rect->h * pitch; dst = swdata->pixels + swdata->h * swdata->w; dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2; @@ -147,7 +147,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, dst += (swdata->w + 1) / 2; } - /* Copy the next plane */ + // Copy the next plane 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); @@ -191,7 +191,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, int row; size_t length; - /* Copy the Y plane */ + // Copy the Y plane src = (Uint8 *)pixels; dst = swdata->pixels + rect->y * swdata->w + rect->x; length = rect->w; @@ -201,7 +201,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, dst += swdata->w; } - /* Copy the next plane */ + // 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); @@ -229,7 +229,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec int row; size_t length; - /* Copy the Y plane */ + // Copy the Y plane src = Yplane; dst = swdata->pixels + rect->y * swdata->w + rect->x; length = rect->w; @@ -239,7 +239,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec dst += swdata->w; } - /* Copy the U plane */ + // Copy the U plane src = Uplane; if (swdata->format == SDL_PIXELFORMAT_IYUV) { dst = swdata->pixels + swdata->h * swdata->w; @@ -255,7 +255,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec dst += (swdata->w + 1) / 2; } - /* Copy the V plane */ + // Copy the V plane src = Vplane; if (swdata->format == SDL_PIXELFORMAT_YV12) { dst = swdata->pixels + swdata->h * swdata->w; @@ -282,7 +282,7 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect int row; size_t length; - /* Copy the Y plane */ + // Copy the Y plane src = Yplane; dst = swdata->pixels + rect->y * swdata->w + rect->x; length = rect->w; @@ -292,7 +292,7 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect dst += swdata->w; } - /* Copy the UV or VU plane */ + // Copy the UV or VU plane src = UVplane; dst = swdata->pixels + swdata->h * swdata->w; dst += rect->y * ((swdata->w + 1) / 2) + rect->x; @@ -342,7 +342,7 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, { int stretch; - /* Make sure we're set up to display in the desired format */ + // Make sure we're set up to display in the desired format if (target_format != swdata->target_format && swdata->display) { SDL_DestroySurface(swdata->display); swdata->display = NULL; @@ -402,4 +402,4 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata) } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV diff --git a/src/render/SDL_yuv_sw_c.h b/src/render/SDL_yuv_sw_c.h index 5d2830ada6..6a1309f2d8 100644 --- a/src/render/SDL_yuv_sw_c.h +++ b/src/render/SDL_yuv_sw_c.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -/* This is the software implementation of the YUV texture support */ +// This is the software implementation of the YUV texture support struct SDL_SW_YUVTexture { @@ -33,11 +33,11 @@ struct SDL_SW_YUVTexture int w, h; Uint8 *pixels; - /* These are just so we don't have to allocate them separately */ + // These are just so we don't have to allocate them separately int pitches[3]; Uint8 *planes[3]; - /* This is a temporary surface in case we have to stretch copy */ + // This is a temporary surface in case we have to stretch copy SDL_Surface *stretch; SDL_Surface *display; }; @@ -64,4 +64,4 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, int pitch); void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata); -#endif /* SDL_yuv_sw_c_h_ */ +#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 a2b01f40bc..b4482fbeff 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -50,7 +50,7 @@ typedef struct const float *shader_params; } D3D_DrawStateCache; -/* Direct3D renderer implementation */ +// Direct3D renderer implementation typedef struct { @@ -96,7 +96,7 @@ typedef struct const float *shader_params; #if SDL_HAVE_YUV - /* YV12 texture support */ + // YV12 texture support SDL_bool yuv; D3D_TextureRep utexture; D3D_TextureRep vtexture; @@ -239,7 +239,7 @@ static void D3D_InitRenderState(D3D_RenderData *data) IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE); IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); - /* Enable color modulation by diffuse color */ + // Enable color modulation by diffuse color IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE); IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, @@ -247,7 +247,7 @@ static void D3D_InitRenderState(D3D_RenderData *data) IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - /* Enable alpha modulation by diffuse alpha */ + // Enable alpha modulation by diffuse alpha IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, @@ -255,18 +255,18 @@ static void D3D_InitRenderState(D3D_RenderData *data) IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - /* Enable separate alpha blend function, if possible */ + // Enable separate alpha blend function, if possible if (data->enableSeparateAlphaBlend) { IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); } - /* Disable second texture stage, since we're done */ + // Disable second texture stage, since we're done IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE); IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - /* Set an identity world and view matrix */ + // Set an identity world and view matrix SDL_zero(matrix); matrix.m[0][0] = 1.0f; matrix.m[1][1] = 1.0f; @@ -275,13 +275,13 @@ static void D3D_InitRenderState(D3D_RenderData *data) IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix); IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix); - /* Reset our current scale mode */ + // Reset our current scale mode SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); - /* Reset our current address mode */ + // Reset our current address mode SDL_zeroa(data->addressMode); - /* Start the render with beginScene */ + // Start the render with beginScene data->beginScene = SDL_TRUE; } @@ -612,14 +612,14 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV if (texturedata->yuv) { - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture 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 */ + // Skip to the correct offset into the next texture 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; @@ -670,7 +670,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, texturedata->locked_rect = *rect; if (texturedata->yuv) { - /* It's more efficient to upload directly... */ + // It's more efficient to upload directly... if (!texturedata->pixels) { texturedata->pitch = texture->w; texturedata->pixels = (Uint8 *)SDL_malloc((texture->h * texturedata->pitch * 3) / 2); @@ -757,7 +757,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text HRESULT result; IDirect3DDevice9 *device = data->device; - /* Release the previous render target if it wasn't the default one */ + // Release the previous render target if it wasn't the default one if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; @@ -773,7 +773,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text return SDL_SetError("Texture is not currently available"); } - /* Make sure the render target is updated if it was locked and written to */ + // Make sure the render target is updated if it was locked and written to texturerep = &texturedata->texture; if (texturerep->dirty && texturerep->staging) { if (!texturerep->texture) { @@ -814,7 +814,7 @@ static int D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int D3D_QueueNoOp(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) @@ -1004,7 +1004,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) D3D9_Shader shader = SHADER_NONE; const float *shader_params = NULL; - /* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */ + // disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. if (!texture) { IDirect3DDevice9_SetTexture(data->device, 0, NULL); } @@ -1029,7 +1029,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) if (shader_params != data->drawstate.shader_params) { if (shader_params) { - const UINT shader_params_length = 4; /* The YUV shader takes 4 float4 parameters */ + const UINT shader_params_length = 4; // The YUV shader takes 4 float4 parameters const HRESULT result = IDirect3DDevice9_SetPixelShaderConstantF(data->device, 0, shader_params, shader_params_length); if (FAILED(result)) { return D3D_SetError("IDirect3DDevice9_SetPixelShaderConstantF()", result); @@ -1037,7 +1037,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) } data->drawstate.shader_params = shader_params; } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV data->drawstate.texture = texture; } else if (texture) { @@ -1086,7 +1086,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) d3dviewport.MaxZ = 1.0f; IDirect3DDevice9_SetViewport(data->device, &d3dviewport); - /* Set an orthographic projection matrix */ + // Set an orthographic projection matrix if (viewport->w && viewport->h) { D3DMATRIX d3dmatrix; SDL_zero(d3dmatrix); @@ -1146,7 +1146,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v } if (vertsize > 0) { - /* upload the new VBO data for this set of commands. */ + // upload the new VBO data for this set of commands. vbo = data->vertexBuffers[vboidx]; if (data->vertexBufferSize[vboidx] < vertsize) { const DWORD usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; @@ -1165,16 +1165,16 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v 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. :( */ + 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. :( } } } - /* cycle through a few VBOs so D3D has some time with the data before we replace it. */ + // cycle through a few VBOs so D3D has some time with the data before we replace it. if (vbo) { data->currentVertexBuffer++; if (data->currentVertexBuffer >= SDL_arraysize(data->vertexBuffers)) { @@ -1243,16 +1243,16 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled; } - /* Don't reset the viewport if we don't have to! */ + // 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 */ + // 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. */ + 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); } @@ -1300,13 +1300,13 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: @@ -1402,7 +1402,7 @@ static int D3D_RenderPresent(SDL_Renderer *renderer) result = IDirect3DDevice9_TestCooperativeLevel(data->device); if (result == D3DERR_DEVICELOST) { - /* We'll reset later */ + // We'll reset later return -1; } if (result == D3DERR_DEVICENOTRESET) { @@ -1455,7 +1455,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer) if (data) { int i; - /* Release the render target */ + // Release the render target if (data->defaultRenderTarget) { IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; @@ -1472,7 +1472,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer) } } #endif - /* Release all vertex buffers */ + // Release all vertex buffers for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) { if (data->vertexBuffers[i]) { IDirect3DVertexBuffer9_Release(data->vertexBuffers[i]); @@ -1499,13 +1499,13 @@ static int D3D_Reset(SDL_Renderer *renderer) SDL_Texture *texture; int i; - /* Cancel any scene that we've started */ + // Cancel any scene that we've started if (!data->beginScene) { IDirect3DDevice9_EndScene(data->device); data->beginScene = SDL_TRUE; } - /* Release the default render target before reset */ + // Release the default render target before reset if (data->defaultRenderTarget) { IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; @@ -1515,7 +1515,7 @@ static int D3D_Reset(SDL_Renderer *renderer) data->currentRenderTarget = NULL; } - /* Release application render targets */ + // Release application render targets for (texture = renderer->textures; texture; texture = texture->next) { if (texture->access == SDL_TEXTUREACCESS_TARGET) { D3D_DestroyTexture(renderer, texture); @@ -1524,7 +1524,7 @@ static int D3D_Reset(SDL_Renderer *renderer) } } - /* Release all vertex buffers */ + // Release all vertex buffers for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) { if (data->vertexBuffers[i]) { IDirect3DVertexBuffer9_Release(data->vertexBuffers[i]); @@ -1536,14 +1536,14 @@ static int D3D_Reset(SDL_Renderer *renderer) result = IDirect3DDevice9_Reset(data->device, &data->pparams); if (FAILED(result)) { if (result == D3DERR_DEVICELOST) { - /* Don't worry about it, we'll reset later... */ + // Don't worry about it, we'll reset later... return 0; } else { return D3D_SetError("Reset()", result); } } - /* Allocate application render targets */ + // Allocate application render targets for (texture = renderer->textures; texture; texture = texture->next) { if (texture->access == SDL_TEXTUREACCESS_TARGET) { D3D_CreateTexture(renderer, texture, 0); @@ -1558,7 +1558,7 @@ static int D3D_Reset(SDL_Renderer *renderer) IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX *)&d3dmatrix); - /* Let the application know that render targets were reset */ + // Let the application know that render targets were reset { SDL_Event event; event.type = SDL_EVENT_RENDER_TARGETS_RESET; @@ -1605,7 +1605,7 @@ static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync) data->pparams.PresentationInterval = PresentationInterval; if (D3D_Reset(renderer) < 0) { - /* D3D_Reset will call SDL_SetError() */ + // D3D_Reset will call SDL_SetError() return -1; } return 0; @@ -1659,7 +1659,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie renderer->QueueSetViewport = D3D_QueueNoOp; renderer->QueueSetDrawColor = D3D_QueueNoOp; 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->InvalidateCachedState = D3D_InvalidateCachedState; renderer->RunCommandQueue = D3D_RunCommandQueue; @@ -1697,7 +1697,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie } pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - /* Get the adapter for the display that the window is on */ + // Get the adapter for the display that the window is on displayID = SDL_GetDisplayForWindow(window); data->adapter = SDL_GetDirect3D9AdapterIndex(displayID); @@ -1726,7 +1726,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie return D3D_SetError("CreateDevice()", result); } - /* Get presentation parameters to fill info */ + // Get presentation parameters to fill info result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); if (FAILED(result)) { return D3D_SetError("GetSwapChain()", result); @@ -1746,11 +1746,11 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie data->enableSeparateAlphaBlend = SDL_TRUE; } - /* Store the default render target */ + // Store the default render target IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); data->currentRenderTarget = NULL; - /* Set up parameters for rendering */ + // Set up parameters for rendering D3D_InitRenderState(data); #if SDL_HAVE_YUV if (caps.MaxSimultaneousTextures >= 3) { @@ -1776,4 +1776,4 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie SDL_RenderDriver D3D_RenderDriver = { D3D_CreateRenderer, "direct3d" }; -#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ +#endif // SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED diff --git a/src/render/direct3d/SDL_shaders_d3d.c b/src/render/direct3d/SDL_shaders_d3d.c index 4b468d84ac..0f1b593d19 100644 --- a/src/render/direct3d/SDL_shaders_d3d.c +++ b/src/render/direct3d/SDL_shaders_d3d.c @@ -28,7 +28,7 @@ #include "SDL_shaders_d3d.h" -/* The shaders here were compiled with compile_shaders.bat */ +// The shaders here were compiled with compile_shaders.bat #define g_ps20_main D3D9_PixelShader_YUV #include "D3D9_PixelShader_YUV.h" @@ -45,4 +45,4 @@ HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, return IDirect3DDevice9_CreatePixelShader(d3dDevice, (const DWORD *)D3D9_shaders[shader], pixelShader); } -#endif /* SDL_VIDEO_RENDER_D3D */ +#endif // SDL_VIDEO_RENDER_D3D diff --git a/src/render/direct3d/SDL_shaders_d3d.h b/src/render/direct3d/SDL_shaders_d3d.h index 41d9fdc7eb..b075730d1b 100644 --- a/src/render/direct3d/SDL_shaders_d3d.h +++ b/src/render/direct3d/SDL_shaders_d3d.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* D3D9 shader implementation */ +// D3D9 shader implementation typedef enum { diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 49d299d162..ded8070efc 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -47,11 +47,11 @@ #if WINAPI_FAMILY == WINAPI_FAMILY_APP #include -/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */ +// TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative; -#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ +#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT #if defined(_MSC_VER) && !defined(__clang__) #define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str @@ -68,7 +68,7 @@ extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNati /* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when !!! FIXME: textures are needed. */ -/* Sampler types */ +// Sampler types typedef enum { SDL_D3D11_SAMPLER_NEAREST_CLAMP, @@ -78,14 +78,14 @@ typedef enum SDL_NUM_D3D11_SAMPLERS } SDL_D3D11_sampler_type; -/* Vertex shader, common values */ +// Vertex shader, common values typedef struct { Float4X4 model; Float4X4 projectionAndView; } VertexShaderConstants; -/* These should mirror the definitions in D3D11_PixelShader_Common.hlsli */ +// These should mirror the definitions in D3D11_PixelShader_Common.hlsli //static const float TONEMAP_NONE = 0; //static const float TONEMAP_LINEAR = 1; static const float TONEMAP_CHROME = 2; @@ -122,7 +122,7 @@ typedef struct PixelShaderConstants shader_constants; } PixelShaderState; -/* Per-vertex data */ +// Per-vertex data typedef struct { Float2 pos; @@ -130,7 +130,7 @@ typedef struct SDL_FColor color; } VertexPositionColor; -/* Per-texture data */ +// Per-texture data typedef struct { int w, h; @@ -144,14 +144,14 @@ typedef struct D3D11_Shader shader; const float *YCbCr_matrix; #if SDL_HAVE_YUV - /* YV12 texture support */ + // YV12 texture support SDL_bool yuv; ID3D11Texture2D *mainTextureU; ID3D11ShaderResourceView *mainTextureResourceViewU; ID3D11Texture2D *mainTextureV; ID3D11ShaderResourceView *mainTextureResourceViewV; - /* NV12 texture support */ + // NV12 texture support SDL_bool nv12; ID3D11ShaderResourceView *mainTextureResourceViewNV; @@ -161,14 +161,14 @@ typedef struct #endif } D3D11_TextureData; -/* Blend mode data */ +// Blend mode data typedef struct { SDL_BlendMode blendMode; ID3D11BlendState *blendState; } D3D11_BlendMode; -/* Private renderer data */ +// Private renderer data typedef struct { void *hDXGIMod; @@ -195,15 +195,15 @@ typedef struct D3D_FEATURE_LEVEL featureLevel; SDL_bool pixelSizeChanged; - /* Rasterizers */ + // Rasterizers ID3D11RasterizerState *mainRasterizer; ID3D11RasterizerState *clippedRasterizer; - /* Vertex buffer constants */ + // Vertex buffer constants VertexShaderConstants vertexShaderConstantsData; ID3D11Buffer *vertexShaderConstants; - /* Cached renderer properties */ + // Cached renderer properties DXGI_MODE_ROTATION rotation; ID3D11RenderTargetView *currentRenderTargetView; ID3D11RasterizerState *currentRasterizerState; @@ -320,10 +320,10 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin 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 */ + case SDL_PIXELFORMAT_NV12: // For the Y texture + case SDL_PIXELFORMAT_NV21: // For the Y texture return DXGI_FORMAT_R8_UNORM; - case SDL_PIXELFORMAT_P010: /* For the Y texture */ + case SDL_PIXELFORMAT_P010: // For the Y texture return DXGI_FORMAT_R16_UNORM; default: return DXGI_FORMAT_UNKNOWN; @@ -337,16 +337,16 @@ static void D3D11_ReleaseAll(SDL_Renderer *renderer) D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; SDL_Texture *texture = NULL; - /* Release all textures */ + // Release all textures for (texture = renderer->textures; texture; texture = texture->next) { D3D11_DestroyTexture(renderer, texture); } - /* Release/reset everything else */ + // Release/reset everything else if (data) { int i; - /* Make sure the swap chain is fully released */ + // Make sure the swap chain is fully released if (data->d3dContext) { ID3D11DeviceContext_ClearState(data->d3dContext); ID3D11DeviceContext_Flush(data->d3dContext); @@ -397,7 +397,7 @@ static void D3D11_ReleaseAll(SDL_Renderer *renderer) data->currentShaderResource = NULL; data->currentSampler = NULL; - /* Check for any leaks if in debug mode */ + // Check for any leaks if in debug mode if (data->dxgiDebug) { DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_DETAIL | DXGI_DEBUG_RLO_IGNORE_INTERNAL); IDXGIDebug_ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, rloFlags); @@ -517,7 +517,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen return blendState; } -/* Create resources that depend on the device. */ +// Create resources that depend on the device. static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) { typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); @@ -552,7 +552,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) D3D11_SAMPLER_DESC samplerDesc; D3D11_RASTERIZER_DESC rasterDesc; - /* See if we need debug interfaces */ + // See if we need debug interfaces createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); #ifdef SDL_PLATFORM_WINRT @@ -585,14 +585,14 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) result = E_FAIL; goto done; } -#endif /* SDL_PLATFORM_WINRT */ +#endif // SDL_PLATFORM_WINRT if (createDebug) { #ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__ IDXGIInfoQueue *dxgiInfoQueue = NULL; PFN_CREATE_DXGI_FACTORY2 DXGIGetDebugInterfaceFunc; - /* If the debug hint is set, also create the DXGI factory in debug mode */ + // If the debug hint is set, also create the DXGI factory in debug mode DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); if (!DXGIGetDebugInterfaceFunc) { result = E_FAIL; @@ -614,7 +614,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE); IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE); SAFE_RELEASE(dxgiInfoQueue); -#endif /* __IDXGIInfoQueue_INTERFACE_DEFINED__ */ +#endif // __IDXGIInfoQueue_INTERFACE_DEFINED__ creationFlags = DXGI_CREATE_FACTORY_DEBUG; } @@ -628,7 +628,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* FIXME: Should we use the default adapter? */ + // FIXME: Should we use the default adapter? result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); @@ -640,28 +640,28 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) */ creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; - /* Make sure Direct3D's debugging feature gets used, if the app requests it. */ + // Make sure Direct3D's debugging feature gets used, if the app requests it. if (createDebug) { creationFlags |= D3D11_CREATE_DEVICE_DEBUG; } - /* Create a single-threaded device unless the app requests otherwise. */ + // Create a single-threaded device unless the app requests otherwise. if (!SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) { creationFlags |= D3D11_CREATE_DEVICE_SINGLETHREADED; } - /* Create the Direct3D 11 API device object and a corresponding context. */ + // Create the Direct3D 11 API device object and a corresponding context. result = D3D11CreateDeviceFunc( data->dxgiAdapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, - creationFlags, /* Set set debug and Direct2D compatibility flags. */ - featureLevels, /* List of feature levels this app can support. */ + 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. */ - &data->featureLevel, /* Returns feature level of device created. */ - &d3dContext /* Returns the device immediate context. */ + 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. ); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); @@ -729,7 +729,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Setup space to hold vertex shader constants: */ + // Setup space to hold vertex shader constants: SDL_zero(constantBufferDesc); constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants); constantBufferDesc.Usage = D3D11_USAGE_DEFAULT; @@ -743,7 +743,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Create samplers to use when drawing textures: */ + // Create samplers to use when drawing textures: static struct { D3D11_FILTER filter; @@ -775,7 +775,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) } } - /* Setup Direct3D rasterizer states */ + // Setup Direct3D rasterizer states SDL_zero(rasterDesc); rasterDesc.AntialiasedLineEnable = FALSE; rasterDesc.CullMode = D3D11_CULL_NONE; @@ -800,13 +800,13 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Create blending states: */ + // Create blending states: if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND)) { - /* D3D11_CreateBlendState will set the SDL error, if it fails */ + // D3D11_CreateBlendState will set the SDL error, if it fails goto done; } - /* Setup render state that doesn't change */ + // Setup render state that doesn't change ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout); ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0); ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants); @@ -824,11 +824,11 @@ done: static DXGI_MODE_ROTATION D3D11_GetCurrentRotation(void) { - /* FIXME */ + // FIXME return DXGI_MODE_ROTATION_IDENTITY; } -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) { @@ -907,7 +907,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) IDXGISwapChain3 *swapChain3 = NULL; HRESULT result = S_OK; - /* Create a swap chain using the same adapter as the existing Direct3D device. */ + // Create a swap chain using the same adapter as the existing Direct3D device. DXGI_SWAP_CHAIN_DESC1 swapChainDesc; SDL_zero(swapChainDesc); swapChainDesc.Width = w; @@ -920,18 +920,18 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) swapChainDesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; break; default: - swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */ + swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format. break; } swapChainDesc.Stereo = FALSE; - swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */ + swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling. swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ + swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency. #if SDL_WINAPI_FAMILY_PHONE - 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 */ + 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 if (usingXAML) { swapChainDesc.Scaling = DXGI_SCALING_STRETCH; @@ -946,7 +946,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) swapChainDesc.Scaling = DXGI_SCALING_STRETCH; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; } else { - 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. } #endif swapChainDesc.Flags = 0; @@ -956,7 +956,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) (IUnknown *)data->d3dDevice, coreWindow, &swapChainDesc, - NULL, /* Allow on all displays. */ + NULL, // Allow on all displays. &data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result); @@ -998,7 +998,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) hwnd, &swapChainDesc, NULL, - NULL, /* Allow on all displays. */ + NULL, // Allow on all displays. &data->swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); @@ -1009,7 +1009,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) #else SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to"); goto done; -#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else */ +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else } data->swapEffect = swapChainDesc.SwapEffect; @@ -1024,7 +1024,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) colorspace = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020; break; default: - /* sRGB */ + // sRGB colorspace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; break; } @@ -1036,7 +1036,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) goto done; } } else if (colorspace != DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709) { - /* Not the default, we're not going to be able to present in this colorspace */ + // Not the default, we're not going to be able to present in this colorspace SDL_SetError("Unsupported output colorspace"); result = DXGI_ERROR_UNSUPPORTED; } @@ -1067,17 +1067,17 @@ static HRESULT D3D11_HandleDeviceLost(SDL_Renderer *renderer) result = D3D11_CreateDeviceResources(renderer); if (FAILED(result)) { - /* D3D11_CreateDeviceResources will set the SDL error */ + // D3D11_CreateDeviceResources will set the SDL error return result; } result = D3D11_UpdateForWindowSizeChange(renderer); if (FAILED(result)) { - /* D3D11_UpdateForWindowSizeChange will set the SDL error */ + // D3D11_UpdateForWindowSizeChange will set the SDL error return result; } - /* Let the application know that the device has been reset */ + // Let the application know that the device has been reset { SDL_Event event; event.type = SDL_EVENT_RENDER_DEVICE_RESET; @@ -1088,7 +1088,7 @@ static HRESULT D3D11_HandleDeviceLost(SDL_Renderer *renderer) return S_OK; } -/* Initialize all resources that change when the window's size changes. */ +// Initialize all resources that change when the window's size changes. static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; @@ -1096,7 +1096,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) HRESULT result = S_OK; int w, h; - /* Release the previous render target view */ + // Release the previous render target view D3D11_ReleaseMainRenderTargetView(renderer); /* The width and height of the swap chain must be based on the display's @@ -1108,7 +1108,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) SDL_GetWindowSizeInPixels(renderer->window, &w, &h); #endif data->rotation = D3D11_GetCurrentRotation(); - /* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */ + // SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); if (D3D11_IsDisplayRotated90Degrees(data->rotation)) { int tmp = w; w = h; @@ -1116,16 +1116,16 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } if (data->swapChain) { - /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */ + // IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. #if !defined(SDL_PLATFORM_WINRT) || !SDL_WINAPI_FAMILY_PHONE - /* If the swap chain already exists, resize it. */ + // If the swap chain already exists, resize it. result = IDXGISwapChain_ResizeBuffers(data->swapChain, 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. */ + // 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 @@ -1181,7 +1181,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) goto done; } - /* Create a render target view of the swap chain back buffer. */ + // Create a render target view of the swap chain back buffer. result = ID3D11Device_CreateRenderTargetView(data->d3dDevice, (ID3D11Resource *)backBuffer, NULL, @@ -1207,7 +1207,7 @@ done: return result; } -/* This method is called when the window's size changes. */ +// This method is called when the window's size changes. static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer) { return D3D11_CreateWindowSizeDependentResources(renderer); @@ -1304,7 +1304,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL textureDesc.SampleDesc.Quality = 0; textureDesc.MiscFlags = 0; - /* NV12 textures must have even width and height */ + // NV12 textures must have even width and height if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21 || texture->format == SDL_PIXELFORMAT_P010) { @@ -1407,7 +1407,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL return SDL_SetError("Unsupported YUV colorspace"); } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV SDL_zero(resourceViewDesc); resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace); resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; @@ -1455,7 +1455,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV if (texture->access & SDL_TEXTUREACCESS_TARGET) { D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc; @@ -1512,7 +1512,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; - /* Create a 'staging' texture, which will be used to write to a portion of the main texture. */ + // Create a 'staging' texture, which will be used to write to a portion of the main texture. ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc); stagingTextureDesc.Width = w; stagingTextureDesc.Height = h; @@ -1533,7 +1533,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } - /* Get a write-only pointer to data in the staging texture: */ + // Get a write-only pointer to data in the staging texture: result = ID3D11DeviceContext_Map(rendererData->d3dContext, (ID3D11Resource *)stagingTexture, 0, @@ -1566,7 +1566,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || stagingTextureDesc.Format == DXGI_FORMAT_P010) { - /* Copy the UV plane as well */ + // Copy the UV plane as well h = (h + 1) / 2; if (stagingTextureDesc.Format == DXGI_FORMAT_P010) { length = (length + 3) & ~3; @@ -1583,12 +1583,12 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex } } - /* Commit the pixel buffer's changes back to the staging texture: */ + // Commit the pixel buffer's changes back to the staging texture: ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)stagingTexture, 0); - /* Copy the staging texture's contents back to the texture: */ + // Copy the staging texture's contents back to the texture: ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, (ID3D11Resource *)texture, 0, @@ -1705,7 +1705,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, w = rect->w; h = rect->h; - /* Create a 'staging' texture, which will be used to write to a portion of the main texture. */ + // Create a 'staging' texture, which will be used to write to a portion of the main texture. ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); stagingTextureDesc.Width = w; stagingTextureDesc.Height = h; @@ -1726,7 +1726,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } - /* Get a write-only pointer to data in the staging texture: */ + // Get a write-only pointer to data in the staging texture: result = ID3D11DeviceContext_Map(rendererData->d3dContext, (ID3D11Resource *)stagingTexture, 0, @@ -1774,12 +1774,12 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, dst += textureMemory.RowPitch; } - /* Commit the pixel buffer's changes back to the staging texture: */ + // Commit the pixel buffer's changes back to the staging texture: ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)stagingTexture, 0); - /* Copy the staging texture's contents back to the texture: */ + // Copy the staging texture's contents back to the texture: ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, (ID3D11Resource *)textureData->mainTexture, 0, @@ -1810,7 +1810,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV if (textureData->yuv || textureData->nv12) { - /* It's more efficient to upload directly... */ + // It's more efficient to upload directly... if (!textureData->pixels) { textureData->pitch = texture->w; textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2); @@ -1853,7 +1853,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } - /* Get a write-only pointer to data in the staging texture: */ + // Get a write-only pointer to data in the staging texture: result = ID3D11DeviceContext_Map(rendererData->d3dContext, (ID3D11Resource *)textureData->stagingTexture, 0, @@ -1897,12 +1897,12 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) return; } #endif - /* Commit the pixel buffer's changes back to the staging texture: */ + // Commit the pixel buffer's changes back to the staging texture: ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)textureData->stagingTexture, 0); - /* Copy the staging texture's contents back to the main texture: */ + // Copy the staging texture's contents back to the main texture: ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, (ID3D11Resource *)textureData->mainTexture, 0, @@ -1950,7 +1950,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int D3D11_QueueNoOp(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) @@ -2048,7 +2048,7 @@ static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, 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) { @@ -2123,7 +2123,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer) * SDL_CreateRenderer is calling it, and will call it again later * with a non-empty viewport. */ - /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */ + // SDL_Log("%s, no viewport was set!\n", __FUNCTION__); return -1; } @@ -2149,7 +2149,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer) return SDL_SetError("An unknown DisplayOrientation is being used"); } - /* Update the view matrix */ + // Update the view matrix SDL_zero(view); view.m[0][0] = 2.0f / viewport->w; view.m[1][1] = -2.0f / viewport->h; @@ -2183,7 +2183,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer) orientationAlignedViewport.w = (float)viewport->w; orientationAlignedViewport.h = (float)viewport->h; } - /* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */ + // TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) d3dviewport.TopLeftX = orientationAlignedViewport.x; d3dviewport.TopLeftY = orientationAlignedViewport.y; @@ -2191,7 +2191,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer) d3dviewport.Height = orientationAlignedViewport.h; d3dviewport.MinDepth = 0.0f; d3dviewport.MaxDepth = 1.0f; - /* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); */ + // SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &d3dviewport); data->viewportDirty = SDL_FALSE; @@ -2294,7 +2294,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c shaderResource = NULL; } - /* Make sure the render target isn't bound to a shader */ + // Make sure the render target isn't bound to a shader if (shaderResource != rendererData->currentShaderResource) { ID3D11ShaderResourceView *pNullResource = NULL; ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, 1, &pNullResource); @@ -2311,7 +2311,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c if (rendererData->viewportDirty) { if (D3D11_UpdateViewport(renderer) == 0) { - /* vertexShaderConstantsData.projectionAndView has changed */ + // vertexShaderConstantsData.projectionAndView has changed updateSubresource = SDL_TRUE; } } @@ -2322,7 +2322,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c } else { D3D11_RECT scissorRect; if (D3D11_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE) != 0) { - /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + // D3D11_GetViewportAlignedD3DRect will have set the SDL error return -1; } ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 1, &scissorRect); @@ -2386,7 +2386,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c } SDL_memcpy(&shader_state->shader_constants, shader_constants, sizeof(*shader_constants)); - /* Force the shader parameters to be re-set */ + // Force the shader parameters to be re-set rendererData->currentShader = SHADER_NONE; } if (shader != rendererData->currentShader) { @@ -2486,7 +2486,7 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, 1, &textureData->mainTextureResourceView, textureSampler, matrix); } @@ -2534,7 +2534,7 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, switch (cmd->command) { case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* this isn't currently used in this render backend. */ + break; // this isn't currently used in this render backend. } case SDL_RENDERCMD_SETVIEWPORT: @@ -2600,13 +2600,13 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: @@ -2661,7 +2661,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec goto done; } - /* Create a staging texture to copy the screen's data to: */ + // Create a staging texture to copy the screen's data to: ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc); stagingTextureDesc.Width = rect->w; stagingTextureDesc.Height = rect->h; @@ -2678,9 +2678,9 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec goto done; } - /* Copy the desired portion of the back buffer to the staging texture: */ + // Copy the desired portion of the back buffer to the staging texture: if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) { - /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + // D3D11_GetViewportAlignedD3DRect will have set the SDL error goto done; } @@ -2698,7 +2698,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec 0, &srcBox); - /* Map the staging texture's data to CPU-accessible memory: */ + // Map the staging texture's data to CPU-accessible memory: result = ID3D11DeviceContext_Map(data->d3dContext, (ID3D11Resource *)stagingTexture, 0, @@ -2717,7 +2717,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec textureMemory.pData, textureMemory.RowPitch); - /* Unmap the texture: */ + // Unmap the texture: ID3D11DeviceContext_Unmap(data->d3dContext, (ID3D11Resource *)stagingTexture, 0); @@ -2752,7 +2752,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer) */ 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 */ + // 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) { @@ -2764,7 +2764,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer) if (result == DXGI_ERROR_DEVICE_REMOVED) { D3D11_HandleDeviceLost(renderer); } else if (result == DXGI_ERROR_INVALID_CALL) { - /* We probably went through a fullscreen <-> windowed transition */ + // We probably went through a fullscreen <-> windowed transition D3D11_CreateWindowSizeDependentResources(renderer); } else { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result); @@ -2847,7 +2847,7 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ renderer->QueueSetViewport = D3D11_QueueNoOp; renderer->QueueSetDrawColor = D3D11_QueueNoOp; 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->InvalidateCachedState = D3D11_InvalidateCachedState; renderer->RunCommandQueue = D3D11_RunCommandQueue; @@ -2878,7 +2878,7 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ */ renderer->window = window; - /* Initialize Direct3D resources */ + // Initialize Direct3D resources if (FAILED(D3D11_CreateDeviceResources(renderer))) { return -1; } @@ -2893,4 +2893,4 @@ SDL_RenderDriver D3D11_RenderDriver = { D3D11_CreateRenderer, "direct3d11" }; -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif // SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 36de74eef7..9e04dbcdd7 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -65,7 +65,7 @@ D3D11_GetCurrentRotation() switch (currentOrientation) { #if SDL_WINAPI_FAMILY_PHONE - /* Windows Phone rotations */ + // Windows Phone rotations case DisplayOrientations::Landscape: return DXGI_MODE_ROTATION_ROTATE90; case DisplayOrientations::Portrait: @@ -75,7 +75,7 @@ D3D11_GetCurrentRotation() case DisplayOrientations::PortraitFlipped: return DXGI_MODE_ROTATION_ROTATE180; #else - /* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */ + // Non-Windows-Phone rotations (ex: Windows 8, Windows RT) case DisplayOrientations::Landscape: return DXGI_MODE_ROTATION_IDENTITY; case DisplayOrientations::Portrait: @@ -84,10 +84,10 @@ D3D11_GetCurrentRotation() return DXGI_MODE_ROTATION_ROTATE180; case DisplayOrientations::PortraitFlipped: return DXGI_MODE_ROTATION_ROTATE90; -#endif /* SDL_WINAPI_FAMILY_PHONE */ +#endif // SDL_WINAPI_FAMILY_PHONE } return DXGI_MODE_ROTATION_IDENTITY; } -#endif /* SDL_VIDEO_RENDER_D3D11 */ +#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/src/render/direct3d11/SDL_render_winrt.h b/src/render/direct3d11/SDL_render_winrt.h index 31acdcfafb..f657dacd69 100644 --- a/src/render/direct3d11/SDL_render_winrt.h +++ b/src/render/direct3d11/SDL_render_winrt.h @@ -33,4 +33,4 @@ DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); } #endif -#endif /* SDL_VIDEO_RENDER_D3D11 */ +#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/src/render/direct3d11/SDL_shaders_d3d11.c b/src/render/direct3d11/SDL_shaders_d3d11.c index 7a88999fd9..2b5b00c395 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.c +++ b/src/render/direct3d11/SDL_shaders_d3d11.c @@ -34,7 +34,7 @@ #error Need to build shaders with level_9_3 #endif -/* The shaders here were compiled with compile_shaders.bat */ +// The shaders here were compiled with compile_shaders.bat #define g_main D3D11_PixelShader_Colors #include "D3D11_PixelShader_Colors.h" @@ -67,7 +67,7 @@ SDL_COMPILE_TIME_ASSERT(D3D11_shaders, SDL_arraysize(D3D11_shaders) == NUM_SHADE int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout) { - /* Declare how the input layout for SDL's vertex shader will be setup: */ + // Declare how the input layout for SDL's vertex shader will be setup: 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 }, @@ -75,7 +75,7 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert }; HRESULT result; - /* Load in SDL's one and only vertex shader: */ + // Load in SDL's one and only vertex shader: result = ID3D11Device_CreateVertexShader(d3dDevice, D3D11_VertexShader, sizeof(D3D11_VertexShader), @@ -85,7 +85,7 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result); } - /* Create an input layout for SDL's vertex shader: */ + // Create an input layout for SDL's vertex shader: result = ID3D11Device_CreateInputLayout(d3dDevice, vertexDesc, ARRAYSIZE(vertexDesc), @@ -113,4 +113,4 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1 return 0; } -#endif /* SDL_VIDEO_RENDER_D3D11 */ +#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/src/render/direct3d11/SDL_shaders_d3d11.h b/src/render/direct3d11/SDL_shaders_d3d11.h index 53ce2625a1..3e52eddc90 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.h +++ b/src/render/direct3d11/SDL_shaders_d3d11.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* D3D11 shader implementation */ +// D3D11 shader implementation typedef enum { diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index c192bd07ca..889e91e0f2 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -45,18 +45,18 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str #endif -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* This must be included here as the function definitions in SDL_pixels.c/_c.h are C, not C++ */ +// This must be included here as the function definitions in SDL_pixels.c/_c.h are C, not C++ #include "../../video/SDL_pixels_c.h" /* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when !!! FIXME: textures are needed. */ -/* Sampler types */ +// Sampler types typedef enum { SDL_D3D12_SAMPLER_NEAREST_CLAMP, @@ -66,14 +66,14 @@ typedef enum SDL_D3D12_NUM_SAMPLERS } SDL_D3D12_sampler_type; -/* Vertex shader, common values */ +// Vertex shader, common values typedef struct { Float4X4 model; Float4X4 projectionAndView; } VertexShaderConstants; -/* These should mirror the definitions in D3D12_PixelShader_Common.hlsli */ +// These should mirror the definitions in D3D12_PixelShader_Common.hlsli //static const float TONEMAP_NONE = 0; //static const float TONEMAP_LINEAR = 1; static const float TONEMAP_CHROME = 2; @@ -104,7 +104,7 @@ typedef struct float YCbCr_matrix[16]; } PixelShaderConstants; -/* Per-vertex data */ +// Per-vertex data typedef struct { Float2 pos; @@ -112,7 +112,7 @@ typedef struct SDL_FColor color; } VertexPositionColor; -/* Per-texture data */ +// Per-texture data typedef struct { int w, h; @@ -128,7 +128,7 @@ typedef struct D3D12_Shader shader; const float *YCbCr_matrix; #if SDL_HAVE_YUV - /* YV12 texture support */ + // YV12 texture support SDL_bool yuv; ID3D12Resource *mainTextureU; D3D12_CPU_DESCRIPTOR_HANDLE mainTextureResourceViewU; @@ -139,7 +139,7 @@ typedef struct D3D12_RESOURCE_STATES mainResourceStateV; SIZE_T mainSRVIndexV; - /* NV12 texture support */ + // NV12 texture support SDL_bool nv12; D3D12_CPU_DESCRIPTOR_HANDLE mainTextureResourceViewNV; SIZE_T mainSRVIndexNV; @@ -150,7 +150,7 @@ typedef struct SDL_Rect lockedRect; } D3D12_TextureData; -/* Pipeline State Object data */ +// Pipeline State Object data typedef struct { D3D12_Shader shader; @@ -161,7 +161,7 @@ typedef struct ID3D12PipelineState *pipelineState; } D3D12_PipelineState; -/* Vertex Buffer */ +// Vertex Buffer typedef struct { ID3D12Resource *resource; @@ -169,14 +169,14 @@ typedef struct size_t size; } D3D12_VertexBuffer; -/* For SRV pool allocator */ +// For SRV pool allocator typedef struct { SIZE_T index; void *next; } D3D12_SRVPoolNode; -/* Private renderer data */ +// Private renderer data typedef struct { void *hDXGIMod; @@ -200,7 +200,7 @@ typedef struct DXGI_FORMAT renderTargetFormat; SDL_bool pixelSizeChanged; - /* Descriptor heaps */ + // Descriptor heaps ID3D12DescriptorHeap *rtvDescriptorHeap; UINT rtvDescriptorSize; ID3D12DescriptorHeap *textureRTVDescriptorHeap; @@ -209,17 +209,17 @@ typedef struct ID3D12DescriptorHeap *samplerDescriptorHeap; UINT samplerDescriptorSize; - /* Data needed per backbuffer */ + // Data needed per backbuffer ID3D12CommandAllocator *commandAllocators[SDL_D3D12_NUM_BUFFERS]; ID3D12Resource *renderTargets[SDL_D3D12_NUM_BUFFERS]; UINT64 fenceValue; int currentBackBufferIndex; - /* Fences */ + // Fences ID3D12Fence *fence; HANDLE fenceEvent; - /* Root signature and pipeline state data */ + // Root signature and pipeline state data ID3D12RootSignature *rootSignatures[NUM_ROOTSIGS]; int pipelineStateCount; D3D12_PipelineState *pipelineStates; @@ -228,18 +228,18 @@ typedef struct D3D12_VertexBuffer vertexBuffers[SDL_D3D12_NUM_VERTEX_BUFFERS]; D3D12_CPU_DESCRIPTOR_HANDLE samplers[SDL_D3D12_NUM_SAMPLERS]; - /* Data for staging/allocating textures */ + // Data for staging/allocating textures ID3D12Resource *uploadBuffers[SDL_D3D12_NUM_UPLOAD_BUFFERS]; int currentUploadBuffer; - /* Pool allocator to handle reusing SRV heap indices */ + // Pool allocator to handle reusing SRV heap indices D3D12_SRVPoolNode *srvPoolHead; D3D12_SRVPoolNode srvPoolNodes[SDL_D3D12_MAX_NUM_TEXTURES]; - /* Vertex buffer constants */ + // Vertex buffer constants VertexShaderConstants vertexShaderConstantsData; - /* Cached renderer properties */ + // Cached renderer properties DXGI_MODE_ROTATION rotation; D3D12_TextureData *textureRenderTarget; D3D12_CPU_DESCRIPTOR_HANDLE currentRenderTargetView; @@ -256,7 +256,7 @@ typedef struct SDL_bool issueBatch; } D3D12_RenderData; -/* Define D3D GUIDs here so we don't have to include uuid.lib. */ +// Define D3D GUIDs here so we don't have to include uuid.lib. #ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA #pragma GCC diagnostic push @@ -359,10 +359,10 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin 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 */ + case SDL_PIXELFORMAT_NV12: // For the Y texture + case SDL_PIXELFORMAT_NV21: // For the Y texture return DXGI_FORMAT_R8_UNORM; - case SDL_PIXELFORMAT_P010: /* For the Y texture */ + case SDL_PIXELFORMAT_P010: // For the Y texture return DXGI_FORMAT_R16_UNORM; default: return DXGI_FORMAT_UNKNOWN; @@ -380,12 +380,12 @@ static void D3D12_ReleaseAll(SDL_Renderer *renderer) SDL_SetPointerProperty(props, SDL_PROP_RENDERER_D3D12_DEVICE_POINTER, NULL); SDL_SetPointerProperty(props, SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER, NULL); - /* Release all textures */ + // Release all textures for (texture = renderer->textures; texture; texture = texture->next) { D3D12_DestroyTexture(renderer, texture); } - /* Release/reset everything else */ + // Release/reset everything else if (data) { int i; @@ -432,7 +432,7 @@ static void D3D12_ReleaseAll(SDL_Renderer *renderer) data->currentSampler.ptr = 0; #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* Check for any leaks if in debug mode */ + // Check for any leaks if in debug mode if (data->dxgiDebug) { DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_DETAIL | DXGI_DEBUG_RLO_IGNORE_INTERNAL); IDXGIDebug_ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, rloFlags); @@ -460,7 +460,7 @@ static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *he D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle; SIZE_T offset; - /* Calculate the correct offset into the heap */ + // Calculate the correct offset into the heap D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart); offset = CPUHandle.ptr - CPUHeapStart.ptr; @@ -533,9 +533,9 @@ static void D3D12_ResetCommandList(D3D12_RenderData *data) data->cliprectDirty = SDL_TRUE; data->viewportDirty = SDL_TRUE; data->currentRenderTargetView.ptr = 0; - /* FIXME should we also clear currentSampler.ptr and currentRenderTargetView.ptr ? (and use D3D12_InvalidateCachedState() instead) */ + // FIXME should we also clear currentSampler.ptr and currentRenderTargetView.ptr ? (and use D3D12_InvalidateCachedState() instead) - /* Release any upload buffers that were inflight */ + // Release any upload buffers that were inflight for (i = 0; i < data->currentUploadBuffer; ++i) { D3D_SAFE_RELEASE(data->uploadBuffers[i]); } @@ -548,7 +548,7 @@ static int D3D12_IssueBatch(D3D12_RenderData *data) { HRESULT result = S_OK; - /* Issue the command list */ + // Issue the command list result = ID3D12GraphicsCommandList2_Close(data->commandList); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_IssueBatch"), result); @@ -758,7 +758,7 @@ static HRESULT D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, si return result; } -/* Create resources that depend on the device. */ +// Create resources that depend on the device. static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) { #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -781,13 +781,13 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) D3D12_SAMPLER_DESC samplerDesc; ID3D12DescriptorHeap *rootDescriptorHeaps[2]; - /* See if we need debug interfaces */ + // See if we need debug interfaces createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); #ifdef SDL_PLATFORM_GDK CreateEventExFunc = CreateEventExW; #else - /* CreateEventEx() arrived in Vista, so we need to load it with GetProcAddress for XP. */ + // CreateEventEx() arrived in Vista, so we need to load it with GetProcAddress for XP. { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); CreateEventExFunc = NULL; @@ -838,12 +838,12 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) ID3D12Debug_EnableDebugLayer(data->debugInterface); } } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) result = D3D12_XBOX_CreateDevice(&d3dDevice, createDebug); if (FAILED(result)) { - /* SDL Error is set by D3D12_XBOX_CreateDevice */ + // SDL Error is set by D3D12_XBOX_CreateDevice goto done; } #else @@ -852,7 +852,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) IDXGIInfoQueue *dxgiInfoQueue = NULL; PFN_CREATE_DXGI_FACTORY DXGIGetDebugInterfaceFunc; - /* If the debug hint is set, also create the DXGI factory in debug mode */ + // If the debug hint is set, also create the DXGI factory in debug mode DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); if (!DXGIGetDebugInterfaceFunc) { result = E_FAIL; @@ -874,7 +874,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE); IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE); D3D_SAFE_RELEASE(dxgiInfoQueue); -#endif /* __IDXGIInfoQueue_INTERFACE_DEFINED__ */ +#endif // __IDXGIInfoQueue_INTERFACE_DEFINED__ creationFlags = DXGI_CREATE_FACTORY_DEBUG; } @@ -884,7 +884,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Prefer a high performance adapter if there are multiple choices */ + // Prefer a high performance adapter if there are multiple choices result = IDXGIFactory6_EnumAdapterByGpuPreference(data->dxgiFactory, 0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, @@ -896,7 +896,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } result = D3D12CreateDeviceFunc((IUnknown *)data->dxgiAdapter, - D3D_FEATURE_LEVEL_11_0, /* Request minimum feature level 11.0 for maximum compatibility */ + D3D_FEATURE_LEVEL_11_0, // Request minimum feature level 11.0 for maximum compatibility D3D_GUID(SDL_IID_ID3D12Device1), (void **)&d3dDevice); if (FAILED(result)) { @@ -904,7 +904,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Setup the info queue if in debug mode */ + // Setup the info queue if in debug mode if (createDebug) { ID3D12InfoQueue *infoQueue = NULL; D3D12_MESSAGE_SEVERITY severities[] = { D3D12_MESSAGE_SEVERITY_INFO }; @@ -926,7 +926,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) D3D_SAFE_RELEASE(infoQueue); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) result = ID3D12Device_QueryInterface(d3dDevice, D3D_GUID(SDL_IID_ID3D12Device1), (void **)&data->d3dDevice); if (FAILED(result)) { @@ -934,7 +934,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Create a command queue */ + // Create a command queue SDL_zero(queueDesc); queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; @@ -948,7 +948,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Create the descriptor heaps for the render target view, texture SRVs, and samplers */ + // Create the descriptor heaps for the render target view, texture SRVs, and samplers SDL_zero(descriptorHeapDesc); descriptorHeapDesc.NumDescriptors = SDL_D3D12_NUM_BUFFERS; descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; @@ -1002,7 +1002,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) rootDescriptorHeaps[1] = data->samplerDescriptorHeap; data->samplerDescriptorSize = ID3D12Device1_GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - /* Create a command allocator for each back buffer */ + // Create a command allocator for each back buffer for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { result = ID3D12Device1_CreateCommandAllocator(data->d3dDevice, D3D12_COMMAND_LIST_TYPE_DIRECT, @@ -1014,7 +1014,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } } - /* Create the command list */ + // Create the command list result = ID3D12Device1_CreateCommandList(data->d3dDevice, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, @@ -1027,10 +1027,10 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Set the descriptor heaps to the correct initial value */ + // Set the descriptor heaps to the correct initial value ID3D12GraphicsCommandList2_SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps); - /* Create the fence and fence event */ + // Create the fence and fence event result = ID3D12Device_CreateFence(data->d3dDevice, data->fenceValue, D3D12_FENCE_FLAG_NONE, @@ -1049,7 +1049,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } - /* Create all the root signatures */ + // Create all the root signatures for (i = 0; i < NUM_ROOTSIGS; ++i) { D3D12_SHADER_BYTECODE rootSigData; D3D12_GetRootSignatureData((D3D12_RootSignature)i, &rootSigData); @@ -1074,13 +1074,13 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) }; int j, k, l; - /* Create a few default pipeline state objects, to verify that this renderer will work */ + // Create a few default pipeline state objects, to verify that this renderer will work for (i = 0; i < NUM_SHADERS; ++i) { 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])) { - /* D3D12_CreatePipelineState will set the SDL error, if it fails */ + // D3D12_CreatePipelineState will set the SDL error, if it fails result = E_FAIL; goto done; } @@ -1090,12 +1090,12 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } } - /* Create default vertex buffers */ + // Create default vertex buffers for (i = 0; i < SDL_D3D12_NUM_VERTEX_BUFFERS; ++i) { D3D12_CreateVertexBuffer(data, i, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT); } - /* Create samplers to use when drawing textures: */ + // Create samplers to use when drawing textures: static struct { D3D12_FILTER filter; @@ -1123,7 +1123,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) ID3D12Device1_CreateSampler(data->d3dDevice, &samplerDesc, data->samplers[i]); } - /* Initialize the pool allocator for SRVs */ + // Initialize the pool allocator for SRVs for (i = 0; i < SDL_D3D12_MAX_NUM_TEXTURES; ++i) { data->srvPoolNodes[i].index = (SIZE_T)i; if (i != SDL_D3D12_MAX_NUM_TEXTURES - 1) { @@ -1143,7 +1143,7 @@ done: static DXGI_MODE_ROTATION D3D12_GetCurrentRotation(void) { - /* FIXME */ + // FIXME return DXGI_MODE_ROTATION_IDENTITY; } @@ -1218,7 +1218,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) IDXGISwapChain1 *swapChain = NULL; HRESULT result = S_OK; - /* Create a swap chain using the same adapter as the existing Direct3D device. */ + // Create a swap chain using the same adapter as the existing Direct3D device. DXGI_SWAP_CHAIN_DESC1 swapChainDesc; SDL_zero(swapChainDesc); swapChainDesc.Width = w; @@ -1233,23 +1233,23 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) data->renderTargetFormat = DXGI_FORMAT_R10G10B10A2_UNORM; break; default: - swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */ + swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format. data->renderTargetFormat = DXGI_FORMAT_B8G8R8A8_UNORM; break; } swapChainDesc.Stereo = FALSE; - swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */ + swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling. swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ + swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency. if (WIN_IsWindows8OrGreater()) { swapChainDesc.Scaling = DXGI_SCALING_NONE; } else { swapChainDesc.Scaling = DXGI_SCALING_STRETCH; } - 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 */ + 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 HWND hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); if (!hwnd) { @@ -1263,7 +1263,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) hwnd, &swapChainDesc, NULL, - NULL, /* Allow on all displays. */ + NULL, // Allow on all displays. &swapChain); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); @@ -1300,7 +1300,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) colorspace = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020; break; default: - /* sRGB */ + // sRGB colorspace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; break; } @@ -1312,7 +1312,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) goto done; } } else { - /* Not the default, we're not going to be able to present in this colorspace */ + // Not the default, we're not going to be able to present in this colorspace SDL_SetError("Unsupported output colorspace"); result = DXGI_ERROR_UNSUPPORTED; } @@ -1336,17 +1336,17 @@ D3D12_HandleDeviceLost(SDL_Renderer *renderer) result = D3D12_CreateDeviceResources(renderer); if (FAILED(result)) { - /* D3D12_CreateDeviceResources will set the SDL error */ + // D3D12_CreateDeviceResources will set the SDL error return result; } result = D3D12_UpdateForWindowSizeChange(renderer); if (FAILED(result)) { - /* D3D12_UpdateForWindowSizeChange will set the SDL error */ + // D3D12_UpdateForWindowSizeChange will set the SDL error return result; } - /* Let the application know that the device has been reset */ + // Let the application know that the device has been reset { SDL_Event event; event.type = SDL_EVENT_RENDER_DEVICE_RESET; @@ -1357,7 +1357,7 @@ D3D12_HandleDeviceLost(SDL_Renderer *renderer) return S_OK; } -/* Initialize all resources that change when the window's size changes. */ +// Initialize all resources that change when the window's size changes. static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal; @@ -1367,11 +1367,11 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) D3D12_RENDER_TARGET_VIEW_DESC rtvDesc; D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor; - /* Release resources in the current command list */ + // Release resources in the current command list D3D12_IssueBatch(data); ID3D12GraphicsCommandList2_OMSetRenderTargets(data->commandList, 0, NULL, FALSE, NULL); - /* Release render targets */ + // Release render targets for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { D3D_SAFE_RELEASE(data->renderTargets[i]); } @@ -1389,14 +1389,14 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (data->swapChain) { - /* If the swap chain already exists, resize it. */ + // If the swap chain already exists, resize it. result = IDXGISwapChain_ResizeBuffers(data->swapChain, 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. */ + // 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 @@ -1414,19 +1414,19 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } } - /* Set the proper rotation for the swap chain. */ + // Set the proper rotation for the swap chain. if (WIN_IsWindows8OrGreater()) { if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { - result = IDXGISwapChain4_SetRotation(data->swapChain, data->rotation); /* NOLINT(clang-analyzer-core.NullDereference) */ + result = IDXGISwapChain4_SetRotation(data->swapChain, data->rotation); // NOLINT(clang-analyzer-core.NullDereference) if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetRotation"), result); goto done; } } } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* Get each back buffer render target and create render target views */ + // Get each back buffer render target and create render target views for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) result = D3D12_XBOX_CreateBackBufferTarget(data->d3dDevice, renderer->window->w, renderer->window->h, (void **)&data->renderTargets[i]); @@ -1435,7 +1435,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) goto done; } #else - result = IDXGISwapChain4_GetBuffer(data->swapChain, /* NOLINT(clang-analyzer-core.NullDereference) */ + result = IDXGISwapChain4_GetBuffer(data->swapChain, // NOLINT(clang-analyzer-core.NullDereference) i, D3D_GUID(SDL_IID_ID3D12Resource), (void **)&data->renderTargets[i]); @@ -1455,7 +1455,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) ID3D12Device1_CreateRenderTargetView(data->d3dDevice, data->renderTargets[i], &rtvDesc, rtvDescriptor); } - /* Set back buffer index to current buffer */ + // Set back buffer index to current buffer #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) data->currentBackBufferIndex = 0; #else @@ -1483,11 +1483,11 @@ done: return result; } -/* This method is called when the window's size changes. */ +// This method is called when the window's size changes. static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer *renderer) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal; - /* If the GPU has previous work, wait for it to be done first */ + // If the GPU has previous work, wait for it to be done first D3D12_WaitForGPU(data); return D3D12_CreateWindowSizeDependentResources(renderer); } @@ -1589,7 +1589,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL textureDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; textureDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - /* NV12 textures must have even width and height */ + // NV12 textures must have even width and height if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21 || texture->format == SDL_PIXELFORMAT_P010) { @@ -1703,7 +1703,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL return SDL_SetError("Unsupported YUV colorspace"); } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV SDL_zero(resourceViewDesc); resourceViewDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace); @@ -1755,7 +1755,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL &nvResourceViewDesc, textureData->mainTextureResourceViewNV); } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV if (texture->access & SDL_TEXTUREACCESS_TARGET) { D3D12_RENDER_TARGET_VIEW_DESC renderTargetViewDesc; @@ -1826,7 +1826,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res UINT row, NumRows, RowPitch; UINT64 RowLength; - /* Create an upload buffer, which will be used to write to the main texture. */ + // Create an upload buffer, which will be used to write to the main texture. SDL_zero(textureDesc); D3D_CALL_RET(texture, GetDesc, &textureDesc); textureDesc.Width = w; @@ -1849,7 +1849,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res uploadDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; uploadDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - /* Figure out how much we need to allocate for the upload buffer */ + // Figure out how much we need to allocate for the upload buffer ID3D12Device1_GetCopyableFootprints(rendererData->d3dDevice, &textureDesc, plane, @@ -1866,7 +1866,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res heapProps.CreationNodeMask = 1; heapProps.VisibleNodeMask = 1; - /* Create the upload buffer */ + // Create the upload buffer result = ID3D12Device1_CreateCommittedResource(rendererData->d3dDevice, &heapProps, D3D12_HEAP_FLAG_NONE, @@ -1879,7 +1879,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result); } - /* Get a write-only pointer to data in the upload buffer: */ + // Get a write-only pointer to data in the upload buffer: uploadBuffer = rendererData->uploadBuffers[rendererData->currentUploadBuffer]; result = ID3D12Resource_Map(uploadBuffer, 0, @@ -1909,10 +1909,10 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res } } - /* Commit the changes back to the upload buffer: */ + // Commit the changes back to the upload buffer: ID3D12Resource_Unmap(uploadBuffer, 0, NULL); - /* Make sure the destination is in the correct resource state */ + // Make sure the destination is in the correct resource state D3D12_TransitionResource(rendererData, texture, *resourceState, D3D12_RESOURCE_STATE_COPY_DEST); *resourceState = D3D12_RESOURCE_STATE_COPY_DEST; @@ -1934,12 +1934,12 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res &srcLocation, NULL); - /* Transition the texture to be shader accessible */ + // 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 we've used up all the upload buffers, we need to issue the batch if (rendererData->currentUploadBuffer == SDL_D3D12_NUM_UPLOAD_BUFFERS) { D3D12_IssueBatch(rendererData); } @@ -1963,14 +1963,14 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV if (textureData->yuv) { - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, 0, 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 */ + // Skip to the correct offset into the next texture 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, 0, 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; @@ -1978,7 +1978,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } if (textureData->nv12) { - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); if (texture->format == SDL_PIXELFORMAT_P010) { @@ -1990,7 +1990,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, return -1; } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV return 0; } @@ -2062,7 +2062,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV if (textureData->yuv || textureData->nv12) { - /* It's more efficient to upload directly... */ + // It's more efficient to upload directly... if (!textureData->pixels) { textureData->pitch = texture->w; textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2); @@ -2082,7 +2082,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, return SDL_SetError("texture is already locked"); } - /* Create an upload buffer, which will be used to write to the main texture. */ + // Create an upload buffer, which will be used to write to the main texture. SDL_zero(textureDesc); D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); textureDesc.Width = rect->w; @@ -2100,7 +2100,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, uploadDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; uploadDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - /* Figure out how much we need to allocate for the upload buffer */ + // Figure out how much we need to allocate for the upload buffer ID3D12Device1_GetCopyableFootprints(rendererData->d3dDevice, &textureDesc, 0, @@ -2116,7 +2116,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, heapProps.CreationNodeMask = 1; heapProps.VisibleNodeMask = 1; - /* Create the upload buffer */ + // Create the upload buffer result = ID3D12Device1_CreateCommittedResource(rendererData->d3dDevice, &heapProps, D3D12_HEAP_FLAG_NONE, @@ -2129,7 +2129,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result); } - /* Get a write-only pointer to data in the upload buffer: */ + // Get a write-only pointer to data in the upload buffer: result = ID3D12Resource_Map(textureData->stagingBuffer, 0, NULL, @@ -2189,7 +2189,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) return; } #endif - /* Commit the pixel buffer's changes back to the staging texture: */ + // Commit the pixel buffer's changes back to the staging texture: ID3D12Resource_Unmap(textureData->stagingBuffer, 0, NULL); SDL_zero(textureDesc); @@ -2234,11 +2234,11 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) &srcLocation, NULL); - /* Transition the texture to be shader accessible */ + // Transition the texture to be shader accessible D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - /* Execute the command list before releasing the staging buffer */ + // Execute the command list before releasing the staging buffer D3D12_IssueBatch(rendererData); D3D_SAFE_RELEASE(textureData->stagingBuffer); } @@ -2289,7 +2289,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int D3D12_QueueNoOp(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) @@ -2391,7 +2391,7 @@ static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, range.End = 0; if (dataSizeInBytes == 0) { - return 0; /* nothing to do. */ + return 0; // nothing to do. } if (rendererData->issueBatch) { @@ -2401,7 +2401,7 @@ static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, } } - /* If the existing vertex buffer isn't big enough, we need to recreate a big enough one */ + // If the existing vertex buffer isn't big enough, we need to recreate a big enough one if (dataSizeInBytes > rendererData->vertexBuffers[vbidx].size) { D3D12_CreateVertexBuffer(rendererData, vbidx, dataSizeInBytes); } @@ -2443,7 +2443,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer) * SDL_CreateRenderer is calling it, and will call it again later * with a non-empty viewport. */ - /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */ + // SDL_Log("%s, no viewport was set!\n", __FUNCTION__); return -1; } @@ -2469,7 +2469,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer) return SDL_SetError("An unknown DisplayOrientation is being used"); } - /* Update the view matrix */ + // Update the view matrix SDL_zero(view); view.m[0][0] = 2.0f / viewport->w; view.m[1][1] = -2.0f / viewport->h; @@ -2510,7 +2510,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer) d3dviewport.Height = orientationAlignedViewport.h; d3dviewport.MinDepth = 0.0f; d3dviewport.MaxDepth = 1.0f; - /* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); */ + // SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); ID3D12GraphicsCommandList_RSSetViewports(data->commandList, 1, &d3dviewport); data->viewportDirty = SDL_FALSE; @@ -2601,7 +2601,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c rtvFormat = rendererData->textureRenderTarget->mainTextureFormat; } - /* See if we need to change the pipeline state */ + // See if we need to change the pipeline state if (!currentPipelineState || currentPipelineState->shader != shader || currentPipelineState->blendMode != blendMode || @@ -2626,20 +2626,20 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c } } - /* If we didn't find a match, create a new one -- it must mean the blend mode is non-standard */ + // If we didn't find a match, create a new one -- it must mean the blend mode is non-standard if (!currentPipelineState) { currentPipelineState = D3D12_CreatePipelineState(renderer, shader, blendMode, topology, rtvFormat); } if (!currentPipelineState) { - /* The error has been set inside D3D12_CreatePipelineState() */ + // The error has been set inside D3D12_CreatePipelineState() return -1; } ID3D12GraphicsCommandList2_SetPipelineState(rendererData->commandList, currentPipelineState->pipelineState); ID3D12GraphicsCommandList2_SetGraphicsRootSignature(rendererData->commandList, rendererData->rootSignatures[D3D12_GetRootSignatureType(currentPipelineState->shader)]); - /* When we change these we will need to re-upload the constant buffer and reset any descriptors */ + // When we change these we will need to re-upload the constant buffer and reset any descriptors updateSubresource = SDL_TRUE; rendererData->currentSampler.ptr = 0; rendererData->currentShaderResource.ptr = 0; @@ -2653,7 +2653,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c if (rendererData->viewportDirty) { if (D3D12_UpdateViewport(renderer) == 0) { - /* vertexShaderConstantsData.projectionAndView has changed */ + // vertexShaderConstantsData.projectionAndView has changed updateSubresource = SDL_TRUE; } } @@ -2661,7 +2661,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c if (rendererData->cliprectDirty) { D3D12_RECT scissorRect; if (D3D12_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE) != 0) { - /* D3D12_GetViewportAlignedD3DRect will have set the SDL error */ + // D3D12_GetViewportAlignedD3DRect will have set the SDL error return -1; } ID3D12GraphicsCommandList2_RSSetScissorRects(rendererData->commandList, 1, &scissorRect); @@ -2685,7 +2685,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle = D3D12_CPUtoGPUHandle(rendererData->samplerDescriptorHeap, *sampler); UINT tableIndex = 0; - /* Figure out the correct sampler descriptor table index based on the type of shader */ + // Figure out the correct sampler descriptor table index based on the type of shader switch (shader) { case SHADER_RGB: tableIndex = 3; @@ -2776,7 +2776,7 @@ static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c shaderResources[1] = textureData->mainTextureResourceViewU; shaderResources[2] = textureData->mainTextureResourceViewV; - /* Make sure each texture is in the correct state to be accessed by the pixel shader. */ + // Make sure each texture is in the correct state to be accessed by the pixel shader. D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; D3D12_TransitionResource(rendererData, textureData->mainTextureU, textureData->mainResourceStateU, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); @@ -2791,13 +2791,13 @@ static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c shaderResources[0] = textureData->mainTextureResourceView; shaderResources[1] = textureData->mainTextureResourceViewNV; - /* Make sure each texture is in the correct state to be accessed by the pixel shader. */ + // Make sure each texture is in the correct state to be accessed by the pixel shader. D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; return D3D12_SetDrawState(renderer, cmd, textureData->shader, &constants, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; return D3D12_SetDrawState(renderer, cmd, textureData->shader, &constants, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 1, &textureData->mainTextureResourceView, textureSampler, matrix); @@ -2843,7 +2843,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, switch (cmd->command) { case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* this isn't currently used in this render backend. */ + break; // this isn't currently used in this render backend. } case SDL_RENDERCMD_SETVIEWPORT: @@ -2920,13 +2920,13 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: @@ -2981,7 +2981,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec backBuffer = data->renderTargets[data->currentBackBufferIndex]; } - /* Create a staging texture to copy the screen's data to: */ + // Create a staging texture to copy the screen's data to: SDL_zero(textureDesc); D3D_CALL_RET(backBuffer, GetDesc, &textureDesc); textureDesc.Width = rect->w; @@ -2999,7 +2999,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec readbackDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; readbackDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - /* Figure out how much we need to allocate for the upload buffer */ + // Figure out how much we need to allocate for the upload buffer ID3D12Device1_GetCopyableFootprints(data->d3dDevice, &textureDesc, 0, @@ -3028,12 +3028,12 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec goto done; } - /* Transition the render target to be copyable from */ + // Transition the render target to be copyable from D3D12_TransitionResource(data, backBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - /* Copy the desired portion of the back buffer to the staging texture: */ + // Copy the desired portion of the back buffer to the staging texture: if (D3D12_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) { - /* D3D12_GetViewportAlignedD3DRect will have set the SDL error */ + // D3D12_GetViewportAlignedD3DRect will have set the SDL error goto done; } srcBox.left = srcRect.left; @@ -3043,7 +3043,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec srcBox.front = 0; srcBox.back = 1; - /* Issue the copy texture region */ + // Issue the copy texture region SDL_zero(pitchedDesc); pitchedDesc.Format = textureDesc.Format; pitchedDesc.Width = (UINT)textureDesc.Width; @@ -3072,13 +3072,13 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec &srcLocation, &srcBox); - /* We need to issue the command list for the copy to finish */ + // We need to issue the command list for the copy to finish D3D12_IssueBatch(data); - /* Transition the render target back to a render target */ + // Transition the render target back to a 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: */ + // Map the staging texture's data to CPU-accessible memory: result = ID3D12Resource_Map(readbackBuffer, 0, NULL, @@ -3095,7 +3095,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec textureMemory, pitchedDesc.RowPitch); - /* Unmap the texture: */ + // Unmap the texture: ID3D12Resource_Unmap(readbackBuffer, 0, NULL); done: @@ -3108,13 +3108,13 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal; HRESULT result; - /* Transition the render target to present state */ + // Transition the render target to present state D3D12_TransitionResource(data, data->renderTargets[data->currentBackBufferIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); - /* Issue the command list */ + // Issue the command list result = ID3D12GraphicsCommandList2_Close(data->commandList); ID3D12CommandQueue_ExecuteCommandLists(data->commandQueue, 1, (ID3D12CommandList *const *)&data->commandList); @@ -3134,14 +3134,14 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) if (result == DXGI_ERROR_DEVICE_REMOVED) { D3D12_HandleDeviceLost(renderer); } else if (result == DXGI_ERROR_INVALID_CALL) { - /* We probably went through a fullscreen <-> windowed transition */ + // We probably went through a fullscreen <-> windowed transition D3D12_CreateWindowSizeDependentResources(renderer); } else { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result); } return -1; } else { - /* Wait for the GPU and move to the next frame */ + // Wait for the GPU and move to the next frame result = ID3D12CommandQueue_Signal(data->commandQueue, data->fence, data->fenceValue); if (ID3D12Fence_GetCompletedValue(data->fence) < data->fenceValue) { @@ -3159,7 +3159,7 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) data->currentBackBufferIndex = IDXGISwapChain4_GetCurrentBackBufferIndex(data->swapChain); #endif - /* Reset the command allocator and command list, and transition back to render target */ + // Reset the command allocator and command list, and transition back to render target D3D12_ResetCommandList(data); D3D12_TransitionResource(data, data->renderTargets[data->currentBackBufferIndex], @@ -3201,7 +3201,7 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert } if (SDL_GetWindowFlags(window) & SDL_WINDOW_TRANSPARENT) { - /* D3D12 removed the swap effect needed to support transparent windows, use D3D11 instead */ + // D3D12 removed the swap effect needed to support transparent windows, use D3D11 instead return SDL_SetError("The direct3d12 renderer doesn't work with transparent windows"); } @@ -3235,7 +3235,7 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert renderer->QueueSetViewport = D3D12_QueueNoOp; renderer->QueueSetDrawColor = D3D12_QueueNoOp; 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->InvalidateCachedState = D3D12_InvalidateCachedState; renderer->RunCommandQueue = D3D12_RunCommandQueue; @@ -3267,7 +3267,7 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert */ renderer->window = window; - /* Initialize Direct3D resources */ + // Initialize Direct3D resources if (FAILED(D3D12_CreateDeviceResources(renderer))) { return -1; } @@ -3282,9 +3282,9 @@ SDL_RenderDriver D3D12_RenderDriver = { D3D12_CreateRenderer, "direct3d12" }; -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */ +#endif // SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp index 4274749295..9c667be6bb 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp @@ -75,7 +75,7 @@ D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug) goto done; } - /* Set frame interval */ + // Set frame interval result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result); diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.h b/src/render/direct3d12/SDL_render_d3d12_xbox.h index d90541a469..5c5ec44a69 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.h +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.h @@ -25,7 +25,7 @@ #include "../../SDL_internal.h" #include "../../video/directx/SDL_d3d12.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -36,7 +36,7 @@ extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken); extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget); extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/render/direct3d12/SDL_shaders_d3d12.c b/src/render/direct3d12/SDL_shaders_d3d12.c index edf63dcad5..a22eeb55ba 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.c +++ b/src/render/direct3d12/SDL_shaders_d3d12.c @@ -29,7 +29,7 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str -/* The shaders here were compiled with compile_shaders.bat */ +// The shaders here were compiled with compile_shaders.bat #define g_main D3D12_PixelShader_Colors #include "D3D12_PixelShader_Colors.h" @@ -122,4 +122,4 @@ void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECO outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // SDL_VIDEO_RENDER_D3D12 && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) diff --git a/src/render/direct3d12/SDL_shaders_d3d12.h b/src/render/direct3d12/SDL_shaders_d3d12.h index 71bbb928ec..9f82a4a4e6 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.h +++ b/src/render/direct3d12/SDL_shaders_d3d12.h @@ -20,9 +20,9 @@ */ #include "SDL_internal.h" -/* D3D12 shader implementation */ +// D3D12 shader implementation -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -48,7 +48,7 @@ extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *out extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader); extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp index d43b1b6900..cd3609b849 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp @@ -31,7 +31,7 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str -/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */ +// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat #define g_main D3D12_PixelShader_Colors #include "D3D12_PixelShader_Colors_One.h" @@ -128,6 +128,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXONE) */ +#endif // SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXONE) -/* vi: set ts=4 sw=4 expandtab: */ +// vi: set ts=4 sw=4 expandtab: diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp index 40ccd6e504..a949b7e753 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp @@ -32,7 +32,7 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str -/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */ +// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat #define g_main D3D12_PixelShader_Colors #include "D3D12_PixelShader_Colors_Series.h" @@ -129,6 +129,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXSERIES) -/* vi: set ts=4 sw=4 expandtab: */ +// vi: set ts=4 sw=4 expandtab: diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index b349a97a8c..9573b108d4 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -38,7 +38,7 @@ #import #endif -/* Regenerate these with build-metal-shaders.sh */ +// Regenerate these with build-metal-shaders.sh #ifdef SDL_PLATFORM_MACOS #include "SDL_shaders_metal_macos.h" #elif defined(SDL_PLATFORM_TVOS) @@ -55,10 +55,10 @@ #endif #endif -/* Apple Metal renderer implementation */ +// Apple Metal renderer implementation -/* macOS requires constants in a buffer to have a 256 byte alignment. */ -/* Use native type alignments from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf */ +// macOS requires constants in a buffer to have a 256 byte alignment. +// Use native type alignments from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf #if defined(SDL_PLATFORM_MACOS) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST #define CONSTANT_ALIGN(x) (256) #else @@ -80,7 +80,7 @@ static const size_t CONSTANTS_OFFSET_DECODE_BT2020_LIMITED = ALIGN_CONSTANTS(16, static const size_t CONSTANTS_OFFSET_DECODE_BT2020_FULL = ALIGN_CONSTANTS(16, CONSTANTS_OFFSET_DECODE_BT2020_LIMITED + sizeof(float) * 4 * 4); static const size_t CONSTANTS_LENGTH = CONSTANTS_OFFSET_DECODE_BT2020_FULL + sizeof(float) * 4 * 4; -/* Sampler types */ +// Sampler types typedef enum { SDL_METAL_SAMPLER_NEAREST_CLAMP, @@ -284,7 +284,7 @@ static id MakePipelineState(SDL3METAL_RenderData *data, switch (cache->vertexFunction) { case SDL_METAL_VERTEX_SOLID: - /* position (float2), color (float4) */ + // position (float2), color (float4) vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(float) * 4; vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; @@ -298,7 +298,7 @@ static id MakePipelineState(SDL3METAL_RenderData *data, break; case SDL_METAL_VERTEX_COPY: - /* position (float2), color (float4), texcoord (float2) */ + // position (float2), color (float4), texcoord (float2) vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(float) * 4 + sizeof(float) * 2; vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; @@ -692,7 +692,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL height:(NSUInteger)texture->h mipmapped:NO]; - /* Not available in iOS 8. */ + // Not available in iOS 8. if ([mtltexdesc respondsToSelector:@selector(usage)]) { if (texture->access == SDL_TEXTUREACCESS_TARGET) { mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget; @@ -745,7 +745,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL return SDL_SetError("Texture allocation failed"); } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV texturedata = [[SDL3METAL_TextureData alloc] init]; if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) { texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY; @@ -788,7 +788,7 @@ static void METAL_UploadTextureData(id texture, SDL_Rect rect, int s static MTLStorageMode METAL_GetStorageMode(id resource) { - /* iOS 8 does not have this method. */ + // iOS 8 does not have this method. if ([resource respondsToSelector:@selector(storageMode)]) { return resource.storageMode; } @@ -879,13 +879,13 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, 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 */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, pixels, UVpitch) < 0) { return -1; } - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + UVrect.h * UVpitch); if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, pixels, UVpitch) < 0) { return -1; @@ -896,7 +896,7 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, 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 */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, pixels, UVpitch) < 0) { return -1; @@ -922,7 +922,7 @@ static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, 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 */ + // Bail out if we're supposed to update an empty rectangle if (rect->w <= 0 || rect->h <= 0) { return 0; } @@ -952,7 +952,7 @@ static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, SDL3METAL_TextureData *texturedata = (__bridge SDL3METAL_TextureData *)texture->internal; 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 */ + // Bail out if we're supposed to update an empty rectangle if (rect->w <= 0 || rect->h <= 0) { return 0; } @@ -1090,7 +1090,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) [data.mtlcmdbuffer commit]; data.mtlcmdbuffer = nil; - texturedata.lockedbuffer = nil; /* Retained property, so it calls release. */ + texturedata.lockedbuffer = nil; // Retained property, so it calls release. texturedata.hasdata = YES; } } @@ -1123,7 +1123,7 @@ static int METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - float projection[4][4]; /* Prepare an orthographic projection */ + 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); @@ -1147,7 +1147,7 @@ static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd static int METAL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; // nothing to do in this backend. } static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) @@ -1184,7 +1184,7 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, 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) + 4 * sizeof(float)) * count; verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); @@ -1214,7 +1214,7 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, 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; { @@ -1223,9 +1223,9 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, 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; } } @@ -1289,7 +1289,7 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S return 0; } -/* These should mirror the definitions in SDL_shaders_metal.metal */ +// These should mirror the definitions in SDL_shaders_metal.metal //static const float TONEMAP_NONE = 0; //static const float TONEMAP_LINEAR = 1; static const float TONEMAP_CHROME = 2; @@ -1426,7 +1426,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm clip = statecache->viewport; } - /* Set Scissor Rect Validation: w/h must be <= render pass */ + // Set Scissor Rect Validation: w/h must be <= render pass SDL_zero(output); if (renderer->target) { @@ -1477,7 +1477,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm statecache->constants_offset = constants_offset; } - [data.mtlcmdencoder setVertexBufferOffset:first atIndex:0]; /* position/texcoords */ + [data.mtlcmdencoder setVertexBufferOffset:first atIndex:0]; // position/texcoords return SDL_TRUE; } @@ -1653,13 +1653,13 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: @@ -1817,7 +1817,7 @@ static void METAL_DestroyRenderer(SDL_Renderer *renderer) /* Release the metal view instead of destroying it, in case we want to use it later (recreating the renderer) */ - /* SDL_Metal_DestroyView(data.mtlview); */ + // SDL_Metal_DestroyView(data.mtlview); CFBridgingRelease(data.mtlview); } } @@ -1921,7 +1921,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ id blitcmd; SDL_bool scRGB_supported = SDL_FALSE; - /* Note: matrices are column major. */ + // Note: matrices are column major. float identitytransform[16] = { 1.0f, 0.0f, @@ -1975,7 +1975,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ #endif if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) { if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR && scRGB_supported) { - /* This colorspace is supported */ + // This colorspace is supported } else { return SDL_SetError("Unsupported output colorspace"); } @@ -2018,7 +2018,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ /* Release the metal view instead of destroying it, in case we want to use it later (recreating the renderer) */ - /* SDL_Metal_DestroyView(view); */ + // SDL_Metal_DestroyView(view); CFBridgingRelease(view); return SDL_SetError("SDL3METAL_RenderData alloc/init failed"); } @@ -2049,11 +2049,11 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ layer.colorspace = colorspace; CGColorSpaceRelease(colorspace); } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS layer.device = mtldevice; - /* Necessary for RenderReadPixels. */ + // Necessary for RenderReadPixels. layer.framebufferOnly = NO; data.mtldevice = layer.device; @@ -2072,7 +2072,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ SDL_assert(err == nil); data.mtllibrary.label = @"SDL Metal renderer shader library"; - /* Do some shader pipeline state loading up-front rather than on demand. */ + // Do some shader pipeline state loading up-front rather than on demand. data.pipelinescount = 0; data.allpipelines = NULL; ChooseShaderPipelines(data, MTLPixelFormatBGRA8Unorm); @@ -2196,7 +2196,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ } #endif - /* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf maxtexsize = 4096; #if defined(SDL_PLATFORM_MACOS) || TARGET_OS_MACCATALYST maxtexsize = 16384; @@ -2240,4 +2240,4 @@ SDL_RenderDriver METAL_RenderDriver = { METAL_CreateRenderer, "metal" }; -#endif /* SDL_VIDEO_RENDER_METAL */ +#endif // SDL_VIDEO_RENDER_METAL diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 2d34dddd7d..d682b6b3dc 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" #if SDL_VIDEO_RENDER_OGL -#include "../../video/SDL_sysvideo.h" /* For SDL_RecreateWindow */ +#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow #include #include "../SDL_sysrender.h" #include "SDL_shaders_gl.h" @@ -43,7 +43,7 @@ #define RENDERER_CONTEXT_MAJOR 2 #define RENDERER_CONTEXT_MINOR 1 -/* OpenGL renderer implementation */ +// OpenGL renderer implementation /* Details on optimizing the texture path on macOS: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html @@ -102,12 +102,12 @@ typedef struct SDL_bool GL_EXT_framebuffer_object_supported; GL_FBOList *framebuffers; - /* OpenGL functions */ + // OpenGL functions #define SDL_PROC(ret, func, params) ret (APIENTRY *func) params; #include "SDL_glfuncs.h" #undef SDL_PROC - /* Multitexture support */ + // Multitexture support SDL_bool GL_ARB_multitexture_supported; PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; GLint num_texture_units; @@ -118,7 +118,7 @@ typedef struct PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; - /* Shader support */ + // Shader support GL_ShaderContext *shaders; GL_DrawStateCache drawstate; @@ -139,7 +139,7 @@ typedef struct SDL_Rect locked_rect; #if SDL_HAVE_YUV - /* YUV texture support */ + // YUV texture support SDL_bool yuv; SDL_bool nv12; GLuint utexture; @@ -191,7 +191,7 @@ static void GL_ClearErrors(SDL_Renderer *renderer) } } else if (data->glGetError) { while (data->glGetError() != GL_NO_ERROR) { - /* continue; */ + // continue; } } } @@ -214,7 +214,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c GL_ClearErrors(renderer); } } else { - /* check gl errors (can return multiple errors) */ + // check gl errors (can return multiple errors) for (;;) { GLenum error = data->glGetError(); if (error != GL_NO_ERROR) { @@ -250,7 +250,7 @@ static int GL_LoadFunctions(GL_RenderData *data) retval = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \ } \ } while (0); -#endif /* __SDL_NOGETPROCADDR__ */ +#endif // __SDL_NOGETPROCADDR__ #include "SDL_glfuncs.h" #undef SDL_PROC @@ -278,7 +278,7 @@ static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id GL_RenderData *data = (GL_RenderData *)renderer->internal; if (type == GL_DEBUG_TYPE_ERROR_ARB) { - /* Record this error */ + // Record this error int errors = data->errors + 1; char **error_messages = (char **)SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages)); if (error_messages) { @@ -288,7 +288,7 @@ static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id } } - /* If there's another error callback, pass it along, otherwise log it */ + // If there's another error callback, pass it along, otherwise log it if (data->next_error_callback) { data->next_error_callback(source, type, id, severity, length, message, data->next_error_userparam); } else { @@ -451,8 +451,8 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr GL_ActivateRenderer(renderer); - renderdata->drawstate.texture = NULL; /* we trash this state. */ - renderdata->drawstate.texturing_dirty = SDL_TRUE; /* we trash this state. */ + renderdata->drawstate.texture = NULL; // we trash this state. + renderdata->drawstate.texturing_dirty = SDL_TRUE; // we trash this state. if (texture->access == SDL_TEXTUREACCESS_TARGET && !renderdata->GL_EXT_framebuffer_object_supported) { @@ -475,12 +475,12 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr size = (size_t)texture->h * data->pitch; if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - /* Need to add size for the U and V planes */ + // Need to add size for the U and V planes size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); } if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21) { - /* Need to add size for the U/V plane */ + // Need to add size for the U/V plane size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); } data->pixels = SDL_calloc(1, size); @@ -663,7 +663,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr return SDL_SetError("Unsupported YUV colorspace"); } } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV return GL_CheckError("", renderer); } @@ -676,11 +676,11 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, GL_TextureData *data = (GL_TextureData *)texture->internal; const int texturebpp = SDL_BYTESPERPIXEL(texture->format); - SDL_assert_release(texturebpp != 0); /* otherwise, division by zero later. */ + SDL_assert_release(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); @@ -692,7 +692,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, if (data->yuv) { renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (texture->format == SDL_PIXELFORMAT_YV12) { renderdata->glBindTexture(textype, data->vtexture); @@ -703,7 +703,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, (rect->w + 1) / 2, (rect->h + 1) / 2, data->format, data->formattype, pixels); - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2)); if (texture->format == SDL_PIXELFORMAT_YV12) { renderdata->glBindTexture(textype, data->utexture); @@ -718,7 +718,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, if (data->nv12) { renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); renderdata->glBindTexture(textype, data->utexture); renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2, @@ -742,7 +742,7 @@ static int GL_UpdateTextureYUV(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. renderdata->glBindTexture(textype, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -777,7 +777,7 @@ static int GL_UpdateTextureNV(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. renderdata->glBindTexture(textype, data->texture); renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -875,9 +875,9 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) texturedata = (GL_TextureData *)texture->internal; data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, texturedata->fbo->FBO); - /* TODO: check if texture pixel format allows this operation */ + // TODO: check if texture pixel format allows this operation data->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, data->textype, texturedata->texture, 0); - /* Check FBO status */ + // Check FBO status status = data->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { return SDL_SetError("glFramebufferTexture2DEXT() failed"); @@ -890,7 +890,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) !!! FIXME: VBOs at some point. */ static int GL_QueueNoOp(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) @@ -923,7 +923,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con } cmd->data.draw.count = count; - /* 0.5f offset to hit the center of the pixel. */ + // 0.5f offset to hit the center of the pixel. prevx = 0.5f + points->x; prevy = 0.5f + points->y; *(verts++) = prevx; @@ -936,9 +936,9 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con 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. */ + // bump a little in the direction we are moving in. const GLfloat deltax = xend - xstart; const GLfloat deltay = yend - ystart; const GLfloat angle = SDL_atan2f(deltay, deltax); @@ -1204,16 +1204,16 @@ static void GL_InvalidateCachedState(SDL_Renderer *renderer) cache->cliprect_enabled_dirty = SDL_TRUE; cache->cliprect_dirty = SDL_TRUE; cache->texturing_dirty = SDL_TRUE; - cache->vertex_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */ - cache->color_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */ - cache->texture_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */ + cache->vertex_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. + cache->color_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. + cache->texture_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. cache->color_dirty = SDL_TRUE; cache->clear_color_dirty = SDL_TRUE; } 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... */ + // !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode... GL_RenderData *data = (GL_RenderData *)renderer->internal; if (GL_ActivateRenderer(renderer) < 0) { @@ -1316,13 +1316,13 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_DRAW_LINES: @@ -1331,14 +1331,14 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo size_t count = cmd->data.draw.count; const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); - /* SetDrawState handles glEnableClientState. */ + // SetDrawState handles glEnableClientState. data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); if (count > 2) { - /* joined lines cannot be grouped */ + // joined lines cannot be grouped data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); } else { - /* let's group non joined lines */ + // let's group non joined lines SDL_RenderCommand *finalcmd = cmd; SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; @@ -1346,20 +1346,20 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo while (nextcmd) { 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. */ + 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 */ + 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. */ + 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. */ + 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. */ + cmd = finalcmd; // skip any copy commands we just combined in here. } } break; @@ -1380,11 +1380,11 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ + 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. */ + 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. */ + finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command. count += nextcmd->data.draw.count; } nextcmd = nextcmd->next; @@ -1398,16 +1398,16 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo if (ret == 0) { const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first); - int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ + 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. */ + // SetDrawState handles glEnableClientState. data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts); } else { - /* SetDrawState handles glEnableClientState. */ + // SetDrawState handles glEnableClientState. if (thistexture) { data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 8, verts + 0); data->glColorPointer(4, GL_FLOAT, sizeof(float) * 8, verts + 2); @@ -1420,7 +1420,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo data->glDrawArrays(op, 0, (GLsizei)count); - /* Restore previously set color when we're done. */ + // Restore previously set color when we're done. if (thiscmdtype != SDL_RENDERCMD_DRAW_POINTS) { const float r = data->drawstate.color.r; const float g = data->drawstate.color.g; @@ -1430,7 +1430,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo } } - cmd = finalcmd; /* skip any copy commands we just combined in here. */ + cmd = finalcmd; // skip any copy commands we just combined in here. break; } @@ -1493,7 +1493,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect * return NULL; } - /* Flip the rows to be top-down if necessary */ + // Flip the rows to be top-down if necessary if (!renderer->target) { SDL_bool isstack; int length = rect->w * SDL_BYTESPERPIXEL(format); @@ -1566,7 +1566,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) if (data) { if (data->context) { - /* make sure we delete the right resources! */ + // make sure we delete the right resources! GL_ActivateRenderer(renderer); } @@ -1574,8 +1574,8 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) if (data->GL_ARB_debug_output_supported) { 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 */ + // 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 glDebugMessageCallbackARBFunc(data->next_error_callback, data->next_error_userparam); } if (data->shaders) { @@ -1584,7 +1584,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) if (data->context) { while (data->framebuffers) { GL_FBOList *nextnode = data->framebuffers->next; - /* delete the framebuffer object */ + // delete the framebuffer object data->glDeleteFramebuffersEXT(1, &data->framebuffers->FBO); GL_CheckError("", renderer); SDL_free(data->framebuffers); @@ -1706,13 +1706,13 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro } #ifdef SDL_PLATFORM_MACOS - /* Enable multi-threaded rendering */ + // Enable multi-threaded rendering /* Disabled until Ryan finishes his VBO/PBO code... CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine); */ #endif - /* Check for debug output support */ + // Check for debug output support if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { data->debug_enabled = SDL_TRUE; @@ -1725,7 +1725,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro data->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM_ARB, &data->next_error_userparam); glDebugMessageCallbackARBFunc(GL_HandleDebugMessage, renderer); - /* Make sure our callback is called when errors actually happen */ + // Make sure our callback is called when errors actually happen data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); } @@ -1766,7 +1766,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value); } - /* Check for multitexture support */ + // Check for multitexture support if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB"); if (data->glActiveTextureARB) { @@ -1775,18 +1775,18 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro } } - /* Check for shader support */ + // Check for shader support data->shaders = GL_CreateShaderContext(); SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s", data->shaders ? "ENABLED" : "DISABLED"); #if SDL_HAVE_YUV - /* We support YV12 textures using 3 textures and a shader */ + // We support YV12 textures using 3 textures and a shader if (data->shaders && data->num_texture_units >= 3) { SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12); SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV); } - /* We support NV12 textures using 2 textures and a shader */ + // We support NV12 textures using 2 textures and a shader if (data->shaders && data->num_texture_units >= 2) { SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV12); SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21); @@ -1820,7 +1820,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro goto error; } - /* Set up parameters for rendering */ + // Set up parameters for rendering data->glMatrixMode(GL_MODELVIEW); data->glLoadIdentity(); data->glDisable(GL_DEPTH_TEST); @@ -1829,8 +1829,8 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro data->glDisable(data->textype); data->glClearColor(1.0f, 1.0f, 1.0f, 1.0f); data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - /* This ended up causing video discrepancies between OpenGL and Direct3D */ - /* data->glEnable(GL_LINE_SMOOTH); */ + // This ended up causing video discrepancies between OpenGL and Direct3D + // data->glEnable(GL_LINE_SMOOTH); data->drawstate.color.r = 1.0f; data->drawstate.color.g = 1.0f; @@ -1845,7 +1845,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro error: if (changed_window) { - /* Uh oh, better try to put it back... */ + // Uh oh, better try to put it back... char *error = SDL_strdup(SDL_GetError()); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); @@ -1861,4 +1861,4 @@ SDL_RenderDriver GL_RenderDriver = { GL_CreateRenderer, "opengl" }; -#endif /* SDL_VIDEO_RENDER_OGL */ +#endif // SDL_VIDEO_RENDER_OGL diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 85a2a70dc3..e705fabe7f 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -25,9 +25,9 @@ #include #include "SDL_shaders_gl.h" -/* OpenGL shader implementation */ +// OpenGL shader implementation -/* #define DEBUG_SHADERS */ +// #define DEBUG_SHADERS typedef struct { @@ -61,7 +61,7 @@ struct GL_ShaderContext const float *shader_params[NUM_SHADERS]; }; -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #define COLOR_VERTEX_SHADER \ "varying vec4 v_color;\n" \ @@ -237,14 +237,14 @@ struct GL_ShaderContext * texture_rectangle versions if we choose to use that extension. */ static const char *shader_source[NUM_SHADERS][2] = { - /* SHADER_NONE */ + // SHADER_NONE { NULL, NULL }, - /* SHADER_SOLID */ + // SHADER_SOLID { - /* vertex shader */ + // vertex shader COLOR_VERTEX_SHADER, - /* fragment shader */ + // fragment shader "varying vec4 v_color;\n" "\n" "void main()\n" @@ -253,11 +253,11 @@ static const char *shader_source[NUM_SHADERS][2] = { "}" }, - /* SHADER_RGB */ + // SHADER_RGB { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader "varying vec4 v_color;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D tex0;\n" @@ -270,11 +270,11 @@ static const char *shader_source[NUM_SHADERS][2] = { "}" }, - /* SHADER_RGBA */ + // SHADER_RGBA { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader "varying vec4 v_color;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D tex0;\n" @@ -285,50 +285,50 @@ static const char *shader_source[NUM_SHADERS][2] = { "}" }, #if SDL_HAVE_YUV - /* SHADER_YUV */ + // SHADER_YUV { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader YUV_SHADER_PROLOGUE YUV_SHADER_BODY }, - /* SHADER_NV12_RA */ + // SHADER_NV12_RA { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader NV12_SHADER_PROLOGUE NV12_RA_SHADER_BODY }, - /* SHADER_NV12_RG */ + // SHADER_NV12_RG { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader NV12_SHADER_PROLOGUE NV12_RG_SHADER_BODY }, - /* SHADER_NV21_RA */ + // SHADER_NV21_RA { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader NV12_SHADER_PROLOGUE NV21_RA_SHADER_BODY }, - /* SHADER_NV21_RG */ + // SHADER_NV21_RG { - /* vertex shader */ + // vertex shader TEXTURE_VERTEX_SHADER, - /* fragment shader */ + // fragment shader NV12_SHADER_PROLOGUE NV21_RG_SHADER_BODY }, -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) { @@ -377,7 +377,7 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader ctx->glGetError(); - /* Make sure we use the correct sampler type for our texture type */ + // 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" @@ -388,27 +388,27 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader "#define UVCoordScale 1.0\n"; } - /* Create one program object to rule them all */ + // Create one program object to rule them all data->program = ctx->glCreateProgramObjectARB(); - /* Create the vertex shader */ + // Create the vertex shader data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) { return SDL_FALSE; } - /* Create the fragment shader */ + // Create the fragment shader data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) { return SDL_FALSE; } - /* ... and in the darkness bind them */ + // ... and in the darkness bind them ctx->glAttachObjectARB(data->program, data->vert_shader); ctx->glAttachObjectARB(data->program, data->frag_shader); ctx->glLinkProgramARB(data->program); - /* Set up some uniform variables */ + // Set up some uniform variables ctx->glUseProgramObjectARB(data->program); for (i = 0; i < num_tmus_bound; ++i) { char tex_name[10]; @@ -447,7 +447,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE; } - /* Check for shader support */ + // Check for shader support shaders_supported = SDL_FALSE; if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") && SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && @@ -492,7 +492,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) return NULL; } - /* Compile all the shaders */ + // Compile all the shaders for (i = 0; i < NUM_SHADERS; ++i) { if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) { GL_DestroyShaderContext(ctx); @@ -500,7 +500,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) } } - /* We're done! */ + // We're done! return ctx; } @@ -512,7 +512,7 @@ void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shade ctx->glUseProgramObjectARB(program); if (shader_params && shader_params != ctx->shader_params[shader]) { - /* YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 */ + // YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 location = ctx->glGetUniformLocationARB(program, "Yoffset"); if (location >= 0) { ctx->glUniform3fARB(location, shader_params[0], shader_params[1], shader_params[2]); @@ -543,4 +543,4 @@ void GL_DestroyShaderContext(GL_ShaderContext *ctx) SDL_free(ctx); } -#endif /* SDL_VIDEO_RENDER_OGL */ +#endif // SDL_VIDEO_RENDER_OGL diff --git a/src/render/opengl/SDL_shaders_gl.h b/src/render/opengl/SDL_shaders_gl.h index ce2abfd3bd..73c1a3dbeb 100644 --- a/src/render/opengl/SDL_shaders_gl.h +++ b/src/render/opengl/SDL_shaders_gl.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -/* OpenGL shader implementation */ +// OpenGL shader implementation typedef enum { @@ -49,4 +49,4 @@ extern GL_ShaderContext *GL_CreateShaderContext(void); extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shader_params); extern void GL_DestroyShaderContext(GL_ShaderContext *ctx); -#endif /* SDL_shaders_gl_h_ */ +#endif // SDL_shaders_gl_h_ diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index f52e56af5b..b957594421 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -22,7 +22,7 @@ #if SDL_VIDEO_RENDER_OGL_ES2 -#include "../../video/SDL_sysvideo.h" /* For SDL_RecreateWindow */ +#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow #include #include "../SDL_sysrender.h" #include "../../video/SDL_blit.h" @@ -69,7 +69,7 @@ typedef struct GLES2_TextureData void *pixel_data; int pitch; #if SDL_HAVE_YUV - /* YUV texture support */ + // YUV texture support SDL_bool yuv; SDL_bool nv12; GLuint texture_v; @@ -219,7 +219,7 @@ static void GL_ClearErrors(SDL_Renderer *renderer) return; } while (data->glGetError() != GL_NO_ERROR) { - /* continue; */ + // continue; } } @@ -231,7 +231,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c if (!data->debug_enabled) { return 0; } - /* check gl errors (can return multiple errors) */ + // check gl errors (can return multiple errors) for (;;) { GLenum error = data->glGetError(); if (error != GL_NO_ERROR) { @@ -275,7 +275,7 @@ static int GLES2_LoadFunctions(GLES2_RenderData *data) return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ } \ } while (0); -#endif /* __SDL_NOGETPROCADDR__ */ +#endif // __SDL_NOGETPROCADDR__ #include "SDL_gles2funcs.h" #undef SDL_PROC @@ -304,7 +304,7 @@ static int GLES2_ActivateRenderer(SDL_Renderer *renderer) GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal; if (SDL_GL_GetCurrentContext() != data->context) { - /* Null out the current program to ensure we set it again */ + // Null out the current program to ensure we set it again data->drawstate.program = NULL; if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { @@ -322,7 +322,7 @@ static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal; if (event->type == SDL_EVENT_WINDOW_MINIMIZED) { - /* According to Apple documentation, we need to finish drawing NOW! */ + // According to Apple documentation, we need to finish drawing NOW! data->glFinish(); } } @@ -409,7 +409,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin GLint linkSuccessful; int i; - /* Check if we've already cached this program */ + // Check if we've already cached this program entry = data->program_cache.head; while (entry) { if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) { @@ -433,7 +433,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin return entry; } - /* Create a program cache entry */ + // Create a program cache entry entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); if (!entry) { return NULL; @@ -441,7 +441,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin entry->vertex_shader = vertex; entry->fragment_shader = fragment; - /* Create the program and link it */ + // Create the program and link it entry->id = data->glCreateProgram(); data->glAttachShader(entry->id, vertex); data->glAttachShader(entry->id, fragment); @@ -457,26 +457,26 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin return NULL; } - /* Predetermine locations of uniform variables */ + // Predetermine locations of uniform variables for (i = 0; i < NUM_GLES2_UNIFORMS; ++i) { entry->uniform_locations[i] = data->glGetUniformLocation(entry->id, GLES2_UniformNames[i]); } 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); } - /* Cache the linked program */ + // Cache the linked program if (data->program_cache.head) { entry->next = data->program_cache.head; data->program_cache.head->prev = entry; @@ -486,7 +486,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin data->program_cache.head = entry; ++data->program_cache.count; - /* Evict the last entry from the cache if we exceed the limit */ + // Evict the last entry from the cache if we exceed the limit if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { data->glDeleteProgram(data->program_cache.tail->id); data->program_cache.tail = data->program_cache.tail->prev; @@ -545,7 +545,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G } #endif - /* Compile */ + // Compile id = data->glCreateShader(shader_type); data->glShaderSource(id, num_src, shader_src_list, NULL); data->glCompileShader(id); @@ -573,7 +573,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G return 0; } - /* Cache */ + // Cache data->shader_id_cache[(Uint32)type] = id; return id; @@ -608,7 +608,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, GLES2_ProgramCacheEntry *program; const float *shader_params = NULL; - /* Select an appropriate shader pair for the specified modes */ + // Select an appropriate shader pair for the specified modes vtype = GLES2_SHADER_VERTEX_DEFAULT; switch (source) { case GLES2_IMAGESOURCE_SOLID: @@ -659,7 +659,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, goto fault; } break; -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES: ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES; break; @@ -667,7 +667,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, goto fault; } - /* Load the requested shaders */ + // Load the requested shaders vertex = data->shader_id_cache[(Uint32)vtype]; if (!vertex) { vertex = GLES2_CacheShader(data, vtype, GL_VERTEX_SHADER); @@ -684,7 +684,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, } } - /* Check if we need to change programs at all */ + // Check if we need to change programs at all if (data->drawstate.program && data->drawstate.program->vertex_shader == vertex && data->drawstate.program->fragment_shader == fragment && @@ -692,17 +692,17 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, return 0; } - /* Generate a matching program */ + // Generate a matching program program = GLES2_CacheProgram(data, vertex, fragment); if (!program) { goto fault; } - /* Select that program in OpenGL */ + // Select that program in OpenGL data->glUseProgram(program->id); if (shader_params && shader_params != program->shader_params) { - /* YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 */ + // YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 if (program->uniform_locations[GLES2_UNIFORM_OFFSET] != -1) { data->glUniform3f(program->uniform_locations[GLES2_UNIFORM_OFFSET], shader_params[0], shader_params[1], shader_params[2]); } @@ -723,10 +723,10 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, program->shader_params = shader_params; } - /* Set the current program */ + // Set the current program data->drawstate.program = program; - /* Clean up and return */ + // Clean up and return return 0; fault: data->drawstate.program = NULL; @@ -735,7 +735,7 @@ fault: static int GLES2_QueueNoOp(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) @@ -796,7 +796,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, cmd->data.draw.count = count; - /* 0.5f offset to hit the center of the pixel. */ + // 0.5f offset to hit the center of the pixel. prevx = 0.5f + points->x; prevy = 0.5f + points->y; verts->position.x = prevx; @@ -811,9 +811,9 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, 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. */ + // bump a little in the direction we are moving in. const GLfloat deltax = xend - xstart; const GLfloat deltay = yend - ystart; const GLfloat angle = SDL_atan2f(deltay, deltax); @@ -1020,7 +1020,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co data->drawstate.blend = blend; } - /* all drawing commands use this */ + // 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); @@ -1054,9 +1054,9 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo SDL_Texture *texture = cmd->data.draw.texture; int ret; - /* Pick an appropriate shader */ + // Pick an appropriate shader if (renderer->target) { - /* Check if we need to do color mapping between the source and render target textures */ + // Check if we need to do color mapping between the source and render target textures if (renderer->target->format != texture->format) { switch (texture->format) { case SDL_PIXELFORMAT_BGRA32: @@ -1134,7 +1134,7 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo 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) { @@ -1256,7 +1256,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, } #if USE_VERTEX_BUFFER_OBJECTS - /* upload the new VBO data for this set of commands. */ + // upload the new VBO data for this set of commands. data->glBindBuffer(GL_ARRAY_BUFFER, vbo); if (data->vertex_buffer_size[vboidx] < vertsize) { data->glBufferData(GL_ARRAY_BUFFER, vertsize, vertices, GL_STREAM_DRAW); @@ -1265,12 +1265,12 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, data->glBufferSubData(GL_ARRAY_BUFFER, 0, vertsize, vertices); } - /* cycle through a few VBOs so the GL has some time with the data before we replace it. */ + // cycle through a few VBOs so the GL has some time with the data before we replace it. data->current_vertex_buffer++; 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) { @@ -1334,13 +1334,13 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_DRAW_LINES: @@ -1348,10 +1348,10 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices) == 0) { size_t count = cmd->data.draw.count; if (count > 2) { - /* joined lines cannot be grouped */ + // joined lines cannot be grouped data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count); } else { - /* let's group non joined lines */ + // let's group non joined lines SDL_RenderCommand *finalcmd = cmd; SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; @@ -1359,20 +1359,20 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, while (nextcmd) { 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. */ + 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 */ + 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. */ + 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. */ + 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. */ + cmd = finalcmd; // skip any copy commands we just combined in here. } } break; @@ -1393,11 +1393,11 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ + 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. */ + 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. */ + finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command. count += nextcmd->data.draw.count; } nextcmd = nextcmd->next; @@ -1410,14 +1410,14 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, } if (ret == 0) { - int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */ + 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. */ + cmd = finalcmd; // skip any copy commands we just combined in here. break; } @@ -1435,7 +1435,7 @@ static void GLES2_DestroyRenderer(SDL_Renderer *renderer) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal; - /* Deallocate everything */ + // Deallocate everything if (data) { GLES2_ActivateRenderer(renderer); @@ -1491,9 +1491,9 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL 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 */ + // Determine the corresponding GLES texture format params switch (texture->format) { case SDL_PIXELFORMAT_BGRA32: case SDL_PIXELFORMAT_RGBA32: @@ -1526,7 +1526,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL return SDL_SetError("Unsupported texture access for SDL_PIXELFORMAT_EXTERNAL_OES"); } - /* Allocate a texture struct */ + // Allocate a texture struct data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); if (!data) { return -1; @@ -1547,17 +1547,17 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL #endif scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? GL_NEAREST : GL_LINEAR; - /* Allocate a blob for image renderdata */ + // Allocate a blob for image renderdata if (texture->access == SDL_TEXTUREACCESS_STREAMING) { size_t size; data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); size = (size_t)texture->h * data->pitch; #if SDL_HAVE_YUV if (data->yuv) { - /* Need to add size for the U and V planes */ + // Need to add size for the U and V planes size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); } else if (data->nv12) { - /* Need to add size for the U/V plane */ + // Need to add size for the U/V plane size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); } #endif @@ -1568,7 +1568,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL } } - /* Allocate the texture */ + // Allocate the texture GL_CheckError("", renderer); #if SDL_HAVE_YUV @@ -1677,10 +1677,10 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff 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 */ + // Reformat the texture data into a tightly packed array src_pitch = (size_t)width * bpp; src = (Uint8 *)pixels; if ((size_t)pitch != src_pitch) { @@ -1712,14 +1712,14 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con GLES2_ActivateRenderer(renderer); - /* Bail out if we're supposed to update an empty rectangle */ + // Bail out if we're supposed to update an empty rectangle if (rect->w <= 0 || rect->h <= 0) { 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 */ + // Create a texture subimage with the supplied data data->glBindTexture(tdata->texture_type, tdata->texture); GLES2_TexSubImage2D(data, tdata->texture_type, rect->x, @@ -1732,7 +1732,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con #if SDL_HAVE_YUV if (tdata->yuv) { - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); if (texture->format == SDL_PIXELFORMAT_YV12) { data->glBindTexture(tdata->texture_type, tdata->texture_v); @@ -1748,7 +1748,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con tdata->pixel_type, pixels, (pitch + 1) / 2, 1); - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture 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); @@ -1764,7 +1764,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con tdata->pixel_type, pixels, (pitch + 1) / 2, 1); } else if (tdata->nv12) { - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch); data->glBindTexture(tdata->texture_type, tdata->texture_u); GLES2_TexSubImage2D(data, tdata->texture_type, @@ -1793,12 +1793,12 @@ static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, GLES2_ActivateRenderer(renderer); - /* Bail out if we're supposed to update an empty rectangle */ + // Bail out if we're supposed to update an empty rectangle if (rect->w <= 0 || rect->h <= 0) { 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, @@ -1843,12 +1843,12 @@ static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, GLES2_ActivateRenderer(renderer); - /* Bail out if we're supposed to update an empty rectangle */ + // Bail out if we're supposed to update an empty rectangle if (rect->w <= 0 || rect->h <= 0) { 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, @@ -1879,7 +1879,7 @@ static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const { GLES2_TextureData *tdata = (GLES2_TextureData *)texture->internal; - /* Retrieve the buffer/pitch for the specified region */ + // Retrieve the buffer/pitch for the specified region *pixels = (Uint8 *)tdata->pixel_data + (tdata->pitch * rect->y) + (rect->x * SDL_BYTESPERPIXEL(texture->format)); @@ -1893,7 +1893,7 @@ static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_TextureData *tdata = (GLES2_TextureData *)texture->internal; SDL_Rect rect; - /* We do whole texture updates, at least for now */ + // We do whole texture updates, at least for now rect.x = 0; rect.y = 0; rect.w = texture->w; @@ -1945,9 +1945,9 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) } else { texturedata = (GLES2_TextureData *)texture->internal; data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO); - /* TODO: check if texture pixel format allows this operation */ + // TODO: check if texture pixel format allows this operation data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0); - /* Check FBO status */ + // Check FBO status status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { return SDL_SetError("glFramebufferTexture2D() failed"); @@ -1970,7 +1970,7 @@ static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.target = NULL; } - /* Destroy the texture */ + // Destroy the texture if (tdata) { if (tdata->texture && !tdata->texture_external) { data->glDeleteTextures(1, &tdata->texture); @@ -2010,7 +2010,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec return NULL; } - /* Flip the rows to be top-down if necessary */ + // Flip the rows to be top-down if necessary if (!renderer->target) { SDL_bool isstack; int length = rect->w * SDL_BYTESPERPIXEL(format); @@ -2032,7 +2032,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec static int GLES2_RenderPresent(SDL_Renderer *renderer) { - /* Tell the video driver to swap buffers */ + // Tell the video driver to swap buffers return SDL_GL_SwapWindow(renderer->window); } @@ -2073,7 +2073,7 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync) static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props) { GLES2_RenderData *data = NULL; - SDL_WindowFlags window_flags = 0; /* -Wconditional-uninitialized */ + SDL_WindowFlags window_flags = 0; // -Wconditional-uninitialized GLint window_framebuffer; GLint value; int profile_mask = 0, major = 0, minor = 0; @@ -2092,7 +2092,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ SDL_SyncWindow(window); window_flags = SDL_GetWindowFlags(window); - /* OpenGL ES 3.0 is a superset of OpenGL ES 2.0 */ + // OpenGL ES 3.0 is a superset of OpenGL ES 2.0 if (!(window_flags & SDL_WINDOW_OPENGL) || profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major < RENDERER_CONTEXT_MAJOR) { @@ -2127,7 +2127,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_BGRX32); SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBX32); - /* Create an OpenGL ES 2.0 context */ + // Create an OpenGL ES 2.0 context data->context = SDL_GL_CreateContext(window); if (!data->context) { goto error; @@ -2144,7 +2144,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ goto error; } - /* Check for debug output support */ + // Check for debug output support if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { data->debug_enabled = SDL_TRUE; @@ -2155,7 +2155,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value); #if USE_VERTEX_BUFFER_OBJECTS - /* we keep a few of these and cycle through them, so data can live for a few frames. */ + // we keep a few of these and cycle through them, so data can live for a few frames. data->glGenBuffers(SDL_arraysize(data->vertex_buffers), data->vertex_buffers); #endif @@ -2163,7 +2163,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); data->window_framebuffer = (GLuint)window_framebuffer; - /* Populate the function pointers for the module */ + // Populate the function pointers for the module renderer->WindowEvent = GLES2_WindowEvent; renderer->SupportsBlendMode = GLES2_SupportsBlendMode; renderer->CreateTexture = GLES2_CreateTexture; @@ -2211,7 +2211,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ data->GL_EXT_blend_minmax_supported = SDL_TRUE; } - /* Set up parameters for rendering */ + // Set up parameters for rendering data->glActiveTexture(GL_TEXTURE0); data->glPixelStorei(GL_PACK_ALIGNMENT, 1); data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -2235,7 +2235,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ error: if (changed_window) { - /* Uh oh, better try to put it back... */ + // Uh oh, better try to put it back... char *error = SDL_strdup(SDL_GetError()); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); @@ -2251,4 +2251,4 @@ SDL_RenderDriver GLES2_RenderDriver = { GLES2_CreateRenderer, "opengles2" }; -#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ +#endif // SDL_VIDEO_RENDER_OGL_ES2 diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c index 1a3a2349af..7bbc5ca104 100644 --- a/src/render/opengles2/SDL_shaders_gles2.c +++ b/src/render/opengles2/SDL_shaders_gles2.c @@ -25,7 +25,7 @@ #include #include "SDL_shaders_gles2.h" -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off /************************************************************************************************* * Vertex/fragment shader source * @@ -100,7 +100,7 @@ static const char GLES2_Fragment_TextureABGR[] = \ "}\n" \ ; -/* ARGB to ABGR conversion */ +// ARGB to ABGR conversion static const char GLES2_Fragment_TextureARGB[] = \ "uniform sampler2D u_texture;\n" \ "varying mediump vec4 v_color;\n" \ @@ -116,7 +116,7 @@ static const char GLES2_Fragment_TextureARGB[] = \ "}\n" \ ; -/* RGB to ABGR conversion */ +// RGB to ABGR conversion static const char GLES2_Fragment_TextureRGB[] = \ "uniform sampler2D u_texture;\n" \ "varying mediump vec4 v_color;\n" \ @@ -133,7 +133,7 @@ static const char GLES2_Fragment_TextureRGB[] = \ "}\n" \ ; -/* BGR to ABGR conversion */ +// BGR to ABGR conversion static const char GLES2_Fragment_TextureBGR[] = \ "uniform sampler2D u_texture;\n" \ "varying mediump vec4 v_color;\n" \ @@ -256,13 +256,13 @@ static const char GLES2_Fragment_TextureBGR[] = \ " gl_FragColor *= v_color;\n" \ "}" \ -/* YUV to ABGR conversion */ +// YUV to ABGR conversion static const char GLES2_Fragment_TextureYUV[] = \ YUV_SHADER_PROLOGUE \ YUV_SHADER_BODY \ ; -/* NV12 to ABGR conversion */ +// NV12 to ABGR conversion static const char GLES2_Fragment_TextureNV12_RA[] = \ YUV_SHADER_PROLOGUE \ NV12_RA_SHADER_BODY \ @@ -272,7 +272,7 @@ static const char GLES2_Fragment_TextureNV12_RG[] = \ NV12_RG_SHADER_BODY \ ; -/* NV21 to ABGR conversion */ +// NV21 to ABGR conversion static const char GLES2_Fragment_TextureNV21_RA[] = \ YUV_SHADER_PROLOGUE \ NV21_RA_SHADER_BODY \ @@ -283,7 +283,7 @@ static const char GLES2_Fragment_TextureNV21_RG[] = \ ; #endif -/* Custom Android video format texture */ +// Custom Android video format texture static const char GLES2_Fragment_TextureExternalOES_Prologue[] = \ "#extension GL_OES_EGL_image_external : require\n" \ "\n" \ @@ -300,7 +300,7 @@ static const char GLES2_Fragment_TextureExternalOES[] = \ "}\n" \ ; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on /************************************************************************************************* * Shader selector * @@ -384,4 +384,4 @@ const char *GLES2_GetShader(GLES2_ShaderType type) } } -#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ +#endif // SDL_VIDEO_RENDER_OGL_ES2 diff --git a/src/render/opengles2/SDL_shaders_gles2.h b/src/render/opengles2/SDL_shaders_gles2.h index ff09969374..7ad28f2580 100644 --- a/src/render/opengles2/SDL_shaders_gles2.h +++ b/src/render/opengles2/SDL_shaders_gles2.h @@ -50,7 +50,7 @@ typedef enum GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RA, GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RG, #endif - /* Shaders beyond this point are optional and not cached at render creation */ + // Shaders beyond this point are optional and not cached at render creation GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GLES2_SHADER_COUNT } GLES2_ShaderType; @@ -60,6 +60,6 @@ extern const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type); extern const char *GLES2_GetShader(GLES2_ShaderType type); extern GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void); -#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ +#endif // SDL_VIDEO_RENDER_OGL_ES2 -#endif /* SDL_shaders_gles2_h_ */ +#endif // SDL_shaders_gles2_h_ diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index 6d76f1494e..7dc147ed0f 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -41,9 +41,9 @@ #pragma GCC diagnostic pop #endif -/* turn black GS Screen */ +// turn black GS Screen #define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80) -/* Size of Persistent drawbuffer (Single Buffered) */ +// Size of Persistent drawbuffer (Single Buffered) #define RENDER_QUEUE_PER_POOLSIZE 1024 * 256 // 256K of persistent renderqueue /* Size of Oneshot drawbuffer (Double Buffered, so it uses this size * 2) */ #define RENDER_QUEUE_OS_POOLSIZE 1024 * 1024 * 2 // 2048K of oneshot renderqueue @@ -54,12 +54,12 @@ typedef struct uint64_t drawColor; SDL_Rect *viewport; int32_t vsync_callback_id; - int vsync; /* 0 (Disabled), 1 (Enabled), -1 (Dynamic) */ + int vsync; // 0 (Disabled), 1 (Enabled), -1 (Dynamic) } PS2_RenderData; static int vsync_sema_id = 0; -/* PRIVATE METHODS */ +// PRIVATE METHODS static int vsync_handler(void) { iSignalSema(vsync_sema_id); @@ -68,7 +68,7 @@ static int vsync_handler(void) return 0; } -/* Copy of gsKit_sync_flip, but without the 'flip' */ +// Copy of gsKit_sync_flip, but without the 'flip' static void gsKit_sync(GSGLOBAL *gsGlobal) { if (!gsGlobal->FirstFrame) { @@ -78,7 +78,7 @@ static void gsKit_sync(GSGLOBAL *gsGlobal) ; } -/* Copy of gsKit_sync_flip, but without the 'sync' */ +// Copy of gsKit_sync_flip, but without the 'sync' static void gsKit_flip(GSGLOBAL *gsGlobal) { if (!gsGlobal->FirstFrame) { @@ -230,7 +230,7 @@ static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) static int PS2_QueueNoOp(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) @@ -338,7 +338,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL static int PS2_RenderSetViewPort(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_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) @@ -349,7 +349,7 @@ static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) const SDL_Rect *rect = &cmd->data.cliprect.rect; if (cmd->data.cliprect.enabled) { - /* We need to do it relative to saved viewport */ + // We need to do it relative to saved viewport viewport->x += rect->x; viewport->y += rect->y; viewport->w = SDL_min(viewport->w, rect->w); @@ -375,20 +375,20 @@ static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) PS2_RenderData *data = (PS2_RenderData *)renderer->internal; - /* Clear the screen, so let's put default viewport */ + // Clear the screen, so let's put default viewport gsKit_set_scissor(data->gsGlobal, GS_SCISSOR_RESET); - /* Put back original offset */ + // Put back original offset offsetX = data->gsGlobal->OffsetX; offsetY = data->gsGlobal->OffsetY; data->gsGlobal->OffsetX = (int)(2048.0f * 16.0f); data->gsGlobal->OffsetY = (int)(2048.0f * 16.0f); gsKit_clear(data->gsGlobal, float_GS_SETREG_RGBAQ(&cmd->data.color.color, cmd->data.color.color_scale)); - /* Put back original offset */ + // Put back original offset data->gsGlobal->OffsetX = offsetX; data->gsGlobal->OffsetY = offsetY; - // /* Put back view port */ + // // Put back view port viewport = data->viewport; gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h)); @@ -418,7 +418,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode) } case SDL_BLENDMODE_BLEND_PREMULTIPLIED: { - /* FIXME: What are the settings for this? */ + // FIXME: What are the settings for this? 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; @@ -431,7 +431,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode) } case SDL_BLENDMODE_ADD_PREMULTIPLIED: { - /* FIXME: What are the settings for this? */ + // FIXME: What are the settings for this? 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; @@ -439,7 +439,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode) case SDL_BLENDMODE_MUL: case SDL_BLENDMODE_MOD: { - /* We don't fully support MOD and MUL, however this is the best we can do */ + // 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; @@ -477,7 +477,7 @@ int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *c PS2_SetBlendMode(data, cmd->data.draw.blend); gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts); - /* We're done! */ + // We're done! return 0; } @@ -490,13 +490,13 @@ int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * PS2_SetBlendMode(data, cmd->data.draw.blend); gsKit_prim_list_points(data->gsGlobal, count, verts); - /* We're done! */ + // We're done! return 0; } static void PS2_InvalidateCachedState(SDL_Renderer *renderer) { - /* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */ + // currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. } static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -506,7 +506,7 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v case SDL_RENDERCMD_SETVIEWPORT: { PS2_RenderSetViewPort(renderer, cmd); - /* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */ + // FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 break; } case SDL_RENDERCMD_SETCLIPRECT: @@ -534,11 +534,11 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v PS2_RenderLines(renderer, vertices, cmd); break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: { @@ -651,7 +651,7 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr return -1; } - /* Specific gsKit init */ + // Specific gsKit init sema.init_count = 0; sema.max_count = 1; sema.option = 0; @@ -724,4 +724,4 @@ SDL_RenderDriver PS2_RenderDriver = { PS2_CreateRenderer, "PS2 gsKit" }; -#endif /* SDL_VIDEO_RENDER_PS2 */ +#endif // SDL_VIDEO_RENDER_PS2 diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 35f34ffa7b..0ea1520e31 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -36,7 +36,7 @@ #include #include -/* PSP renderer implementation, based on the PGE */ +// PSP renderer implementation, based on the PGE #define PSP_SCREEN_WIDTH 480 #define PSP_SCREEN_HEIGHT 272 @@ -170,7 +170,7 @@ static inline int InVram(void *data) return data < (void *)0x04200000; } -/* Return next power of 2 */ +// Return next power of 2 static int TextureNextPow2(unsigned int w) { unsigned int n = 2; @@ -547,15 +547,15 @@ static void TextureActivate(SDL_Texture *texture) PSP_TextureData *psp_texture = (PSP_TextureData *)texture->internal; int scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? GU_NEAREST : GU_LINEAR; - /* Swizzling is useless with small textures. */ + // Swizzling is useless with small textures. if (TextureShouldSwizzle(psp_texture, texture)) { TextureSwizzle(psp_texture, NULL); } 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 */ + sceGuTexFilter(scaleMode, scaleMode); // GU_NEAREST good for tile-map + // GU_LINEAR good for scaling sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data); } @@ -604,7 +604,7 @@ static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_TextureData *psp_texture = (PSP_TextureData *)texture->internal; SDL_Rect rect; - /* We do whole texture updates, at least for now */ + // We do whole texture updates, at least for now rect.x = 0; rect.y = 0; rect.w = texture->w; @@ -614,7 +614,7 @@ static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) static void PSP_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) { - /* Nothing to do because TextureActivate takes care of it */ + // Nothing to do because TextureActivate takes care of it } static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) @@ -624,7 +624,7 @@ static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int PSP_QueueNoOp(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) @@ -1012,7 +1012,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) break; case SDL_BLENDMODE_MUL: sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); - /* FIXME SDL_BLENDMODE_MUL is simplified, and dstA is in fact un-changed.*/ + // FIXME SDL_BLENDMODE_MUL is simplified, and dstA is in fact un-changed. sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuEnable(GU_BLEND); break; @@ -1043,7 +1043,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) static void PSP_InvalidateCachedState(SDL_Renderer *renderer) { - /* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */ + // currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. } static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -1086,7 +1086,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v 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); - /* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */ + // FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 break; } @@ -1194,7 +1194,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v if (!cmd->data.draw.texture) { const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first); sceGuDisable(GU_TEXTURE_2D); - /* In GU_SMOOTH mode */ + // In GU_SMOOTH mode sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts); sceGuEnable(GU_TEXTURE_2D); } else { @@ -1319,7 +1319,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr renderer->QueueSetViewport = PSP_QueueNoOp; renderer->QueueSetDrawColor = PSP_QueueNoOp; 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; @@ -1364,7 +1364,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr data->frontbuffer = ((uint8_t *)doublebuffer) + PSP_FRAME_BUFFER_SIZE * data->bpp; sceGuInit(); - /* setup GU */ + // setup GU sceGuStart(GU_DIRECT, DisplayList); sceGuDrawBuffer(data->psm, vrelptr(data->frontbuffer), PSP_FRAME_BUFFER_WIDTH); sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, vrelptr(data->backbuffer), PSP_FRAME_BUFFER_WIDTH); @@ -1374,11 +1374,11 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr sceGuDisable(GU_DEPTH_TEST); - /* Scissoring */ + // Scissoring sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); - /* Backface culling */ + // Backface culling /* FIXME: Culling probably un-needed ? It can conflict with SDL_RENDERCMD_GEOMETRY sceGuFrontFace(GU_CCW); @@ -1393,7 +1393,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr sceDisplayWaitVblankStartCB(); sceGuDisplay(GU_TRUE); - /* Improve performance when VSYC is enabled and it is not reaching the 60 FPS */ + // Improve performance when VSYC is enabled and it is not reaching the 60 FPS data->vblank_not_reached = SDL_TRUE; sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, data); sceKernelEnableSubIntr(PSP_VBLANK_INT, 0); @@ -1405,4 +1405,4 @@ SDL_RenderDriver PSP_RenderDriver = { PSP_CreateRenderer, "PSP" }; -#endif /* SDL_VIDEO_RENDER_PSP */ +#endif // SDL_VIDEO_RENDER_PSP diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c index df42f4517f..5fc2b228ac 100644 --- a/src/render/software/SDL_blendfillrect.c +++ b/src/render/software/SDL_blendfillrect.c @@ -243,14 +243,14 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, return SDL_InvalidParamError("SDL_BlendFillRect(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (SDL_BITSPERPIXEL(dst->format) < 8) { return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format"); } - /* If 'rect' == NULL, then fill the whole surface */ + // If 'rect' == NULL, then fill the whole surface if (rect) { - /* Perform clipping */ + // Perform clipping if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) { return 0; } @@ -286,7 +286,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, } else { return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a); } - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break } break; default: @@ -313,7 +313,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_InvalidParamError("SDL_BlendFillRects(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (dst->internal->format->bits_per_pixel < 8) { return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format"); } @@ -324,7 +324,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, b = DRAW_MUL(b, a); } - /* FIXME: Does this function pointer slow things down significantly? */ + // FIXME: Does this function pointer slow things down significantly? switch (dst->internal->format->bits_per_pixel) { case 15: switch (dst->internal->format->Rmask) { @@ -362,7 +362,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } for (i = 0; i < count; ++i) { - /* Perform clipping */ + // Perform clipping if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) { continue; } @@ -371,4 +371,4 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_blendfillrect.h b/src/render/software/SDL_blendfillrect.h index 8ab67d2efd..9d5f1108b2 100644 --- a/src/render/software/SDL_blendfillrect.h +++ b/src/render/software/SDL_blendfillrect.h @@ -27,4 +27,4 @@ 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_ */ +#endif // SDL_blendfillrect_h_ diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index 8b53d5ca3f..77115b0b96 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -900,7 +900,7 @@ static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fm } else { return SDL_BlendLine_RGB2; } - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break case 4: if (fmt->Rmask == 0x00FF0000) { if (fmt->Amask) { @@ -933,8 +933,8 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, return SDL_SetError("SDL_BlendLine(): Unsupported surface format"); } - /* Perform clipping */ - /* FIXME: We don't actually want to clip, as it may change line slope */ + // Perform clipping + // FIXME: We don't actually want to clip, as it may change line slope if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) { return 0; } @@ -967,13 +967,13 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, x2 = points[i].x; y2 = points[i].y; - /* Perform clipping */ - /* FIXME: We don't actually want to clip, as it may change line slope */ + // Perform clipping + // FIXME: We don't actually want to clip, as it may change line slope if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) { continue; } - /* Draw the end if it was clipped */ + // Draw the end if it was clipped draw_end = (x2 != points[i].x || y2 != points[i].y); func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end); @@ -985,4 +985,4 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_blendline.h b/src/render/software/SDL_blendline.h index ad079545b6..057e3b0f26 100644 --- a/src/render/software/SDL_blendline.h +++ b/src/render/software/SDL_blendline.h @@ -27,4 +27,4 @@ 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_ */ +#endif // SDL_blendline_h_ diff --git a/src/render/software/SDL_blendpoint.c b/src/render/software/SDL_blendpoint.c index 4ccdabe170..8cfedd0851 100644 --- a/src/render/software/SDL_blendpoint.c +++ b/src/render/software/SDL_blendpoint.c @@ -241,12 +241,12 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint return SDL_InvalidParamError("SDL_BlendPoint(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (SDL_BITSPERPIXEL(dst->format) < 8) { return SDL_SetError("SDL_BlendPoint(): Unsupported surface format"); } - /* Perform clipping */ + // Perform clipping if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y || x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) || y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) { @@ -280,7 +280,7 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint } else { return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a); } - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break } break; default: @@ -309,7 +309,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, return SDL_InvalidParamError("SDL_BlendPoints(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (dst->internal->format->bits_per_pixel < 8) { return SDL_SetError("SDL_BlendPoints(): Unsupported surface format"); } @@ -320,7 +320,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, b = DRAW_MUL(b, a); } - /* FIXME: Does this function pointer slow things down significantly? */ + // FIXME: Does this function pointer slow things down significantly? switch (dst->internal->format->bits_per_pixel) { case 15: switch (dst->internal->format->Rmask) { @@ -376,4 +376,4 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_blendpoint.h b/src/render/software/SDL_blendpoint.h index 7b4b679ba3..d1a6c552c3 100644 --- a/src/render/software/SDL_blendpoint.h +++ b/src/render/software/SDL_blendpoint.h @@ -27,4 +27,4 @@ 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_ */ +#endif // SDL_blendpoint_h_ diff --git a/src/render/software/SDL_draw.h b/src/render/software/SDL_draw.h index 08c8aba819..e1277f1f45 100644 --- a/src/render/software/SDL_draw.h +++ b/src/render/software/SDL_draw.h @@ -424,7 +424,7 @@ #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) -/* Horizontal line */ +// Horizontal line #define HLINE(type, op, draw_end) \ { \ int length; \ @@ -446,7 +446,7 @@ } \ } -/* Vertical line */ +// Vertical line #define VLINE(type, op, draw_end) \ { \ int length; \ @@ -468,7 +468,7 @@ } \ } -/* Diagonal line */ +// Diagonal line #define DLINE(type, op, draw_end) \ { \ int length; \ @@ -503,7 +503,7 @@ } \ } -/* Bresenham's line algorithm */ +// Bresenham's line algorithm #define BLINE(x1, y1, x2, y2, op, draw_end) \ { \ int i, deltax, deltay, numpixels; \ @@ -563,7 +563,7 @@ } \ } -/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */ +// 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; \ diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index 1794331010..d529bb73fe 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -146,8 +146,8 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) return SDL_SetError("SDL_DrawLine(): Unsupported surface format"); } - /* Perform clipping */ - /* FIXME: We don't actually want to clip, as it may change line slope */ + // Perform clipping + // FIXME: We don't actually want to clip, as it may change line slope if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) { return 0; } @@ -180,13 +180,13 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, x2 = points[i].x; y2 = points[i].y; - /* Perform clipping */ - /* FIXME: We don't actually want to clip, as it may change line slope */ + // Perform clipping + // FIXME: We don't actually want to clip, as it may change line slope if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) { continue; } - /* Draw the end if the whole line is a single point or it was clipped */ + // Draw the end if the whole line is a single point or it was clipped draw_end = ((x1 == x2) && (y1 == y2)) || (x2 != points[i].x || y2 != points[i].y); func(dst, x1, y1, x2, y2, color, draw_end); @@ -197,4 +197,4 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_drawline.h b/src/render/software/SDL_drawline.h index 1bbb827f1c..1486de0836 100644 --- a/src/render/software/SDL_drawline.h +++ b/src/render/software/SDL_drawline.h @@ -27,4 +27,4 @@ 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_ */ +#endif // SDL_drawline_h_ diff --git a/src/render/software/SDL_drawpoint.c b/src/render/software/SDL_drawpoint.c index 89174487a4..d61ddce94a 100644 --- a/src/render/software/SDL_drawpoint.c +++ b/src/render/software/SDL_drawpoint.c @@ -31,12 +31,12 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) return SDL_InvalidParamError("SDL_DrawPoint(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (dst->internal->format->bits_per_pixel < 8) { return SDL_SetError("SDL_DrawPoint(): Unsupported surface format"); } - /* Perform clipping */ + // Perform clipping if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y || x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) || y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) { @@ -71,7 +71,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, return SDL_InvalidParamError("SDL_DrawPoints(): dst"); } - /* This function doesn't work on surfaces < 8 bpp */ + // This function doesn't work on surfaces < 8 bpp if (dst->internal->format->bits_per_pixel < 8) { return SDL_SetError("SDL_DrawPoints(): Unsupported surface format"); } @@ -106,4 +106,4 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_drawpoint.h b/src/render/software/SDL_drawpoint.h index 6766f9d957..06e8829360 100644 --- a/src/render/software/SDL_drawpoint.h +++ b/src/render/software/SDL_drawpoint.h @@ -27,4 +27,4 @@ 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_ */ +#endif // SDL_drawpoint_h_ diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index cbabcfff30..ddab8c2e88 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -35,7 +35,7 @@ #include "SDL_triangle.h" #include "../../video/SDL_pixels_c.h" -/* SDL surface based renderer implementation */ +// SDL surface based renderer implementation typedef struct { @@ -189,7 +189,7 @@ static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int SW_QueueNoOp(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) @@ -301,7 +301,7 @@ static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surf float scale_x, float scale_y, SDL_ScaleMode scaleMode) { int retval; - /* Renderer scaling, if needed */ + // Renderer scaling, if needed if (scale_x != 1.0f || scale_y != 1.0f) { SDL_Rect r; r.x = (int)((float)dstrect->x * scale_x); @@ -363,29 +363,29 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex SDL_GetSurfaceAlphaMod(src, &alphaMod); SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod); - /* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */ + // SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) { blitRequired = SDL_TRUE; } - /* If scaling and cropping is necessary, it has to be taken care of before the rotation. */ + // If scaling and cropping is necessary, it has to be taken care of before the rotation. if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) { blitRequired = SDL_TRUE; } - /* srcrect is not selecting the whole src surface, so cropping is needed */ + // srcrect is not selecting the whole src surface, so cropping is needed if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) { blitRequired = SDL_TRUE; } - /* The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes. */ + // The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes. if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) { applyModulation = SDL_TRUE; SDL_SetSurfaceAlphaMod(src_clone, alphaMod); SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod); } - /* Opaque surfaces are much easier to handle with the NONE blend mode. */ + // Opaque surfaces are much easier to handle with the NONE blend mode. if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) { isOpaque = SDL_TRUE; } @@ -419,7 +419,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex } } - /* SDLgfx_rotateSurface is going to make decisions depending on the blend mode. */ + // SDLgfx_rotateSurface is going to make decisions depending on the blend mode. SDL_SetSurfaceBlendMode(src_clone, blendmode); if (!retval) { @@ -435,7 +435,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex retval = -1; } if (!retval && mask) { - /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ + // 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); @@ -455,11 +455,11 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex */ if (blendmode != SDL_BLENDMODE_NONE || isOpaque) { if (applyModulation == SDL_FALSE) { - /* If the modulation wasn't already applied, make it happen now. */ + // If the modulation wasn't already applied, make it happen now. SDL_SetSurfaceAlphaMod(src_rotated, alphaMod); SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod); } - /* Renderer scaling, if needed */ + // Renderer scaling, if needed retval = Blit_to_Screen(src_rotated, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode); } else { /* The NONE blend mode requires three steps to get the pixels onto the destination surface. @@ -469,7 +469,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex */ SDL_Rect mask_rect = tmp_rect; SDL_SetSurfaceBlendMode(mask_rotated, SDL_BLENDMODE_NONE); - /* Renderer scaling, if needed */ + // Renderer scaling, if needed retval = Blit_to_Screen(mask_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode); if (!retval) { /* The next step copies the alpha value. This is done with the BLEND blend mode and @@ -478,7 +478,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex */ SDL_SetSurfaceColorMod(src_rotated, 0, 0, 0); mask_rect = tmp_rect; - /* Renderer scaling, if needed */ + // Renderer scaling, if needed retval = Blit_to_Screen(src_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode); if (!retval) { /* The last step gets the color values in place. The ADD blend mode simply adds them to @@ -491,7 +491,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex retval = -1; } else { SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD); - /* Renderer scaling, if needed */ + // Renderer scaling, if needed retval = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode); SDL_DestroySurface(src_rotated_rgb); } @@ -637,7 +637,7 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache * SDL_SetSurfaceRLE(surface, 0); } - /* !!! FIXME: we can probably avoid some of these calls. */ + // !!! FIXME: we can probably avoid some of these calls. SDL_SetSurfaceColorMod(surface, r, g, b); SDL_SetSurfaceAlphaMod(surface, a); SDL_SetSurfaceBlendMode(surface, blend); @@ -648,7 +648,7 @@ 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_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ + SDL_assert_release(viewport != NULL); // the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT if (cliprect && viewport) { SDL_Rect clip_rect; @@ -667,7 +667,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) static void SW_InvalidateCachedState(SDL_Renderer *renderer) { - /* SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here! */ + // SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here! } @@ -719,7 +719,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo const Uint8 g = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.g * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f); const Uint8 b = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.b * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f); const Uint8 a = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.a, 0.0f, 1.0f) * 255.0f); - /* By definition the clear ignores the clip rect */ + // By definition the clear ignores the clip rect SDL_SetSurfaceClipRect(surface, NULL); SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a)); drawstate.surface_cliprect_dirty = SDL_TRUE; @@ -737,7 +737,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo const SDL_BlendMode blend = cmd->data.draw.blend; SetDrawState(surface, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { @@ -765,7 +765,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo const SDL_BlendMode blend = cmd->data.draw.blend; SetDrawState(surface, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { @@ -793,7 +793,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo const SDL_BlendMode blend = cmd->data.draw.blend; SetDrawState(surface, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { @@ -822,7 +822,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { dstrect->x += drawstate.viewport->x; dstrect->y += drawstate.viewport->y; @@ -836,10 +836,10 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo */ SDL_SetSurfaceRLE(surface, 0); - /* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */ + // 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_CreateSurface(dstrect->w, dstrect->h, src->format); - /* Scale to an intermediate surface, then blit */ + // Scale to an intermediate surface, then blit if (tmp) { SDL_Rect r; SDL_BlendMode blendmode; @@ -866,7 +866,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_BlitSurface(tmp, NULL, surface, dstrect); SDL_DestroySurface(tmp); - /* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */ + // No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() } } else { SDL_BlitSurfaceScaled(src, srcrect, surface, dstrect, texture->scaleMode); @@ -881,7 +881,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); PrepTextureForCopy(cmd, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { copydata->dstrect.x += drawstate.viewport->x; copydata->dstrect.y += drawstate.viewport->y; @@ -910,7 +910,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd, &drawstate); - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; @@ -934,7 +934,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo } else { GeometryFillData *ptr = (GeometryFillData *)verts; - /* Apply viewport */ + // Apply viewport if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; @@ -1019,7 +1019,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer) static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormat format) { - /* Prefer the format used by the framebuffer by default. */ + // Prefer the format used by the framebuffer by default. SDL_AddSupportedTextureFormat(renderer, format); switch (format) { @@ -1140,7 +1140,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD renderer->QueueSetViewport = SW_QueueNoOp; renderer->QueueSetDrawColor = SW_QueueNoOp; 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; @@ -1169,7 +1169,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props) { - /* Set the vsync hint based on our flags, if it's not already set */ + // Set the vsync hint based on our flags, if it's not already set const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); const SDL_bool no_hint_set = (!hint || !*hint); @@ -1183,7 +1183,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro SDL_Surface *surface = SDL_GetWindowSurface(window); - /* Reset the vsync hint if we set it above */ + // Reset the vsync hint if we set it above if (no_hint_set) { SDL_SetHint(SDL_HINT_RENDER_VSYNC, ""); } @@ -1199,4 +1199,4 @@ SDL_RenderDriver SW_RenderDriver = { SW_CreateRenderer, SDL_SOFTWARE_RENDERER }; -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_render_sw_c.h b/src/render/software/SDL_render_sw_c.h index 27eb84ded4..060c8ce0f9 100644 --- a/src/render/software/SDL_render_sw_c.h +++ b/src/render/software/SDL_render_sw_c.h @@ -24,4 +24,4 @@ extern int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props); -#endif /* SDL_render_sw_c_h_ */ +#endif // SDL_render_sw_c_h_ diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 35446fd051..85a25adadc 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -40,7 +40,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net #include "../../video/SDL_blit.h" -/* ---- Internally used structures */ +// ---- Internally used structures /** A 32 bit RGBA pixel. @@ -85,7 +85,7 @@ static Uint32 get_colorkey(SDL_Surface *src) return key; } -/* rotate (sx, sy) by (angle, center) into (dx, dy) */ +// 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) { sx -= center->x; @@ -143,24 +143,24 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S rect_dest->x = minx; rect_dest->y = miny; - /* reverse the angle because our rotations are clockwise */ + // reverse the angle because our rotations are clockwise *sangle = -sinangle; *cangle = cosangle; { - /* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */ + // 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 */ + 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 */ + angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg } if (angle90 & 1) { rect_dest->w = height; rect_dest->h = width; *cangle = 0; - *sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */ + *sangle = angle90 == 1 ? -1 : 1; // reversed because our rotations are clockwise } else { rect_dest->w = width; rect_dest->h = height; @@ -171,7 +171,7 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S } } -/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */ +// 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) { @@ -179,7 +179,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int if (flipx) { bpp = -bpp; } - switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ + switch (angle) { // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; @@ -212,7 +212,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int } } -/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */ +// 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; \ @@ -495,7 +495,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in int colorKeyAvailable = SDL_FALSE; double sangleinv, cangleinv; - /* Sanity check */ + // Sanity check if (!SDL_SurfaceValid(src)) { return NULL; } @@ -505,41 +505,41 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in colorKeyAvailable = SDL_TRUE; } } - /* This function requires a 32-bit surface or 8-bit surface with a colorkey */ + // This function requires a 32-bit surface or 8-bit surface with a colorkey is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable; if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) { return NULL; } - /* Calculate target factors from sine/cosine and zoom */ + // Calculate target factors from sine/cosine and zoom sangleinv = sangle * 65536.0; cangleinv = cangle * 65536.0; - /* Alloc space to completely contain the rotated surface */ + // Alloc space to completely contain the rotated surface rz_dst = NULL; if (is8bit) { - /* Target surface is 8 bit */ + // Target surface is 8 bit rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format); if (rz_dst) { SDL_SetSurfacePalette(rz_dst, src->internal->palette); } } else { - /* Target surface is 32 bit with source RGBA ordering */ + // Target surface is 32 bit with source RGBA ordering rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format); } - /* Check target */ + // Check target if (!rz_dst) { return NULL; } - /* Adjust for guard rows */ + // Adjust for guard rows rz_dst->h = rect_dest->h; SDL_GetSurfaceBlendMode(src, &blendmode); if (colorKeyAvailable == SDL_TRUE) { - /* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */ + // If available, the colorkey will be used to discard the pixels that are outside of the rotated area. SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey); SDL_FillSurfaceRect(rz_dst, NULL, colorkey); } else if (blendmode == SDL_BLENDMODE_NONE) { @@ -559,7 +559,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in SDL_SetSurfaceBlendMode(rz_dst, blendmode); - /* Lock source surface */ + // Lock source surface if (SDL_MUSTLOCK(src)) { if (SDL_LockSurface(src) < 0) { SDL_DestroySurface(rz_dst); @@ -575,7 +575,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (angle90 == angle / 90) { angle90 %= 4; if (angle90 < 0) { - angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */ + angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg } } else { @@ -583,7 +583,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in } if (is8bit) { - /* Call the 8-bit transformation routine to do the rotation */ + // Call the 8-bit transformation routine to do the rotation if (angle90 >= 0) { transformSurfaceY90(src, rz_dst, angle90, flipx, flipy); } else { @@ -591,7 +591,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in flipx, flipy, rect_dest, center); } } else { - /* Call the 32-bit transformation routine to do the rotation */ + // Call the 32-bit transformation routine to do the rotation if (angle90 >= 0) { transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy); } else { @@ -600,13 +600,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in } } - /* Unlock source surface */ + // Unlock source surface if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } - /* Return rotated surface */ + // Return rotated surface return rz_dst; } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_rotate.h b/src/render/software/SDL_rotate.h index 9e08e53abb..a33b1e3c5e 100644 --- a/src/render/software/SDL_rotate.h +++ b/src/render/software/SDL_rotate.h @@ -27,4 +27,4 @@ extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smo extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center, SDL_Rect *rect_dest, double *cangle, double *sangle); -#endif /* SDL_rotate_h_ */ +#endif // SDL_rotate_h_ diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 4abc01a7b2..8c945e9078 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -87,13 +87,13 @@ int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color) } #endif -/* cross product AB x AC */ +// cross product AB x AC static Sint64 cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int c_y) { return ((Sint64)(b->x - a->x)) * ((Sint64)(c_y - a->y)) - ((Sint64)(b->y - a->y)) * ((Sint64)(c_x - a->x)); } -/* check for top left rules */ +// check for top left rules static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise) { if (is_clockwise) { @@ -114,8 +114,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise) return 0; } -/* x = (y << FP_BITS) */ -/* prevent runtime error: left shift of negative value */ +// x = (y << FP_BITS) +// prevent runtime error: left shift of negative value #define PRECOMP(x, y) \ val = y; \ if (val >= 0) { \ @@ -133,21 +133,21 @@ void trianglepoint_2_fixedpoint(SDL_Point *a) PRECOMP(a->y, a->y); } -/* bounding rect of three points (in fixed point) */ +// bounding rect of three points (in fixed point) static void bounding_rect_fixedpoint(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r) { int min_x = SDL_min(a->x, SDL_min(b->x, c->x)); int max_x = SDL_max(a->x, SDL_max(b->x, c->x)); int min_y = SDL_min(a->y, SDL_min(b->y, c->y)); int max_y = SDL_max(a->y, SDL_max(b->y, c->y)); - /* points are in fixed point, shift back */ + // points are in fixed point, shift back r->x = min_x >> FP_BITS; r->y = min_y >> FP_BITS; r->w = (max_x - min_x) >> FP_BITS; r->h = (max_y - min_y) >> FP_BITS; } -/* bounding rect of three points */ +// bounding rect of three points static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r) { int min_x = SDL_min(a->x, SDL_min(b->x, c->x)); @@ -180,7 +180,7 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin 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 */ +// 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); \ @@ -253,12 +253,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin is_uniform = COLOR_EQ(c0, c1) && COLOR_EQ(c1, c2); - /* Flat triangle */ + // Flat triangle if (area == 0) { return 0; } - /* Lock the destination, if needed */ + // Lock the destination, if needed if (SDL_MUSTLOCK(dst)) { if (SDL_LockSurface(dst) < 0) { ret = -1; @@ -271,7 +271,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin bounding_rect_fixedpoint(d0, d1, d2, &dstrect); { - /* Clip triangle rect with surface rect */ + // Clip triangle rect with surface rect SDL_Rect rect; rect.x = 0; rect.y = 0; @@ -281,7 +281,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin } { - /* Clip triangle with surface clip rect */ + // Clip triangle with surface clip rect SDL_Rect rect; SDL_GetSurfaceClipRect(dst, &rect); SDL_GetRectIntersection(&dstrect, &rect, &dstrect); @@ -290,12 +290,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin if (blend != SDL_BLENDMODE_NONE) { SDL_PixelFormat format = dst->format; - /* need an alpha format */ + // need an alpha format if (!SDL_ISPIXELFORMAT_ALPHA(format)) { format = SDL_PIXELFORMAT_ARGB8888; } - /* Use an intermediate surface */ + // Use an intermediate surface tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format); if (!tmp) { ret = -1; @@ -314,7 +314,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin dst_pitch = tmp->pitch; } else { - /* Write directly to destination surface */ + // Write directly to destination surface dstbpp = dst->internal->format->bytes_per_pixel; dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch; dst_pitch = dst->pitch; @@ -335,7 +335,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin PRECOMP(d0d1_x, d1->x - d0->x) } - /* Starting point for rendering, at the middle of a pixel */ + // Starting point for rendering, at the middle of a pixel { SDL_Point p; p.x = dstrect.x; @@ -348,7 +348,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin w2_row = cross_product(d0, d1, p.x, p.y); } - /* Handle anti-clockwise triangles */ + // Handle anti-clockwise triangles if (!is_clockwise) { d2d1_y *= -1; d0d2_y *= -1; @@ -361,7 +361,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin w2_row *= -1; } - /* Add a bias to respect top-left rasterization rule */ + // Add a bias to respect top-left rasterization rule bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1); bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1); bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1); @@ -507,12 +507,12 @@ int SDL_SW_BlitTriangle( area = cross_product(d0, d1, d2->x, d2->y); - /* Flat triangle */ + // Flat triangle if (area == 0) { return 0; } - /* Lock the destination, if needed */ + // Lock the destination, if needed if (SDL_MUSTLOCK(dst)) { if (SDL_LockSurface(dst) < 0) { ret = -1; @@ -522,7 +522,7 @@ int SDL_SW_BlitTriangle( } } - /* Lock the source, if needed */ + // Lock the source, if needed if (SDL_MUSTLOCK(src)) { if (SDL_LockSurface(src) < 0) { ret = -1; @@ -538,7 +538,7 @@ int SDL_SW_BlitTriangle( SDL_GetSurfaceBlendMode(src, &blend); - /* TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 */ + // TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 if (texture_address_mode == SDL_TEXTURE_ADDRESS_CLAMP) { SDL_Rect srcrect; int maxx, maxy; @@ -577,18 +577,18 @@ int SDL_SW_BlitTriangle( } { - /* Clip triangle with surface clip rect */ + // Clip triangle with surface clip rect SDL_Rect rect; SDL_GetSurfaceClipRect(dst, &rect); SDL_GetRectIntersection(&dstrect, &rect, &dstrect); } - /* Set destination pointer */ + // Set destination pointer dstbpp = dst->internal->format->bytes_per_pixel; dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch; dst_pitch = dst->pitch; - /* Set source pointer */ + // Set source pointer src_ptr = (const int *)src->pixels; src_pitch = src->pitch; @@ -612,7 +612,7 @@ int SDL_SW_BlitTriangle( s2s0_y = s0->y - s2->y; s2s1_y = s1->y - s2->y; - /* Starting point for rendering, at the middle of a pixel */ + // Starting point for rendering, at the middle of a pixel { SDL_Point p; p.x = dstrect.x; @@ -625,7 +625,7 @@ int SDL_SW_BlitTriangle( w2_row = cross_product(d0, d1, p.x, p.y); } - /* Handle anti-clockwise triangles */ + // Handle anti-clockwise triangles if (!is_clockwise) { d2d1_y *= -1; d0d2_y *= -1; @@ -638,7 +638,7 @@ int SDL_SW_BlitTriangle( w2_row *= -1; } - /* Add a bias to respect top-left rasterization rule */ + // Add a bias to respect top-left rasterization rule bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1); bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1); bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1); @@ -660,7 +660,7 @@ int SDL_SW_BlitTriangle( } if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) { - /* Use SDL_BlitTriangle_Slow */ + // Use SDL_BlitTriangle_Slow SDL_BlitInfo *info = &src->internal->map.info; SDL_BlitInfo tmp_info; @@ -695,12 +695,12 @@ int SDL_SW_BlitTriangle( tmp_info.colorkey = info->colorkey; - /* src */ + // src tmp_info.src_surface = src_surface; tmp_info.src = (Uint8 *)src_ptr; tmp_info.src_pitch = src_pitch; - /* dst */ + // dst tmp_info.dst = dst_ptr; tmp_info.dst_pitch = dst_pitch; @@ -827,12 +827,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB); srcA = 0xFF; } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ + // SDL_PIXELFORMAT_ARGB2101010 srcpixel = *((Uint32 *)(src)); RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA); } if (flags & SDL_COPY_COLORKEY) { - /* srcpixel isn't set for 24 bpp */ + // srcpixel isn't set for 24 bpp if (srcbpp == 3) { srcpixel = (srcR << src_fmt->Rshift) | (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); @@ -848,12 +848,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); dstA = 0xFF; } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ + // SDL_PIXELFORMAT_ARGB2101010 dstpixel = *((Uint32 *) (dst)); RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); } } else { - /* don't care */ + // don't care dstR = dstG = dstB = dstA = 0; } @@ -874,7 +874,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, srcA = (srcA * modulateA) / 255; } if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ + // This goes away if we ever use premultiplied alpha if (srcA < 255) { srcR = (srcR * srcA) / 255; srcG = (srcG * srcA) / 255; @@ -933,7 +933,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB); } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ + // SDL_PIXELFORMAT_ARGB2101010 Uint32 pixel; ARGB2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA); *(Uint32 *)dst = pixel; @@ -942,4 +942,4 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, TRIANGLE_END_LOOP } -#endif /* SDL_VIDEO_RENDER_SW */ +#endif // SDL_VIDEO_RENDER_SW diff --git a/src/render/software/SDL_triangle.h b/src/render/software/SDL_triangle.h index d970350674..5ecca68b54 100644 --- a/src/render/software/SDL_triangle.h +++ b/src/render/software/SDL_triangle.h @@ -40,4 +40,4 @@ extern int SDL_SW_BlitTriangle( extern void trianglepoint_2_fixedpoint(SDL_Point *a); -#endif /* SDL_triangle_h_ */ +#endif // SDL_triangle_h_ diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index 79142d5dc7..b112cfcba3 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -36,7 +36,7 @@ #include -/* #define DEBUG_RAZOR */ +// #define DEBUG_RAZOR #ifdef DEBUG_RAZOR #include @@ -915,7 +915,7 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) data->drawstate.texture = texture; } - /* all drawing commands use this */ + // all drawing commands use this sceGxmSetVertexStream(data->gxm_context, 0, (const void *)cmd->data.draw.first); return 0; @@ -923,7 +923,7 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) static void VITA_GXM_InvalidateCachedState(SDL_Renderer *renderer) { - /* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */ + // currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. } static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -983,13 +983,13 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_DRAW_POINTS: @@ -1006,11 +1006,11 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { - break; /* can't go any further on this draw call, different render command up next. */ + 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. */ + 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. */ + finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command. count += nextcmd->data.draw.count; } nextcmd = nextcmd->next; @@ -1036,7 +1036,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c } } - cmd = finalcmd; /* skip any copy commands we just combined in here. */ + cmd = finalcmd; // skip any copy commands we just combined in here. break; } @@ -1099,7 +1099,7 @@ static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_ read_pixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h, rect->w, rect->h, surface->pixels); - /* Flip the rows to be top-down if necessary */ + // Flip the rows to be top-down if necessary if (!renderer->target) { SDL_bool isstack; @@ -1204,4 +1204,4 @@ static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer) } } -#endif /* SDL_VIDEO_RENDER_VITA_GXM */ +#endif // SDL_VIDEO_RENDER_VITA_GXM diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c index ea39d1f14d..053bd12c5d 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -174,4 +174,4 @@ void vita_mem_fragment_usse_free(SceUID uid) sceKernelFreeMemBlock(uid); } -#endif /* SDL_VIDEO_RENDER_VITA_GXM */ +#endif // SDL_VIDEO_RENDER_VITA_GXM diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/src/render/vitagxm/SDL_render_vita_gxm_memory.h index 9cd9f8899a..8bbca3eeae 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.h @@ -39,4 +39,4 @@ void vita_mem_vertex_usse_free(SceUID uid); void *vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset); void vita_mem_fragment_usse_free(SceUID uid); -#endif /* SDL_RENDER_VITA_GXM_MEMORY_H */ +#endif // SDL_RENDER_VITA_GXM_MEMORY_H diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 4fe1621ace..1e4b5a5afe 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -734,13 +734,13 @@ int gxm_init(SDL_Renderer *renderer) // create color vertex format SceGxmVertexAttribute colorVertexAttributes[2]; SceGxmVertexStream colorVertexStreams[1]; - /* x,y: 2 float 32 bits */ + // x,y: 2 float 32 bits colorVertexAttributes[0].streamIndex = 0; colorVertexAttributes[0].offset = 0; colorVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; colorVertexAttributes[0].componentCount = 2; // (x, y) colorVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorPositionAttribute); - /* color: 4 unsigned char = 32 bits */ + // color: 4 unsigned char = 32 bits colorVertexAttributes[1].streamIndex = 0; colorVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes colorVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; @@ -773,19 +773,19 @@ int gxm_init(SDL_Renderer *renderer) // create texture vertex format SceGxmVertexAttribute textureVertexAttributes[3]; SceGxmVertexStream textureVertexStreams[1]; - /* x,y: 2 float 32 bits */ + // x,y: 2 float 32 bits textureVertexAttributes[0].streamIndex = 0; textureVertexAttributes[0].offset = 0; textureVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; textureVertexAttributes[0].componentCount = 2; // (x, y) textureVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTexturePositionAttribute); - /* u,v: 2 floats 32 bits */ + // u,v: 2 floats 32 bits textureVertexAttributes[1].streamIndex = 0; textureVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes textureVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; textureVertexAttributes[1].componentCount = 2; // (u, v) textureVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTexcoordAttribute); - /* r,g,b,a: 4 unsigned chars 32 bits */ + // r,g,b,a: 4 unsigned chars 32 bits textureVertexAttributes[2].streamIndex = 0; textureVertexAttributes[2].offset = 16; // (x, y, u, v) * 4 = 16 bytes textureVertexAttributes[2].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; @@ -1009,12 +1009,12 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig *return_h = h; *return_pitch = aligned_w * tex_format_to_bytespp(format); - /* Allocate a GPU buffer for the texture */ + // Allocate a GPU buffer for the texture texture_data = vita_gpu_mem_alloc( data, tex_size); - /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */ + // Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM if (!texture_data) { SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n"); texture_data = vita_mem_alloc( @@ -1033,10 +1033,10 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig return NULL; } - /* Clear the texture */ + // Clear the texture SDL_memset(texture_data, 0, tex_size); - /* Create the gxm texture */ + // Create the gxm texture ret = sceGxmTextureInitLinear(&texture->gxm_tex, texture_data, format, texture_w, h, 0); if (ret < 0) { free_gxm_texture(data, texture); @@ -1210,4 +1210,4 @@ void gxm_term_for_common_dialog(void) } } -#endif /* SDL_VIDEO_RENDER_VITA_GXM */ +#endif // SDL_VIDEO_RENDER_VITA_GXM diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.h b/src/render/vitagxm/SDL_render_vita_gxm_tools.h index 067edc2df2..d6b80927c6 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.h @@ -60,4 +60,4 @@ void gxm_init_for_common_dialog(void); void gxm_swap_for_common_dialog(void); void gxm_term_for_common_dialog(void); -#endif /* SDL_RENDER_VITA_GXM_TOOLS_H */ +#endif // SDL_RENDER_VITA_GXM_TOOLS_H diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h index d62941dc61..a1d364b278 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_types.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h @@ -207,4 +207,4 @@ typedef struct SDL_bool nv12; } VITA_GXM_TextureData; -#endif /* SDL_RENDER_VITA_GXM_TYPES_H */ +#endif // SDL_RENDER_VITA_GXM_TYPES_H diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c index 40941cc5f6..a9723a6ddd 100644 --- a/src/render/vulkan/SDL_render_vulkan.c +++ b/src/render/vulkan/SDL_render_vulkan.c @@ -150,14 +150,14 @@ VULKAN_FUNCTIONS() #undef VULKAN_OPTIONAL_INSTANCE_FUNCTION #undef VULKAN_OPTIONAL_DEVICE_FUNCTION -/* Renderpass types */ +// Renderpass types typedef enum { SDL_VULKAN_RENDERPASS_LOAD = 0, SDL_VULKAN_RENDERPASS_CLEAR = 1, SDL_VULKAN_NUM_RENDERPASSES } SDL_vulkan_renderpass_type; -/* Sampler types */ +// Sampler types typedef enum { SDL_VULKAN_SAMPLER_NEAREST_CLAMP, @@ -167,14 +167,14 @@ typedef enum SDL_VULKAN_NUM_SAMPLERS } SDL_vulkan_sampler_type; -/* Vertex shader, common values */ +// Vertex shader, common values typedef struct { Float4X4 model; Float4X4 projectionAndView; } VertexShaderConstants; -/* These should mirror the definitions in VULKAN_PixelShader_Common.hlsli */ +// These should mirror the definitions in VULKAN_PixelShader_Common.hlsli //static const float TONEMAP_NONE = 0; //static const float TONEMAP_LINEAR = 1; static const float TONEMAP_CHROME = 2; @@ -193,7 +193,7 @@ typedef enum NUM_SAMPLERS } Sampler; -/* Pixel shader constants, common values */ +// Pixel shader constants, common values typedef struct { float scRGB_output; @@ -207,7 +207,7 @@ typedef struct float sdr_white_point; } PixelShaderConstants; -/* Per-vertex data */ +// Per-vertex data typedef struct { float pos[2]; @@ -215,7 +215,7 @@ typedef struct SDL_FColor color; } VertexPositionColor; -/* Vulkan Buffer */ +// Vulkan Buffer typedef struct { VkDeviceMemory deviceMemory; @@ -225,7 +225,7 @@ typedef struct } VULKAN_Buffer; -/* Vulkan image */ +// Vulkan image typedef struct { SDL_bool allocatedImage; @@ -236,7 +236,7 @@ typedef struct VkFormat format; } VULKAN_Image; -/* Per-texture data */ +// Per-texture data typedef struct { VULKAN_Image mainImage; @@ -249,18 +249,18 @@ typedef struct int height; VULKAN_Shader shader; - /* Object passed to VkImageView and VkSampler for doing Ycbcr -> RGB conversion */ + // Object passed to VkImageView and VkSampler for doing Ycbcr -> RGB conversion VkSamplerYcbcrConversion samplerYcbcrConversion; - /* Sampler created with samplerYcbcrConversion, passed to PSO as immutable sampler */ + // Sampler created with samplerYcbcrConversion, passed to PSO as immutable sampler VkSampler samplerYcbcr; - /* Descriptor set layout with samplerYcbcr baked as immutable sampler */ + // Descriptor set layout with samplerYcbcr baked as immutable sampler VkDescriptorSetLayout descriptorSetLayoutYcbcr; - /* Pipeline layout with immutable sampler descriptor set layout */ + // Pipeline layout with immutable sampler descriptor set layout VkPipelineLayout pipelineLayoutYcbcr; } VULKAN_TextureData; -/* Pipeline State Object data */ +// Pipeline State Object data typedef struct { VULKAN_Shader shader; @@ -278,7 +278,7 @@ typedef struct VkBuffer vertexBuffer; } VULKAN_DrawStateCache; -/* Private renderer data */ +// Private renderer data typedef struct { PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; @@ -316,15 +316,15 @@ typedef struct VkDescriptorSetLayout descriptorSetLayout; VkPipelineLayout pipelineLayout; - /* Vertex buffer data */ + // Vertex buffer data VULKAN_Buffer vertexBuffers[SDL_VULKAN_NUM_VERTEX_BUFFERS]; VertexShaderConstants vertexShaderConstantsData; - /* Data for staging/allocating textures */ + // Data for staging/allocating textures VULKAN_Buffer **uploadBuffers; int *currentUploadBuffer; - /* Data for updating constants */ + // Data for updating constants VULKAN_Buffer **constantBuffers; uint32_t *numConstantBuffers; uint32_t currentConstantBufferIndex; @@ -365,7 +365,7 @@ typedef struct uint32_t signalRenderSemaphoreCount; uint32_t signalRenderSemaphoreMax; - /* Cached renderer properties */ + // Cached renderer properties VULKAN_TextureData *textureRenderTarget; SDL_bool cliprectDirty; SDL_bool currentCliprectEnabled; @@ -823,7 +823,7 @@ static VkResult VULKAN_AllocateImage(VULKAN_RenderData *rendererData, SDL_Proper imageViewCreateInfo.subresourceRange.baseArrayLayer = 0; imageViewCreateInfo.subresourceRange.layerCount = 1; - /* If it's a YCbCr image, we need to pass the conversion info to the VkImageView (and the VkSampler) */ + // If it's a YCbCr image, we need to pass the conversion info to the VkImageView (and the VkSampler) if (samplerYcbcrConversion != VK_NULL_HANDLE) { samplerYcbcrConversionInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR; samplerYcbcrConversionInfo.conversion = samplerYcbcrConversion; @@ -844,7 +844,7 @@ static VkResult VULKAN_AllocateImage(VULKAN_RenderData *rendererData, SDL_Proper static void VULKAN_RecordPipelineImageBarrier(VULKAN_RenderData *rendererData, VkAccessFlags sourceAccessMask, VkAccessFlags destAccessMask, VkPipelineStageFlags srcStageFlags, VkPipelineStageFlags dstStageFlags, VkImageLayout destLayout, VkImage image, VkImageLayout *imageLayout) { - /* Stop any outstanding renderpass if open */ + // Stop any outstanding renderpass if open if (rendererData->currentRenderPass != VK_NULL_HANDLE) { vkCmdEndRenderPass(rendererData->currentCommandBuffer); rendererData->currentRenderPass = VK_NULL_HANDLE; @@ -881,7 +881,7 @@ static VkResult VULKAN_AcquireNextSwapchainImage(SDL_Renderer *renderer) result = VULKAN_CreateWindowSizeDependentResources(renderer); return result; } else if(result == VK_SUBOPTIMAL_KHR) { - /* Suboptimal, but we can contiue */ + // Suboptimal, but we can contiue } else if (result != VK_SUCCESS) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkAcquireNextImageKHR(): %s\n", SDL_Vulkan_GetResultString(result)); @@ -942,7 +942,7 @@ static void VULKAN_EnsureCommandBuffer(VULKAN_RenderData *rendererData) rendererData->currentCommandBuffer = rendererData->commandBuffers[rendererData->currentCommandBufferIndex]; VULKAN_ResetCommandList(rendererData); - /* Ensure the swapchain is in the correct layout */ + // Ensure the swapchain is in the correct layout if (rendererData->swapchainImageLayouts[rendererData->currentSwapchainImageIndex] == VK_IMAGE_LAYOUT_UNDEFINED) { VULKAN_RecordPipelineImageBarrier(rendererData, 0, @@ -1016,7 +1016,7 @@ static void VULKAN_ResetCommandList(VULKAN_RenderData *rendererData) rendererData->currentConstantBufferOffset = -1; rendererData->currentConstantBufferIndex = 0; - /* Release any upload buffers that were inflight */ + // Release any upload buffers that were inflight for (int i = 0; i < rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex]; ++i) { VULKAN_DestroyBuffer(rendererData, &rendererData->uploadBuffers[rendererData->currentCommandBufferIndex][i]); } @@ -1162,7 +1162,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, pipelineCreateInfo.pColorBlendState = &colorBlendStateCreateInfo; pipelineCreateInfo.pDynamicState = &dynamicStateCreateInfo; - /* Shaders */ + // Shaders const char *name = "main"; for (uint32_t i = 0; i < 2; i++) { SDL_memset(&shaderStageCreateInfo[i], 0, sizeof(shaderStageCreateInfo[i])); @@ -1175,7 +1175,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, pipelineCreateInfo.pStages = &shaderStageCreateInfo[0]; - /* Vertex input */ + // Vertex input vertexInputCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputCreateInfo.vertexAttributeDescriptionCount = 3; vertexInputCreateInfo.pVertexAttributeDescriptions = &attributeDescriptions[0]; @@ -1199,7 +1199,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, bindingDescriptions[ 0 ].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; bindingDescriptions[ 0 ].stride = 32; - /* Input assembly */ + // Input assembly inputAssemblyStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; inputAssemblyStateCreateInfo.topology = ( VkPrimitiveTopology ) topology; inputAssemblyStateCreateInfo.primitiveRestartEnable = VK_FALSE; @@ -1208,7 +1208,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, viewportStateCreateInfo.scissorCount = 1; viewportStateCreateInfo.viewportCount = 1; - /* Dynamic states */ + // Dynamic states dynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; VkDynamicState dynamicStates[2] = { VK_DYNAMIC_STATE_VIEWPORT, @@ -1217,7 +1217,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, dynamicStateCreateInfo.dynamicStateCount = SDL_arraysize(dynamicStates); dynamicStateCreateInfo.pDynamicStates = dynamicStates; - /* Rasterization state */ + // Rasterization state rasterizationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizationStateCreateInfo.depthClampEnable = VK_FALSE; rasterizationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE; @@ -1230,16 +1230,16 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, rasterizationStateCreateInfo.depthBiasSlopeFactor = 0.0f; rasterizationStateCreateInfo.lineWidth = 1.0f; - /* MSAA state */ + // MSAA state multisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; VkSampleMask multiSampleMask = 0xFFFFFFFF; multisampleStateCreateInfo.pSampleMask = &multiSampleMask; multisampleStateCreateInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - /* Depth Stencil */ + // Depth Stencil depthStencilStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - /* Color blend */ + // Color blend VkPipelineColorBlendAttachmentState colorBlendAttachment = { 0 }; colorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlendStateCreateInfo.attachmentCount = 1; @@ -1253,7 +1253,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, colorBlendAttachment.alphaBlendOp = GetBlendOp(SDL_GetBlendModeAlphaOperation(blendMode)); colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - /* Renderpass / layout */ + // Renderpass / layout pipelineCreateInfo.renderPass = rendererData->currentRenderPass; pipelineCreateInfo.subpass = 0; pipelineCreateInfo.layout = pipelineLayout; @@ -1283,7 +1283,7 @@ static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint uint32_t memoryTypeIndex = 0; SDL_bool foundExactMatch = SDL_FALSE; - /* Desired flags must be a superset of required flags. */ + // Desired flags must be a superset of required flags. desiredFlags |= requiredFlags; for (memoryTypeIndex = 0; memoryTypeIndex < rendererData->physicalDeviceMemoryProperties.memoryTypeCount; memoryTypeIndex++) { @@ -1673,7 +1673,7 @@ static SDL_bool VULKAN_ValidationLayersFound(void) return foundValidation; } -/* Create resources that depend on the device. */ +// Create resources that depend on the device. static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_PropertiesID create_props) { static const char *const deviceExtensionNames[] = { @@ -1704,13 +1704,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert return VK_ERROR_UNKNOWN; } - /* Load global Vulkan functions */ + // Load global Vulkan functions rendererData->vkGetInstanceProcAddr = vkGetInstanceProcAddr; if (VULKAN_LoadGlobalFunctions(rendererData) != 0) { return VK_ERROR_UNKNOWN; } - /* Check for colorspace extension */ + // Check for colorspace extension rendererData->supportsEXTSwapchainColorspace = VK_FALSE; if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR || renderer->output_colorspace == SDL_COLORSPACE_HDR10) { @@ -1721,10 +1721,10 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert } } - /* Check for VK_KHR_get_physical_device_properties2 */ + // Check for VK_KHR_get_physical_device_properties2 rendererData->supportsKHRGetPhysicalDeviceProperties2 = VULKAN_InstanceExtensionFound(rendererData, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); - /* Create VkInstance */ + // Create VkInstance rendererData->instance = (VkInstance)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER, NULL); if (rendererData->instance) { rendererData->instance_external = SDL_TRUE; @@ -1762,13 +1762,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert } } - /* Load instance Vulkan functions */ + // Load instance Vulkan functions if (VULKAN_LoadInstanceFunctions(rendererData) != 0) { VULKAN_DestroyAll(renderer); return VK_ERROR_UNKNOWN; } - /* Create Vulkan surface */ + // Create Vulkan surface rendererData->surface = (VkSurfaceKHR)SDL_GetNumberProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER, 0); if (rendererData->surface) { rendererData->surface_external = SDL_TRUE; @@ -1780,7 +1780,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert } } - /* Choose Vulkan physical device */ + // Choose Vulkan physical device rendererData->physicalDevice = (VkPhysicalDevice)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER, NULL); if (rendererData->physicalDevice) { vkGetPhysicalDeviceMemoryProperties(rendererData->physicalDevice, &rendererData->physicalDeviceMemoryProperties); @@ -1804,7 +1804,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert rendererData->supportsKHRSamplerYCbCrConversion = SDL_TRUE; } - /* Create Vulkan device */ + // Create Vulkan device rendererData->device = (VkDevice)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER, NULL); if (rendererData->device) { rendererData->device_external = SDL_TRUE; @@ -1855,7 +1855,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert return VK_ERROR_UNKNOWN; } - /* Get graphics/present queues */ + // Get graphics/present queues vkGetDeviceQueue(rendererData->device, rendererData->graphicsQueueFamilyIndex, 0, &rendererData->graphicsQueue); if (rendererData->graphicsQueueFamilyIndex != rendererData->presentQueueFamilyIndex) { vkGetDeviceQueue(rendererData->device, rendererData->presentQueueFamilyIndex, 0, &rendererData->presentQueue); @@ -1863,7 +1863,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert rendererData->presentQueue = rendererData->graphicsQueue; } - /* Create command pool/command buffers */ + // Create command pool/command buffers VkCommandPoolCreateInfo commandPoolCreateInfo = { 0 }; commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; @@ -1880,7 +1880,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert return result; } - /* Create shaders / layouts */ + // Create shaders / layouts for (uint32_t i = 0; i < NUM_SHADERS; i++) { VULKAN_Shader shader = (VULKAN_Shader)i; VkShaderModuleCreateInfo shaderModuleCreateInfo = { 0 }; @@ -1901,7 +1901,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert } } - /* Descriptor set layout / pipeline layout*/ + // Descriptor set layout / pipeline layout result = VULKAN_CreateDescriptorSetAndPipelineLayout(rendererData, VK_NULL_HANDLE, &rendererData->descriptorSetLayout, &rendererData->pipelineLayout); if (result != VK_SUCCESS) { VULKAN_DestroyAll(renderer); @@ -1909,12 +1909,12 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert return result; } - /* Create default vertex buffers */ + // Create default vertex buffers for (uint32_t i = 0; i < SDL_VULKAN_NUM_VERTEX_BUFFERS; ++i) { VULKAN_CreateVertexBuffer(rendererData, i, SDL_VULKAN_VERTEX_BUFFER_DEFAULT_SIZE); } - /* Create samplers */ + // Create samplers { static struct { @@ -2101,11 +2101,11 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) rendererData->surfaceCapabilities.maxImageExtent.height); if (rendererData->swapchainSize.width == 0 && rendererData->swapchainSize.height == 0) { - /* Don't recreate the swapchain if size is (0,0), just fail and continue attempting creation */ + // Don't recreate the swapchain if size is (0,0), just fail and continue attempting creation return VK_ERROR_OUT_OF_DATE_KHR; } - /* Choose a present mode. If vsync is requested, then use VK_PRESENT_MODE_FIFO_KHR which is guaranteed to be supported */ + // Choose a present mode. If vsync is requested, then use VK_PRESENT_MODE_FIFO_KHR which is guaranteed to be supported VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR; if (rendererData->vsync <= 0) { uint32_t presentModeCount = 0; @@ -2203,7 +2203,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) return result; } - /* Create VkImageView's for swapchain images */ + // Create VkImageView's for swapchain images { VkImageViewCreateInfo imageViewCreateInfo = { 0 }; imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; @@ -2260,7 +2260,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) return result; } - /* Create fences */ + // Create fences if (rendererData->fences) { for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { if (rendererData->fences[i] != VK_NULL_HANDLE) { @@ -2282,7 +2282,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) } } - /* Create renderpasses and framebuffer */ + // Create renderpasses and framebuffer if (rendererData->framebuffers) { for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { if (rendererData->framebuffers[i] != VK_NULL_HANDLE) { @@ -2312,7 +2312,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) return result; } - /* Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed */ + // Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed if (rendererData->descriptorPools) { SDL_assert(rendererData->numDescriptorPools); for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { @@ -2329,7 +2329,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) rendererData->descriptorPools = (VkDescriptorPool **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool*)); rendererData->numDescriptorPools = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t)); for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { - /* Start by just allocating one pool, it will grow if needed */ + // Start by just allocating one pool, it will grow if needed rendererData->numDescriptorPools[i] = 1; rendererData->descriptorPools[i] = (VkDescriptorPool *)SDL_calloc(1, sizeof(VkDescriptorPool)); rendererData->descriptorPools[i][0] = VULKAN_AllocateDescriptorPool(rendererData); @@ -2339,7 +2339,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) } } - /* Create semaphores */ + // Create semaphores if (rendererData->imageAvailableSemaphores) { for (uint32_t i = 0; i < rendererData->swapchainImageCount; ++i) { if (rendererData->imageAvailableSemaphores[i] != VK_NULL_HANDLE) { @@ -2371,7 +2371,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) } } - /* Upload buffers */ + // Upload buffers if (rendererData->uploadBuffers) { for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { for (uint32_t j = 0; j < SDL_VULKAN_NUM_UPLOAD_BUFFERS; j++) { @@ -2388,7 +2388,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) SDL_free(rendererData->currentUploadBuffer); rendererData->currentUploadBuffer = (int *)SDL_calloc(rendererData->swapchainImageCount, sizeof(int)); - /* Constant buffers */ + // Constant buffers if (rendererData->constantBuffers) { SDL_assert(rendererData->numConstantBuffers); for (uint32_t i = 0; i < rendererData->swapchainImageCount; ++i) { @@ -2404,7 +2404,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) rendererData->constantBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*)); rendererData->numConstantBuffers = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t)); for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) { - /* Start with just allocating one, will grow if needed */ + // Start with just allocating one, will grow if needed rendererData->numConstantBuffers[i] = 1; rendererData->constantBuffers[i] = (VULKAN_Buffer *)SDL_calloc(1, sizeof(VULKAN_Buffer)); result = VULKAN_AllocateBuffer(rendererData, @@ -2431,14 +2431,14 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h) return result; } -/* Initialize all resources that change when the window's size changes. */ +// Initialize all resources that change when the window's size changes. static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; VkResult result = VK_SUCCESS; int w, h; - /* Release resources in the current command list */ + // Release resources in the current command list VULKAN_IssueBatch(rendererData); VULKAN_WaitForGPU(rendererData); @@ -2457,11 +2457,11 @@ static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer return result; } -/* This method is called when the window's size changes. */ +// This method is called when the window's size changes. static VkResult VULKAN_UpdateForWindowSizeChange(SDL_Renderer *renderer) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; - /* If the GPU has previous work, wait for it to be done first */ + // If the GPU has previous work, wait for it to be done first VULKAN_WaitForGPU(rendererData); return VULKAN_CreateWindowSizeDependentResources(renderer); @@ -2522,7 +2522,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR; #if SDL_HAVE_YUV - /* YUV textures must have even width and height. Also create Ycbcr conversion */ + // YUV textures must have even width and height. Also create Ycbcr conversion if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV || texture->format == SDL_PIXELFORMAT_NV12 || @@ -2530,7 +2530,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD texture->format == SDL_PIXELFORMAT_P010) { const uint32_t YUV_SD_THRESHOLD = 576; - /* Check that we have VK_KHR_sampler_ycbcr_conversion support */ + // Check that we have VK_KHR_sampler_ycbcr_conversion support if (!rendererData->supportsKHRSamplerYCbCrConversion) { return SDL_SetError("[Vulkan] YUV textures require a Vulkan device that supports VK_KHR_sampler_ycbcr_conversion"); } @@ -2538,11 +2538,11 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD VkSamplerYcbcrConversionCreateInfoKHR samplerYcbcrConversionCreateInfo = { 0 }; samplerYcbcrConversionCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR; - /* Pad width/height to multiple of 2 */ + // Pad width/height to multiple of 2 width = (width + 1) & ~1; height = (height + 1) & ~1; - /* Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler */ + // Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler samplerYcbcrConversionCreateInfo.format = textureFormat; switch (SDL_COLORSPACEMATRIX(texture->colorspace)) { case SDL_MATRIX_COEFFICIENTS_BT470BG: @@ -2611,7 +2611,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD return SDL_SetError("[Vulkan] vkCreateSamplerYcbcrConversionKHR %s", SDL_Vulkan_GetResultString(result)); } - /* Also create VkSampler object which we will need to pass to the PSO as an immutable sampler */ + // Also create VkSampler object which we will need to pass to the PSO as an immutable sampler VkSamplerCreateInfo samplerCreateInfo = { 0 }; samplerCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; samplerCreateInfo.magFilter = VK_FILTER_NEAREST; @@ -2635,7 +2635,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD return SDL_SetError("[Vulkan] vkCreateSampler %s", SDL_Vulkan_GetResultString(result)); } - /* Allocate special descriptor set layout with samplerYcbcr baked as an immutable sampler */ + // Allocate special descriptor set layout with samplerYcbcr baked as an immutable sampler result = VULKAN_CreateDescriptorSetAndPipelineLayout(rendererData, textureData->samplerYcbcr, &textureData->descriptorSetLayoutYcbcr, &textureData->pipelineLayoutYcbcr); if (result != VK_SUCCESS) { @@ -2769,7 +2769,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk } } - /* Make sure the destination is in the correct resource state */ + // Make sure the destination is in the correct resource state VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, @@ -2801,7 +2801,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk vkCmdCopyBufferToImage(rendererData->currentCommandBuffer, uploadBuffer->buffer, image, *imageLayout, 1, ®ion); - /* Transition the texture to be shader accessible */ + // Transition the texture to be shader accessible VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, @@ -2813,7 +2813,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex]++; - /* If we've used up all the upload buffers, we need to issue the batch */ + // If we've used up all the upload buffers, we need to issue the batch if (rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex] == SDL_VULKAN_NUM_UPLOAD_BUFFERS) { VULKAN_IssueBatch(rendererData); } @@ -2838,7 +2838,7 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, } #if SDL_HAVE_YUV Uint32 numPlanes = VULKAN_VkFormatGetNumPlanes(textureData->mainImage.format); - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch); // YUV data if (numPlanes == 3) { @@ -2847,7 +2847,7 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, return -1; } - /* Skip to the correct offset into the next texture */ + // Skip to the correct offset into the next texture srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2)); } } @@ -2970,7 +2970,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) VULKAN_EnsureCommandBuffer(rendererData); - /* Make sure the destination is in the correct resource state */ + // Make sure the destination is in the correct resource state VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, @@ -2996,7 +2996,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) region.imageExtent.depth = 1; vkCmdCopyBufferToImage(rendererData->currentCommandBuffer, textureData->stagingBuffer.buffer, textureData->mainImage.image, textureData->mainImage.imageLayout, 1, ®ion); - /* Transition the texture to be shader accessible */ + // Transition the texture to be shader accessible VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, @@ -3006,7 +3006,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) textureData->mainImage.image, &textureData->mainImage.imageLayout); - /* Execute the command list before releasing the staging buffer */ + // Execute the command list before releasing the staging buffer VULKAN_IssueBatch(rendererData); VULKAN_DestroyBuffer(rendererData, &textureData->stagingBuffer); @@ -3067,7 +3067,7 @@ static int VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) static int VULKAN_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - return 0; /* nothing to do in this backend. */ + return 0; // nothing to do in this backend. } static int VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) @@ -3159,7 +3159,7 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, VULKAN_Buffer *vertexBuffer; if (dataSizeInBytes == 0) { - return 0; /* nothing to do. */ + return 0; // nothing to do. } if (rendererData->issueBatch) { @@ -3168,7 +3168,7 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, return SDL_FALSE; } } - /* If the existing vertex buffer isn't big enough, we need to recreate a big enough one */ + // If the existing vertex buffer isn't big enough, we need to recreate a big enough one if (dataSizeInBytes > rendererData->vertexBuffers[vbidx].size) { VULKAN_IssueBatch(rendererData); VULKAN_WaitForGPU(rendererData); @@ -3201,13 +3201,13 @@ static int VULKAN_UpdateViewport(SDL_Renderer *renderer) * SDL_CreateRenderer is calling it, and will call it again later * with a non-empty viewport. */ - /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */ + // SDL_Log("%s, no viewport was set!\n", __FUNCTION__); return -1; } projection = MatrixIdentity(); - /* Update the view matrix */ + // Update the view matrix SDL_zero(view); view.m[0][0] = 2.0f / viewport->w; view.m[1][1] = -2.0f / viewport->h; @@ -3337,19 +3337,19 @@ static VkResult VULKAN_CreateDescriptorSetAndPipelineLayout(VULKAN_RenderData *r { VkResult result; - /* Descriptor set layout */ + // Descriptor set layout VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { 0 }; descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; descriptorSetLayoutCreateInfo.flags = 0; VkDescriptorSetLayoutBinding layoutBindings[2]; - /* PixelShaderConstants */ + // PixelShaderConstants layoutBindings[0].binding = 1; layoutBindings[0].descriptorCount = 1; layoutBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; layoutBindings[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; layoutBindings[0].pImmutableSamplers = NULL; - /* Combined image/sampler */ + // Combined image/sampler layoutBindings[1].binding = 0; layoutBindings[1].descriptorCount = 1; layoutBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; @@ -3364,7 +3364,7 @@ static VkResult VULKAN_CreateDescriptorSetAndPipelineLayout(VULKAN_RenderData *r return result; } - /* Pipeline layout */ + // Pipeline layout VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { 0 }; VkPushConstantRange pushConstantRange; pushConstantRange.size = sizeof( VertexShaderConstants ); @@ -3403,14 +3403,14 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK result = vkAllocateDescriptorSets(rendererData->device, &descriptorSetAllocateInfo, &descriptorSet); } if (result != VK_SUCCESS) { - /* Out of descriptor sets in this pool - see if we have more pools allocated */ + // Out of descriptor sets in this pool - see if we have more pools allocated currentDescriptorPoolIndex++; if (currentDescriptorPoolIndex < rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]) { descriptorPool = rendererData->descriptorPools[rendererData->currentCommandBufferIndex][currentDescriptorPoolIndex]; descriptorSetAllocateInfo.descriptorPool = descriptorPool; result = vkAllocateDescriptorSets(rendererData->device, &descriptorSetAllocateInfo, &descriptorSet); if (result != VK_SUCCESS) { - /* This should not fail - we are allocating from the front of the descriptor set */ + // This should not fail - we are allocating from the front of the descriptor set SDL_SetError("[Vulkan] Unable to allocate descriptor set"); return VK_NULL_HANDLE; } @@ -3418,11 +3418,11 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK rendererData->currentDescriptorSetIndex = 0; } - /* We are out of pools, create a new one */ + // We are out of pools, create a new one else { descriptorPool = VULKAN_AllocateDescriptorPool(rendererData); if (descriptorPool == VK_NULL_HANDLE) { - /* SDL_SetError called in VULKAN_AllocateDescriptorPool if we failed to allocate a new pool */ + // SDL_SetError called in VULKAN_AllocateDescriptorPool if we failed to allocate a new pool return VK_NULL_HANDLE; } rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]++; @@ -3433,7 +3433,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK rendererData->currentDescriptorPoolIndex = currentDescriptorPoolIndex; rendererData->currentDescriptorSetIndex = 0; - /* Call recursively to allocate from the new pool */ + // Call recursively to allocate from the new pool return VULKAN_AllocateDescriptorSet(renderer, shader, descriptorSetLayout, sampler, constantBuffer, constantBufferOffset, imageView); } } @@ -3446,7 +3446,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK VkWriteDescriptorSet descriptorWrites[2]; SDL_memset(descriptorWrites, 0, sizeof(descriptorWrites)); - uint32_t descriptorCount = 1; /* Always have the uniform buffer */ + uint32_t descriptorCount = 1; // Always have the uniform buffer descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; descriptorWrites[0].dstSet = descriptorSet; @@ -3466,7 +3466,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK descriptorWrites[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; descriptorWrites[1].pImageInfo = &combinedImageSamplerDescriptor; - /* Ignore the sampler if we're using YcBcCr data since it will be baked in the descriptor set layout */ + // Ignore the sampler if we're using YcBcCr data since it will be baked in the descriptor set layout if (descriptorSetLayout == rendererData->descriptorSetLayout) { combinedImageSamplerDescriptor.sampler = sampler; } @@ -3498,7 +3498,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm return SDL_FALSE; } - /* See if we need to change the pipeline state */ + // See if we need to change the pipeline state if (!rendererData->currentPipelineState || rendererData->currentPipelineState->shader != shader || rendererData->currentPipelineState->blendMode != blendMode || @@ -3521,7 +3521,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm } } - /* If we didn't find a match, create a new one -- it must mean the blend mode is non-standard */ + // If we didn't find a match, create a new one -- it must mean the blend mode is non-standard if (!rendererData->currentPipelineState) { rendererData->currentPipelineState = VULKAN_CreatePipelineState(renderer, shader, pipelineLayout, descriptorSetLayout, blendMode, topology, format); } @@ -3536,7 +3536,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm if (rendererData->viewportDirty) { if (VULKAN_UpdateViewport(renderer) == 0) { - /* vertexShaderConstantsData.projectionAndView has changed */ + // vertexShaderConstantsData.projectionAndView has changed updateConstants = SDL_TRUE; } } @@ -3563,22 +3563,22 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm SDL_memcmp(shader_constants, &rendererData->currentPipelineState->shader_constants, sizeof(*shader_constants)) != 0) { if (rendererData->currentConstantBufferOffset == -1) { - /* First time, grab offset 0 */ + // First time, grab offset 0 rendererData->currentConstantBufferOffset = 0; constantBufferOffset = 0; } else { - /* Align the next address to the minUniformBufferOffsetAlignment */ + // Align the next address to the minUniformBufferOffsetAlignment VkDeviceSize alignment = rendererData->physicalDeviceProperties.limits.minUniformBufferOffsetAlignment; SDL_assert(rendererData->currentConstantBufferOffset >= 0 ); rendererData->currentConstantBufferOffset += (int32_t)(sizeof(PixelShaderConstants) + alignment - 1) & ~(alignment - 1); constantBufferOffset = rendererData->currentConstantBufferOffset; } - /* If we have run out of size in this constant buffer, create another if needed */ + // If we have run out of size in this constant buffer, create another if needed if (rendererData->currentConstantBufferOffset >= SDL_VULKAN_CONSTANT_BUFFER_DEFAULT_SIZE) { uint32_t newConstantBufferIndex = (rendererData->currentConstantBufferIndex + 1); - /* We need a new constant buffer */ + // We need a new constant buffer if (newConstantBufferIndex >= rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex]) { VULKAN_Buffer newConstantBuffer; VkResult result = VULKAN_AllocateBuffer(rendererData, @@ -3608,19 +3608,19 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm SDL_memcpy(&rendererData->currentPipelineState->shader_constants, shader_constants, sizeof(*shader_constants)); - /* Upload constants to persistently mapped buffer */ + // Upload constants to persistently mapped buffer uint8_t *dst = (uint8_t *)rendererData->constantBuffers[rendererData->currentCommandBufferIndex][rendererData->currentConstantBufferIndex].mappedBufferPtr; dst += constantBufferOffset; SDL_memcpy(dst, &rendererData->currentPipelineState->shader_constants, sizeof(PixelShaderConstants)); } - /* Allocate/update descriptor set with the bindings */ + // Allocate/update descriptor set with the bindings descriptorSet = VULKAN_AllocateDescriptorSet(renderer, shader, descriptorSetLayout, sampler, constantBuffer, constantBufferOffset, imageView); if (descriptorSet == VK_NULL_HANDLE) { return SDL_FALSE; } - /* Bind the descriptor set with the sampler/UBO/image views */ + // Bind the descriptor set with the sampler/UBO/image views vkCmdBindDescriptorSets(rendererData->currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, rendererData->currentPipelineState->pipelineLayout, 0, 1, &descriptorSet, 0, NULL); @@ -3728,7 +3728,7 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd switch (cmd->command) { case SDL_RENDERCMD_SETDRAWCOLOR: { - break; /* this isn't currently used in this render backend. */ + break; // this isn't currently used in this render backend. } case SDL_RENDERCMD_SETVIEWPORT: @@ -3801,13 +3801,13 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd break; } - case SDL_RENDERCMD_FILL_RECTS: /* unused */ + case SDL_RENDERCMD_FILL_RECTS: // unused break; - case SDL_RENDERCMD_COPY: /* unused */ + case SDL_RENDERCMD_COPY: // unused break; - case SDL_RENDERCMD_COPY_EX: /* unused */ + case SDL_RENDERCMD_COPY_EX: // unused break; case SDL_RENDERCMD_GEOMETRY: @@ -3850,7 +3850,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re VULKAN_EnsureCommandBuffer(rendererData); - /* Stop any outstanding renderpass if open */ + // Stop any outstanding renderpass if open if (rendererData->currentRenderPass != VK_NULL_HANDLE) { vkCmdEndRenderPass(rendererData->currentCommandBuffer); rendererData->currentRenderPass = VK_NULL_HANDLE; @@ -3880,7 +3880,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re } - /* Make sure the source is in the correct resource state */ + // Make sure the source is in the correct resource state VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, @@ -3890,7 +3890,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re backBuffer, imageLayout); - /* Copy the image to the readback buffer */ + // Copy the image to the readback buffer VkBufferImageCopy region; region.bufferOffset = 0; region.bufferRowLength = 0; @@ -3907,10 +3907,10 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re region.imageExtent.depth = 1; vkCmdCopyImageToBuffer(rendererData->currentCommandBuffer, backBuffer, *imageLayout, readbackBuffer.buffer, 1, ®ion); - /* We need to issue the command list for the copy to finish */ + // We need to issue the command list for the copy to finish VULKAN_IssueBatch(rendererData); - /* Transition the render target back to a render target */ + // Transition the render target back to a render target VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, @@ -3938,7 +3938,7 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_ if (wait_semaphore) { if (rendererData->waitRenderSemaphoreCount == rendererData->waitRenderSemaphoreMax) { - /* Allocate an additional one at the end for the normal present wait */ + // Allocate an additional one at the end for the normal present wait VkPipelineStageFlags *waitDestStageMasks = (VkPipelineStageFlags *)SDL_realloc(rendererData->waitDestStageMasks, (rendererData->waitRenderSemaphoreMax + 2) * sizeof(*waitDestStageMasks)); if (!waitDestStageMasks) { return -1; @@ -3959,7 +3959,7 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_ if (signal_semaphore) { if (rendererData->signalRenderSemaphoreCount == rendererData->signalRenderSemaphoreMax) { - /* Allocate an additional one at the end for the normal present signal */ + // Allocate an additional one at the end for the normal present signal VkSemaphore *semaphores = (VkSemaphore *)SDL_realloc(rendererData->signalRenderSemaphores, (rendererData->signalRenderSemaphoreMax + 2) * sizeof(*semaphores)); if (!semaphores) { return -1; @@ -4053,7 +4053,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer) rendererData->currentCommandBufferIndex = ( rendererData->currentCommandBufferIndex + 1 ) % rendererData->swapchainImageCount; - /* Wait for previous time this command buffer was submitted, will be N frames ago */ + // Wait for previous time this command buffer was submitted, will be N frames ago result = vkWaitForFences(rendererData->device, 1, &rendererData->fences[rendererData->currentCommandBufferIndex], VK_TRUE, UINT64_MAX); if (result != VK_SUCCESS) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkWaitForFences(): %s\n", SDL_Vulkan_GetResultString(result)); @@ -4074,7 +4074,7 @@ static int VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync) case -1: case 0: case 1: - /* Supported */ + // Supported break; default: return SDL_Unsupported(); @@ -4124,7 +4124,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL renderer->QueueSetViewport = VULKAN_QueueNoOp; renderer->QueueSetDrawColor = VULKAN_QueueNoOp; renderer->QueueDrawPoints = VULKAN_QueueDrawPoints; - renderer->QueueDrawLines = VULKAN_QueueDrawPoints; /* lines and points queue vertices the same way. */ + renderer->QueueDrawLines = VULKAN_QueueDrawPoints; // lines and points queue vertices the same way. renderer->QueueGeometry = VULKAN_QueueGeometry; renderer->InvalidateCachedState = VULKAN_InvalidateCachedState; renderer->RunCommandQueue = VULKAN_RunCommandQueue; @@ -4149,7 +4149,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL */ renderer->window = window; - /* Initialize Vulkan resources */ + // Initialize Vulkan resources if (VULKAN_CreateDeviceResources(renderer, create_props) != VK_SUCCESS) { return -1; } else if (VULKAN_CreateWindowSizeDependentResources(renderer) != VK_SUCCESS) { @@ -4173,4 +4173,4 @@ SDL_RenderDriver VULKAN_RenderDriver = { VULKAN_CreateRenderer, "vulkan" }; -#endif /* SDL_VIDEO_RENDER_VULKAN */ +#endif // SDL_VIDEO_RENDER_VULKAN diff --git a/src/render/vulkan/SDL_shaders_vulkan.c b/src/render/vulkan/SDL_shaders_vulkan.c index 705281493a..ea02533bfc 100644 --- a/src/render/vulkan/SDL_shaders_vulkan.c +++ b/src/render/vulkan/SDL_shaders_vulkan.c @@ -24,7 +24,7 @@ #include "SDL_shaders_vulkan.h" -/* The shaders here were compiled with compile_shaders.bat */ +// The shaders here were compiled with compile_shaders.bat #include "VULKAN_PixelShader_Colors.h" #include "VULKAN_PixelShader_Textures.h" #include "VULKAN_PixelShader_Advanced.h" @@ -57,4 +57,4 @@ void VULKAN_GetPixelShader(VULKAN_Shader shader, const uint32_t **outBytecode, s *outSize = VULKAN_shaders[shader].ps_shader_size; } -#endif /* SDL_VIDEO_RENDER_VULKAN */ +#endif // SDL_VIDEO_RENDER_VULKAN diff --git a/src/render/vulkan/SDL_shaders_vulkan.h b/src/render/vulkan/SDL_shaders_vulkan.h index 21a6f75af3..63a81fc298 100644 --- a/src/render/vulkan/SDL_shaders_vulkan.h +++ b/src/render/vulkan/SDL_shaders_vulkan.h @@ -20,9 +20,9 @@ */ #include "SDL_internal.h" -/* Vulkan shader implementation */ +// Vulkan shader implementation -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -38,7 +38,7 @@ typedef enum extern void VULKAN_GetVertexShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize); extern void VULKAN_GetPixelShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif diff --git a/src/render/vulkan/VULKAN_VertexShader.hlsl b/src/render/vulkan/VULKAN_VertexShader.hlsl index d376876295..373a179a2c 100644 --- a/src/render/vulkan/VULKAN_VertexShader.hlsl +++ b/src/render/vulkan/VULKAN_VertexShader.hlsl @@ -5,7 +5,7 @@ struct VertexShaderConstants matrix model; matrix projectionAndView; }; -[[vk::push_constant]] +[[vk::push_constant]] ConstantBuffer pushConstants; struct VertexShaderInput diff --git a/src/render/vulkan/compile_shaders.bat b/src/render/vulkan/compile_shaders.bat index de3f912386..093de82d4d 100644 --- a/src/render/vulkan/compile_shaders.bat +++ b/src/render/vulkan/compile_shaders.bat @@ -1,5 +1,5 @@ -glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Colors -o VULKAN_PixelShader_Colors.h VULKAN_PixelShader_Colors.hlsl -glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Textures -o VULKAN_PixelShader_Textures.h VULKAN_PixelShader_Textures.hlsl -glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Advanced -o VULKAN_PixelShader_Advanced.h VULKAN_PixelShader_Advanced.hlsl +glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Colors -o VULKAN_PixelShader_Colors.h VULKAN_PixelShader_Colors.hlsl +glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Textures -o VULKAN_PixelShader_Textures.h VULKAN_PixelShader_Textures.hlsl +glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Advanced -o VULKAN_PixelShader_Advanced.h VULKAN_PixelShader_Advanced.hlsl -glslangValidator -D --sep mainColor -e main -S vert --iy --target-env vulkan1.0 --vn VULKAN_VertexShader -o VULKAN_VertexShader.h VULKAN_VertexShader.hlsl +glslangValidator -D --sep mainColor -e main -S vert --iy --target-env vulkan1.0 --vn VULKAN_VertexShader -o VULKAN_VertexShader.h VULKAN_VertexShader.hlsl diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index f13d3e8b0a..167fae1566 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This is the sensor API for Simple DirectMedia Layer */ +// This is the sensor API for Simple DirectMedia Layer #include "SDL_syssensor.h" @@ -51,7 +51,7 @@ static SDL_SensorDriver *SDL_sensor_drivers[] = { #ifndef SDL_THREAD_SAFETY_ANALYSIS static #endif -SDL_Mutex *SDL_sensor_lock = NULL; /* This needs to support recursive locks */ +SDL_Mutex *SDL_sensor_lock = NULL; // This needs to support recursive locks static SDL_AtomicInt SDL_sensor_lock_pending; static int SDL_sensors_locked; static SDL_bool SDL_sensors_initialized; @@ -85,7 +85,7 @@ void SDL_UnlockSensors(void) --SDL_sensors_locked; if (!SDL_sensors_initialized) { - /* NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks */ + // NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks if (!SDL_sensors_locked && SDL_AtomicGet(&SDL_sensor_lock_pending) == 0) { last_unlock = SDL_TRUE; } @@ -124,7 +124,7 @@ int SDL_InitSensors(void) { int i, status; - /* Create the sensor list lock */ + // Create the sensor list lock if (SDL_sensor_lock == NULL) { SDL_sensor_lock = SDL_CreateMutex(); } @@ -319,7 +319,7 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id) sensorlist = sensorlist->next; } - /* Create and initialize the sensor */ + // Create and initialize the sensor sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1); if (!sensor) { SDL_UnlockSensors(); @@ -345,9 +345,9 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id) sensor->name = NULL; } - /* Add sensor to list */ + // Add sensor to list ++sensor->ref_count; - /* Link the sensor in the list */ + // Link the sensor in the list sensor->next = SDL_sensors; SDL_sensors = sensor; @@ -497,7 +497,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor) { CHECK_SENSOR_MAGIC(sensor,); - /* First decrement ref count */ + // First decrement ref count if (--sensor->ref_count > 0) { SDL_UnlockSensors(); return; @@ -514,7 +514,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor) while (sensorlist) { if (sensor == sensorlist) { if (sensorlistprev) { - /* unlink this entry */ + // unlink this entry sensorlistprev->next = sensorlist->next; } else { SDL_sensors = sensor->next; @@ -525,7 +525,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor) sensorlist = sensorlist->next; } - /* Free the data associated with this sensor */ + // Free the data associated with this sensor SDL_free(sensor->name); SDL_free(sensor); } @@ -538,13 +538,13 @@ void SDL_QuitSensors(void) SDL_LockSensors(); - /* Stop the event polling */ + // Stop the event polling while (SDL_sensors) { SDL_sensors->ref_count = 1; SDL_CloseSensor(SDL_sensors); } - /* Quit the sensor setup */ + // Quit the sensor setup for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) { SDL_sensor_drivers[i]->Quit(); } @@ -556,7 +556,7 @@ void SDL_QuitSensors(void) SDL_UnlockSensors(); } -/* These are global for SDL_syssensor.c and SDL_events.c */ +// These are global for SDL_syssensor.c and SDL_events.c int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values) { @@ -564,13 +564,13 @@ int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_tim SDL_AssertSensorsLocked(); - /* Allow duplicate events, for things like steps and heartbeats */ + // Allow duplicate events, for things like steps and heartbeats - /* Update internal sensor state */ + // Update internal sensor state num_values = SDL_min(num_values, SDL_arraysize(sensor->data)); SDL_memcpy(sensor->data, data, num_values * sizeof(*data)); - /* Post the event, if desired */ + // Post the event, if desired posted = 0; if (SDL_EventEnabled(SDL_EVENT_SENSOR_UPDATE)) { SDL_Event event; diff --git a/src/sensor/SDL_sensor_c.h b/src/sensor/SDL_sensor_c.h index fce4896873..09b99fba52 100644 --- a/src/sensor/SDL_sensor_c.h +++ b/src/sensor/SDL_sensor_c.h @@ -29,31 +29,31 @@ extern SDL_Mutex *SDL_sensor_lock; struct SDL_SensorDriver; -/* Useful functions and variables from SDL_sensor.c */ +// Useful functions and variables from SDL_sensor.c -/* Initialization and shutdown functions */ +// Initialization and shutdown functions extern int SDL_InitSensors(void); extern void SDL_QuitSensors(void); -/* Return whether the sensor system is currently initialized */ +// Return whether the sensor system is currently initialized extern SDL_bool SDL_SensorsInitialized(void); -/* Return whether the sensors are currently locked */ +// Return whether the sensors are currently locked extern SDL_bool SDL_SensorsLocked(void); -/* Make sure we currently have the sensors locked */ +// Make sure we currently have the sensors locked extern void SDL_AssertSensorsLocked(void) SDL_ASSERT_CAPABILITY(SDL_sensor_lock); extern void SDL_LockSensors(void) SDL_ACQUIRE(SDL_sensor_lock); extern void SDL_UnlockSensors(void) SDL_RELEASE(SDL_sensor_lock); -/* Function to return whether there are any sensors opened by the application */ +// Function to return whether there are any sensors opened by the application extern SDL_bool SDL_SensorsOpened(void); -/* Update an individual sensor, used by gamepad sensor fusion */ +// Update an individual sensor, used by gamepad sensor fusion extern void SDL_UpdateSensor(SDL_Sensor *sensor); -/* Internal event queueing functions */ +// Internal event queueing functions extern int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values); -#endif /* SDL_sensor_c_h_ */ +#endif // SDL_sensor_c_h_ diff --git a/src/sensor/SDL_syssensor.h b/src/sensor/SDL_syssensor.h index 1b7d6b4af0..1caed32002 100644 --- a/src/sensor/SDL_syssensor.h +++ b/src/sensor/SDL_syssensor.h @@ -23,31 +23,31 @@ #ifndef SDL_syssensor_c_h_ #define SDL_syssensor_c_h_ -/* This is the system specific header for the SDL sensor API */ +// This is the system specific header for the SDL sensor API #include "SDL_sensor_c.h" #define _guarded SDL_GUARDED_BY(SDL_sensor_lock) -/* The SDL sensor structure */ +// The SDL sensor structure struct SDL_Sensor { - SDL_SensorID instance_id _guarded; /* Device instance, monotonically increasing from 0 */ - char *name _guarded; /* Sensor name - system dependent */ - SDL_SensorType type _guarded; /* Type of the sensor */ - int non_portable_type _guarded; /* Platform dependent type of the sensor */ + SDL_SensorID instance_id _guarded; // Device instance, monotonically increasing from 0 + char *name _guarded; // Sensor name - system dependent + SDL_SensorType type _guarded; // Type of the sensor + int non_portable_type _guarded; // Platform dependent type of the sensor - float data[16] _guarded; /* The current state of the sensor */ + float data[16] _guarded; // The current state of the sensor struct SDL_SensorDriver *driver _guarded; - struct sensor_hwdata *hwdata _guarded; /* Driver dependent information */ + struct sensor_hwdata *hwdata _guarded; // Driver dependent information SDL_PropertiesID props _guarded; - int ref_count _guarded; /* Reference count for multiple opens */ + int ref_count _guarded; // Reference count for multiple opens - struct SDL_Sensor *next _guarded; /* pointer to next sensor we have allocated */ + struct SDL_Sensor *next _guarded; // pointer to next sensor we have allocated }; #undef _guarded @@ -60,22 +60,22 @@ typedef struct SDL_SensorDriver */ int (*Init)(void); - /* Function to return the number of sensors available right now */ + // Function to return the number of sensors available right now int (*GetCount)(void); - /* Function to check to see if the available sensors have changed */ + // Function to check to see if the available sensors have changed void (*Detect)(void); - /* Function to get the device-dependent name of a sensor */ + // Function to get the device-dependent name of a sensor const char *(*GetDeviceName)(int device_index); - /* Function to get the type of a sensor */ + // Function to get the type of a sensor SDL_SensorType (*GetDeviceType)(int device_index); - /* Function to get the platform dependent type of a sensor */ + // Function to get the platform dependent type of a sensor int (*GetDeviceNonPortableType)(int device_index); - /* Function to get the current instance id of the sensor located at device_index */ + // Function to get the current instance id of the sensor located at device_index SDL_SensorID (*GetDeviceInstanceID)(int device_index); /* Function to open a sensor for use. @@ -91,15 +91,15 @@ typedef struct SDL_SensorDriver */ void (*Update)(SDL_Sensor *sensor); - /* Function to close a sensor after use */ + // Function to close a sensor after use void (*Close)(SDL_Sensor *sensor); - /* Function to perform any system-specific sensor related cleanup */ + // Function to perform any system-specific sensor related cleanup void (*Quit)(void); } SDL_SensorDriver; -/* The available sensor drivers */ +// The available sensor drivers extern SDL_SensorDriver SDL_ANDROID_SensorDriver; extern SDL_SensorDriver SDL_COREMOTION_SensorDriver; extern SDL_SensorDriver SDL_WINDOWS_SensorDriver; @@ -107,4 +107,4 @@ extern SDL_SensorDriver SDL_DUMMY_SensorDriver; extern SDL_SensorDriver SDL_VITA_SensorDriver; extern SDL_SensorDriver SDL_N3DS_SensorDriver; -#endif /* SDL_syssensor_h_ */ +#endif // SDL_syssensor_h_ diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 12ecaac88c..786c42ef27 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -22,7 +22,7 @@ #ifdef SDL_SENSOR_ANDROID -/* This is the system specific header for the SDL sensor API */ +// This is the system specific header for the SDL sensor API #include #include "SDL_androidsensor.h" @@ -126,7 +126,7 @@ static int SDL_ANDROID_StartSensorThread(SDL_AndroidSensorThreadContext *ctx) return -1; } - /* Wait for the sensor thread to start */ + // Wait for the sensor thread to start SDL_WaitSemaphore(ctx->sem); return 0; @@ -142,7 +142,7 @@ static int SDL_ANDROID_SensorInit(void) return SDL_SetError("Couldn't create sensor manager"); } - /* FIXME: Is the sensor list dynamic? */ + // FIXME: Is the sensor list dynamic? sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors); if (sensors_count > 0) { SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors)); @@ -219,8 +219,8 @@ static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) return SDL_SetError("Couldn't enable sensor"); } - /* Use 60 Hz update rate if possible */ - /* FIXME: Maybe add a hint for this? */ + // Use 60 Hz update rate if possible + // FIXME: Maybe add a hint for this? delay_us = 1000000 / 60; min_delay_us = ASensor_getMinDelay(SDL_sensors[device_index].asensor); if (delay_us < min_delay_us) { @@ -258,7 +258,7 @@ static void SDL_ANDROID_SensorClose(SDL_Sensor *sensor) static void SDL_ANDROID_SensorQuit(void) { - /* All sensors are closed, but we need to unblock the sensor thread */ + // All sensors are closed, but we need to unblock the sensor thread SDL_AssertSensorsLocked(); SDL_UnlockSensors(); SDL_ANDROID_StopSensorThread(&SDL_sensor_thread_context); @@ -285,4 +285,4 @@ SDL_SensorDriver SDL_ANDROID_SensorDriver = { SDL_ANDROID_SensorQuit, }; -#endif /* SDL_SENSOR_ANDROID */ +#endif // SDL_SENSOR_ANDROID diff --git a/src/sensor/coremotion/SDL_coremotionsensor.h b/src/sensor/coremotion/SDL_coremotionsensor.h index 2e65230e06..75494fddc7 100644 --- a/src/sensor/coremotion/SDL_coremotionsensor.h +++ b/src/sensor/coremotion/SDL_coremotionsensor.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* The private structure used to keep track of a sensor */ +// The private structure used to keep track of a sensor struct sensor_hwdata { float data[3]; diff --git a/src/sensor/coremotion/SDL_coremotionsensor.m b/src/sensor/coremotion/SDL_coremotionsensor.m index 3f9c36464f..2763316d0e 100644 --- a/src/sensor/coremotion/SDL_coremotionsensor.m +++ b/src/sensor/coremotion/SDL_coremotionsensor.m @@ -22,7 +22,7 @@ #ifdef SDL_SENSOR_COREMOTION -/* This is the system specific header for the SDL sensor API */ +// This is the system specific header for the SDL sensor API #include #include "SDL_coremotionsensor.h" @@ -211,4 +211,4 @@ SDL_SensorDriver SDL_COREMOTION_SensorDriver = { SDL_COREMOTION_SensorQuit, }; -#endif /* SDL_SENSOR_COREMOTION */ +#endif // SDL_SENSOR_COREMOTION diff --git a/src/sensor/dummy/SDL_dummysensor.c b/src/sensor/dummy/SDL_dummysensor.c index c9041d81e1..d23d24ff85 100644 --- a/src/sensor/dummy/SDL_dummysensor.c +++ b/src/sensor/dummy/SDL_dummysensor.c @@ -90,4 +90,4 @@ SDL_SensorDriver SDL_DUMMY_SensorDriver = { SDL_DUMMY_SensorQuit, }; -#endif /* SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED */ +#endif // SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED diff --git a/src/sensor/n3ds/SDL_n3dssensor.c b/src/sensor/n3ds/SDL_n3dssensor.c index 5b44d6562e..96603fdbb0 100644 --- a/src/sensor/n3ds/SDL_n3dssensor.c +++ b/src/sensor/n3ds/SDL_n3dssensor.c @@ -27,7 +27,7 @@ #include "../SDL_syssensor.h" -/* 1 accelerometer and 1 gyroscope */ +// 1 accelerometer and 1 gyroscope #define N3DS_SENSOR_COUNT 2 typedef struct @@ -200,4 +200,4 @@ SDL_SensorDriver SDL_N3DS_SensorDriver = { .Quit = N3DS_SensorQuit, }; -#endif /* SDL_SENSOR_N3DS */ +#endif // SDL_SENSOR_N3DS diff --git a/src/sensor/vita/SDL_vitasensor.c b/src/sensor/vita/SDL_vitasensor.c index 7c0cd8b6e0..047660ab0a 100644 --- a/src/sensor/vita/SDL_vitasensor.c +++ b/src/sensor/vita/SDL_vitasensor.c @@ -201,4 +201,4 @@ SDL_SensorDriver SDL_VITA_SensorDriver = { SDL_VITA_SensorQuit, }; -#endif /* SDL_SENSOR_VITA */ +#endif // SDL_SENSOR_VITA diff --git a/src/sensor/vita/SDL_vitasensor.h b/src/sensor/vita/SDL_vitasensor.h index 92518df7af..f9055a1d0a 100644 --- a/src/sensor/vita/SDL_vitasensor.h +++ b/src/sensor/vita/SDL_vitasensor.h @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* The private structure used to keep track of a sensor */ +// The private structure used to keep track of a sensor struct sensor_hwdata { Uint32 counter; diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index d7c8813fa3..2a855422c5 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -36,7 +36,7 @@ DEFINE_GUID(SDL_IID_SensorManager, 0xBD77DB67, 0x45A8, 0x42DC, 0x8D, 0x00, 0x6D, DEFINE_GUID(SDL_IID_SensorManagerEvents, 0x9B3B0B86, 0x266A, 0x4AAD, 0xB2, 0x1F, 0xFD, 0xE5, 0x50, 0x10, 0x01, 0xB7); DEFINE_GUID(SDL_IID_SensorEvents, 0x5D8DCC91, 0x4641, 0x47E7, 0xB7, 0xC3, 0xB7, 0x4F, 0x48, 0xA6, 0xC3, 0x91); -/* These constants aren't available in Visual Studio 2015 or earlier Windows SDK */ +// These constants aren't available in Visual Studio 2015 or earlier Windows SDK DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_X_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 10); //[VT_R8] DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Y_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 11); //[VT_R8] DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Z_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 12); //[VT_R8] @@ -199,7 +199,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents * } break; default: - /* FIXME: Need to know how to interpret the data for this sensor */ + // FIXME: Need to know how to interpret the data for this sensor break; } } @@ -337,7 +337,7 @@ static int DisconnectSensor(ISensor *sensor) /* This call hangs for some reason: * https://github.com/libsdl-org/SDL/issues/5288 */ - /*ISensor_SetEventSink(sensor, NULL);*/ + // ISensor_SetEventSink(sensor, NULL); ISensor_Release(sensor); SDL_free(old_sensor->name); --SDL_num_sensors; @@ -363,8 +363,8 @@ static int SDL_WINDOWS_SensorInit(void) 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); */ + // 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); } hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events); @@ -482,4 +482,4 @@ SDL_SensorDriver SDL_WINDOWS_SensorDriver = { SDL_WINDOWS_SensorQuit, }; -#endif /* SDL_SENSOR_WINDOWS */ +#endif // SDL_SENSOR_WINDOWS diff --git a/src/stdlib/SDL_casefolding.h b/src/stdlib/SDL_casefolding.h index e850dc4501..a728b30cdf 100644 --- a/src/stdlib/SDL_casefolding.h +++ b/src/stdlib/SDL_casefolding.h @@ -2765,5 +2765,5 @@ static const CaseFoldHashBucket3_16 case_fold_hash3_16[] = { { case_fold3_16_003, SDL_arraysize(case_fold3_16_003) }, }; -#endif /* SDL_casefolding_h_ */ +#endif // SDL_casefolding_h_ diff --git a/src/stdlib/SDL_crc16.c b/src/stdlib/SDL_crc16.c index 58830d6990..67cfaad540 100644 --- a/src/stdlib/SDL_crc16.c +++ b/src/stdlib/SDL_crc16.c @@ -43,7 +43,7 @@ static Uint16 crc16_for_byte(Uint8 r) Uint16 SDL_crc16(Uint16 crc, const void *data, size_t len) { - /* As an optimization we can precalculate a 256 entry table for each byte */ + // 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; diff --git a/src/stdlib/SDL_crc32.c b/src/stdlib/SDL_crc32.c index f61ae5439c..166ba19678 100644 --- a/src/stdlib/SDL_crc32.c +++ b/src/stdlib/SDL_crc32.c @@ -41,7 +41,7 @@ static Uint32 crc32_for_byte(Uint32 r) Uint32 SDL_crc32(Uint32 crc, const void *data, size_t len) { - /* As an optimization we can precalculate a 256 entry table for each byte */ + // 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; diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 3deea8c681..f6ac7ff1df 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -40,37 +40,37 @@ #define HAVE_LOCAL_ENVIRONMENT #endif -/* Put a variable into the environment */ -/* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */ +// Put a variable into the environment +// Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) #ifdef HAVE_LIBC_ENVIRONMENT #if defined(HAVE_SETENV) int SDL_setenv(const char *name, const char *value, int overwrite) { - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } return setenv(name, value, overwrite); } -/* We have a real environment table, but no real setenv? Fake it w/ putenv. */ +// We have a real environment table, but no real setenv? Fake it w/ putenv. #else int SDL_setenv(const char *name, const char *value, int overwrite) { char *new_variable; - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } if (getenv(name) != NULL) { if (!overwrite) { - 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. */ + // This leaks. Sorry. Get a better OS so we don't have to do this. SDL_asprintf(&new_variable, "%s=%s", name, value); if (!new_variable) { return -1; @@ -81,14 +81,14 @@ int SDL_setenv(const char *name, const char *value, int overwrite) #elif defined(HAVE_WIN32_ENVIRONMENT) int SDL_setenv(const char *name, const char *value, int overwrite) { - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { 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)) { @@ -96,9 +96,9 @@ int SDL_setenv(const char *name, const char *value, int overwrite) } return 0; } -#else /* roll our own */ +#else // roll our own -/* We'll leak this, as environment variables are intended to persist past SDL_Quit() */ +// We'll leak this, as environment variables are intended to persist past SDL_Quit() static char **SDL_env; int SDL_setenv(const char *name, const char *value, int overwrite) @@ -108,17 +108,17 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char **new_env; char *new_variable; - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } - /* See if it already exists */ + // See if it already exists if (!overwrite && SDL_getenv(name)) { return 0; } - /* Allocate memory for the variable */ + // Allocate memory for the variable len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); if (!new_variable) { @@ -129,15 +129,15 @@ int SDL_setenv(const char *name, const char *value, int overwrite) value = new_variable + SDL_strlen(name) + 1; name = new_variable; - /* Actually put it into the environment */ + // Actually put it into the environment added = 0; i = 0; if (SDL_env) { - /* Check to see if it's already there... */ + // Check to see if it's already there... len = (value - name); for (; SDL_env[i]; ++i) { if (SDL_strncmp(SDL_env[i], name, len) == 0) { - /* If we found it, just replace the entry */ + // If we found it, just replace the entry SDL_free(SDL_env[i]); SDL_env[i] = new_variable; added = 1; @@ -146,7 +146,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) } } - /* Didn't find it in the environment, expand and add */ + // Didn't find it in the environment, expand and add if (!added) { new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *)); if (new_env) { @@ -166,18 +166,18 @@ int SDL_setenv(const char *name, const char *value, int overwrite) #if defined(HAVE_UNSETENV) int SDL_unsetenv(const char *name) { - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) { return -1; } return unsetenv(name); } -/* We have a real environment table, but no unsetenv? Fake it w/ putenv. */ +// We have a real environment table, but no unsetenv? Fake it w/ putenv. #else int SDL_unsetenv(const char *name) { - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) { return -1; } @@ -189,7 +189,7 @@ int SDL_unsetenv(const char *name) #elif defined(HAVE_WIN32_ENVIRONMENT) int SDL_unsetenv(const char *name) { - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) { return -1; } @@ -204,7 +204,7 @@ int SDL_unsetenv(const char *name) { size_t len, i; - /* Input validation */ + // Input validation if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) { return -1; } @@ -214,7 +214,7 @@ int SDL_unsetenv(const char *name) for (i = 0; SDL_env[i]; ++i) { if ((SDL_strncmp(SDL_env[i], name, len) == 0) && (SDL_env[i][len] == '=')) { - /* Just clear out this entry for now */ + // Just clear out this entry for now *SDL_env[i] = '\0'; break; } @@ -224,16 +224,16 @@ int SDL_unsetenv(const char *name) } #endif // HAVE_LIBC_ENVIRONMENT -/* Retrieve a variable named "name" from the environment */ +// Retrieve a variable named "name" from the environment #ifdef HAVE_LIBC_ENVIRONMENT const char *SDL_getenv(const char *name) { #ifdef SDL_PLATFORM_ANDROID - /* Make sure variables from the application manifest are available */ + // Make sure variables from the application manifest are available Android_JNI_GetManifestEnvironmentVariables(); #endif - /* Input validation */ + // Input validation if (!name || *name == '\0') { return NULL; } @@ -247,7 +247,7 @@ const char *SDL_getenv(const char *name) char *string = NULL; const char *retval = NULL; - /* Input validation */ + // Input validation if (!name || *name == '\0') { return NULL; } @@ -285,7 +285,7 @@ const char *SDL_getenv(const char *name) size_t len, i; char *value; - /* Input validation */ + // Input validation if (!name || *name == '\0') { return NULL; } diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index b31ee0c42c..d53bb3ead7 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -20,11 +20,11 @@ */ #include "SDL_internal.h" -/* This file contains portable iconv functions for SDL */ +// This file contains portable iconv functions for SDL #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) #ifndef SDL_USE_LIBICONV -/* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */ +// Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. #define LIBICONV_PLUG 1 #endif #include @@ -87,10 +87,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, @@ -121,7 +121,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 }, @@ -155,7 +155,7 @@ static struct { "UCS-4LE", ENCODING_UCS4LE }, { "UCS-4BE", ENCODING_UCS4BE }, { "UCS-4-INTERNAL", ENCODING_UCS4NATIVE }, -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on }; static const char *getlocale(char *buffer, size_t bufsize) @@ -177,7 +177,7 @@ static const char *getlocale(char *buffer, size_t bufsize) lang = "ASCII"; } - /* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */ + // We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" ptr = SDL_strchr(lang, '.'); if (ptr) { lang = ptr + 1; @@ -186,7 +186,7 @@ static const char *getlocale(char *buffer, size_t bufsize) SDL_strlcpy(buffer, lang, bufsize); ptr = SDL_strchr(buffer, '@'); if (ptr) { - *ptr = '\0'; /* chop end of string. */ + *ptr = '\0'; // chop end of string. } return buffer; @@ -235,7 +235,7 @@ size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { - /* For simplicity, we'll convert everything to and from UCS-4 */ + // For simplicity, we'll convert everything to and from UCS-4 const char *src; char *dst; size_t srclen, dstlen; @@ -246,7 +246,7 @@ size_t SDL_iconv(SDL_iconv_t cd, return SDL_ICONV_ERROR; } if (!inbuf || !*inbuf) { - /* Reset the context */ + // Reset the context return 0; } if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) { @@ -259,7 +259,7 @@ size_t SDL_iconv(SDL_iconv_t cd, switch (cd->src_fmt) { case ENCODING_UTF16: - /* Scan for a byte order marker */ + // Scan for a byte order marker { Uint8 *p = (Uint8 *)src; size_t n = srclen / 2; @@ -275,13 +275,13 @@ size_t SDL_iconv(SDL_iconv_t cd, --n; } if (n == 0) { - /* We can't tell, default to host order */ + // We can't tell, default to host order cd->src_fmt = ENCODING_UTF16NATIVE; } } break; case ENCODING_UTF32: - /* Scan for a byte order marker */ + // Scan for a byte order marker { Uint8 *p = (Uint8 *)src; size_t n = srclen / 4; @@ -299,7 +299,7 @@ size_t SDL_iconv(SDL_iconv_t cd, --n; } if (n == 0) { - /* We can't tell, default to host order */ + // We can't tell, default to host order cd->src_fmt = ENCODING_UTF32NATIVE; } } @@ -308,7 +308,7 @@ size_t SDL_iconv(SDL_iconv_t cd, switch (cd->dst_fmt) { case ENCODING_UTF16: - /* Default to host order, need to add byte order marker */ + // Default to host order, need to add byte order marker if (dstlen < 2) { return SDL_ICONV_E2BIG; } @@ -318,7 +318,7 @@ size_t SDL_iconv(SDL_iconv_t cd, cd->dst_fmt = ENCODING_UTF16NATIVE; break; case ENCODING_UTF32: - /* Default to host order, need to add byte order marker */ + // Default to host order, need to add byte order marker if (dstlen < 4) { return SDL_ICONV_E2BIG; } @@ -331,7 +331,7 @@ size_t SDL_iconv(SDL_iconv_t cd, total = 0; while (srclen > 0) { - /* Decode a character */ + // Decode a character switch (cd->src_fmt) { case ENCODING_ASCII: { @@ -347,7 +347,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ++src; --srclen; } break; - case ENCODING_UTF8: /* RFC 3629 */ + case ENCODING_UTF8: // RFC 3629 { Uint8 *p = (Uint8 *)src; size_t left = 0; @@ -434,7 +434,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } } break; - case ENCODING_UTF16BE: /* RFC 2781 */ + case ENCODING_UTF16BE: // RFC 2781 { Uint8 *p = (Uint8 *)src; Uint16 W1, W2; @@ -473,7 +473,7 @@ size_t SDL_iconv(SDL_iconv_t cd, (Uint32)(W2 & 0x3FF)) + 0x10000; } break; - case ENCODING_UTF16LE: /* RFC 2781 */ + case ENCODING_UTF16LE: // RFC 2781 { Uint8 *p = (Uint8 *)src; Uint16 W1, W2; @@ -560,7 +560,7 @@ size_t SDL_iconv(SDL_iconv_t cd, } break; } - /* Encode a character */ + // Encode a character switch (cd->dst_fmt) { case ENCODING_ASCII: { @@ -590,7 +590,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ++dst; --dstlen; } break; - case ENCODING_UTF8: /* RFC 3629 */ + case ENCODING_UTF8: // RFC 3629 { Uint8 *p = (Uint8 *)dst; if (ch > 0x10FFFF) { @@ -632,7 +632,7 @@ size_t SDL_iconv(SDL_iconv_t cd, dstlen -= 4; } } break; - case ENCODING_UTF16BE: /* RFC 2781 */ + case ENCODING_UTF16BE: // RFC 2781 { Uint8 *p = (Uint8 *)dst; if (ch > 0x10FFFF) { @@ -662,7 +662,7 @@ size_t SDL_iconv(SDL_iconv_t cd, dstlen -= 4; } } break; - case ENCODING_UTF16LE: /* RFC 2781 */ + case ENCODING_UTF16LE: // RFC 2781 { Uint8 *p = (Uint8 *)dst; if (ch > 0x10FFFF) { @@ -766,7 +766,7 @@ size_t SDL_iconv(SDL_iconv_t cd, break; } - /* Update state */ + // Update state *inbuf = src; *inbytesleft = srclen; *outbuf = dst; @@ -785,7 +785,7 @@ int SDL_iconv_close(SDL_iconv_t cd) return 0; } -#endif /* !HAVE_ICONV */ +#endif // !HAVE_ICONV char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft) { @@ -838,17 +838,17 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb continue; } case SDL_ICONV_EILSEQ: - /* Try skipping some input data - not perfect, but... */ + // Try skipping some input data - not perfect, but... ++inbuf; --inbytesleft; break; case SDL_ICONV_EINVAL: case SDL_ICONV_ERROR: - /* We can't continue... */ + // We can't continue... inbytesleft = 0; break; } - /* Avoid infinite loops when nothing gets converted */ + // Avoid infinite loops when nothing gets converted if (oldinbytesleft == inbytesleft) { break; } diff --git a/src/stdlib/SDL_memcpy.c b/src/stdlib/SDL_memcpy.c index 6c6457652d..f889916d6f 100644 --- a/src/stdlib/SDL_memcpy.c +++ b/src/stdlib/SDL_memcpy.c @@ -45,7 +45,7 @@ void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void aligned before we loop using them. */ if (((uintptr_t)src & 0x3) || ((uintptr_t)dst & 0x3)) { - /* Do an unaligned byte copy */ + // Do an unaligned byte copy Uint8 *srcp1 = (Uint8 *)src; Uint8 *dstp1 = (Uint8 *)dst; @@ -78,13 +78,13 @@ void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void } } return dst; -#endif /* HAVE_MEMCPY */ +#endif // HAVE_MEMCPY } /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls. We will provide our own implementation if we're not building with a C runtime. */ #ifndef HAVE_LIBC -/* NOLINTNEXTLINE(readability-redundant-declaration) */ +// NOLINTNEXTLINE(readability-redundant-declaration) extern void *memcpy(void *dst, const void *src, size_t len); #if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER) #pragma intrinsic(memcpy) @@ -93,9 +93,9 @@ extern void *memcpy(void *dst, const void *src, size_t len); #if defined(_MSC_VER) && !defined(__clang__) #pragma function(memcpy) #endif -/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */ +// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) void *memcpy(void *dst, const void *src, size_t len) { return SDL_memcpy(dst, src, len); } -#endif /* !HAVE_LIBC */ +#endif // !HAVE_LIBC diff --git a/src/stdlib/SDL_memmove.c b/src/stdlib/SDL_memmove.c index db5d319466..0c244ca05f 100644 --- a/src/stdlib/SDL_memmove.c +++ b/src/stdlib/SDL_memmove.c @@ -30,7 +30,7 @@ void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len) { #if defined(__GNUC__) && (defined(HAVE_LIBC) && HAVE_LIBC) - /* Presumably this is well tuned for speed. */ + // Presumably this is well tuned for speed. return __builtin_memmove(dst, src, len); #elif defined(HAVE_MEMMOVE) return memmove(dst, src, len); @@ -50,12 +50,12 @@ void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void } } return dst; -#endif /* HAVE_MEMMOVE */ +#endif // HAVE_MEMMOVE } #ifndef HAVE_LIBC -/* NOLINTNEXTLINE(readability-redundant-declaration) */ +// NOLINTNEXTLINE(readability-redundant-declaration) extern void *memmove(void *dst, const void *src, size_t len); #if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER) #pragma intrinsic(memmove) @@ -64,10 +64,10 @@ extern void *memmove(void *dst, const void *src, size_t len); #if defined(_MSC_VER) && !defined(__clang__) #pragma function(memmove) #endif -/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */ +// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) void *memmove(void *dst, const void *src, size_t len) { return SDL_memmove(dst, src, len); } -#endif /* !HAVE_LIBC */ +#endif // !HAVE_LIBC diff --git a/src/stdlib/SDL_memset.c b/src/stdlib/SDL_memset.c index 2103ff183f..a655f57c48 100644 --- a/src/stdlib/SDL_memset.c +++ b/src/stdlib/SDL_memset.c @@ -40,7 +40,7 @@ void *SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len) Uint8 value1; Uint32 value4; - /* The value used in memset() is a byte, passed as an int */ + // The value used in memset() is a byte, passed as an int c &= 0xff; /* The destination pointer needs to be aligned on a 4-byte boundary to @@ -76,10 +76,10 @@ void *SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len) } return dst; -#endif /* HAVE_MEMSET */ +#endif // HAVE_MEMSET } -/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ +// Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. void *SDL_memset4(void *dst, Uint32 val, size_t dwords) { #if defined(__APPLE__) && defined(HAVE_STRING_H) @@ -121,7 +121,7 @@ void *SDL_memset4(void *dst, Uint32 val, size_t dwords) /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls. We will provide our own implementation if we're not building with a C runtime. */ #ifndef HAVE_LIBC -/* NOLINTNEXTLINE(readability-redundant-declaration) */ +// NOLINTNEXTLINE(readability-redundant-declaration) extern void *memset(void *dst, int c, size_t len); #if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER) #pragma intrinsic(memset) @@ -130,10 +130,10 @@ extern void *memset(void *dst, int c, size_t len); #if defined(_MSC_VER) && !defined(__clang__) #pragma function(memset) #endif -/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */ +// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) void *memset(void *dst, int c, size_t len) { return SDL_memset(dst, c, len); } -#endif /* !HAVE_LIBC */ +#endif // !HAVE_LIBC diff --git a/src/stdlib/SDL_mslibc.c b/src/stdlib/SDL_mslibc.c index 43fec09742..98e3a38ff2 100644 --- a/src/stdlib/SDL_mslibc.c +++ b/src/stdlib/SDL_mslibc.c @@ -20,11 +20,11 @@ */ #include "SDL_internal.h" -/* This file contains SDL replacements for functions in the C library */ +// This file contains SDL replacements for functions in the C library #if !defined(HAVE_LIBC) && !defined(SDL_STATIC_LIB) -/* These are some C runtime intrinsics that need to be defined */ +// These are some C runtime intrinsics that need to be defined #ifdef _MSC_VER @@ -35,7 +35,7 @@ __declspec(selectany) int _fltused = 1; #ifdef _M_IX86 -/* Float to long */ +// Float to long void __declspec(naked) _ftol() { /* *INDENT-OFF* */ @@ -95,7 +95,7 @@ void _ftol2() _ftol(); } -/* 64-bit math operators for 32-bit systems */ +// 64-bit math operators for 32-bit systems void __declspec(naked) _allmul() { /* *INDENT-OFF* */ @@ -726,7 +726,7 @@ void __declspec(naked) _alloca_probe_16(void) /* *INDENT-ON* */ } -#endif /* _M_IX86 */ +#endif // _M_IX86 #ifdef _M_ARM64 @@ -736,7 +736,7 @@ void __chkstk() { #endif -#endif /* MSC_VER */ +#endif // MSC_VER #ifdef __ICL /* The classic Intel compiler generates calls to _intel_fast_memcpy @@ -751,4 +751,4 @@ void *_intel_fast_memset(void *dst, int c, size_t len) } #endif -#endif /* !HAVE_LIBC && !SDL_STATIC_LIB */ +#endif // !HAVE_LIBC && !SDL_STATIC_LIB diff --git a/src/stdlib/SDL_random.c b/src/stdlib/SDL_random.c index 9295d593ac..6b7ed737ef 100644 --- a/src/stdlib/SDL_random.c +++ b/src/stdlib/SDL_random.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This file contains portable random functions for SDL */ +// This file contains portable random functions for SDL static Uint64 SDL_rand_state; static SDL_bool SDL_rand_initialized = SDL_FALSE; diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 5ae573e305..c92bf26752 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This file contains portable stdlib functions for SDL */ +// This file contains portable stdlib functions for SDL #include "../libm/math_libm.h" @@ -122,7 +122,7 @@ double SDL_ceil(double x) integer += 1.0; } return integer; -#endif /* HAVE_CEIL */ +#endif // HAVE_CEIL } float SDL_ceilf(float x) @@ -141,14 +141,14 @@ double SDL_copysign(double x, double y) #elif defined(HAVE__COPYSIGN) return _copysign(x, y); #elif defined(__WATCOMC__) && defined(__386__) - /* this is nasty as hell, but it works.. */ + // this is nasty as hell, but it works.. unsigned int *xi = (unsigned int *)&x, *yi = (unsigned int *)&y; xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff); return x; #else return SDL_uclibc_copysign(x, y); -#endif /* HAVE_COPYSIGN */ +#endif // HAVE_COPYSIGN } float SDL_copysignf(float x, float y) @@ -544,13 +544,13 @@ void *SDL_aligned_alloc(size_t alignment, size_t size) SDL_size_add_overflow(size, padding, &size) == 0) { void *original = SDL_malloc(size); if (original) { - /* Make sure we have enough space to store the original pointer */ + // Make sure we have enough space to store the original pointer retval = (Uint8 *)original + sizeof(original); - /* Align the pointer we're going to return */ + // Align the pointer we're going to return retval += alignment - (((size_t)retval) % alignment); - /* Store the original pointer right before the returned value */ + // Store the original pointer right before the returned value SDL_memcpy(retval - sizeof(original), &original, sizeof(original)); } } diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index b477979a5d..43dd7696ba 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This file contains portable string manipulation functions for SDL */ +// This file contains portable string manipulation functions for SDL #include "SDL_vacopy.h" @@ -628,7 +628,7 @@ int SDL_memcmp(const void *s1, const void *s2, size_t len) ++s2p; } return 0; -#endif /* HAVE_MEMCMP */ +#endif // HAVE_MEMCMP } size_t SDL_strlen(const char *string) @@ -641,7 +641,7 @@ size_t SDL_strlen(const char *string) ++len; } return len; -#endif /* HAVE_STRLEN */ +#endif // HAVE_STRLEN } size_t SDL_strnlen(const char *string, size_t maxlen) @@ -654,7 +654,7 @@ size_t SDL_strnlen(const char *string, size_t maxlen) ++len; } return len; -#endif /* HAVE_STRNLEN */ +#endif // HAVE_STRNLEN } size_t SDL_wcslen(const wchar_t *string) @@ -667,7 +667,7 @@ size_t SDL_wcslen(const wchar_t *string) ++len; } return len; -#endif /* HAVE_WCSLEN */ +#endif // HAVE_WCSLEN } size_t SDL_wcsnlen(const wchar_t *string, size_t maxlen) @@ -680,7 +680,7 @@ size_t SDL_wcsnlen(const wchar_t *string, size_t maxlen) ++len; } return len; -#endif /* HAVE_WCSNLEN */ +#endif // HAVE_WCSNLEN } size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen) @@ -695,7 +695,7 @@ size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_ dst[len] = '\0'; } return srclen; -#endif /* HAVE_WCSLCPY */ +#endif // HAVE_WCSLCPY } size_t SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen) @@ -709,7 +709,7 @@ size_t SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, siz SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen); } return dstlen + srclen; -#endif /* HAVE_WCSLCAT */ +#endif // HAVE_WCSLCAT } wchar_t *SDL_wcsdup(const wchar_t *string) @@ -744,7 +744,7 @@ wchar_t *SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle) return SDL_const_cast(wchar_t *, wcsstr(haystack, needle)); #else return SDL_wcsnstr(haystack, needle, SDL_wcslen(haystack)); -#endif /* HAVE_WCSSTR */ +#endif // HAVE_WCSSTR } int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2) @@ -760,7 +760,7 @@ int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2) ++str2; } return *str1 - *str2; -#endif /* HAVE_WCSCMP */ +#endif // HAVE_WCSCMP } int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) @@ -781,7 +781,7 @@ int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen) } return *str1 - *str2; -#endif /* HAVE_WCSNCMP */ +#endif // HAVE_WCSNCMP } int SDL_wcscasecmp(const wchar_t *wstr1, const wchar_t *wstr2) @@ -840,7 +840,7 @@ long SDL_wcstol(const wchar_t *string, wchar_t **endp, int base) *endp = (wchar_t *)string + len; } return value; -#endif /* HAVE_WCSTOL */ +#endif // HAVE_WCSTOL } size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen) @@ -855,7 +855,7 @@ size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxl dst[len] = '\0'; } return srclen; -#endif /* HAVE_STRLCPY */ +#endif // HAVE_STRLCPY } size_t SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes) @@ -918,7 +918,7 @@ size_t SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t ma SDL_strlcpy(dst + dstlen, src, maxlen - dstlen); } return dstlen + srclen; -#endif /* HAVE_STRLCAT */ +#endif // HAVE_STRLCAT } char *SDL_strdup(const char *string) @@ -952,12 +952,12 @@ char *SDL_strrev(char *string) char *b = &string[len - 1]; len /= 2; while (len--) { - const char c = *a; /* NOLINT(clang-analyzer-core.uninitialized.Assign) */ + const char c = *a; // NOLINT(clang-analyzer-core.uninitialized.Assign) *a++ = *b; *b-- = c; } return string; -#endif /* HAVE__STRREV */ +#endif // HAVE__STRREV } char *SDL_strupr(char *string) @@ -997,7 +997,7 @@ char *SDL_strchr(const char *string, int c) return (char *)string; } return NULL; -#endif /* HAVE_STRCHR */ +#endif // HAVE_STRCHR } char *SDL_strrchr(const char *string, int c) @@ -1015,7 +1015,7 @@ char *SDL_strrchr(const char *string, int c) --bufp; } return NULL; -#endif /* HAVE_STRRCHR */ +#endif // HAVE_STRRCHR } char *SDL_strnstr(const char *haystack, const char *needle, size_t maxlen) @@ -1035,7 +1035,7 @@ char *SDL_strnstr(const char *haystack, const char *needle, size_t maxlen) --maxlen; } return NULL; -#endif /* HAVE_STRSTR */ +#endif // HAVE_STRSTR } char *SDL_strstr(const char *haystack, const char *needle) @@ -1044,7 +1044,7 @@ char *SDL_strstr(const char *haystack, const char *needle) return SDL_const_cast(char *, strstr(haystack, needle)); #else return SDL_strnstr(haystack, needle, SDL_strlen(haystack)); -#endif /* HAVE_STRSTR */ +#endif // HAVE_STRSTR } char *SDL_strcasestr(const char *haystack, const char *needle) @@ -1067,7 +1067,7 @@ static const char ntoa_table[] = { 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; -#endif /* ntoa() conversion table */ +#endif // ntoa() conversion table char *SDL_itoa(int value, char *string, int radix) { @@ -1075,7 +1075,7 @@ char *SDL_itoa(int value, char *string, int radix) return itoa(value, string, radix); #else return SDL_ltoa((long)value, string, radix); -#endif /* HAVE_ITOA */ +#endif // HAVE_ITOA } char *SDL_uitoa(unsigned int value, char *string, int radix) @@ -1084,7 +1084,7 @@ char *SDL_uitoa(unsigned int value, char *string, int radix) return _uitoa(value, string, radix); #else return SDL_ultoa((unsigned long)value, string, radix); -#endif /* HAVE__UITOA */ +#endif // HAVE__UITOA } char *SDL_ltoa(long value, char *string, int radix) @@ -1102,7 +1102,7 @@ char *SDL_ltoa(long value, char *string, int radix) } return string; -#endif /* HAVE__LTOA */ +#endif // HAVE__LTOA } char *SDL_ultoa(unsigned long value, char *string, int radix) @@ -1122,11 +1122,11 @@ char *SDL_ultoa(unsigned long value, char *string, int radix) } *bufp = '\0'; - /* The numbers went into the string backwards. :) */ + // The numbers went into the string backwards. :) SDL_strrev(string); return string; -#endif /* HAVE__ULTOA */ +#endif // HAVE__ULTOA } char *SDL_lltoa(Sint64 value, char *string, int radix) @@ -1144,7 +1144,7 @@ char *SDL_lltoa(Sint64 value, char *string, int radix) } return string; -#endif /* HAVE__I64TOA */ +#endif // HAVE__I64TOA } char *SDL_ulltoa(Uint64 value, char *string, int radix) @@ -1164,11 +1164,11 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix) } *bufp = '\0'; - /* The numbers went into the string backwards. :) */ + // The numbers went into the string backwards. :) SDL_strrev(string); return string; -#endif /* HAVE__UI64TOA */ +#endif // HAVE__UI64TOA } int SDL_atoi(const char *string) @@ -1177,7 +1177,7 @@ int SDL_atoi(const char *string) return atoi(string); #else return SDL_strtol(string, NULL, 10); -#endif /* HAVE_ATOI */ +#endif // HAVE_ATOI } double SDL_atof(const char *string) @@ -1186,7 +1186,7 @@ double SDL_atof(const char *string) return atof(string); #else return SDL_strtod(string, NULL); -#endif /* HAVE_ATOF */ +#endif // HAVE_ATOF } long SDL_strtol(const char *string, char **endp, int base) @@ -1210,7 +1210,7 @@ long SDL_strtol(const char *string, char **endp, int base) *endp = (char *)string + len; } return value; -#endif /* HAVE_STRTOL */ +#endif // HAVE_STRTOL } unsigned long @@ -1235,7 +1235,7 @@ SDL_strtoul(const char *string, char **endp, int base) *endp = (char *)string + len; } return value; -#endif /* HAVE_STRTOUL */ +#endif // HAVE_STRTOUL } Sint64 SDL_strtoll(const char *string, char **endp, int base) @@ -1259,7 +1259,7 @@ Sint64 SDL_strtoll(const char *string, char **endp, int base) *endp = (char *)string + len; } return value; -#endif /* HAVE_STRTOLL */ +#endif // HAVE_STRTOLL } Uint64 SDL_strtoull(const char *string, char **endp, int base) @@ -1283,7 +1283,7 @@ Uint64 SDL_strtoull(const char *string, char **endp, int base) *endp = (char *)string + len; } return value; -#endif /* HAVE_STRTOULL */ +#endif // HAVE_STRTOULL } double SDL_strtod(const char *string, char **endp) @@ -1299,7 +1299,7 @@ double SDL_strtod(const char *string, char **endp) *endp = (char *)string + len; } return value; -#endif /* HAVE_STRTOD */ +#endif // HAVE_STRTOD } int SDL_strcmp(const char *str1, const char *str2) @@ -1318,7 +1318,7 @@ int SDL_strcmp(const char *str1, const char *str2) ++str2; } return result; -#endif /* HAVE_STRCMP */ +#endif // HAVE_STRCMP } int SDL_strncmp(const char *str1, const char *str2, size_t maxlen) @@ -1338,7 +1338,7 @@ int SDL_strncmp(const char *str1, const char *str2, size_t maxlen) --maxlen; } return result; -#endif /* HAVE_STRNCMP */ +#endif // HAVE_STRNCMP } int SDL_strcasecmp(const char *str1, const char *str2) @@ -1402,7 +1402,7 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len) return result; } -/* NOLINTNEXTLINE(readability-non-const-parameter) */ +// NOLINTNEXTLINE(readability-non-const-parameter) int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) { int retval = 0; @@ -1471,7 +1471,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++text; } - /* FIXME: implement more of the format specifiers */ + // FIXME: implement more of the format specifiers while (!done) { switch (*fmt) { case '*': @@ -1555,7 +1555,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li } break; case DO_LONGLONG: case DO_SIZE_T: - /* Handled above */ + // Handled above break; } ++retval; @@ -1616,7 +1616,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li } break; case DO_LONGLONG: case DO_SIZE_T: - /* Handled above */ + // Handled above break; } ++retval; @@ -1726,13 +1726,13 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++fmt; continue; } - /* Text didn't match format specifier */ + // Text didn't match format specifier break; } return retval; } -#endif /* HAVE_VSSCANF */ +#endif // HAVE_VSSCANF int SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { @@ -1759,7 +1759,7 @@ int SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_ } #if defined(HAVE_LIBC) && defined(__WATCOMC__) -/* _vsnprintf() doesn't ensure nul termination */ +// _vsnprintf() doesn't ensure nul termination int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap) { int retval; @@ -1786,7 +1786,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *f #else #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, @@ -1798,7 +1798,7 @@ typedef struct { SDL_bool left_justify; 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; @@ -1876,7 +1876,7 @@ static size_t SDL_PrintStringW(char *text, size_t maxlen, SDL_FormatInfo *info, } static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info) -{ /* left-pad num with zeroes. */ +{ // left-pad num with zeroes. size_t sz, pad, have_sign; if (!info) { @@ -1892,23 +1892,23 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf sz = SDL_strlen(num); if (info->precision > 0 && sz < (size_t)info->precision) { pad = (size_t)info->precision - sz; - if (pad + sz + 1 <= maxlen) { /* otherwise ignore the precision */ + if (pad + sz + 1 <= maxlen) { // otherwise ignore the precision SDL_memmove(num + pad, num, sz + 1); 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. */ + // 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); SDL_memset(num, '0', pad); } - info->width = 0; /* so that SDL_PrintString() doesn't make a mess. */ + info->width = 0; // so that SDL_PrintString() doesn't make a mess. } } @@ -1963,7 +1963,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do size_t integer_length; int precision = info->precision; - /* This isn't especially accurate, but hey, it's easy. :) */ + // This isn't especially accurate, but hey, it's easy. :) Uint64 value; if (arg < 0) { @@ -1980,7 +1980,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do precision = 6; } if (g) { - /* The precision includes the integer portion */ + // The precision includes the integer portion precision -= SDL_min((int)integer_length, precision); } if (info->force_type || precision > 0) { @@ -2000,7 +2000,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do arg *= 10.0; integer_value = SDL_round(arg); if (integer_value == 10.0) { - /* Carry the one... */ + // Carry the one... size_t i; for (i = length; i--; ) { @@ -2029,7 +2029,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do } if (g) { - /* Trim trailing zeroes and decimal separator */ + // Trim trailing zeroes and decimal separator size_t i; for (i = length - 1; num[i] != decimal_separator; --i) { @@ -2077,7 +2077,7 @@ static size_t SDL_PrintPointer(char *text, size_t maxlen, SDL_FormatInfo *info, return length + SDL_PrintString(TEXT_AND_LEN_ARGS, info, num); } -/* NOLINTNEXTLINE(readability-non-const-parameter) */ +// NOLINTNEXTLINE(readability-non-const-parameter) int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) { size_t length = 0; @@ -2159,7 +2159,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO done = SDL_TRUE; break; case 'c': - /* char is promoted to int when passed through (...) */ + // char is promoted to int when passed through (...) if (length < maxlen) { text[length] = (char)va_arg(ap, int); } @@ -2167,7 +2167,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO done = SDL_TRUE; break; case 'h': - /* short is promoted to int when passed through (...) */ + // short is promoted to int when passed through (...) break; case 'l': if (inttype < DO_LONGLONG) { @@ -2300,7 +2300,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO } #undef TEXT_AND_LEN_ARGS -#endif /* HAVE_VSNPRINTF */ +#endif // HAVE_VSNPRINTF int SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap) { @@ -2315,7 +2315,7 @@ int SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wcha } if (!maxlen) { - /* We still need to generate the text to find the final text length */ + // We still need to generate the text to find the final text length maxlen = 1024; } text_utf8 = (char *)SDL_malloc(maxlen * 4); @@ -2360,7 +2360,7 @@ int SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING 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; @@ -2372,25 +2372,25 @@ int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list } while (1) { - /* Try to print in the allocated space */ + // Try to print in the allocated space va_copy(aq, ap); retval = SDL_vsnprintf(p, size, fmt, aq); va_end(aq); - /* Check error code */ + // Check error code if (retval < 0) { SDL_free(p); return retval; } - /* If that worked, return the string */ + // If that worked, return the string if (retval < size) { *strp = p; return retval; } - /* Else try again with more space */ - size = retval + 1; /* Precisely what is needed */ + // Else try again with more space + size = retval + 1; // Precisely what is needed np = (char *)SDL_realloc(p, size); if (!np) { diff --git a/src/stdlib/SDL_vacopy.h b/src/stdlib/SDL_vacopy.h index e2c9902227..c50c17f0f1 100644 --- a/src/stdlib/SDL_vacopy.h +++ b/src/stdlib/SDL_vacopy.h @@ -19,13 +19,13 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* Do our best to make sure va_copy is working */ +// Do our best to make sure va_copy is working #ifdef SDL_PLATFORM_NGAGE #undef va_copy #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 */ +// 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 diff --git a/src/storage/SDL_storage.c b/src/storage/SDL_storage.c index bc31f0c4f5..c3b0ecfc6b 100644 --- a/src/storage/SDL_storage.c +++ b/src/storage/SDL_storage.c @@ -24,13 +24,13 @@ #include "SDL_sysstorage.h" #include "../filesystem/SDL_sysfilesystem.h" -/* Available title storage drivers */ +// Available title storage drivers static TitleStorageBootStrap *titlebootstrap[] = { &GENERIC_titlebootstrap, NULL }; -/* Available user storage drivers */ +// Available user storage drivers static UserStorageBootStrap *userbootstrap[] = { #ifdef SDL_STORAGE_STEAM &STEAM_userbootstrap, @@ -61,7 +61,7 @@ SDL_Storage *SDL_OpenTitleStorage(const char *override, SDL_PropertiesID props) SDL_Storage *storage = NULL; int i = 0; - /* Select the proper storage driver */ + // Select the proper storage driver const char *driver_name = SDL_GetHint(SDL_HINT_STORAGE_TITLE_DRIVER); if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; @@ -103,7 +103,7 @@ SDL_Storage *SDL_OpenUserStorage(const char *org, const char *app, SDL_Propertie SDL_Storage *storage = NULL; int i = 0; - /* Select the proper storage driver */ + // Select the proper storage driver const char *driver_name = SDL_GetHint(SDL_HINT_STORAGE_USER_DRIVER); if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; diff --git a/src/storage/SDL_sysstorage.h b/src/storage/SDL_sysstorage.h index 363e2f0b6d..460a7b596d 100644 --- a/src/storage/SDL_sysstorage.h +++ b/src/storage/SDL_sysstorage.h @@ -38,14 +38,14 @@ typedef struct UserStorageBootStrap SDL_Storage *(*create)(const char*, const char*, SDL_PropertiesID); } UserStorageBootStrap; -/* Not all of these are available in a given build. Use #ifdefs, etc. */ +// Not all of these are available in a given build. Use #ifdefs, etc. extern TitleStorageBootStrap GENERIC_titlebootstrap; -/* Steam does not have title storage APIs */ +// Steam does not have title storage APIs extern UserStorageBootStrap GENERIC_userbootstrap; extern UserStorageBootStrap STEAM_userbootstrap; extern SDL_Storage *GENERIC_OpenFileStorage(const char *path); -#endif /* SDL_sysstorage_h_ */ +#endif // SDL_sysstorage_h_ diff --git a/src/storage/generic/SDL_genericstorage.c b/src/storage/generic/SDL_genericstorage.c index ad43ddc348..e15efce658 100644 --- a/src/storage/generic/SDL_genericstorage.c +++ b/src/storage/generic/SDL_genericstorage.c @@ -82,7 +82,7 @@ static int GENERIC_ReadStorageFile(void *userdata, const char *path, void *desti if (fullpath) { SDL_IOStream *stream = SDL_IOFromFile(fullpath, "rb"); if (stream) { - /* FIXME: Should SDL_ReadIO use u64 now...? */ + // FIXME: Should SDL_ReadIO use u64 now...? if (SDL_ReadIO(stream, destination, (size_t)length) == length) { result = 0; } @@ -95,7 +95,7 @@ static int GENERIC_ReadStorageFile(void *userdata, const char *path, void *desti static int GENERIC_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length) { - /* TODO: Recursively create subdirectories with SDL_CreateDirectory */ + // TODO: Recursively create subdirectories with SDL_CreateDirectory int result = -1; if (length > SDL_SIZE_MAX) { @@ -107,7 +107,7 @@ static int GENERIC_WriteStorageFile(void *userdata, const char *path, const void SDL_IOStream *stream = SDL_IOFromFile(fullpath, "wb"); if (stream) { - /* FIXME: Should SDL_WriteIO use u64 now...? */ + // FIXME: Should SDL_WriteIO use u64 now...? if (SDL_WriteIO(stream, source, (size_t)length) == length) { result = 0; } @@ -120,7 +120,7 @@ static int GENERIC_WriteStorageFile(void *userdata, const char *path, const void static int GENERIC_CreateStorageDirectory(void *userdata, const char *path) { - /* TODO: Recursively create subdirectories with SDL_CreateDirectory */ + // TODO: Recursively create subdirectories with SDL_CreateDirectory int result = -1; char *fullpath = GENERIC_INTERNAL_CreateFullPath((char *)userdata, path); @@ -177,22 +177,22 @@ static int GENERIC_CopyStorageFile(void *userdata, const char *oldpath, const ch static Uint64 GENERIC_GetStorageSpaceRemaining(void *userdata) { - /* TODO: There's totally a way to query a folder root's quota... */ + // TODO: There's totally a way to query a folder root's quota... return SDL_MAX_UINT64; } static const SDL_StorageInterface GENERIC_title_iface = { GENERIC_CloseStorage, - NULL, /* ready */ + NULL, // ready GENERIC_EnumerateStorageDirectory, GENERIC_GetStoragePathInfo, GENERIC_ReadStorageFile, - NULL, /* write_file */ - NULL, /* mkdir */ - NULL, /* remove */ - NULL, /* rename */ - NULL, /* copy */ - NULL /* space_remaining */ + NULL, // write_file + NULL, // mkdir + NULL, // remove + NULL, // rename + NULL, // copy + NULL // space_remaining }; static SDL_Storage *GENERIC_Title_Create(const char *override, SDL_PropertiesID props) @@ -225,7 +225,7 @@ TitleStorageBootStrap GENERIC_titlebootstrap = { static const SDL_StorageInterface GENERIC_user_iface = { GENERIC_CloseStorage, - NULL, /* ready */ + NULL, // ready GENERIC_EnumerateStorageDirectory, GENERIC_GetStoragePathInfo, GENERIC_ReadStorageFile, @@ -260,7 +260,7 @@ UserStorageBootStrap GENERIC_userbootstrap = { static const SDL_StorageInterface GENERIC_file_iface = { GENERIC_CloseStorage, - NULL, /* ready */ + NULL, // ready GENERIC_EnumerateStorageDirectory, GENERIC_GetStoragePathInfo, GENERIC_ReadStorageFile, diff --git a/src/storage/steam/SDL_steamstorage.c b/src/storage/steam/SDL_steamstorage.c index c4295145bb..a0182c28b5 100644 --- a/src/storage/steam/SDL_steamstorage.c +++ b/src/storage/steam/SDL_steamstorage.c @@ -23,7 +23,7 @@ #include "../SDL_sysstorage.h" -#include /* Needed by Steamworks */ +#include // Needed by Steamworks // !!! FIXME: Async API can use SteamRemoteStorage_ReadFileAsync // !!! FIXME: Async API can use SteamRemoteStorage_WriteFileAsync @@ -133,14 +133,14 @@ static Uint64 STEAM_GetStorageSpaceRemaining(void *userdata) static const SDL_StorageInterface STEAM_user_iface = { STEAM_CloseStorage, STEAM_StorageReady, - NULL, /* enumerate */ + NULL, // enumerate STEAM_GetStoragePathInfo, STEAM_ReadStorageFile, STEAM_WriteStorageFile, - NULL, /* mkdir */ - NULL, /* remove */ - NULL, /* rename */ - NULL, /* copy */ + NULL, // mkdir + NULL, // remove + NULL, // rename + NULL, // copy STEAM_GetStorageSpaceRemaining }; diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index 55af6e5f26..a12a9754ff 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -20,14 +20,14 @@ */ #include "SDL_internal.h" -/* These are functions that need to be implemented by a port of SDL */ +// These are functions that need to be implemented by a port of SDL #ifndef SDL_systhread_h_ #define SDL_systhread_h_ #include "SDL_thread_c.h" -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -40,10 +40,10 @@ extern int SDL_SYS_CreateThread(SDL_Thread *thread, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread); -/* This function does any necessary setup in the child thread */ +// This function does any necessary setup in the child thread extern void SDL_SYS_SetupThread(const char *name); -/* This function sets the current thread priority */ +// This function sets the current thread priority extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority); /* This function waits for the thread to finish and frees any data @@ -51,27 +51,27 @@ extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority); */ extern void SDL_SYS_WaitThread(SDL_Thread *thread); -/* Mark thread as cleaned up as soon as it exits, without joining. */ +// Mark thread as cleaned up as soon as it exits, without joining. extern void SDL_SYS_DetachThread(SDL_Thread *thread); -/* Initialize the global TLS data */ +// Initialize the global TLS data extern void SDL_SYS_InitTLSData(void); -/* Get the thread local storage for this thread */ +// Get the thread local storage for this thread extern SDL_TLSData *SDL_SYS_GetTLSData(void); -/* Set the thread local storage for this thread */ +// Set the thread local storage for this thread extern int SDL_SYS_SetTLSData(SDL_TLSData *data); -/* Quit the global TLS data */ +// Quit the global TLS data extern void SDL_SYS_QuitTLSData(void); -/* A helper function for setting up a thread with a stack size. */ +// A helper function for setting up a thread with a stack size. extern SDL_Thread *SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, size_t stacksize, void *data); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_systhread_h_ */ +#endif // SDL_systhread_h_ diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index a34280b38b..634b757d2c 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -20,13 +20,13 @@ */ #include "SDL_internal.h" -/* System independent thread management routines for SDL */ +// System independent thread management routines for SDL #include "SDL_thread_c.h" #include "SDL_systhread.h" #include "../SDL_error_c.h" -/* The storage is local to the thread, but the IDs are global for the process */ +// The storage is local to the thread, but the IDs are global for the process static SDL_AtomicInt SDL_tls_allocated; static SDL_AtomicInt SDL_tls_id; @@ -69,7 +69,7 @@ int SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destr */ SDL_InitTLSData(); - /* Get the storage index associated with the ID in a thread-safe way */ + // Get the storage index associated with the ID in a thread-safe way storage_index = SDL_AtomicGet(id) - 1; if (storage_index < 0) { int new_id = (SDL_AtomicIncRef(&SDL_tls_id) + 1); @@ -82,7 +82,7 @@ int SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destr storage_index = SDL_AtomicGet(id) - 1; } - /* Get the storage for the current thread */ + // Get the storage for the current thread storage = SDL_SYS_GetTLSData(); if (!storage || storage_index >= storage->limit) { unsigned int i, oldlimit, newlimit; @@ -116,7 +116,7 @@ void SDL_CleanupTLS(void) { SDL_TLSData *storage; - /* Cleanup the storage for the current thread */ + // Cleanup the storage for the current thread storage = SDL_SYS_GetTLSData(); if (storage) { int i; @@ -138,7 +138,7 @@ void SDL_QuitTLSData(void) if (SDL_AtomicGet(&SDL_tls_allocated) == 0) { SDL_SYS_QuitTLSData(); } else { - /* Some thread hasn't called SDL_CleanupTLS() */ + // Some thread hasn't called SDL_CleanupTLS() } } @@ -229,7 +229,7 @@ void SDL_Generic_QuitTLSData(void) { SDL_TLSEntry *entry; - /* This should have been cleaned up by the time we get here */ + // This should have been cleaned up by the time we get here SDL_assert(!SDL_generic_TLS); if (SDL_generic_TLS) { SDL_LockMutex(SDL_generic_TLS_mutex); @@ -249,7 +249,7 @@ void SDL_Generic_QuitTLSData(void) } } -/* Non-thread-safe global error variable */ +// Non-thread-safe global error variable static SDL_error *SDL_GetStaticErrBuf(void) { static SDL_error SDL_global_error; @@ -271,7 +271,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data) } #endif -/* Routine to get the thread-specific error variable */ +// Routine to get the thread-specific error variable SDL_error *SDL_GetErrBuf(SDL_bool create) { #ifdef SDL_THREADS_DISABLED @@ -303,7 +303,7 @@ SDL_error *SDL_GetErrBuf(SDL_bool create) SDL_SetTLS(&tls_errbuf, errbuf, SDL_FreeErrBuf); } return errbuf; -#endif /* SDL_THREADS_DISABLED */ +#endif // SDL_THREADS_DISABLED } void SDL_RunThread(SDL_Thread *thread) @@ -313,23 +313,23 @@ void SDL_RunThread(SDL_Thread *thread) int *statusloc = &thread->status; - /* Perform any system-dependent setup - this function may not fail */ + // Perform any system-dependent setup - this function may not fail SDL_SYS_SetupThread(thread->name); - /* Get the thread id */ + // Get the thread id thread->threadid = SDL_GetCurrentThreadID(); - /* Run the function */ + // Run the function *statusloc = userfunc(userdata); - /* Clean up thread-local storage */ + // Clean up thread-local storage SDL_CleanupTLS(); - /* Mark us as ready to be joined (or detached) */ + // Mark us as ready to be joined (or detached) if (!SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_ZOMBIE)) { - /* Clean up if something already detached us. */ + // Clean up if something already detached us. if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_DETACHED, SDL_THREAD_STATE_CLEANED)) { - SDL_free(thread->name); /* Can't free later, we've already cleaned up TLS */ + SDL_free(thread->name); // Can't free later, we've already cleaned up TLS SDL_free(thread); } } @@ -462,16 +462,16 @@ void SDL_DetachThread(SDL_Thread *thread) return; } - /* Grab dibs if the state is alive+joinable. */ + // Grab dibs if the state is alive+joinable. if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_DETACHED)) { SDL_SYS_DetachThread(thread); } else { - /* all other states are pretty final, see where we landed. */ + // 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 2f4a92daa5..8c18b94a7f 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -23,7 +23,7 @@ #ifndef SDL_thread_c_h_ #define SDL_thread_c_h_ -/* Need the definitions of SYS_ThreadHandle */ +// Need the definitions of SYS_ThreadHandle #ifdef SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h" #elif defined(SDL_THREAD_PTHREAD) @@ -56,7 +56,7 @@ typedef enum SDL_ThreadState SDL_THREAD_STATE_CLEANED, } SDL_ThreadState; -/* This is the system-independent thread info structure */ +// This is the system-independent thread info structure struct SDL_Thread { SDL_ThreadID threadid; @@ -65,17 +65,17 @@ struct SDL_Thread SDL_AtomicInt state; /* SDL_THREAD_STATE_* */ SDL_error errbuf; char *name; - size_t stacksize; /* 0 for default, >0 for user-specified stack size. */ + size_t stacksize; // 0 for default, >0 for user-specified stack size. int(SDLCALL *userfunc)(void *); void *userdata; void *data; - SDL_FunctionPointer endfunc; /* only used on some platforms. */ + SDL_FunctionPointer endfunc; // only used on some platforms. }; -/* This is the function called to run a thread */ +// 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 */ +// This is the system-independent thread local storage structure typedef struct { int limit; @@ -86,7 +86,7 @@ typedef struct } array[1]; } SDL_TLSData; -/* This is how many TLS entries we allocate at once */ +// This is how many TLS entries we allocate at once #define TLS_ALLOC_CHUNKSIZE 4 extern void SDL_InitTLSData(void); @@ -101,4 +101,4 @@ extern SDL_TLSData *SDL_Generic_GetTLSData(void); extern int SDL_Generic_SetTLSData(SDL_TLSData *data); extern void SDL_Generic_QuitTLSData(void); -#endif /* SDL_thread_c_h_ */ +#endif // SDL_thread_c_h_ diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index 9d73650b38..a83f28235a 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* An implementation of condition variables using semaphores and mutexes */ +// An implementation of condition variables using semaphores and mutexes /* This implementation borrows heavily from the BeOS condition variable implementation, written by Christopher Tate and Owen Smith. Thanks! @@ -49,7 +49,7 @@ typedef struct SDL_cond_generic SDL_Semaphore *wait_done; } SDL_cond_generic; -/* Create a condition variable */ +// Create a condition variable SDL_Condition *SDL_CreateCondition_generic(void) { SDL_cond_generic *cond = (SDL_cond_generic *)SDL_calloc(1, sizeof(*cond)); @@ -70,7 +70,7 @@ SDL_Condition *SDL_CreateCondition_generic(void) return (SDL_Condition *)cond; } -/* Destroy a condition variable */ +// Destroy a condition variable void SDL_DestroyCondition_generic(SDL_Condition *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; @@ -88,7 +88,7 @@ void SDL_DestroyCondition_generic(SDL_Condition *_cond) } } -/* Restart one of the threads that are waiting on the condition variable */ +// Restart one of the threads that are waiting on the condition variable int SDL_SignalCondition_generic(SDL_Condition *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; @@ -114,7 +114,7 @@ int SDL_SignalCondition_generic(SDL_Condition *_cond) return 0; } -/* Restart all threads that are waiting on the condition variable */ +// Restart all threads that are waiting on the condition variable int SDL_BroadcastCondition_generic(SDL_Condition *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; @@ -189,10 +189,10 @@ int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *_cond, SDL_Mutex *mutex, S ++cond->waiting; SDL_UnlockMutex(cond->lock); - /* Unlock the mutex, as is required by condition variable semantics */ + // Unlock the mutex, as is required by condition variable semantics SDL_UnlockMutex(mutex); - /* Wait for a signal */ + // Wait for a signal retval = SDL_WaitSemaphoreTimeoutNS(cond->wait_sem, timeoutNS); /* Let the signaler know we have completed the wait, otherwise @@ -203,20 +203,20 @@ int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *_cond, SDL_Mutex *mutex, S */ SDL_LockMutex(cond->lock); if (cond->signals > 0) { - /* If we timed out, we need to eat a condition signal */ + // If we timed out, we need to eat a condition signal if (retval > 0) { SDL_WaitSemaphore(cond->wait_sem); } - /* We always notify the signal thread that we are done */ + // We always notify the signal thread that we are done SDL_SignalSemaphore(cond->wait_done); - /* Signal handshake complete */ + // Signal handshake complete --cond->signals; } --cond->waiting; SDL_UnlockMutex(cond->lock); - /* Lock the mutex, as is required by condition variable semantics */ + // Lock the mutex, as is required by condition variable semantics SDL_LockMutex(mutex); #endif diff --git a/src/thread/generic/SDL_syscond_c.h b/src/thread/generic/SDL_syscond_c.h index 8e36078040..c4517c806a 100644 --- a/src/thread/generic/SDL_syscond_c.h +++ b/src/thread/generic/SDL_syscond_c.h @@ -31,6 +31,6 @@ int SDL_SignalCondition_generic(SDL_Condition *cond); int SDL_BroadcastCondition_generic(SDL_Condition *cond); int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS); -#endif /* SDL_THREAD_GENERIC_COND_SUFFIX */ +#endif // SDL_THREAD_GENERIC_COND_SUFFIX -#endif /* SDL_syscond_generic_h_ */ +#endif // SDL_syscond_generic_h_ diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index cb5d77bd57..f23fae69ab 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -37,7 +37,7 @@ SDL_Mutex *SDL_CreateMutex(void) #ifndef SDL_THREADS_DISABLED if (mutex) { - /* Create the mutex semaphore, with initial value 1 */ + // Create the mutex semaphore, with initial value 1 mutex->sem = SDL_CreateSemaphore(1); mutex->recursive = 0; mutex->owner = 0; @@ -78,7 +78,7 @@ void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doe mutex->recursive = 0; } } -#endif /* SDL_THREADS_DISABLED */ +#endif // SDL_THREADS_DISABLED } int SDL_TryLockMutex(SDL_Mutex *mutex) diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index d8398120ec..6e703b068c 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* An implementation of semaphores using mutexes and condition variables */ +// An implementation of semaphores using mutexes and condition variables #include "SDL_systhread_c.h" @@ -111,7 +111,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) return SDL_InvalidParamError("sem"); } - /* A timeout of 0 is an easy case */ + // A timeout of 0 is an easy case if (timeoutNS == 0) { retval = SDL_MUTEX_TIMEDOUT; SDL_LockMutex(sem->count_lock); @@ -169,4 +169,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return 0; } -#endif /* SDL_THREADS_DISABLED */ +#endif // SDL_THREADS_DISABLED diff --git a/src/thread/generic/SDL_systhread.c b/src/thread/generic/SDL_systhread.c index d622732648..2927bdf8d6 100644 --- a/src/thread/generic/SDL_systhread.c +++ b/src/thread/generic/SDL_systhread.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Thread management routines for SDL */ +// Thread management routines for SDL #include "../SDL_systhread.h" diff --git a/src/thread/generic/SDL_systhread_c.h b/src/thread/generic/SDL_systhread_c.h index 352961bee2..204177a34d 100644 --- a/src/thread/generic/SDL_systhread_c.h +++ b/src/thread/generic/SDL_systhread_c.h @@ -20,5 +20,5 @@ */ #include "SDL_internal.h" -/* Stub until we implement threads on this platform */ +// Stub until we implement threads on this platform typedef int SYS_ThreadHandle; diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c index ff82627fb2..39625ca58d 100644 --- a/src/thread/n3ds/SDL_syscond.c +++ b/src/thread/n3ds/SDL_syscond.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_N3DS -/* An implementation of condition variables using libctru's CondVar */ +// An implementation of condition variables using libctru's CondVar #include "SDL_sysmutex_c.h" @@ -31,7 +31,7 @@ struct SDL_Condition CondVar cond_variable; }; -/* Create a condition variable */ +// Create a condition variable SDL_Condition *SDL_CreateCondition(void) { SDL_Condition *cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition)); @@ -41,7 +41,7 @@ SDL_Condition *SDL_CreateCondition(void) return cond; } -/* Destroy a condition variable */ +// Destroy a condition variable void SDL_DestroyCondition(SDL_Condition *cond) { if (cond) { @@ -49,7 +49,7 @@ void SDL_DestroyCondition(SDL_Condition *cond) } } -/* Restart one of the threads that are waiting on the condition variable */ +// Restart one of the threads that are waiting on the condition variable int SDL_SignalCondition(SDL_Condition *cond) { if (!cond) { @@ -60,7 +60,7 @@ int SDL_SignalCondition(SDL_Condition *cond) return 0; } -/* Restart all threads that are waiting on the condition variable */ +// Restart all threads that are waiting on the condition variable int SDL_BroadcastCondition(SDL_Condition *cond) { if (!cond) { @@ -113,4 +113,4 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim return R_SUCCEEDED(res) ? 0 : SDL_MUTEX_TIMEDOUT; } -#endif /* SDL_THREAD_N3DS */ +#endif // SDL_THREAD_N3DS diff --git a/src/thread/n3ds/SDL_sysmutex_c.h b/src/thread/n3ds/SDL_sysmutex_c.h index 1b22566340..d0c29601a9 100644 --- a/src/thread/n3ds/SDL_sysmutex_c.h +++ b/src/thread/n3ds/SDL_sysmutex_c.h @@ -30,4 +30,4 @@ struct SDL_Mutex RecursiveLock lock; }; -#endif /* SDL_sysmutex_c_h */ +#endif // SDL_sysmutex_c_h diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 70c48f6f37..08994b672f 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_N3DS -/* An implementation of semaphores using libctru's LightSemaphore */ +// An implementation of semaphores using libctru's LightSemaphore #include <3ds.h> @@ -86,12 +86,12 @@ int WaitOnSemaphoreFor(SDL_Semaphore *sem, Sint64 timeout) if (LightSemaphore_TryAcquire(&sem->semaphore, 1) == 0) { return 0; } - /* 100 microseconds seems to be the sweet spot */ + // 100 microseconds seems to be the sweet spot SDL_DelayNS(SDL_US_TO_NS(100)); current_time = SDL_GetTicksNS(); } - /* If we failed, yield to avoid starvation on busy waits */ + // If we failed, yield to avoid starvation on busy waits SDL_DelayNS(1); return SDL_MUTEX_TIMEDOUT; } @@ -114,4 +114,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return 0; } -#endif /* SDL_THREAD_N3DS */ +#endif // SDL_THREAD_N3DS diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c index 68d8546cf2..cdce192886 100644 --- a/src/thread/n3ds/SDL_systhread.c +++ b/src/thread/n3ds/SDL_systhread.c @@ -22,11 +22,11 @@ #ifdef SDL_THREAD_N3DS -/* Thread management routines for SDL */ +// Thread management routines for SDL #include "../SDL_systhread.h" -/* N3DS has very limited RAM (128MB), so we set a low default thread stack size. */ +// N3DS has very limited RAM (128MB), so we set a low default thread stack size. #define N3DS_THREAD_STACK_SIZE_DEFAULT (80 * 1024) #define N3DS_THREAD_PRIORITY_LOW 0x3F /**< Minimum priority */ @@ -53,7 +53,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); - /* prefer putting audio thread on system core */ + // prefer putting audio thread on system core if (thread->name && (SDL_strncmp(thread->name, "SDLAudioP", 9) == 0) && R_SUCCEEDED(APT_SetAppCpuTimeLimit(30))) { cpu = 1; } @@ -133,4 +133,4 @@ void SDL_SYS_DetachThread(SDL_Thread *thread) threadDetach(thread->handle); } -#endif /* SDL_THREAD_N3DS */ +#endif // SDL_THREAD_N3DS diff --git a/src/thread/n3ds/SDL_systhread_c.h b/src/thread/n3ds/SDL_systhread_c.h index 195c8cff6c..38ea71e269 100644 --- a/src/thread/n3ds/SDL_systhread_c.h +++ b/src/thread/n3ds/SDL_systhread_c.h @@ -27,4 +27,4 @@ typedef Thread SYS_ThreadHandle; -#endif /* SDL_systhread_c_h_ */ +#endif // SDL_systhread_c_h_ diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp index 5bf1fd736e..df4de76a05 100644 --- a/src/thread/ngage/SDL_sysmutex.cpp +++ b/src/thread/ngage/SDL_sysmutex.cpp @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* An implementation of mutexes using the Symbian API. */ +// An implementation of mutexes using the Symbian API. #include @@ -38,7 +38,7 @@ static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *) return ((RMutex *)aPtr1)->CreateGlobal(aName); } -/* Create a mutex */ +// Create a mutex SDL_Mutex *SDL_CreateMutex(void) { RMutex rmutex; @@ -53,7 +53,7 @@ SDL_Mutex *SDL_CreateMutex(void) return mutex; } -/* Free the mutex */ +// Free the mutex void SDL_DestroyMutex(SDL_Mutex *mutex) { if (mutex) { @@ -66,8 +66,8 @@ void SDL_DestroyMutex(SDL_Mutex *mutex) } } -/* Lock the mutex */ -void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ +// Lock the mutex +void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes { if (mutex != NULL) { RMutex rmutex; @@ -76,7 +76,7 @@ void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang does } } -/* Try to lock the mutex */ +// Try to lock the mutex #if 0 int SDL_TryLockMutex(SDL_Mutex *mutex) { @@ -90,8 +90,8 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) } #endif -/* Unlock the mutex */ -void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ +// Unlock the mutex +void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes { if (mutex != NULL) { RMutex rmutex; diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index 4a2d9f4cae..f843592a71 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -20,11 +20,11 @@ */ #include "SDL_internal.h" -/* An implementation of semaphores using the Symbian API. */ +// An implementation of semaphores using the Symbian API. #include -/* !!! FIXME: Should this be SDL_MUTEX_TIMEDOUT? */ +// !!! FIXME: Should this be SDL_MUTEX_TIMEDOUT? #define SDL_MUTEX_TIMEOUT -2 struct SDL_Semaphore diff --git a/src/thread/ngage/SDL_systhread.cpp b/src/thread/ngage/SDL_systhread.cpp index de51dff9bb..5a73a34b12 100644 --- a/src/thread/ngage/SDL_systhread.cpp +++ b/src/thread/ngage/SDL_systhread.cpp @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_NGAGE -/* N-Gage thread management routines for SDL */ +// N-Gage thread management routines for SDL #include @@ -109,4 +109,4 @@ void SDL_SYS_DetachThread(SDL_Thread *thread) return; } -#endif /* SDL_THREAD_NGAGE */ +#endif // SDL_THREAD_NGAGE diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index a368f69625..fe695f19f9 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_PS2 -/* Semaphore functions for the PS2. */ +// Semaphore functions for the PS2. #include #include @@ -35,7 +35,7 @@ struct SDL_Semaphore s32 semid; }; -/* Create a semaphore */ +// Create a semaphore SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { SDL_Semaphore *sem; @@ -43,7 +43,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); if (sem) { - /* TODO: Figure out the limit on the maximum value. */ + // TODO: Figure out the limit on the maximum value. sema.init_count = initial_value; sema.max_count = 255; sema.option = 0; @@ -59,7 +59,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) return sem; } -/* Free the semaphore */ +// Free the semaphore void SDL_DestroySemaphore(SDL_Semaphore *sem) { if (sem) { @@ -104,7 +104,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) return 0; // Wait condition satisfied. } -/* Returns the current count of the semaphore */ +// Returns the current count of the semaphore Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { ee_sema_t info; @@ -137,4 +137,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return 0; } -#endif /* SDL_THREAD_PS2 */ +#endif // SDL_THREAD_PS2 diff --git a/src/thread/ps2/SDL_systhread.c b/src/thread/ps2/SDL_systhread.c index c52ecbdbdf..469f669ee0 100644 --- a/src/thread/ps2/SDL_systhread.c +++ b/src/thread/ps2/SDL_systhread.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_PS2 -/* PS2 thread management routines for SDL */ +// PS2 thread management routines for SDL #include #include @@ -64,7 +64,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, size_t stack_size; int priority = 32; - /* Set priority of new thread to the same as the current thread */ + // Set priority of new thread to the same as the current thread // status.size = sizeof(ee_thread_t); if (ReferThreadStatus(GetThreadId(), &status) == 0) { priority = status.current_priority; @@ -72,7 +72,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, stack_size = thread->stacksize ? ((int)thread->stacksize) : 0x1800; - /* Create EE Thread */ + // Create EE Thread eethread.attr = 0; eethread.option = 0; eethread.func = &childThread; @@ -97,7 +97,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void SDL_SYS_SetupThread(const char *name) { - /* Do nothing. */ + // Do nothing. } SDL_ThreadID SDL_GetCurrentThreadID(void) @@ -114,7 +114,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) void SDL_SYS_DetachThread(SDL_Thread *thread) { - /* Do nothing. */ + // Do nothing. } int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) @@ -134,4 +134,4 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return ChangeThreadPriority(GetThreadId(), value); } -#endif /* SDL_THREAD_PS2 */ +#endif // SDL_THREAD_PS2 diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index d4fcf6617b..ce094e6639 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_PSP -/* Semaphore functions for the PSP. */ +// Semaphore functions for the PSP. #include #include @@ -35,14 +35,14 @@ struct SDL_Semaphore SceUID semid; }; -/* Create a semaphore */ +// Create a semaphore SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { SDL_Semaphore *sem; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); if (sem) { - /* TODO: Figure out the limit on the maximum value. */ + // TODO: Figure out the limit on the maximum value. sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { SDL_SetError("Couldn't create semaphore"); @@ -54,7 +54,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) return sem; } -/* Free the semaphore */ +// Free the semaphore void SDL_DestroySemaphore(SDL_Semaphore *sem) { if (sem) { @@ -92,7 +92,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) if (timeoutNS < 0) { pTimeout = NULL; } else { - timeoutUS = (SceUInt)SDL_NS_TO_US(timeoutNS); /* Convert to microseconds. */ + timeoutUS = (SceUInt)SDL_NS_TO_US(timeoutNS); // Convert to microseconds. pTimeout = &timeoutUS; } @@ -107,7 +107,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) } } -/* Returns the current count of the semaphore */ +// Returns the current count of the semaphore Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { SceKernelSemaInfo info; @@ -140,4 +140,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return 0; } -#endif /* SDL_THREAD_PSP */ +#endif // SDL_THREAD_PSP diff --git a/src/thread/psp/SDL_systhread.c b/src/thread/psp/SDL_systhread.c index df60cc16a3..8e7d8e3791 100644 --- a/src/thread/psp/SDL_systhread.c +++ b/src/thread/psp/SDL_systhread.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_PSP -/* PSP thread management routines for SDL */ +// PSP thread management routines for SDL #include #include @@ -45,7 +45,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, SceKernelThreadInfo status; int priority = 32; - /* Set priority of new thread to the same as the current thread */ + // Set priority of new thread to the same as the current thread status.size = sizeof(SceKernelThreadInfo); if (sceKernelReferThreadStatus(sceKernelGetThreadId(), &status) == 0) { priority = status.currentPriority; @@ -64,7 +64,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void SDL_SYS_SetupThread(const char *name) { - /* Do nothing. */ + // Do nothing. } SDL_ThreadID SDL_GetCurrentThreadID(void) @@ -80,7 +80,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) void SDL_SYS_DetachThread(SDL_Thread *thread) { - /* !!! FIXME: is this correct? */ + // !!! FIXME: is this correct? sceKernelDeleteThread(thread->handle); } @@ -106,4 +106,4 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return sceKernelChangeThreadPriority(sceKernelGetThreadId(), value); } -#endif /* SDL_THREAD_PSP */ +#endif // SDL_THREAD_PSP diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index fbfca4ac77..2e804b4aa4 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -33,7 +33,7 @@ struct SDL_Condition pthread_cond_t cond; }; -/* Create a condition variable */ +// Create a condition variable SDL_Condition *SDL_CreateCondition(void) { SDL_Condition *cond; @@ -49,7 +49,7 @@ SDL_Condition *SDL_CreateCondition(void) return cond; } -/* Destroy a condition variable */ +// Destroy a condition variable void SDL_DestroyCondition(SDL_Condition *cond) { if (cond) { @@ -58,7 +58,7 @@ void SDL_DestroyCondition(SDL_Condition *cond) } } -/* Restart one of the threads that are waiting on the condition variable */ +// Restart one of the threads that are waiting on the condition variable int SDL_SignalCondition(SDL_Condition *cond) { int retval; @@ -74,7 +74,7 @@ int SDL_SignalCondition(SDL_Condition *cond) return retval; } -/* Restart all threads that are waiting on the condition variable */ +// Restart all threads that are waiting on the condition variable int SDL_BroadcastCondition(SDL_Condition *cond) { int retval; @@ -130,7 +130,7 @@ tryagain: switch (retval) { case EINTR: goto tryagain; - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break case ETIMEDOUT: retval = SDL_MUTEX_TIMEDOUT; break; diff --git a/src/thread/pthread/SDL_sysmutex_c.h b/src/thread/pthread/SDL_sysmutex_c.h index bbb5aa87f3..4cd703b419 100644 --- a/src/thread/pthread/SDL_sysmutex_c.h +++ b/src/thread/pthread/SDL_sysmutex_c.h @@ -37,4 +37,4 @@ struct SDL_Mutex #endif }; -#endif /* SDL_mutex_c_h_ */ +#endif // SDL_mutex_c_h_ diff --git a/src/thread/pthread/SDL_sysrwlock.c b/src/thread/pthread/SDL_sysrwlock.c index 8e486dc48f..7278a666cf 100644 --- a/src/thread/pthread/SDL_sysrwlock.c +++ b/src/thread/pthread/SDL_sysrwlock.c @@ -33,7 +33,7 @@ SDL_RWLock *SDL_CreateRWLock(void) { SDL_RWLock *rwlock; - /* Allocate the structure */ + // Allocate the structure rwlock = (SDL_RWLock *)SDL_calloc(1, sizeof(*rwlock)); if (rwlock) { if (pthread_rwlock_init(&rwlock->id, NULL) != 0) { diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index a0a3829da5..d89f3fa9ed 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -26,10 +26,10 @@ #include #include -/* Wrapper around POSIX 1003.1b semaphores */ +// Wrapper around POSIX 1003.1b semaphores #if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) -/* macOS doesn't support sem_getvalue() as of version 10.4 */ +// macOS doesn't support sem_getvalue() as of version 10.4 #include "../generic/SDL_syssem.c" #else @@ -38,7 +38,7 @@ struct SDL_Semaphore sem_t sem; }; -/* Create a semaphore, initialized with value */ +// Create a semaphore, initialized with value SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { SDL_Semaphore *sem = (SDL_Semaphore *)SDL_malloc(sizeof(SDL_Semaphore)); @@ -76,7 +76,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) return SDL_InvalidParamError("sem"); } - /* Try the easy cases first */ + // Try the easy cases first if (timeoutNS == 0) { retval = SDL_MUTEX_TIMEDOUT; if (sem_trywait(&sem->sem) == 0) { @@ -103,24 +103,24 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) #ifdef HAVE_CLOCK_GETTIME clock_gettime(CLOCK_REALTIME, &ts_timeout); - /* Add our timeout to current time */ + // Add our timeout to current time ts_timeout.tv_sec += (timeoutNS / SDL_NS_PER_SECOND); ts_timeout.tv_nsec += (timeoutNS % SDL_NS_PER_SECOND); #else gettimeofday(&now, NULL); - /* Add our timeout to current time */ + // Add our timeout to current time ts_timeout.tv_sec = now.tv_sec + (timeoutNS / SDL_NS_PER_SECOND); ts_timeout.tv_nsec = SDL_US_TO_NS(now.tv_usec) + (timeoutNS % SDL_NS_PER_SECOND); #endif - /* Wrap the second if needed */ + // Wrap the second if needed while (ts_timeout.tv_nsec >= 1000000000) { ts_timeout.tv_sec += 1; ts_timeout.tv_nsec -= 1000000000; } - /* Wait. */ + // Wait. do { retval = sem_timedwait(&sem->sem, &ts_timeout); } while (retval < 0 && errno == EINTR); @@ -141,7 +141,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) } SDL_DelayNS(100); } -#endif /* HAVE_SEM_TIMEDWAIT */ +#endif // HAVE_SEM_TIMEDWAIT return retval; } @@ -177,4 +177,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return retval; } -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 5f04c9c1af..54b1826ca8 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -36,7 +36,7 @@ #include #include "../../core/linux/SDL_dbus.h" -#endif /* SDL_PLATFORM_LINUX */ +#endif // SDL_PLATFORM_LINUX #if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) #include @@ -55,7 +55,7 @@ #include #endif -/* List of signals to mask in the subthreads */ +// List of signals to mask in the subthreads static const int sig_list[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, SIGVTALRM, SIGPROF, 0 @@ -83,7 +83,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, { pthread_attr_t type; -/* do this here before any threads exist, so there's no race condition. */ +// do this here before any threads exist, so there's no race condition. #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) if (!checked_setname) { void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np"); @@ -96,18 +96,18 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, } #endif - /* Set the thread attributes */ + // 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. */ + // Set caller-requested stack size. Otherwise: use the system default. if (thread->stacksize) { pthread_attr_setstacksize(&type, thread->stacksize); } - /* Create the thread and go! */ + // Create the thread and go! if (pthread_create(&thread->handle, &type, RunThread, thread) != 0) { return SDL_SetError("Not enough resources to create thread"); } @@ -128,7 +128,7 @@ void SDL_SYS_SetupThread(const char *name) ppthread_setname_np(name); #elif defined(SDL_PLATFORM_LINUX) if (ppthread_setname_np(pthread_self(), name) == ERANGE) { - char namebuf[16]; /* Limited to 16 char */ + char namebuf[16]; // Limited to 16 char SDL_strlcpy(namebuf, name, sizeof(namebuf)); ppthread_setname_np(pthread_self(), namebuf); } @@ -139,7 +139,7 @@ void SDL_SYS_SetupThread(const char *name) pthread_setname_np(pthread_self(), "%s", name); #else if (pthread_setname_np(pthread_self(), name) == ERANGE) { - char namebuf[16]; /* Limited to 16 char */ + char namebuf[16]; // Limited to 16 char SDL_strlcpy(namebuf, name, sizeof(namebuf)); pthread_setname_np(pthread_self(), namebuf); } @@ -147,14 +147,14 @@ void SDL_SYS_SetupThread(const char *name) #elif defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); #elif defined(SDL_PLATFORM_HAIKU) - /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ + // 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 } - /* Mask asynchronous signals for this thread */ + // Mask asynchronous signals for this thread sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { sigaddset(&mask, sig_list[i]); @@ -162,7 +162,7 @@ void SDL_SYS_SetupThread(const char *name) pthread_sigmask(SIG_BLOCK, &mask, 0); #ifdef PTHREAD_CANCEL_ASYNCHRONOUS - /* Allow ourselves to be asynchronously cancelled */ + // Allow ourselves to be asynchronously cancelled { int oldstate; pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); @@ -178,7 +178,7 @@ SDL_ThreadID SDL_GetCurrentThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { #ifdef SDL_PLATFORM_RISCOS - /* FIXME: Setting thread priority does not seem to be supported */ + // FIXME: Setting thread priority does not seem to be supported return 0; #else struct sched_param sched; @@ -203,7 +203,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) case SDL_THREAD_PRIORITY_HIGH: case SDL_THREAD_PRIORITY_TIME_CRITICAL: #if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) - /* Apple requires SCHED_RR for high priority threads */ + // Apple requires SCHED_RR for high priority threads pri_policy = SCHED_RR; break; #else @@ -221,7 +221,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) if (policyhint) { if (SDL_strcmp(policyhint, "current") == 0) { - /* Leave current thread scheduler policy unchanged */ + // Leave current thread scheduler policy unchanged } else if (SDL_strcmp(policyhint, "other") == 0) { policy = SCHED_OTHER; } else if (SDL_strcmp(policyhint, "rr") == 0) { @@ -251,14 +251,14 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) #if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) if (min_priority == 15 && max_priority == 47) { - /* Apple has a specific set of thread priorities */ + // Apple has a specific set of thread priorities if (priority == SDL_THREAD_PRIORITY_HIGH) { sched.sched_priority = 45; } else { sched.sched_priority = 37; } } else -#endif /* SDL_PLATFORM_MACOS || SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_MACOS || SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS { sched.sched_priority = (min_priority + (max_priority - min_priority) / 2); if (priority == SDL_THREAD_PRIORITY_HIGH) { @@ -270,8 +270,8 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return SDL_SetError("pthread_setschedparam() failed"); } return 0; -#endif /* linux */ -#endif /* #if SDL_PLATFORM_RISCOS */ +#endif // linux +#endif // #if SDL_PLATFORM_RISCOS } void SDL_SYS_WaitThread(SDL_Thread *thread) diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp index 02c1ddd29d..c182ea60c4 100644 --- a/src/thread/stdcpp/SDL_syscond.cpp +++ b/src/thread/stdcpp/SDL_syscond.cpp @@ -35,11 +35,11 @@ struct SDL_Condition std::condition_variable_any cpp_cond; }; -/* Create a condition variable */ +// Create a condition variable extern "C" SDL_Condition * SDL_CreateCondition(void) { - /* Allocate and initialize the condition variable */ + // Allocate and initialize the condition variable try { SDL_Condition *cond = new SDL_Condition; return cond; @@ -52,7 +52,7 @@ SDL_CreateCondition(void) } } -/* Destroy a condition variable */ +// Destroy a condition variable extern "C" void SDL_DestroyCondition(SDL_Condition *cond) { @@ -61,7 +61,7 @@ SDL_DestroyCondition(SDL_Condition *cond) } } -/* Restart one of the threads that are waiting on the condition variable */ +// Restart one of the threads that are waiting on the condition variable extern "C" int SDL_SignalCondition(SDL_Condition *cond) { @@ -73,7 +73,7 @@ SDL_SignalCondition(SDL_Condition *cond) return 0; } -/* Restart all threads that are waiting on the condition variable */ +// Restart all threads that are waiting on the condition variable extern "C" int SDL_BroadcastCondition(SDL_Condition *cond) { diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index 98af40e19d..025957e030 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -67,7 +67,7 @@ extern "C" int SDL_TryLockMutex(SDL_Mutex *mutex) return ((!mutex) || mutex->cpp_mutex.try_lock()) ? 0 : SDL_MUTEX_TIMEDOUT; } -/* Unlock the mutex */ +// Unlock the mutex extern "C" void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes { if (mutex != NULL) { diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 0d195f90b6..b71b52f156 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* Thread management routines for SDL */ +// Thread management routines for SDL extern "C" { #include "../SDL_thread_c.h" @@ -58,7 +58,7 @@ SDL_SYS_CreateThread(SDL_Thread *thread, extern "C" void SDL_SYS_SetupThread(const char *name) { - /* Do nothing. */ + // Do nothing. } extern "C" SDL_ThreadID diff --git a/src/thread/stdcpp/SDL_systhread_c.h b/src/thread/stdcpp/SDL_systhread_c.h index 49aa4e85f8..b8bf7b78a2 100644 --- a/src/thread/stdcpp/SDL_systhread_c.h +++ b/src/thread/stdcpp/SDL_systhread_c.h @@ -20,5 +20,5 @@ */ #include "SDL_internal.h" -/* For a thread handle, use a void pointer to a std::thread */ +// For a thread handle, use a void pointer to a std::thread typedef void *SYS_ThreadHandle; diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c index d37b9b33c0..fceeaaa460 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_VITA -/* Semaphore functions for the VITA. */ +// Semaphore functions for the VITA. #include #include @@ -36,14 +36,14 @@ struct SDL_Semaphore SceUID semid; }; -/* Create a semaphore */ +// Create a semaphore SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { SDL_Semaphore *sem; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); if (sem) { - /* TODO: Figure out the limit on the maximum value. */ + // TODO: Figure out the limit on the maximum value. sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { SDL_SetError("Couldn't create semaphore"); @@ -55,7 +55,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) return sem; } -/* Free the semaphore */ +// Free the semaphore void SDL_DestroySemaphore(SDL_Semaphore *sem) { if (sem) { @@ -93,7 +93,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) if (timeoutNS < 0) { pTimeout = NULL; } else { - timeoutUS = (SceUInt)SDL_NS_TO_US(timeoutNS); /* Convert to microseconds. */ + timeoutUS = (SceUInt)SDL_NS_TO_US(timeoutNS); // Convert to microseconds. pTimeout = &timeoutUS; } @@ -108,7 +108,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) } } -/* Returns the current count of the semaphore */ +// Returns the current count of the semaphore Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { SceKernelSemaInfo info; @@ -142,4 +142,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return 0; } -#endif /* SDL_THREAD_VITA */ +#endif // SDL_THREAD_VITA diff --git a/src/thread/vita/SDL_systhread.c b/src/thread/vita/SDL_systhread.c index 9230641d27..919863098b 100644 --- a/src/thread/vita/SDL_systhread.c +++ b/src/thread/vita/SDL_systhread.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_VITA -/* VITA thread management routines for SDL */ +// VITA thread management routines for SDL #include #include @@ -71,7 +71,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, stack_size = thread->stacksize; } - /* Create new thread with the same priority as the current thread */ + // Create new thread with the same priority as the current thread thread->handle = sceKernelCreateThread( thread_name, // name ThreadEntry, // function to run @@ -92,7 +92,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void SDL_SYS_SetupThread(const char *name) { - /* Do nothing. */ + // Do nothing. } SDL_ThreadID SDL_GetCurrentThreadID(void) @@ -108,7 +108,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) void SDL_SYS_DetachThread(SDL_Thread *thread) { - /* Do nothing. */ + // Do nothing. } int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) @@ -133,4 +133,4 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return sceKernelChangeThreadPriority(0, value); } -#endif /* SDL_THREAD_VITA */ +#endif // SDL_THREAD_VITA diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index 338e86c585..9beca1abb5 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -38,7 +38,7 @@ typedef struct SDL_cond_impl_t pfnSDL_WaitConditionTimeoutNS WaitTimeoutNS; } SDL_cond_impl_t; -/* Implementation will be chosen at runtime based on available Kernel features */ +// Implementation will be chosen at runtime based on available Kernel features static SDL_cond_impl_t SDL_cond_impl_active = { 0 }; /** @@ -80,13 +80,13 @@ typedef struct SDL_cond_cv static SDL_Condition *SDL_CreateCondition_cv(void) { - /* Relies on CONDITION_VARIABLE_INIT == 0. */ + // Relies on CONDITION_VARIABLE_INIT == 0. return (SDL_Condition *)SDL_calloc(1, sizeof(SDL_cond_cv)); } static void SDL_DestroyCondition_cv(SDL_Condition *cond) { - /* There are no kernel allocated resources */ + // There are no kernel allocated resources SDL_free(cond); } @@ -140,7 +140,7 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex return SDL_SetError("Passed mutex is not locked or locked recursively"); } - /* The mutex must be updated to the released state */ + // The mutex must be updated to the released state mutex->count = 0; mutex->owner = 0; @@ -154,7 +154,7 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex ret = 0; } - /* The mutex is owned by us again, regardless of status of the wait */ + // The mutex is owned by us again, regardless of status of the wait SDL_assert(mutex->count == 0 && mutex->owner == 0); mutex->count = 1; mutex->owner = GetCurrentThreadId(); @@ -187,7 +187,7 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = { #ifndef SDL_PLATFORM_WINRT -/* Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore */ +// Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore static const SDL_cond_impl_t SDL_cond_impl_generic = { &SDL_CreateCondition_generic, &SDL_DestroyCondition_generic, @@ -203,7 +203,7 @@ SDL_Condition *SDL_CreateCondition(void) const SDL_cond_impl_t *impl = NULL; if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) { - /* The mutex implementation isn't decided yet, trigger it */ + // The mutex implementation isn't decided yet, trigger it SDL_Mutex *mutex = SDL_CreateMutex(); if (!mutex) { return NULL; @@ -214,10 +214,10 @@ SDL_Condition *SDL_CreateCondition(void) } #ifdef SDL_PLATFORM_WINRT - /* Link statically on this platform */ + // Link statically on this platform impl = &SDL_cond_impl_cv; #else - /* Default to generic implementation, works with all mutex implementations */ + // Default to generic implementation, works with all mutex implementations impl = &SDL_cond_impl_generic; { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); @@ -227,7 +227,7 @@ SDL_Condition *SDL_CreateCondition(void) pSleepConditionVariableSRW = (pfnSleepConditionVariableSRW)GetProcAddress(kernel32, "SleepConditionVariableSRW"); pSleepConditionVariableCS = (pfnSleepConditionVariableCS)GetProcAddress(kernel32, "SleepConditionVariableCS"); if (pWakeConditionVariable && pWakeAllConditionVariable && pSleepConditionVariableSRW && pSleepConditionVariableCS) { - /* Use the Windows provided API */ + // Use the Windows provided API impl = &SDL_cond_impl_cv; } } diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 115d38f45c..596e30d8bf 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -32,7 +32,7 @@ #include "SDL_sysmutex_c.h" -/* Implementation will be chosen at runtime based on available Kernel features */ +// Implementation will be chosen at runtime based on available Kernel features SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; /** @@ -40,7 +40,7 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; */ #ifdef SDL_PLATFORM_WINRT -/* Functions are guaranteed to be available */ +// Functions are guaranteed to be available #define pInitializeSRWLock InitializeSRWLock #define pReleaseSRWLockExclusive ReleaseSRWLockExclusive #define pAcquireSRWLockExclusive AcquireSRWLockExclusive @@ -67,7 +67,7 @@ static SDL_Mutex *SDL_CreateMutex_srw(void) static void SDL_DestroyMutex_srw(SDL_Mutex *mutex) { - /* There are no kernel allocated resources */ + // There are no kernel allocated resources SDL_free(mutex); } diff --git a/src/thread/windows/SDL_sysmutex_c.h b/src/thread/windows/SDL_sysmutex_c.h index 1fe81ba081..447e2cff65 100644 --- a/src/thread/windows/SDL_sysmutex_c.h +++ b/src/thread/windows/SDL_sysmutex_c.h @@ -42,7 +42,7 @@ typedef struct SDL_mutex_impl_t pfnSDL_LockMutex Lock; pfnSDL_TryLockMutex TryLock; pfnSDL_UnlockMutex Unlock; - /* Needed by SDL_Condition: */ + // Needed by SDL_Condition: SDL_MutexType Type; } SDL_mutex_impl_t; @@ -62,7 +62,7 @@ typedef struct _SRWLOCK typedef struct SDL_mutex_srw { SRWLOCK srw; - /* SRW Locks are not recursive, that has to be handled by SDL: */ + // SRW Locks are not recursive, that has to be handled by SDL: DWORD count; DWORD owner; } SDL_mutex_srw; diff --git a/src/thread/windows/SDL_sysrwlock_srw.c b/src/thread/windows/SDL_sysrwlock_srw.c index 6eb6bd3c0e..fecbc2f733 100644 --- a/src/thread/windows/SDL_sysrwlock_srw.c +++ b/src/thread/windows/SDL_sysrwlock_srw.c @@ -24,7 +24,7 @@ * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. */ -/* This header makes sure SRWLOCK is actually declared, even on ancient WinSDKs. */ +// This header makes sure SRWLOCK is actually declared, even on ancient WinSDKs. #include "SDL_sysmutex_c.h" typedef VOID(WINAPI *pfnInitializeSRWLock)(PSRWLOCK); @@ -36,7 +36,7 @@ typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK); typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK); #ifdef SDL_PLATFORM_WINRT -/* Functions are guaranteed to be available */ +// Functions are guaranteed to be available #define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive #define pInitializeSRWLock InitializeSRWLock #define pReleaseSRWLockShared ReleaseSRWLockShared @@ -74,10 +74,10 @@ typedef struct SDL_rwlock_impl_t pfnSDL_UnlockRWLock Unlock; } SDL_rwlock_impl_t; -/* Implementation will be chosen at runtime based on available Kernel features */ +// Implementation will be chosen at runtime based on available Kernel features static SDL_rwlock_impl_t SDL_rwlock_impl_active = { 0 }; -/* rwlock implementation using Win7+ slim read/write locks (SRWLOCK) */ +// rwlock implementation using Win7+ slim read/write locks (SRWLOCK) typedef struct SDL_rwlock_srw { @@ -98,7 +98,7 @@ static void SDL_DestroyRWLock_srw(SDL_RWLock *_rwlock) { SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock; if (rwlock) { - /* There are no kernel allocated resources */ + // There are no kernel allocated resources SDL_free(rwlock); } } @@ -167,7 +167,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = { #include "../generic/SDL_sysrwlock_c.h" -/* Generic rwlock implementation using SDL_Mutex, SDL_Condition, and SDL_AtomicInt */ +// Generic rwlock implementation using SDL_Mutex, SDL_Condition, and SDL_AtomicInt static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = { &SDL_CreateRWLock_generic, &SDL_DestroyRWLock_generic, @@ -185,10 +185,10 @@ SDL_RWLock *SDL_CreateRWLock(void) const SDL_rwlock_impl_t *impl; #ifdef SDL_PLATFORM_WINRT - /* Link statically on this platform */ + // Link statically on this platform impl = &SDL_rwlock_impl_srw; #else - /* Default to generic implementation, works with all mutex implementations */ + // Default to generic implementation, works with all mutex implementations impl = &SDL_rwlock_impl_generic; { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); @@ -204,7 +204,7 @@ SDL_RWLock *SDL_CreateRWLock(void) LOOKUP_SRW_SYM(TryAcquireSRWLockExclusive); #undef LOOKUP_SRW_SYM if (okay) { - impl = &SDL_rwlock_impl_srw; /* Use the Windows provided API instead of generic fallback */ + impl = &SDL_rwlock_impl_srw; // Use the Windows provided API instead of generic fallback } } } diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index d0456a6a11..e50d7f9547 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -50,19 +50,19 @@ typedef struct SDL_semaphore_impl_t pfnSDL_SignalSemaphore Post; } SDL_sem_impl_t; -/* Implementation will be chosen at runtime based on available Kernel features */ +// Implementation will be chosen at runtime based on available Kernel features static SDL_sem_impl_t SDL_sem_impl_active = { 0 }; /** * Atomic + WaitOnAddress implementation */ -/* APIs not available on WinPhone 8.1 */ -/* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */ +// APIs not available on WinPhone 8.1 +// https://www.microsoft.com/en-us/download/details.aspx?id=47328 #if !SDL_WINAPI_FAMILY_PHONE #ifdef SDL_PLATFORM_WINRT -/* Functions are guaranteed to be available */ +// Functions are guaranteed to be available #define pWaitOnAddress WaitOnAddress #define pWakeByAddressSingle WakeByAddressSingle #else @@ -143,7 +143,7 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS for (;;) { count = sem->count; - /* If no semaphore is available we need to wait */ + // If no semaphore is available we need to wait while (count == 0) { now = SDL_GetTicksNS(); if (deadline > now) { @@ -160,8 +160,8 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS count = sem->count; } - /* Actually the semaphore is only consumed if this succeeds */ - /* If it doesn't we need to do everything again */ + // Actually the semaphore is only consumed if this succeeds + // If it doesn't we need to do everything again if (InterlockedCompareExchange(&sem->count, count - 1, count) == count) { return 0; } @@ -201,7 +201,7 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = { &SDL_GetSemaphoreValue_atom, &SDL_SignalSemaphore_atom, }; -#endif /* !SDL_WINAPI_FAMILY_PHONE */ +#endif // !SDL_WINAPI_FAMILY_PHONE /** * Fallback Semaphore implementation using Kernel Semaphores @@ -213,15 +213,15 @@ typedef struct SDL_semaphore_kern LONG count; } SDL_sem_kern; -/* Create a semaphore */ +// Create a semaphore static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) { SDL_sem_kern *sem; - /* Allocate sem memory */ + // Allocate sem memory sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); if (sem) { - /* Create the semaphore, with max value 32K */ + // Create the semaphore, with max value 32K // !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef. #ifdef SDL_PLATFORM_WINRT sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); @@ -238,7 +238,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) return (SDL_Semaphore *)sem; } -/* Free the semaphore */ +// Free the semaphore static void SDL_DestroySemaphore_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; @@ -281,7 +281,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS return retval; } -/* Returns the current count of the semaphore */ +// Returns the current count of the semaphore static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; @@ -305,7 +305,7 @@ static int SDL_SignalSemaphore_kern(SDL_Semaphore *_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; @@ -326,13 +326,13 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = { SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { if (!SDL_sem_impl_active.Create) { - /* Default to fallback implementation */ + // Default to fallback implementation 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)) { #ifdef SDL_PLATFORM_WINRT - /* Link statically on this platform */ + // Link statically on this platform impl = &SDL_sem_impl_atom; #else /* We already statically link to features from this Api @@ -343,7 +343,7 @@ SDL_Semaphore *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 */ + // Try to load required functions provided by Win 8 or newer pWaitOnAddress = (pfnWaitOnAddress)GetProcAddress(synch120, "WaitOnAddress"); pWakeByAddressSingle = (pfnWakeByAddressSingle)GetProcAddress(synch120, "WakeByAddressSingle"); @@ -355,7 +355,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) } #endif - /* Copy instead of using pointer to save one level of indirection */ + // Copy instead of using pointer to save one level of indirection SDL_copyp(&SDL_sem_impl_active, impl); } return SDL_sem_impl_active.Create(initial_value); @@ -381,4 +381,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem) return SDL_sem_impl_active.Post(sem); } -#endif /* SDL_THREAD_WINDOWS */ +#endif // SDL_THREAD_WINDOWS diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 8653fe1180..446efc7d59 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -22,7 +22,7 @@ #ifdef SDL_THREAD_WINDOWS -/* Win32 thread management routines for SDL */ +// Win32 thread management routines for SDL #include "../SDL_thread_c.h" #include "../SDL_systhread.h" @@ -66,10 +66,10 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0; - /* Save the function which we will have to call to clear the RTL of calling app! */ + // Save the function which we will have to call to clear the RTL of calling app! thread->endfunc = vpfnEndThread; - /* thread->stacksize == 0 means "system default", same as win32 expects */ + // 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, @@ -90,10 +90,10 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, #pragma pack(push, 8) typedef struct tagTHREADNAME_INFO { - 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 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 } THREADNAME_INFO; #pragma pack(pop) @@ -109,7 +109,7 @@ void SDL_SYS_SetupThread(const char *name) { if (name) { PVOID exceptionHandlerHandle; -#ifndef SDL_PLATFORM_WINRT /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ +#ifndef SDL_PLATFORM_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 = NULL; @@ -142,14 +142,14 @@ void SDL_SYS_SetupThread(const char *name) exceptionHandlerHandle = AddVectoredExceptionHandler(1, EmptyVectoredExceptionHandler); if (exceptionHandlerHandle) { THREADNAME_INFO inf; - /* This magic tells the debugger to name a thread if it's listening. */ + // This magic tells the debugger to name a thread if it's listening. SDL_zero(inf); inf.dwType = 0x1000; inf.szName = name; inf.dwThreadID = (DWORD)-1; inf.dwFlags = 0; - /* The debugger catches this, renames the thread, continues on. */ + // The debugger catches this, renames the thread, continues on. RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR *)&inf); RemoveVectoredExceptionHandler(exceptionHandlerHandle); } @@ -191,4 +191,4 @@ void SDL_SYS_DetachThread(SDL_Thread *thread) CloseHandle(thread->handle); } -#endif /* SDL_THREAD_WINDOWS */ +#endif // SDL_THREAD_WINDOWS diff --git a/src/thread/windows/SDL_systhread_c.h b/src/thread/windows/SDL_systhread_c.h index 568551d697..fcc70823f5 100644 --- a/src/thread/windows/SDL_systhread_c.h +++ b/src/thread/windows/SDL_systhread_c.h @@ -27,4 +27,4 @@ typedef HANDLE SYS_ThreadHandle; -#endif /* SDL_systhread_c_h_ */ +#endif // SDL_systhread_c_h_ diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 9c6dc239fe..0d9f815480 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -90,4 +90,4 @@ void SDL_SYS_QuitTLSData(void) } } -#endif /* SDL_THREAD_WINDOWS */ +#endif // SDL_THREAD_WINDOWS diff --git a/src/time/SDL_time.c b/src/time/SDL_time.c index 2a3244bc5d..71ba037315 100644 --- a/src/time/SDL_time.c +++ b/src/time/SDL_time.c @@ -44,9 +44,9 @@ Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, int *day_ *day_of_week = (int)(z >= -4 ? (z + 4) % 7 : (z + 5) % 7 + 6); } if (day_of_year) { - /* This algorithm considers March 1 to be the first day of the year, so offset by Jan + Feb. */ + // This algorithm considers March 1 to be the first day of the year, so offset by Jan + Feb. if (doy > 305) { - /* Day 0 is the first day of the year. */ + // Day 0 is the first day of the year. *day_of_year = doy - 306; } else { const int doy_offset = 59 + (!(year % 4) && ((year % 100) || !(year % 400))); @@ -59,7 +59,7 @@ Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, int *day_ int SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat) { - /* Default to ISO 8061 date format, as it is unambiguous, and 24 hour time. */ + // Default to ISO 8061 date format, as it is unambiguous, and 24 hour time. if (dateFormat) { *dateFormat = SDL_DATE_FORMAT_YYYYMMDD; } @@ -147,7 +147,7 @@ static SDL_bool SDL_DateTimeIsValid(const SDL_DateTime *dt) } if (dt->second < 0 || dt->second > 60) { SDL_SetError("Malformed SDL_DateTime: second out of range [0-60], current: %i", dt->second); - return SDL_FALSE; /* 60 accounts for a possible leap second. */ + return SDL_FALSE; // 60 accounts for a possible leap second. } if (dt->nanosecond < 0 || dt->nanosecond >= SDL_NS_PER_SECOND) { SDL_SetError("Malformed SDL_DateTime: nanosecond out of range [0-999999999], current: %i", dt->nanosecond); @@ -170,7 +170,7 @@ int SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks) return SDL_InvalidParamError("ticks"); } if (!SDL_DateTimeIsValid(dt)) { - /* The validation function sets the error string. */ + // The validation function sets the error string. return -1; } @@ -210,7 +210,7 @@ SDL_Time SDL_TimeFromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime) Uint64 wtime = (((Uint64)dwHighDateTime << 32) | dwLowDateTime); - /* Clamp the windows time range to the SDL_Time min/max */ + // Clamp the windows time range to the SDL_Time min/max wtime = SDL_clamp(wtime, wintime_min, wintime_max); return (SDL_Time)(wtime - DELTA_EPOCH_1601_100NS) * 100; diff --git a/src/time/SDL_time_c.h b/src/time/SDL_time_c.h index 5c92f0cd9e..3114128cc7 100644 --- a/src/time/SDL_time_c.h +++ b/src/time/SDL_time_c.h @@ -33,4 +33,4 @@ extern Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, in extern void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf); -#endif /* SDL_time_c_h_ */ +#endif // SDL_time_c_h_ diff --git a/src/time/n3ds/SDL_systime.c b/src/time/n3ds/SDL_systime.c index 2a470af5d5..06d01e3cf3 100644 --- a/src/time/n3ds/SDL_systime.c +++ b/src/time/n3ds/SDL_systime.c @@ -30,7 +30,7 @@ * no timezone or DST functionality. */ -/* 3DS epoch is Jan 1 1900 */ +// 3DS epoch is Jan 1 1900 #define DELTA_EPOCH_1900_OFFSET_MS 2208988800000LL /* Returns year/month/day triple in civil calendar @@ -58,20 +58,20 @@ static void civil_from_days(int days, int *year, int *month, int *day) void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) { - /* The 3DS only has 12 supported languages, so take the standard for each */ + // The 3DS only has 12 supported languages, so take the standard for each static const SDL_DateFormat LANG_TO_DATE_FORMAT[] = { - SDL_DATE_FORMAT_YYYYMMDD, /* JP */ - SDL_DATE_FORMAT_DDMMYYYY, /* EN, assume non-american format */ - SDL_DATE_FORMAT_DDMMYYYY, /* FR */ - SDL_DATE_FORMAT_DDMMYYYY, /* DE */ - SDL_DATE_FORMAT_DDMMYYYY, /* IT */ - SDL_DATE_FORMAT_DDMMYYYY, /* ES */ - SDL_DATE_FORMAT_YYYYMMDD, /* ZH (CN) */ - SDL_DATE_FORMAT_YYYYMMDD, /* KR */ - SDL_DATE_FORMAT_DDMMYYYY, /* NL */ - SDL_DATE_FORMAT_DDMMYYYY, /* PT */ - SDL_DATE_FORMAT_DDMMYYYY, /* RU */ - SDL_DATE_FORMAT_YYYYMMDD /* ZH (TW) */ + SDL_DATE_FORMAT_YYYYMMDD, // JP + SDL_DATE_FORMAT_DDMMYYYY, // EN, assume non-american format + SDL_DATE_FORMAT_DDMMYYYY, // FR + SDL_DATE_FORMAT_DDMMYYYY, // DE + SDL_DATE_FORMAT_DDMMYYYY, // IT + SDL_DATE_FORMAT_DDMMYYYY, // ES + SDL_DATE_FORMAT_YYYYMMDD, // ZH (CN) + SDL_DATE_FORMAT_YYYYMMDD, // KR + SDL_DATE_FORMAT_DDMMYYYY, // NL + SDL_DATE_FORMAT_DDMMYYYY, // PT + SDL_DATE_FORMAT_DDMMYYYY, // RU + SDL_DATE_FORMAT_YYYYMMDD // ZH (TW) }; u8 system_language, is_north_america; Result result, has_region; @@ -112,7 +112,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) return SDL_InvalidParamError("ticks"); } - /* Returns milliseconds since the epoch. */ + // Returns milliseconds since the epoch. const Uint64 ndsTicksMax = (SDL_MAX_TIME / SDL_NS_PER_MS) + DELTA_EPOCH_1900_OFFSET_MS; const Uint64 ndsTicks = SDL_min(osGetTime(), ndsTicksMax); @@ -137,11 +137,11 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) rem -= dt->minute * 60; dt->second = rem; dt->nanosecond = ticks % SDL_NS_PER_SECOND; - dt->utc_offset = 0; /* Unknown */ + dt->utc_offset = 0; // Unknown SDL_CivilToDays(dt->year, dt->month, dt->day, &dt->day_of_week, NULL); return 0; } -#endif /* SDL_TIME_N3DS */ +#endif // SDL_TIME_N3DS diff --git a/src/time/ps2/SDL_systime.c b/src/time/ps2/SDL_systime.c index c2d18f8822..892229c7a8 100644 --- a/src/time/ps2/SDL_systime.c +++ b/src/time/ps2/SDL_systime.c @@ -24,10 +24,10 @@ #include "../SDL_time_c.h" -/* PS2 epoch is Jan 1 2000 JST (UTC +9) */ +// PS2 epoch is Jan 1 2000 JST (UTC +9) #define UNIX_EPOCH_OFFSET_SEC 946717200 -/* TODO: Implement this... */ +// TODO: Implement this... void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) { } @@ -62,4 +62,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) return 0; } -#endif /* SDL_TIME_PS2 */ +#endif // SDL_TIME_PS2 diff --git a/src/time/psp/SDL_systime.c b/src/time/psp/SDL_systime.c index 95d4642b0d..d76138bcf1 100644 --- a/src/time/psp/SDL_systime.c +++ b/src/time/psp/SDL_systime.c @@ -28,7 +28,7 @@ #include "../SDL_time_c.h" -/* Sony seems to use 0001-01-01T00:00:00 as an epoch. */ +// Sony seems to use 0001-01-01T00:00:00 as an epoch. #define DELTA_EPOCH_0001_OFFSET 62135596800ULL void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) @@ -82,7 +82,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) const Uint64 scetime_min = (Uint64)((SDL_MIN_TIME / div) + epoch_offset); const Uint64 scetime_max = (Uint64)((SDL_MAX_TIME / div) + epoch_offset); - /* Clamp to the valid SDL_Time range. */ + // Clamp to the valid SDL_Time range. sceTicks = SDL_clamp(sceTicks, scetime_min, scetime_max); *ticks = (SDL_Time)(sceTicks - epoch_offset) * div; @@ -134,4 +134,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) return SDL_SetError("Local time conversion failed (%i)", ret); } -#endif /* SDL_TIME_PSP */ +#endif // SDL_TIME_PSP diff --git a/src/time/unix/SDL_systime.c b/src/time/unix/SDL_systime.c index 0a9353415a..09461d6403 100644 --- a/src/time/unix/SDL_systime.c +++ b/src/time/unix/SDL_systime.c @@ -43,7 +43,7 @@ void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) if (df) { const char *s = nl_langinfo(D_FMT); - /* Figure out the preferred system date format from the first format character. */ + // Figure out the preferred system date format from the first format character. if (s) { while (*s) { switch (*s++) { @@ -75,7 +75,7 @@ found_date: if (tf) { const char *s = nl_langinfo(T_FMT); - /* Figure out the preferred system date format. */ + // Figure out the preferred system date format. if (s) { while (*s) { switch (*s++) { @@ -123,7 +123,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) SDL_zero(mts); ret = clock_get_time(cclock, &mts); if (ret == 0) { - /* mach_timespec_t tv_sec is 32-bit, so no overflow possible */ + // mach_timespec_t tv_sec is 32-bit, so no overflow possible *ticks = SDL_SECONDS_TO_NS(mts.tv_sec) + mts.tv_nsec; } mach_port_deallocate(mach_task_self(), cclock); @@ -194,4 +194,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) return SDL_SetError("SDL_DateTime conversion failed (%i)", errno); } -#endif /* SDL_TIME_UNIX */ +#endif // SDL_TIME_UNIX diff --git a/src/time/vita/SDL_systime.c b/src/time/vita/SDL_systime.c index 767910f0ae..15886e1c39 100644 --- a/src/time/vita/SDL_systime.c +++ b/src/time/vita/SDL_systime.c @@ -27,7 +27,7 @@ #include #include -/* Sony seems to use 0001-01-01T00:00:00 as an epoch. */ +// Sony seems to use 0001-01-01T00:00:00 as an epoch. #define DELTA_EPOCH_0001_OFFSET 62135596800ULL void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) @@ -88,7 +88,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) const Uint64 scetime_min = (Uint64)((SDL_MIN_TIME / div) + epoch_offset); const Uint64 scetime_max = (Uint64)((SDL_MAX_TIME / div) + epoch_offset); - /* Clamp to the valid SDL_Time range. */ + // Clamp to the valid SDL_Time range. sceTicks.tick = SDL_clamp(sceTicks.tick, scetime_min, scetime_max); *ticks = (SDL_Time)(sceTicks.tick - epoch_offset) * div; @@ -139,4 +139,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) return SDL_SetError("Local time conversion failed (%i)", ret); } -#endif /* SDL_TIME_VITA */ +#endif // SDL_TIME_VITA diff --git a/src/time/windows/SDL_systime.c b/src/time/windows/SDL_systime.c index 3a960aee43..cc2c06a8bd 100644 --- a/src/time/windows/SDL_systime.c +++ b/src/time/windows/SDL_systime.c @@ -34,7 +34,7 @@ typedef void(WINAPI *pfnGetSystemTimePreciseAsFileTime)(FILETIME *); void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) { - WCHAR str[80]; /* Per the docs, the time and short date format strings can be a max of 80 characters. */ + WCHAR str[80]; // Per the docs, the time and short date format strings can be a max of 80 characters. if (df && GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, str, sizeof(str) / sizeof(WCHAR))) { LPWSTR s = str; @@ -57,7 +57,7 @@ void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf) found_date: - /* Figure out the preferred system date format. */ + // Figure out the preferred system date format. if (tf && GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, str, sizeof(str) / sizeof(WCHAR))) { LPWSTR s = str; while (*s) { @@ -91,7 +91,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL; static SDL_bool load_attempted = SDL_FALSE; - /* Only available in Win8/Server 2012 or higher. */ + // Only available in Win8/Server 2012 or higher. if (!pGetSystemTimePreciseAsFileTime && !load_attempted) { HANDLE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { @@ -130,7 +130,7 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) if (FileTimeToSystemTime(&ft, &utc_st)) { if (localTime) { if (SystemTimeToTzSpecificLocalTime(NULL, &utc_st, &local_st)) { - /* Calculate the difference for the UTC offset. */ + // Calculate the difference for the UTC offset. SystemTimeToFileTime(&local_st, &local_ft); const SDL_Time local_ticks = SDL_TimeFromWindows(local_ft.dwLowDateTime, local_ft.dwHighDateTime); dt->utc_offset = (int)SDL_NS_TO_SECONDS(local_ticks - ticks); @@ -158,4 +158,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime) return SDL_SetError("SDL_DateTime conversion failed (%lu)", GetLastError()); } -#endif /* SDL_TIME_WINDOWS */ +#endif // SDL_TIME_WINDOWS diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 20050952b9..1ce123e49f 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -23,7 +23,7 @@ #include "SDL_timer_c.h" #include "../thread/SDL_systhread.h" -/* #define DEBUG_TIMERS */ +// #define DEBUG_TIMERS #if !defined(SDL_PLATFORM_EMSCRIPTEN) || !defined(SDL_THREADS_DISABLED) @@ -46,25 +46,25 @@ typedef struct SDL_TimerMap struct SDL_TimerMap *next; } SDL_TimerMap; -/* The timers are kept in a sorted list */ +// The timers are kept in a sorted list typedef struct { - /* Data used by the main thread */ + // Data used by the main thread SDL_Thread *thread; SDL_TimerMap *timermap; SDL_Mutex *timermap_lock; - /* Padding to separate cache lines between threads */ + // Padding to separate cache lines between threads char cache_pad[SDL_CACHELINE_SIZE]; - /* Data used to communicate with the timer thread */ + // Data used to communicate with the timer thread SDL_SpinLock lock; SDL_Semaphore *sem; SDL_Timer *pending; SDL_Timer *freelist; SDL_AtomicInt active; - /* List of timers - this is only touched by the timer thread */ + // List of timers - this is only touched by the timer thread SDL_Timer *timers; } SDL_TimerData; @@ -87,7 +87,7 @@ static void SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer) } } - /* Insert the timer here! */ + // Insert the timer here! if (prev) { prev->next = timer; } else { @@ -111,14 +111,14 @@ static int SDLCALL SDL_TimerThread(void *_data) * 3. Wait until next dispatch time or new timer arrives */ for (;;) { - /* Pending and freelist maintenance */ + // Pending and freelist maintenance SDL_LockSpinlock(&data->lock); { - /* Get any timers ready to be queued */ + // Get any timers ready to be queued pending = data->pending; data->pending = NULL; - /* Make any unused timer structures available */ + // Make any unused timer structures available if (freelist_head) { freelist_tail->next = data->freelist; data->freelist = freelist_head; @@ -126,7 +126,7 @@ static int SDLCALL SDL_TimerThread(void *_data) } SDL_UnlockSpinlock(&data->lock); - /* Sort the pending timers into our list */ + // Sort the pending timers into our list while (pending) { current = pending; pending = pending->next; @@ -135,27 +135,27 @@ static int SDLCALL SDL_TimerThread(void *_data) freelist_head = NULL; freelist_tail = NULL; - /* Check to see if we're still running, after maintenance */ + // Check to see if we're still running, after maintenance if (!SDL_AtomicGet(&data->active)) { break; } - /* Initial delay if there are no timers */ + // Initial delay if there are no timers delay = (Uint64)-1; tick = SDL_GetTicksNS(); - /* Process all the pending timers for this tick */ + // Process all the pending timers for this tick while (data->timers) { current = data->timers; if (tick < current->scheduled) { - /* Scheduled for the future, wait a bit */ + // Scheduled for the future, wait a bit delay = (current->scheduled - tick); break; } - /* We're going to do something with this timer */ + // We're going to do something with this timer data->timers = current->next; if (SDL_AtomicGet(¤t->canceled)) { @@ -169,7 +169,7 @@ static int SDLCALL SDL_TimerThread(void *_data) } if (interval > 0) { - /* Reschedule this timer */ + // Reschedule this timer current->interval = interval; current->scheduled = tick + interval; SDL_AddTimerInternal(data, current); @@ -186,7 +186,7 @@ static int SDLCALL SDL_TimerThread(void *_data) } } - /* Adjust the delay based on processing time */ + // Adjust the delay based on processing time now = SDL_GetTicksNS(); interval = (now - tick); if (interval > delay) { @@ -224,7 +224,7 @@ int SDL_InitTimers(void) SDL_AtomicSet(&data->active, 1); - /* Timer threads use a callback into the app, so we can't set a limited stack size here. */ + // Timer threads use a callback into the app, so we can't set a limited stack size here. data->thread = SDL_CreateThread(SDL_TimerThread, name, data); if (!data->thread) { SDL_QuitTimers(); @@ -240,8 +240,8 @@ void SDL_QuitTimers(void) SDL_Timer *timer; SDL_TimerMap *entry; - if (SDL_AtomicCompareAndSwap(&data->active, 1, 0)) { /* active? Move to inactive. */ - /* Shutdown the timer thread */ + if (SDL_AtomicCompareAndSwap(&data->active, 1, 0)) { // active? Move to inactive. + // Shutdown the timer thread if (data->thread) { SDL_SignalSemaphore(data->sem); SDL_WaitThread(data->thread, NULL); @@ -251,7 +251,7 @@ void SDL_QuitTimers(void) SDL_DestroySemaphore(data->sem); data->sem = NULL; - /* Clean up the timer entries */ + // Clean up the timer entries while (data->timers) { timer = data->timers; data->timers = timer->next; @@ -327,13 +327,13 @@ static SDL_TimerID SDL_CreateTimer(Uint64 interval, SDL_TimerCallback callback_m data->timermap = entry; SDL_UnlockMutex(data->timermap_lock); - /* Add the timer to the pending list for the timer thread */ + // Add the timer to the pending list for the timer thread SDL_LockSpinlock(&data->lock); timer->next = data->pending; data->pending = timer; SDL_UnlockSpinlock(&data->lock); - /* Wake up the timer thread if necessary */ + // Wake up the timer thread if necessary SDL_SignalSemaphore(data->sem); return entry->timerID; @@ -359,7 +359,7 @@ int SDL_RemoveTimer(SDL_TimerID id) return SDL_InvalidParamError("id"); } - /* Find the timer */ + // Find the timer SDL_LockMutex(data->timermap_lock); prev = NULL; for (entry = data->timermap; entry; prev = entry, entry = entry->next) { @@ -492,7 +492,7 @@ int SDL_RemoveTimer(SDL_TimerID id) return SDL_InvalidParamError("id"); } - /* Find the timer */ + // Find the timer prev = NULL; for (entry = data->timermap; entry; prev = entry, entry = entry->next) { if (entry->timerID == id) { @@ -514,7 +514,7 @@ int SDL_RemoveTimer(SDL_TimerID id) } } -#endif /* !defined(SDL_PLATFORM_EMSCRIPTEN) || !SDL_THREADS_DISABLED */ +#endif // !defined(SDL_PLATFORM_EMSCRIPTEN) || !SDL_THREADS_DISABLED static Uint64 tick_start; static Uint32 tick_numerator_ns; @@ -544,14 +544,14 @@ static void SDL_SetSystemTimerResolutionMS(int period) timeBeginPeriod((UINT)timer_period); } } -#endif /* HAVE_TIME_BEGIN_PERIOD */ +#endif // HAVE_TIME_BEGIN_PERIOD } static void SDLCALL SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { int period; - /* Unless the hint says otherwise, let's have good sleep precision */ + // Unless the hint says otherwise, let's have good sleep precision if (hint && *hint) { period = SDL_atoi(hint); } else { @@ -606,7 +606,7 @@ void SDL_QuitTicks(void) SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION, SDL_TimerResolutionChanged, NULL); - SDL_SetSystemTimerResolutionMS(0); /* always release our timer resolution request. */ + SDL_SetSystemTimerResolutionMS(0); // always release our timer resolution request. tick_start = 0; } diff --git a/src/timer/SDL_timer_c.h b/src/timer/SDL_timer_c.h index 9c202a3689..6a461d448e 100644 --- a/src/timer/SDL_timer_c.h +++ b/src/timer/SDL_timer_c.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -/* Useful functions and variables from SDL_timer.c */ +// Useful functions and variables from SDL_timer.c #define ROUND_RESOLUTION(X) \ (((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION) @@ -36,4 +36,4 @@ extern void SDL_QuitTimers(void); extern void SDL_SYS_DelayNS(Uint64 ns); -#endif /* SDL_timer_c_h_ */ +#endif // SDL_timer_c_h_ diff --git a/src/timer/haiku/SDL_systimer.c b/src/timer/haiku/SDL_systimer.c index 8f844b6d30..3a3b72c581 100644 --- a/src/timer/haiku/SDL_systimer.c +++ b/src/timer/haiku/SDL_systimer.c @@ -40,4 +40,4 @@ void SDL_SYS_DelayNS(Uint64 ns) snooze((bigtime_t)SDL_NS_TO_US(ns)); } -#endif /* SDL_TIMER_HAIKU */ +#endif // SDL_TIMER_HAIKU diff --git a/src/timer/n3ds/SDL_systimer.c b/src/timer/n3ds/SDL_systimer.c index e90b99dc7c..8b7bed938c 100644 --- a/src/timer/n3ds/SDL_systimer.c +++ b/src/timer/n3ds/SDL_systimer.c @@ -40,4 +40,4 @@ void SDL_SYS_DelayNS(Uint64 ns) svcSleepThread(ns); } -#endif /* SDL_TIMER_N3DS */ +#endif // SDL_TIMER_N3DS diff --git a/src/timer/ngage/SDL_systimer.cpp b/src/timer/ngage/SDL_systimer.cpp index ce0082a40d..bfcacc630d 100644 --- a/src/timer/ngage/SDL_systimer.cpp +++ b/src/timer/ngage/SDL_systimer.cpp @@ -34,7 +34,7 @@ extern "C" { Uint64 SDL_GetPerformanceCounter(void) { - /* FIXME: Need to account for 32-bit wrapping */ + // FIXME: Need to account for 32-bit wrapping return (Uint64)User::TickCount(); } @@ -56,4 +56,4 @@ void SDL_SYS_DelayNS(Uint64 ns) } #endif -#endif /* SDL_TIMER_NGAGE */ +#endif // SDL_TIMER_NGAGE diff --git a/src/timer/ps2/SDL_systimer.c b/src/timer/ps2/SDL_systimer.c index 8d13c4f599..7bc6677af1 100644 --- a/src/timer/ps2/SDL_systimer.c +++ b/src/timer/ps2/SDL_systimer.c @@ -47,4 +47,4 @@ void SDL_SYS_DelayNS(Uint64 ns) nanosleep(&tv, NULL); } -#endif /* SDL_TIMER_PS2 */ +#endif // SDL_TIMER_PS2 diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c index 0a33f45822..2418675998 100644 --- a/src/timer/psp/SDL_systimer.c +++ b/src/timer/psp/SDL_systimer.c @@ -51,4 +51,4 @@ void SDL_SYS_DelayNS(Uint64 ns) sceKernelDelayThreadCB((SceUInt)SDL_NS_TO_US(ns)); } -#endif /* SDL_TIMER_PSP */ +#endif // SDL_TIMER_PSP diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 6f9a5c8a4f..6af7f60760 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -51,7 +51,7 @@ #include #endif -/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */ +// Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_MONOTONIC_RAW #define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW @@ -60,7 +60,7 @@ #endif #endif -/* The first ticks value of the application */ +// The first ticks value of the application #if !defined(HAVE_CLOCK_GETTIME) && defined(SDL_PLATFORM_APPLE) mach_timebase_info_data_t mach_base_info; #endif @@ -148,13 +148,13 @@ void SDL_SYS_DelayNS(Uint64 ns) #ifdef SDL_PLATFORM_EMSCRIPTEN if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { - /* pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent */ + // pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent emscripten_sleep(ns / SDL_NS_PER_MS); return; } #endif - /* Set the timeout interval */ + // Set the timeout interval #ifdef HAVE_NANOSLEEP remaining.tv_sec = (time_t)(ns / SDL_NS_PER_SECOND); remaining.tv_nsec = (long)(ns % SDL_NS_PER_SECOND); @@ -169,7 +169,7 @@ void SDL_SYS_DelayNS(Uint64 ns) tv.tv_nsec = remaining.tv_nsec; was_error = nanosleep(&tv, &remaining); #else - /* Calculate the time interval left (in case of interrupt) */ + // Calculate the time interval left (in case of interrupt) now = SDL_GetTicksNS(); elapsed = (now - then); then = now; @@ -181,8 +181,8 @@ void SDL_SYS_DelayNS(Uint64 ns) tv.tv_usec = SDL_NS_TO_US(ns % SDL_NS_PER_SECOND); was_error = select(0, NULL, NULL, NULL, &tv); -#endif /* HAVE_NANOSLEEP */ +#endif // HAVE_NANOSLEEP } while (was_error && (errno == EINTR)); } -#endif /* SDL_TIMER_UNIX */ +#endif // SDL_TIMER_UNIX diff --git a/src/timer/vita/SDL_systimer.c b/src/timer/vita/SDL_systimer.c index d9e856ef6d..826f71cef6 100644 --- a/src/timer/vita/SDL_systimer.c +++ b/src/timer/vita/SDL_systimer.c @@ -48,4 +48,4 @@ void SDL_SYS_DelayNS(Uint64 ns) sceKernelDelayThreadCB((SceUInt)SDL_NS_TO_US(ns)); } -#endif /* SDL_TIMER_VITA */ +#endif // SDL_TIMER_VITA diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 8bf46fb97f..568cf62fa8 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -45,13 +45,13 @@ HANDLE SDL_GetWaitableTimer(void) } return timer; } -#endif /* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION */ +#endif // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION Uint64 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. */ + SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later. return (Uint64)counter.QuadPart; } @@ -59,7 +59,7 @@ Uint64 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. */ + SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later. return (Uint64)frequency.QuadPart; } @@ -109,4 +109,4 @@ void SDL_SYS_DelayNS(Uint64 ns) } } -#endif /* SDL_TIMER_WINDOWS */ +#endif // SDL_TIMER_WINDOWS diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 7cfcda66c3..465148b69a 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -251,7 +251,7 @@ * care to shift before we add, not after. */ -/* helper: blend a single 16 bit pixel at 50% */ +// helper: blend a single 16 bit pixel at 50% #define BLEND16_50(dst, src, mask) \ do { \ Uint32 s = *src++; \ @@ -260,7 +260,7 @@ (s & d & (~mask & 0xffff))); \ } while (0) -/* basic 16bpp blender. mask is the pixels to keep when adding. */ +// 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); \ @@ -441,7 +441,7 @@ static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, #undef RLECLIPBLIT -/* blit a colorkeyed RLE surface */ +// blit a colorkeyed RLE surface static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, SDL_Surface *surf_dst, const SDL_Rect *dstrect) { @@ -451,21 +451,21 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, int w = surf_src->w; unsigned alpha; - /* Lock the destination if necessary */ + // Lock the destination if necessary if (SDL_MUSTLOCK(surf_dst)) { if (SDL_LockSurface(surf_dst) < 0) { return -1; } } - /* Set up the source and destination pointers */ + // 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->internal->format->bytes_per_pixel; srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat); { - /* skip lines at the top if necessary */ + // skip lines at the top if necessary int vskip = srcrect->y; int ofs = 0; if (vskip) { @@ -508,7 +508,7 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, } alpha = surf_src->internal->map.info.a; - /* if left or right edge clipping needed, call clip blit */ + // if left or right edge clipping needed, call clip blit if (srcrect->x || srcrect->w != surf_src->w) { RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha); } else { @@ -544,7 +544,7 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, } done: - /* Unlock the destination if necessary */ + // Unlock the destination if necessary if (SDL_MUSTLOCK(surf_dst)) { SDL_UnlockSurface(surf_dst); } @@ -604,7 +604,7 @@ done: dst = (Uint16)(d | d >> 16); \ } while (0) -/* blit a pixel-alpha RLE surface clipped at the right and/or left edges */ +// 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, const SDL_Rect *srcrect) { @@ -696,7 +696,7 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, } } -/* blit a pixel-alpha RLE surface */ +// blit a pixel-alpha RLE surface static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, SDL_Surface *surf_dst, const SDL_Rect *dstrect) { @@ -705,7 +705,7 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre Uint8 *srcbuf, *dstbuf; const SDL_PixelFormatDetails *df = surf_dst->internal->format; - /* Lock the destination if necessary */ + // Lock the destination if necessary if (SDL_MUSTLOCK(surf_dst)) { if (SDL_LockSurface(surf_dst) < 0) { return -1; @@ -718,14 +718,14 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat); { - /* skip lines at the top if necessary */ + // skip lines at the top if necessary int vskip = srcrect->y; if (vskip) { int ofs; if (df->bytes_per_pixel == 2) { - /* the 16/32 interleaved format */ + // the 16/32 interleaved format do { - /* skip opaque line */ + // skip opaque line ofs = 0; do { int run; @@ -740,10 +740,10 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre } } while (ofs < w); - /* skip padding */ + // skip padding srcbuf += (uintptr_t)srcbuf & 2; - /* skip translucent line */ + // skip translucent line ofs = 0; do { int run; @@ -754,8 +754,8 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre } while (ofs < w); } while (--vskip); } else { - /* the 32/32 interleaved format */ - vskip <<= 1; /* opaque and translucent have same format */ + // the 32/32 interleaved format + vskip <<= 1; // opaque and translucent have same format do { ofs = 0; do { @@ -775,7 +775,7 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre } } - /* if left or right edge clipping needed, call clip blit */ + // if left or right edge clipping needed, call clip blit if (srcrect->x || srcrect->w != surf_src->w) { RLEAlphaClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect); } else { @@ -845,7 +845,7 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre } done: - /* Unlock the destination if necessary */ + // Unlock the destination if necessary if (SDL_MUSTLOCK(surf_dst)) { SDL_UnlockSurface(surf_dst); } @@ -862,7 +862,7 @@ done: * highly optimised. */ -/* encode 32bpp rgb + a into 16bpp rgb, losing alpha */ +// encode 32bpp rgb + a into 16bpp rgb, losing alpha static int copy_opaque_16(void *dst, const Uint32 *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -878,7 +878,7 @@ static int copy_opaque_16(void *dst, const Uint32 *src, int n, return n * 2; } -/* decode opaque pixels from 16bpp to 32bpp rgb + a */ +// decode opaque pixels from 16bpp to 32bpp rgb + a static int uncopy_opaque_16(Uint32 *dst, const void *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -895,7 +895,7 @@ static int uncopy_opaque_16(Uint32 *dst, const void *src, int n, return n * 2; } -/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */ +// encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 static int copy_transl_565(void *dst, const Uint32 *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -913,7 +913,7 @@ static int copy_transl_565(void *dst, const Uint32 *src, int n, return n * 4; } -/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */ +// encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 static int copy_transl_555(void *dst, const Uint32 *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -931,7 +931,7 @@ static int copy_transl_555(void *dst, const Uint32 *src, int n, return n * 4; } -/* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */ +// decode translucent pixels from 32bpp GORAB to 32bpp rgb + a static int uncopy_transl_16(Uint32 *dst, const void *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -949,7 +949,7 @@ static int uncopy_transl_16(Uint32 *dst, const void *src, int n, return n * 4; } -/* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ +// encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) static int copy_32(void *dst, const Uint32 *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -965,7 +965,7 @@ static int copy_32(void *dst, const Uint32 *src, int n, return n * 4; } -/* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ +// decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) static int uncopy_32(Uint32 *dst, const void *src, int n, const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) { @@ -987,7 +987,7 @@ static int uncopy_32(Uint32 *dst, const void *src, int n, #define ISTRANSL(pixel, fmt) \ ((unsigned)((((pixel)&fmt->Amask) >> fmt->Ashift) - 1U) < 254U) -/* convert surface to be quickly alpha-blittable onto dest, if possible */ +// convert surface to be quickly alpha-blittable onto dest, if possible static int RLEAlphaSurface(SDL_Surface *surface) { SDL_Surface *dest; @@ -1008,7 +1008,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) } df = dest->internal->format; if (surface->internal->format->bits_per_pixel != 32) { - return -1; /* only 32bpp source supported */ + return -1; // only 32bpp source supported } /* find out whether the destination is one we support, @@ -1016,7 +1016,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) masksum = df->Rmask | df->Gmask | df->Bmask; switch (df->bytes_per_pixel) { case 2: - /* 16bpp: only support 565 and 555 formats */ + // 16bpp: only support 565 and 555 formats switch (masksum) { case 0xffff: if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { @@ -1037,7 +1037,7 @@ static int 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 */ @@ -1045,17 +1045,17 @@ static int 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 */ + // 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(SDL_PixelFormat); @@ -1063,19 +1063,19 @@ static int RLEAlphaSurface(SDL_Surface *surface) if (!rlebuf) { return -1; } - /* save the destination format so we can undo the encoding later */ + // save the destination format so we can undo the encoding later *(SDL_PixelFormat *)rlebuf = df->format; dst = rlebuf + sizeof(SDL_PixelFormat); - /* Do the actual encoding */ + // Do the actual encoding { int x, y; int h = surface->h, w = surface->w; const SDL_PixelFormatDetails *sf = surface->internal->format; Uint32 *src = (Uint32 *)surface->pixels; - Uint8 *lastline = dst; /* end of last non-blank line */ + Uint8 *lastline = dst; // end of last non-blank line - /* opaque counts are 8 or 16 bits, depending on target depth */ + // opaque counts are 8 or 16 bits, depending on target depth #define ADD_OPAQUE_COUNTS(n, m) \ if (df->bytes_per_pixel == 4) { \ ((Uint16 *)dst)[0] = (Uint16)n; \ @@ -1087,14 +1087,14 @@ static int RLEAlphaSurface(SDL_Surface *surface) dst += 2; \ } - /* translucent counts are always 16 bit */ + // translucent counts are always 16 bit #define ADD_TRANSL_COUNTS(n, m) \ (((Uint16 *)dst)[0] = (Uint16)n, ((Uint16 *)dst)[1] = (Uint16)m, dst += 4) for (y = 0; y < h; y++) { int runstart, skipstart; int blankline = 0; - /* First encode all opaque pixels of a scan line */ + // First encode all opaque pixels of a scan line x = 0; do { int run, skip, len; @@ -1129,10 +1129,10 @@ static int RLEAlphaSurface(SDL_Surface *surface) } } while (x < w); - /* Make sure the next output address is 32-bit aligned */ + // Make sure the next output address is 32-bit aligned dst += (uintptr_t)dst & 2; - /* Next, encode all translucent pixels of the same scan line */ + // Next, encode all translucent pixels of the same scan line x = 0; do { int run, skip, len; @@ -1170,14 +1170,14 @@ static int 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); } #undef ADD_OPAQUE_COUNTS #undef ADD_TRANSL_COUNTS - /* Now that we have it encoded, release the original pixels */ + // Now that we have it encoded, release the original pixels if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) { if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { SDL_aligned_free(surface->pixels); @@ -1188,7 +1188,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) surface->pixels = NULL; } - /* reallocate the buffer to release unused memory */ + // reallocate the buffer to release unused memory { Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf); if (!p) { @@ -1242,7 +1242,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) Uint32 ckey, rgbmask; int w, h; - /* calculate the worst case size for the compressed surface */ + // calculate the worst case size for the compressed surface switch (bpp) { case 1: /* worst case is alternating opaque and transparent pixels, @@ -1251,11 +1251,11 @@ static int RLEColorkeySurface(SDL_Surface *surface) break; case 2: case 3: - /* worst case is solid runs, at most 255 pixels wide */ + // worst case is solid runs, at most 255 pixels wide 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 */ + // worst case is solid runs, at most 65535 pixels wide maxsize = surface->h * (4 * (surface->w / 65535 + 1) + surface->w * 4) + 4; break; @@ -1268,7 +1268,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) return -1; } - /* Set up the conversion */ + // Set up the conversion srcbuf = (Uint8 *)surface->pixels; maxn = bpp == 4 ? 65535 : 255; dst = rlebuf; @@ -1299,7 +1299,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) int runstart; int skipstart = x; - /* find run of transparent, then opaque pixels */ + // find run of transparent, then opaque pixels while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey) { x++; } @@ -1313,7 +1313,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) } run = x - runstart; - /* encode segment */ + // encode segment while (skip > maxn) { ADD_COUNTS(maxn, 0); skip -= maxn; @@ -1339,12 +1339,12 @@ static int 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 - /* Now that we have it encoded, release the original pixels */ + // Now that we have it encoded, release the original pixels if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) { if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { SDL_aligned_free(surface->pixels); @@ -1355,9 +1355,9 @@ static int RLEColorkeySurface(SDL_Surface *surface) surface->pixels = NULL; } - /* reallocate the buffer to release unused memory */ + // reallocate the buffer to release unused memory { - /* If SDL_realloc returns NULL, the original block is left intact */ + // If SDL_realloc returns NULL, the original block is left intact Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf); if (!p) { p = rlebuf; @@ -1372,32 +1372,32 @@ int SDL_RLESurface(SDL_Surface *surface) { int flags; - /* Clear any previous RLE conversion */ + // Clear any previous RLE conversion if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { SDL_UnRLESurface(surface, SDL_TRUE); } - /* We don't support RLE encoding of bitmaps */ + // We don't support RLE encoding of bitmaps if (SDL_BITSPERPIXEL(surface->format) < 8) { return -1; } - /* Make sure the pixels are available */ + // Make sure the pixels are available if (!surface->pixels) { return -1; } flags = surface->internal->map.info.flags; if (flags & SDL_COPY_COLORKEY) { - /* ok */ + // ok } else if ((flags & SDL_COPY_BLEND) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) { - /* ok */ + // ok } else { - /* If we don't have colorkey or blending, nothing to do... */ + // If we don't have colorkey or blending, nothing to do... return -1; } - /* Pass on combinations not supported */ + // Pass on combinations not supported if ((flags & SDL_COPY_MODULATE_COLOR) || ((flags & SDL_COPY_MODULATE_ALPHA) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) || (flags & (SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) || @@ -1405,7 +1405,7 @@ int SDL_RLESurface(SDL_Surface *surface) return -1; } - /* Encode and set up the blit */ + // Encode and set up the blit if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) || !(flags & SDL_COPY_BLEND)) { if (!surface->internal->map.identity) { return -1; @@ -1423,7 +1423,7 @@ int SDL_RLESurface(SDL_Surface *surface) surface->internal->map.info.flags |= SDL_COPY_RLE_ALPHAKEY; } - /* The surface is now accelerated */ + // The surface is now accelerated surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; return 0; @@ -1465,13 +1465,13 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) return SDL_FALSE; } surface->flags |= SDL_SURFACE_SIMD_ALIGNED; - /* fill background with transparent pixels */ + // fill background with transparent pixels SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch); dst = (Uint32 *)surface->pixels; srcbuf = (Uint8 *)surface->internal->map.data + sizeof(SDL_PixelFormat); for (;;) { - /* copy opaque pixels */ + // copy opaque pixels int ofs = 0; do { unsigned run; @@ -1492,12 +1492,12 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } } while (ofs < w); - /* skip padding if needed */ + // skip padding if needed if (bpp == 2) { srcbuf += (uintptr_t)srcbuf & 2; } - /* copy translucent pixels */ + // copy translucent pixels ofs = 0; do { unsigned run; @@ -1526,31 +1526,31 @@ void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode) SDL_Rect full; size_t size; - /* re-create the original surface */ + // re-create the original surface if (SDL_size_mul_overflow(surface->h, surface->pitch, &size)) { - /* Memory corruption? */ + // Memory corruption? surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; return; } surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); if (!surface->pixels) { - /* Oh crap... */ + // Oh crap... surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; return; } surface->flags |= SDL_SURFACE_SIMD_ALIGNED; - /* fill it with the background color */ + // fill it with the background color SDL_FillSurfaceRect(surface, NULL, surface->internal->map.info.colorkey); - /* now render the encoded surface */ + // now render the encoded surface full.x = full.y = 0; full.w = surface->w; full.h = surface->h; SDL_RLEBlit(surface, &full, surface, &full); } else { if (!UnRLEAlpha(surface)) { - /* Oh crap... */ + // Oh crap... surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; return; } @@ -1564,4 +1564,4 @@ void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode) } } -#endif /* SDL_HAVE_RLE */ +#endif // SDL_HAVE_RLE diff --git a/src/video/SDL_RLEaccel_c.h b/src/video/SDL_RLEaccel_c.h index 95c54a5df2..d9cd067ce6 100644 --- a/src/video/SDL_RLEaccel_c.h +++ b/src/video/SDL_RLEaccel_c.h @@ -24,9 +24,9 @@ #include "SDL_internal.h" -/* Useful functions and variables from SDL_RLEaccel.c */ +// Useful functions and variables from SDL_RLEaccel.c extern int SDL_RLESurface(SDL_Surface *surface); extern void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode); -#endif /* SDL_RLEaccel_c_h_ */ +#endif // SDL_RLEaccel_c_h_ diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 447e96d26f..41569324dd 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -28,7 +28,7 @@ #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" -/* The general purpose software blit routine */ +// The general purpose software blit routine static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect) { @@ -36,10 +36,10 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, int src_locked; int dst_locked; - /* Everything is okay at the beginning... */ + // Everything is okay at the beginning... okay = 1; - /* Lock the destination if it's in hardware */ + // Lock the destination if it's in hardware dst_locked = 0; if (SDL_MUSTLOCK(dst)) { if (SDL_LockSurface(dst) < 0) { @@ -48,7 +48,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, dst_locked = 1; } } - /* Lock the source if it's in hardware */ + // Lock the source if it's in hardware src_locked = 0; if (SDL_MUSTLOCK(src)) { if (SDL_LockSurface(src) < 0) { @@ -58,12 +58,12 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, } } - /* Set up source and destination buffer pointers, and BLIT! */ + // Set up source and destination buffer pointers, and BLIT! if (okay && !SDL_RectEmpty(srcrect)) { SDL_BlitFunc RunBlit; SDL_BlitInfo *info = &src->internal->map.info; - /* Set up the blit information */ + // Set up the blit information info->src = (Uint8 *)src->pixels + (Uint16)srcrect->y * src->pitch + (Uint16)srcrect->x * info->src_fmt->bytes_per_pixel; @@ -82,18 +82,18 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, info->dst_pitch - info->dst_w * info->dst_fmt->bytes_per_pixel; RunBlit = (SDL_BlitFunc)src->internal->map.data; - /* Run the actual software blit */ + // Run the actual software blit RunBlit(info); } - /* We need to unlock the surfaces if they're locked */ + // We need to unlock the surfaces if they're locked if (dst_locked) { SDL_UnlockSurface(dst); } if (src_locked) { SDL_UnlockSurface(src); } - /* Blit is done! */ + // Blit is done! return okay ? 0 : -1; } @@ -117,10 +117,10 @@ static SDL_bool SDL_UseAltivecPrefetch(void) #else static SDL_bool SDL_UseAltivecPrefetch(void) { - /* Just guess G4 */ + // Just guess G4 return SDL_TRUE; } -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelFormat dst_format, int flags, SDL_BlitFuncEntry *entries) @@ -128,7 +128,7 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelForm int i, flagcheck = (flags & (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_COLORKEY | SDL_COPY_NEAREST)); static unsigned int features = 0x7fffffff; - /* Get the available CPU features */ + // Get the available CPU features if (features == 0x7fffffff) { features = SDL_CPU_ANY; if (SDL_HasMMX()) { @@ -150,7 +150,7 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelForm } for (i = 0; entries[i].func; ++i) { - /* Check for matching pixel formats */ + // Check for matching pixel formats if (src_format != entries[i].src_format) { continue; } @@ -158,24 +158,24 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelForm continue; } - /* Check flags */ + // Check flags if ((flagcheck & entries[i].flags) != flagcheck) { continue; } - /* Check CPU features */ + // Check CPU features if ((entries[i].cpu & features) != entries[i].cpu) { continue; } - /* We found the best one! */ + // We found the best one! return entries[i].func; } return NULL; } -#endif /* SDL_HAVE_BLIT_AUTO */ +#endif // SDL_HAVE_BLIT_AUTO -/* Figure out which of many blit routines to set up on a surface */ +// Figure out which of many blit routines to set up on a surface int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) { SDL_BlitFunc blit = NULL; @@ -183,14 +183,14 @@ int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) SDL_Colorspace src_colorspace = surface->internal->colorspace; SDL_Colorspace dst_colorspace = dst->internal->colorspace; - /* We don't currently support blitting to < 8 bpp surfaces */ + // We don't currently support blitting to < 8 bpp surfaces if (SDL_BITSPERPIXEL(dst->format) < 8) { SDL_InvalidateMap(map); return SDL_SetError("Blit combination not supported"); } #if SDL_HAVE_RLE - /* Clean everything out to start */ + // Clean everything out to start if (surface->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { SDL_UnRLESurface(surface, SDL_TRUE); } @@ -205,7 +205,7 @@ int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) map->info.dst_pal = dst->internal->palette; #if SDL_HAVE_RLE - /* See if we can do RLE acceleration */ + // See if we can do RLE acceleration if (map->info.flags & SDL_COPY_RLE_DESIRED) { if (SDL_RLESurface(surface) == 0) { return 0; @@ -213,7 +213,7 @@ int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) } #endif - /* Choose a standard blit function */ + // Choose a standard blit function if (!blit) { if (src_colorspace != dst_colorspace || SDL_BYTESPERPIXEL(surface->format) > 4 || @@ -280,7 +280,7 @@ int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) } map->data = (void *)blit; - /* Make sure we have a blit function */ + // Make sure we have a blit function if (!blit) { SDL_InvalidateMap(map); return SDL_SetError("Blit combination not supported"); diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h index af0b8c3a1e..7fd3f0aead 100644 --- a/src/video/SDL_blit.h +++ b/src/video/SDL_blit.h @@ -25,11 +25,11 @@ #include "../SDL_hashtable.h" -/* Table to do pixel byte expansion */ +// Table to do pixel byte expansion extern const Uint8 *SDL_expand_byte[9]; extern const Uint16 SDL_expand_byte_10[]; -/* SDL blit copy flags */ +// SDL blit copy flags #define SDL_COPY_MODULATE_COLOR 0x00000001 #define SDL_COPY_MODULATE_ALPHA 0x00000002 #define SDL_COPY_MODULATE_MASK (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA) @@ -47,7 +47,7 @@ extern const Uint16 SDL_expand_byte_10[]; #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 */ +// SDL blit CPU flags #define SDL_CPU_ANY 0x00000000 #define SDL_CPU_MMX 0x00000001 #define SDL_CPU_SSE 0x00000002 @@ -91,7 +91,7 @@ typedef struct typedef int (SDLCALL *SDL_Blit) (struct SDL_Surface *src, const SDL_Rect *srcrect, struct SDL_Surface *dst, const SDL_Rect *dstrect); -/* Blit mapping definition */ +// Blit mapping definition typedef struct SDL_BlitMap { int identity; @@ -105,7 +105,7 @@ typedef struct SDL_BlitMap Uint32 src_palette_version; } SDL_BlitMap; -/* Functions found in SDL_blit.c */ +// Functions found in SDL_blit.c extern int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst); /* Functions found in SDL_blit_*.c */ @@ -126,7 +126,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); #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 */ +// 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->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ @@ -222,7 +222,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } while (0) -/* Assemble R-G-B values into a specified pixel format and store them */ +// Assemble R-G-B values into a specified pixel format and store them #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ { \ Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \ @@ -342,7 +342,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } -/* FIXME: Should we rescale alpha into 0..255 here? */ +// FIXME: Should we rescale alpha into 0..255 here? #define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ { \ r = SDL_expand_byte[fmt->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ @@ -454,7 +454,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } while (0) -/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ +// FIXME: this isn't correct, especially for Alpha (maximum != 255) #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ { \ Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \ @@ -504,14 +504,14 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } -/* Convert any 32-bit 4-bpp pixel to ARGB format */ +// Convert any 32-bit 4-bpp pixel to ARGB format #define PIXEL_TO_ARGB_PIXEL(src, srcfmt, dst) \ do { \ Uint8 a, r, g, b; \ RGBA_FROM_PIXEL(src, srcfmt, r, g, b, a); \ dst = a << 24 | r << 16 | g << 8 | b; \ } while (0) -/* Blend a single color channel or alpha value */ +// Blend a single color channel or alpha value /* dC = ((sC * sA) + (dC * (255 - sA))) / 255 */ #define ALPHA_BLEND_CHANNEL(sC, dC, sA) \ do { \ @@ -521,7 +521,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); x += x >> 8; \ dC = x >> 8; \ } while (0) -/* Perform a division by 255 after a multiplication of two 8-bit color channels */ +// Perform a division by 255 after a multiplication of two 8-bit color channels /* out = (sC * dC) / 255 */ #define MULT_DIV_255(sC, dC, out) \ do { \ @@ -530,7 +530,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); x += x >> 8; \ out = x >> 8; \ } while (0) -/* Blend the RGB values of two pixels with an alpha value */ +// Blend the RGB values of two pixels with an alpha value #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ do { \ ALPHA_BLEND_CHANNEL(sR, dR, A); \ @@ -538,9 +538,9 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); ALPHA_BLEND_CHANNEL(sB, dB, A); \ } while (0) -/* Blend two 8888 pixels with the same format */ +// Blend two 8888 pixels with the same format /* Calculates dst = ((src * factor) + (dst * (255 - factor))) / 255 */ -/* FIXME: SDL_SIZE_MAX might not be an integer literal */ +// FIXME: SDL_SIZE_MAX might not be an integer literal #if defined(SIZE_MAX) && (SIZE_MAX == 0xffffffffffffffff) #define FACTOR_BLEND_8888(src, dst, factor) \ do { \ @@ -579,7 +579,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } while (0) #endif -/* Alpha blend two 8888 pixels with the same formats. */ +// Alpha blend two 8888 pixels with the same formats. #define ALPHA_BLEND_8888(src, dst, fmt) \ do { \ Uint32 srcA = (src >> fmt->Ashift) & 0xFF; \ @@ -587,7 +587,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); FACTOR_BLEND_8888(tmp, dst, srcA); \ } while (0) -/* Alpha blend two 8888 pixels with differing formats. */ +// Alpha blend two 8888 pixels with differing formats. #define ALPHA_BLEND_SWIZZLE_8888(src, dst, srcfmt, dstfmt) \ do { \ Uint32 srcA = (src >> srcfmt->Ashift) & 0xFF; \ @@ -597,7 +597,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); dstfmt->Amask; \ FACTOR_BLEND_8888(tmp, dst, srcA); \ } while (0) -/* Blend the RGBA values of two pixels */ +// Blend the RGBA values of two pixels #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ do { \ ALPHA_BLEND_CHANNEL(sR, dR, sA); \ @@ -606,15 +606,15 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); ALPHA_BLEND_CHANNEL(255, dA, sA); \ } while (0) -/* This is a very useful loop for optimizing blitters */ +// This is a very useful loop for optimizing blitters #if defined(_MSC_VER) && (_MSC_VER == 1300) -/* There's a bug in the Visual C++ 7 optimizer when compiling this code */ +// There's a bug in the Visual C++ 7 optimizer when compiling this code #else #define USE_DUFFS_LOOP #endif #ifdef USE_DUFFS_LOOP -/* 8-times unrolled loop */ +// 8-times unrolled loop #define DUFFS_LOOP8(pixel_copy_increment, width) \ { \ int n = (width + 7) / 8; \ @@ -647,7 +647,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } -/* 4-times unrolled loop */ +// 4-times unrolled loop #define DUFFS_LOOP4(pixel_copy_increment, width) \ { \ int n = (width + 3) / 4; \ @@ -668,11 +668,11 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); } \ } -/* Use the 8-times version of the loop by default */ +// Use the 8-times version of the loop by default #define DUFFS_LOOP(pixel_copy_increment, width) \ DUFFS_LOOP8(pixel_copy_increment, width) -/* Special version of Duff's device for even more optimization */ +// Special version of Duff's device for even more optimization #define DUFFS_LOOP_124(pixel_copy_increment1, \ pixel_copy_increment2, \ pixel_copy_increment4, width) \ @@ -701,7 +701,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); #else -/* Don't use Duff's device to unroll loops */ +// Don't use Duff's device to unroll loops #define DUFFS_LOOP(pixel_copy_increment, width) \ { \ int n; \ @@ -718,12 +718,12 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); pixel_copy_increment4, width) \ DUFFS_LOOP(pixel_copy_increment1, width) -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP #if defined(_MSC_VER) && (_MSC_VER >= 600) -#pragma warning(disable : 4244) /* '=': conversion from 'X' to 'Y', possible loss of data */ +#pragma warning(disable : 4244) // '=': conversion from 'X' to 'Y', possible loss of data #endif #include "SDL_surface_c.h" -#endif /* SDL_blit_h_ */ +#endif // SDL_blit_h_ diff --git a/src/video/SDL_blit_0.c b/src/video/SDL_blit_0.c index 5ea34aeae4..53cdb4a0a3 100644 --- a/src/video/SDL_blit_0.c +++ b/src/video/SDL_blit_0.c @@ -24,7 +24,7 @@ #include "SDL_blit.h" -/* Functions to blit from bitmaps to other surfaces */ +// Functions to blit from bitmaps to other surfaces SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp) { @@ -36,7 +36,7 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *src, *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -138,7 +138,7 @@ SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp) Uint16 *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -201,7 +201,7 @@ SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *src, *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -271,7 +271,7 @@ SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp) int srcskip, dstskip; int c; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -339,7 +339,7 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *palmap = info->table; int c; - /* Set up some basic variables */ + // Set up some basic variables if (srcbpp == 4) srcskip += width - (width + 1) / 2; else if (srcbpp == 2) @@ -437,7 +437,7 @@ SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *palmap = info->table; int c; - /* Set up some basic variables */ + // Set up some basic variables if (srcbpp == 4) srcskip += width - (width + 1) / 2; else if (srcbpp == 2) @@ -498,7 +498,7 @@ SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *palmap = info->table; int c; - /* Set up some basic variables */ + // Set up some basic variables if (srcbpp == 4) srcskip += width - (width + 1) / 2; else if (srcbpp == 2) @@ -558,7 +558,7 @@ SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp) Uint8 *palmap = info->table; int c; - /* Set up some basic variables */ + // Set up some basic variables if (srcbpp == 4) srcskip += width - (width + 1) / 2; else if (srcbpp == 2) @@ -624,7 +624,7 @@ SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp) unsigned dR, dG, dB, dA; const unsigned A = info->a; - /* Set up some basic variables */ + // Set up some basic variables dstbpp = dstfmt->bytes_per_pixel; if (srcbpp == 4) srcskip += width - (width + 1) / 2; @@ -701,7 +701,7 @@ SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp) const unsigned A = info->a; Uint32 ckey = info->colorkey; - /* Set up some basic variables */ + // Set up some basic variables dstbpp = dstfmt->bytes_per_pixel; if (srcbpp == 4) srcskip += width - (width + 1) / 2; @@ -997,4 +997,4 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface) return NULL; } -#endif /* SDL_HAVE_BLIT_0 */ +#endif // SDL_HAVE_BLIT_0 diff --git a/src/video/SDL_blit_1.c b/src/video/SDL_blit_1.c index 2c8acbdb1f..0f49d67f5b 100644 --- a/src/video/SDL_blit_1.c +++ b/src/video/SDL_blit_1.c @@ -25,7 +25,7 @@ #include "SDL_blit.h" #include "SDL_sysvideo.h" -/* Functions to blit from 8-bit surfaces to other surfaces */ +// Functions to blit from 8-bit surfaces to other surfaces static void Blit1to1(SDL_BlitInfo *info) { @@ -36,7 +36,7 @@ static void Blit1to1(SDL_BlitInfo *info) Uint8 *src, *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -47,7 +47,7 @@ static void Blit1to1(SDL_BlitInfo *info) while (height--) { #ifdef USE_DUFFS_LOOP - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *dst = map[*src]; @@ -55,7 +55,7 @@ static void Blit1to1(SDL_BlitInfo *info) dst++; src++; , width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on #else for (c = width; c; --c) { *dst = map[*src]; @@ -68,12 +68,12 @@ static void Blit1to1(SDL_BlitInfo *info) } } -/* This is now endian dependent */ +// 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 ) */ +#else // ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) #define HI 0 #define LO 1 #endif @@ -88,7 +88,7 @@ static void Blit1to2(SDL_BlitInfo *info) Uint16 *map; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -99,32 +99,32 @@ static void Blit1to2(SDL_BlitInfo *info) #ifdef USE_DUFFS_LOOP while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *(Uint16 *)dst = map[*src++]; dst += 2; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } #else - /* Memory align at 4-byte boundary, if necessary */ + // Memory align at 4-byte boundary, if necessary if ((long)dst & 0x03) { - /* Don't do anything if width is 0 */ + // Don't do anything if width is 0 if (width == 0) { return; } --width; while (height--) { - /* Perform copy alignment */ + // Perform copy alignment *(Uint16 *)dst = map[*src++]; dst += 2; - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; @@ -133,7 +133,7 @@ static void Blit1to2(SDL_BlitInfo *info) src += 2; dst += 4; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: *(Uint16 *)dst = map[*src++]; @@ -154,7 +154,7 @@ static void Blit1to2(SDL_BlitInfo *info) } } else { while (height--) { - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); src += 2; @@ -163,7 +163,7 @@ static void Blit1to2(SDL_BlitInfo *info) src += 2; dst += 4; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: *(Uint16 *)dst = map[*src++]; @@ -183,7 +183,7 @@ static void Blit1to2(SDL_BlitInfo *info) dst += dstskip; } } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP } static void Blit1to3(SDL_BlitInfo *info) @@ -196,7 +196,7 @@ static void Blit1to3(SDL_BlitInfo *info) Uint8 *src, *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -207,7 +207,7 @@ static void Blit1to3(SDL_BlitInfo *info) while (height--) { #ifdef USE_DUFFS_LOOP - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { o = *src * 4; @@ -218,7 +218,7 @@ static void Blit1to3(SDL_BlitInfo *info) src++; dst += 3; , width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on #else for (c = width; c; --c) { o = *src * 4; @@ -228,7 +228,7 @@ static void Blit1to3(SDL_BlitInfo *info) src++; dst += 3; } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP src += srcskip; dst += dstskip; } @@ -244,7 +244,7 @@ static void Blit1to4(SDL_BlitInfo *info) Uint32 *map, *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -255,11 +255,11 @@ static void Blit1to4(SDL_BlitInfo *info) while (height--) { #ifdef USE_DUFFS_LOOP - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( *dst++ = map[*src++]; , width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on #else for (c = width / 4; c; --c) { *dst++ = map[*src++]; @@ -277,7 +277,7 @@ static void Blit1to4(SDL_BlitInfo *info) case 1: *dst++ = map[*src++]; } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP src += srcskip; dst += dstskip; } @@ -296,7 +296,7 @@ static void Blit1to1Key(SDL_BlitInfo *info) if (palmap) { while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -306,13 +306,13 @@ static void Blit1to1Key(SDL_BlitInfo *info) src++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } else { while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -322,7 +322,7 @@ static void Blit1to1Key(SDL_BlitInfo *info) src++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -340,11 +340,11 @@ static void Blit1to2Key(SDL_BlitInfo *info) Uint16 *palmap = (Uint16 *)info->table; Uint32 ckey = info->colorkey; - /* Set up some basic variables */ + // Set up some basic variables dstskip /= 2; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -354,7 +354,7 @@ static void Blit1to2Key(SDL_BlitInfo *info) dstp++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dstp += dstskip; } @@ -373,7 +373,7 @@ static void Blit1to3Key(SDL_BlitInfo *info) int o; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -386,7 +386,7 @@ static void Blit1to3Key(SDL_BlitInfo *info) dst += 3; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -403,11 +403,11 @@ static void Blit1to4Key(SDL_BlitInfo *info) Uint32 *palmap = (Uint32 *)info->table; Uint32 ckey = info->colorkey; - /* Set up some basic variables */ + // Set up some basic variables dstskip /= 4; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -417,7 +417,7 @@ static void Blit1to4Key(SDL_BlitInfo *info) dstp++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dstp += dstskip; } @@ -439,11 +439,11 @@ static void Blit1toNAlpha(SDL_BlitInfo *info) unsigned dR, dG, dB, dA; const unsigned A = info->a; - /* Set up some basic variables */ + // Set up some basic variables dstbpp = dstfmt->bytes_per_pixel; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4( { sR = srcpal[*src].r; @@ -457,7 +457,7 @@ static void Blit1toNAlpha(SDL_BlitInfo *info) dst += dstbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -480,11 +480,11 @@ static void Blit1toNAlphaKey(SDL_BlitInfo *info) unsigned dR, dG, dB, dA; const unsigned A = info->a; - /* Set up some basic variables */ + // Set up some basic variables dstbpp = dstfmt->bytes_per_pixel; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( *src != ckey ) { @@ -500,7 +500,7 @@ static void Blit1toNAlphaKey(SDL_BlitInfo *info) dst += dstbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -537,7 +537,7 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface) } break; - case SDL_COPY_COLORKEY | SDL_COPY_BLEND: /* this is not super-robust but handles a specific case we found sdl12-compat. */ + case SDL_COPY_COLORKEY | SDL_COPY_BLEND: // this is not super-robust but handles a specific case we found sdl12-compat. return (surface->internal->map.info.a == 255) ? one_blitkey[which] : which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL; @@ -554,4 +554,4 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface) return (SDL_BlitFunc)NULL; } -#endif /* SDL_HAVE_BLIT_1 */ +#endif // SDL_HAVE_BLIT_1 diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 61942465d5..d67ce87782 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -24,9 +24,9 @@ #include "SDL_blit.h" -/* Functions to perform alpha blended blitting */ +// Functions to perform alpha blended blitting -/* N->1 blending with per-surface alpha */ +// N->1 blending with per-surface alpha static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -45,7 +45,7 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) const unsigned A = info->a; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4( { DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); @@ -56,7 +56,7 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) dR &= 0xff; dG &= 0xff; dB &= 0xff; - /* Pack RGB into 8bit pixel */ + // Pack RGB into 8bit pixel if ( palmap == NULL ) { *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); } else { @@ -66,13 +66,13 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* N->1 blending with pixel alpha */ +// N->1 blending with pixel alpha static void BlitNto1PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -90,7 +90,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info) unsigned dR, dG, dB; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4( { DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); @@ -101,7 +101,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info) dR &= 0xff; dG &= 0xff; dB &= 0xff; - /* Pack RGB into 8bit pixel */ + // Pack RGB into 8bit pixel if ( palmap == NULL ) { *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); } else { @@ -111,13 +111,13 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* colorkeyed N->1 blending with per-surface alpha */ +// colorkeyed N->1 blending with per-surface alpha static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; @@ -137,7 +137,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) const unsigned A = info->a; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); @@ -149,7 +149,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) dR &= 0xff; dG &= 0xff; dB &= 0xff; - /* Pack RGB into 8bit pixel */ + // Pack RGB into 8bit pixel if ( palmap == NULL ) { *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); } else { @@ -160,7 +160,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -241,7 +241,7 @@ static void SDL_TARGETING("sse2") Blit888to888SurfaceAlphaSSE2(SDL_BlitInfo *inf #endif -/* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ +// fast RGB888->(A)RGB888 blending with surface alpha=128 special case static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) { int width = info->dst_w; @@ -252,20 +252,20 @@ static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) int dstskip = info->dst_skip >> 2; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ Uint32 s = *srcp++; Uint32 d = *dstp; *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + (s & d & 0x00010101)) | 0xff000000; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } -/* fast RGB888->(A)RGB888 blending with surface alpha */ +// fast RGB888->(A)RGB888 blending with surface alpha static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) { unsigned alpha = info->a; @@ -282,7 +282,7 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) Uint32 d; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ s = *srcp; d = *dstp; @@ -293,20 +293,20 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) ++srcp; ++dstp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } } -/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */ +// 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel -/* blend a single 16 bit pixel at 50% */ +// blend a single 16 bit pixel at 50% #define BLEND16_50(d, s, mask) \ ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) -/* blend two 16 bit pixels at 50% */ +// 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)))) @@ -329,7 +329,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) Uint32 prev_sw; int w = width; - /* handle odd destination */ + // handle odd destination if ((uintptr_t)dstp & 2) { Uint16 d = *dstp, s = *srcp; *dstp = BLEND16_50(d, s, mask); @@ -337,9 +337,9 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) srcp++; w--; } - srcp++; /* srcp is now 32-bit aligned */ + srcp++; // srcp is now 32-bit aligned - /* bootstrap pipeline with first halfword */ + // bootstrap pipeline with first halfword prev_sw = ((Uint32 *)srcp)[-1]; while (w > 1) { @@ -358,7 +358,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) w -= 2; } - /* final pixel if any */ + // final pixel if any if (w) { Uint16 d = *dstp, s; #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -373,10 +373,10 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) srcp += srcskip - 1; dstp += dstskip; } else { - /* source and destination are aligned */ + // source and destination are aligned int w = width; - /* first odd pixel? */ + // first odd pixel? if ((uintptr_t)srcp & 2) { Uint16 d = *dstp, s = *srcp; *dstp = BLEND16_50(d, s, mask); @@ -384,7 +384,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) dstp++; w--; } - /* srcp and dstp are now 32-bit aligned */ + // srcp and dstp are now 32-bit aligned while (w > 1) { Uint32 sw = *(Uint32 *)srcp; @@ -395,7 +395,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) w -= 2; } - /* last odd pixel? */ + // last odd pixel? if (w) { Uint16 d = *dstp, s = *srcp; *dstp = BLEND16_50(d, s, mask); @@ -410,7 +410,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) #ifdef SDL_MMX_INTRINSICS -/* fast RGB565->RGB565 blending with surface alpha */ +// fast RGB565->RGB565 blending with surface alpha static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) { unsigned alpha = info->a; @@ -428,23 +428,23 @@ static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) #ifdef USE_DUFFS_LOOP __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 */ + // Setup the 565 color channel masks + gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); // MASKGREEN -> gmask + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); // MASKBLUE -> bmask #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP_124( { s = *srcp++; @@ -485,62 +485,62 @@ static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) d &= 0x07e0f81f; *dstp++ = (Uint16)(d | d >> 16); },{ - src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ - dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ + src1 = *(__m64*)srcp; // 4 src pixels -> src1 + dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1 - /* red */ + // red src2 = src1; - src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 [000r 000r 000r 000r] */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 [000r 000r 000r 000r] dst2 = dst1; - dst2 = _mm_srli_pi16(dst2, 11); /* dst2 >> 11 -> dst2 [000r 000r 000r 000r] */ + dst2 = _mm_srli_pi16(dst2, 11); // dst2 >> 11 -> dst2 [000r 000r 000r 000r] - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ - dst2 = _mm_slli_pi16(dst2, 11); /* dst2 << 11 -> dst2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_slli_pi16(dst2, 11); // dst2 << 11 -> dst2 - mm_res = dst2; /* RED -> mm_res */ + mm_res = dst2; // RED -> mm_res - /* green -- process the bits in place */ + // green -- process the bits in place src2 = src1; - src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ + src2 = _mm_and_si64(src2, gmask); // src & MASKGREEN -> src2 dst2 = dst1; - dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ + dst2 = _mm_and_si64(dst2, gmask); // dst & MASKGREEN -> dst2 - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 - mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN -> mm_res - /* blue */ + // blue src2 = src1; - src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ + src2 = _mm_and_si64(src2, bmask); // src & MASKBLUE -> src2[000b 000b 000b 000b] dst2 = dst1; - dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ + dst2 = _mm_and_si64(dst2, bmask); // dst & MASKBLUE -> dst2[000b 000b 000b 000b] - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ - dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst2 & MASKBLUE -> dst2 - mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res - *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ + *(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels srcp += 4; dstp += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } @@ -548,7 +548,7 @@ static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) } } -/* fast RGB555->RGB555 blending with surface alpha */ +// fast RGB555->RGB555 blending with surface alpha static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) { unsigned alpha = info->a; @@ -566,23 +566,23 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) #ifdef USE_DUFFS_LOOP __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 */ + // 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 #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP_124( { s = *srcp++; @@ -623,62 +623,62 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) d &= 0x03e07c1f; *dstp++ = (Uint16)(d | d >> 16); },{ - src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ - dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ + src1 = *(__m64*)srcp; // 4 src pixels -> src1 + dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1 - /* red -- process the bits in place */ + // red -- process the bits in place src2 = src1; - src2 = _mm_and_si64(src2, rmask); /* src & MASKRED -> src2 */ + src2 = _mm_and_si64(src2, rmask); // src & MASKRED -> src2 dst2 = dst1; - dst2 = _mm_and_si64(dst2, rmask); /* dst & MASKRED -> dst2 */ + dst2 = _mm_and_si64(dst2, rmask); // dst & MASKRED -> dst2 - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ - dst2 = _mm_and_si64(dst2, rmask); /* dst2 & MASKRED -> dst2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, rmask); // dst2 & MASKRED -> dst2 - mm_res = dst2; /* RED -> mm_res */ + mm_res = dst2; // RED -> mm_res - /* green -- process the bits in place */ + // green -- process the bits in place src2 = src1; - src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ + src2 = _mm_and_si64(src2, gmask); // src & MASKGREEN -> src2 dst2 = dst1; - dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ + dst2 = _mm_and_si64(dst2, gmask); // dst & MASKGREEN -> dst2 - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 - mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN -> mm_res - /* blue */ - src2 = src1; /* src -> src2 */ - src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ + // blue + src2 = src1; // src -> src2 + src2 = _mm_and_si64(src2, bmask); // src & MASKBLUE -> src2[000b 000b 000b 000b] - dst2 = dst1; /* dst -> dst2 */ - dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ + dst2 = dst1; // dst -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst & MASKBLUE -> dst2[000b 000b 000b 000b] - /* blend */ - src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ - dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ - dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst2 & MASKBLUE -> dst2 - mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res - *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ + *(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels srcp += 4; dstp += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } @@ -686,9 +686,9 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) } } -#endif /* SDL_MMX_INTRINSICS */ +#endif // SDL_MMX_INTRINSICS -/* fast RGB565->RGB565 blending with surface alpha */ +// fast RGB565->RGB565 blending with surface alpha static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) { unsigned alpha = info->a; @@ -701,10 +701,10 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) int srcskip = info->src_skip >> 1; 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 */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ Uint32 s = *srcp++; Uint32 d = *dstp; @@ -719,17 +719,17 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) d &= 0x07e0f81f; *dstp++ = (Uint16)(d | d >> 16); }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } } -/* fast RGB555->RGB555 blending with surface alpha */ +// fast RGB555->RGB555 blending with surface alpha 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 { @@ -739,10 +739,10 @@ static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info) int srcskip = info->src_skip >> 1; 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 */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ Uint32 s = *srcp++; Uint32 d = *dstp; @@ -757,14 +757,14 @@ static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info) d &= 0x03e07c1f; *dstp++ = (Uint16)(d | d >> 16); }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } } -/* fast ARGB8888->RGB565 blending with pixel alpha */ +// fast ARGB8888->RGB565 blending with pixel alpha static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -775,10 +775,10 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info) int dstskip = info->dst_skip >> 1; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ Uint32 s = *srcp; - unsigned alpha = s >> 27; /* downscale alpha to 5 bits */ + unsigned alpha = s >> 27; // downscale alpha to 5 bits /* FIXME: Here we special-case opaque alpha since the compositioning used (>>8 instead of /255) doesn't handle it correctly. Also special-case alpha=0 for speed? @@ -803,13 +803,13 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info) srcp++; dstp++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } -/* fast ARGB8888->RGB555 blending with pixel alpha */ +// fast ARGB8888->RGB555 blending with pixel alpha static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -820,11 +820,11 @@ static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info) int dstskip = info->dst_skip >> 1; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4({ unsigned alpha; Uint32 s = *srcp; - alpha = s >> 27; /* downscale alpha to 5 bits */ + alpha = s >> 27; // downscale alpha to 5 bits /* FIXME: Here we special-case opaque alpha since the compositioning used (>>8 instead of /255) doesn't handle it correctly. Also special-case alpha=0 for speed? @@ -849,13 +849,13 @@ static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info) srcp++; dstp++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } } -/* General (slow) N->N blending with per-surface alpha */ +// General (slow) N->N blending with per-surface alpha static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -875,7 +875,7 @@ static void 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); @@ -886,14 +886,14 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info) dst += dstbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } } -/* General (slow) colorkeyed N->N blending with per-surface alpha */ +// General (slow) colorkeyed N->N blending with per-surface alpha static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) { int width = info->dst_w; @@ -913,7 +913,7 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) const unsigned sA = info->a; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP4( { RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); @@ -927,13 +927,13 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) dst += dstbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* Fast 32-bit RGBA->RGBA blending with pixel alpha */ +// Fast 32-bit RGBA->RGBA blending with pixel alpha static void Blit8888to8888PixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -961,7 +961,7 @@ static void Blit8888to8888PixelAlpha(SDL_BlitInfo *info) } } -/* Fast 32-bit RGBA->RGB(A) blending with pixel alpha and src swizzling */ +// Fast 32-bit RGBA->RGB(A) blending with pixel alpha and src swizzling static void Blit8888to8888PixelAlphaSwizzle(SDL_BlitInfo *info) { int width = info->dst_w; @@ -1174,7 +1174,7 @@ static void SDL_TARGETING("avx2") Blit8888to8888PixelAlphaSwizzleAVX2(SDL_BlitIn #endif -/* General (slow) N->N blending with pixel alpha */ +// General (slow) N->N blending with pixel alpha static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -1191,7 +1191,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) unsigned sR, sG, sB, sA; unsigned dR, dG, dB, dA; - /* Set up some basic variables */ + // Set up some basic variables srcbpp = srcfmt->bytes_per_pixel; dstbpp = dstfmt->bytes_per_pixel; @@ -1208,7 +1208,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) dst += dstbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -1221,13 +1221,13 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) { case SDL_COPY_BLEND: - /* Per-pixel alpha blits */ + // Per-pixel alpha blits switch (df->bytes_per_pixel) { case 1: if (surface->internal->map.info.dst_pal) { return BlitNto1PixelAlpha; } else { - /* RGB332 has no palette ! */ + // RGB332 has no palette ! return BlitNtoNPixelAlpha; } @@ -1270,13 +1270,13 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: if (sf->Amask == 0) { - /* Per-surface alpha blits */ + // Per-surface alpha blits switch (df->bytes_per_pixel) { case 1: if (surface->internal->map.info.dst_pal) { return BlitNto1SurfaceAlpha; } else { - /* RGB332 has no palette ! */ + // RGB332 has no palette ! return BlitNtoNSurfaceAlpha; } @@ -1331,7 +1331,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) if (surface->internal->map.info.dst_pal) { return BlitNto1SurfaceAlphaKey; } else { - /* RGB332 has no palette ! */ + // RGB332 has no palette ! return BlitNtoNSurfaceAlphaKey; } } else { @@ -1344,5 +1344,5 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) return NULL; } -#endif /* SDL_HAVE_BLIT_A */ +#endif // SDL_HAVE_BLIT_A diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 0a5d0704e1..1c7f23d7b0 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -25,16 +25,16 @@ #include "SDL_blit.h" #include "SDL_blit_copy.h" -/* General optimized routines that write char by char */ +// 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 */ +// On some CPU, it's slower than combining and write a word #ifdef __MIPS__ #undef HAVE_FAST_WRITE_INT8 #define HAVE_FAST_WRITE_INT8 0 #endif -/* Functions to blit from N-bit surfaces to other surfaces */ +// Functions to blit from N-bit surfaces to other surfaces #define BLIT_FEATURE_NONE 0x00 #define BLIT_FEATURE_HAS_MMX 0x01 @@ -61,10 +61,10 @@ static size_t GetL3CacheSize(void) #else static size_t GetL3CacheSize(void) { - /* XXX: Just guess G4 */ + // XXX: Just guess G4 return 2097152; } -#endif /* SDL_PLATFORM_MACOS */ +#endif // SDL_PLATFORM_MACOS #if (defined(SDL_PLATFORM_MACOS) && (__GNUC__ < 4)) #define VECUINT8_LITERAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ @@ -105,7 +105,7 @@ static size_t GetL3CacheSize(void) #define DST_CHAN_SRC 1 #define DST_CHAN_DEST 2 -/* macro to set DST control word value... */ +// macro to set DST control word value... #define DST_CTRL(size, count, stride) \ (((size) << 24) | ((count) << 16) | (stride)) @@ -113,7 +113,7 @@ static size_t GetL3CacheSize(void) ? vec_lvsl(0, src) \ : vec_add(vec_lvsl(8, src), vec_splat_u8(8))) -/* Calculate the permute vector used for 32->32 swizzling */ +// Calculate the permute vector used for 32->32 swizzling static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *dstfmt) { /* @@ -121,7 +121,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, * colors is alpha, and it's one complete byte, since some formats * leave alpha with a zero mask, but we should still swizzle the bits. */ - /* ARGB */ + // ARGB static const SDL_PixelFormatDetails default_pixel_format = { SDL_PIXELFORMAT_ARGB8888, 0, 0, { 0, 0 }, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 8, 8, 8, 8, 16, 8, 0, 24 }; @@ -146,7 +146,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift); bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift); - /* Use zero for alpha if either surface doesn't have alpha */ + // Use zero for alpha if either surface doesn't have alpha if (dstfmt->Amask) { amask = ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->Ashift); @@ -163,7 +163,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, } #if SDL_BYTEORDER == SDL_LIL_ENDIAN -/* reorder bytes for PowerPC little endian */ +// reorder bytes for PowerPC little endian static vector unsigned char reorder_ppc64le_vec(vector unsigned char vpermute) { /* The result vector of calc_swizzle32 reorder bytes using vec_perm. @@ -224,7 +224,7 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) int width = info->dst_w; int extrawidth; - /* do scalar until we can align... */ + // do scalar until we can align... #define ONE_PIXEL_BLEND(condition, widthvar) \ while (condition) { \ Uint32 Pixel; \ @@ -241,8 +241,8 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); - /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -260,7 +260,7 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) voverflow = vec_ld(15, src); vsrc = vec_perm(vsrc, voverflow, valigner); vsrc2 = (vector unsigned int)vec_perm(vsrc, valpha, vpermute); - /* 1555 */ + // 1555 vpixel = (vector unsigned short)vec_packpx(vsrc1, vsrc2); vgpixel = (vector unsigned short)vec_perm(vsrc1, vsrc2, vgmerge); vgpixel = vec_and(vgpixel, vfc); @@ -271,7 +271,7 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) vdst = vec_or((vector unsigned char)vrpixel, (vector unsigned char)vgpixel); - /* 565 */ + // 565 vdst = vec_or(vdst, (vector unsigned char)vbpixel); vec_st(vdst, 0, dst); @@ -283,11 +283,11 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) SDL_assert(width == 0); - /* do scalar until we can align... */ + // 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; } } @@ -365,7 +365,7 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) int width = info->dst_w; int extrawidth; - /* do scalar until we can align... */ + // do scalar until we can align... #define ONE_PIXEL_BLEND(condition, widthvar) \ while (condition) { \ unsigned sR, sG, sB; \ @@ -380,8 +380,8 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) } ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); - /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -421,11 +421,11 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) SDL_assert(width == 0); - /* do scalar until we can align... */ + // 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; } } @@ -503,7 +503,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) int width = info->dst_w; int extrawidth; - /* do scalar until we can align... */ + // do scalar until we can align... #define ONE_PIXEL_BLEND(condition, widthvar) \ while (condition) { \ unsigned sR, sG, sB; \ @@ -518,8 +518,8 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) } ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); - /* After all that work, here's the vector part! */ - extrawidth = (width % 8); /* trailing unaligned stores */ + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores width -= extrawidth; vsrc = vec_ld(0, src); valigner = VEC_ALIGNER(src); @@ -559,11 +559,11 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) SDL_assert(width == 0); - /* do scalar until we can align... */ + // 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; } } @@ -614,7 +614,7 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info) vrgbmask = vec_splat(vrgbmask, 0); #if SDL_BYTEORDER == SDL_LIL_ENDIAN - /* reorder bytes for PowerPC little endian */ + // reorder bytes for PowerPC little endian vpermute = reorder_ppc64le_vec(vpermute); #endif @@ -662,16 +662,16 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info) vector unsigned char vsel; vector unsigned int vd; vector unsigned int voverflow = vec_ld(15, srcp); - /* load the source vec */ + // load the source vec vs = vec_perm(vs, voverflow, valigner); - /* vsel is set for items that match the key */ + // 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); - /* permute the src vec to the dest format */ + // permute the src vec to the dest format vs = vec_perm(vs, valpha, vpermute); - /* load the destination vec */ + // load the destination vec vd = vec_ld(0, dstp); - /* select the source and dest into vs */ + // select the source and dest into vs vd = (vector unsigned int)vec_sel((vector unsigned char)vs, (vector unsigned char)vd, vsel); @@ -690,8 +690,8 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info) } } -/* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ -/* Use this on a G5 */ +// 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) { int height = info->dst_h; @@ -715,7 +715,7 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) SDL_assert(dstfmt->bytes_per_pixel == 4); #if SDL_BYTEORDER == SDL_LIL_ENDIAN - /* reorder bytes for PowerPC little endian */ + // reorder bytes for PowerPC little endian vpermute = reorder_ppc64le_vec(vpermute); #endif @@ -729,7 +729,7 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) int width = info->dst_w; int extrawidth; - /* do scalar until we can align... */ + // do scalar until we can align... while ((UNALIGNED_PTR(dst)) && (width)) { bits = *(src++); RGBA_FROM_8888(bits, srcfmt, r, g, b, a); @@ -739,7 +739,7 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) width--; } - /* After all that work, here's the vector part! */ + // After all that work, here's the vector part! extrawidth = (width % 4); width -= extrawidth; valigner = VEC_ALIGNER(src); @@ -749,18 +749,18 @@ static void 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, vzero, vpermute); /* swizzle it. */ - vec_st(vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, voverflow, valigner); // src is ready. + vbits = vec_perm(vbits, vzero, vpermute); // swizzle it. + vec_st(vbits, 0, dst); // store it back out. dst += 4; vbits = voverflow; } SDL_assert(width == 0); - /* cover pixels at the end of the row that didn't fit in 16 bytes. */ + // 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; @@ -773,8 +773,8 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) } } -/* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ -/* Use this on a G4 */ +// 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) { const int scalar_dst_lead = sizeof(Uint32) * 4; @@ -801,7 +801,7 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info) SDL_assert(dstfmt->bytes_per_pixel == 4); #if SDL_BYTEORDER == SDL_LIL_ENDIAN - /* reorder bytes for PowerPC little endian */ + // reorder bytes for PowerPC little endian vpermute = reorder_ppc64le_vec(vpermute); #endif @@ -815,7 +815,7 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info) int width = info->dst_w; int extrawidth; - /* do scalar until we can align... */ + // do scalar until we can align... while ((UNALIGNED_PTR(dst)) && (width)) { vec_dstt(src + scalar_dst_lead, DST_CTRL(2, 32, 1024), DST_CHAN_SRC); @@ -829,7 +829,7 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info) width--; } - /* After all that work, here's the vector part! */ + // After all that work, here's the vector part! extrawidth = (width % 4); width -= extrawidth; valigner = VEC_ALIGNER(src); @@ -843,18 +843,18 @@ static void 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, vzero, vpermute); /* swizzle it. */ - vec_st(vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, voverflow, valigner); // src is ready. + vbits = vec_perm(vbits, vzero, vpermute); // swizzle it. + vec_st(vbits, 0, dst); // store it back out. dst += 4; vbits = voverflow; } SDL_assert(width == 0); - /* cover pixels at the end of the row that didn't fit in 16 bytes. */ + // 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; @@ -875,12 +875,12 @@ static Uint32 GetBlitFeatures(void) static Uint32 features = ~0u; if (features == ~0u) { features = (0 - /* Feature 1 is has-MMX */ + // Feature 1 is has-MMX | ((SDL_HasMMX()) ? BLIT_FEATURE_HAS_MMX : 0) - /* Feature 2 is has-AltiVec */ + // Feature 2 is has-AltiVec | ((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. */ + // 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)); } return features; @@ -890,7 +890,7 @@ static Uint32 GetBlitFeatures(void) #pragma altivec_model off #endif #else -/* Feature 1 is has-MMX */ +// Feature 1 is has-MMX #define GetBlitFeatures() ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0) | (SDL_HasARMSIMD() ? BLIT_FEATURE_HAS_ARM_SIMD : 0)) #endif @@ -924,16 +924,16 @@ static void Blit_RGB444_XRGB8888ARMSIMD(SDL_BlitInfo *info) } #endif -/* This is now endian dependent */ +// This is now endian dependent #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define HI 1 #define LO 0 -#else /* SDL_BYTEORDER == SDL_BIG_ENDIAN */ +#else // SDL_BYTEORDER == SDL_BIG_ENDIAN #define HI 0 #define LO 1 #endif -/* Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 */ +// Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 #define RGB888_RGB555(dst, src) \ { \ *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 9) | \ @@ -962,7 +962,7 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) Uint16 *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = (Uint32 *)info->src; @@ -972,32 +972,32 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) #ifdef USE_DUFFS_LOOP while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( RGB888_RGB555(dst, src); ++src; ++dst; , width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } #else - /* Memory align at 4-byte boundary, if necessary */ + // Memory align at 4-byte boundary, if necessary if ((long)dst & 0x03) { - /* Don't do anything if width is 0 */ + // Don't do anything if width is 0 if (width == 0) { return; } --width; while (height--) { - /* Perform copy alignment */ + // Perform copy alignment RGB888_RGB555(dst, src); ++src; ++dst; - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { RGB888_RGB555_TWO(dst, src); src += 2; @@ -1006,7 +1006,7 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) src += 2; dst += 2; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: RGB888_RGB555(dst, src); @@ -1029,7 +1029,7 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) } } else { while (height--) { - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { RGB888_RGB555_TWO(dst, src); src += 2; @@ -1038,7 +1038,7 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) src += 2; dst += 2; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: RGB888_RGB555(dst, src); @@ -1060,10 +1060,10 @@ static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) dst += dstskip; } } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP } -/* Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 */ +// Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 #define RGB888_RGB565(dst, src) \ { \ *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 8) | \ @@ -1092,7 +1092,7 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) Uint16 *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = (Uint32 *)info->src; @@ -1102,32 +1102,32 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) #ifdef USE_DUFFS_LOOP while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( RGB888_RGB565(dst, src); ++src; ++dst; , width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } #else - /* Memory align at 4-byte boundary, if necessary */ + // Memory align at 4-byte boundary, if necessary if ((long)dst & 0x03) { - /* Don't do anything if width is 0 */ + // Don't do anything if width is 0 if (width == 0) { return; } --width; while (height--) { - /* Perform copy alignment */ + // Perform copy alignment RGB888_RGB565(dst, src); ++src; ++dst; - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { RGB888_RGB565_TWO(dst, src); src += 2; @@ -1136,7 +1136,7 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) src += 2; dst += 2; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: RGB888_RGB565(dst, src); @@ -1159,7 +1159,7 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) } } else { while (height--) { - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { RGB888_RGB565_TWO(dst, src); src += 2; @@ -1168,7 +1168,7 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) src += 2; dst += 2; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: RGB888_RGB565(dst, src); @@ -1190,12 +1190,12 @@ static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) dst += dstskip; } } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP } #if SDL_HAVE_BLIT_N_RGB565 -/* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */ +// 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) { @@ -1207,7 +1207,7 @@ static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) Uint32 *dst; int srcskip, dstskip; - /* Set up some basic variables */ + // Set up some basic variables width = info->dst_w; height = info->dst_h; src = info->src; @@ -1217,20 +1217,20 @@ static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) #ifdef USE_DUFFS_LOOP while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *dst++ = RGB565_32(dst, src, map); src += 2; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } #else while (height--) { - /* Copy in 4 pixel chunks */ + // Copy in 4 pixel chunks for (c = width / 4; c; --c) { *dst++ = RGB565_32(dst, src, map); src += 2; @@ -1241,7 +1241,7 @@ static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) *dst++ = RGB565_32(dst, src, map); src += 2; } - /* Get any leftovers */ + // Get any leftovers switch (width & 3) { case 3: *dst++ = RGB565_32(dst, src, map); @@ -1259,12 +1259,12 @@ static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) src += srcskip; dst += dstskip; } -#endif /* USE_DUFFS_LOOP */ +#endif // USE_DUFFS_LOOP } -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off -/* Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 */ +// Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 static const Uint32 RGB565_ARGB8888_LUT[512] = { 0x00000000, 0xff000000, 0x00000008, 0xff002000, 0x00000010, 0xff004000, 0x00000018, 0xff006100, @@ -1401,7 +1401,7 @@ static void Blit_RGB565_ARGB8888(SDL_BlitInfo * info) Blit_RGB565_32(info, RGB565_ARGB8888_LUT); } -/* Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 */ +// Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 static const Uint32 RGB565_ABGR8888_LUT[512] = { 0xff000000, 0x00000000, 0xff080000, 0x00002000, 0xff100000, 0x00004000, 0xff180000, 0x00006100, @@ -1538,7 +1538,7 @@ static void Blit_RGB565_ABGR8888(SDL_BlitInfo * info) Blit_RGB565_32(info, RGB565_ABGR8888_LUT); } -/* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */ +// Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 static const Uint32 RGB565_RGBA8888_LUT[512] = { 0x000000ff, 0x00000000, 0x000008ff, 0x00200000, 0x000010ff, 0x00400000, 0x000018ff, 0x00610000, @@ -1675,7 +1675,7 @@ static void Blit_RGB565_RGBA8888(SDL_BlitInfo * info) Blit_RGB565_32(info, RGB565_RGBA8888_LUT); } -/* Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 */ +// Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 static const Uint32 RGB565_BGRA8888_LUT[512] = { 0x00000000, 0x000000ff, 0x08000000, 0x002000ff, 0x10000000, 0x004000ff, 0x18000000, 0x006100ff, @@ -1812,11 +1812,11 @@ static void Blit_RGB565_BGRA8888(SDL_BlitInfo * info) Blit_RGB565_32(info, RGB565_BGRA8888_LUT); } -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on -#endif /* SDL_HAVE_BLIT_N_RGB565 */ +#endif // SDL_HAVE_BLIT_N_RGB565 -/* RGB555->ARGB1555, and BGR555->ABGR1555, SET_ALPHA */ +// RGB555->ARGB1555, and BGR555->ABGR1555, SET_ALPHA static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info) { int width = info->dst_w; @@ -1830,7 +1830,7 @@ static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info) Uint16 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *dst = *src | mask; @@ -1838,13 +1838,13 @@ static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info) ++src; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src = (Uint16 *)((Uint8 *)src + srcskip); dst = (Uint16 *)((Uint8 *)dst + dstskip); } } -/* blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields */ +// blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields static void Blit4to4MaskAlpha(SDL_BlitInfo *info) { int width = info->dst_w; @@ -1857,11 +1857,11 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info) const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; if (dstfmt->Amask) { - /* RGB->RGBA, SET_ALPHA */ + // RGB->RGBA, SET_ALPHA Uint32 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *dst = *src | mask; @@ -1869,16 +1869,16 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info) ++src; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src = (Uint32 *)((Uint8 *)src + srcskip); dst = (Uint32 *)((Uint8 *)dst + dstskip); } } else { - /* RGBA->RGB, NO_ALPHA */ + // RGBA->RGB, NO_ALPHA Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { *dst = *src & mask; @@ -1886,22 +1886,22 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info) ++src; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src = (Uint32 *)((Uint8 *)src + srcskip); dst = (Uint32 *)((Uint8 *)dst + dstskip); } } } -/* permutation for mapping srcfmt to dstfmt, overloading or not the alpha channel */ +// permutation for mapping srcfmt to dstfmt, overloading or not the alpha channel static void get_permutation(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *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 - int Pixel = 0x04030201; /* identity permutation */ + int Pixel = 0x04030201; // identity permutation #else - int Pixel = 0x01020304; /* identity permutation */ + int Pixel = 0x01020304; // identity permutation int srcbpp = srcfmt->bytes_per_pixel; int dstbpp = dstfmt->bytes_per_pixel; #endif @@ -1995,17 +1995,17 @@ static void BlitNtoN(SDL_BlitInfo *info) unsigned alpha = dstfmt->Amask ? info->a : 0; #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 4->4 */ + // Blit with permutation: 4->4 if (srcbpp == 4 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int alpha_channel, p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { dst[0] = src[p0]; @@ -2016,7 +2016,7 @@ static void BlitNtoN(SDL_BlitInfo *info) src += 4; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2024,16 +2024,16 @@ static void BlitNtoN(SDL_BlitInfo *info) } #endif - /* Blit with permutation: 4->3 */ + // Blit with permutation: 4->3 if (srcbpp == 4 && dstbpp == 3 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { dst[0] = src[p0]; @@ -2042,7 +2042,7 @@ static void BlitNtoN(SDL_BlitInfo *info) src += 4; dst += 3; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2050,16 +2050,16 @@ static void BlitNtoN(SDL_BlitInfo *info) } #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 3->4 */ + // Blit with permutation: 3->4 if (srcbpp == 3 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int alpha_channel, p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { dst[0] = src[p0]; @@ -2070,7 +2070,7 @@ static void BlitNtoN(SDL_BlitInfo *info) src += 3; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2079,7 +2079,7 @@ static void BlitNtoN(SDL_BlitInfo *info) #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 Pixel; @@ -2092,7 +2092,7 @@ static void BlitNtoN(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2113,17 +2113,17 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info) int c; #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 4->4 */ + // Blit with permutation: 4->4 if (srcbpp == 4 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { dst[0] = src[p0]; @@ -2133,7 +2133,7 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info) src += 4; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2166,13 +2166,13 @@ static void Blit2to2Key(SDL_BlitInfo *info) Uint32 ckey = info->colorkey; Uint32 rgbmask = ~info->src_fmt->Amask; - /* Set up some basic variables */ + // Set up some basic variables srcskip /= 2; dstskip /= 2; ckey &= rgbmask; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ( (*srcp & rgbmask) != ckey ) { @@ -2182,7 +2182,7 @@ static void Blit2to2Key(SDL_BlitInfo *info) srcp++; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on srcp += srcskip; dstp += dstskip; } @@ -2206,19 +2206,19 @@ static void BlitNtoNKey(SDL_BlitInfo *info) int sfmt = srcfmt->format; int dfmt = dstfmt->format; - /* Set up some basic variables */ + // Set up some basic variables ckey &= rgbmask; - /* BPP 4, same rgb */ + // 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; if (dstfmt->Amask) { - /* RGB->RGBA, SET_ALPHA */ + // RGB->RGBA, SET_ALPHA Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ((*src32 & rgbmask) != ckey) { @@ -2227,16 +2227,16 @@ static void BlitNtoNKey(SDL_BlitInfo *info) ++dst32; ++src32; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src32 = (Uint32 *)((Uint8 *)src32 + srcskip); dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); } return; } else { - /* RGBA->RGB, NO_ALPHA */ + // RGBA->RGB, NO_ALPHA Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ((*src32 & rgbmask) != ckey) { @@ -2245,7 +2245,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) ++dst32; ++src32; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src32 = (Uint32 *)((Uint8 *)src32 + srcskip); dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); } @@ -2254,17 +2254,17 @@ static void BlitNtoNKey(SDL_BlitInfo *info) } #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 4->4 */ + // Blit with permutation: 4->4 if (srcbpp == 4 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int alpha_channel, p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *src32 = (Uint32*)src; @@ -2279,7 +2279,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) src += 4; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2287,7 +2287,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) } #endif - /* BPP 3, same rgb triplet */ + // BPP 3, same rgb triplet if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_RGB24) || (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_BGR24)) { @@ -2302,7 +2302,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint8 s0 = src[0]; @@ -2318,14 +2318,14 @@ static void BlitNtoNKey(SDL_BlitInfo *info) dst += 3; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } return; } - /* BPP 3, inversed rgb triplet */ + // BPP 3, inversed rgb triplet if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_BGR24) || (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_RGB24)) { @@ -2340,14 +2340,14 @@ static void BlitNtoNKey(SDL_BlitInfo *info) #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint8 s0 = src[0]; Uint8 s1 = src[1]; Uint8 s2 = src[2]; if (k0 != s0 || k1 != s1 || k2 != s2) { - /* Inversed RGB */ + // Inversed RGB dst[0] = s2; dst[1] = s1; dst[2] = s0; @@ -2356,23 +2356,23 @@ static void BlitNtoNKey(SDL_BlitInfo *info) dst += 3; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } return; } - /* Blit with permutation: 4->3 */ + // Blit with permutation: 4->3 if (srcbpp == 4 && dstbpp == 3 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *src32 = (Uint32*)src; @@ -2384,7 +2384,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) src += 4; dst += 3; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2392,7 +2392,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) } #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 3->4 */ + // Blit with permutation: 3->4 if (srcbpp == 3 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { @@ -2406,12 +2406,12 @@ static void BlitNtoNKey(SDL_BlitInfo *info) Uint8 k2 = ckey & 0xFF; #endif - /* Find the appropriate permutation */ + // Find the appropriate permutation int alpha_channel, p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint8 s0 = src[0]; @@ -2428,7 +2428,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) src += 3; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2437,7 +2437,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 Pixel; @@ -2453,7 +2453,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2477,12 +2477,12 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) Uint32 Pixel; unsigned sR, sG, sB, sA; - /* Set up some basic variables */ + // Set up some basic variables srcbpp = srcfmt->bytes_per_pixel; dstbpp = dstfmt->bytes_per_pixel; ckey &= rgbmask; - /* Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster */ + // Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster if (srcfmt->format == dstfmt->format) { if (srcfmt->format == SDL_PIXELFORMAT_ARGB8888 || @@ -2493,7 +2493,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) Uint32 *src32 = (Uint32 *)src; Uint32 *dst32 = (Uint32 *)dst; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { if ((*src32 & rgbmask) != ckey) { @@ -2503,7 +2503,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) ++dst32; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src32 = (Uint32 *)((Uint8 *)src32 + srcskip); dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); } @@ -2512,17 +2512,17 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) } #if HAVE_FAST_WRITE_INT8 - /* Blit with permutation: 4->4 */ + // Blit with permutation: 4->4 if (srcbpp == 4 && dstbpp == 4 && !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { - /* Find the appropriate permutation */ + // Find the appropriate permutation int p0, p1, p2, p3; get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *src32 = (Uint32*)src; @@ -2535,7 +2535,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) src += 4; dst += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } @@ -2544,7 +2544,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); @@ -2555,13 +2555,13 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* Special optimized blit for ARGB 2-10-10-10 --> RGBA */ +// Special optimized blit for ARGB 2-10-10-10 --> RGBA static void Blit2101010toN(SDL_BlitInfo *info) { int width = info->dst_w; @@ -2576,7 +2576,7 @@ static void Blit2101010toN(SDL_BlitInfo *info) unsigned sR, sG, sB, sA; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Pixel = *(Uint32 *)src; @@ -2586,13 +2586,13 @@ static void Blit2101010toN(SDL_BlitInfo *info) src += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* Special optimized blit for RGBA --> ARGB 2-10-10-10 */ +// Special optimized blit for RGBA --> ARGB 2-10-10-10 static void BlitNto2101010(SDL_BlitInfo *info) { int width = info->dst_w; @@ -2607,7 +2607,7 @@ static void BlitNto2101010(SDL_BlitInfo *info) unsigned sR, sG, sB, sA; while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); @@ -2617,13 +2617,13 @@ static void BlitNto2101010(SDL_BlitInfo *info) src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } -/* Blit_3or4_to_3or4__same_rgb: 3 or 4 bpp, same RGB triplet */ +// Blit_3or4_to_3or4__same_rgb: 3 or 4 bpp, same RGB triplet static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) { int width = info->dst_w; @@ -2638,7 +2638,7 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) int dstbpp = dstfmt->bytes_per_pixel; if (dstfmt->Amask) { - /* SET_ALPHA */ + // SET_ALPHA Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; #if SDL_BYTEORDER == SDL_LIL_ENDIAN int i0 = 0, i1 = 1, i2 = 2; @@ -2648,7 +2648,7 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) int i2 = srcbpp - 1 - 2; #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *dst32 = (Uint32*)dst; @@ -2659,12 +2659,12 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) dst += 4; src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } else { - /* NO_ALPHA */ + // NO_ALPHA #if SDL_BYTEORDER == SDL_LIL_ENDIAN int i0 = 0, i1 = 1, i2 = 2; int j0 = 0, j1 = 1, j2 = 2; @@ -2677,7 +2677,7 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) int j2 = dstbpp - 1 - 2; #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint8 s0 = src[i0]; @@ -2689,14 +2689,14 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) dst += dstbpp; src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } } -/* Blit_3or4_to_3or4__inversed_rgb: 3 or 4 bpp, inversed RGB triplet */ +// Blit_3or4_to_3or4__inversed_rgb: 3 or 4 bpp, inversed RGB triplet static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) { int width = info->dst_w; @@ -2712,15 +2712,15 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) if (dstfmt->Amask) { if (srcfmt->Amask) { - /* COPY_ALPHA */ - /* Only to switch ABGR8888 <-> ARGB8888 */ + // COPY_ALPHA + // Only to switch ABGR8888 <-> ARGB8888 while (height--) { #if SDL_BYTEORDER == SDL_LIL_ENDIAN int i0 = 0, i1 = 1, i2 = 2, i3 = 3; #else int i0 = 3, i1 = 2, i2 = 1, i3 = 0; #endif - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *dst32 = (Uint32*)dst; @@ -2728,17 +2728,17 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) Uint8 s1 = src[i1]; Uint8 s2 = src[i2]; Uint32 alphashift = ((Uint32)src[i3]) << dstfmt->Ashift; - /* inversed, compared to Blit_3or4_to_3or4__same_rgb */ + // inversed, compared to Blit_3or4_to_3or4__same_rgb *dst32 = (s0 << 16) | (s1 << 8) | (s2) | alphashift; dst += 4; src += 4; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } else { - /* SET_ALPHA */ + // SET_ALPHA Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; #if SDL_BYTEORDER == SDL_LIL_ENDIAN int i0 = 0, i1 = 1, i2 = 2; @@ -2748,25 +2748,25 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) int i2 = srcbpp - 1 - 2; #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint32 *dst32 = (Uint32*)dst; Uint8 s0 = src[i0]; Uint8 s1 = src[i1]; Uint8 s2 = src[i2]; - /* inversed, compared to Blit_3or4_to_3or4__same_rgb */ + // inversed, compared to Blit_3or4_to_3or4__same_rgb *dst32 = (s0 << 16) | (s1 << 8) | (s2) | mask; dst += 4; src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } } else { - /* NO_ALPHA */ + // NO_ALPHA #if SDL_BYTEORDER == SDL_LIL_ENDIAN int i0 = 0, i1 = 1, i2 = 2; int j0 = 2, j1 = 1, j2 = 0; @@ -2779,27 +2779,27 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) int j2 = dstbpp - 1 - 0; #endif while (height--) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off DUFFS_LOOP( { Uint8 s0 = src[i0]; Uint8 s1 = src[i1]; Uint8 s2 = src[i2]; - /* inversed, compared to Blit_3or4_to_3or4__same_rgb */ + // inversed, compared to Blit_3or4_to_3or4__same_rgb dst[j0] = s0; dst[j1] = s1; dst[j2] = s2; dst += dstbpp; src += srcbpp; }, width); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on src += srcskip; dst += dstskip; } } } -/* Normal N to N optimized blitters */ +// Normal N to N optimized blitters #define NO_ALPHA 1 #define SET_ALPHA 2 #define COPY_ALPHA 4 @@ -2810,16 +2810,16 @@ struct blit_table Uint32 dstR, dstG, dstB; Uint32 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 */ + // Default for 8-bit RGB source, never optimized { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_2[] = { #ifdef SDL_ALTIVEC_BLITTERS - /* has-altivec */ + // 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, @@ -2844,12 +2844,12 @@ static const struct blit_table normal_blit_2[] = { { 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 */ + // Default for 16-bit RGB source, used if no other blitter matches { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_3[] = { - /* 3->4 with same rgb triplet */ + // 3->4 with same rgb triplet { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, 0, Blit_3or4_to_3or4__same_rgb, #if HAVE_FAST_WRITE_INT8 @@ -2862,7 +2862,7 @@ static const struct blit_table normal_blit_3[] = { NO_ALPHA | #endif SET_ALPHA }, - /* 3->4 with inversed rgb triplet */ + // 3->4 with inversed rgb triplet { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, 0, Blit_3or4_to_3or4__inversed_rgb, #if HAVE_FAST_WRITE_INT8 @@ -2875,24 +2875,24 @@ static const struct blit_table normal_blit_3[] = { NO_ALPHA | #endif SET_ALPHA }, - /* 3->3 to switch RGB 24 <-> BGR 24 */ + // 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 }, - /* Default for 24-bit RGB source, never optimized */ + // Default for 24-bit RGB source, never optimized { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; static const struct blit_table normal_blit_4[] = { #ifdef SDL_ALTIVEC_BLITTERS - /* has-altivec | dont-use-prefetch */ + // 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 }, - /* has-altivec */ + // has-altivec { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, BLIT_FEATURE_HAS_ALTIVEC, ConvertAltivec32to32_prefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, - /* has-altivec */ + // has-altivec { 0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, BLIT_FEATURE_HAS_ALTIVEC, Blit_XRGB8888_RGB565Altivec, NO_ALPHA }, #endif @@ -2900,17 +2900,17 @@ static const struct blit_table normal_blit_4[] = { { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, BLIT_FEATURE_HAS_ARM_SIMD, Blit_XBGR8888_XRGB8888ARMSIMD, NO_ALPHA | COPY_ALPHA }, #endif - /* 4->3 with same rgb triplet */ + // 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 }, - /* 4->3 with inversed rgb triplet */ + // 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 }, - /* 4->4 with inversed rgb triplet, and COPY_ALPHA to switch ABGR8888 <-> ARGB8888 */ + // 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, #if HAVE_FAST_WRITE_INT8 @@ -2923,12 +2923,12 @@ static const struct blit_table normal_blit_4[] = { NO_ALPHA | #endif SET_ALPHA | COPY_ALPHA }, - /* RGB 888 and RGB 565 */ + // RGB 888 and RGB 565 { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F, 0, Blit_XRGB8888_RGB565, NO_ALPHA }, { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F, 0, Blit_XRGB8888_RGB555, NO_ALPHA }, - /* Default for 32-bit RGB source, used if no other blitter matches */ + // Default for 32-bit RGB source, used if no other blitter matches { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } }; @@ -2936,7 +2936,7 @@ static const struct blit_table *const normal_blit[] = { normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4 }; -/* Mask matches table, or table entry is zero */ +// Mask matches table, or table entry is zero #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000)) SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) @@ -2947,11 +2947,11 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) int which; SDL_BlitFunc blitfun; - /* Set up data for choosing the blit */ + // Set up data for choosing the blit srcfmt = surface->internal->format; dstfmt = surface->internal->map.info.dst_fmt; - /* We don't support destinations less than 8-bits */ + // We don't support destinations less than 8-bits if (dstfmt->bits_per_pixel < 8) { return NULL; } @@ -2984,7 +2984,7 @@ SDL_BlitFunc 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) { @@ -2996,13 +2996,13 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) srcfmt->Bmask == dstfmt->Bmask) { if (a_need == COPY_ALPHA) { if (srcfmt->Amask == dstfmt->Amask) { - /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */ + // Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA blitfun = SDL_BlitCopy; } else { blitfun = BlitNtoNCopyAlpha; } } else { - /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */ + // Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB blitfun = Blit4to4MaskAlpha; } } else if (a_need == COPY_ALPHA) { @@ -3036,4 +3036,4 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) return NULL; } -#endif /* SDL_HAVE_BLIT_N */ +#endif // SDL_HAVE_BLIT_N diff --git a/src/video/SDL_blit_auto.c b/src/video/SDL_blit_auto.c index d039bb67a9..0964f31f60 100644 --- a/src/video/SDL_blit_auto.c +++ b/src/video/SDL_blit_auto.c @@ -1,4 +1,4 @@ -/* DO NOT EDIT! This file is generated by sdlgenblit.pl */ +// DO NOT EDIT! This file is generated by sdlgenblit.pl /* Simple DirectMedia Layer Copyright (C) 1997-2024 Sam Lantinga @@ -24,7 +24,7 @@ #if SDL_HAVE_BLIT_AUTO -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #include "SDL_blit.h" #include "SDL_blit_auto.h" @@ -11537,7 +11537,7 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { { 0, 0, 0, 0, NULL } }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on -#endif /* SDL_HAVE_BLIT_AUTO */ +#endif // SDL_HAVE_BLIT_AUTO diff --git a/src/video/SDL_blit_auto.h b/src/video/SDL_blit_auto.h index 6ffb28c93d..9d6a48fa08 100644 --- a/src/video/SDL_blit_auto.h +++ b/src/video/SDL_blit_auto.h @@ -1,4 +1,4 @@ -/* DO NOT EDIT! This file is generated by sdlgenblit.pl */ +// DO NOT EDIT! This file is generated by sdlgenblit.pl /* Simple DirectMedia Layer Copyright (C) 1997-2024 Sam Lantinga @@ -24,11 +24,11 @@ #if SDL_HAVE_BLIT_AUTO -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on -#endif /* SDL_HAVE_BLIT_AUTO */ +#endif // SDL_HAVE_BLIT_AUTO diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index bdb96b162a..a41683ae9d 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -24,7 +24,7 @@ #include "SDL_blit_copy.h" #ifdef SDL_SSE_INTRINSICS -/* This assumes 16-byte aligned src and dst */ +// This assumes 16-byte aligned src and dst static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint8 *src, int len) { int i; @@ -48,7 +48,7 @@ static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint SDL_memcpy(dst, src, len & 63); } } -#endif /* SDL_SSE_INTRINSICS */ +#endif // SDL_SSE_INTRINSICS void SDL_BlitCopy(SDL_BlitInfo *info) { @@ -64,7 +64,7 @@ void SDL_BlitCopy(SDL_BlitInfo *info) srcskip = info->src_pitch; dstskip = info->dst_pitch; - /* Properly handle overlapping blits */ + // Properly handle overlapping blits if (src < dst) { overlap = (dst < (src + h * srcskip)); } else { diff --git a/src/video/SDL_blit_copy.h b/src/video/SDL_blit_copy.h index de9311531f..6f720e030f 100644 --- a/src/video/SDL_blit_copy.h +++ b/src/video/SDL_blit_copy.h @@ -24,4 +24,4 @@ void SDL_BlitCopy(SDL_BlitInfo *info); -#endif /* SDL_blit_copy_h_ */ +#endif // SDL_blit_copy_h_ diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c index 121c911a4f..0253c24cc1 100644 --- a/src/video/SDL_blit_slow.c +++ b/src/video/SDL_blit_slow.c @@ -87,13 +87,13 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) incy = ((Uint64)info->src_h << 16) / info->dst_h; incx = ((Uint64)info->src_w << 16) / info->dst_w; - posy = incy / 2; /* start at the middle of pixel */ + posy = incy / 2; // start at the middle of pixel while (info->dst_h--) { Uint8 *src = 0; Uint8 *dst = info->dst; int n = info->dst_w; - posx = incx / 2; /* start at the middle of pixel */ + posx = incx / 2; // start at the middle of pixel srcy = posy >> 16; while (n--) { srcx = posx >> 16; @@ -136,12 +136,12 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) } break; case SlowBlitPixelAccess_Large: - /* Handled in SDL_Blit_Slow_Float() */ + // Handled in SDL_Blit_Slow_Float() break; } if (flags & SDL_COPY_COLORKEY) { - /* srcpixel isn't set for 24 bpp */ + // srcpixel isn't set for 24 bpp if (srcbpp == 3) { srcpixel = (srcR << src_fmt->Rshift) | (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); @@ -190,11 +190,11 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) } break; case SlowBlitPixelAccess_Large: - /* Handled in SDL_Blit_Slow_Float() */ + // Handled in SDL_Blit_Slow_Float() break; } } else { - /* don't care */ + // don't care } if (flags & SDL_COPY_MODULATE_COLOR) { @@ -318,7 +318,7 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) break; } case SlowBlitPixelAccess_Large: - /* Handled in SDL_Blit_Slow_Float() */ + // Handled in SDL_Blit_Slow_Float() break; } @@ -394,25 +394,25 @@ static Uint16 float_to_half(float a) ir = (ia >> 16) & 0x8000; if ((ia & 0x7f800000) == 0x7f800000) { if ((ia & 0x7fffffff) == 0x7f800000) { - ir |= 0x7c00; /* infinity */ + ir |= 0x7c00; // infinity } else { - ir |= 0x7e00 | ((ia >> (24 - 11)) & 0x1ff); /* NaN, quietened */ + ir |= 0x7e00 | ((ia >> (24 - 11)) & 0x1ff); // NaN, quietened } } else if ((ia & 0x7f800000) >= 0x33000000) { int shift = (int)((ia >> 23) & 0xff) - 127; if (shift > 15) { - ir |= 0x7c00; /* infinity */ + ir |= 0x7c00; // infinity } else { - ia = (ia & 0x007fffff) | 0x00800000; /* extract mantissa */ - if (shift < -14) { /* denormal */ + ia = (ia & 0x007fffff) | 0x00800000; // extract mantissa + if (shift < -14) { // denormal ir |= ia >> (-1 - shift); ia = ia << (32 - (-1 - shift)); - } else { /* normal */ + } else { // normal ir |= ia >> (24 - 11); ia = ia << (32 - (24 - 11)); ir = ir + ((14 + shift) << 10); } - /* IEEE-754 round to nearest of even */ + // IEEE-754 round to nearest of even if ((ia > 0x80000000) || ((ia == 0x80000000) && (ir & 1))) { ir++; } @@ -506,7 +506,7 @@ static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_ } break; default: - /* Unknown array type */ + // Unknown array type v[0] = v[1] = v[2] = v[3] = 0.0f; break; } @@ -548,14 +548,14 @@ static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_ fR = v[3]; break; default: - /* Unknown array order */ + // Unknown array order fA = fR = fG = fB = 0.0f; break; } break; } - /* Convert to nits so src and dst are guaranteed to be linear and in the same units */ + // Convert to nits so src and dst are guaranteed to be linear and in the same units switch (SDL_COLORSPACETRANSFER(colorspace)) { case SDL_TRANSFER_CHARACTERISTICS_SRGB: fR = SDL_sRGBtoLinear(fR); @@ -573,7 +573,7 @@ static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_ fB /= SDR_white_point; break; default: - /* Unknown, leave it alone */ + // Unknown, leave it alone break; } @@ -590,7 +590,7 @@ static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL Uint32 pixel; float v[4]; - /* We converted to nits so src and dst are guaranteed to be linear and in the same units */ + // We converted to nits so src and dst are guaranteed to be linear and in the same units switch (SDL_COLORSPACETRANSFER(colorspace)) { case SDL_TRANSFER_CHARACTERISTICS_SRGB: fR = SDL_sRGBfromLinear(fR); @@ -608,7 +608,7 @@ static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL fB *= SDR_white_point; break; default: - /* Unknown, leave it alone */ + // Unknown, leave it alone break; } @@ -691,7 +691,7 @@ static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL v[3] = fR; break; default: - /* Unknown array order */ + // Unknown array order v[0] = v[1] = v[2] = v[3] = 0.0f; break; } @@ -721,7 +721,7 @@ static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL } break; default: - /* Unknown array type */ + // Unknown array type break; } break; @@ -849,7 +849,7 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info) src_headroom = SDL_GetSurfaceHDRHeadroom(info->src_surface, src_colorspace); dst_headroom = SDL_GetSurfaceHDRHeadroom(info->dst_surface, dst_colorspace); if (dst_headroom == 0.0f) { - /* The destination will have the same headroom as the source */ + // The destination will have the same headroom as the source dst_headroom = src_headroom; SDL_SetFloatProperty(SDL_GetSurfaceProperties(info->dst_surface), SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, dst_headroom); } @@ -874,7 +874,7 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info) tonemap.data.chrome.a = (dst_headroom / (src_headroom * src_headroom)); tonemap.data.chrome.b = (1.0f / dst_headroom); - /* We'll convert to BT.2020 primaries for the tonemap operation */ + // We'll convert to BT.2020 primaries for the tonemap operation tonemap.data.chrome.color_primaries_matrix = SDL_GetColorPrimariesConversionMatrix(src_primaries, SDL_COLOR_PRIMARIES_BT2020); if (tonemap.data.chrome.color_primaries_matrix) { src_primaries = SDL_COLOR_PRIMARIES_BT2020; @@ -894,13 +894,13 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info) incy = ((Uint64)info->src_h << 16) / info->dst_h; incx = ((Uint64)info->src_w << 16) / info->dst_w; - posy = incy / 2; /* start at the middle of pixel */ + posy = incy / 2; // start at the middle of pixel while (info->dst_h--) { Uint8 *src = 0; Uint8 *dst = info->dst; int n = info->dst_w; - posx = incx / 2; /* start at the middle of pixel */ + posx = incx / 2; // start at the middle of pixel srcy = posy >> 16; while (n--) { srcx = posx >> 16; @@ -917,12 +917,12 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info) } if (flags & SDL_COPY_COLORKEY) { - /* colorkey isn't supported */ + // colorkey isn't supported } if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { ReadFloatPixel(dst, dst_access, dst_fmt, dst_pal, dst_colorspace, dst_white_point, &dstR, &dstG, &dstB, &dstA); } else { - /* don't care */ + // don't care dstR = dstG = dstB = dstA = 0.0f; } diff --git a/src/video/SDL_blit_slow.h b/src/video/SDL_blit_slow.h index 3dc63084ae..4f98367c47 100644 --- a/src/video/SDL_blit_slow.h +++ b/src/video/SDL_blit_slow.h @@ -27,4 +27,4 @@ extern void SDL_Blit_Slow(SDL_BlitInfo *info); extern void SDL_Blit_Slow_Float(SDL_BlitInfo *info); -#endif /* SDL_blit_slow_h_ */ +#endif // SDL_blit_slow_h_ diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 1f52862033..7e4fa85b9d 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -36,7 +36,7 @@ #define SAVE_32BIT_BMP -/* Compression encodings for BMP files */ +// Compression encodings for BMP files #ifndef BI_RGB #define BI_RGB 0 #define BI_RLE8 1 @@ -44,9 +44,9 @@ #define BI_BITFIELDS 3 #endif -/* Logical color space values for BMP files */ +// Logical color space values for BMP files #ifndef LCS_WINDOWS_COLOR_SPACE -/* 0x57696E20 == "Win " */ +// 0x57696E20 == "Win " #define LCS_WINDOWS_COLOR_SPACE 0x57696E20 #endif @@ -69,7 +69,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle if (spot >= start && spot < end) \ *spot = (x) - /* !!! FIXME: for all these reads, handle error vs eof? handle -2 if non-blocking? */ + // !!! FIXME: for all these reads, handle error vs eof? handle -2 if non-blocking? for (;;) { if (!SDL_ReadU8(src, &ch)) { return SDL_TRUE; @@ -83,19 +83,19 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle if (!SDL_ReadU8(src, &pixel)) { 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 */ + COPY_PIXEL(pixel0); // even count, high nibble if (!--ch) { break; } - COPY_PIXEL(pixel1); /* odd count, low nibble */ + COPY_PIXEL(pixel1); // odd count, low nibble if (!--ch) { break; } @@ -111,13 +111,13 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle 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_ReadU8(src, &ch)) { return SDL_TRUE; } @@ -127,7 +127,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle } bits -= (ch * pitch); break; - default: /* no compression */ + default: // no compression if (isRle8) { needsPad = (ch & 1); do { @@ -138,7 +138,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle 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_ReadU8(src, &pixel)) { @@ -154,7 +154,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle } } } - /* pad at even boundary */ + // pad at even boundary if (needsPad && !SDL_ReadU8(src, &ch)) { return SDL_TRUE; } @@ -166,7 +166,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle static void CorrectAlphaChannel(SDL_Surface *surface) { - /* Check to see if there is any alpha channel data */ + // Check to see if there is any alpha channel data SDL_bool hasAlpha = SDL_FALSE; #if SDL_BYTEORDER == SDL_BIG_ENDIAN int alphaChannelOffset = 0; @@ -210,34 +210,34 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) SDL_bool haveAlphaMask = SDL_FALSE; SDL_bool correctAlpha = SDL_FALSE; - /* The Win32 BMP file header (14 bytes) */ + // The Win32 BMP file header (14 bytes) char magic[2]; - /* Uint32 bfSize; */ - /* Uint16 bfReserved1; */ - /* Uint16 bfReserved2; */ + // Uint32 bfSize; + // Uint16 bfReserved1; + // Uint16 bfReserved2; Uint32 bfOffBits; - /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ + // The Win32 BITMAPINFOHEADER struct (40 bytes) Uint32 biSize; Sint32 biWidth = 0; Sint32 biHeight = 0; - /* Uint16 biPlanes; */ + // Uint16 biPlanes; Uint16 biBitCount = 0; Uint32 biCompression = 0; - /* Uint32 biSizeImage; */ - /* Sint32 biXPelsPerMeter; */ - /* Sint32 biYPelsPerMeter; */ + // Uint32 biSizeImage; + // Sint32 biXPelsPerMeter; + // Sint32 biYPelsPerMeter; Uint32 biClrUsed = 0; - /* Uint32 biClrImportant; */ + // Uint32 biClrImportant; - /* Make sure we are passed a valid data source */ + // Make sure we are passed a valid data source surface = NULL; if (!src) { SDL_InvalidParamError("src"); goto done; } - /* Read in the BMP file header */ + // Read in the BMP file header fp_offset = SDL_TellIO(src); if (fp_offset < 0) { goto done; @@ -257,11 +257,11 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) goto done; } - /* Read the Win32 BITMAPINFOHEADER */ + // Read the Win32 BITMAPINFOHEADER if (!SDL_ReadU32LE(src, &biSize)) { goto done; } - if (biSize == 12) { /* really old BITMAPCOREHEADER */ + if (biSize == 12) { // really old BITMAPCOREHEADER Uint16 biWidth16, biHeight16; if (!SDL_ReadU16LE(src, &biWidth16) || !SDL_ReadU16LE(src, &biHeight16) || @@ -272,12 +272,12 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) biWidth = biWidth16; biHeight = biHeight16; biCompression = BI_RGB; - /* biSizeImage = 0; */ - /* biXPelsPerMeter = 0; */ - /* biYPelsPerMeter = 0; */ + // biSizeImage = 0; + // biXPelsPerMeter = 0; + // biYPelsPerMeter = 0; biClrUsed = 0; - /* biClrImportant = 0; */ - } else if (biSize >= 40) { /* some version of BITMAPINFOHEADER */ + // biClrImportant = 0; + } else if (biSize >= 40) { // some version of BITMAPINFOHEADER Uint32 headerSize; if (!SDL_ReadS32LE(src, &biWidth) || !SDL_ReadS32LE(src, &biHeight) || @@ -292,7 +292,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) goto done; } - /* 64 == BITMAPCOREHEADER2, an incompatible OS/2 2.x extension. Skip this stuff for now. */ + // 64 == BITMAPCOREHEADER2, an incompatible OS/2 2.x extension. Skip this stuff for now. if (biSize != 64) { /* This is complicated. If compression is BI_BITFIELDS, then we have 3 DWORDS that specify the RGB masks. This is either @@ -309,23 +309,23 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) goto done; } - /* ...v3 adds an alpha mask. */ - if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ + // ...v3 adds an alpha mask. + if (biSize >= 56) { // BITMAPV3INFOHEADER; adds alpha mask haveAlphaMask = SDL_TRUE; if (!SDL_ReadU32LE(src, &Amask)) { goto done; } } } else { - /* the mask fields are ignored for v2+ headers if not BI_BITFIELD. */ - if (biSize >= 52) { /* BITMAPV2INFOHEADER; adds RGB masks */ + // the mask fields are ignored for v2+ headers if not BI_BITFIELD. + if (biSize >= 52) { // BITMAPV2INFOHEADER; adds RGB masks if (!SDL_ReadU32LE(src, NULL /* Rmask */) || !SDL_ReadU32LE(src, NULL /* Gmask */) || !SDL_ReadU32LE(src, NULL /* Bmask */)) { goto done; } } - if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */ + if (biSize >= 56) { // BITMAPV3INFOHEADER; adds alpha mask if (!SDL_ReadU32LE(src, NULL /* Amask */)) { goto done; } @@ -338,7 +338,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) currently parse up to v3 correctly (hopefully!). */ } - /* skip any header bytes we didn't handle... */ + // skip any header bytes we didn't handle... headerSize = (Uint32)(SDL_TellIO(src) - (fp_offset + 14)); if (biSize > headerSize) { if (SDL_SeekIO(src, (biSize - headerSize), SDL_IO_SEEK_CUR) < 0) { @@ -357,12 +357,12 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) topDown = SDL_FALSE; } - /* Check for read error */ + // Check for read error if (SDL_strcmp(SDL_GetError(), "") != 0) { goto done; } - /* Reject invalid bit depths */ + // Reject invalid bit depths switch (biBitCount) { case 0: case 3: @@ -375,38 +375,38 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) break; } - /* RLE4 and RLE8 BMP compression is supported */ + // RLE4 and RLE8 BMP compression is supported switch (biCompression) { case BI_RGB: - /* If there are no masks, use the defaults */ + // If there are no masks, use the defaults SDL_assert(!haveRGBMasks); SDL_assert(!haveAlphaMask); - /* Default values for the BMP format */ + // Default values for the BMP format switch (biBitCount) { case 15: case 16: - /* SDL_PIXELFORMAT_XRGB1555 or SDL_PIXELFORMAT_ARGB1555 if Amask */ + // SDL_PIXELFORMAT_XRGB1555 or SDL_PIXELFORMAT_ARGB1555 if Amask Rmask = 0x7C00; Gmask = 0x03E0; Bmask = 0x001F; break; case 24: #if SDL_BYTEORDER == SDL_BIG_ENDIAN - /* SDL_PIXELFORMAT_RGB24 */ + // SDL_PIXELFORMAT_RGB24 Rmask = 0x000000FF; Gmask = 0x0000FF00; Bmask = 0x00FF0000; #else - /* SDL_PIXELFORMAT_BGR24 */ + // SDL_PIXELFORMAT_BGR24 Rmask = 0x00FF0000; Gmask = 0x0000FF00; Bmask = 0x000000FF; #endif break; case 32: - /* We don't know if this has alpha channel or not */ + // We don't know if this has alpha channel or not correctAlpha = SDL_TRUE; - /* SDL_PIXELFORMAT_RGBA8888 */ + // SDL_PIXELFORMAT_RGBA8888 Amask = 0xFF000000; Rmask = 0x00FF0000; Gmask = 0x0000FF00; @@ -418,17 +418,17 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) break; case BI_BITFIELDS: - break; /* we handled this in the info header. */ + break; // we handled this in the info header. default: break; } - /* Create a compatible surface, note that the colors are RGB ordered */ + // Create a compatible surface, note that the colors are RGB ordered { SDL_PixelFormat format; - /* Get the pixel format */ + // Get the pixel format format = SDL_GetPixelFormatForMasks(biBitCount, Rmask, Gmask, Bmask, Amask); surface = SDL_CreateSurface(biWidth, biHeight, format); @@ -437,7 +437,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) } } - /* Load the palette, if any */ + // Load the palette, if any if (SDL_ISPIXELFORMAT_INDEXED(surface->format)) { SDL_Palette *palette = SDL_CreateSurfacePalette(surface); if (!palette) { @@ -449,7 +449,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) 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"); goto done; } @@ -459,7 +459,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) } 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"); goto done; @@ -494,7 +494,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) } } - /* Read the surface pixels. Note that the bmp image is upside down */ + // Read the surface pixels. Note that the bmp image is upside down if (SDL_SeekIO(src, fp_offset + bfOffBits, SDL_IO_SEEK_SET) < 0) { SDL_SetError("Error seeking in datastream"); goto done; @@ -551,7 +551,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) } #endif - /* Skip padding bytes, ugh */ + // Skip padding bytes, ugh if (pad) { Uint8 padbyte; for (i = 0; i < pad; ++i) { @@ -601,14 +601,14 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) SDL_bool save32bit = SDL_FALSE; SDL_bool saveLegacyBMP = SDL_FALSE; - /* The Win32 BMP file header (14 bytes) */ + // The Win32 BMP file header (14 bytes) char magic[2] = { 'B', 'M' }; Uint32 bfSize; Uint16 bfReserved1; Uint16 bfReserved2; Uint32 bfOffBits; - /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ + // The Win32 BITMAPINFOHEADER struct (40 bytes) Uint32 biSize; Sint32 biWidth; Sint32 biHeight; @@ -621,7 +621,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) Uint32 biClrUsed; Uint32 biClrImportant; - /* The additional header members from the Win32 BITMAPV4HEADER struct (108 bytes in total) */ + // The additional header members from the Win32 BITMAPV4HEADER struct (108 bytes in total) Uint32 bV4RedMask = 0; Uint32 bV4GreenMask = 0; Uint32 bV4BlueMask = 0; @@ -632,7 +632,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) Uint32 bV4GammaGreen = 0; Uint32 bV4GammaBlue = 0; - /* Make sure we have somewhere to save */ + // Make sure we have somewhere to save intermediate_surface = NULL; if (dst) { if (!SDL_SurfaceValid(surface)) { @@ -641,13 +641,13 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } #ifdef SAVE_32BIT_BMP - /* We can save alpha information in a 32-bit BMP */ + // We can save alpha information in a 32-bit BMP if (SDL_BITSPERPIXEL(surface->format) >= 8 && (SDL_ISPIXELFORMAT_ALPHA(surface->format) || surface->internal->map.info.flags & SDL_COPY_COLORKEY)) { save32bit = SDL_TRUE; } -#endif /* SAVE_32BIT_BMP */ +#endif // SAVE_32BIT_BMP if (surface->internal->palette && !save32bit) { if (SDL_BITSPERPIXEL(surface->format) == 8) { @@ -699,13 +699,13 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) if (SDL_LockSurface(intermediate_surface) == 0) { const size_t bw = intermediate_surface->w * intermediate_surface->internal->format->bytes_per_pixel; - /* Set the BMP file header values */ - bfSize = 0; /* We'll write this when we're done */ + // Set the BMP file header values + 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 */ + // Write the BMP file header values fp_offset = SDL_TellIO(dst); if (fp_offset < 0) { goto done; @@ -718,7 +718,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) goto done; } - /* Set the BMP info values */ + // Set the BMP info values biSize = 40; biWidth = intermediate_surface->w; biHeight = intermediate_surface->h; @@ -735,11 +735,11 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } biClrImportant = 0; - /* Set the BMP info values for the version 4 header */ + // Set the BMP info values for the version 4 header if (save32bit && !saveLegacyBMP) { biSize = 108; biCompression = BI_BITFIELDS; - /* The BMP format is always little endian, these masks stay the same */ + // The BMP format is always little endian, these masks stay the same bV4RedMask = 0x00ff0000; bV4GreenMask = 0x0000ff00; bV4BlueMask = 0x000000ff; @@ -750,7 +750,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) bV4GammaBlue = 0; } - /* Write the BMP info values */ + // Write the BMP info values if (!SDL_WriteU32LE(dst, biSize) || !SDL_WriteS32LE(dst, biWidth) || !SDL_WriteS32LE(dst, biHeight) || @@ -765,7 +765,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) goto done; } - /* Write the BMP info values for the version 4 header */ + // Write the BMP info values for the version 4 header if (save32bit && !saveLegacyBMP) { if (!SDL_WriteU32LE(dst, bV4RedMask) || !SDL_WriteU32LE(dst, bV4GreenMask) || @@ -786,7 +786,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } } - /* Write the palette (in BGR color order) */ + // Write the palette (in BGR color order) if (intermediate_surface->internal->palette) { SDL_Color *colors; int ncolors; @@ -803,7 +803,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } } - /* Write the bitmap offset */ + // Write the bitmap offset bfOffBits = (Uint32)(SDL_TellIO(dst) - fp_offset); if (SDL_SeekIO(dst, fp_offset + 10, SDL_IO_SEEK_SET) < 0) { goto done; @@ -815,7 +815,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) goto done; } - /* Write the bitmap image upside down */ + // Write the bitmap image upside down bits = (Uint8 *)intermediate_surface->pixels + (intermediate_surface->h * intermediate_surface->pitch); pad = ((bw % 4) ? (4 - (bw % 4)) : 0); while (bits > (Uint8 *)intermediate_surface->pixels) { @@ -833,7 +833,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } } - /* Write the BMP file size */ + // Write the BMP file size new_offset = SDL_TellIO(dst); if (new_offset < 0) { goto done; @@ -849,7 +849,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) goto done; } - /* Close it up.. */ + // Close it up.. SDL_UnlockSurface(intermediate_surface); was_error = SDL_FALSE; diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index 559747e766..e26c0a2011 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -31,7 +31,7 @@ void SDL_CancelClipboardData(Uint32 sequence) size_t i; if (sequence != _this->clipboard_sequence) { - /* This clipboard data was already canceled */ + // This clipboard data was already canceled return; } @@ -62,14 +62,14 @@ int SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanu return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } - /* Parameter validation */ + // Parameter validation if (!((callback && mime_types && num_mime_types > 0) || (!callback && !mime_types && num_mime_types == 0))) { return SDL_SetError("Invalid parameters"); } if (!callback && !_this->clipboard_callback) { - /* Nothing to do, don't modify the system clipboard */ + // Nothing to do, don't modify the system clipboard return 0; } @@ -151,7 +151,7 @@ void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type if (_this->clipboard_callback) { const void *provided_data = _this->clipboard_callback(_this->clipboard_userdata, mime_type, size); if (provided_data) { - /* Make a copy of it for the caller and guarantee null termination */ + // Make a copy of it for the caller and guarantee null termination data = SDL_malloc(*size + sizeof(Uint32)); if (data) { SDL_memcpy(data, provided_data, *size); @@ -180,7 +180,7 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size) return NULL; } - /* Initialize size to empty, so implementations don't have to worry about it */ + // Initialize size to empty, so implementations don't have to worry about it *size = 0; if (_this->GetClipboardData) { @@ -232,7 +232,7 @@ SDL_bool SDL_HasClipboardData(const char *mime_type) } } -/* Clipboard text */ +// Clipboard text SDL_bool SDL_IsTextMimeType(const char *mime_type) { @@ -330,7 +330,7 @@ SDL_bool SDL_HasClipboardText(void) return SDL_FALSE; } -/* Primary selection text */ +// Primary selection text int SDL_SetPrimarySelectionText(const char *text) { diff --git a/src/video/SDL_clipboard_c.h b/src/video/SDL_clipboard_c.h index acab36f96e..5347fc8307 100644 --- a/src/video/SDL_clipboard_c.h +++ b/src/video/SDL_clipboard_c.h @@ -26,17 +26,17 @@ #include "SDL_sysvideo.h" -/* Return true if the mime type is valid clipboard text */ +// Return true if the mime type is valid clipboard text extern SDL_bool SDL_IsTextMimeType(const char *mime_type); -/* Cancel the clipboard data callback, called internally for cleanup */ +// Cancel the clipboard data callback, called internally for cleanup extern void SDL_CancelClipboardData(Uint32 sequence); -/* Call the clipboard callback for application data */ +// Call the clipboard callback for application data extern void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); extern SDL_bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type); -/* General purpose clipboard text callback */ +// General purpose clipboard text callback const void * SDLCALL SDL_ClipboardTextCallback(void *userdata, const char *mime_type, size_t *size); -#endif /* SDL_clipboard_c_h_ */ +#endif // SDL_clipboard_c_h_ diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 1c0737379c..bd7373cfcc 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -40,11 +40,11 @@ #include "SDL_egl_c.h" #ifdef EGL_KHR_create_context -/* EGL_OPENGL_ES3_BIT_KHR was added in version 13 of the extension. */ +// EGL_OPENGL_ES3_BIT_KHR was added in version 13 of the extension. #ifndef EGL_OPENGL_ES3_BIT_KHR #define EGL_OPENGL_ES3_BIT_KHR 0x00000040 #endif -#endif /* EGL_KHR_create_context */ +#endif // EGL_KHR_create_context #ifndef EGL_EXT_pixel_format_float #define EGL_EXT_pixel_format_float @@ -56,10 +56,10 @@ #ifndef EGL_EXT_present_opaque #define EGL_EXT_present_opaque 1 #define EGL_PRESENT_OPAQUE_EXT 0x31DF -#endif /* EGL_EXT_present_opaque */ +#endif // EGL_EXT_present_opaque #ifdef SDL_VIDEO_DRIVER_RPI -/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */ +// 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" @@ -68,14 +68,14 @@ #define DEFAULT_OGL_ES (vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so") #elif defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_VIVANTE) -/* Android */ +// Android #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" #elif defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) -/* EGL AND OpenGL ES support via ANGLE */ +// EGL AND OpenGL ES support via ANGLE #define DEFAULT_EGL "libEGL.dll" #define DEFAULT_OGL "opengl32.dll" #define DEFAULT_OGL_ES2 "libGLESv2.dll" @@ -83,14 +83,14 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.dll" #elif defined(SDL_VIDEO_DRIVER_COCOA) -/* EGL AND OpenGL ES support via ANGLE */ +// EGL AND OpenGL ES support via ANGLE #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" //??? #elif defined(SDL_PLATFORM_OPENBSD) -/* OpenBSD */ +// OpenBSD #define DEFAULT_OGL "libGL.so" #define DEFAULT_EGL "libEGL.so" #define DEFAULT_OGL_ES2 "libGLESv2.so" @@ -98,14 +98,14 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.so" #else -/* Desktop Linux/Unix-like */ +// 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_ES_PVR "libGLES_CM.so.1" #define DEFAULT_OGL_ES "libGLESv1_CM.so.1" -#endif /* SDL_VIDEO_DRIVER_RPI */ +#endif // SDL_VIDEO_DRIVER_RPI #if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_VITA_PVR_OGL) #include @@ -133,7 +133,7 @@ typedef void (APIENTRY* PFNGLGETINTEGERVPROC) (GLenum pname, GLint * params); } #endif -/* it is allowed to not have some of the EGL extensions on start - attempts to use them will fail later. */ +// it is allowed to not have some of the EGL extensions on start - attempts to use them will fail later. #define LOAD_FUNC_EGLEXT(TYPE, NAME) \ _this->egl_data->NAME = (TYPE)_this->egl_data->eglGetProcAddress(#NAME); @@ -167,14 +167,14 @@ int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint 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. */ + // An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. (void)SDL_snprintf(altErrorText, SDL_arraysize(altErrorText), "0x%x", (unsigned int)eglErrorCode); errorText = altErrorText; } return SDL_SetError("%s (call to %s failed, reporting an error of %s)", message, eglFunctionName, errorText); } -/* EGL implementation of SDL OpenGL ES support */ +// EGL implementation of SDL OpenGL ES support SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext) { @@ -183,9 +183,9 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type const char *egl_extstr; const char *ext_start; - /* Invalid extensions can be rejected early */ + // Invalid extensions can be rejected early if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { - /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */ + // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); return SDL_FALSE; } @@ -219,7 +219,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type egl_extstr = _this->egl_data->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); break; default: - /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid extension type"); */ + // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid extension type"); return SDL_FALSE; } @@ -231,13 +231,13 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type if (!ext_start) { return SDL_FALSE; } - /* Check if the match is not just a substring of one of the extensions */ + // Check if the match is not just a substring of one of the extensions if (ext_start == egl_extstr || *(ext_start - 1) == ' ') { if (ext_start[ext_len] == ' ' || ext_start[ext_len] == 0) { return SDL_TRUE; } } - /* If the search stopped in the middle of an extension, skip to the end of it */ + // If the search stopped in the middle of an extension, skip to the end of it ext_start += ext_len; while (*ext_start != ' ' && *ext_start != 0) { ext_start++; @@ -255,19 +255,19 @@ SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const 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. */ + // EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } -#if !defined(SDL_PLATFORM_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 !defined(SDL_PLATFORM_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) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); } #endif - /* Try eglGetProcAddress if we're on <= 1.4 and still searching... */ + // Try eglGetProcAddress if we're on <= 1.4 and still searching... if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } @@ -318,7 +318,7 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p } } else { if (WIN_IsWindowsVistaOrGreater()) { - /* Try the newer d3d compilers first */ + // Try the newer d3d compilers first const char *d3dcompiler_list[] = { "d3dcompiler_47.dll", "d3dcompiler_46.dll", @@ -396,7 +396,7 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p if (egl_path) { egl_dll_handle = SDL_LoadObject(egl_path); } - /* Try loading a EGL symbol, if it does not work try the default library paths */ + // Try loading a EGL symbol, if it does not work try the default library paths if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); @@ -429,7 +429,7 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p _this->egl_data->opengl_dll_handle = opengl_dll_handle; #endif - /* Load new function pointers */ + // Load new function pointers LOAD_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); LOAD_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); LOAD_FUNC(PFNEGLTERMINATEPROC, eglTerminate); @@ -451,13 +451,13 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p LOAD_FUNC(PFNEGLGETERRORPROC, eglGetError); LOAD_FUNC_EGLEXT(PFNEGLQUERYDEVICESEXTPROC, eglQueryDevicesEXT); LOAD_FUNC_EGLEXT(PFNEGLGETPLATFORMDISPLAYEXTPROC, eglGetPlatformDisplayEXT); - /* Atomic functions */ + // Atomic functions LOAD_FUNC_EGLEXT(PFNEGLCREATESYNCKHRPROC, eglCreateSyncKHR); LOAD_FUNC_EGLEXT(PFNEGLDESTROYSYNCKHRPROC, eglDestroySyncKHR); LOAD_FUNC_EGLEXT(PFNEGLDUPNATIVEFENCEFDANDROIDPROC, eglDupNativeFenceFDANDROID); LOAD_FUNC_EGLEXT(PFNEGLWAITSYNCKHRPROC, eglWaitSyncKHR); LOAD_FUNC_EGLEXT(PFNEGLCLIENTWAITSYNCKHRPROC, eglClientWaitSyncKHR); - /* Atomic functions end */ + // Atomic functions end if (path) { SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1); @@ -548,7 +548,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp } } #endif - /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */ + // Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay) && SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK, SDL_TRUE)) { @@ -567,7 +567,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp } #endif - /* Get the EGL version with a valid egl_display, for EGL <= 1.4 */ + // Get the EGL version with a valid egl_display, for EGL <= 1.4 SDL_EGL_GetVersion(_this); _this->egl_data->is_offscreen = SDL_FALSE; @@ -593,7 +593,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) return SDL_SetError("SDL_EGL_LoadLibraryOnly() has not been called or has failed."); } - /* Check for all extensions that are optional until used and fail if any is missing */ + // Check for all extensions that are optional until used and fail if any is missing if (!_this->egl_data->eglQueryDevicesEXT) { return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)"); } @@ -628,7 +628,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) SDL_bool found = SDL_FALSE; EGLDisplay attempted_egl_display; - /* If no hint is provided lets look for the first device/display that will allow us to eglInit */ + // If no hint is provided lets look for the first device/display that will allow us to eglInit for (i = 0; i < num_egl_devices; i++) { attempted_egl_display = _this->egl_data->eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, egl_devices[i], NULL); @@ -641,7 +641,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) continue; } - /* We did not fail, we'll pick this one! */ + // We did not fail, we'll pick this one! _this->egl_data->egl_display = attempted_egl_display; found = SDL_TRUE; @@ -653,7 +653,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) } } - /* Get the EGL version with a valid egl_display, for EGL <= 1.4 */ + // Get the EGL version with a valid egl_display, for EGL <= 1.4 SDL_EGL_GetVersion(_this); _this->egl_data->is_offscreen = SDL_TRUE; @@ -725,20 +725,20 @@ static void dumpconfig(SDL_VideoDevice *_this, EGLConfig config) } } -#endif /* DUMP_EGL_CONFIG */ +#endif // DUMP_EGL_CONFIG static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_config_caveat_none) { - /* 64 seems nice. */ + // 64 seems nice. EGLint attribs[64]; EGLint found_configs = 0, value; - /* 128 seems even nicer here */ + // 128 seems even nicer here EGLConfig configs[128]; SDL_bool has_matching_format = SDL_FALSE; int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1; int truecolor_config_idx = -1; - /* Get a valid EGL configuration */ + // Get a valid EGL configuration i = 0; attribs[i++] = EGL_RED_SIZE; attribs[i++] = _this->gl_config.red_size; @@ -828,7 +828,7 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf return -1; } - /* first ensure that a found config has a matching format, or the function will fall through. */ + // 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++) { EGLint format; @@ -842,8 +842,8 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf } } - /* 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 */ + // 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++) { SDL_bool is_truecolor = SDL_FALSE; @@ -882,7 +882,7 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf 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 */ + bitdiff += value - attribs[j + 1]; // value is always >= attrib } } @@ -933,13 +933,13 @@ int SDL_EGL_ChooseConfig(SDL_VideoDevice *_this) return SDL_SetError("EGL not initialized"); } - /* Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG */ + // Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG ret = SDL_EGL_PrivateChooseConfig(_this, SDL_TRUE); if (ret == 0) { return 0; } - /* Fallback with all configs */ + // Fallback with all configs ret = SDL_EGL_PrivateChooseConfig(_this, SDL_FALSE); if (ret == 0) { SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config"); @@ -951,7 +951,7 @@ int SDL_EGL_ChooseConfig(SDL_VideoDevice *_this) SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surface) { - /* max 16 key+value pairs plus terminator. */ + // max 16 key+value pairs plus terminator. EGLint attribs[33]; int attr = 0; @@ -982,13 +982,13 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa int egl_version_minor = _this->egl_data->egl_version_minor; if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) && !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) { - /* SDL profile bits match EGL profile bits. */ + // SDL profile bits match EGL profile bits. _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG; } } #endif - /* Set the context version and other attributes. */ + // Set the context version and other attributes. if ((major_version < 3 || (minor_version == 0 && profile_es)) && _this->gl_config.flags == 0 && (profile_mask == 0 || profile_es)) { @@ -1013,19 +1013,19 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR; attribs[attr++] = minor_version; - /* SDL profile bits match EGL profile bits. */ + // SDL profile bits match EGL profile bits. if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { attribs[attr++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR; attribs[attr++] = profile_mask; } - /* SDL flags match EGL flags. */ + // SDL flags match EGL flags. if (_this->gl_config.flags != 0) { attribs[attr++] = EGL_CONTEXT_FLAGS_KHR; attribs[attr++] = _this->gl_config.flags; } } else -#endif /* EGL_KHR_create_context */ +#endif // EGL_KHR_create_context { SDL_SetError("Could not create EGL context (context attributes are not supported)"); return NULL; @@ -1066,7 +1066,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa attribs[attr++] = EGL_NONE; - /* Bind the API */ + // Bind the API if (profile_es) { _this->egl_data->apitype = EGL_OPENGL_ES_API; } else { @@ -1086,7 +1086,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa _this->egl_data->egl_swapinterval = 0; if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) { - /* Delete the context */ + // Delete the context SDL_EGL_DeleteContext(_this, egl_context); return NULL; } @@ -1097,7 +1097,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa 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")) { - /* Secondary condition: The client API must support it. */ + // Secondary condition: The client API must support it. if (profile_es) { /* On OpenGL ES, the GL_OES_surfaceless_context extension must be * present. */ @@ -1106,7 +1106,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa } #if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_DRIVER_VITA) } else { - /* Desktop OpenGL supports it by default from version 3.0 on. */ + // Desktop OpenGL supports it by default from version 3.0 on. PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); if (glGetIntegervFunc) { GLint v = 0; @@ -1132,14 +1132,14 @@ int SDL_EGL_MakeCurrent(SDL_VideoDevice *_this, EGLSurface egl_surface, SDL_GLCo if (!_this->egl_data->eglMakeCurrent) { if (!egl_surface && !context) { - /* Can't do the nothing there is to do? Probably trying to cleanup a failed startup, just return. */ + // 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. } } - /* Make sure current thread has a valid API bound to it. */ + // Make sure current thread has a valid API bound to it. if (_this->egl_data->eglBindAPI) { _this->egl_data->eglBindAPI(_this->egl_data->apitype); } @@ -1205,7 +1205,7 @@ int SDL_EGL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) { EGLContext egl_context = (EGLContext)context; - /* Clean up GLES and EGL */ + // Clean up GLES and EGL if (!_this->egl_data) { return 0; } @@ -1222,7 +1222,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat EGLint format_wanted; EGLint format_got; #endif - /* max 16 key+value pairs, plus terminator. */ + // max 16 key+value pairs, plus terminator. EGLint attribs[33]; int attr = 0; @@ -1239,7 +1239,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat _this->egl_data->egl_config, EGL_NATIVE_VISUAL_ID, &format_wanted); - /* Format based on selected egl config. */ + // Format based on selected egl config. ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted); #endif @@ -1340,4 +1340,4 @@ void SDL_EGL_DestroySurface(SDL_VideoDevice *_this, EGLSurface egl_surface) } } -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index 7477553b20..4817ed47ed 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -31,7 +31,7 @@ #define SDL_EGL_MAX_DEVICES 8 -/* For systems that don't define these */ +// For systems that don't define these typedef intptr_t EGLAttrib; typedef void *EGLDeviceEXT; typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); @@ -71,8 +71,8 @@ typedef struct SDL_EGL_VideoData int egl_surfacetype; int egl_version_major, egl_version_minor; EGLint egl_required_visual_id; - SDL_bool is_offscreen; /* whether EGL display was offscreen */ - EGLenum apitype; /* EGL_OPENGL_ES_API, EGL_OPENGL_API, etc */ + SDL_bool is_offscreen; // whether EGL display was offscreen + EGLenum apitype; // EGL_OPENGL_ES_API, EGL_OPENGL_API, etc PFNEGLGETDISPLAYPROC eglGetDisplay; PFNEGLINITIALIZEPROC eglInitialize; @@ -97,17 +97,17 @@ typedef struct SDL_EGL_VideoData PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplay; PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; - /* Atomic functions */ + // Atomic functions PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR; PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID; PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR; PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR; - /* Atomic functions end */ + // Atomic functions end } SDL_EGL_VideoData; -/* OpenGLES functions */ +// OpenGLES functions typedef enum SDL_EGL_ExtensionType { SDL_EGL_DISPLAY_EXTENSION, @@ -133,19 +133,19 @@ extern EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *wind extern void SDL_EGL_DestroySurface(SDL_VideoDevice *_this, EGLSurface egl_surface); extern EGLSurface SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height); -/* Assumes that LoadLibraryOnly() has succeeded */ +// Assumes that LoadLibraryOnly() has succeeded extern int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device); -/* These need to be wrapped to get the surface for the window by the platform GLES implementation */ +// These need to be wrapped to get the surface for the window by the platform GLES implementation extern SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surface); extern int SDL_EGL_MakeCurrent(SDL_VideoDevice *_this, EGLSurface egl_surface, SDL_GLContext context); extern int SDL_EGL_SwapBuffers(SDL_VideoDevice *_this, EGLSurface egl_surface); -/* SDL Error-reporting */ +// SDL Error-reporting 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 */ +// A few of useful macros #define SDL_EGL_SwapWindow_impl(BACKEND) \ int BACKEND##_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) \ @@ -165,6 +165,6 @@ extern int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, return SDL_EGL_CreateContext(_this, window->internal->egl_surface); \ } -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL -#endif /* SDL_egl_h_ */ +#endif // SDL_egl_h_ diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index f0eb67d108..3f53a2fea8 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -23,7 +23,7 @@ #include "SDL_blit.h" #ifdef SDL_SSE_INTRINSICS -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #if defined(_MSC_VER) && !defined(__clang__) #define SSE_BEGIN \ @@ -119,12 +119,12 @@ static void SDL_TARGETING("sse") SDL_FillSurfaceRect1SSE(Uint8 *pixels, int pitc SSE_END; } -/* DEFINE_SSE_FILLRECT(1, Uint8) */ +// DEFINE_SSE_FILLRECT(1, Uint8) DEFINE_SSE_FILLRECT(2, Uint16) DEFINE_SSE_FILLRECT(4, Uint32) -/* *INDENT-ON* */ /* clang-format on */ -#endif /* __SSE__ */ +/* *INDENT-ON* */ // clang-format on +#endif // __SSE__ static void SDL_FillSurfaceRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { @@ -235,10 +235,10 @@ int SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) return SDL_InvalidParamError("SDL_FillSurfaceRect(): dst"); } - /* If 'rect' == NULL, then fill the whole surface */ + // If 'rect' == NULL, then fill the whole surface if (!rect) { rect = &dst->internal->clip_rect; - /* Don't attempt to fill if the surface's clip_rect is empty */ + // Don't attempt to fill if the surface's clip_rect is empty if (SDL_RectEmpty(rect)) { return 0; } @@ -260,12 +260,12 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_InvalidParamError("SDL_FillSurfaceRects(): dst"); } - /* Nothing to do */ + // Nothing to do if (dst->w == 0 || dst->h == 0) { return 0; } - /* Perform software fill */ + // Perform software fill if (!dst->pixels) { return SDL_SetError("SDL_FillSurfaceRects(): You must lock the surface"); } @@ -321,7 +321,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } case 3: - /* 24-bit RGB is a slow path, at least for now. */ + // 24-bit RGB is a slow path, at least for now. { fill_function = SDL_FillSurfaceRect3; break; @@ -346,7 +346,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, for (i = 0; i < count; ++i) { rect = &rects[i]; - /* Perform clipping */ + // Perform clipping if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) { continue; } @@ -358,6 +358,6 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, fill_function(pixels, dst->pitch, color, rect->w, rect->h); } - /* We're done! */ + // We're done! return 0; } diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 8d4ee72f1f..3534db4a57 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* General (mostly internal) pixel/color manipulation routines for SDL */ +// General (mostly internal) pixel/color manipulation routines for SDL #include "SDL_sysvideo.h" #include "SDL_blit.h" @@ -29,7 +29,7 @@ #include "../SDL_hashtable.h" #include "../SDL_list.h" -/* Lookup tables to expand partial bytes to the full 0..255 range */ +// Lookup tables to expand partial bytes to the full 0..255 range static const Uint8 lookup_0[] = { 255 @@ -79,14 +79,14 @@ const Uint8 *SDL_expand_byte[9] = { lookup_8 }; -/* Lookup tables to expand 8 bit to 10 bit range */ +// Lookup tables to expand 8 bit to 10 bit range const Uint16 SDL_expand_byte_10[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, 417, 421, 425, 429, 433, 437, 441, 445, 449, 453, 457, 461, 465, 469, 473, 477, 481, 485, 489, 493, 497, 501, 505, 509, 514, 518, 522, 526, 530, 534, 538, 542, 546, 550, 554, 558, 562, 566, 570, 574, 578, 582, 586, 590, 594, 598, 602, 606, 610, 614, 618, 622, 626, 630, 634, 638, 642, 646, 650, 654, 658, 662, 666, 670, 674, 678, 682, 686, 690, 694, 698, 702, 706, 710, 714, 718, 722, 726, 730, 734, 738, 742, 746, 750, 754, 758, 762, 766, 770, 774, 778, 782, 786, 790, 794, 798, 802, 806, 810, 814, 818, 822, 826, 830, 834, 838, 842, 846, 850, 855, 859, 863, 867, 871, 875, 879, 883, 887, 891, 895, 899, 903, 907, 911, 915, 919, 923, 927, 931, 935, 939, 943, 947, 951, 955, 959, 963, 967, 971, 975, 979, 983, 987, 991, 995, 999, 1003, 1007, 1011, 1015, 1019, 1023 }; SDL_COMPILE_TIME_ASSERT(SDL_expand_byte_10_size, SDL_arraysize(SDL_expand_byte_10) == (1 << 8)); -/* Helper functions */ +// Helper functions #define CASE(X) \ case X: \ @@ -170,9 +170,9 @@ int SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 masks[4]; #if SDL_HAVE_YUV - /* Partial support for SDL_Surface with FOURCC */ + // Partial support for SDL_Surface with FOURCC if (SDL_ISPIXELFORMAT_FOURCC(format)) { - /* Not a format that uses masks */ + // Not a format that uses masks *Rmask = *Gmask = *Bmask = *Amask = 0; // however, some of these are packed formats, and can legit declare bits-per-pixel! switch (format) { @@ -192,7 +192,7 @@ int SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, } #endif - /* Initialize the values here */ + // Initialize the values here if (SDL_BYTESPERPIXEL(format) <= 2) { *bpp = SDL_BITSPERPIXEL(format); } else { @@ -229,7 +229,7 @@ int SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 && SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 && SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) { - /* Not a format that uses masks */ + // Not a format that uses masks return 0; } @@ -341,13 +341,13 @@ SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, { switch (bpp) { case 1: - /* SDL defaults to MSB ordering */ + // SDL defaults to MSB ordering return SDL_PIXELFORMAT_INDEX1MSB; case 2: - /* SDL defaults to MSB ordering */ + // SDL defaults to MSB ordering return SDL_PIXELFORMAT_INDEX2MSB; case 4: - /* SDL defaults to MSB ordering */ + // SDL defaults to MSB ordering return SDL_PIXELFORMAT_INDEX4MSB; case 8: if (Rmask == 0xE0 && @@ -459,7 +459,7 @@ SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Gmask == 0x07C0 && Bmask == 0xF800 && Amask == 0x0000) { - /* Technically this would be BGR556, but Witek says this works in bug 3158 */ + // Technically this would be BGR556, but Witek says this works in bug 3158 return SDL_PIXELFORMAT_RGB565; } break; @@ -588,7 +588,7 @@ static int SDL_InitPixelFormatDetails(SDL_PixelFormatDetails *details, SDL_Pixel return -1; } - /* Set up the format */ + // Set up the format SDL_zerop(details); details->format = format; details->bits_per_pixel = (Uint8)bpp; @@ -663,7 +663,7 @@ const SDL_PixelFormatDetails *SDL_GetPixelFormatDetails(SDL_PixelFormat format) goto done; } - /* Allocate an empty pixel format structure, and initialize it */ + // Allocate an empty pixel format structure, and initialize it details = (SDL_PixelFormatDetails *)SDL_malloc(sizeof(*details)); if (!details) { goto done; @@ -767,45 +767,45 @@ float SDL_PQfromNits(float v) * https://kdashg.github.io/misc/colors/from-coeffs.html */ static const float mat_BT601_Limited_8bit[] = { - -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, /* offset */ - 1.1644f, 0.0000f, 1.5960f, 0.0f, /* Rcoeff */ - 1.1644f, -0.3918f, -0.8130f, 0.0f, /* Gcoeff */ - 1.1644f, 2.0172f, 0.0000f, 0.0f, /* Bcoeff */ + -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.1644f, 0.0000f, 1.5960f, 0.0f, // Rcoeff + 1.1644f, -0.3918f, -0.8130f, 0.0f, // Gcoeff + 1.1644f, 2.0172f, 0.0000f, 0.0f, // Bcoeff }; static const float mat_BT601_Full_8bit[] = { - 0.0f, -0.501960814f, -0.501960814f, 0.0f, /* offset */ - 1.0000f, 0.0000f, 1.4020f, 0.0f, /* Rcoeff */ - 1.0000f, -0.3441f, -0.7141f, 0.0f, /* Gcoeff */ - 1.0000f, 1.7720f, 0.0000f, 0.0f, /* Bcoeff */ + 0.0f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.0000f, 0.0000f, 1.4020f, 0.0f, // Rcoeff + 1.0000f, -0.3441f, -0.7141f, 0.0f, // Gcoeff + 1.0000f, 1.7720f, 0.0000f, 0.0f, // Bcoeff }; static const float mat_BT709_Limited_8bit[] = { - -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, /* offset */ - 1.1644f, 0.0000f, 1.7927f, 0.0f, /* Rcoeff */ - 1.1644f, -0.2132f, -0.5329f, 0.0f, /* Gcoeff */ - 1.1644f, 2.1124f, 0.0000f, 0.0f, /* Bcoeff */ + -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.1644f, 0.0000f, 1.7927f, 0.0f, // Rcoeff + 1.1644f, -0.2132f, -0.5329f, 0.0f, // Gcoeff + 1.1644f, 2.1124f, 0.0000f, 0.0f, // Bcoeff }; static const float mat_BT709_Full_8bit[] = { - 0.0f, -0.501960814f, -0.501960814f, 0.0f, /* offset */ - 1.0000f, 0.0000f, 1.5748f, 0.0f, /* Rcoeff */ - 1.0000f, -0.1873f, -0.4681f, 0.0f, /* Gcoeff */ - 1.0000f, 1.8556f, 0.0000f, 0.0f, /* Bcoeff */ + 0.0f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.0000f, 0.0000f, 1.5748f, 0.0f, // Rcoeff + 1.0000f, -0.1873f, -0.4681f, 0.0f, // Gcoeff + 1.0000f, 1.8556f, 0.0000f, 0.0f, // Bcoeff }; static const float mat_BT2020_Limited_10bit[] = { - -0.062561095f, -0.500488759f, -0.500488759f, 0.0f, /* offset */ - 1.1678f, 0.0000f, 1.6836f, 0.0f, /* Rcoeff */ - 1.1678f, -0.1879f, -0.6523f, 0.0f, /* Gcoeff */ - 1.1678f, 2.1481f, 0.0000f, 0.0f, /* Bcoeff */ + -0.062561095f, -0.500488759f, -0.500488759f, 0.0f, // offset + 1.1678f, 0.0000f, 1.6836f, 0.0f, // Rcoeff + 1.1678f, -0.1879f, -0.6523f, 0.0f, // Gcoeff + 1.1678f, 2.1481f, 0.0000f, 0.0f, // Bcoeff }; static const float mat_BT2020_Full_10bit[] = { - 0.0f, -0.500488759f, -0.500488759f, 0.0f, /* offset */ - 1.0000f, 0.0000f, 1.4760f, 0.0f, /* Rcoeff */ - 1.0000f, -0.1647f, -0.5719f, 0.0f, /* Gcoeff */ - 1.0000f, 1.8832f, 0.0000f, 0.0f, /* Bcoeff */ + 0.0f, -0.500488759f, -0.500488759f, 0.0f, // offset + 1.0000f, 0.0000f, 1.4760f, 0.0f, // Rcoeff + 1.0000f, -0.1647f, -0.5719f, 0.0f, // Gcoeff + 1.0000f, 1.8832f, 0.0000f, 0.0f, // Bcoeff }; static const float *SDL_GetBT601ConversionMatrix( SDL_Colorspace colorspace ) @@ -1011,7 +1011,7 @@ SDL_Palette *SDL_CreatePalette(int ncolors) { SDL_Palette *palette; - /* Input validation */ + // Input validation if (ncolors < 1) { SDL_InvalidParamError("ncolors"); return NULL; @@ -1040,7 +1040,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, { int status = 0; - /* Verify the parameters */ + // Verify the parameters if (!palette) { return -1; } @@ -1080,7 +1080,7 @@ void SDL_DitherPalette(SDL_Palette *palette) { int i; if (palette->ncolors != 256) { - return; /* only 8bpp supported right now */ + return; // only 8bpp supported right now } for (i = 0; i < palette->ncolors; i++) { @@ -1106,7 +1106,7 @@ void SDL_DitherPalette(SDL_Palette *palette) */ Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - /* Do colorspace distance matching */ + // Do colorspace distance matching unsigned int smallest; unsigned int distance; int rd, gd, bd, ad; @@ -1122,7 +1122,7 @@ Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad); if (distance < smallest) { pixel = (Uint8)i; - if (distance == 0) { /* Perfect match! */ + if (distance == 0) { // Perfect match! break; } smallest = distance; @@ -1148,7 +1148,7 @@ Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Pa return color_index; } -/* Tell whether palette is opaque, and if it has an alpha_channel */ +// Tell whether palette is opaque, and if it has an alpha_channel void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel) { int i; @@ -1164,7 +1164,7 @@ void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *ha } if (all_opaque) { - /* Palette is opaque, with an alpha channel */ + // Palette is opaque, with an alpha channel *is_opaque = SDL_TRUE; *has_alpha_channel = SDL_TRUE; return; @@ -1182,19 +1182,19 @@ void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *ha } if (all_transparent) { - /* Palette is opaque, without an alpha channel */ + // Palette is opaque, without an alpha channel *is_opaque = SDL_TRUE; *has_alpha_channel = SDL_FALSE; return; } } - /* Palette has alpha values */ + // Palette has alpha values *is_opaque = SDL_FALSE; *has_alpha_channel = SDL_TRUE; } -/* Find the opaque pixel value corresponding to an RGB triple */ +// Find the opaque pixel value corresponding to an RGB triple Uint32 SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b) { if (!format) { @@ -1223,7 +1223,7 @@ Uint32 SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palet } } -/* Find the pixel value corresponding to an RGBA quadruple */ +// Find the pixel value corresponding to an RGBA quadruple Uint32 SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { if (!format) { @@ -1358,7 +1358,7 @@ void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_P } } -/* Map from Palette to Palette */ +// Map from Palette to Palette static Uint8 *Map1to1(const SDL_Palette *src, const SDL_Palette *dst, int *identical) { Uint8 *map; @@ -1366,7 +1366,7 @@ static Uint8 *Map1to1(const SDL_Palette *src, const SDL_Palette *dst, int *ident if (identical) { if (src->ncolors <= dst->ncolors) { - /* If an identical palette, no need to map */ + // If an identical palette, no need to map if (src == dst || (SDL_memcmp(src->colors, dst->colors, src->ncolors * sizeof(SDL_Color)) == 0)) { @@ -1388,7 +1388,7 @@ static Uint8 *Map1to1(const SDL_Palette *src, const SDL_Palette *dst, int *ident return map; } -/* Map from Palette to BitField */ +// Map from Palette to BitField static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, const SDL_PixelFormatDetails *dst) { Uint8 *map; @@ -1406,7 +1406,7 @@ static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod return NULL; } - /* We memory copy to the pixel map so the endianness is preserved */ + // 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); @@ -1431,11 +1431,11 @@ int SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst) if (SDL_MapSurface(src, dst) < 0) { return -1; } - /* just here for debugging */ - /* printf */ - /* ("src = 0x%08X src->flags = %08X map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->internal->map.info.flags = %08X\nmap->blit = 0x%08x\n", */ - /* src, dst->flags, map->info.flags, dst, dst->flags, */ - /* dst->internal->map.info.flags, map->blit); */ + // just here for debugging + // printf + // ("src = 0x%08X src->flags = %08X map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->internal->map.info.flags = %08X\nmap->blit = 0x%08x\n", + // src, dst->flags, map->info.flags, dst, dst->flags, + // dst->internal->map.info.flags, map->blit); } else { map->info.dst_surface = dst; } @@ -1466,7 +1466,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) const SDL_Palette *dstpal; SDL_BlitMap *map; - /* Clear out any previous mapping */ + // Clear out any previous mapping map = &src->internal->map; #if SDL_HAVE_RLE if (src->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { @@ -1475,7 +1475,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) #endif SDL_InvalidateMap(map); - /* Figure out what kind of mapping we're doing */ + // Figure out what kind of mapping we're doing map->identity = 0; srcfmt = src->internal->format; srcpal = src->internal->palette; @@ -1483,7 +1483,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) dstpal = dst->internal->palette; if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) { if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { - /* Palette --> Palette */ + // Palette --> Palette if (srcpal && dstpal) { map->info.table = Map1to1(srcpal, dstpal, &map->identity); } else { @@ -1498,7 +1498,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->identity = 0; } } else { - /* Palette --> BitField */ + // Palette --> BitField map->info.table = Map1toN(srcpal, src->internal->map.info.r, src->internal->map.info.g, src->internal->map.info.b, src->internal->map.info.a, dstfmt); @@ -1508,10 +1508,10 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) } } else { if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { - /* BitField --> Palette */ + // BitField --> Palette map->info.palette_map = SDL_CreateHashTable(NULL, 32, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE); } else { - /* BitField --> BitField */ + // BitField --> BitField if (srcfmt == dstfmt) { map->identity = 1; } @@ -1530,7 +1530,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->src_palette_version = 0; } - /* Choose your blitters wisely */ + // Choose your blitters wisely return SDL_CalculateBlit(src, dst); } diff --git a/src/video/SDL_pixels_c.h b/src/video/SDL_pixels_c.h index 4da44bd9ca..db9885503a 100644 --- a/src/video/SDL_pixels_c.h +++ b/src/video/SDL_pixels_c.h @@ -23,17 +23,17 @@ #ifndef SDL_pixels_c_h_ #define SDL_pixels_c_h_ -/* Useful functions and variables from SDL_pixel.c */ +// Useful functions and variables from SDL_pixel.c #include "SDL_blit.h" -/* Pixel format functions */ +// Pixel format functions extern int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch); extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat pixel_format); extern void SDL_QuitPixelFormatDetails(void); -/* Colorspace conversion functions */ +// Colorspace conversion functions extern float SDL_sRGBtoLinear(float v); extern float SDL_sRGBfromLinear(float v); extern float SDL_PQtoNits(float v); @@ -42,16 +42,16 @@ extern const float *SDL_GetYCbCRtoRGBConversionMatrix(SDL_Colorspace colorspace, extern const float *SDL_GetColorPrimariesConversionMatrix(SDL_ColorPrimaries src, SDL_ColorPrimaries dst); extern void SDL_ConvertColorPrimaries(float *fR, float *fG, float *fB, const float *matrix); -/* Blit mapping functions */ +// Blit mapping functions extern int SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst); extern void SDL_InvalidateMap(SDL_BlitMap *map); extern int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst); -/* Miscellaneous functions */ +// Miscellaneous functions extern void SDL_DitherPalette(SDL_Palette *palette); extern Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); extern Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Palette *pal); extern void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel); extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, void *pixels, int pitch); -#endif /* SDL_pixels_c_h_ */ +#endif // SDL_pixels_c_h_ diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 202c7f9666..d89da72053 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -48,7 +48,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, return SDL_FALSE; } - /* Initialize to empty rect */ + // Initialize to empty rect span_y1 = height; span_y2 = 0; @@ -56,7 +56,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, rect_y1 = rects[i].y; rect_y2 = rect_y1 + rects[i].h; - /* Clip out of bounds rectangles, and expand span rect */ + // Clip out of bounds rectangles, and expand span rect if (rect_y1 < 0) { span_y1 = 0; } else if (rect_y1 < span_y1) { @@ -78,13 +78,13 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, return SDL_FALSE; } -/* For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h */ +// For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h #define CODE_BOTTOM 1 #define CODE_TOP 2 #define CODE_LEFT 4 #define CODE_RIGHT 8 -/* Same code twice, for float and int versions... */ +// Same code twice, for float and int versions... #define RECTTYPE SDL_Rect #define POINTTYPE SDL_Point #define SCALARTYPE int diff --git a/src/video/SDL_rect_c.h b/src/video/SDL_rect_c.h index e3d2a033af..d441ba176f 100644 --- a/src/video/SDL_rect_c.h +++ b/src/video/SDL_rect_c.h @@ -26,4 +26,4 @@ extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span); -#endif /* SDL_rect_c_h_ */ +#endif // SDL_rect_c_h_ diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index 82287137e7..edde16fb75 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* This file is #included twice to support int and float versions with the same code. */ +// This file is #included twice to support int and float versions with the same code. static SDL_bool SDL_RECT_CAN_OVERFLOW(const RECTTYPE *rect) { @@ -49,10 +49,10 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) SDL_SetError("Potential rect math overflow"); 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 */ + // Horizontal intersection Amin = A->x; Amax = Amin + A->w; Bmin = B->x; @@ -66,7 +66,7 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) if ((Amax - ENCLOSEPOINTS_EPSILON) < Amin) { return SDL_FALSE; } - /* Vertical intersection */ + // Vertical intersection Amin = A->y; Amax = Amin + A->h; Bmin = B->y; @@ -100,13 +100,13 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul } else if (!result) { 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; } - /* Horizontal intersection */ + // Horizontal intersection Amin = A->x; Amax = Amin + A->w; Bmin = B->x; @@ -120,7 +120,7 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul } result->w = Amax - Amin; - /* Vertical intersection */ + // Vertical intersection Amin = A->y; Amax = Amin + A->h; Bmin = B->y; @@ -151,19 +151,19 @@ int SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) return SDL_FALSE; } else if (!result) { return SDL_InvalidParamError("result"); - } 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 0; - } else if (SDL_RECTEMPTY(B)) { /* A not empty, B empty */ + } else if (SDL_RECTEMPTY(B)) { // A not empty, B empty *result = *A; return 0; } - /* Horizontal union */ + // Horizontal union Amin = A->x; Amax = Amin + A->w; Bmin = B->x; @@ -177,7 +177,7 @@ int SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) } result->w = Amax - Amin; - /* Vertical union */ + // Vertical union Amin = A->y; Amax = Amin + A->h; Bmin = B->y; @@ -218,7 +218,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c const SCALARTYPE clip_maxx = clip->x + clip->w - ENCLOSEPOINTS_EPSILON; const SCALARTYPE clip_maxy = clip->y + clip->h - ENCLOSEPOINTS_EPSILON; - /* Special case for empty rectangle */ + // Special case for empty rectangle if (SDL_RECTEMPTY(clip)) { return SDL_FALSE; } @@ -232,12 +232,12 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c continue; } if (!added) { - /* Special case: if no result was requested, we are done */ + // Special case: if no result was requested, we are done if (!result) { return SDL_TRUE; } - /* First point added */ + // First point added minx = maxx = x; miny = maxy = y; added = SDL_TRUE; @@ -258,12 +258,12 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c return SDL_FALSE; } } else { - /* Special case: if no result was requested, we are done */ + // Special case: if no result was requested, we are done if (!result) { return SDL_TRUE; } - /* No clipping, always add the first point */ + // No clipping, always add the first point minx = maxx = points[0].x; miny = maxy = points[0].y; @@ -293,7 +293,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c return SDL_TRUE; } -/* Use the Cohen-Sutherland algorithm for line clipping */ +// Use the Cohen-Sutherland algorithm for line clipping static int COMPUTEOUTCODE(const RECTTYPE *rect, SCALARTYPE x, SCALARTYPE y) { int code = 0; @@ -341,7 +341,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY 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; @@ -353,19 +353,19 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY rectx2 = rect->x + rect->w - ENCLOSEPOINTS_EPSILON; recty2 = rect->y + rect->h - ENCLOSEPOINTS_EPSILON; - /* Check to see if entire line is inside rect */ + // Check to see if entire line is inside rect if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 && y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) { return SDL_TRUE; } - /* Check to see if entire line is to one side of rect */ + // Check to see if entire line is to one side of rect if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) || (y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) { 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) { @@ -379,7 +379,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY 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) { @@ -393,7 +393,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY return SDL_TRUE; } - /* More complicated Cohen-Sutherland algorithm */ + // More complicated Cohen-Sutherland algorithm outcode1 = COMPUTEOUTCODE(rect, x1, y1); outcode2 = COMPUTEOUTCODE(rect, x2, y2); while (outcode1 || outcode2) { @@ -420,23 +420,23 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY 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 = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(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 = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(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 = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(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 = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); } diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 6c37f064f1..006b57ec31 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -96,7 +96,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, } } - /* Verify the blit rectangles */ + // Verify the blit rectangles if (srcrect) { if ((srcrect->x < 0) || (srcrect->y < 0) || ((srcrect->x + srcrect->w) > src->w) || @@ -133,7 +133,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, return SDL_SetError("Size too large for scaling"); } - /* Lock the destination if it's in hardware */ + // Lock the destination if it's in hardware dst_locked = 0; if (SDL_MUSTLOCK(dst)) { if (SDL_LockSurface(dst) < 0) { @@ -141,7 +141,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, } dst_locked = 1; } - /* Lock the source if it's in hardware */ + // Lock the source if it's in hardware src_locked = 0; if (SDL_MUSTLOCK(src)) { if (SDL_LockSurface(src) < 0) { @@ -159,7 +159,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, ret = SDL_LowerSoftStretchLinear(src, srcrect, dst, dstrect); } - /* We need to unlock the surfaces if they're locked */ + // We need to unlock the surfaces if they're locked if (dst_locked) { SDL_UnlockSurface(dst); } @@ -237,22 +237,22 @@ __attribute__((noinline)) static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *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 Sint64 fp_sum; int i; #if 0 - /* scale to source coordinates */ + // scale to source coordinates x0 *= src_nb; - x0 /= dst_nb; /* x0 == step / 2 */ + x0 /= dst_nb; // x0 == step / 2 #else - /* Use this code for perfect match with pixman */ + // Use this code for perfect match with pixman 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 */ + // -= 0.5, get back the pixel origin, in source coordinates x0 -= FP_ONE / 2; *fp_start = x0; @@ -317,11 +317,11 @@ static SDL_INLINE void INTERPOL_BILINEAR(const Uint32 *s0, const Uint32 *s1, int Uint32 tmp[2]; unsigned int frac_w1 = FRAC_ONE - frac_w0; - /* Vertical first, store to 'tmp' */ + // Vertical first, store to 'tmp' INTERPOL(s0, s1, frac_h0, frac_h1, tmp); INTERPOL(s0 + 1, s1 + 1, frac_h0, frac_h1, tmp + 1); - /* Horizontal, store to 'dst' */ + // Horizontal, store to 'dst' INTERPOL(tmp, tmp + 1, frac_w0, frac_w1, dst); } @@ -419,27 +419,27 @@ static SDL_INLINE void SDL_TARGETING("sse2") INTERPOL_BILINEAR_SSE(const Uint32 f2 = FRAC_ONE - frac_w; v_frac_w0 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)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 */ - /* Interpolation vertical */ + // Interpolation vertical k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); k0 = _mm_add_epi16(k0, l0); - /* For perfect match, clear the factionnal part eventually. */ + // For perfect match, clear the factionnal part eventually. /* k0 = _mm_srli_epi16(k0, PRECISION); k0 = _mm_slli_epi16(k0, PRECISION); */ - /* Interpolation horizontal */ + // Interpolation horizontal l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); - /* Store 1 pixel */ + // Store 1 pixel d0 = _mm_srli_epi32(k0, PRECISION * 2); e0 = _mm_packs_epi32(d0, d0); e0 = _mm_packus_epi16(e0, e0); @@ -508,12 +508,12 @@ static int SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int f2 = FRAC_ONE - frac_w_1; v_frac_w1 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2); - x_00_01 = _mm_loadl_epi64((const __m128i *)s_00_01); /* Load x00 and x01 */ + x_00_01 = _mm_loadl_epi64((const __m128i *)s_00_01); // Load x00 and x01 x_02_03 = _mm_loadl_epi64((const __m128i *)s_02_03); x_10_11 = _mm_loadl_epi64((const __m128i *)s_10_11); x_12_13 = _mm_loadl_epi64((const __m128i *)s_12_13); - /* Interpolation vertical */ + // Interpolation vertical k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); k0 = _mm_add_epi16(k0, l0); @@ -521,26 +521,26 @@ static int SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int l1 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_12_13, zero), v_frac_h0); k1 = _mm_add_epi16(k1, l1); - /* Interpolation horizontal */ + // Interpolation horizontal l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); l1 = _mm_unpacklo_epi64(/* unused */ l1, k1); k1 = _mm_madd_epi16(_mm_unpackhi_epi16(l1, k1), v_frac_w1); - /* Store 1 pixel */ + // Store 1 pixel d0 = _mm_srli_epi32(k0, PRECISION * 2); e0 = _mm_packs_epi32(d0, d0); e0 = _mm_packus_epi16(e0, e0); *dst++ = _mm_cvtsi128_si32(e0); - /* Store 1 pixel */ + // Store 1 pixel d1 = _mm_srli_epi32(k1, PRECISION * 2); e1 = _mm_packs_epi32(d1, d1); e1 = _mm_packus_epi16(e1, e1); *dst++ = _mm_cvtsi128_si32(e1); } - /* Last point */ + // Last point if (middle & 0x1) { const Uint32 *s_00_01; const Uint32 *s_10_11; @@ -586,27 +586,27 @@ static SDL_INLINE void INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1 uint16x8_t d0; uint8x8_t e0; - x_00_01 = CAST_uint8x8_t vld1_u32(s0); /* Load 2 pixels */ + x_00_01 = CAST_uint8x8_t vld1_u32(s0); // Load 2 pixels 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 now contains 2 interpolated pixels { j0, j1 } */ + // k0 now contains 2 interpolated pixels { j0, j1 } l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w); l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w); - /* Shift and narrow */ + // Shift and narrow d0 = vcombine_u16( /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION)); - /* Narrow again */ + // Narrow again e0 = vmovn_u16(d0); - /* Store 1 pixel */ + // Store 1 pixel *dst = vget_lane_u32(CAST_uint32x2_t e0, 0); } @@ -670,8 +670,8 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch s_14_15 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_2); s_16_17 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_3); - /* Interpolation vertical */ - x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01); /* Load 2 pixels */ + // Interpolation vertical + 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_04_05 = CAST_uint8x8_t vld1_u32(s_04_05); x_06_07 = CAST_uint8x8_t vld1_u32(s_06_07); @@ -693,10 +693,10 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch k3 = vmull_u8(x_06_07, v_frac_h1); k3 = vmlal_u8(k3, x_16_17, v_frac_h0); - /* k0 now contains 2 interpolated pixels { j0, j1 } */ - /* k1 now contains 2 interpolated pixels { j2, j3 } */ - /* k2 now contains 2 interpolated pixels { j4, j5 } */ - /* k3 now contains 2 interpolated pixels { j6, j7 } */ + // k0 now contains 2 interpolated pixels { j0, j1 } + // k1 now contains 2 interpolated pixels { j2, j3 } + // k2 now contains 2 interpolated pixels { j4, j5 } + // k3 now contains 2 interpolated pixels { j6, j7 } l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); @@ -714,22 +714,22 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch l3 = vmlsl_n_u16(l3, vget_low_u16(k3), frac_w_3); l3 = vmlal_n_u16(l3, vget_high_u16(k3), frac_w_3); - /* shift and narrow */ + // shift and narrow d0 = vcombine_u16( /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); - /* narrow again */ + // narrow again e0 = vmovn_u16(d0); - /* Shift and narrow */ + // Shift and narrow d1 = vcombine_u16( /* uint16x4_t */ vshrn_n_u32(l2, 2 * PRECISION), /* uint16x4_t */ vshrn_n_u32(l3, 2 * PRECISION)); - /* Narrow again */ + // Narrow again e1 = vmovn_u16(d1); f0 = vcombine_u32(CAST_uint32x2_t e0, CAST_uint32x2_t e1); - /* Store 4 pixels */ + // Store 4 pixels vst1q_u32(dst, f0); dst += 4; @@ -766,8 +766,8 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch 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 */ + // Interpolation vertical + 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); @@ -779,8 +779,8 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch k1 = vmull_u8(x_02_03, v_frac_h1); k1 = vmlal_u8(k1, x_12_13, v_frac_h0); - /* k0 now contains 2 interpolated pixels { j0, j1 } */ - /* k1 now contains 2 interpolated pixels { j2, j3 } */ + // k0 now contains 2 interpolated pixels { j0, j1 } + // k1 now contains 2 interpolated pixels { j2, j3 } l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); @@ -790,21 +790,21 @@ static int scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch l1 = vmlsl_n_u16(l1, vget_low_u16(k1), frac_w_1); l1 = vmlal_n_u16(l1, vget_high_u16(k1), frac_w_1); - /* Shift and narrow */ + // Shift and narrow d0 = vcombine_u16( /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); - /* Narrow again */ + // Narrow again e0 = vmovn_u16(d0); - /* Store 2 pixels */ + // Store 2 pixels vst1_u32(dst, CAST_uint32x2_t e0); dst += 2; } - /* Last point */ + // Last point if (middle & 0x1) { int index_w = 4 * SRC_INDEX(fp_sum_w); int frac_w = FRAC(fp_sum_w); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index e2a03d0b0a..5e3a2b9c47 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -31,13 +31,13 @@ #include "SDL_surface_c.h" -/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */ +// 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)); SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32); -/* Public routines */ +// Public routines SDL_bool SDL_SurfaceValid(SDL_Surface *surface) { @@ -75,7 +75,7 @@ static int SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size *pitch /= 8; } if (!minimal) { - /* 4-byte aligning for speed */ + // 4-byte aligning for speed if (SDL_size_add_overflow(*pitch, 3, pitch)) { return SDL_SetError("aligning pitch would overflow"); } @@ -103,12 +103,12 @@ int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size if (SDL_ISPIXELFORMAT_FOURCC(format)) { if (SDL_CalculateYUVSize(format, width, height, &sz, &p) < 0) { - /* Overflow... */ + // Overflow... return -1; } } else { if (SDL_CalculateRGBSize(format, width, height, &sz, &p, minimalPitch) < 0) { - /* Overflow... */ + // Overflow... return -1; } } @@ -148,11 +148,11 @@ static SDL_Surface *SDL_InitializeSurface(SDL_InternalSurface *mem, int width, i return NULL; } - /* Initialize the clip rect */ + // Initialize the clip rect surface->internal->clip_rect.w = width; surface->internal->clip_rect.h = height; - /* Allocate an empty mapping */ + // Allocate an empty mapping surface->internal->map.info.r = 0xFF; surface->internal->map.info.g = 0xFF; surface->internal->map.info.b = 0xFF; @@ -170,12 +170,12 @@ static SDL_Surface *SDL_InitializeSurface(SDL_InternalSurface *mem, int width, i } } - /* By default surfaces with an alpha mask are set up for blending */ + // By default surfaces with an alpha mask are set up for blending if (SDL_ISPIXELFORMAT_ALPHA(surface->format)) { SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); } - /* The surface is ready to go */ + // The surface is ready to go surface->refcount = 1; return surface; } @@ -200,11 +200,11 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format) } if (SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, SDL_FALSE /* not minimal pitch */) < 0) { - /* Overflow... */ + // Overflow... return NULL; } - /* Allocate and initialize the surface */ + // Allocate and initialize the surface mem = (SDL_InternalSurface *)SDL_malloc(sizeof(*mem)); if (!mem) { return NULL; @@ -221,7 +221,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format) } surface->flags |= SDL_SURFACE_SIMD_ALIGNED; - /* This is important for bitmaps */ + // This is important for bitmaps SDL_memset(surface->pixels, 0, size); } } @@ -247,12 +247,12 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format } if (pitch == 0 && !pixels) { - /* The application will fill these in later with valid values */ + // The application will fill these in later with valid values } else { size_t minimalPitch; if (SDL_CalculateSurfaceSize(format, width, height, NULL, &minimalPitch, SDL_TRUE /* minimal pitch */) < 0) { - /* Overflow... */ + // Overflow... return NULL; } @@ -262,7 +262,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format } } - /* Allocate and initialize the surface */ + // Allocate and initialize the surface mem = (SDL_InternalSurface *)SDL_malloc(sizeof(*mem)); if (!mem) { return NULL; @@ -380,7 +380,7 @@ SDL_Palette *SDL_CreateSurfacePalette(SDL_Surface *surface) } if (palette->ncolors == 2) { - /* Create a black and white bitmap palette */ + // Create a black and white bitmap palette palette->colors[0].r = 0xFF; palette->colors[0].g = 0xFF; palette->colors[0].b = 0xFF; @@ -394,7 +394,7 @@ SDL_Palette *SDL_CreateSurfacePalette(SDL_Surface *surface) return NULL; } - /* The surface has retained the palette, we can remove the reference here */ + // The surface has retained the palette, we can remove the reference here SDL_assert(palette->refcount == 2); SDL_DestroyPalette(palette); return palette; @@ -697,7 +697,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp Uint16 ckey = (Uint16)surface->internal->map.info.colorkey; Uint16 mask = (Uint16)(~surface->internal->format->Amask); - /* Ignore, or not, alpha in colorkey comparison */ + // Ignore, or not, alpha in colorkey comparison if (ignore_alpha) { ckey &= mask; row = (Uint16 *)surface->pixels; @@ -729,7 +729,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp Uint32 ckey = surface->internal->map.info.colorkey; Uint32 mask = ~surface->internal->format->Amask; - /* Ignore, or not, alpha in colorkey comparison */ + // Ignore, or not, alpha in colorkey comparison if (ignore_alpha) { ckey &= mask; row = (Uint32 *)surface->pixels; @@ -944,18 +944,18 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) { SDL_Rect full_rect; - /* Don't do anything if there's no surface to act on */ + // Don't do anything if there's no surface to act on if (!SDL_SurfaceValid(surface)) { return SDL_FALSE; } - /* Set up the full surface rectangle */ + // Set up the full surface rectangle full_rect.x = 0; full_rect.y = 0; full_rect.w = surface->w; full_rect.h = surface->h; - /* Set the clipping rectangle */ + // Set the clipping rectangle if (!rect) { surface->internal->clip_rect = full_rect; return SDL_TRUE; @@ -992,7 +992,7 @@ int SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect) int SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect) { - /* Check to make sure the blit mapping is valid */ + // Check to make sure the blit mapping is valid if (SDL_ValidateMap(src, dst) < 0) { return -1; } @@ -1004,7 +1004,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, { SDL_Rect r_src, r_dst; - /* Make sure the surfaces aren't locked */ + // Make sure the surfaces aren't locked if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); } else if (!SDL_SurfaceValid(dst)) { @@ -1013,7 +1013,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, return SDL_SetError("Surfaces must not be locked during blit"); } - /* Full src surface */ + // Full src surface r_src.x = 0; r_src.y = 0; r_src.w = src->w; @@ -1027,48 +1027,48 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, r_dst.y = 0; } - /* clip the source rectangle to the source surface */ + // clip the source rectangle to the source surface if (srcrect) { SDL_Rect tmp; if (SDL_GetRectIntersection(srcrect, &r_src, &tmp) == SDL_FALSE) { return 0; } - /* Shift dstrect, if srcrect origin has changed */ + // Shift dstrect, if srcrect origin has changed r_dst.x += tmp.x - srcrect->x; r_dst.y += tmp.y - srcrect->y; - /* Update srcrect */ + // Update srcrect r_src = tmp; } - /* There're no dstrect.w/h parameters. It's the same as srcrect */ + // There're no dstrect.w/h parameters. It's the same as srcrect r_dst.w = r_src.w; r_dst.h = r_src.h; - /* clip the destination rectangle against the clip rectangle */ + // clip the destination rectangle against the clip rectangle { SDL_Rect tmp; if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &tmp) == SDL_FALSE) { return 0; } - /* Shift srcrect, if dstrect has changed */ + // Shift srcrect, if dstrect has changed r_src.x += tmp.x - r_dst.x; r_src.y += tmp.y - r_dst.y; r_src.w = tmp.w; r_src.h = tmp.h; - /* Update dstrect */ + // Update dstrect r_dst = tmp; } if (r_dst.w <= 0 || r_dst.h <= 0) { - /* No-op. */ + // No-op. return 0; } - /* Switch back to a fast blit if we were previously stretching */ + // Switch back to a fast blit if we were previously stretching if (src->internal->map.info.flags & SDL_COPY_NEAREST) { src->internal->map.info.flags &= ~SDL_COPY_NEAREST; SDL_InvalidateMap(&src->internal->map); @@ -1089,7 +1089,7 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, int src_w, src_h; int dst_w, dst_h; - /* Make sure the surfaces aren't locked */ + // Make sure the surfaces aren't locked if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); } else if (!SDL_SurfaceValid(dst)) { @@ -1119,7 +1119,7 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, } if (dst_w == src_w && dst_h == src_h) { - /* No scaling, defer to regular blit */ + // No scaling, defer to regular blit return SDL_BlitSurface(src, srcrect, dst, dstrect); } @@ -1149,7 +1149,7 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, src_x1 = src_x0 + src_w; src_y1 = src_y0 + src_h; - /* Clip source rectangle to the source surface */ + // Clip source rectangle to the source surface if (src_x0 < 0) { dst_x0 -= src_x0 * scaling_w; @@ -1172,10 +1172,10 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, } } - /* Clip destination rectangle to the clip rectangle */ + // Clip destination rectangle to the clip rectangle clip_rect = &dst->internal->clip_rect; - /* Translate to clip space for easier calculations */ + // Translate to clip space for easier calculations dst_x0 -= clip_rect->x; dst_x1 -= clip_rect->x; dst_y0 -= clip_rect->y; @@ -1201,7 +1201,7 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, dst_y1 = clip_rect->h; } - /* Translate back to surface coordinates */ + // Translate back to surface coordinates dst_x0 += clip_rect->x; dst_x1 += clip_rect->x; dst_y0 += clip_rect->y; @@ -1217,7 +1217,7 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, final_dst.w = (int)SDL_round(dst_x1 - dst_x0); final_dst.h = (int)SDL_round(dst_y1 - dst_y0); - /* Clip again */ + // Clip again { SDL_Rect tmp; tmp.x = 0; @@ -1227,12 +1227,12 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_GetRectIntersection(&tmp, &final_src, &final_src); } - /* Clip again */ + // Clip again SDL_GetRectIntersection(clip_rect, &final_dst, &final_dst); if (final_dst.w == 0 || final_dst.h == 0 || final_src.w <= 0 || final_src.h <= 0) { - /* No-op. */ + // No-op. return 0; } @@ -1282,7 +1282,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, !SDL_ISPIXELFORMAT_INDEXED(src->format) && SDL_BYTESPERPIXEL(src->format) == 4 && src->format != SDL_PIXELFORMAT_ARGB2101010) { - /* fast path */ + // fast path return SDL_SoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_LINEAR); } else if (SDL_BITSPERPIXEL(src->format) < 8) { // Scaling bitmap not yet supported, convert to RGBA for blit @@ -1294,7 +1294,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, } return retval; } else { - /* Use intermediate surface(s) */ + // Use intermediate surface(s) SDL_Surface *tmp1 = NULL; int ret; SDL_Rect srcrect2; @@ -1304,7 +1304,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, Uint8 alpha; SDL_BlendMode blendMode; - /* Save source infos */ + // Save source infos SDL_GetSurfaceColorMod(src, &r, &g, &b); SDL_GetSurfaceAlphaMod(src, &alpha); SDL_GetSurfaceBlendMode(src, &blendMode); @@ -1313,7 +1313,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, srcrect2.w = srcrect->w; srcrect2.h = srcrect->h; - /* Change source format if not appropriate for scaling */ + // Change source format if not appropriate for scaling if (SDL_BYTESPERPIXEL(src->format) != 4 || src->format == SDL_PIXELFORMAT_ARGB2101010) { SDL_Rect tmprect; SDL_PixelFormat fmt; @@ -1338,7 +1338,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, src = tmp1; } - /* Intermediate scaling */ + // Intermediate scaling if (is_complex_copy_flags || src->format != dst->format) { SDL_Rect tmprect; SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format); @@ -1368,7 +1368,7 @@ int SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface { SDL_Rect r_src, r_dst; - /* Make sure the surfaces aren't locked */ + // Make sure the surfaces aren't locked if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); } else if (!SDL_SurfaceValid(dst)) { @@ -1377,7 +1377,7 @@ int SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface return SDL_SetError("Surfaces must not be locked during blit"); } - /* Full src surface */ + // Full src surface r_src.x = 0; r_src.y = 0; r_src.w = src->w; @@ -1395,25 +1395,25 @@ int SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface r_dst.h = dst->h; } - /* clip the source rectangle to the source surface */ + // clip the source rectangle to the source surface if (srcrect) { if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == SDL_FALSE) { return 0; } - /* For tiling we don't adjust the destination rectangle */ + // For tiling we don't adjust the destination rectangle } - /* clip the destination rectangle against the clip rectangle */ + // clip the destination rectangle against the clip rectangle { if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == SDL_FALSE) { return 0; } - /* For tiling we don't adjust the source rectangle */ + // For tiling we don't adjust the source rectangle } - /* Switch back to a fast blit if we were previously stretching */ + // Switch back to a fast blit if we were previously stretching if (src->internal->map.info.flags & SDL_COPY_NEAREST) { src->internal->map.info.flags &= ~SDL_COPY_NEAREST; SDL_InvalidateMap(&src->internal->map); @@ -1473,7 +1473,7 @@ int SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, flo { SDL_Rect r_src, r_dst; - /* Make sure the surfaces aren't locked */ + // Make sure the surfaces aren't locked if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); } else if (!SDL_SurfaceValid(dst)) { @@ -1486,7 +1486,7 @@ int SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, flo return SDL_InvalidParamError("scale"); } - /* Full src surface */ + // Full src surface r_src.x = 0; r_src.y = 0; r_src.w = src->w; @@ -1504,25 +1504,25 @@ int SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, flo r_dst.h = dst->h; } - /* clip the source rectangle to the source surface */ + // clip the source rectangle to the source surface if (srcrect) { if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == SDL_FALSE) { return 0; } - /* For tiling we don't adjust the destination rectangle */ + // For tiling we don't adjust the destination rectangle } - /* clip the destination rectangle against the clip rectangle */ + // clip the destination rectangle against the clip rectangle { if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == SDL_FALSE) { return 0; } - /* For tiling we don't adjust the source rectangle */ + // For tiling we don't adjust the source rectangle } - /* Switch back to a fast blit if we were previously stretching */ + // Switch back to a fast blit if we were previously stretching if (src->internal->map.info.flags & SDL_COPY_NEAREST) { src->internal->map.info.flags &= ~SDL_COPY_NEAREST; SDL_InvalidateMap(&src->internal->map); @@ -1591,7 +1591,7 @@ int SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_wid int dst_top_height; int dst_bottom_height; - /* Make sure the surfaces aren't locked */ + // Make sure the surfaces aren't locked if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); } else if (!SDL_SurfaceValid(dst)) { @@ -1731,19 +1731,19 @@ int SDL_LockSurface(SDL_Surface *surface) if (!surface->internal->locked) { #if SDL_HAVE_RLE - /* Perform the lock */ + // Perform the lock if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { SDL_UnRLESurface(surface, SDL_TRUE); - surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; /* save accel'd state */ + surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; // save accel'd state } #endif } - /* Increment the surface lock count, for recursive locks */ + // Increment the surface lock count, for recursive locks ++surface->internal->locked; surface->flags |= SDL_SURFACE_LOCKED; - /* Ready to go.. */ + // Ready to go.. return 0; } @@ -1756,15 +1756,15 @@ void SDL_UnlockSurface(SDL_Surface *surface) return; } - /* Only perform an unlock if we are locked */ + // Only perform an unlock if we are locked if (!surface->internal->locked || (--surface->internal->locked > 0)) { return; } #if SDL_HAVE_RLE - /* Update RLE encoded surface with new data */ + // Update RLE encoded surface with new data if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - surface->internal->flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL; /* stop lying */ + surface->internal->flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL; // stop lying SDL_RLESurface(surface); } #endif @@ -1779,7 +1779,7 @@ static int SDL_FlipSurfaceHorizontal(SDL_Surface *surface) int i, j, bpp; if (SDL_BITSPERPIXEL(surface->format) < 8) { - /* We could implement this if needed, but we'd have to flip sets of bits within a byte */ + // We could implement this if needed, but we'd have to flip sets of bits within a byte return SDL_Unsupported(); } @@ -1878,7 +1878,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm goto error; } - /* Check for empty destination palette! (results in empty image) */ + // Check for empty destination palette! (results in empty image) if (palette) { int i; for (i = 0; i < palette->ncolors; ++i) { @@ -1902,7 +1902,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm src_colorspace = surface->internal->colorspace; src_properties = surface->internal->props; - /* Create a new surface with the desired format */ + // Create a new surface with the desired format convert = SDL_CreateSurface(surface->w, surface->h, format); if (!convert) { goto error; @@ -1921,13 +1921,13 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm goto error; } - /* Save the original copy flags */ + // Save the original copy flags copy_flags = surface->internal->map.info.flags; goto end; } - /* Save the original copy flags */ + // Save the original copy flags copy_flags = surface->internal->map.info.flags; copy_color.r = surface->internal->map.info.r; copy_color.g = surface->internal->map.info.g; @@ -1940,7 +1940,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm surface->internal->map.info.flags = (copy_flags & (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)); SDL_InvalidateMap(&surface->internal->map); - /* Copy over the image data */ + // Copy over the image data bounds.x = 0; bounds.y = 0; bounds.w = surface->w; @@ -1961,7 +1961,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm } } - /* Set opaque and backup palette alpha values */ + // Set opaque and backup palette alpha values if (set_opaque) { int i; palette_saved_alpha_ncolors = surface->internal->palette->ncolors; @@ -1975,7 +1975,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm } } - /* Transform colorkey to alpha. for cases where source palette has duplicate values, and colorkey is one of them */ + // Transform colorkey to alpha. for cases where source palette has duplicate values, and colorkey is one of them if (copy_flags & SDL_COPY_COLORKEY) { if (surface->internal->palette && !palette) { palette_ck_transform = SDL_TRUE; @@ -1986,12 +1986,12 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm ret = SDL_BlitSurfaceUnchecked(surface, &bounds, convert, &bounds); - /* Restore colorkey alpha value */ + // Restore colorkey alpha value if (palette_ck_transform) { surface->internal->palette->colors[surface->internal->map.info.colorkey].a = palette_ck_value; } - /* Restore palette alpha values */ + // Restore palette alpha values if (palette_saved_alpha) { int i; for (i = 0; i < palette_saved_alpha_ncolors; i++) { @@ -2000,7 +2000,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm SDL_stack_free(palette_saved_alpha); } - /* Clean up the original surface, and update converted surface */ + // Clean up the original surface, and update converted surface convert->internal->map.info.r = copy_color.r; convert->internal->map.info.g = copy_color.g; convert->internal->map.info.b = copy_color.b; @@ -2016,7 +2016,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm surface->internal->map.info.flags = copy_flags; SDL_InvalidateMap(&surface->internal->map); - /* SDL_BlitSurfaceUnchecked failed, and so the conversion */ + // SDL_BlitSurfaceUnchecked failed, and so the conversion if (ret < 0) { goto error; } @@ -2030,13 +2030,13 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm surface->internal->palette->ncolors <= palette->ncolors && (SDL_memcmp(surface->internal->palette->colors, palette->colors, surface->internal->palette->ncolors * sizeof(SDL_Color)) == 0)) { - /* The palette is identical, just set the same colorkey */ + // The palette is identical, just set the same colorkey SDL_SetSurfaceColorKey(convert, 1, surface->internal->map.info.colorkey); } else if (!palette) { if (SDL_ISPIXELFORMAT_ALPHA(format)) { - /* No need to add the colorkey, transparency is in the alpha channel*/ + // No need to add the colorkey, transparency is in the alpha channel } else { - /* Only set the colorkey information */ + // Only set the colorkey information set_colorkey_by_color = SDL_TRUE; convert_colorkey = SDL_FALSE; } @@ -2052,13 +2052,13 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm SDL_Surface *tmp2; int converted_colorkey = 0; - /* Create a dummy surface to get the colorkey converted */ + // Create a dummy surface to get the colorkey converted tmp = SDL_CreateSurface(1, 1, surface->format); if (!tmp) { goto error; } - /* Share the palette, if any */ + // Share the palette, if any if (surface->internal->palette) { SDL_SetSurfacePalette(tmp, surface->internal->palette); } @@ -2067,23 +2067,23 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm tmp->internal->map.info.flags &= ~SDL_COPY_COLORKEY; - /* Conversion of the colorkey */ + // Conversion of the colorkey tmp2 = SDL_ConvertSurfaceAndColorspace(tmp, format, palette, colorspace, props); if (!tmp2) { SDL_DestroySurface(tmp); goto error; } - /* Get the converted colorkey */ + // Get the converted colorkey SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->internal->format->bytes_per_pixel); SDL_DestroySurface(tmp); SDL_DestroySurface(tmp2); - /* Set the converted colorkey on the new surface */ + // Set the converted colorkey on the new surface SDL_SetSurfaceColorKey(convert, 1, converted_colorkey); - /* This is needed when converting for 3D texture upload */ + // This is needed when converting for 3D texture upload if (convert_colorkey) { SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE); } @@ -2107,14 +2107,14 @@ end: SDL_SetSurfaceRLE(convert, SDL_TRUE); } - /* Copy alternate images */ + // Copy alternate images for (int i = 0; i < surface->internal->num_images; ++i) { if (SDL_AddSurfaceAlternateImage(convert, surface->internal->images[i]) < 0) { goto error; } } - /* We're ready to go! */ + // We're ready to go! return convert; error: @@ -2168,7 +2168,7 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S return result; } - /* Create a new surface with the desired size */ + // Create a new surface with the desired size convert = SDL_CreateSurface(width, height, surface->format); if (!convert) { goto error; @@ -2176,7 +2176,7 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S SDL_SetSurfacePalette(convert, surface->internal->palette); SDL_SetSurfaceColorspace(convert, surface->internal->colorspace); - /* Save the original copy flags */ + // Save the original copy flags copy_flags = surface->internal->map.info.flags; copy_color.r = surface->internal->map.info.r; copy_color.g = surface->internal->map.info.g; @@ -2191,7 +2191,7 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S ret = SDL_BlitSurfaceScaled(surface, NULL, convert, NULL, scaleMode); - /* Clean up the original surface, and update converted surface */ + // Clean up the original surface, and update converted surface convert->internal->map.info.r = copy_color.r; convert->internal->map.info.g = copy_color.g; convert->internal->map.info.b = copy_color.b; @@ -2204,12 +2204,12 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S surface->internal->map.info.flags = copy_flags; SDL_InvalidateMap(&surface->internal->map); - /* SDL_BlitSurfaceScaled failed, and so the conversion */ + // SDL_BlitSurfaceScaled failed, and so the conversion if (ret < 0) { goto error; } - /* We're ready to go! */ + // We're ready to go! return convert; error: @@ -2293,7 +2293,7 @@ int SDL_ConvertPixelsAndColorspace(int width, int height, } #endif - /* Fast path for same format copy */ + // Fast path for same format copy if (src_format == dst_format && src_colorspace == dst_colorspace) { int i; const int bpp = SDL_BYTESPERPIXEL(src_format); @@ -2317,7 +2317,7 @@ int SDL_ConvertPixelsAndColorspace(int width, int height, return -1; } - /* Set up the rect and go! */ + // Set up the rect and go! rect.x = 0; rect.y = 0; rect.w = width; @@ -2359,17 +2359,17 @@ static void SDL_PremultiplyAlpha_AXYZ8888(int width, int height, const void *src const Uint32 *src_px = (const Uint32 *)src; Uint32 *dst_px = (Uint32 *)dst; for (c = width; c; --c) { - /* Component bytes extraction. */ + // Component bytes extraction. srcpixel = *src_px++; RGBA_FROM_ARGB8888(srcpixel, srcR, srcG, srcB, srcA); - /* Alpha pre-multiplication of each component. */ + // Alpha pre-multiplication of each component. dstA = srcA; dstR = (srcA * srcR) / 255; dstG = (srcA * srcG) / 255; dstB = (srcA * srcB) / 255; - /* ARGB8888 pixel recomposition. */ + // ARGB8888 pixel recomposition. ARGB8888_FROM_RGBA(dstpixel, dstR, dstG, dstB, dstA); *dst_px++ = dstpixel; } @@ -2390,17 +2390,17 @@ static void SDL_PremultiplyAlpha_XYZA8888(int width, int height, const void *src const Uint32 *src_px = (const Uint32 *)src; Uint32 *dst_px = (Uint32 *)dst; for (c = width; c; --c) { - /* Component bytes extraction. */ + // Component bytes extraction. srcpixel = *src_px++; RGBA_FROM_RGBA8888(srcpixel, srcR, srcG, srcB, srcA); - /* Alpha pre-multiplication of each component. */ + // Alpha pre-multiplication of each component. dstA = srcA; dstR = (srcA * srcR) / 255; dstG = (srcA * srcG) / 255; dstB = (srcA * srcB) / 255; - /* RGBA8888 pixel recomposition. */ + // RGBA8888 pixel recomposition. RGBA8888_FROM_RGBA(dstpixel, dstR, dstG, dstB, dstA); *dst_px++ = dstpixel; } @@ -2423,7 +2423,7 @@ static void SDL_PremultiplyAlpha_AXYZ128(int width, int height, const void *src, flG = *src_px++; flB = *src_px++; - /* Alpha pre-multiplication of each component. */ + // Alpha pre-multiplication of each component. flR *= flA; flG *= flA; flB *= flA; @@ -2635,7 +2635,7 @@ Uint32 SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 return SDL_MapRGBA(surface->internal->format, surface->internal->palette, r, g, b, a); } -/* This function Copyright 2023 Collabora Ltd., contributed to SDL under the ZLib license */ +// This function Copyright 2023 Collabora Ltd., contributed to SDL under the ZLib license int SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { Uint32 pixel = 0; @@ -2708,7 +2708,7 @@ int SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, SDL_DestroySurface(converted); } } else { - /* This is really slow, but it gets the job done */ + // This is really slow, but it gets the job done Uint8 rgba[4]; if (SDL_ConvertPixelsAndColorspace(1, 1, surface->format, surface->internal->colorspace, surface->internal->props, p, surface->pitch, SDL_PIXELFORMAT_RGBA32, SDL_COLORSPACE_SRGB, 0, rgba, sizeof(rgba)) == 0) { @@ -2785,7 +2785,7 @@ int SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, floa SDL_DestroySurface(converted); } } else { - /* This is really slow, but it gets the job done */ + // This is really slow, but it gets the job done float rgba[4]; Uint8 *p; @@ -2863,7 +2863,7 @@ int SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { result = SDL_Unsupported(); } else { - /* This is really slow, but it gets the job done */ + // This is really slow, but it gets the job done Uint8 rgba[4]; rgba[0] = r; @@ -2908,7 +2908,7 @@ int SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, floa } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { result = SDL_Unsupported(); } else { - /* This is really slow, but it gets the job done */ + // This is really slow, but it gets the job done float rgba[4]; Uint8 *p; @@ -2974,12 +2974,12 @@ void SDL_DestroySurface(SDL_Surface *surface) SDL_SetSurfacePalette(surface, NULL); if (surface->flags & SDL_SURFACE_PREALLOCATED) { - /* Don't free */ + // Don't free } else if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { - /* Free aligned */ + // Free aligned SDL_aligned_free(surface->pixels); } else { - /* Normal */ + // Normal SDL_free(surface->pixels); } if (!(surface->internal->flags & SDL_INTERNAL_SURFACE_STACK)) { diff --git a/src/video/SDL_surface_c.h b/src/video/SDL_surface_c.h index db3c8060a6..3980095c61 100644 --- a/src/video/SDL_surface_c.h +++ b/src/video/SDL_surface_c.h @@ -23,18 +23,18 @@ #ifndef SDL_surface_c_h_ #define SDL_surface_c_h_ -/* Useful functions and variables from SDL_surface.c */ +// Useful functions and variables from SDL_surface.c #include "../SDL_list.h" -/* Surface internal flags */ +// Surface internal flags typedef Uint32 SDL_SurfaceDataFlags; #define SDL_INTERNAL_SURFACE_DONTFREE 0x00000001u /**< Surface is referenced internally */ #define SDL_INTERNAL_SURFACE_STACK 0x00000002u /**< Surface is allocated on the stack */ #define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */ -/* Surface internal data definition */ +// Surface internal data definition struct SDL_SurfaceData { /** flags for this surface */ @@ -73,7 +73,7 @@ typedef struct SDL_InternalSurface } SDL_InternalSurface; -/* Surface functions */ +// Surface functions extern SDL_bool SDL_SurfaceValid(SDL_Surface *surface); extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface); extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace); @@ -83,4 +83,4 @@ extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colo extern SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale); extern int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); -#endif /* SDL_surface_c_h_ */ +#endif // SDL_surface_c_h_ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 6aeee58fd6..05917319a9 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -25,7 +25,7 @@ #include -/* The SDL video driver */ +// The SDL video driver typedef struct SDL_VideoDisplay SDL_VideoDisplay; typedef struct SDL_VideoDevice SDL_VideoDevice; @@ -39,7 +39,7 @@ typedef struct float HDR_headroom; } SDL_HDROutputProperties; -/* Define the SDL window structure, corresponding to toplevel windows */ +// Define the SDL window structure, corresponding to toplevel windows struct SDL_Window { SDL_WindowID id; @@ -56,8 +56,8 @@ struct SDL_Window SDL_WindowFlags pending_flags; float display_scale; SDL_bool external_graphics_context; - SDL_bool fullscreen_exclusive; /* The window is currently fullscreen exclusive */ - SDL_DisplayID last_fullscreen_exclusive_display; /* The last fullscreen_exclusive display */ + SDL_bool fullscreen_exclusive; // The window is currently fullscreen exclusive + SDL_DisplayID last_fullscreen_exclusive_display; // The last fullscreen_exclusive display SDL_DisplayID last_displayID; /* Stored position and size for the window in the non-fullscreen state, @@ -81,7 +81,7 @@ struct SDL_Window */ SDL_bool tiled; - /* Whether or not the initial position was defined */ + // Whether or not the initial position was defined SDL_bool undefined_x; SDL_bool undefined_y; @@ -94,11 +94,11 @@ struct SDL_Window SDL_Surface *surface; SDL_bool surface_valid; - SDL_bool is_repositioning; /* Set during an SDL_SetWindowPosition() call. */ + SDL_bool is_repositioning; // Set during an SDL_SetWindowPosition() call. SDL_bool is_hiding; - SDL_bool restore_on_show; /* Child was hidden recursively by the parent, restore when shown. */ + SDL_bool restore_on_show; // Child was hidden recursively by the parent, restore when shown. 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(). int safe_inset_left; int safe_inset_right; @@ -163,7 +163,7 @@ struct SDL_VideoDisplay SDL_DisplayData *internal; }; -/* Video device flags */ +// Video device flags typedef enum { VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED = 0x01, @@ -175,7 +175,7 @@ typedef enum VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x40 } DeviceCaps; -/* Fullscreen operations */ +// Fullscreen operations typedef enum { SDL_FULLSCREEN_OP_LEAVE = 0, @@ -186,11 +186,11 @@ typedef enum struct SDL_VideoDevice { /* * * */ - /* The name of this video driver */ + // The name of this video driver const char *name; /* * * */ - /* Initialization/Query functions */ + // Initialization/Query functions /* * Initialize the native video subsystem, filling in the list of @@ -328,22 +328,22 @@ struct SDL_VideoDevice void (*SendWakeupEvent)(SDL_VideoDevice *_this, SDL_Window *window); void (*PumpEvents)(SDL_VideoDevice *_this); - /* Suspend the screensaver */ + // Suspend the screensaver int (*SuspendScreenSaver)(SDL_VideoDevice *_this); - /* Text input */ + // Text input int (*StartTextInput)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); int (*StopTextInput)(SDL_VideoDevice *_this, SDL_Window *window); int (*UpdateTextInputArea)(SDL_VideoDevice *_this, SDL_Window *window); int (*ClearComposition)(SDL_VideoDevice *_this, SDL_Window *window); - /* Screen keyboard */ + // Screen keyboard SDL_bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this); void (*ShowScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void (*HideScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window); SDL_bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window); - /* Clipboard */ + // Clipboard const char **(*GetTextMimeTypes)(SDL_VideoDevice *_this, size_t *num_mime_types); int (*SetClipboardData)(SDL_VideoDevice *_this); void *(*GetClipboardData)(SDL_VideoDevice *_this, const char *mime_type, size_t *size); @@ -352,31 +352,31 @@ struct SDL_VideoDevice int (*SetClipboardText)(SDL_VideoDevice *_this, const char *text); char *(*GetClipboardText)(SDL_VideoDevice *_this); SDL_bool (*HasClipboardText)(SDL_VideoDevice *_this); - /* These functions are only needed if the platform has a separate primary selection buffer */ + // These functions are only needed if the platform has a separate primary selection buffer int (*SetPrimarySelectionText)(SDL_VideoDevice *_this, const char *text); char *(*GetPrimarySelectionText)(SDL_VideoDevice *_this); SDL_bool (*HasPrimarySelectionText)(SDL_VideoDevice *_this); - /* MessageBox */ + // MessageBox int (*ShowMessageBox)(SDL_VideoDevice *_this, const SDL_MessageBoxData *messageboxdata, int *buttonID); - /* Hit-testing */ + // Hit-testing int (*SetWindowHitTest)(SDL_Window *window, SDL_bool enabled); - /* Tell window that app enabled drag'n'drop events */ + // Tell window that app enabled drag'n'drop events void (*AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept); - /* Display the system-level window menu */ + // Display the system-level window menu void (*ShowWindowSystemMenu)(SDL_Window *window, int x, int y); /* * * */ - /* Data common to all drivers */ + // Data common to all drivers SDL_ThreadID thread; SDL_bool checked_texture_framebuffer; SDL_bool is_dummy; SDL_bool suspend_screensaver; SDL_Window *wakeup_window; - SDL_Mutex *wakeup_lock; /* Initialized only if WaitEventTimeout/SendWakeupEvent are supported */ + SDL_Mutex *wakeup_lock; // Initialized only if WaitEventTimeout/SendWakeupEvent are supported int num_displays; SDL_VideoDisplay **displays; SDL_Rect desktop_bounds; @@ -394,7 +394,7 @@ struct SDL_VideoDevice SDL_SystemTheme system_theme; /* * * */ - /* Data used by the GL drivers */ + // Data used by the GL drivers struct { int red_size; @@ -435,7 +435,7 @@ struct SDL_VideoDevice SDL_EGLIntArrayCallback egl_contextattrib_callback; /* * * */ - /* Cache current GL context; don't call the OS when it hasn't changed. */ + // Cache current GL context; don't call the OS when it hasn't changed. /* We have the global pointers here so Cocoa continues to work the way it always has, and the thread-local storage for the general case. */ @@ -450,7 +450,7 @@ struct SDL_VideoDevice SDL_bool gl_allow_no_surface; /* * * */ - /* Data used by the Vulkan drivers */ + // Data used by the Vulkan drivers struct { SDL_FunctionPointer vkGetInstanceProcAddr; @@ -461,7 +461,7 @@ struct SDL_VideoDevice } vulkan_config; /* * * */ - /* Data private to this driver */ + // Data private to this driver SDL_VideoData *internal; struct SDL_GLDriverData *gl_data; @@ -474,7 +474,7 @@ struct SDL_VideoDevice #endif /* * * */ - /* The function used to dispose of this structure */ + // The function used to dispose of this structure void (*free)(SDL_VideoDevice *_this); }; @@ -483,10 +483,10 @@ typedef struct VideoBootStrap const char *name; const char *desc; SDL_VideoDevice *(*create)(void); - int (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonID); /* can be done without initializing backend! */ + int (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonID); // can be done without initializing backend! } VideoBootStrap; -/* Not all of these are available in a given build. Use #ifdefs, etc. */ +// Not all of these are available in a given build. Use #ifdefs, etc. extern VideoBootStrap COCOA_bootstrap; extern VideoBootStrap X11_bootstrap; extern VideoBootStrap WINDOWS_bootstrap; @@ -511,7 +511,7 @@ extern VideoBootStrap OFFSCREEN_bootstrap; extern VideoBootStrap NGAGE_bootstrap; extern VideoBootStrap QNX_bootstrap; -/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */ +// 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 void SDL_SetSystemTheme(SDL_SystemTheme theme); @@ -572,4 +572,4 @@ extern SDL_Capitalization SDL_GetTextInputCapitalization(SDL_PropertiesID props) extern SDL_bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props); extern SDL_bool SDL_GetTextInputMultiline(SDL_PropertiesID props); -#endif /* SDL_sysvideo_h_ */ +#endif // SDL_sysvideo_h_ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index aed4af1a5c..64e52f7297 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" -/* The high-level video driver subsystem */ +// The high-level video driver subsystem #include "SDL_sysvideo.h" #include "SDL_egl_c.h" @@ -38,16 +38,16 @@ #ifdef SDL_VIDEO_OPENGL #include -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL #if defined(SDL_VIDEO_OPENGL_ES) && !defined(SDL_VIDEO_OPENGL) #include -#endif /* SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL -/* GL and GLES2 headers conflict on Linux 32 bits */ +// GL and GLES2 headers conflict on Linux 32 bits #if defined(SDL_VIDEO_OPENGL_ES2) && !defined(SDL_VIDEO_OPENGL) #include -#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL #ifndef SDL_VIDEO_OPENGL #ifndef GL_CONTEXT_RELEASE_BEHAVIOR_KHR @@ -65,7 +65,7 @@ #include #endif -/* Available video drivers */ +// Available video drivers static VideoBootStrap *bootstrap[] = { #ifdef SDL_VIDEO_DRIVER_COCOA &COCOA_bootstrap, @@ -161,7 +161,7 @@ static VideoBootStrap *bootstrap[] = { } #if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) -/* Support for macOS fullscreen spaces */ +// Support for macOS fullscreen spaces extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window); extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_bool blocking); #endif @@ -170,7 +170,7 @@ static void SDL_CheckWindowDisplayChanged(SDL_Window *window); static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window); static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window); -/* Convenience functions for reading driver flags */ +// Convenience functions for reading driver flags static SDL_bool SDL_ModeSwitchingEmulated(SDL_VideoDevice *_this) { if (_this->device_caps & VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED) { @@ -204,7 +204,7 @@ static SDL_bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this) return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES); } -/* Hint to treat all window ops as synchronous */ +// Hint to treat all window ops as synchronous static SDL_bool syncHint; static void SDL_SyncHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue) @@ -221,7 +221,7 @@ static void SDL_SyncIfRequired(SDL_Window *window) static void SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent) { - /* Unlink the window from the existing parent. */ + // Unlink the window from the existing parent. if (window->parent) { if (window->next_sibling) { window->next_sibling->prev_sibling = window->prev_sibling; @@ -246,7 +246,7 @@ static void SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent) } } -/* Support for framebuffer emulation using an accelerated renderer */ +// Support for framebuffer emulation using an accelerated renderer #define SDL_PROP_WINDOW_TEXTUREDATA_POINTER "SDL.internal.window.texturedata" @@ -304,7 +304,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S const char *render_driver = NULL; const char *hint; - /* See if there's a render driver being requested */ + // See if there's a render driver being requested hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); if (hint && *hint != '0' && *hint != '1' && SDL_strcasecmp(hint, "true") != 0 && @@ -320,11 +320,11 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S } } - /* Check to see if there's a specific driver requested */ + // Check to see if there's a specific driver requested if (render_driver) { renderer = SDL_CreateRenderer(window, render_driver); if (!renderer) { - /* The error for this specific renderer has already been set */ + // The error for this specific renderer has already been set return -1; } } else { @@ -334,7 +334,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S if (name && SDL_strcmp(name, SDL_SOFTWARE_RENDERER) != 0) { renderer = SDL_CreateRenderer(window, name); if (renderer) { - break; /* this will work. */ + break; // this will work. } } } @@ -343,9 +343,9 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S } } - 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) */ + // Create the data after we successfully create the renderer (bug #1116) data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); if (!data) { SDL_DestroyRenderer(renderer); @@ -364,7 +364,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S return -1; } - /* Free any old texture and pixel data */ + // Free any old texture and pixel data if (data->texture) { SDL_DestroyTexture(data->texture); data->texture = NULL; @@ -372,7 +372,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S SDL_free(data->pixels); data->pixels = NULL; - /* Find the first format with or without an alpha channel */ + // Find the first format with or without an alpha channel *format = texture_formats[0]; for (i = 0; texture_formats[i] != SDL_PIXELFORMAT_UNKNOWN; ++i) { @@ -390,16 +390,16 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S SDL_TEXTUREACCESS_STREAMING, w, h); if (!data->texture) { - /* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_PROP_WINDOW_TEXTUREDATA_POINTER and not leaked here. */ - return -1; /* NOLINT(clang-analyzer-unix.Malloc) */ + // codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_PROP_WINDOW_TEXTUREDATA_POINTER and not leaked here. + return -1; // NOLINT(clang-analyzer-unix.Malloc) } - /* Create framebuffer data */ + // Create framebuffer data data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format); data->pitch = (((w * data->bytes_per_pixel) + 3) & ~3); { - /* Make static analysis happy about potential SDL_malloc(0) calls. */ + // Make static analysis happy about potential SDL_malloc(0) calls. const size_t allocsize = (size_t)h * data->pitch; data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1); if (!data->pixels) { @@ -410,7 +410,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S *pixels = data->pixels; *pitch = data->pitch; - /* Make sure we're not double-scaling the viewport */ + // Make sure we're not double-scaling the viewport SDL_SetRenderViewport(data->renderer, NULL); return 0; @@ -458,7 +458,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, c return SDL_SetError("No window texture data"); } - /* Update a single rect that contains subrects for best DMA performance */ + // Update a single rect that contains subrects for best DMA performance if (SDL_GetSpanEnclosingRect(w, h, numrects, rects, &rect)) { src = (void *)((Uint8 *)data->pixels + rect.y * data->pitch + @@ -514,7 +514,7 @@ static int SDL_UninitializedVideo(void) return SDL_SetError("Video subsystem has not been initialized"); } -/* Deduplicated list of video bootstrap drivers. */ +// Deduplicated list of video bootstrap drivers. static const VideoBootStrap *deduped_bootstrap[SDL_arraysize(bootstrap) - 1]; int SDL_GetNumVideoDrivers(void) @@ -527,7 +527,7 @@ int SDL_GetNumVideoDrivers(void) num_drivers = 0; - /* Build a list of unique video drivers. */ + // Build a list of unique video drivers. for (int i = 0; bootstrap[i] != NULL; ++i) { SDL_bool duplicate = SDL_FALSE; for (int j = 0; j < i; ++j) { @@ -566,14 +566,14 @@ int SDL_VideoInit(const char *driver_name) SDL_bool init_pen = SDL_FALSE; int i = 0; - /* Check to make sure we don't overwrite '_this' */ + // Check to make sure we don't overwrite '_this' if (_this) { SDL_VideoQuit(); } SDL_InitTicks(); - /* Start the event loop */ + // Start the event loop if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { goto pre_driver_error; } @@ -595,7 +595,7 @@ int SDL_VideoInit(const char *driver_name) } init_pen = SDL_TRUE; - /* Select the proper video driver */ + // Select the proper video driver video = NULL; if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); @@ -642,18 +642,18 @@ int SDL_VideoInit(const char *driver_name) _this->name = bootstrap[i]->name; _this->thread = SDL_GetCurrentThreadID(); - /* Set some very sane GL defaults */ + // Set some very sane GL defaults _this->gl_config.driver_loaded = 0; _this->gl_config.dll_handle = NULL; SDL_GL_ResetAttributes(); - /* Initialize the video subsystem */ + // Initialize the video subsystem if (_this->VideoInit(_this) < 0) { SDL_VideoQuit(); return -1; } - /* Make sure some displays were added */ + // Make sure some displays were added if (_this->num_displays == 0) { SDL_VideoQuit(); return SDL_SetError("The video driver did not add any displays"); @@ -673,7 +673,7 @@ int SDL_VideoInit(const char *driver_name) SDL_PostInitMouse(); - /* We're ready to go! */ + // We're ready to go! return 0; pre_driver_error: @@ -756,7 +756,7 @@ static void SDL_UpdateDesktopBounds(void) static void SDL_FinalizeDisplayMode(SDL_DisplayMode *mode) { - /* Make sure all the fields are set up correctly */ + // Make sure all the fields are set up correctly if (mode->pixel_density <= 0.0f) { mode->pixel_density = 1.0f; } @@ -846,7 +846,7 @@ void SDL_OnDisplayAdded(SDL_VideoDisplay *display) { SDL_Window *window; - /* See if any windows have changed to the new display */ + // See if any windows have changed to the new display for (window = _this->windows; window; window = window->next) { SDL_CheckWindowDisplayChanged(window); } @@ -1012,7 +1012,7 @@ int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect) } } - /* Assume that the displays are left to right */ + // Assume that the displays are left to right if (displayID == SDL_GetPrimaryDisplay()) { rect->x = 0; rect->y = 0; @@ -1051,7 +1051,7 @@ int SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect) } } - /* Oh well, just give the entire display bounds. */ + // Oh well, just give the entire display bounds. return SDL_GetDisplayBounds(displayID, rect); } @@ -1064,7 +1064,7 @@ SDL_DisplayOrientation SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID) if (display->natural_orientation != SDL_ORIENTATION_UNKNOWN) { return display->natural_orientation; } else { - /* Default to landscape if the driver hasn't set it */ + // Default to landscape if the driver hasn't set it return SDL_ORIENTATION_LANDSCAPE; } } @@ -1078,7 +1078,7 @@ SDL_DisplayOrientation SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID) if (display->current_orientation != SDL_ORIENTATION_UNKNOWN) { return display->current_orientation; } else { - /* Default to landscape if the driver hasn't set it */ + // Default to landscape if the driver hasn't set it return SDL_ORIENTATION_LANDSCAPE; } } @@ -1091,7 +1091,7 @@ void SDL_SetDisplayContentScale(SDL_VideoDisplay *display, float scale) display->content_scale = scale; SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, 0, 0); - /* Check the windows on this display */ + // Check the windows on this display for (window = _this->windows; window; window = window->next) { if (display->id == window->last_displayID) { SDL_CheckWindowDisplayScaleChanged(window); @@ -1162,7 +1162,7 @@ static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode * SDL_DisplayMode fullscreen_mode; if (mode->w <= 0 || mode->h <= 0) { - /* Use the desktop mode */ + // Use the desktop mode return NULL; } @@ -1178,7 +1178,7 @@ static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode * if (display) { SDL_UpdateFullscreenDisplayModes(display); - /* Search for an exact match */ + // Search for an exact match if (!mode) { for (int i = 0; i < display->num_fullscreen_modes; ++i) { if (SDL_memcmp(&fullscreen_mode, &display->fullscreen_modes[i], sizeof(fullscreen_mode)) == 0) { @@ -1188,7 +1188,7 @@ static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode * } } - /* Search for a mode with the same characteristics */ + // Search for a mode with the same characteristics if (!mode) { for (int i = 0; i < display->num_fullscreen_modes; ++i) { if (cmpmodes(&fullscreen_mode, &display->fullscreen_modes[i]) == 0) { @@ -1207,12 +1207,12 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ SDL_DisplayMode new_mode; int i, nmodes; - /* Finalize the mode for the display */ + // Finalize the mode for the display SDL_memcpy(&new_mode, mode, sizeof(new_mode)); new_mode.displayID = display->id; SDL_FinalizeDisplayMode(&new_mode); - /* Make sure we don't already have the mode in the list */ + // Make sure we don't already have the mode in the list modes = display->fullscreen_modes; nmodes = display->num_fullscreen_modes; for (i = 0; i < nmodes; ++i) { @@ -1221,7 +1221,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ } } - /* Go ahead and add the new mode */ + // Go ahead and add the new mode if (nmodes == display->max_fullscreen_modes) { modes = (SDL_DisplayMode *)SDL_malloc((display->max_fullscreen_modes + 32) * sizeof(*modes)); if (!modes) { @@ -1229,7 +1229,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ } if (display->fullscreen_modes) { - /* Copy the list and update the current mode pointer, if necessary. */ + // Copy the list and update the current mode pointer, if necessary. SDL_memcpy(modes, display->fullscreen_modes, nmodes * sizeof(*modes)); for (i = 0; i < nmodes; ++i) { if (display->current_mode == &display->fullscreen_modes[i]) { @@ -1245,7 +1245,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ } SDL_memcpy(&modes[display->num_fullscreen_modes++], &new_mode, sizeof(new_mode)); - /* Re-sort video modes */ + // Re-sort video modes SDL_qsort(display->fullscreen_modes, display->num_fullscreen_modes, sizeof(SDL_DisplayMode), cmpmodes); @@ -1332,7 +1332,7 @@ int SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, f mode = &display->fullscreen_modes[i]; if (w > mode->w) { - /* Out of sorted modes large enough here */ + // Out of sorted modes large enough here break; } if (h > mode->h) { @@ -1347,7 +1347,7 @@ int SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, f float current_aspect_ratio = (float)mode->w / mode->h; float closest_aspect_ratio = (float)closest->w / closest->h; if (SDL_fabsf(aspect_ratio - closest_aspect_ratio) < SDL_fabsf(aspect_ratio - current_aspect_ratio)) { - /* The mode we already found has a better aspect ratio match */ + // The mode we already found has a better aspect ratio match continue; } @@ -1432,7 +1432,7 @@ const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID) CHECK_DISPLAY_MAGIC(display, NULL); - /* Make sure our mode list is updated */ + // Make sure our mode list is updated SDL_UpdateFullscreenDisplayModes(display); return display->current_mode; @@ -1456,7 +1456,7 @@ int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mod return 0; } - /* Actually change the display mode */ + // Actually change the display mode if (_this->SetDisplayMode) { int result; @@ -1512,12 +1512,12 @@ static SDL_DisplayID GetDisplayForRect(int x, int y, int w, int h) SDL_Rect display_rect; SDL_GetDisplayBounds(display->id, &display_rect); - /* Check if the window is fully enclosed */ + // Check if the window is fully enclosed if (SDL_GetRectEnclosingPoints(¢er, 1, &display_rect, NULL)) { return display->id; } - /* Snap window center to the display rect */ + // Snap window center to the display rect closest_point_on_display = center; SDL_GetClosestPointOnRect(&display_rect, &closest_point_on_display); @@ -1543,7 +1543,7 @@ void SDL_RelativeToGlobalForWindow(SDL_Window *window, int rel_x, int rel_y, int SDL_Window *w; if (SDL_WINDOW_IS_POPUP(window)) { - /* Calculate the total offset of the popup from the parents */ + // Calculate the total offset of the popup from the parents for (w = window->parent; w; w = w->parent) { rel_x += w->x; rel_y += w->y; @@ -1563,7 +1563,7 @@ void SDL_GlobalToRelativeForWindow(SDL_Window *window, int abs_x, int abs_y, int SDL_Window *w; if (SDL_WINDOW_IS_POPUP(window)) { - /* Convert absolute window coordinates to relative for a popup */ + // Convert absolute window coordinates to relative for a popup for (w = window->parent; w; w = w->parent) { abs_x -= w->x; abs_y -= w->y; @@ -1617,7 +1617,7 @@ SDL_DisplayID SDL_GetDisplayForWindowPosition(SDL_Window *window) } } if (!displayID) { - /* Use the primary display for a window if we can't find it anywhere else */ + // Use the primary display for a window if we can't find it anywhere else displayID = SDL_GetPrimaryDisplay(); } return displayID; @@ -1629,7 +1629,7 @@ SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window) CHECK_WINDOW_MAGIC(window, 0); - /* An explicit fullscreen display overrides all */ + // An explicit fullscreen display overrides all if (window->current_fullscreen_mode.displayID) { displayID = window->current_fullscreen_mode.displayID; } @@ -1643,14 +1643,14 @@ SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window) */ if (!displayID) { if (window->flags & SDL_WINDOW_FULLSCREEN && !window->is_repositioning) { - /* This was a window manager initiated move, use the current position. */ + // This was a window manager initiated move, use the current position. displayID = GetDisplayForRect(window->x, window->y, 1, 1); } else { displayID = GetDisplayForRect(window->floating.x, window->floating.y, window->floating.w, window->floating.h); } } if (!displayID) { - /* Use the primary display for a window if we can't find it anywhere else */ + // Use the primary display for a window if we can't find it anywhere else displayID = SDL_GetPrimaryDisplay(); } return SDL_GetVideoDisplay(displayID); @@ -1662,7 +1662,7 @@ SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window) CHECK_WINDOW_MAGIC(window, 0); - /* An explicit fullscreen display overrides all */ + // An explicit fullscreen display overrides all if (window->flags & SDL_WINDOW_FULLSCREEN) { displayID = window->current_fullscreen_mode.displayID; } @@ -1684,7 +1684,7 @@ static void SDL_CheckWindowDisplayChanged(SDL_Window *window) if (displayID != window->last_displayID) { int i, display_index; - /* Sanity check our fullscreen windows */ + // Sanity check our fullscreen windows display_index = SDL_GetDisplayIndex(displayID); for (i = 0; i < _this->num_displays; ++i) { SDL_VideoDisplay *display = _this->displays[i]; @@ -1696,10 +1696,10 @@ static void SDL_CheckWindowDisplayChanged(SDL_Window *window) } else { SDL_VideoDisplay *new_display = _this->displays[display_index]; - /* The window was moved to a different display */ + // The window was moved to a different display if (new_display->fullscreen_window && new_display->fullscreen_window != window) { - /* Uh oh, there's already a fullscreen window here; minimize it */ + // Uh oh, there's already a fullscreen window here; minimize it SDL_MinimizeWindow(new_display->fullscreen_window); } new_display->fullscreen_window = window; @@ -1761,7 +1761,7 @@ static void SDL_RestoreMousePosition(SDL_Window *window) const SDL_bool prev_warp_val = mouse->warp_emulation_prohibited; SDL_GetMouseState(&x, &y); - /* Disable the warp emulation so it isn't accidentally activated on a fullscreen transitions. */ + // Disable the warp emulation so it isn't accidentally activated on a fullscreen transitions. mouse->warp_emulation_prohibited = SDL_TRUE; SDL_WarpMouseInWindow(window, x, y); mouse->warp_emulation_prohibited = prev_warp_val; @@ -1778,16 +1778,16 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD window->fullscreen_exclusive = SDL_FALSE; - /* If we are in the process of hiding don't go back to fullscreen */ + // If we are in the process of hiding don't go back to fullscreen if (window->is_destroying || window->is_hiding) { fullscreen = SDL_FALSE; } - /* Get the correct display for this operation */ + // Get the correct display for this operation if (fullscreen) { display = SDL_GetVideoDisplayForFullscreenWindow(window); if (!display) { - /* This should never happen, but it did... */ + // This should never happen, but it did... goto done; } } else { @@ -1798,7 +1798,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } } if (!display || i == _this->num_displays) { - /* Already not fullscreen on any display */ + // Already not fullscreen on any display display = NULL; } } @@ -1808,7 +1808,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (mode) { window->fullscreen_exclusive = SDL_TRUE; } else { - /* Make sure the current mode is zeroed for fullscreen desktop. */ + // Make sure the current mode is zeroed for fullscreen desktop. SDL_zero(window->current_fullscreen_mode); } } @@ -1817,7 +1817,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD /* 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_exclusive_display) { window->fullscreen_exclusive = SDL_FALSE; if (display) { @@ -1826,7 +1826,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD goto done; } if (commit) { - /* If we're switching between a fullscreen Space and exclusive fullscreen, we need to get back to normal first. */ + // If we're switching between a fullscreen Space and exclusive fullscreen, we need to get back to normal first. if (fullscreen && Cocoa_IsWindowInFullscreenSpace(window) && !window->last_fullscreen_exclusive_display && window->fullscreen_exclusive) { if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE, SDL_TRUE)) { goto error; @@ -1881,7 +1881,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD #endif if (display) { - /* Restore the video mode on other displays if needed */ + // Restore the video mode on other displays if needed for (i = 0; i < _this->num_displays; ++i) { SDL_VideoDisplay *other = _this->displays[i]; if (other != display && other->fullscreen_window == window) { @@ -1895,7 +1895,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD int mode_w = 0, mode_h = 0; SDL_bool resized = SDL_FALSE; - /* Hide any other fullscreen window on this display */ + // Hide any other fullscreen window on this display if (display->fullscreen_window && display->fullscreen_window != window) { SDL_MinimizeWindow(display->fullscreen_window); @@ -1913,7 +1913,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } if (ret == 0) { - /* Window is fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. */ + // Window is fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); } @@ -1952,7 +1952,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } } - /* Restore the cursor position */ + // Restore the cursor position if (!SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { SDL_RestoreMousePosition(window); } @@ -1960,7 +1960,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } else { SDL_bool resized = SDL_FALSE; - /* Restore the desktop mode */ + // Restore the desktop mode if (display) { SDL_SetDisplayModeForDisplay(display, NULL); } @@ -1976,7 +1976,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } if (ret == 0) { - /* Window left fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. */ + // Window left fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. if (window->flags & SDL_WINDOW_FULLSCREEN) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); } @@ -1998,7 +1998,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } } - /* Restore the cursor position if we've exited fullscreen on a display */ + // Restore the cursor position if we've exited fullscreen on a display if (display && !SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { SDL_RestoreMousePosition(window); } @@ -2011,7 +2011,7 @@ done: error: if (fullscreen) { - /* Something went wrong and the window is no longer fullscreen. */ + // Something went wrong and the window is no longer fullscreen. SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, commit); } return -1; @@ -2027,7 +2027,7 @@ int SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode) return SDL_SetError("Invalid fullscreen display mode"); } - /* Save the mode so we can look up the closest match later */ + // Save the mode so we can look up the closest match later SDL_copyp(&window->requested_fullscreen_mode, mode); } else { SDL_zero(window->requested_fullscreen_mode); @@ -2093,7 +2093,7 @@ static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void) return SDL_FALSE; } -/* prepare a newly-created window */ +// prepare a newly-created window static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window) { if (_this->AcceptDragAndDrop) { @@ -2101,7 +2101,7 @@ static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window) } } -/* toggle d'n'd for all existing windows. */ +// toggle d'n'd for all existing windows. void SDL_ToggleDragAndDropSupport(void) { if (_this && _this->AcceptDragAndDrop) { @@ -2264,12 +2264,12 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) SDL_bool external_graphics_context = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, SDL_FALSE); if (!_this) { - /* Initialize the video system if needed */ + // Initialize the video system if needed if (SDL_Init(SDL_INIT_VIDEO) < 0) { return NULL; } - /* Make clang-tidy happy */ + // Make clang-tidy happy if (!_this) { return NULL; } @@ -2286,29 +2286,29 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) return NULL; } - /* Tooltip and popup menu window must specify a parent window */ + // Tooltip and popup menu window must specify a parent window if (!SDL_ObjectValid(parent, SDL_OBJECT_TYPE_WINDOW)) { SDL_SetError("Tooltip and popup menu windows must specify a parent window"); return NULL; } - /* Remove invalid flags */ + // Remove invalid flags flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS); } - /* Ensure no more than one of these flags is set */ + // Ensure no more than one of these flags is set type_flags = flags & (SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_MODAL); if (type_flags & (type_flags - 1)) { SDL_SetError("Conflicting window type flags specified: 0x%.8x", (unsigned int)type_flags); return NULL; } - /* Make sure the display list is up to date for window placement */ + // Make sure the display list is up to date for window placement if (_this->RefreshDisplays) { _this->RefreshDisplays(_this); } - /* Some platforms can't create zero-sized windows */ + // Some platforms can't create zero-sized windows if (w < 1) { w = 1; } @@ -2333,7 +2333,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) SDL_zero(bounds); SDL_GetDisplayUsableBounds(displayID, &bounds); if (w > bounds.w || h > bounds.h) { - /* This window is larger than the usable bounds, just center on the display */ + // This window is larger than the usable bounds, just center on the display SDL_GetDisplayUsableBounds(displayID, &bounds); } if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISUNDEFINED(x)) { @@ -2350,14 +2350,14 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) } } - /* ensure no more than one of these flags is set */ + // ensure no more than one of these flags is set graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); if (graphics_flags & (graphics_flags - 1)) { SDL_SetError("Conflicting window graphics flags specified: 0x%.8x", (unsigned int)graphics_flags); return NULL; } - /* Some platforms have certain graphics backends enabled by default */ + // Some platforms have certain graphics backends enabled by default if (!graphics_flags && !external_graphics_context) { flags |= SDL_DefaultGraphicsBackends(_this); } @@ -2430,7 +2430,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) } _this->windows = window; - /* Set the parent before creation if this is non-modal, otherwise it will be set later. */ + // Set the parent before creation if this is non-modal, otherwise it will be set later. if (!(flags & SDL_WINDOW_MODAL)) { SDL_SetWindowParent(window, parent); } @@ -2469,7 +2469,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) } SDL_FinishWindowCreation(window, flags); - /* Make sure window pixel size is up to date */ + // Make sure window pixel size is up to date SDL_CheckWindowPixelSizeChanged(window); SDL_ClearError(); @@ -2497,7 +2497,7 @@ SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y SDL_Window *window; SDL_PropertiesID props = SDL_CreateProperties(); - /* Popups must specify either the tooltip or popup menu window flags */ + // Popups must specify either the tooltip or popup menu window flags if (!(flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))) { SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag"); return NULL; @@ -2525,7 +2525,7 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) SDL_WindowFlags graphics_flags; SDL_Window *parent = window->parent; - /* ensure no more than one of these flags is set */ + // ensure no more than one of these flags is set graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); if (graphics_flags & (graphics_flags - 1)) { return SDL_SetError("Conflicting window flags specified"); @@ -2542,25 +2542,25 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) } if (window->flags & SDL_WINDOW_EXTERNAL) { - /* Can't destroy and re-create external windows, hrm */ + // Can't destroy and re-create external windows, hrm flags |= SDL_WINDOW_EXTERNAL; } else { flags &= ~SDL_WINDOW_EXTERNAL; } - /* If this is a modal dialog, clear the modal status. */ + // If this is a modal dialog, clear the modal status. if (window->flags & SDL_WINDOW_MODAL) { SDL_SetWindowModalFor(window, NULL); } - /* Restore video mode, etc. */ + // Restore video mode, etc. if (!(window->flags & SDL_WINDOW_EXTERNAL)) { const SDL_bool restore_on_show = window->restore_on_show; SDL_HideWindow(window); window->restore_on_show = restore_on_show; } - /* Tear down the old native window */ + // Tear down the old native window SDL_DestroyWindowSurface(window); if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { @@ -2763,7 +2763,7 @@ int SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) SDL_DestroySurface(window->icon); - /* Convert the icon into ARGB8888 */ + // Convert the icon into ARGB8888 window->icon = SDL_ConvertSurface(icon, SDL_PIXELFORMAT_ARGB8888); if (!window->icon) { return -1; @@ -2841,7 +2841,7 @@ int SDL_GetWindowPosition(SDL_Window *window, int *x, int *y) { CHECK_WINDOW_MAGIC(window, -1); - /* Fullscreen windows are always at their display's origin */ + // Fullscreen windows are always at their display's origin if (window->flags & SDL_WINDOW_FULLSCREEN) { SDL_DisplayID displayID; @@ -2884,7 +2884,7 @@ int SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (bordered != SDL_FALSE); /* normalize the flag. */ + const SDL_bool want = (bordered != SDL_FALSE); // normalize the flag. const SDL_bool have = !(window->flags & SDL_WINDOW_BORDERLESS); if ((want != have) && (_this->SetWindowBordered)) { if (want) { @@ -2903,7 +2903,7 @@ int SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (resizable != SDL_FALSE); /* normalize the flag. */ + const SDL_bool want = (resizable != SDL_FALSE); // normalize the flag. const SDL_bool have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0); if ((want != have) && (_this->SetWindowResizable)) { if (want) { @@ -2923,7 +2923,7 @@ int SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (on_top != SDL_FALSE); /* normalize the flag. */ + const SDL_bool want = (on_top != SDL_FALSE); // normalize the flag. const SDL_bool have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); if ((want != have) && (_this->SetWindowAlwaysOnTop)) { if (want) { @@ -2948,9 +2948,9 @@ int SDL_SetWindowSize(SDL_Window *window, int w, int h) return SDL_InvalidParamError("h"); } - /* It is possible for the aspect ratio contraints to not satisfy the size constraints. */ - /* The size constraints will override the aspect ratio contraints so we will apply the */ - /* the aspect ratio constraints first */ + // It is possible for the aspect ratio contraints to not satisfy the size constraints. + // The size constraints will override the aspect ratio contraints so we will apply the + // the aspect ratio constraints first float new_aspect = w / (float)h; if (window->max_aspect > 0.0f && new_aspect > window->max_aspect) { w = (int)SDL_roundf(h * window->max_aspect); @@ -2958,7 +2958,7 @@ int SDL_SetWindowSize(SDL_Window *window, int w, int h) h = (int)SDL_roundf(w / window->min_aspect); } - /* Make sure we don't exceed any window size limits */ + // Make sure we don't exceed any window size limits if (window->min_w && w < window->min_w) { w = window->min_w; } @@ -3038,7 +3038,7 @@ int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *botto bottom = &dummy; } - /* Always initialize, so applications don't have to care */ + // Always initialize, so applications don't have to care *top = *left = *bottom = *right = 0; CHECK_WINDOW_MAGIC(window, -1); @@ -3109,7 +3109,7 @@ int SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h) _this->SetWindowMinimumSize(_this, window); } - /* Ensure that window is not smaller than minimal size */ + // Ensure that window is not smaller than minimal size w = window->min_w ? SDL_max(window->floating.w, window->min_w) : window->floating.w; h = window->min_h ? SDL_max(window->floating.h, window->min_h) : window->floating.h; return SDL_SetWindowSize(window, w, h); @@ -3150,7 +3150,7 @@ int SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h) _this->SetWindowMaximumSize(_this, window); } - /* Ensure that window is not larger than maximal size */ + // Ensure that window is not larger than maximal size w = window->max_w ? SDL_min(window->floating.w, window->max_w) : window->floating.w; h = window->max_h ? SDL_min(window->floating.h, window->max_h) : window->floating.h; return SDL_SetWindowSize(window, w, h); @@ -3177,7 +3177,7 @@ int SDL_ShowWindow(SDL_Window *window) return 0; } - /* If the parent is hidden, set the flag to restore this when the parent is shown */ + // If the parent is hidden, set the flag to restore this when the parent is shown if (window->parent && (window->parent->flags & SDL_WINDOW_HIDDEN)) { window->restore_on_show = SDL_TRUE; return 0; @@ -3191,7 +3191,7 @@ int SDL_ShowWindow(SDL_Window *window) } SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0); - /* Restore child windows */ + // Restore child windows for (child = window->first_child; child; child = child->next_sibling) { if (!child->restore_on_show && (child->flags & SDL_WINDOW_HIDDEN)) { break; @@ -3212,7 +3212,7 @@ int SDL_HideWindow(SDL_Window *window) return 0; } - /* Hide all child windows */ + // Hide all child windows for (child = window->first_child; child; child = child->next_sibling) { if (child->flags & SDL_WINDOW_HIDDEN) { break; @@ -3221,7 +3221,7 @@ int SDL_HideWindow(SDL_Window *window) child->restore_on_show = SDL_TRUE; } - /* Store the flags for restoration later. */ + // Store the flags for restoration later. window->pending_flags = window->flags; window->is_hiding = SDL_TRUE; @@ -3327,14 +3327,14 @@ int SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) } if (fullscreen) { - /* Set the current fullscreen mode to the desired mode */ + // Set the current fullscreen mode to the desired mode SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); } ret = SDL_UpdateFullscreenMode(window, fullscreen ? SDL_FULLSCREEN_OP_ENTER : SDL_FULLSCREEN_OP_LEAVE, SDL_TRUE); if (!fullscreen || ret != 0) { - /* Clear the current fullscreen mode. */ + // Clear the current fullscreen mode. SDL_zero(window->current_fullscreen_mode); } @@ -3361,12 +3361,12 @@ static SDL_bool ShouldAttemptTextureFramebuffer(void) const char *hint; SDL_bool attempt_texture_framebuffer = SDL_TRUE; - /* The dummy driver never has GPU support, of course. */ + // The dummy driver never has GPU support, of course. if (_this->is_dummy) { return SDL_FALSE; } - /* See if there's a hint override */ + // See if there's a hint override hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); if (hint && *hint) { if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0 || SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) == 0) { @@ -3375,17 +3375,17 @@ static SDL_bool ShouldAttemptTextureFramebuffer(void) attempt_texture_framebuffer = SDL_TRUE; } } else { - /* Check for platform specific defaults */ + // Check for platform specific defaults #ifdef SDL_PLATFORM_LINUX - /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ + // On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; - if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ + if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { // if either of these exist, we're on WSL. attempt_texture_framebuffer = SDL_FALSE; } } #endif -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) // GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) if (_this->CreateWindowFramebuffer && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } @@ -3418,7 +3418,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) !!! FIXME: a software fallback at the system level (can we blit to an !!! FIXME: OpenGL window? etc). */ } else { - /* future attempts will just try to use a texture framebuffer. */ + // future attempts will just try to use a texture framebuffer. /* !!! FIXME: maybe we shouldn't override these but check if we used a texture !!! FIXME: framebuffer at the right places; is it feasible we could have an !!! FIXME: accelerated OpenGL window and a second ends up in software? */ @@ -3431,7 +3431,7 @@ static SDL_Surface *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) { @@ -3446,7 +3446,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } if (window->surface) { - /* We may have gone recursive and already created the surface */ + // We may have gone recursive and already created the surface return window->surface; } @@ -3522,7 +3522,7 @@ int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface"); } - SDL_assert(_this->checked_texture_framebuffer); /* we should have done this before we had a valid surface. */ + SDL_assert(_this->checked_texture_framebuffer); // we should have done this before we had a valid surface. return _this->UpdateWindowFramebuffer(_this, window, rects, numrects); } @@ -3538,7 +3538,7 @@ int SDL_DestroyWindowSurface(SDL_Window *window) window->surface_valid = SDL_FALSE; } - if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ + if (_this->checked_texture_framebuffer) { // never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. if (_this->DestroyWindowFramebuffer) { _this->DestroyWindowFramebuffer(_this, window); } @@ -3595,7 +3595,7 @@ int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window) } else if (modal_window->flags & SDL_WINDOW_MODAL) { modal_window->flags &= ~SDL_WINDOW_MODAL; } else { - return 0; /* Not modal; nothing to do. */ + return 0; // Not modal; nothing to do. } const int ret = _this->SetWindowModalFor(_this, modal_window, parent_window); @@ -3614,7 +3614,7 @@ int SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable) { CHECK_WINDOW_MAGIC(window, -1); - const SDL_bool want = (focusable != SDL_FALSE); /* normalize the flag. */ + const SDL_bool want = (focusable != SDL_FALSE); // normalize the flag. const SDL_bool have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE); if ((want != have) && (_this->SetWindowFocusable)) { if (want) { @@ -3651,7 +3651,7 @@ void SDL_UpdateWindowGrab(SDL_Window *window) if (mouse_grabbed || keyboard_grabbed) { if (_this->grabbed_window && (_this->grabbed_window != window)) { - /* stealing a grab from another window! */ + // stealing a grab from another window! _this->grabbed_window->flags &= ~(SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED); if (_this->SetWindowMouseGrab) { _this->SetWindowMouseGrab(_this, _this->grabbed_window, SDL_FALSE); @@ -3662,7 +3662,7 @@ void 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) { @@ -3839,7 +3839,7 @@ int SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation) void SDL_OnWindowShown(SDL_Window *window) { - /* Set window state if we have pending window flags cached */ + // Set window state if we have pending window flags cached ApplyWindowFlags(window, window->pending_flags); window->pending_flags = 0; } @@ -3852,7 +3852,7 @@ void SDL_OnWindowHidden(SDL_Window *window) */ window->pending_flags |= (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)); - /* The window is already hidden at this point, so just change the mode back if necessary. */ + // The window is already hidden at this point, so just change the mode back if necessary. SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_FALSE); } @@ -3975,7 +3975,7 @@ void SDL_OnWindowRestored(SDL_Window *window) * windows shouldn't affect the stacking order; maybe the right fix is to * re-decouple OnWindowShown and OnWindowRestored. */ - /*SDL_RaiseWindow(window);*/ + // SDL_RaiseWindow(window); if (window->flags & SDL_WINDOW_FULLSCREEN) { SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, SDL_FALSE); @@ -4016,7 +4016,7 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) } #if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) - 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 (Cocoa_IsWindowInFullscreenSpace(window)) { return SDL_FALSE; } @@ -4032,7 +4032,7 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) } #endif - /* Real fullscreen windows should minimize on focus loss so the desktop video mode is restored */ + // Real fullscreen windows should minimize on focus loss so the desktop video mode is restored hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { if (window->fullscreen_exclusive && !SDL_ModeSwitchingEmulated(_this)) { @@ -4058,7 +4058,7 @@ SDL_Window *SDL_GetToplevelForKeyboardFocus(void) SDL_Window *focus = SDL_GetKeyboardFocus(); if (focus) { - /* Get the toplevel parent window. */ + // Get the toplevel parent window. while (focus->parent) { focus = focus->parent; } @@ -4073,7 +4073,7 @@ void SDL_DestroyWindow(SDL_Window *window) window->is_destroying = SDL_TRUE; - /* Destroy any child windows of this window */ + // Destroy any child windows of this window while (window->first_child) { SDL_DestroyWindow(window->first_child); } @@ -4085,7 +4085,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_DestroyRendererWithoutFreeing(renderer); } - /* Restore video mode, etc. */ + // Restore video mode, etc. SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_TRUE); if (!(window->flags & SDL_WINDOW_EXTERNAL)) { SDL_HideWindow(window); @@ -4102,14 +4102,14 @@ void SDL_DestroyWindow(SDL_Window *window) _this->SetWindowModalFor(_this, window, NULL); } - /* Make sure the destroyed window isn't referenced by any display as a fullscreen window. */ + // Make sure the destroyed window isn't referenced by any display as a fullscreen window. for (int i = 0; i < _this->num_displays; ++i) { if (_this->displays[i]->fullscreen_window == window) { _this->displays[i]->fullscreen_window = NULL; } } - /* Make sure this window no longer has focus */ + // Make sure this window no longer has focus if (SDL_GetKeyboardFocus() == window) { SDL_SetKeyboardFocus(NULL); } @@ -4122,7 +4122,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_DestroyWindowSurface(window); - /* Make no context current if this is the current context window */ + // Make no context current if this is the current context window if (window->flags & SDL_WINDOW_OPENGL) { if (_this->current_glwin == window) { SDL_GL_MakeCurrent(window, NULL); @@ -4133,7 +4133,7 @@ void SDL_DestroyWindow(SDL_Window *window) _this->DestroyWindow(_this, window); } - /* Unload the graphics libraries after the window is destroyed, which may clean up EGL surfaces */ + // Unload the graphics libraries after the window is destroyed, which may clean up EGL surfaces if (window->flags & SDL_WINDOW_OPENGL) { SDL_GL_UnloadLibrary(); } @@ -4142,7 +4142,7 @@ void SDL_DestroyWindow(SDL_Window *window) } if (_this->grabbed_window == window) { - _this->grabbed_window = NULL; /* ungrabbing input. */ + _this->grabbed_window = NULL; // ungrabbing input. } if (_this->current_glwin == window) { @@ -4153,17 +4153,17 @@ void SDL_DestroyWindow(SDL_Window *window) _this->wakeup_window = NULL; } - /* Now invalidate magic */ + // Now invalidate magic SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, SDL_FALSE); - /* Free memory associated with the window */ + // Free memory associated with the window SDL_free(window->title); SDL_DestroySurface(window->icon); - /* Unlink the window from its siblings. */ + // Unlink the window from its siblings. SDL_SetWindowParent(window, NULL); - /* Unlink the window from the list */ + // Unlink the window from the list if (window->next) { window->next->prev = window->prev; } @@ -4224,7 +4224,7 @@ void SDL_VideoQuit(void) return; } - /* Halt event processing before doing anything else */ + // Halt event processing before doing anything else SDL_QuitPen(); SDL_QuitTouch(); SDL_QuitMouse(); @@ -4233,7 +4233,7 @@ void SDL_VideoQuit(void) SDL_EnableScreenSaver(); - /* Clean up the system video */ + // Clean up the system video while (_this->windows) { SDL_DestroyWindow(_this->windows); } @@ -4357,7 +4357,7 @@ static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) { return verstr && (SDL_atoi(verstr) >= 3); } -#endif /* SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 */ +#endif // SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 SDL_bool SDL_GL_ExtensionSupported(const char *extension) { @@ -4367,18 +4367,18 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) const char *start; const char *where, *terminator; - /* Extension names should not have spaces. */ + // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { return SDL_FALSE; } - /* See if there's a hint or environment variable override */ + // See if there's a hint or environment variable override start = SDL_GetHint(extension); if (start && *start == '0') { return SDL_FALSE; } - /* Lookup the available extensions */ + // Lookup the available extensions glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); if (!glGetStringFunc) { @@ -4411,7 +4411,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) return SDL_FALSE; } - /* Try the old way with glGetString(GL_EXTENSIONS) ... */ + // Try the old way with glGetString(GL_EXTENSIONS) ... extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); if (!extensions) { @@ -4453,8 +4453,8 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) */ 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. */ +// 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. #if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) /* XXX This is fragile; it will break in the event of release of * new versions of OpenGL ES. @@ -4514,7 +4514,7 @@ void SDL_GL_ResetAttributes(void) _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 #ifdef SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; @@ -4662,7 +4662,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) return retval; #else return SDL_Unsupported(); -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL } int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) @@ -4689,7 +4689,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return SDL_InvalidParamError("value"); } - /* Clear value in any case */ + // Clear value in any case *value = 0; if (!_this) { @@ -4726,9 +4726,9 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) attrib = GL_DOUBLEBUFFER; break; #else - /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */ - /* parameter which switches double buffer to single buffer. OpenGL ES */ - /* SDL driver must set proper value after initialization */ + // OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER + // parameter which switches double buffer to single buffer. OpenGL ES + // SDL driver must set proper value after initialization *value = _this->gl_config.double_buffer; return 0; #endif @@ -4768,7 +4768,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) case SDL_GL_ACCUM_BLUE_SIZE: case SDL_GL_ACCUM_ALPHA_SIZE: case SDL_GL_STEREO: - /* none of these are supported in OpenGL ES */ + // none of these are supported in OpenGL ES *value = 0; return 0; #endif @@ -4789,7 +4789,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { int rsize = 0, gsize = 0, bsize = 0, asize = 0; - /* There doesn't seem to be a single flag in OpenGL for this! */ + // 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; } @@ -4808,7 +4808,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } case SDL_GL_ACCELERATED_VISUAL: { - /* FIXME: How do we get this information? */ + // FIXME: How do we get this information? *value = (_this->gl_config.accelerated != 0); return 0; } @@ -4868,7 +4868,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } if (attachmentattrib && isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { - /* glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. */ + // glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. GLint current_fbo = 0; PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv"); PFNGLBINDFRAMEBUFFERPROC glBindFramebufferFunc = (PFNGLBINDFRAMEBUFFERPROC)SDL_GL_GetProcAddress("glBindFramebuffer"); @@ -4916,7 +4916,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; #else return SDL_Unsupported(); -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL } #define NOT_AN_OPENGL_WINDOW "The specified window isn't an OpenGL window" @@ -4933,7 +4933,7 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window) ctx = _this->GL_CreateContext(_this, window); - /* Creating a context is assumed to make it current in the SDL driver. */ + // Creating a context is assumed to make it current in the SDL driver. if (ctx) { _this->current_glwin = window; _this->current_glctx = ctx; @@ -4953,7 +4953,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) if (window == SDL_GL_GetCurrentWindow() && context == SDL_GL_GetCurrentContext()) { - /* We're already current. */ + // We're already current. return 0; } @@ -5117,7 +5117,7 @@ int SDL_GL_DestroyContext(SDL_GLContext context) return _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. @@ -5189,7 +5189,7 @@ static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int fl void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { if (icon && _this->SetIcon) { - /* Generate a mask if necessary, and create the icon! */ + // Generate a mask if necessary, and create the icon! if (mask == NULL) { int mask_len = icon->h * (icon->w + 7) / 8; int flags = 0; @@ -5288,7 +5288,7 @@ int SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props) } } - /* Show the on-screen keyboard, if desired */ + // Show the on-screen keyboard, if desired if (AutoShowingScreenKeyboard() && !SDL_ScreenKeyboardShown(window)) { if (_this->ShowScreenKeyboard) { _this->ShowScreenKeyboard(_this, window, props); @@ -5296,7 +5296,7 @@ int SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props) } if (!window->text_input_active) { - /* Finally start the text input system */ + // Finally start the text input system if (_this->StartTextInput) { if (_this->StartTextInput(_this, window, props) < 0) { return -1; @@ -5319,14 +5319,14 @@ int SDL_StopTextInput(SDL_Window *window) CHECK_WINDOW_MAGIC(window, -1); if (window->text_input_active) { - /* Stop the text input system */ + // Stop the text input system if (_this->StopTextInput) { _this->StopTextInput(_this, window); } window->text_input_active = SDL_FALSE; } - /* Hide the on-screen keyboard, if desired */ + // Hide the on-screen keyboard, if desired if (AutoShowingScreenKeyboard() && SDL_ScreenKeyboardShown(window)) { if (_this->HideScreenKeyboard) { _this->HideScreenKeyboard(_this, window); @@ -5475,7 +5475,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) if (_this && _this->ShowMessageBox) { retval = _this->ShowMessageBox(_this, messageboxdata, buttonID); } else { - /* It's completely fine to call this function before video is initialized */ + // It's completely fine to call this function before video is initialized const char *driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; @@ -5533,7 +5533,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) int SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window) { #ifdef SDL_PLATFORM_EMSCRIPTEN - /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */ + // !!! FIXME: propose a browser API for this, get this #ifdef out of here? /* Web browsers don't (currently) have an API for a custom message box that can block, but for the most common case (SDL_ShowSimpleMessageBox), we can use the standard Javascript alert() function. */ @@ -5813,7 +5813,7 @@ SDL_MetalView SDL_Metal_CreateView(SDL_Window *window) } if (!(window->flags & SDL_WINDOW_METAL)) { - /* No problem, we can convert to Metal */ + // No problem, we can convert to Metal if (window->flags & SDL_WINDOW_OPENGL) { window->flags &= ~SDL_WINDOW_OPENGL; SDL_GL_UnloadLibrary(); @@ -5853,8 +5853,8 @@ void *SDL_Metal_GetLayer(SDL_MetalView view) #if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name) { - /* Reference: https://www.w3.org/TR/css-ui-4/#cursor */ - /* Also in: https://www.freedesktop.org/wiki/Specifications/cursor-spec/ */ + // Reference: https://www.w3.org/TR/css-ui-4/#cursor + // Also in: https://www.freedesktop.org/wiki/Specifications/cursor-spec/ switch (id) { case SDL_SYSTEM_CURSOR_DEFAULT: return "default"; @@ -5873,14 +5873,14 @@ const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name case SDL_SYSTEM_CURSOR_NWSE_RESIZE: if (fallback_name) { - /* only a single arrow */ + // only a single arrow *fallback_name = "nw-resize"; } return "nwse-resize"; case SDL_SYSTEM_CURSOR_NESW_RESIZE: if (fallback_name) { - /* only a single arrow */ + // only a single arrow *fallback_name = "ne-resize"; } return "nesw-resize"; diff --git a/src/video/SDL_video_c.h b/src/video/SDL_video_c.h index 2251ce3053..4dd5210dc7 100644 --- a/src/video/SDL_video_c.h +++ b/src/video/SDL_video_c.h @@ -65,4 +65,4 @@ extern int SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Ui const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name); #endif -#endif /* SDL_video_c_h_ */ +#endif // SDL_video_c_h_ diff --git a/src/video/SDL_video_unsupported.c b/src/video/SDL_video_unsupported.c index caf19787a9..b101ec2215 100644 --- a/src/video/SDL_video_unsupported.c +++ b/src/video/SDL_video_unsupported.c @@ -40,7 +40,7 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) { } -#endif /* SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK */ +#endif // SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK SDL_DECLSPEC int SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); int SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) @@ -67,7 +67,7 @@ int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) return SDL_Unsupported(); } -#endif /* !SDL_VIDEO_DRIVER_WINDOWS */ +#endif // !SDL_VIDEO_DRIVER_WINDOWS #ifndef SDL_PLATFORM_GDK diff --git a/src/video/SDL_vulkan_internal.h b/src/video/SDL_vulkan_internal.h index f07e592904..787062a9ce 100644 --- a/src/video/SDL_vulkan_internal.h +++ b/src/video/SDL_vulkan_internal.h @@ -57,7 +57,7 @@ extern const char *SDL_Vulkan_GetResultString(VkResult result); extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties, - Uint32 *extensionCount); /* free returned list with SDL_free */ + Uint32 *extensionCount); // free returned list with SDL_free /* Create a surface directly from a display connected to a physical device * using the DisplayKHR extension. @@ -80,12 +80,12 @@ extern void SDL_Vulkan_DestroySurface_Internal(void *vkGetInstanceProcAddr, const struct VkAllocationCallbacks *allocator); #else -/* No SDL Vulkan support, just include the header for typedefs */ +// No SDL Vulkan support, just include the header for typedefs #include typedef void (*PFN_vkGetInstanceProcAddr)(void); typedef int (*PFN_vkEnumerateInstanceExtensionProperties)(void); -#endif /* SDL_VIDEO_VULKAN */ +#endif // SDL_VIDEO_VULKAN -#endif /* SDL_vulkan_internal_h_ */ +#endif // SDL_vulkan_internal_h_ diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c index c5223cdb0a..c883bd20bd 100644 --- a/src/video/SDL_vulkan_utils.c +++ b/src/video/SDL_vulkan_utils.c @@ -125,7 +125,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( VkExtensionProperties *retval; if (result == VK_ERROR_INCOMPATIBLE_DRIVER) { - /* Avoid the ERR_MAX_STRLEN limit by passing part of the message as a string argument. */ + // Avoid the ERR_MAX_STRLEN limit by passing part of the message as a string argument. SDL_SetError( "You probably don't have a working Vulkan driver installed. %s %s %s(%d)", "Getting Vulkan extensions failed:", @@ -166,7 +166,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( return retval; } -/* Alpha modes, in order of preference */ +// Alpha modes, in order of preference static const VkDisplayPlaneAlphaFlagBitsKHR alphaModes[4] = { VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR, VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR, @@ -197,7 +197,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, VkPhysicalDevice *physicalDevices = NULL; uint32_t physicalDeviceIndex; const char *chosenDisplayId; - int displayId = 0; /* Counting from physical device 0, display 0 */ + int displayId = 0; // Counting from physical device 0, display 0 if (!vkEnumeratePhysicalDevices || !vkGetPhysicalDeviceDisplayPropertiesKHR || @@ -214,7 +214,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, displayId = SDL_atoi(chosenDisplayId); } - /* Enumerate physical devices */ + // Enumerate physical devices result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL); if (result != VK_SUCCESS) { SDL_SetError("Could not enumerate Vulkan physical devices"); @@ -253,17 +253,17 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, VkExtent2D extent; VkDisplayPlaneCapabilitiesKHR planeCaps = { 0 }; - /* Get information about the physical displays */ + // Get information about the physical displays result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL); if (result != VK_SUCCESS || displayPropertiesCount == 0) { - /* This device has no physical device display properties, move on to next. */ + // This device has no physical device display properties, move on to next. continue; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display properties for device %u: %u", physicalDeviceIndex, displayPropertiesCount); if (displayId < 0 || (uint32_t)displayId >= displayPropertiesCount) { - /* Display id specified was higher than number of available displays, move to next physical device. */ + // Display id specified was higher than number of available displays, move to next physical device. displayId -= displayPropertiesCount; continue; } @@ -288,7 +288,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_free(displayProperties); displayProperties = NULL; - /* Get display mode properties for the chosen display */ + // Get display mode properties for the chosen display result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL); if (result != VK_SUCCESS || displayModePropertiesCount == 0) { SDL_SetError("Error enumerating display modes"); @@ -308,7 +308,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, goto error; } - /* Try to find a display mode that matches the native resolution */ + // Try to find a display mode that matches the native resolution for (i = 0; i < displayModePropertiesCount; ++i) { if (displayModeProperties[i].parameters.visibleRegion.width == extent.width && displayModeProperties[i].parameters.visibleRegion.height == extent.height && @@ -334,7 +334,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_free(displayModeProperties); displayModeProperties = NULL; - /* Try to find a plane index that supports our display */ + // Try to find a plane index that supports our display result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL); if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) { SDL_SetError("Error enumerating display planes"); @@ -359,15 +359,15 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, VkDisplayKHR *planeSupportedDisplays = NULL; uint32_t j; - /* Check if plane is attached to a display, if not, continue. */ + // Check if plane is attached to a display, if not, continue. if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE) { continue; } - /* Check supported displays for this plane. */ + // 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); @@ -393,7 +393,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, planeSupportedDisplays = NULL; if (j == planeSupportedDisplaysCount) { - /* This display is not supported for this plane, move on. */ + // This display is not supported for this plane, move on. continue; } @@ -404,10 +404,10 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, goto error; } - /* Check if plane fulfills extent requirements. */ + // Check if plane fulfills extent requirements. if (extent.width >= planeCaps.minDstExtent.width && extent.height >= planeCaps.minDstExtent.height && extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) { - /* If it does, choose this plane. */ + // If it does, choose this plane. SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Choosing plane %u, minimum extent %ux%u maximum extent %ux%u", i, planeCaps.minDstExtent.width, planeCaps.minDstExtent.height, planeCaps.maxDstExtent.width, planeCaps.maxDstExtent.height); @@ -427,7 +427,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_free(displayPlaneProperties); displayPlaneProperties = NULL; - /* Find a supported alpha mode. Not all planes support OPAQUE */ + // Find a supported alpha mode. Not all planes support OPAQUE createInfo.alphaMode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; for (i = 0; i < SDL_arraysize(alphaModes); i++) { if (planeCaps.supportedAlpha & alphaModes[i]) { @@ -437,7 +437,7 @@ int SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Chose alpha mode 0x%x", createInfo.alphaMode); - /* Found a match, finally! Fill in extent, and break from loop */ + // Found a match, finally! Fill in extent, and break from loop createInfo.imageExtent = extent; break; } diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index e1ed035890..fa815135c3 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -89,7 +89,7 @@ int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, siz } if (size) { - /* dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; */ + // dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; size_t s1, s2; if (SDL_size_add_overflow(sz_plane, sz_plane_chroma, &s1) < 0) { return SDL_SetError("Y + U would overflow"); @@ -135,7 +135,7 @@ int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, siz } if (size) { - /* dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; */ + // dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; size_t s1, s2; if (SDL_size_add_overflow(sz_plane, sz_plane_chroma, &s1) < 0) { return SDL_SetError("Y + U would overflow"); @@ -296,7 +296,7 @@ static int GetYUVPlanes(int width, int height, SDL_PixelFormat format, const voi *uv_stride = pitches[1]; break; default: - /* Should have caught this above */ + // Should have caught this above return SDL_SetError("GetYUVPlanes[2]: Unsupported YUV format: %s", SDL_GetPixelFormatName(format)); } return 0; @@ -620,7 +620,7 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, } } - /* No fast path for the RGB format, instead convert using an intermediate buffer */ + // No fast path for the RGB format, instead convert using an intermediate buffer if (src_format == SDL_PIXELFORMAT_P010 && dst_format != SDL_PIXELFORMAT_XBGR2101010) { int ret; void *tmp; @@ -631,14 +631,14 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, return -1; } - /* convert src/src_format to tmp/XBGR2101010 */ + // convert src/src_format to tmp/XBGR2101010 ret = SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, src_colorspace, src_properties, tmp, tmp_pitch); if (ret < 0) { SDL_free(tmp); return ret; } - /* convert tmp/XBGR2101010 to dst/RGB */ + // convert tmp/XBGR2101010 to dst/RGB ret = SDL_ConvertPixelsAndColorspace(width, height, SDL_PIXELFORMAT_XBGR2101010, src_colorspace, src_properties, tmp, tmp_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); SDL_free(tmp); return ret; @@ -654,14 +654,14 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, return -1; } - /* convert src/src_format to tmp/ARGB8888 */ + // convert src/src_format to tmp/ARGB8888 ret = SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, SDL_COLORSPACE_SRGB, 0, tmp, tmp_pitch); if (ret < 0) { SDL_free(tmp); return ret; } - /* convert tmp/ARGB8888 to dst/RGB */ + // convert tmp/ARGB8888 to dst/RGB ret = SDL_ConvertPixelsAndColorspace(width, height, SDL_PIXELFORMAT_ARGB8888, SDL_COLORSPACE_SRGB, 0, tmp, tmp_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); SDL_free(tmp); return ret; @@ -673,34 +673,34 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, struct RGB2YUVFactors { int y_offset; - float y[3]; /* Rfactor, Gfactor, Bfactor */ - float u[3]; /* Rfactor, Gfactor, Bfactor */ - float v[3]; /* Rfactor, Gfactor, Bfactor */ + float y[3]; // Rfactor, Gfactor, Bfactor + float u[3]; // Rfactor, Gfactor, Bfactor + float v[3]; // Rfactor, Gfactor, Bfactor }; static struct RGB2YUVFactors RGB2YUVFactorTables[] = { - /* ITU-T T.871 (JPEG) */ + // ITU-T T.871 (JPEG) { 0, { 0.2990f, 0.5870f, 0.1140f }, { -0.1687f, -0.3313f, 0.5000f }, { 0.5000f, -0.4187f, -0.0813f }, }, - /* ITU-R BT.601-7 */ + // ITU-R BT.601-7 { 16, { 0.2568f, 0.5041f, 0.0979f }, { -0.1482f, -0.2910f, 0.4392f }, { 0.4392f, -0.3678f, -0.0714f }, }, - /* ITU-R BT.709-6 */ + // ITU-R BT.709-6 { 16, { 0.1826f, 0.6142f, 0.0620f }, { -0.1006f, -0.3386f, 0.4392f }, { 0.4392f, -0.3989f, -0.0403f }, }, - /* ITU-R BT.2020 10-bit full range */ + // ITU-R BT.2020 10-bit full range { 0, { 0.2627f, 0.6780f, 0.0593f }, @@ -793,7 +793,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * curr_row = (const Uint8 *)src; - /* Write Y plane */ + // Write Y plane for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { const Uint32 p1 = ((const Uint32 *)curr_row)[i]; @@ -811,7 +811,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * next_row += src_pitch; if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV) { - /* Write UV planes, not interleaved */ + // 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++) { @@ -918,12 +918,12 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * } plane_skip = (dst_pitch - row_size); - /* Write YUV plane, packed */ + // 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 */ + // Y U Y1 V *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_U(R, G, B); *plane++ = MAKE_Y(r1, g1, b1); @@ -931,7 +931,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * } if (width_remainder) { READ_ONE_RGB_PIXEL; - /* Y U Y V */ + // Y U Y V *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_U(r, g, b); *plane++ = MAKE_Y(r, g, b); @@ -944,7 +944,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * for (j = 0; j < height; j++) { for (i = 0; i < width_half; i++) { READ_TWO_RGB_PIXELS; - /* U Y V Y1 */ + // U Y V Y1 *plane++ = MAKE_U(R, G, B); *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_V(R, G, B); @@ -952,7 +952,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * } if (width_remainder) { READ_ONE_RGB_PIXEL; - /* U Y V Y */ + // U Y V Y *plane++ = MAKE_U(r, g, b); *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_V(r, g, b); @@ -965,7 +965,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * for (j = 0; j < height; j++) { for (i = 0; i < width_half; i++) { READ_TWO_RGB_PIXELS; - /* Y V Y1 U */ + // Y V Y1 U *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_V(R, G, B); *plane++ = MAKE_Y(r1, g1, b1); @@ -973,7 +973,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void * } if (width_remainder) { READ_ONE_RGB_PIXEL; - /* Y V Y U */ + // Y V Y U *plane++ = MAKE_Y(r, g, b); *plane++ = MAKE_V(r, g, b); *plane++ = MAKE_Y(r, g, b); @@ -1066,7 +1066,7 @@ static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const vo curr_row = (const Uint8 *)src; - /* Write Y plane */ + // Write Y plane for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { const Uint32 p1 = ((const Uint32 *)curr_row)[i]; @@ -1132,8 +1132,8 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, return -1; } -#if 0 /* Doesn't handle odd widths */ - /* RGB24 to FOURCC */ +#if 0 // Doesn't handle odd widths + // RGB24 to FOURCC if (src_format == SDL_PIXELFORMAT_RGB24) { Uint8 *y; Uint8 *u; @@ -1150,7 +1150,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, } #endif - /* ARGB8888 to FOURCC */ + // ARGB8888 to FOURCC if (src_format == SDL_PIXELFORMAT_ARGB8888 && SDL_COLORSPACEPRIMARIES(src_colorspace) == SDL_COLORSPACEPRIMARIES(dst_colorspace)) { return SDL_ConvertPixels_ARGB8888_to_YUV(width, height, src, src_pitch, dst_format, dst, dst_pitch, yuv_type); @@ -1162,7 +1162,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, return SDL_ConvertPixels_XBGR2101010_to_P010(width, height, src, src_pitch, dst_format, dst, dst_pitch, yuv_type); } - /* We currently only support converting from XBGR2101010 to P010 */ + // We currently only support converting from XBGR2101010 to P010 int ret; void *tmp; int tmp_pitch = (width * sizeof(Uint32)); @@ -1172,20 +1172,20 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, return -1; } - /* convert src/src_format to tmp/XBGR2101010 */ + // convert src/src_format to tmp/XBGR2101010 ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, dst_colorspace, dst_properties, tmp, tmp_pitch); if (ret < 0) { SDL_free(tmp); return ret; } - /* convert tmp/XBGR2101010 to dst/P010 */ + // convert tmp/XBGR2101010 to dst/P010 ret = SDL_ConvertPixels_XBGR2101010_to_P010(width, height, tmp, tmp_pitch, dst_format, dst, dst_pitch, yuv_type); SDL_free(tmp); return ret; } - /* not ARGB8888 to FOURCC : need an intermediate conversion */ + // not ARGB8888 to FOURCC : need an intermediate conversion { int ret; void *tmp; @@ -1196,14 +1196,14 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, return -1; } - /* convert src/src_format to tmp/ARGB8888 */ + // convert src/src_format to tmp/ARGB8888 ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, dst_colorspace, dst_properties, tmp, tmp_pitch); if (ret < 0) { SDL_free(tmp); return ret; } - /* convert tmp/ARGB8888 to dst/FOURCC */ + // convert tmp/ARGB8888 to dst/FOURCC ret = SDL_ConvertPixels_ARGB8888_to_YUV(width, height, tmp, tmp_pitch, dst_format, dst, dst_pitch, yuv_type); SDL_free(tmp); return ret; @@ -1216,7 +1216,7 @@ static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFor int i; if (IsPlanar2x2Format(format)) { - /* Y plane */ + // Y plane for (i = height; i--;) { SDL_memcpy(dst, src, width); src = (const Uint8 *)src + src_pitch; @@ -1224,7 +1224,7 @@ static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFor } if (format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV) { - /* U and V planes are a quarter the size of the Y plane, rounded up */ + // U and V planes are a quarter the size of the Y plane, rounded up width = (width + 1) / 2; height = (height + 1) / 2; src_pitch = (src_pitch + 1) / 2; @@ -1235,7 +1235,7 @@ static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFor 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 */ + // 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; @@ -1246,7 +1246,7 @@ static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFor dst = (Uint8 *)dst + dst_pitch; } } else if (format == SDL_PIXELFORMAT_P010) { - /* U/V plane is half the height of the Y plane, rounded up */ + // 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; @@ -1261,7 +1261,7 @@ static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFor } if (IsPacked4Format(format)) { - /* Packed planes */ + // Packed planes width = 4 * ((width + 1) / 2); for (i = height; i--;) { SDL_memcpy(dst, src, width); @@ -1280,7 +1280,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src const int UVwidth = (width + 1) / 2; const int UVheight = (height + 1) / 2; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; @@ -1290,7 +1290,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src Uint8 *row1 = (Uint8 *)dst; Uint8 *row2 = row1 + UVheight * UVpitch; - /* Allocate a temporary row for the swap */ + // Allocate a temporary row for the swap tmp = (Uint8 *)SDL_malloc(UVwidth); if (!tmp) { return -1; @@ -1309,7 +1309,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src int srcUVPitch = ((src_pitch + 1) / 2); int dstUVPitch = ((dst_pitch + 1) / 2); - /* Copy the first plane */ + // Copy the first plane srcUV = (const Uint8 *)src; dstUV = (Uint8 *)dst + UVheight * dstUVPitch; for (y = 0; y < UVheight; ++y) { @@ -1318,7 +1318,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src dstUV += dstUVPitch; } - /* Copy the second plane */ + // Copy the second plane dstUV = (Uint8 *)dst; for (y = 0; y < UVheight; ++y) { SDL_memcpy(dstUV, srcUV, UVwidth); @@ -1343,12 +1343,12 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int w Uint8 *dstUV; Uint8 *tmp = NULL; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; if (src == dst) { - /* Need to make a copy of the buffer so we don't clobber it while converting */ + // Need to make a copy of the buffer so we don't clobber it while converting tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); if (tmp == NULL) { return -1; @@ -1409,12 +1409,12 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int Uint8 *dst1, *dst2; Uint8 *tmp = NULL; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; if (src == dst) { - /* Need to make a copy of the buffer so we don't clobber it while converting */ + // Need to make a copy of the buffer so we don't clobber it while converting tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); if (tmp == NULL) { return -1; @@ -1479,7 +1479,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_SwapNV_SSE2(int width, int he const Uint16 *srcUV; Uint16 *dstUV; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; @@ -1521,12 +1521,12 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const Uint8 *dstUV; Uint8 *tmp = NULL; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; if (src == dst) { - /* Need to make a copy of the buffer so we don't clobber it while converting */ + // Need to make a copy of the buffer so we don't clobber it while converting tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); if (!tmp) { return -1; @@ -1575,12 +1575,12 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes_std(int width, int height, cons Uint8 *dst1, *dst2; Uint8 *tmp = NULL; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; if (src == dst) { - /* Need to make a copy of the buffer so we don't clobber it while converting */ + // Need to make a copy of the buffer so we don't clobber it while converting tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); if (!tmp) { return -1; @@ -1628,7 +1628,7 @@ static int SDL_ConvertPixels_SwapNV_std(int width, int height, const void *src, const Uint16 *srcUV; Uint16 *dstUV; - /* Skip the Y plane */ + // Skip the Y plane src = (const Uint8 *)src + height * src_pitch; dst = (Uint8 *)dst + height * dst_pitch; @@ -1681,7 +1681,7 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, SDL_PixelFormat dst_format, void *dst, int dst_pitch) { if (src != dst) { - /* Copy Y plane */ + // Copy Y plane int i; const Uint8 *srcY = (const Uint8 *)src; Uint8 *dstY = (Uint8 *)dst; @@ -2317,10 +2317,10 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, dstV2 = dstV1 + dstUV_pitch; dst_pitch_left = (dstY_pitch - 4 * ((width + 1) / 2)); - /* Copy 2x2 blocks of pixels at a time */ + // Copy 2x2 blocks of pixels at a time for (y = 0; y < (height - 1); y += 2) { for (x = 0; x < (width - 1); x += 2) { - /* Row 1 */ + // Row 1 *dstY1 = *srcY1++; dstY1 += 2; *dstY1 = *srcY1++; @@ -2328,7 +2328,7 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, *dstU1 = *srcU; *dstV1 = *srcV; - /* Row 2 */ + // Row 2 *dstY2 = *srcY2++; dstY2 += 2; *dstY2 = *srcY2++; @@ -2344,9 +2344,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, dstV2 += 4; } - /* Last column */ + // Last column if (x == (width - 1)) { - /* Row 1 */ + // Row 1 *dstY1 = *srcY1; dstY1 += 2; *dstY1 = *srcY1++; @@ -2354,7 +2354,7 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, *dstU1 = *srcU; *dstV1 = *srcV; - /* Row 2 */ + // Row 2 *dstY2 = *srcY2; dstY2 += 2; *dstY2 = *srcY2++; @@ -2382,10 +2382,10 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, dstV2 += dst_pitch_left + dstUV_pitch; } - /* Last row */ + // Last row if (y == (height - 1)) { for (x = 0; x < (width - 1); x += 2) { - /* Row 1 */ + // Row 1 *dstY1 = *srcY1++; dstY1 += 2; *dstY1 = *srcY1++; @@ -2399,9 +2399,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, dstV1 += 4; } - /* Last column */ + // Last column if (x == (width - 1)) { - /* Row 1 */ + // Row 1 *dstY1 = *srcY1; dstY1 += 2; *dstY1 = *srcY1++; @@ -2459,16 +2459,16 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, dstUV_pitch_left = (dstUV_pitch - ((width + 1) / 2)); } - /* Copy 2x2 blocks of pixels at a time */ + // Copy 2x2 blocks of pixels at a time for (y = 0; y < (height - 1); y += 2) { for (x = 0; x < (width - 1); x += 2) { - /* Row 1 */ + // Row 1 *dstY1++ = *srcY1; srcY1 += 2; *dstY1++ = *srcY1; srcY1 += 2; - /* Row 2 */ + // Row 2 *dstY2++ = *srcY2; srcY2 += 2; *dstY2++ = *srcY2; @@ -2485,15 +2485,15 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, dstV += dstUV_pixel_stride; } - /* Last column */ + // Last column if (x == (width - 1)) { - /* Row 1 */ + // Row 1 *dstY1 = *srcY1; srcY1 += 2; *dstY1++ = *srcY1; srcY1 += 2; - /* Row 2 */ + // Row 2 *dstY2 = *srcY2; srcY2 += 2; *dstY2++ = *srcY2; @@ -2522,7 +2522,7 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, dstV += dstUV_pitch_left; } - /* Last row */ + // Last row if (y == (height - 1)) { for (x = 0; x < (width - 1); x += 2) { *dstY1++ = *srcY1; @@ -2539,7 +2539,7 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, dstV += dstUV_pixel_stride; } - /* Last column */ + // Last column if (x == (width - 1)) { *dstY1 = *srcY1; *dstU = *srcU1; @@ -2549,7 +2549,7 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, return 0; } -#endif /* SDL_HAVE_YUV */ +#endif // SDL_HAVE_YUV int SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, @@ -2562,7 +2562,7 @@ int SDL_ConvertPixels_YUV_to_YUV(int width, int height, if (src_format == dst_format) { if (src == dst) { - /* Nothing to do */ + // Nothing to do return 0; } return SDL_ConvertPixels_YUV_to_YUV_Copy(width, height, src_format, src, src_pitch, dst, dst_pitch); diff --git a/src/video/SDL_yuv_c.h b/src/video/SDL_yuv_c.h index 47dac3b256..7d3c6fdb2c 100644 --- a/src/video/SDL_yuv_c.h +++ b/src/video/SDL_yuv_c.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -/* YUV conversion functions */ +// YUV conversion functions extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); @@ -33,4 +33,4 @@ extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormat s extern int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch); -#endif /* SDL_yuv_c_h_ */ +#endif // SDL_yuv_c_h_ diff --git a/src/video/android/SDL_androidclipboard.c b/src/video/android/SDL_androidclipboard.c index 70c4fc1556..ef792d8573 100644 --- a/src/video/android/SDL_androidclipboard.c +++ b/src/video/android/SDL_androidclipboard.c @@ -41,4 +41,4 @@ SDL_bool Android_HasClipboardText(SDL_VideoDevice *_this) return Android_JNI_HasClipboardText(); } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidclipboard.h b/src/video/android/SDL_androidclipboard.h index e6b22b2aeb..56c96ec608 100644 --- a/src/video/android/SDL_androidclipboard.h +++ b/src/video/android/SDL_androidclipboard.h @@ -27,4 +27,4 @@ extern int Android_SetClipboardText(SDL_VideoDevice *_this, const char *text); extern char *Android_GetClipboardText(SDL_VideoDevice *_this); extern SDL_bool Android_HasClipboardText(SDL_VideoDevice *_this); -#endif /* SDL_androidclipboard_h_ */ +#endif // SDL_androidclipboard_h_ diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 63abf92b33..331523c1f5 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -40,7 +40,7 @@ static void android_egl_context_restore(SDL_Window *window) SDL_WindowData *data = window->internal; SDL_GL_MakeCurrent(window, NULL); if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) { - /* The context is no longer valid, create a new one */ + // 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); event.type = SDL_EVENT_RENDER_DEVICE_RESET; @@ -60,17 +60,17 @@ static void android_egl_context_backup(SDL_Window *window) { if (window) { int interval = 0; - /* Keep a copy of the EGL Context so we can try to restore it when we resume */ + // Keep a copy of the EGL Context so we can try to restore it when we resume SDL_WindowData *data = window->internal; data->egl_context = SDL_GL_GetCurrentContext(); - /* Save/Restore the swap interval / vsync */ + // Save/Restore the swap interval / vsync if (SDL_GL_GetSwapInterval(&interval) == 0) { data->has_swap_interval = 1; data->swap_interval = interval; } - /* We need to do this so the EGLSurface can be freed */ + // We need to do this so the EGLSurface can be freed SDL_GL_MakeCurrent(window, NULL); data->backup_done = SDL_TRUE; } @@ -131,7 +131,7 @@ static void Android_OnPause(void) #endif if (Android_BlockOnPause) { - /* We're blocking, also pause audio */ + // We're blocking, also pause audio Android_PauseAudio(); } @@ -147,7 +147,7 @@ static void Android_OnResume(void) Android_ResumeAudio(); #ifdef SDL_VIDEO_OPENGL_EGL - /* Restore the GL Context from here, as this operation is thread dependent */ + // Restore the GL Context from here, as this operation is thread dependent if (Android_Window && !Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { Android_LockActivityMutex(); android_egl_context_restore(Android_Window); @@ -155,7 +155,7 @@ static void Android_OnResume(void) } #endif - /* Make sure SW Keyboard is restored when an app becomes foreground */ + // Make sure SW Keyboard is restored when an app becomes foreground if (Android_Window) { Android_RestoreScreenKeyboardOnResume(SDL_GetVideoDevice(), Android_Window); } @@ -170,7 +170,7 @@ static void Android_OnLowMemory(void) static void Android_OnDestroy(void) { - /* Make sure we unblock any audio processing before we quit */ + // Make sure we unblock any audio processing before we quit Android_ResumeAudio(); /* Discard previous events. The user should have handled state storage @@ -265,4 +265,4 @@ void Android_QuitEvents(void) Android_EventsInitialized = SDL_FALSE; } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index 3fdddf5b35..74dddd0220 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -22,7 +22,7 @@ #if defined(SDL_VIDEO_DRIVER_ANDROID) && defined(SDL_VIDEO_OPENGL_EGL) -/* Android SDL video driver implementation */ +// Android SDL video driver implementation #include "../SDL_egl_c.h" #include "SDL_androidwindow.h" @@ -85,4 +85,4 @@ int Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidgl.h b/src/video/android/SDL_androidgl.h index ab22f83d42..eff2e59812 100644 --- a/src/video/android/SDL_androidgl.h +++ b/src/video/android/SDL_androidgl.h @@ -28,4 +28,4 @@ int Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLC int Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); -#endif /* SDL_androidgl_h_ */ +#endif // SDL_androidgl_h_ diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index 84da48166f..cf41060fd9 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -71,286 +71,286 @@ 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_UNKNOWN, /* AKEYCODE_EXPLORER */ - SDL_SCANCODE_UNKNOWN, /* 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_MEDIA_PLAY_PAUSE, /* AKEYCODE_MEDIA_PLAY_PAUSE */ - SDL_SCANCODE_MEDIA_STOP, /* AKEYCODE_MEDIA_STOP */ - SDL_SCANCODE_MEDIA_NEXT_TRACK, /* AKEYCODE_MEDIA_NEXT */ - SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, /* AKEYCODE_MEDIA_PREVIOUS */ - SDL_SCANCODE_MEDIA_REWIND, /* AKEYCODE_MEDIA_REWIND */ - SDL_SCANCODE_MEDIA_FAST_FORWARD, /* 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_MEDIA_PLAY, /* AKEYCODE_MEDIA_PLAY */ - SDL_SCANCODE_MEDIA_PAUSE, /* AKEYCODE_MEDIA_PAUSE */ - SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */ - SDL_SCANCODE_MEDIA_EJECT, /* AKEYCODE_MEDIA_EJECT */ - SDL_SCANCODE_MEDIA_RECORD, /* 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_NUMLOCKCLEAR, /* 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_CHANNEL_INCREMENT, /* AKEYCODE_CHANNEL_UP */ - SDL_SCANCODE_CHANNEL_INCREMENT, /* 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_UNKNOWN, /* 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_UNKNOWN, /* AKEYCODE_BRIGHTNESS_DOWN */ - SDL_SCANCODE_UNKNOWN, /* 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_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_UNKNOWN, // AKEYCODE_EXPLORER + SDL_SCANCODE_UNKNOWN, // 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_MEDIA_PLAY_PAUSE, // AKEYCODE_MEDIA_PLAY_PAUSE + SDL_SCANCODE_MEDIA_STOP, // AKEYCODE_MEDIA_STOP + SDL_SCANCODE_MEDIA_NEXT_TRACK, // AKEYCODE_MEDIA_NEXT + SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, // AKEYCODE_MEDIA_PREVIOUS + SDL_SCANCODE_MEDIA_REWIND, // AKEYCODE_MEDIA_REWIND + SDL_SCANCODE_MEDIA_FAST_FORWARD, // 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_MEDIA_PLAY, // AKEYCODE_MEDIA_PLAY + SDL_SCANCODE_MEDIA_PAUSE, // AKEYCODE_MEDIA_PAUSE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_CLOSE + SDL_SCANCODE_MEDIA_EJECT, // AKEYCODE_MEDIA_EJECT + SDL_SCANCODE_MEDIA_RECORD, // 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_NUMLOCKCLEAR, // 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_CHANNEL_INCREMENT, // AKEYCODE_CHANNEL_UP + SDL_SCANCODE_CHANNEL_INCREMENT, // 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_UNKNOWN, // 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_UNKNOWN, // AKEYCODE_BRIGHTNESS_DOWN + SDL_SCANCODE_UNKNOWN, // 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_bool SDL_screen_keyboard_shown; @@ -465,4 +465,4 @@ SDL_bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *windo return Android_JNI_IsScreenKeyboardShown(); } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidmessagebox.c b/src/video/android/SDL_androidmessagebox.c index bea406fa0b..33c678c961 100644 --- a/src/video/android/SDL_androidmessagebox.c +++ b/src/video/android/SDL_androidmessagebox.c @@ -30,4 +30,4 @@ int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button return Android_JNI_ShowMessageBox(messageboxdata, buttonID); } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidmessagebox.h b/src/video/android/SDL_androidmessagebox.h index 564eaf075b..ece8e0764e 100644 --- a/src/video/android/SDL_androidmessagebox.h +++ b/src/video/android/SDL_androidmessagebox.h @@ -24,4 +24,4 @@ extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 1ff75b4883..f049b99119 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -29,7 +29,7 @@ #include "../../core/android/SDL_android.h" -/* See Android's MotionEvent class for constants */ +// See Android's MotionEvent class for constants #define ACTION_DOWN 0 #define ACTION_UP 1 #define ACTION_MOVE 2 @@ -47,10 +47,10 @@ struct SDL_CursorData int system_cursor; }; -/* Last known Android mouse button state (includes all buttons) */ +// Last known Android mouse button state (includes all buttons) static int last_state; -/* Blank cursor */ +// Blank cursor static SDL_Cursor *empty_cursor; static SDL_Cursor *Android_WrapCursor(int custom_cursor, int system_cursor) @@ -150,7 +150,7 @@ static int Android_ShowCursor(SDL_Cursor *cursor) } return 0; } else { - /* SDL error set inside Android_CreateEmptyCursor() */ + // SDL error set inside Android_CreateEmptyCursor() return -1; } } @@ -188,7 +188,7 @@ void Android_QuitMouse(void) Android_DestroyEmptyCursor(); } -/* Translate Android mouse button state to SDL mouse button */ +// Translate Android mouse button state to SDL mouse button static Uint8 TranslateButton(int state) { if (state & BUTTON_PRIMARY) { @@ -246,4 +246,4 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y } } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidmouse.h b/src/video/android/SDL_androidmouse.h index d6f6f7970f..ee4021761d 100644 --- a/src/video/android/SDL_androidmouse.h +++ b/src/video/android/SDL_androidmouse.h @@ -28,4 +28,4 @@ extern void Android_InitMouse(void); extern void Android_OnMouse(SDL_Window *window, int button, int action, float x, float y, SDL_bool relative); extern void Android_QuitMouse(void); -#endif /* SDL_androidmouse_h_ */ +#endif // SDL_androidmouse_h_ diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index bf8d7af341..14d73c5237 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -32,14 +32,14 @@ #define ACTION_DOWN 0 #define ACTION_UP 1 #define ACTION_MOVE 2 -/* #define ACTION_CANCEL 3 */ -/* #define ACTION_OUTSIDE 4 */ +// #define ACTION_CANCEL 3 +// #define ACTION_OUTSIDE 4 #define ACTION_POINTER_DOWN 5 #define ACTION_POINTER_UP 6 void Android_InitTouch(void) { - /* Add all touch devices */ + // Add all touch devices Android_JNI_InitTouch(); } @@ -62,7 +62,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin */ touchDeviceId = (SDL_TouchID)(touch_device_id_in + 2); - /* Finger ID should be greater than 0 */ + // Finger ID should be greater than 0 fingerId = (SDL_FingerID)(pointer_finger_id_in + 1); if (SDL_AddTouch(touchDeviceId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { @@ -89,4 +89,4 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin } } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index b11b725009..b069dc41b2 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_ANDROID -/* Android SDL video driver implementation */ +// Android SDL video driver implementation #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -42,7 +42,7 @@ #define ANDROID_VID_DRIVER_NAME "android" -/* Initialization/Query functions */ +// Initialization/Query functions static int Android_VideoInit(SDL_VideoDevice *_this); static void Android_VideoQuit(SDL_VideoDevice *_this); @@ -53,14 +53,14 @@ static void Android_VideoQuit(SDL_VideoDevice *_this); #define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval #define Android_GLES_DeleteContext SDL_EGL_DeleteContext -/* Android driver bootstrap functions */ +// Android driver bootstrap functions -/* These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) */ +// 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; -static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; /* Default SurfaceView format, in case this is queried before being filled */ +static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; // Default SurfaceView format, in case this is queried before being filled float Android_ScreenDensity = 1.0f; static float Android_ScreenRate = 0.0f; static SDL_SystemTheme Android_SystemTheme; @@ -81,7 +81,7 @@ static SDL_VideoDevice *Android_CreateDevice(void) SDL_VideoDevice *device; SDL_VideoData *data; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; @@ -96,7 +96,7 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->internal = data; device->system_theme = Android_SystemTheme; - /* Set the function pointers */ + // Set the function pointers device->VideoInit = Android_VideoInit; device->VideoQuit = Android_VideoQuit; @@ -109,7 +109,7 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->free = Android_DeleteDevice; - /* GL pointers */ + // GL pointers #ifdef SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = Android_GLES_LoadLibrary; device->GL_GetProcAddress = Android_GLES_GetProcAddress; @@ -130,16 +130,16 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->Vulkan_DestroySurface = Android_Vulkan_DestroySurface; #endif - /* Screensaver */ + // Screensaver device->SuspendScreenSaver = Android_SuspendScreenSaver; - /* Screen keyboard */ + // Screen keyboard device->HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport; device->ShowScreenKeyboard = Android_ShowScreenKeyboard; device->HideScreenKeyboard = Android_HideScreenKeyboard; device->IsScreenKeyboardShown = Android_IsScreenKeyboardShown; - /* Clipboard */ + // Clipboard device->SetClipboardText = Android_SetClipboardText; device->GetClipboardText = Android_GetClipboardText; device->HasClipboardText = Android_HasClipboardText; @@ -184,7 +184,7 @@ int Android_VideoInit(SDL_VideoDevice *_this) Android_InitMouse(); - /* We're done! */ + // We're done! return 0; } @@ -207,13 +207,13 @@ void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int device 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 */ + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) { // 2 pf = SDL_PIXELFORMAT_RGBX8888; - } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM) { /* 3 */ + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM) { // 3 pf = SDL_PIXELFORMAT_RGB24; - } else if (format == AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM) { /* 4*/ + } else if (format == AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM) { // 4 pf = SDL_PIXELFORMAT_RGB565; } else if (format == 5) { pf = SDL_PIXELFORMAT_BGRA8888; @@ -222,7 +222,7 @@ static Uint32 format_to_pixelFormat(int format) } else if (format == 7) { pf = SDL_PIXELFORMAT_RGBA4444; } else if (format == 0x115) { - /* HAL_PIXEL_FORMAT_BGR_565 */ + // HAL_PIXEL_FORMAT_BGR_565 pf = SDL_PIXELFORMAT_RGB565; } else { pf = SDL_PIXELFORMAT_UNKNOWN; @@ -286,4 +286,4 @@ void Android_SetDarkMode(SDL_bool enabled) } } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h index fa6bbc2fe7..4a2d9964e7 100644 --- a/src/video/android/SDL_androidvideo.h +++ b/src/video/android/SDL_androidvideo.h @@ -25,13 +25,13 @@ #include "../SDL_sysvideo.h" -/* Called by the JNI layer when the screen changes size or format */ +// Called by the JNI layer when the screen changes size or format extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float density, float rate); extern void Android_SetFormat(int format_wanted, int format_got); extern void Android_SendResize(SDL_Window *window); extern void Android_SetDarkMode(SDL_bool enabled); -/* Private display data */ +// Private display data struct SDL_VideoData { @@ -43,4 +43,4 @@ extern int Android_SurfaceWidth; extern int Android_SurfaceHeight; extern float Android_ScreenDensity; -#endif /* SDL_androidvideo_h_ */ +#endif // SDL_androidvideo_h_ diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index b4be7232a7..c57303dc52 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -47,7 +47,7 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } diff --git a/src/video/android/SDL_androidvulkan.h b/src/video/android/SDL_androidvulkan.h index 7bc5e21940..1ef42994e0 100644 --- a/src/video/android/SDL_androidvulkan.h +++ b/src/video/android/SDL_androidvulkan.h @@ -50,4 +50,4 @@ void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this, #endif -#endif /* SDL_androidvulkan_h_ */ +#endif // SDL_androidvulkan_h_ diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index ad777dfb40..c74c3b92f5 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -33,7 +33,7 @@ #include "SDL_androidwindow.h" -/* Currently only one window */ +// Currently only one window SDL_Window *Android_Window = NULL; int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) @@ -50,16 +50,16 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert goto endfunction; } - /* Set orientation */ + // Set orientation Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); - /* Adjust the window data to match the screen */ + // Adjust the window data to match the screen window->x = 0; window->y = 0; window->w = Android_SurfaceWidth; window->h = Android_SurfaceHeight; - /* One window, it always has focus */ + // One window, it always has focus SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); @@ -116,7 +116,7 @@ int Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_ SDL_WindowData *data; int old_w, old_h, new_w, new_h; - /* If the window is being destroyed don't change visible state */ + // If the window is being destroyed don't change visible state if (!window->is_destroying) { Android_JNI_SetWindowStyle(fullscreen); } @@ -167,7 +167,7 @@ void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) { - /* Set orientation */ + // Set orientation Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); } @@ -198,4 +198,4 @@ void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) Android_UnlockActivityMutex(); } -#endif /* SDL_VIDEO_DRIVER_ANDROID */ +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index 5a13c3023b..2de1fd25c7 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -39,8 +39,8 @@ struct SDL_WindowData { #ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; - EGLContext egl_context; /* We use this to preserve the context when losing focus */ - int has_swap_interval; /* Save/Restore the swap interval / vsync */ + EGLContext egl_context; // We use this to preserve the context when losing focus + int has_swap_interval; // Save/Restore the swap interval / vsync int swap_interval; #endif SDL_bool backup_done; @@ -48,4 +48,4 @@ struct SDL_WindowData }; -#endif /* SDL_androidwindow_h_ */ +#endif // SDL_androidwindow_h_ diff --git a/src/video/cocoa/SDL_cocoaclipboard.h b/src/video/cocoa/SDL_cocoaclipboard.h index 4fdfb4089b..c263a04ef0 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.h +++ b/src/video/cocoa/SDL_cocoaclipboard.h @@ -23,7 +23,7 @@ #ifndef SDL_cocoaclipboard_h_ #define SDL_cocoaclipboard_h_ -/* Forward declaration */ +// Forward declaration @class SDL_CocoaVideoData; extern int Cocoa_SetClipboardText(SDL_VideoDevice *_this, const char *text); @@ -34,4 +34,4 @@ extern int Cocoa_SetClipboardData(SDL_VideoDevice *_this); extern void *Cocoa_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); extern SDL_bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); -#endif /* SDL_cocoaclipboard_h_ */ +#endif // SDL_cocoaclipboard_h_ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index 3afaef8ba6..a262d4eb2b 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -26,7 +26,7 @@ #include "../../events/SDL_clipboardevents_c.h" #if MAC_OS_X_VERSION_MAX_ALLOWED < 101300 -typedef NSString *NSPasteboardType; /* Defined in macOS 10.13+ */ +typedef NSString *NSPasteboardType; // Defined in macOS 10.13+ #endif @interface Cocoa_PasteboardDataProvider : NSObject @@ -173,4 +173,4 @@ SDL_bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoaevents.h b/src/video/cocoa/SDL_cocoaevents.h index 096db4dc97..740fc4e1d1 100644 --- a/src/video/cocoa/SDL_cocoaevents.h +++ b/src/video/cocoa/SDL_cocoaevents.h @@ -30,4 +30,4 @@ extern int Cocoa_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); extern void Cocoa_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); extern int Cocoa_SuspendScreenSaver(SDL_VideoDevice *_this); -#endif /* SDL_cocoaevents_h_ */ +#endif // SDL_cocoaevents_h_ diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 02b0edc5e8..711b09de1b 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -77,7 +77,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) case NSEventTypeRightMouseUp: case NSEventTypeLeftMouseDragged: case NSEventTypeRightMouseDragged: - case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */ + case NSEventTypeOtherMouseDragged: // usually middle mouse dragged case NSEventTypeMouseMoved: case NSEventTypeScrollWheel: Cocoa_HandleMouseEvent(_this, theEvent); @@ -116,7 +116,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) @end // SDL3Application -/* setAppleMenu disappeared from the headers in 10.4 */ +// setAppleMenu disappeared from the headers in 10.4 @interface NSApplication (NSAppleMenu) - (void)setAppleMenu:(NSMenu *)menu; @end @@ -187,7 +187,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) [center removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil]; [NSApp removeObserver:self forKeyPath:@"effectiveAppearance"]; - /* Remove our URL event handler only if we set it */ + // Remove our URL event handler only if we set it if ([NSApp delegate] == self) { [[NSAppleEventManager sharedAppleEventManager] removeEventHandlerForEventClass:kInternetEventClass @@ -203,7 +203,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) return; } - /* Don't do anything if this was not an SDL window that was closed */ + // Don't do anything if this was not an SDL window that was closed if (FindSDLWindowForNSWindow(win) == NULL) { return; } @@ -319,12 +319,12 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) * of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051 */ if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { - /* Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. */ + // Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { [i activateWithOptions:NSApplicationActivateIgnoringOtherApps]; break; } - SDL_Delay(300); /* !!! FIXME: this isn't right. */ + SDL_Delay(300); // !!! FIXME: this isn't right. [NSApp activateIgnoringOtherApps:YES]; } @@ -369,7 +369,7 @@ static NSString *GetApplicationName(void) appName = [NSString stringWithUTF8String:metaname]; } - /* Determine the application name */ + // Determine the application name if (!appName) { appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; if (!appName) { @@ -418,14 +418,14 @@ static void CreateApplicationMenus(void) mainMenu = [[NSMenu alloc] init]; - /* Create the main menu bar */ + // Create the main menu bar [NSApp setMainMenu:mainMenu]; - /* Create the application menu */ + // Create the application menu appName = GetApplicationName(); appleMenu = [[NSMenu alloc] initWithTitle:@""]; - /* Add menu items */ + // Add menu items title = [@"About " stringByAppendingString:appName]; // !!! FIXME: Menu items can't take parameters, just a basic selector, so this should instead call a selector @@ -460,25 +460,25 @@ static void CreateApplicationMenus(void) title = [@"Quit " stringByAppendingString:appName]; [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - /* Put menu into the menubar */ + // Put menu into the menubar menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; [menuItem setSubmenu:appleMenu]; [[NSApp mainMenu] addItem:menuItem]; - /* Tell the application object that this is now the application menu */ + // Tell the application object that this is now the application menu [NSApp setAppleMenu:appleMenu]; - /* Create the window menu */ + // Create the window menu windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - /* Add menu items */ + // Add menu items [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"]; [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; - /* Add the fullscreen toggle menu option. */ + // 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. */ @@ -486,19 +486,19 @@ static void CreateApplicationMenus(void) [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand]; [windowMenu addItem:menuItem]; - /* Put menu into the menubar */ + // Put menu into the menubar menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; [menuItem setSubmenu:windowMenu]; [[NSApp mainMenu] addItem:menuItem]; - /* Tell the application object that this is now the window menu */ + // Tell the application object that this is now the window menu [NSApp setWindowsMenu:windowMenu]; } void Cocoa_RegisterApp(void) { @autoreleasepool { - /* This can get called more than once! Be careful what you initialize! */ + // This can get called more than once! Be careful what you initialize! if (NSApp == nil) { [SDL3Application sharedApplication]; @@ -574,7 +574,7 @@ Uint64 Cocoa_GetEventTimestamp(NSTimeInterval nsTimestamp) int Cocoa_PumpEventsUntilDate(SDL_VideoDevice *_this, NSDate *expiration, bool accumulate) { - /* Run any existing modal sessions. */ + // Run any existing modal sessions. for (SDL_Window *w = _this->windows; w; w = w->next) { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)w->internal; if (data.modal_session) { @@ -669,4 +669,4 @@ int Cocoa_SuspendScreenSaver(SDL_VideoDevice *_this) return 0; } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoakeyboard.h b/src/video/cocoa/SDL_cocoakeyboard.h index 0103e1a8a3..6c57eae3a6 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.h +++ b/src/video/cocoa/SDL_cocoakeyboard.h @@ -33,4 +33,4 @@ extern int Cocoa_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) extern int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); -#endif /* SDL_cocoakeyboard_h_ */ +#endif // SDL_cocoakeyboard_h_ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 3a38fa6d5c..b942d68407 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -30,7 +30,7 @@ #include -/*#define DEBUG_IME NSLog */ +// #define DEBUG_IME NSLog #define DEBUG_IME(...) @interface SDL3TranslatorResponder : NSView @@ -59,7 +59,7 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange { - /* TODO: Make use of replacementRange? */ + // TODO: Make use of replacementRange? const char *str; @@ -73,7 +73,7 @@ str = [aString UTF8String]; } - /* We're likely sending the composed text, so we reset the IME status. */ + // We're likely sending the composed text, so we reset the IME status. if ([self hasMarkedText]) { [self unmarkText]; } @@ -280,14 +280,14 @@ static void UpdateKeymap(SDL_CocoaVideoData *data, SDL_bool send_event) UCKeyboardLayout *keyLayoutPtr = NULL; CFDataRef uchrDataRef; - /* See if the keymap needs to be updated */ + // See if the keymap needs to be updated key_layout = TISCopyCurrentKeyboardLayoutInputSource(); if (key_layout == data.key_layout) { return; } data.key_layout = key_layout; - /* Try Unicode data first */ + // Try Unicode data first uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData); if (uchrDataRef) { keyLayoutPtr = (UCKeyboardLayout *)CFDataGetBytePtr(uchrDataRef); @@ -322,7 +322,7 @@ static void UpdateKeymap(SDL_CocoaVideoData *data, SDL_bool send_event) UniCharCount len; UInt32 dead_key_state; - /* Make sure this scancode is a valid character scancode */ + // Make sure this scancode is a valid character scancode SDL_Scancode scancode = darwin_scancode_table[i]; if (scancode == SDL_SCANCODE_UNKNOWN || scancode == SDL_SCANCODE_DELETE || @@ -337,7 +337,7 @@ static void UpdateKeymap(SDL_CocoaVideoData *data, SDL_bool send_event) * key '<', which is on the right of the Shift key, are inverted */ if ((scancode == SDL_SCANCODE_NONUSBACKSLASH || scancode == SDL_SCANCODE_GRAVE) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { - /* see comments in scancodes_darwin.h */ + // see comments in scancodes_darwin.h scancode = (SDL_Scancode)((SDL_SCANCODE_NONUSBACKSLASH + SDL_SCANCODE_GRAVE) - scancode); } @@ -369,9 +369,9 @@ void Cocoa_InitKeyboard(SDL_VideoDevice *_this) UpdateKeymap(data, SDL_FALSE); - /* Set our own names for the platform-dependent but layout-independent keys */ - /* This key is NumLock on the MacBook keyboard. :) */ - /*SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear");*/ + // Set our own names for the platform-dependent but layout-independent keys + // This key is NumLock on the MacBook keyboard. :) + // SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear"); SDL_SetScancodeName(SDL_SCANCODE_LALT, "Left Option"); SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command"); SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option"); @@ -400,7 +400,7 @@ int Cocoa_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert } if (![[data.fieldEdit superview] isEqual:parentView]) { - /* DEBUG_IME(@"add fieldEdit to window contentView"); */ + // DEBUG_IME(@"add fieldEdit to window contentView"); [data.fieldEdit removeFromSuperview]; [parentView addSubview:data.fieldEdit]; [nswindow makeFirstResponder:data.fieldEdit]; @@ -437,27 +437,27 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) SDL_Scancode code; SDL_CocoaVideoData *data = _this ? ((__bridge SDL_CocoaVideoData *)_this->internal) : 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]; if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { - /* see comments in scancodes_darwin.h */ + // see comments in scancodes_darwin.h scancode = 60 - scancode; } if (scancode < SDL_arraysize(darwin_scancode_table)) { code = darwin_scancode_table[scancode]; } else { - /* Hmm, does this ever happen? If so, need to extend the keymap... */ + // Hmm, does this ever happen? If so, need to extend the keymap... code = SDL_SCANCODE_UNKNOWN; } switch ([event type]) { case NSEventTypeKeyDown: if (![event isARepeat]) { - /* See if we need to rebuild the keyboard layout */ + // See if we need to rebuild the keyboard layout UpdateKeymap(data, SDL_TRUE); } @@ -490,7 +490,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) HandleModifiers(_this, SDL_SCANCODE_RGUI, modflags); break; } - default: /* just to avoid compiler warnings */ + default: // just to avoid compiler warnings break; } } @@ -517,4 +517,4 @@ int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_ return 0; } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoamessagebox.h b/src/video/cocoa/SDL_cocoamessagebox.h index 00dfb2a09c..96c64e010b 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.h +++ b/src/video/cocoa/SDL_cocoamessagebox.h @@ -24,4 +24,4 @@ extern int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index 29434058e1..b33ec60401 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -40,7 +40,7 @@ if (self) { clicked = -1; - /* Retain the NSWindow because we'll show the alert later on the main thread */ + // Retain the NSWindow because we'll show the alert later on the main thread if (window) { nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; } else { @@ -125,7 +125,7 @@ static void Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, i } } -/* Display a Cocoa message box */ +// Display a Cocoa message box int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { @autoreleasepool { @@ -142,4 +142,4 @@ int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID } } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoametalview.h b/src/video/cocoa/SDL_cocoametalview.h index 1db563fbb4..acc711438e 100644 --- a/src/video/cocoa/SDL_cocoametalview.h +++ b/src/video/cocoa/SDL_cocoametalview.h @@ -49,7 +49,7 @@ - (void)updateDrawableSize; - (NSView *)hitTest:(NSPoint)point; -/* Override superclass tag so this class can set it. */ +// Override superclass tag so this class can set it. @property(assign, readonly) NSInteger tag; @property(nonatomic) BOOL highDPI; @@ -61,6 +61,6 @@ SDL_MetalView Cocoa_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) void Cocoa_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view); void *Cocoa_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view); -#endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ +#endif // SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) -#endif /* SDL_cocoametalview_h_ */ +#endif // SDL_cocoametalview_h_ diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index 23832076bb..ad28f64d88 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -52,13 +52,13 @@ static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) @implementation SDL3_cocoametalview -/* Return a Metal-compatible layer. */ +// Return a Metal-compatible layer. + (Class)layerClass { return NSClassFromString(@"CAMetalLayer"); } -/* Indicate the view wants to draw using a backing layer instead of drawRect. */ +// Indicate the view wants to draw using a backing layer instead of drawRect. - (BOOL)wantsUpdateLayer { return YES; @@ -83,7 +83,7 @@ static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) self.sdlWindowID = windowID; self.wantsLayer = YES; - /* Allow resize. */ + // Allow resize. self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; self.layer.opaque = opaque; @@ -152,7 +152,7 @@ SDL_MetalView Cocoa_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) [view addSubview:newview]; - /* Make sure the drawable size is up to date after attaching the view. */ + // Make sure the drawable size is up to date after attaching the view. [newview updateDrawableSize]; metalview = (SDL_MetalView)CFBridgingRetain(newview); @@ -177,4 +177,4 @@ void *Cocoa_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view) } } -#endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ +#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 5380853c04..c29a473bf1 100644 --- a/src/video/cocoa/SDL_cocoamodes.h +++ b/src/video/cocoa/SDL_cocoamodes.h @@ -41,4 +41,4 @@ extern int Cocoa_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *displ extern int Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void Cocoa_QuitModes(SDL_VideoDevice *_this); -#endif /* SDL_cocoamodes_h_ */ +#endif // SDL_cocoamodes_h_ diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index 9eecb9d6d0..6291509b15 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -24,14 +24,14 @@ #include "SDL_cocoavideo.h" -/* We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName */ +// We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName #include -/* We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod */ +// We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod #include #include -/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +// This gets us MAC_OS_X_VERSION_MIN_REQUIRED... #include #ifndef MAC_OS_X_VERSION_10_13 @@ -87,7 +87,7 @@ static NSScreen *GetNSScreenForDisplayID(CGDirectDisplayID displayID) { NSArray *screens = [NSScreen screens]; - /* !!! FIXME: maybe track the NSScreen in SDL_DisplayData? */ + // !!! FIXME: maybe track the NSScreen in SDL_DisplayData? for (NSScreen *screen in screens) { const CGDirectDisplayID thisDisplay = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; if (thisDisplay == displayID) { @@ -101,7 +101,7 @@ static float GetDisplayModeRefreshRate(CGDisplayModeRef vidmode, CVDisplayLinkRe { float refreshRate = (float)CGDisplayModeGetRefreshRate(vidmode); - /* CGDisplayModeGetRefreshRate can return 0 (eg for built-in displays). */ + // 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) { @@ -116,12 +116,12 @@ static SDL_bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) { uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); - /* Filter out modes which have flags that we don't want. */ + // Filter out modes which have flags that we don't want. if (ioflags & (kDisplayModeNeverShowFlag | kDisplayModeNotGraphicsQualityFlag)) { return SDL_FALSE; } - /* Filter out modes which don't have flags that we want. */ + // Filter out modes which don't have flags that we want. if (!(ioflags & kDisplayModeValidFlag) || !(ioflags & kDisplayModeSafeFlag)) { return SDL_FALSE; } @@ -131,7 +131,7 @@ static SDL_bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) { - /* This API is deprecated in 10.11 with no good replacement (as of 10.15). */ + // This API is deprecated in 10.11 with no good replacement (as of 10.15). CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode); Uint32 pixelformat = SDL_PIXELFORMAT_UNKNOWN; @@ -145,7 +145,7 @@ static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) kCFCompareCaseInsensitive) == kCFCompareEqualTo) { pixelformat = SDL_PIXELFORMAT_ARGB2101010; } else { - /* ignore 8-bit and such for now. */ + // ignore 8-bit and such for now. } CFRelease(fmt); @@ -277,7 +277,7 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, static char *Cocoa_GetDisplayName(CGDirectDisplayID displayID) { - /* This API is deprecated in 10.9 with no good replacement (as of 10.15). */ + // 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]]; @@ -295,7 +295,7 @@ static void Cocoa_GetHDRProperties(CGDirectDisplayID displayID, SDL_HDROutputPro HDR->SDR_white_level = 1.0f; HDR->HDR_headroom = 1.0f; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500 /* Added in the 10.15 SDK */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500 // Added in the 10.15 SDK if (@available(macOS 10.15, *)) { NSScreen *screen = GetNSScreenForDisplayID(displayID); if (screen) { @@ -331,7 +331,7 @@ void Cocoa_InitModes(SDL_VideoDevice *_this) return; } - /* Pick up the primary display in the first pass, then get the rest */ + // 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; @@ -370,7 +370,7 @@ void Cocoa_InitModes(SDL_VideoDevice *_this) CVDisplayLinkCreateWithCGDisplay(displays[i], &link); SDL_zero(display); - /* this returns a strdup'ed string */ + // this returns a strdup'ed string display.name = Cocoa_GetDisplayName(displays[i]); if (!GetDisplayMode(_this, moderef, SDL_TRUE, NULL, link, &mode)) { CVDisplayLinkRelease(link); @@ -511,7 +511,7 @@ static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayMo CGDisplayModeRef moderef = (CGDisplayModeRef)CFArrayGetValueAtIndex(data->modes, i); result = CGDisplaySetDisplayMode(display, moderef, NULL); if (result == kCGErrorSuccess) { - /* If this mode works, try it first next time. */ + // If this mode works, try it first next time. CFArrayExchangeValuesAtIndices(data->modes, i, 0); break; } @@ -528,20 +528,20 @@ int Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_ b_inModeTransition = SDL_TRUE; - /* Fade to black to hide resolution-switching flicker */ + // Fade to black to hide resolution-switching flicker if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) { CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); } if (data == display->desktop_mode.internal) { - /* Restoring desktop mode */ + // Restoring desktop mode SetDisplayModeForDisplay(displaydata->display, data); } else { - /* Do the physical switch */ + // Do the physical switch result = SetDisplayModeForDisplay(displaydata->display, data); } - /* Fade in again (asynchronously) */ + // Fade in again (asynchronously) if (fade_token != kCGDisplayFadeReservationInvalidToken) { CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); CGReleaseDisplayFadeReservation(fade_token); @@ -578,4 +578,4 @@ void Cocoa_QuitModes(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoamouse.h b/src/video/cocoa/SDL_cocoamouse.h index b6b3e7497b..f8ce338f04 100644 --- a/src/video/cocoa/SDL_cocoamouse.h +++ b/src/video/cocoa/SDL_cocoamouse.h @@ -33,12 +33,12 @@ extern void Cocoa_QuitMouse(SDL_VideoDevice *_this); typedef struct { - /* Whether we've seen a cursor warp since the last move event. */ + // Whether we've seen a cursor warp since the last move event. SDL_bool seenWarp; - /* What location our last cursor warp was to. */ + // What location our last cursor warp was to. CGFloat lastWarpX; CGFloat lastWarpY; - /* What location we last saw the cursor move to. */ + // What location we last saw the cursor move to. CGFloat lastMoveX; CGFloat lastMoveY; } SDL_MouseData; @@ -47,4 +47,4 @@ typedef struct + (NSCursor *)invisibleCursor; @end -#endif /* SDL_cocoamouse_h_ */ +#endif // SDL_cocoamouse_h_ diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 647c469c24..0267c8df19 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -27,7 +27,7 @@ #include "../../events/SDL_mouse_c.h" -/* #define DEBUG_COCOAMOUSE */ +// #define DEBUG_COCOAMOUSE #ifdef DEBUG_COCOAMOUSE #define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) @@ -42,7 +42,7 @@ { static NSCursor *invisibleCursor = NULL; if (!invisibleCursor) { - /* RAW 16x16 transparent GIF */ + // RAW 16x16 transparent GIF static unsigned char cursorBytes[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04, @@ -112,7 +112,7 @@ 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"]]; - /* we can't do animation atm. :/ */ + // we can't do animation atm. :/ const int frames = (int)[[info valueForKey:@"frames"] integerValue]; NSCursor *cursor; NSImage *image = [[NSImage alloc] initWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"cursor.pdf"]]; @@ -121,7 +121,7 @@ static NSCursor *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 const NSCompositingOperation operation = NSCompositeCopy; @@ -161,10 +161,10 @@ static SDL_Cursor *Cocoa_CreateSystemCursor(SDL_SystemCursor id) case SDL_SYSTEM_CURSOR_CROSSHAIR: nscursor = [NSCursor crosshairCursor]; break; - case SDL_SYSTEM_CURSOR_WAIT: /* !!! FIXME: this is more like WAITARROW */ + case SDL_SYSTEM_CURSOR_WAIT: // !!! FIXME: this is more like WAITARROW nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); break; - case SDL_SYSTEM_CURSOR_PROGRESS: /* !!! FIXME: this is meant to be animated */ + case SDL_SYSTEM_CURSOR_PROGRESS: // !!! FIXME: this is meant to be animated nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); break; case SDL_SYSTEM_CURSOR_NWSE_RESIZE: @@ -220,7 +220,7 @@ static SDL_Cursor *Cocoa_CreateSystemCursor(SDL_SystemCursor id) if (nscursor) { cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { - /* We'll free it later, so retain it here */ + // We'll free it later, so retain it here cursor->internal = (void *)CFBridgingRetain(nscursor); } } @@ -329,7 +329,7 @@ static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) return 0; } - /* make sure the mouse isn't at the corner of the window, as this can confuse things if macOS thinks a window resize is happening on the first click. */ + // make sure the mouse isn't at the corner of the window, as this can confuse things if macOS thinks a window resize is happening on the first click. const CGPoint point = CGPointMake((float)(window->x + (window->w / 2)), (float)(window->y + (window->h / 2))); Cocoa_HandleMouseWarp(point.x, point.y); CGWarpMouseCursorPosition(point); @@ -473,14 +473,14 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) return; default: - /* Ignore any other events. */ + // Ignore any other events. return; } mouse = SDL_GetMouse(); data = (SDL_MouseData *)mouse->internal; if (!data) { - return; /* can happen when returning from fullscreen Space on shutdown */ + return; // can happen when returning from fullscreen Space on shutdown } seenWarp = data->seenWarp; @@ -493,12 +493,12 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) data->lastMoveY = location.y; DLog("Last seen mouse: (%g, %g)", location.x, location.y); - /* Non-relative movement is handled in -[SDL3Cocoa_WindowListener mouseMoved:] */ + // Non-relative movement is handled in -[SDL3Cocoa_WindowListener mouseMoved:] if (!mouse->relative_mode) { return; } - /* Ignore events that aren't inside the client area (i.e. title bar.) */ + // Ignore events that aren't inside the client area (i.e. title bar.) if ([event window]) { NSRect windowRect = [[[event window] contentView] frame]; if (!NSMouseInRect([event locationInWindow], windowRect, NO)) { @@ -575,4 +575,4 @@ void Cocoa_QuitMouse(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 3c873aa73c..5ee8495962 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -28,7 +28,7 @@ #import #import -/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +// 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" @@ -68,7 +68,7 @@ struct SDL_GLDriverData @end -/* OpenGL functions */ +// OpenGL functions extern int Cocoa_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer Cocoa_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); extern void Cocoa_GL_UnloadLibrary(SDL_VideoDevice *_this); @@ -84,6 +84,6 @@ extern int Cocoa_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) #pragma clang diagnostic pop #endif -#endif /* SDL_VIDEO_OPENGL_CGL */ +#endif // SDL_VIDEO_OPENGL_CGL -#endif /* SDL_cocoaopengl_h_ */ +#endif // SDL_cocoaopengl_h_ diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 319e31e239..ed065c1508 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* NSOpenGL implementation of SDL OpenGL support */ +// NSOpenGL implementation of SDL OpenGL support #ifdef SDL_VIDEO_OPENGL_CGL #include "SDL_cocoavideo.h" @@ -36,13 +36,13 @@ #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. */ +// 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 -/* _Nullable is available starting Xcode 7 */ +// _Nullable is available starting Xcode 7 #ifdef __has_feature #if __has_feature(nullability) #define HAS_FEATURE_NULLABLE @@ -63,9 +63,9 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt { SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)displayLinkContext; - /*printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); */ + // printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting); - if (setting != 0) { /* nothing to do if vsync is disabled, don't even lock */ + if (setting != 0) { // nothing to do if vsync is disabled, don't even lock SDL_LockMutex(nscontext->swapIntervalMutex); SDL_AtomicAdd(&nscontext->swapIntervalsPassed, 1); SDL_SignalCondition(nscontext->swapIntervalCond); @@ -93,7 +93,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt return nil; } - /* !!! FIXME: check return values. */ + // !!! FIXME: check return values. CVDisplayLinkCreateWithActiveCGDisplays(&self->displayLink); CVDisplayLinkSetOutputCallback(self->displayLink, &DisplayLinkCallback, (__bridge void *_Nullable)self); CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [format CGLPixelFormatObj]); @@ -116,31 +116,31 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt SDL_AtomicAdd(&self->dirty, 1); } -/* This should only be called on the thread on which a user is using the context. */ +// This should only be called on the thread on which a user is using the context. - (void)updateIfNeeded { const int value = SDL_AtomicSet(&self->dirty, 0); if (value > 0) { - /* We call the real underlying update here, since -[SDL3OpenGLContext update] just calls us. */ + // We call the real underlying update here, since -[SDL3OpenGLContext update] just calls us. [self explicitUpdate]; } } -/* This should only be called on the thread on which a user is using the context. */ +// This should only be called on the thread on which a user is using the context. - (void)update { - /* This ensures that regular 'update' calls clear the atomic dirty flag. */ + // This ensures that regular 'update' calls clear the atomic dirty flag. [self scheduleUpdate]; [self updateIfNeeded]; } -/* Updates the drawable for the contexts and manages related state. */ +// Updates the drawable for the contexts and manages related state. - (void)setWindow:(SDL_Window *)newWindow { if (self->window) { SDL_CocoaWindowData *oldwindowdata = (__bridge SDL_CocoaWindowData *)self->window->internal; - /* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */ + // 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) { [contexts removeObject:self]; @@ -153,7 +153,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt SDL_CocoaWindowData *windowdata = (__bridge SDL_CocoaWindowData *)newWindow->internal; NSView *contentview = windowdata.sdlContentView; - /* Now sign up for scheduled updates for the new window. */ + // Now sign up for scheduled updates for the new window. NSMutableArray *contexts = windowdata.nscontexts; @synchronized(contexts) { [contexts addObject:self]; @@ -227,7 +227,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt int Cocoa_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - /* Load the OpenGL library */ + // Load the OpenGL library if (path == NULL) { path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); } @@ -274,7 +274,7 @@ SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { #ifdef SDL_VIDEO_OPENGL_EGL - /* Switch to EGL based functions */ + // Switch to EGL based functions Cocoa_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; _this->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; @@ -378,7 +378,7 @@ SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) sdlcontext = (SDL_GLContext)CFBridgingRetain(context); - /* vsync is handled separately by synchronizing with a display link. */ + // vsync is handled separately by synchronizing with a display link. interval = 0; [context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; @@ -394,7 +394,7 @@ SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) 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. */ + // This is a legacy profile, so to match other backends, we're done. } else { const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); @@ -428,8 +428,8 @@ SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) /* 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;*/ + // _this->gl_config.major_version = glversion_major; + // _this->gl_config.minor_version = glversion_minor; } return sdlcontext; } @@ -494,8 +494,8 @@ int Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) 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 */ + // 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_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); @@ -504,14 +504,14 @@ int Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_UnlockMutex(nscontext->swapIntervalMutex); } else { SDL_LockMutex(nscontext->swapIntervalMutex); - do { /* always wait here so we know we just hit a swap interval. */ + do { // always wait here so we know we just hit a swap interval. SDL_WaitCondition(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_GetTicks(); const unsigned int diff = (unsigned int) (now - prev); prev = now; printf("GLSWAPBUFFERS TICKS %u\n", diff); }*/ + // { static Uint64 prev = 0; const Uint64 now = SDL_GetTicks(); 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. */ @@ -533,9 +533,9 @@ int Cocoa_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. #ifdef __clang__ #pragma clang diagnostic pop #endif -#endif /* SDL_VIDEO_OPENGL_CGL */ +#endif // SDL_VIDEO_OPENGL_CGL diff --git a/src/video/cocoa/SDL_cocoaopengles.h b/src/video/cocoa/SDL_cocoaopengles.h index 57da08aa89..1b21b8a570 100644 --- a/src/video/cocoa/SDL_cocoaopengles.h +++ b/src/video/cocoa/SDL_cocoaopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define Cocoa_GLES_GetAttribute SDL_EGL_GetAttribute #define Cocoa_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define Cocoa_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -43,6 +43,6 @@ extern int Cocoa_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext contex extern int Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_EGLSurface Cocoa_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL -#endif /* SDL_cocoaopengles_h_ */ +#endif // SDL_cocoaopengles_h_ diff --git a/src/video/cocoa/SDL_cocoaopengles.m b/src/video/cocoa/SDL_cocoaopengles.m index 04ea386e38..aea4d0484e 100644 --- a/src/video/cocoa/SDL_cocoaopengles.m +++ b/src/video/cocoa/SDL_cocoaopengles.m @@ -26,11 +26,11 @@ #include "SDL_cocoaopengles.h" #include "SDL_cocoaopengl.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support int Cocoa_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - /* If the profile requested is not GL ES, switch over to WIN_GL functions */ + // 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) { #ifdef SDL_VIDEO_OPENGL_CGL Cocoa_GLES_UnloadLibrary(_this); @@ -65,7 +65,7 @@ SDL_GLContext Cocoa_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *windo #ifdef SDL_VIDEO_OPENGL_CGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { - /* Switch to CGL based functions */ + // Switch to CGL based functions Cocoa_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = Cocoa_GL_LoadLibrary; _this->GL_GetProcAddress = Cocoa_GL_GetProcAddress; @@ -117,14 +117,14 @@ int Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) { @autoreleasepool { NSView *v; - /* The current context is lost in here; save it and reset it. */ + // The current context is lost in here; save it and reset it. SDL_CocoaWindowData *windowdata = (__bridge SDL_CocoaWindowData *)window->internal; 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, _this->gl_config.egl_platform) < 0) { @@ -134,7 +134,7 @@ int Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) _this->gl_config.driver_loaded = 1; } - /* Create the GLES window surface */ + // Create the GLES window surface v = windowdata.nswindow.contentView; windowdata.egl_surface = SDL_EGL_CreateSurface(_this, window, (__bridge NativeWindowType)[v layer]); @@ -153,4 +153,4 @@ SDL_EGLSurface Cocoa_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *wind } } -#endif /* SDL_VIDEO_DRIVER_COCOA && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_COCOA && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/cocoa/SDL_cocoapen.h b/src/video/cocoa/SDL_cocoapen.h index 61d8496f7d..8e3259ec46 100644 --- a/src/video/cocoa/SDL_cocoapen.h +++ b/src/video/cocoa/SDL_cocoapen.h @@ -29,4 +29,4 @@ extern int Cocoa_InitPen(SDL_VideoDevice *_this); extern SDL_bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event); // return SDL_FALSE if we didn't handle this event. extern void Cocoa_QuitPen(SDL_VideoDevice *_this); -#endif /* SDL_cocoapen_h_ */ +#endif // SDL_cocoapen_h_ diff --git a/src/video/cocoa/SDL_cocoapen.m b/src/video/cocoa/SDL_cocoapen.m index e22fa5aaea..db5d28faa6 100644 --- a/src/video/cocoa/SDL_cocoapen.m +++ b/src/video/cocoa/SDL_cocoapen.m @@ -175,4 +175,4 @@ void Cocoa_QuitPen(SDL_VideoDevice *_this) SDL_RemoveAllPenDevices(Cocoa_FreePenHandle, NULL); } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoashape.h b/src/video/cocoa/SDL_cocoashape.h index b2d1d0cf29..a16d9321f6 100644 --- a/src/video/cocoa/SDL_cocoashape.h +++ b/src/video/cocoa/SDL_cocoashape.h @@ -25,4 +25,4 @@ extern int Cocoa_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); -#endif /* SDL_cocoashape_h_ */ +#endif // SDL_cocoashape_h_ diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 5a3dd0125b..ff9eaa355f 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -51,4 +51,4 @@ int Cocoa_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surf return 0; } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index a3c1df6263..29edadb3a8 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -80,7 +80,7 @@ DECLARE_WINDOW_MASK(Resizable); DECLARE_WINDOW_MASK(TexturedBackground); DECLARE_WINDOW_MASK(UnifiedTitleAndToolbar); DECLARE_WINDOW_MASK(FullScreen); -/*DECLARE_WINDOW_MASK(FullSizeContentView);*/ /* Not used, fails compile on older SDKs */ +/*DECLARE_WINDOW_MASK(FullSizeContentView);*/ // Not used, fails compile on older SDKs static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask; static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask; static const unsigned int NSWindowStyleMaskHUDWindow = NSHUDWindowMask; @@ -93,7 +93,7 @@ DECLARE_ALERT_STYLE(Critical); #undef DECLARE_ALERT_STYLE #endif -/* Private display data */ +// Private display data @class SDL3TranslatorResponder; @@ -108,13 +108,13 @@ DECLARE_ALERT_STYLE(Critical); @property(nonatomic) SDL_Mutex *swaplock; @end -/* Utility functions */ +// Utility functions extern SDL_SystemTheme Cocoa_GetSystemTheme(void); extern NSImage *Cocoa_CreateImage(SDL_Surface *surface); -/* Fix build with the 10.11 SDK */ +// Fix build with the 10.11 SDK #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #define NSEventSubtypeMouseEvent NSMouseEventSubtype #endif -#endif /* SDL_cocoavideo_h_ */ +#endif // SDL_cocoavideo_h_ diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 677c24a08b..f210551b9c 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -40,11 +40,11 @@ @end -/* Initialization/Query functions */ +// Initialization/Query functions static int Cocoa_VideoInit(SDL_VideoDevice *_this); static void Cocoa_VideoQuit(SDL_VideoDevice *_this); -/* Cocoa driver bootstrap functions */ +// Cocoa driver bootstrap functions static void Cocoa_DeleteDevice(SDL_VideoDevice *device) { @@ -65,7 +65,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void) Cocoa_RegisterApp(); - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { data = [[SDL_CocoaVideoData alloc] init]; @@ -80,7 +80,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void) device->wakeup_lock = SDL_CreateMutex(); device->system_theme = Cocoa_GetSystemTheme(); - /* Set the function pointers */ + // Set the function pointers device->VideoInit = Cocoa_VideoInit; device->VideoQuit = Cocoa_VideoQuit; device->GetDisplayBounds = Cocoa_GetDisplayBounds; @@ -235,10 +235,10 @@ void Cocoa_VideoQuit(SDL_VideoDevice *_this) } } -/* This function assumes that it's called from within an autorelease pool */ +// This function assumes that it's called from within an autorelease pool SDL_SystemTheme Cocoa_GetSystemTheme(void) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 /* Added in the 10.14.0 SDK. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 // Added in the 10.14.0 SDK. if ([[NSApplication sharedApplication] respondsToSelector:@selector(effectiveAppearance)]) { NSAppearance* appearance = [[NSApplication sharedApplication] effectiveAppearance]; @@ -250,7 +250,7 @@ SDL_SystemTheme Cocoa_GetSystemTheme(void) return SDL_SYSTEM_THEME_LIGHT; } -/* This function assumes that it's called from within an autorelease pool */ +// This function assumes that it's called from within an autorelease pool NSImage *Cocoa_CreateImage(SDL_Surface *surface) { NSImage *img; @@ -272,7 +272,7 @@ NSImage *Cocoa_CreateImage(SDL_Surface *surface) return nil; } - /* Premultiply the alpha channel */ + // Premultiply the alpha channel SDL_PremultiplySurfaceAlpha(converted, SDL_FALSE); NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL @@ -291,12 +291,12 @@ NSImage *Cocoa_CreateImage(SDL_Surface *surface) return nil; } - /* Copy the pixels */ + // Copy the pixels Uint8 *pixels = [imgrep bitmapData]; SDL_memcpy(pixels, converted->pixels, (size_t)converted->h * converted->pitch); SDL_DestroySurface(converted); - /* Add the image representation */ + // Add the image representation [img addRepresentation:imgrep]; } SDL_free(images); @@ -327,4 +327,4 @@ void SDL_NSLog(const char *prefix, const char *text) } } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/cocoa/SDL_cocoavulkan.h b/src/video/cocoa/SDL_cocoavulkan.h index 3b42d4a3dc..12e58f34ea 100644 --- a/src/video/cocoa/SDL_cocoavulkan.h +++ b/src/video/cocoa/SDL_cocoavulkan.h @@ -50,4 +50,4 @@ void Cocoa_Vulkan_DestroySurface(SDL_VideoDevice *_this, #endif -#endif /* SDL_cocoavulkan_h_ */ +#endif // SDL_cocoavulkan_h_ diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m index 0c956411ac..eaa2b24887 100644 --- a/src/video/cocoa/SDL_cocoavulkan.m +++ b/src/video/cocoa/SDL_cocoavulkan.m @@ -43,7 +43,7 @@ const char *defaultPaths[] = { "libMoltenVK.dylib" }; -/* Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. */ +// Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. #define DEFAULT_HANDLE RTLD_DEFAULT int Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) @@ -59,13 +59,13 @@ int Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan Portability library is already loaded."); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } if (!path) { - /* Handle the case where Vulkan Portability is linked statically. */ + // Handle the case where Vulkan Portability is linked statically. vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, "vkGetInstanceProcAddr"); @@ -297,7 +297,7 @@ void Cocoa_Vulkan_DestroySurface(SDL_VideoDevice *_this, { if (_this->vulkan_config.loader_handle) { SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); - /* TODO: Add CFBridgingRelease(metalview) here perhaps? */ + // TODO: Add CFBridgingRelease(metalview) here perhaps? } } diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 9dfffac6dc..54cf362989 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -79,7 +79,7 @@ typedef enum - (void)windowDidFinishMoving; - (void)onMovingOrFocusClickPendingStateCleared; -/* Window delegate functionality */ +// Window delegate functionality - (BOOL)windowShouldClose:(id)sender; - (void)windowDidExpose:(NSNotification *)aNotification; - (void)windowDidMove:(NSNotification *)aNotification; @@ -97,11 +97,11 @@ typedef enum - (void)windowDidExitFullScreen:(NSNotification *)aNotification; - (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; -/* See if event is in a drag area, toggle on window dragging. */ +// See if event is in a drag area, toggle on window dragging. - (void)updateHitTest; - (BOOL)processHitTest:(NSEvent *)theEvent; -/* Window event handling */ +// Window event handling - (void)mouseDown:(NSEvent *)theEvent; - (void)rightMouseDown:(NSEvent *)theEvent; - (void)otherMouseDown:(NSEvent *)theEvent; @@ -118,10 +118,10 @@ typedef enum - (void)touchesEndedWithEvent:(NSEvent *)theEvent; - (void)touchesCancelledWithEvent:(NSEvent *)theEvent; -/* Touch event handling */ +// Touch event handling - (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent; -/* Tablet event handling (but these also come through on mouse events sometimes!) */ +// Tablet event handling (but these also come through on mouse events sometimes!) - (void)tabletProximity:(NSEvent *)theEvent; - (void)tabletPoint:(NSEvent *)theEvent; @@ -186,4 +186,4 @@ extern int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, extern int Cocoa_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window); extern int Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_cocoawindow_h_ */ +#endif // SDL_cocoawindow_h_ diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index a353981191..61a7adcf32 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -24,9 +24,9 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1090 #error SDL for macOS must be built with a 10.9 SDK or above. -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1090 */ +#endif // MAC_OS_X_VERSION_MAX_ALLOWED < 1090 -#include /* For FLT_MAX */ +#include // For FLT_MAX #include "../../events/SDL_dropevents_c.h" #include "../../events/SDL_keyboard_c.h" @@ -40,7 +40,7 @@ #include "SDL_cocoaopengles.h" #include "SDL_cocoavideo.h" -/* #define DEBUG_COCOAWINDOW */ +// #define DEBUG_COCOAWINDOW #ifdef DEBUG_COCOAWINDOW #define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) @@ -65,28 +65,28 @@ @end @interface NSScreen (SDL) -#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 /* Added in the 12.0 SDK */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 // Added in the 12.0 SDK @property(readonly) NSEdgeInsets safeAreaInsets; #endif @end @interface NSWindow (SDL) -#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 /* Added in the 10.10 SDK */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 // Added in the 10.10 SDK @property(readonly) NSRect contentLayoutRect; #endif -/* This is available as of 10.13.2, but isn't in public headers */ +// This is available as of 10.13.2, but isn't in public headers @property(nonatomic) NSRect mouseConfinementRect; @end @interface SDL3Window : NSWindow -/* These are needed for borderless/fullscreen windows */ +// These are needed for borderless/fullscreen windows - (BOOL)canBecomeKeyWindow; - (BOOL)canBecomeMainWindow; - (void)sendEvent:(NSEvent *)event; - (void)doCommandBySelector:(SEL)aSelector; -/* Handle drag-and-drop of files onto the SDL window. */ +// Handle drag-and-drop of files onto the SDL window. - (NSDragOperation)draggingEntered:(id)sender; - (NSDragOperation)draggingUpdated:(id)sender; - (BOOL)performDragOperation:(id)sender; @@ -160,7 +160,7 @@ */ - (void)doCommandBySelector:(SEL)aSelector { - /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/ + // NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector)); } - (NSDragOperation)draggingEntered:(id)sender @@ -171,7 +171,7 @@ return NSDragOperationCopy; } - return NSDragOperationNone; /* no idea what to do with this, reject it. */ + return NSDragOperationNone; // no idea what to do with this, reject it. } - (NSDragOperation)draggingUpdated:(id)sender @@ -194,7 +194,7 @@ return NSDragOperationCopy; } - return NSDragOperationNone; /* no idea what to do with this, reject it. */ + return NSDragOperationNone; // no idea what to do with this, reject it. } - (BOOL)performDragOperation:(id)sender @@ -237,7 +237,7 @@ } if (desiredType == nil) { - return NO; /* can't accept anything that's being dropped here. */ + return NO; // can't accept anything that's being dropped here. } pboardData = [pasteboard dataForType:desiredType]; if (pboardData == nil) { @@ -249,14 +249,14 @@ pboardString = [pasteboard stringForType:desiredType]; pboardPlist = [pasteboard propertyListForType:desiredType]; - /* Use SendDropPosition to update the mouse location */ + // Use SendDropPosition to update the mouse location point = [sender draggingLocation]; x = point.x; y = (sdlwindow->h - point.y); if (x >= 0.0f && x < (float)sdlwindow->w && y >= 0.0f && y < (float)sdlwindow->h) { SDL_SendDropPosition(sdlwindow, x, y); } - /* Use SendDropPosition to update the mouse location */ + // Use SendDropPosition to update the mouse location if ([desiredType isEqualToString:NSFilenamesPboardType]) { for (NSString *path in (NSArray *)pboardPlist) { @@ -265,7 +265,7 @@ [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil]; - /* If the URL is an alias, resolve it. */ + // If the URL is an alias, resolve it. if ([isAlias boolValue]) { NSURLBookmarkResolutionOptions opts = NSURLBookmarkResolutionWithoutMounting | NSURLBookmarkResolutionWithoutUI; @@ -325,7 +325,7 @@ SDL_Window *sdlwindow = NULL; SDL_VideoDevice *_this = SDL_GetVideoDevice(); - /* !!! FIXME: is there a better way to do this? */ + // !!! FIXME: is there a better way to do this? if (_this) { for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) { NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)sdlwindow->internal).nswindow; @@ -369,7 +369,7 @@ static NSScreen *ScreenForPoint(const NSPoint *point) { NSScreen *screen; - /* Do a quick check first to see if the point lies on a specific screen*/ + // Do a quick check first to see if the point lies on a specific screen for (NSScreen *candidate in [NSScreen screens]) { if (NSPointInRect(*point, [candidate frame])) { screen = candidate; @@ -377,7 +377,7 @@ static NSScreen *ScreenForPoint(const NSPoint *point) } } - /* Find the screen the point is closest to */ + // Find the screen the point is closest to if (!screen) { CGFloat closest = MAXFLOAT; for (NSScreen *candidate in [NSScreen screens]) { @@ -407,7 +407,7 @@ static void ConvertNSRect(NSRect *r) static void ScheduleContextUpdates(SDL_CocoaWindowData *data) { -/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. #ifdef SDL_VIDEO_OPENGL #ifdef __clang__ @@ -437,10 +437,10 @@ static void ScheduleContextUpdates(SDL_CocoaWindowData *data) #pragma clang diagnostic pop #endif -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL } -/* !!! FIXME: this should use a hint callback. */ +// !!! FIXME: this should use a hint callback. static int GetHintCtrlClickEmulateRightClick(void) { return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); @@ -487,14 +487,14 @@ static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style) SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; NSWindow *nswindow = data.nswindow; - /* The view responder chain gets messed with during setStyleMask */ + // The view responder chain gets messed with during setStyleMask if ([data.sdlContentView nextResponder] == data.listener) { [data.sdlContentView setNextResponder:nil]; } [nswindow setStyleMask:style]; - /* The view responder chain gets messed with during setStyleMask */ + // The view responder chain gets messed with during setStyleMask if ([data.sdlContentView nextResponder] != data.listener) { [data.sdlContentView setNextResponder:data.listener]; } @@ -598,7 +598,7 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window) nswindow.mouseConfinementRect = rect; } } else { - /* Move the cursor to the nearest point in the window */ + // Move the cursor to the nearest point in the window if (ShouldAdjustCoordinatesForGrab(window)) { float x, y; CGPoint cgpoint; @@ -616,7 +616,7 @@ static SDL_Window *GetTopmostWindow(SDL_Window *window) { SDL_Window *topmost = window; - /* Find the topmost parent */ + // Find the topmost parent while (topmost->parent != NULL) { topmost = topmost->parent; } @@ -788,13 +788,13 @@ static NSCursor *Cocoa_GetDesiredCursor(void) SDL_CocoaVideoData *videodata = ((__bridge SDL_CocoaWindowData *)window->internal).videodata; if (!videodata.allow_spaces) { - return NO; /* Spaces are forcibly disabled. */ + return NO; // Spaces are forcibly disabled. } else if (state && window->fullscreen_exclusive) { - 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_exclusive_display) { - 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) { @@ -807,7 +807,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } inFullscreenTransition = YES; - /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */ + // 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]; return YES; @@ -956,7 +956,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) pendingWindowWarpX = pendingWindowWarpY = FLT_MAX; } if (mouse->relative_mode && !mouse->relative_mode_warp && mouse->focus == _data.window) { - /* Move the cursor to the nearest point in the window */ + // Move the cursor to the nearest point in the window { float x, y; CGPoint cgpoint; @@ -1015,7 +1015,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) ConvertNSRect(&rect); if (inFullscreenTransition || b_inModeTransition) { - /* We'll take care of this at the end of the transition */ + // We'll take care of this at the end of the transition return; } @@ -1024,7 +1024,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) ScheduleContextUpdates(_data); - /* Get the parent-relative coordinates for child windows. */ + // Get the parent-relative coordinates for child windows. SDL_GlobalToRelativeForWindow(window, x, y, &x, &y); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); } @@ -1087,7 +1087,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) BOOL zoomed; if (inFullscreenTransition || b_inModeTransition) { - /* We'll take care of this at the end of the transition */ + // We'll take care of this at the end of the transition return; } @@ -1150,10 +1150,10 @@ static NSCursor *Cocoa_GetDesiredCursor(void) - (void)windowDidDeminiaturize:(NSNotification *)aNotification { - /* Always send restored before maximized. */ + // Always send restored before maximized. SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_RESTORED, 0, 0); - /* isZoomed always returns true if the window is not resizable. */ + // isZoomed always returns true if the window is not resizable. if ((_data.window->flags & SDL_WINDOW_RESIZABLE) && Cocoa_IsZoomed(_data.window)) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); } @@ -1167,11 +1167,11 @@ static NSCursor *Cocoa_GetDesiredCursor(void) { SDL_Window *window = _data.window; - /* We're going to get keyboard events, since we're key. */ - /* This needs to be done before restoring the relative mouse mode. */ + // We're going to get keyboard events, since we're key. + // This needs to be done before restoring the relative mouse mode. Cocoa_SetKeyboardFocus(_data.keyboard_focus ? _data.keyboard_focus : window); - /* If we just gained focus we need the updated mouse position */ + // If we just gained focus we need the updated mouse position if (!(window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE)) { NSPoint point; float x, y; @@ -1185,7 +1185,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } } - /* Check to see if someone updated the clipboard */ + // Check to see if someone updated the clipboard Cocoa_CheckClipboardUpdate(_data.videodata); if (isFullscreenSpace && !window->fullscreen_exclusive) { @@ -1200,12 +1200,12 @@ static NSCursor *Cocoa_GetDesiredCursor(void) - (void)windowDidResignKey:(NSNotification *)aNotification { - /* Some other window will get mouse events, since we're not key. */ + // Some other window will get mouse events, since we're not key. if (SDL_GetMouseFocus() == _data.window) { SDL_SetMouseFocus(NULL); } - /* Some other window will get keyboard events, since we're not key. */ + // Some other window will get keyboard events, since we're not key. if (SDL_GetKeyboardFocus() == _data.window) { SDL_SetKeyboardFocus(NULL); } @@ -1224,7 +1224,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } if ([oldscale doubleValue] != [_data.nswindow backingScaleFactor]) { - /* Send a resize event when the backing scale factor changes. */ + // Send a resize event when the backing scale factor changes. [self windowDidResize:aNotification]; } } @@ -1236,7 +1236,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) - (void)windowDidChangeScreen:(NSNotification *)aNotification { - /*printf("WINDOWDIDCHANGESCREEN\n");*/ + // printf("WINDOWDIDCHANGESCREEN\n"); #ifdef SDL_VIDEO_OPENGL @@ -1246,7 +1246,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } } -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL } - (void)windowWillEnterFullScreen:(NSNotification *)aNotification @@ -1398,16 +1398,16 @@ static NSCursor *Cocoa_GetDesiredCursor(void) [self addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; [nswindow miniaturize:nil]; } else { - /* Adjust the fullscreen toggle button and readd menu now that we're here. */ + // Adjust the fullscreen toggle button and readd menu now that we're here. if (window->flags & SDL_WINDOW_RESIZABLE) { - /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } else { [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; } [NSMenu setMenuBarVisible:YES]; - /* Restore windowed size and position in case it changed while fullscreen */ + // Restore windowed size and position in case it changed while fullscreen NSRect rect; rect.origin.x = _data.was_zoomed ? window->windowed.x : window->floating.x; rect.origin.y = _data.was_zoomed ? window->windowed.y : window->floating.y; @@ -1430,7 +1430,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) _data.was_zoomed = SDL_FALSE; - /* FIXME: Why does the window get hidden? */ + // FIXME: Why does the window get hidden? if (!(window->flags & SDL_WINDOW_HIDDEN)) { Cocoa_ShowWindow(SDL_GetVideoDevice(), window); } @@ -1452,7 +1452,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) */ - (void)flagsChanged:(NSEvent *)theEvent { - /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); /* Catch capslock in here as a special case: https://developer.apple.com/library/archive/qa/qa1519/_index.html @@ -1472,11 +1472,11 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } - (void)keyDown:(NSEvent *)theEvent { - /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); } - (void)keyUp:(NSEvent *)theEvent { - /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); } /* We'll respond to selectors by doing nothing so we don't beep. @@ -1484,7 +1484,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) */ - (void)doCommandBySelector:(SEL)aSelector { - /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/ + // NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector)); } - (void)updateHitTest @@ -1516,7 +1516,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) { SDL_Window *window = _data.window; - if (window->hit_test) { /* if no hit-test, skip this. */ + if (window->hit_test) { // if no hit-test, skip this. const NSPoint location = [theEvent locationInWindow]; const SDL_Point point = { (int)location.x, window->h - (((int)location.y) - 1) }; const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); @@ -1525,17 +1525,17 @@ static NSCursor *Cocoa_GetDesiredCursor(void) isDragAreaRunning = YES; [_data.nswindow setMovableByWindowBackground:YES]; } - return YES; /* dragging! */ + return YES; // dragging! } else { 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) @@ -1579,7 +1579,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ return; } - /* Ignore events that aren't inside the client area (i.e. title bar.) */ + // Ignore events that aren't inside the client area (i.e. title bar.) if ([theEvent window]) { NSRect windowRect = [[[theEvent window] contentView] frame]; if (!NSMouseInRect([theEvent locationInWindow], windowRect, NO)) { @@ -1589,7 +1589,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; /* dragging, drop event. */ + return; // dragging, drop event. } switch ([theEvent buttonNumber]) { @@ -1642,7 +1642,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; /* stopped dragging, drop event. */ + return; // stopped dragging, drop event. } switch ([theEvent buttonNumber]) { @@ -1714,7 +1714,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; /* dragging, drop event. */ + return; // dragging, drop event. } if (mouse->relative_mode) { @@ -1725,7 +1725,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ y = (window->h - point.y); if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) { - /* Mouse grab is taken care of by the confinement rect */ + // Mouse grab is taken care of by the confinement rect } else { CGPoint cgpoint; if (ShouldAdjustCoordinatesForGrab(window) && @@ -1857,7 +1857,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ */ SDL_Window *window = NULL; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202 /* Added in the 10.12.2 SDK. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101202 // Added in the 10.12.2 SDK. if ([touch respondsToSelector:@selector(type)]) { /* TODO: Before implementing direct touch support here, we need to * figure out whether the OS generates mouse events from them on its @@ -1879,7 +1879,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ fingerId = (SDL_FingerID)(uintptr_t)[touch identity]; x = [touch normalizedPosition].x; y = [touch normalizedPosition].y; - /* Make the origin the upper left instead of the lower left */ + // Make the origin the upper left instead of the lower left y = 1.0f - y; switch (phase) { @@ -1918,7 +1918,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ - (void)setSDLWindow:(SDL_Window *)window; -/* The default implementation doesn't pass rightMouseDown to responder chain */ +// The default implementation doesn't pass rightMouseDown to responder chain - (void)rightMouseDown:(NSEvent *)theEvent; - (BOOL)mouseDownCanMoveWindow; - (void)drawRect:(NSRect)dirtyRect; @@ -1961,7 +1961,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ return YES; } -/* This is also called when a Metal layer is active. */ +// This is also called when a Metal layer is active. - (void)updateLayer { /* Force the graphics context to clear to black so we don't get a flash of @@ -2011,7 +2011,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->internal; SDL_CocoaWindowData *data; - /* Allocate the window data */ + // Allocate the window data data = [[SDL_CocoaWindowData alloc] init]; if (!data) { return SDL_OutOfMemory(); @@ -2023,10 +2023,10 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow data.nscontexts = [[NSMutableArray alloc] init]; data.sdlContentView = nsview; - /* Create an event listener for the window */ + // Create an event listener for the window data.listener = [[SDL3Cocoa_WindowListener alloc] init]; - /* Fill in the SDL window with the window data */ + // Fill in the SDL window with the window data { int x, y; NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; @@ -2038,7 +2038,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow window->h = (int)rect.size.height; } - /* Set up the listener after we create the view */ + // Set up the listener after we create the view [data.listener listen:data]; if ([nswindow isVisible]) { @@ -2065,7 +2065,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow } } - /* isZoomed always returns true if the window is not resizable */ + // isZoomed always returns true if the window is not resizable if ((window->flags & SDL_WINDOW_RESIZABLE) && Cocoa_IsZoomed(window)) { window->flags |= SDL_WINDOW_MAXIMIZED; } else { @@ -2124,7 +2124,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow [nswindow setOneShot:NO]; if (window->flags & SDL_WINDOW_EXTERNAL) { - /* Query the title from the existing window */ + // Query the title from the existing window NSString *title = [nswindow title]; if (title) { window->title = SDL_strdup([title UTF8String]); @@ -2135,7 +2135,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow SDL_SetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, (__bridge void *)data.nswindow); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER, SDL_METALVIEW_TAG); - /* All done! */ + // All done! window->internal = (SDL_WindowData *)CFBridgingRetain(data); return 0; } @@ -2185,13 +2185,13 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie style = GetWindowStyle(window); - /* Figure out which screen to place this window */ + // Figure out which screen to place this window screen = ScreenForRect(&rect); screenRect = [screen frame]; rect.origin.x -= screenRect.origin.x; rect.origin.y -= screenRect.origin.y; - /* Constrain the popup */ + // Constrain the popup if (SDL_WINDOW_IS_POPUP(window)) { if (rect.origin.x + rect.size.width > screenRect.origin.x + screenRect.size.width) { rect.origin.x -= (rect.origin.x + rect.size.width) - (screenRect.origin.x + screenRect.size.width); @@ -2212,22 +2212,22 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie [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 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]; } #endif if (videodata.allow_spaces) { - /* we put fullscreen desktop windows in their own Space, without a toggle button or menubar, later */ + // 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. */ + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } } - /* Create a default view for this window */ + // Create a default view for this window rect = [nswindow contentRectForFrameRect:[nswindow frame]]; contentView = [[SDL3View alloc] initWithFrame:rect]; [contentView setSDLWindow:window]; @@ -2244,7 +2244,7 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie nswindow.backgroundColor = [NSColor clearColor]; } -/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ +// 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" @@ -2269,8 +2269,8 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie nsview.layer.contentsScale = 1; } } -#endif /* SDL_VIDEO_OPENGL_EGL */ -#endif /* SDL_VIDEO_OPENGL_ES2 */ +#endif // SDL_VIDEO_OPENGL_EGL +#endif // SDL_VIDEO_OPENGL_ES2 [nswindow setContentView:nsview]; if (SetupWindowData(_this, window, nswindow, nsview) < 0) { @@ -2281,7 +2281,7 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie return 0; } - /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ + // The rest of this macro mess is for OpenGL or OpenGL ES windows #ifdef SDL_VIDEO_OPENGL_ES2 if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { #ifdef SDL_VIDEO_OPENGL_EGL @@ -2292,9 +2292,9 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie 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_EGL } -#endif /* SDL_VIDEO_OPENGL_ES2 */ +#endif // SDL_VIDEO_OPENGL_ES2 return 0; } } @@ -2353,7 +2353,7 @@ int Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) } ConvertNSRect(&rect); - /* Position and constrain the popup */ + // Position and constrain the popup if (SDL_WINDOW_IS_POPUP(window)) { NSRect screenRect = [ScreenForRect(&rect) frame]; @@ -2388,7 +2388,7 @@ void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) Cocoa_SyncWindow(_this, window); } - /* isZoomed always returns true if the window is not resizable */ + // isZoomed always returns true if the window is not resizable if (!(window->flags & SDL_WINDOW_RESIZABLE) || !Cocoa_IsZoomed(window)) { if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { int x, y; @@ -2450,7 +2450,7 @@ void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int NSRect viewport = [contentView bounds]; if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { - /* This gives us the correct viewport for a Retina-enabled view. */ + // This gives us the correct viewport for a Retina-enabled view. viewport = [contentView convertRectToBacking:viewport]; } @@ -2479,7 +2479,7 @@ void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) if (bActivate) { [nswindow makeKeyAndOrderFront:nil]; } else { - /* Order this window below the key window if we're not activating it */ + // Order this window below the key window if we're not activating it if ([NSApp keyWindow]) { [nswindow orderWindow:NSWindowBelow relativeTo:[[NSApp keyWindow] windowNumber]]; } @@ -2514,12 +2514,12 @@ void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) */ Cocoa_SetWindowModalFor(_this, window, NULL); - /* Transfer keyboard focus back to the parent */ + // Transfer keyboard focus back to the parent if (window->flags & SDL_WINDOW_POPUP_MENU) { if (window == SDL_GetKeyboardFocus()) { SDL_Window *new_focus = window->parent; - /* Find the highest level window that isn't being hidden or destroyed. */ + // Find the highest level window that isn't being hidden or destroyed. while (new_focus->parent != NULL && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -2620,11 +2620,11 @@ void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) } else if ((window->flags & SDL_WINDOW_RESIZABLE) && Cocoa_IsZoomed(window)) { NSRect rect; - /* Update the floating coordinates */ + // Update the floating coordinates rect.origin.x = window->floating.x; rect.origin.y = window->floating.y; - /* The floating size will be set in windowWillResize */ + // The floating size will be set in windowWillResize [nswindow zoom:nil]; rect.size.width = window->floating.w; @@ -2647,11 +2647,11 @@ void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_boo @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; - /* If the window is in or transitioning to/from fullscreen, this will be set on leave. */ + // If the window is in or transitioning to/from fullscreen, this will be set on leave. if (!(window->flags & SDL_WINDOW_FULLSCREEN) && ![data.listener isInFullscreenSpaceTransition]) { if (SetWindowStyle(window, GetWindowStyle(window))) { if (bordered) { - Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */ + Cocoa_SetWindowTitle(_this, window); // this got blanked out. } } } else { @@ -2676,7 +2676,7 @@ void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bo } if (videodata.allow_spaces) { if (resizable) { - /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } else { [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; @@ -2691,7 +2691,7 @@ void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_ SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; NSWindow *nswindow = data.nswindow; - /* If the window is in or transitioning to/from fullscreen, this will be set on leave. */ + // If the window is in or transitioning to/from fullscreen, this will be set on leave. if (!(window->flags & SDL_WINDOW_FULLSCREEN) && ![data.listener isInFullscreenSpaceTransition]) { if (on_top) { [nswindow setLevel:NSFloatingWindowLevel]; @@ -2709,7 +2709,7 @@ int Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vi NSWindow *nswindow = data.nswindow; NSRect rect; - /* The view responder chain gets messed with during setStyleMask */ + // The view responder chain gets messed with during setStyleMask if ([data.sdlContentView nextResponder] == data.listener) { [data.sdlContentView setNextResponder:nil]; } @@ -2760,13 +2760,13 @@ int Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vi * was created as fullscreen-desktop. */ [nswindow setStyleMask:GetWindowWindowedStyle(window)]; - /* Hack to restore window decorations on macOS 10.10 */ + // 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]; } - /* The view responder chain gets messed with during setStyleMask */ + // The view responder chain gets messed with during setStyleMask if ([data.sdlContentView nextResponder] != data.listener) { [data.sdlContentView setNextResponder:data.listener]; } @@ -2774,7 +2774,7 @@ int Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vi [nswindow setContentSize:rect.size]; [nswindow setFrameOrigin:rect.origin]; - /* When the window style changes the title is cleared */ + // When the window style changes the title is cleared if (!fullscreen) { Cocoa_SetWindowTitle(_this, window); @@ -2788,7 +2788,7 @@ int Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vi } if (SDL_ShouldAllowTopmost() && fullscreen) { - /* OpenGL is rendering to the window, so make it visible! */ + // OpenGL is rendering to the window, so make it visible! [nswindow setLevel:kCGMainMenuWindowLevel + 1]; } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { [nswindow setLevel:NSFloatingWindowLevel]; @@ -2866,21 +2866,21 @@ SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *wind NSScreen *screen; SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; - /* Not recognized via CHECK_WINDOW_MAGIC */ + // 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");*/ + // Don't set the error here, it hides other errors and is ignored anyway + // return SDL_SetError("Window data not set"); return 0; } - /* NSWindow.screen may be nil when the window is off-screen. */ + // 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 */ + // 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++) { @@ -2891,7 +2891,7 @@ SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *wind } } - /* The higher level code will use other logic to find the display */ + // The higher level code will use other logic to find the display return 0; } } @@ -2911,8 +2911,8 @@ int Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_boo if (data && (window->flags & SDL_WINDOW_FULLSCREEN) != 0) { 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) */ + // 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:kCGMainMenuWindowLevel + 1]; } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { [data.nswindow setLevel:NSFloatingWindowLevel]; @@ -2935,7 +2935,7 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) NSArray *contexts; -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL SDL_Window *topmost = GetTopmostWindow(window); SDL_CocoaWindowData *topmost_data = (__bridge SDL_CocoaWindowData *)topmost->internal; @@ -2960,7 +2960,7 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) data.listener = nil; if (!(window->flags & SDL_WINDOW_EXTERNAL)) { - /* Release the content view to avoid further updateLayer callbacks */ + // Release the content view to avoid further updateLayer callbacks [data.nswindow setContentView:nil]; [data.nswindow close]; } @@ -2969,11 +2969,11 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) contexts = [data.nscontexts copy]; for (SDL3OpenGLContext *context in contexts) { - /* Calling setWindow:NULL causes the context to remove itself from the context list. */ + // Calling setWindow:NULL causes the context to remove itself from the context list. [context setWindow:NULL]; } -#endif /* SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_OPENGL } window->internal = NULL; } @@ -3011,7 +3011,7 @@ SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_ int count = 0; while ([data.listener isInFullscreenSpaceTransition]) { if (++count == limit) { - /* Uh oh, transition isn't completing. Should we assert? */ + // Uh oh, transition isn't completing. Should we assert? break; } SDL_Delay(1); @@ -3020,14 +3020,14 @@ SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_ if ([data.listener isInFullscreenSpace] == (state ? YES : NO)) { break; } - /* Try again, the last attempt was interrupted by user gestures */ + // Try again, the last attempt was interrupted by user gestures if (![data.listener setFullscreenSpace:(state ? YES : NO)]) { - break; /* ??? */ + break; // ??? } } } - /* Return TRUE to prevent non-space fullscreen logic from running */ + // Return TRUE to prevent non-space fullscreen logic from running succeeded = SDL_TRUE; } @@ -3078,7 +3078,7 @@ int Cocoa_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SD int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) { @autoreleasepool { - /* Note that this is app-wide and not window-specific! */ + // Note that this is app-wide and not window-specific! SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; if (data.flash_request) { @@ -3088,7 +3088,7 @@ int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOpera switch (operation) { case SDL_FLASH_CANCEL: - /* Canceled above */ + // Canceled above break; case SDL_FLASH_BRIEFLY: data.flash_request = [NSApp requestUserAttention:NSInformationalRequest]; @@ -3105,7 +3105,7 @@ int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOpera int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable) { - return 0; /* just succeed, the real work is done elsewhere. */ + return 0; // just succeed, the real work is done elsewhere. } int Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) @@ -3145,4 +3145,4 @@ int Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) return ret; } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/src/video/directx/SDL_d3d12.h b/src/video/directx/SDL_d3d12.h index 03e3d96df9..8ce9ebb815 100644 --- a/src/video/directx/SDL_d3d12.h +++ b/src/video/directx/SDL_d3d12.h @@ -32,10 +32,10 @@ */ #define __REQUIRED_RPCNDR_H_VERSION__ 475 -/* May not be defined in winapifamily.h, can safely be ignored */ +// May not be defined in winapifamily.h, can safely be ignored #ifndef WINAPI_PARTITION_GAMES #define WINAPI_PARTITION_GAMES 0 -#endif /* WINAPI_PARTITION_GAMES */ +#endif // WINAPI_PARTITION_GAMES #define COBJMACROS #include "d3d12.h" @@ -55,11 +55,11 @@ */ #define D3D_CALL_RET(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__) -#else /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#else // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) #if defined(SDL_PLATFORM_XBOXONE) #include -#else /* SDL_PLATFORM_XBOXSERIES */ +#else // SDL_PLATFORM_XBOXSERIES #include #endif @@ -71,15 +71,15 @@ X = NULL; \ } -/* Older versions of the Xbox GDK may not have this defined */ +// Older versions of the Xbox GDK may not have this defined #ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT #define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 256 #endif -/* DXGI_PRESENT flags are removed on Xbox */ +// DXGI_PRESENT flags are removed on Xbox #define DXGI_PRESENT_ALLOW_TEARING 0 -/* Xbox D3D12 does not define the COBJMACROS, so we need to define them ourselves */ +// Xbox D3D12 does not define the COBJMACROS, so we need to define them ourselves #include "SDL_d3d12_xbox_cmacros.h" /* Xbox's D3D12 ABI actually varies from Windows, if a function does not exist @@ -87,6 +87,6 @@ */ #define D3D_CALL_RET(THIS, FUNC, RETVAL, ...) *(RETVAL) = (THIS)->FUNC(__VA_ARGS__) -#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) -#endif /* SDL_D3D12_H */ +#endif // SDL_D3D12_H diff --git a/src/video/directx/gen_xbox_cmacros.cs b/src/video/directx/gen_xbox_cmacros.cs index 519f64eebd..74923986dc 100644 --- a/src/video/directx/gen_xbox_cmacros.cs +++ b/src/video/directx/gen_xbox_cmacros.cs @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* Build and run this any time you update d3d12.h/d3d12sdklayers.h! */ +// Build and run this any time you update d3d12.h/d3d12sdklayers.h! using System.IO; diff --git a/src/video/dummy/SDL_nullevents.c b/src/video/dummy/SDL_nullevents.c index 6849efbbe6..e2b2c1ffb3 100644 --- a/src/video/dummy/SDL_nullevents.c +++ b/src/video/dummy/SDL_nullevents.c @@ -32,7 +32,7 @@ void DUMMY_PumpEvents(SDL_VideoDevice *_this) { - /* do nothing. */ + // do nothing. } -#endif /* SDL_VIDEO_DRIVER_DUMMY */ +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/src/video/dummy/SDL_nullevents_c.h b/src/video/dummy/SDL_nullevents_c.h index 5b1e15fe6e..7672e2b289 100644 --- a/src/video/dummy/SDL_nullevents_c.h +++ b/src/video/dummy/SDL_nullevents_c.h @@ -28,4 +28,4 @@ extern void DUMMY_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_nullevents_c_h_ */ +#endif // SDL_nullevents_c_h_ diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index b1c19ac48a..c0818b64f1 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -35,14 +35,14 @@ int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888; int w, h; - /* Create a new framebuffer */ + // Create a new framebuffer SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); if (!surface) { return -1; } - /* Save the info and return! */ + // Save the info and return! SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, surface); *format = surface_format; *pixels = surface->pixels; @@ -60,7 +60,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window return SDL_SetError("Couldn't find dummy surface for window"); } - /* Send the data to the display */ + // Send the data to the display if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES, SDL_FALSE)) { char file[128]; (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", @@ -75,4 +75,4 @@ void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind SDL_ClearProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE); } -#endif /* SDL_VIDEO_DRIVER_DUMMY */ +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/src/video/dummy/SDL_nullframebuffer_c.h b/src/video/dummy/SDL_nullframebuffer_c.h index 01644418f4..c946cc19a6 100644 --- a/src/video/dummy/SDL_nullframebuffer_c.h +++ b/src/video/dummy/SDL_nullframebuffer_c.h @@ -28,4 +28,4 @@ extern int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window extern int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); extern void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_nullframebuffer_c_h_ */ +#endif // SDL_nullframebuffer_c_h_ diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index a001433b55..dc36a6cf3f 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -51,7 +51,7 @@ #define DUMMYVID_DRIVER_NAME "dummy" #define DUMMYVID_DRIVER_EVDEV_NAME "evdev" -/* Initialization/Query functions */ +// Initialization/Query functions static int DUMMY_VideoInit(SDL_VideoDevice *_this); static void DUMMY_VideoQuit(SDL_VideoDevice *_this); @@ -66,7 +66,7 @@ static void DUMMY_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->floating.w, window->floating.h); } -/* DUMMY driver bootstrap functions */ +// DUMMY driver bootstrap functions static SDL_bool DUMMY_Available(const char *enable_hint) { @@ -92,14 +92,14 @@ static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint) return NULL; } - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } device->is_dummy = SDL_TRUE; - /* Set the function pointers */ + // Set the function pointers device->VideoInit = DUMMY_VideoInit; device->VideoQuit = DUMMY_VideoQuit; device->PumpEvents = DUMMY_PumpEvents; @@ -121,7 +121,7 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void) VideoBootStrap DUMMY_bootstrap = { DUMMYVID_DRIVER_NAME, "SDL dummy video driver", DUMMY_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; #ifdef SDL_INPUT_LINUXEV @@ -144,16 +144,16 @@ static SDL_VideoDevice *DUMMY_EVDEV_CreateDevice(void) VideoBootStrap DUMMY_evdev_bootstrap = { DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev", DUMMY_EVDEV_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; -#endif /* SDL_INPUT_LINUXEV */ +#endif // SDL_INPUT_LINUXEV int DUMMY_VideoInit(SDL_VideoDevice *_this) { SDL_DisplayMode mode; - /* Use a fake 32-bpp desktop mode */ + // Use a fake 32-bpp desktop mode SDL_zero(mode); mode.format = SDL_PIXELFORMAT_XRGB8888; mode.w = 1024; @@ -166,7 +166,7 @@ int DUMMY_VideoInit(SDL_VideoDevice *_this) SDL_EVDEV_Init(); #endif - /* We're done! */ + // We're done! return 0; } @@ -177,4 +177,4 @@ void DUMMY_VideoQuit(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_DUMMY */ +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/src/video/dummy/SDL_nullvideo.h b/src/video/dummy/SDL_nullvideo.h index 97534133f5..491ec76d76 100644 --- a/src/video/dummy/SDL_nullvideo.h +++ b/src/video/dummy/SDL_nullvideo.h @@ -25,4 +25,4 @@ #include "../SDL_sysvideo.h" -#endif /* SDL_nullvideo_h_ */ +#endif // SDL_nullvideo_h_ diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index 803d9f9ce1..80a4f1cd2b 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -262,7 +262,7 @@ static SDL_Scancode Emscripten_MapScanCode(const char *code) static EM_BOOL Emscripten_HandlePointerLockChange(int eventType, const EmscriptenPointerlockChangeEvent *changeEvent, void *userData) { SDL_WindowData *window_data = (SDL_WindowData *)userData; - /* keep track of lock losses, so we can regrab if/when appropriate. */ + // keep track of lock losses, so we can regrab if/when appropriate. window_data->has_pointer_lock = changeEvent->isActive; return 0; } @@ -273,7 +273,7 @@ static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEv const SDL_bool isPointerLocked = window_data->has_pointer_lock; float mx, my; - /* rescale (in case canvas is being scaled)*/ + // rescale (in case canvas is being scaled) double client_w, client_h, xscale, yscale; emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); xscale = window_data->window->w / client_w; @@ -298,7 +298,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse Uint8 sdl_button_state; SDL_EventType sdl_event_type; double css_w, css_h; - SDL_bool prevent_default = SDL_FALSE; /* needed for iframe implementation in Chrome-based browsers. */ + SDL_bool prevent_default = SDL_FALSE; // needed for iframe implementation in Chrome-based browsers. switch (mouseEvent->button) { case 0: @@ -316,7 +316,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse 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_EVENT_MOUSE_BUTTON_DOWN; @@ -327,7 +327,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse } SDL_SendMouseButton(0, window_data->window, SDL_DEFAULT_MOUSE_ID, sdl_button_state, sdl_button); - /* Do not consume the event if the mouse is outside of the canvas. */ + // Do not consume the event if the mouse is outside of the canvas. emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h); if (mouseEvent->targetX < 0 || mouseEvent->targetX >= css_w || mouseEvent->targetY < 0 || mouseEvent->targetY >= css_h) { @@ -344,7 +344,7 @@ static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseE const SDL_bool isPointerLocked = window_data->has_pointer_lock; if (!isPointerLocked) { - /* rescale (in case canvas is being scaled)*/ + // rescale (in case canvas is being scaled) float mx, my; double client_w, client_h; emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); @@ -366,13 +366,13 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent switch (wheelEvent->deltaMode) { case DOM_DELTA_PIXEL: - deltaY /= 100; /* 100 pixels make up a step */ + deltaY /= 100; // 100 pixels make up a step break; case DOM_DELTA_LINE: - deltaY /= 3; /* 3 lines make up a step */ + deltaY /= 3; // 3 lines make up a step break; case DOM_DELTA_PAGE: - deltaY *= 80; /* A page makes up 80 steps */ + deltaY *= 80; // A page makes up 80 steps break; } @@ -433,7 +433,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) { SDL_SendTouch(0, deviceId, id, window_data->window, SDL_TRUE, x, y, 1.0f); - /* disable browser scrolling/pinch-to-zoom if app handles touch events */ + // disable browser scrolling/pinch-to-zoom if app handles touch events if (!preventDefault && SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) { preventDefault = 1; } @@ -442,7 +442,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent } else { SDL_SendTouch(0, deviceId, id, window_data->window, SDL_FALSE, x, y, 1.0f); - /* block browser's simulated mousedown/mouseup on touchscreen devices */ + // block browser's simulated mousedown/mouseup on touchscreen devices preventDefault = 1; } } @@ -494,7 +494,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent } if (scancode == SDL_SCANCODE_UNKNOWN) { - /* KaiOS Left Soft Key and Right Soft Key, they act as OK/Next/Menu and Cancel/Back/Clear */ + // KaiOS Left Soft Key and Right Soft Key, they act as OK/Next/Menu and Cancel/Back/Clear if (SDL_strcmp(keyEvent->key, "SoftLeft") == 0) { scancode = SDL_SCANCODE_AC_FORWARD; } else if (SDL_strcmp(keyEvent->key, "SoftRight") == 0) { @@ -572,7 +572,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u SDL_WindowData *window_data = userData; SDL_bool force = SDL_FALSE; - /* update pixel ratio */ + // update pixel ratio if (window_data->window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { if (window_data->pixel_ratio != emscripten_get_device_pixel_ratio()) { window_data->pixel_ratio = emscripten_get_device_pixel_ratio(); @@ -581,7 +581,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u } if (!(window_data->window->flags & SDL_WINDOW_FULLSCREEN)) { - /* this will only work if the canvas size is set through css */ + // this will only work if the canvas size is set through css if (window_data->window->flags & SDL_WINDOW_RESIZABLE) { double w = window_data->window->w; double h = window_data->window->h; @@ -592,13 +592,13 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u emscripten_set_canvas_element_size(window_data->canvas_id, SDL_lroundf(w * window_data->pixel_ratio), SDL_lroundf(h * window_data->pixel_ratio)); - /* set_canvas_size unsets this */ + // set_canvas_size unsets this if (!window_data->external_size && window_data->pixel_ratio != 1.0f) { emscripten_set_element_css_size(window_data->canvas_id, w, h); } if (force) { - /* force the event to trigger, so pixel ratio changes can be handled */ + // force the event to trigger, so pixel ratio changes can be handled window_data->window->w = 0; window_data->window->h = 0; } @@ -613,7 +613,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u EM_BOOL Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData) { - /*this is used during fullscreen changes*/ + // this is used during fullscreen changes SDL_WindowData *window_data = userData; if (window_data->fullscreen_resize) { @@ -636,9 +636,9 @@ static const char *Emscripten_HandleBeforeUnload(int eventType, const void *rese { /* This event will need to be handled synchronously, e.g. using SDL_AddEventWatch, as the page is being closed *now*. */ - /* No need to send a SDL_EVENT_QUIT, the app won't get control again. */ + // No need to send a SDL_EVENT_QUIT, the app won't get control again. SDL_SendAppEvent(SDL_EVENT_TERMINATING); - return ""; /* don't trigger confirmation dialog */ + return ""; // don't trigger confirmation dialog } // IF YOU CHANGE THIS STRUCTURE, YOU NEED TO UPDATE THE JAVASCRIPT THAT FILLS IT IN: makePointerEventCStruct, below. @@ -662,7 +662,7 @@ static void Emscripten_UpdatePointerFromEvent(SDL_WindowData *window_data, const { const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); if (pen) { - /* rescale (in case canvas is being scaled)*/ + // rescale (in case canvas is being scaled) double client_w, client_h; emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); const double xscale = window_data->window->w / client_w; @@ -770,7 +770,7 @@ static void Emscripten_set_pointer_event_callbacks(SDL_WindowData *data) var d = makePointerEventCStruct(event); if (d != 0) { _Emscripten_HandlePointerLeave(data, d); _SDL_free(d); } }; target.addEventListener("pointerleave", SDL3.eventHandlerPointerLeave); - target.addEventListener("pointercancel", SDL3.eventHandlerPointerLeave); /* catch this, just in case. */ + target.addEventListener("pointercancel", SDL3.eventHandlerPointerLeave); // catch this, just in case. SDL3.eventHandlerPointerGeneric = function(event) { var d = makePointerEventCStruct(event); if (d != 0) { _Emscripten_HandlePointerGeneric(data, d); _SDL_free(d); } @@ -805,7 +805,7 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data) { const char *keyElement; - /* There is only one window and that window is the canvas */ + // There is only one window and that window is the canvas emscripten_set_mousemove_callback(data->canvas_id, data, 0, Emscripten_HandleMouseMove); emscripten_set_mousedown_callback(data->canvas_id, data, 0, Emscripten_HandleMouseButton); @@ -826,7 +826,7 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data) emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandlePointerLockChange); - /* Keyboard events are awkward */ + // Keyboard events are awkward keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); if (!keyElement) { keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW; @@ -857,7 +857,7 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) // !!! FIXME: https://github.com/emscripten-core/emscripten/issues/7278#issuecomment-2280024621 Emscripten_unset_pointer_event_callbacks(data); - /* only works due to having one window */ + // only works due to having one window emscripten_set_mousemove_callback(data->canvas_id, NULL, 0, NULL); emscripten_set_mousedown_callback(data->canvas_id, NULL, 0, NULL); @@ -896,4 +896,4 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) emscripten_set_beforeunload_callback(NULL, NULL); } -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/src/video/emscripten/SDL_emscriptenevents.h b/src/video/emscripten/SDL_emscriptenevents.h index 41859805fe..ccf3ef0748 100644 --- a/src/video/emscripten/SDL_emscriptenevents.h +++ b/src/video/emscripten/SDL_emscriptenevents.h @@ -28,4 +28,4 @@ extern void Emscripten_RegisterEventHandlers(SDL_WindowData *data); extern void Emscripten_UnregisterEventHandlers(SDL_WindowData *data); extern EM_BOOL Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData); -#endif /* SDL_emscriptenevents_h_ */ +#endif // SDL_emscriptenevents_h_ diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 02f84e34ac..3d821ae56f 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -33,12 +33,12 @@ int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XBGR8888; int w, h; - /* Free the old framebuffer surface */ + // Free the old framebuffer surface SDL_WindowData *data = window->internal; surface = data->surface; SDL_DestroySurface(surface); - /* Create a new one */ + // Create a new one SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); @@ -46,7 +46,7 @@ int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo return -1; } - /* Save the info and return! */ + // Save the info and return! data->surface = surface; *format = surface_format; *pixels = surface->pixels; @@ -64,9 +64,9 @@ int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo return SDL_SetError("Couldn't find framebuffer surface for window"); } - /* Send the data to the display */ + // Send the data to the display - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off MAIN_THREAD_EM_ASM({ var w = $0; var h = $1; @@ -140,10 +140,10 @@ int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo SDL3.ctx.putImageData(SDL3.image, 0, 0); }, surface->w, surface->h, surface->pixels, data->canvas_id); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { - /* give back control to browser for screen refresh */ + // give back control to browser for screen refresh emscripten_sleep(0); } @@ -158,4 +158,4 @@ void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *win data->surface = NULL; } -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.h b/src/video/emscripten/SDL_emscriptenframebuffer.h index 2e0df3d0d1..c2406ecad1 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.h +++ b/src/video/emscripten/SDL_emscriptenframebuffer.h @@ -27,4 +27,4 @@ extern int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window extern int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); extern void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_emscriptenframebuffer_h_ */ +#endif // SDL_emscriptenframebuffer_h_ diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index 886c4a529b..3ef88bae0e 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -32,7 +32,7 @@ #include "../SDL_video_c.h" #include "../../events/SDL_mouse_c.h" -/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ +// older Emscriptens don't have this, but we need to for wasm64 compatibility. #ifndef MAIN_THREAD_EM_ASM_PTR #ifdef __wasm64__ #error You need to upgrade your Emscripten compiler to support wasm64 @@ -78,7 +78,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int return NULL; } - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off cursor_url = (const char *)MAIN_THREAD_EM_ASM_PTR({ var w = $0; var h = $1; @@ -109,7 +109,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int return urlBuf; }, surface->w, surface->h, hot_x, hot_y, conv_surf->pixels); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on SDL_DestroySurface(conv_surf); @@ -148,22 +148,22 @@ static int Emscripten_ShowCursor(SDL_Cursor *cursor) curdata = cursor->internal; if (curdata->system_cursor) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on } } else { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off MAIN_THREAD_EM_ASM( if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } ); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on } } return 0; @@ -174,7 +174,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) SDL_Window *window; SDL_WindowData *window_data; - /* TODO: pointer lock isn't actually enabled yet */ + // TODO: pointer lock isn't actually enabled yet if (enabled) { window = SDL_GetMouseFocus(); if (!window) { @@ -211,4 +211,4 @@ void Emscripten_QuitMouse(void) { } -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/src/video/emscripten/SDL_emscriptenmouse.h b/src/video/emscripten/SDL_emscriptenmouse.h index 113e4006a7..b155a9801e 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.h +++ b/src/video/emscripten/SDL_emscriptenmouse.h @@ -31,4 +31,4 @@ struct SDL_CursorData extern void Emscripten_InitMouse(void); extern void Emscripten_QuitMouse(void); -#endif /* SDL_emscriptenmouse_h_ */ +#endif // SDL_emscriptenmouse_h_ diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c index ae187a01e0..b9afb8a97c 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.c +++ b/src/video/emscripten/SDL_emscriptenopengles.c @@ -86,7 +86,7 @@ SDL_GLContext Emscripten_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window * attribs.antialias = _this->gl_config.multisamplebuffers == 1; if (_this->gl_config.major_version == 3) - attribs.majorVersion = 2; /* WebGL 2.0 ~= GLES 3.0 */ + attribs.majorVersion = 2; // WebGL 2.0 ~= GLES 3.0 window_data = window->internal; @@ -116,7 +116,7 @@ int Emscripten_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) { SDL_Window *window; - /* remove the context from its window */ + // remove the context from its window for (window = _this->windows; window; window = window->next) { SDL_WindowData *window_data = window->internal; @@ -132,7 +132,7 @@ int Emscripten_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) int Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) { if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { - /* give back control to browser for screen refresh */ + // give back control to browser for screen refresh emscripten_sleep(0); } return 0; @@ -140,7 +140,7 @@ int Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) int Emscripten_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) { - /* it isn't possible to reuse contexts across canvases */ + // it isn't possible to reuse contexts across canvases if (window && context) { SDL_WindowData *window_data = window->internal; @@ -155,4 +155,4 @@ int Emscripten_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_ return 0; } -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/src/video/emscripten/SDL_emscriptenopengles.h b/src/video/emscripten/SDL_emscriptenopengles.h index 4a75162330..2515ef9af8 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.h +++ b/src/video/emscripten/SDL_emscriptenopengles.h @@ -27,7 +27,7 @@ #include "../SDL_sysvideo.h" -/* OpenGLES functions */ +// OpenGLES functions extern int Emscripten_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern void Emscripten_GLES_UnloadLibrary(SDL_VideoDevice *_this); extern SDL_FunctionPointer Emscripten_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); @@ -38,6 +38,6 @@ extern int Emscripten_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext c extern int Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int Emscripten_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN -#endif /* SDL_emscriptenopengles_h_ */ +#endif // SDL_emscriptenopengles_h_ diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 12fb0ae2a5..607b765621 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -34,7 +34,7 @@ #define EMSCRIPTENVID_DRIVER_NAME "emscripten" -/* Initialization/Query functions */ +// Initialization/Query functions static int Emscripten_VideoInit(SDL_VideoDevice *_this); static int Emscripten_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void Emscripten_VideoQuit(SDL_VideoDevice *_this); @@ -48,7 +48,7 @@ static int Emscripten_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *wi static void Emscripten_PumpEvents(SDL_VideoDevice *_this); static void Emscripten_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); -/* Emscripten driver bootstrap functions */ +// Emscripten driver bootstrap functions static void Emscripten_DeleteDevice(SDL_VideoDevice *device) { @@ -59,7 +59,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) { SDL_VideoDevice *device; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; @@ -71,7 +71,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) */ SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); - /* Set the function pointers */ + // Set the function pointers device->VideoInit = Emscripten_VideoInit; device->VideoQuit = Emscripten_VideoQuit; device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds; @@ -117,14 +117,14 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) VideoBootStrap Emscripten_bootstrap = { EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver", Emscripten_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; int Emscripten_VideoInit(SDL_VideoDevice *_this) { SDL_DisplayMode mode; - /* Use a fake 32-bpp desktop mode */ + // Use a fake 32-bpp desktop mode SDL_zero(mode); mode.format = SDL_PIXELFORMAT_XRGB8888; emscripten_get_screen_size(&mode.w, &mode.h); @@ -136,17 +136,17 @@ int Emscripten_VideoInit(SDL_VideoDevice *_this) Emscripten_InitMouse(); - /* Assume we have a mouse and keyboard */ + // Assume we have a mouse and keyboard SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); - /* We're done! */ + // We're done! return 0; } static int Emscripten_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { - /* can't do this */ + // can't do this return 0; } @@ -172,7 +172,7 @@ static int Emscripten_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDi static void Emscripten_PumpEvents(SDL_VideoDevice *_this) { - /* do nothing. */ + // do nothing. } static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -182,7 +182,7 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, S double css_w, css_h; const char *selector; - /* Allocate window internal data */ + // Allocate window internal data wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!wdata) { return -1; @@ -204,14 +204,14 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, S scaled_w = SDL_floor(window->w * wdata->pixel_ratio); scaled_h = SDL_floor(window->h * wdata->pixel_ratio); - /* set a fake size to check if there is any CSS sizing the canvas */ + // set a fake size to check if there is any CSS sizing the canvas emscripten_set_canvas_element_size(wdata->canvas_id, 1, 1); emscripten_get_element_css_size(wdata->canvas_id, &css_w, &css_h); wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1; if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) { - /* external css has resized us */ + // external css has resized us scaled_w = css_w * wdata->pixel_ratio; scaled_h = css_h * wdata->pixel_ratio; @@ -219,26 +219,26 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, S } emscripten_set_canvas_element_size(wdata->canvas_id, SDL_lroundf(scaled_w), SDL_lroundf(scaled_h)); - /* if the size is not being controlled by css, we need to scale down for hidpi */ + // if the size is not being controlled by css, we need to scale down for hidpi if (!wdata->external_size) { if (wdata->pixel_ratio != 1.0f) { - /*scale canvas down*/ + // scale canvas down emscripten_set_element_css_size(wdata->canvas_id, window->w, window->h); } } wdata->window = window; - /* Setup driver data for this window */ + // Setup driver data for this window window->internal = wdata; - /* One window, it always has focus */ + // One window, it always has focus SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); Emscripten_RegisterEventHandlers(wdata); - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -248,13 +248,13 @@ static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) if (window->internal) { data = window->internal; - /* update pixel ratio */ + // update pixel ratio if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { data->pixel_ratio = emscripten_get_device_pixel_ratio(); } emscripten_set_canvas_element_size(data->canvas_id, SDL_lroundf(window->floating.w * data->pixel_ratio), SDL_lroundf(window->floating.h * data->pixel_ratio)); - /*scale canvas down*/ + // scale canvas down if (!data->external_size && data->pixel_ratio != 1.0f) { emscripten_set_element_css_size(data->canvas_id, window->floating.w, window->floating.h); } @@ -282,7 +282,7 @@ static void Emscripten_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) Emscripten_UnregisterEventHandlers(data); - /* We can't destroy the canvas, so resize it to zero instead */ + // We can't destroy the canvas, so resize it to zero instead emscripten_set_canvas_element_size(data->canvas_id, 0, 0); SDL_free(data->canvas_id); @@ -342,4 +342,4 @@ static void Emscripten_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window emscripten_set_window_title(window->title); } -#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */ +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/src/video/emscripten/SDL_emscriptenvideo.h b/src/video/emscripten/SDL_emscriptenvideo.h index 4417205850..f5797e3c60 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.h +++ b/src/video/emscripten/SDL_emscriptenvideo.h @@ -47,4 +47,4 @@ struct SDL_WindowData SDL_bool has_pointer_lock; }; -#endif /* SDL_emscriptenvideo_h_ */ +#endif // SDL_emscriptenvideo_h_ diff --git a/src/video/gdk/SDL_gdktextinput.cpp b/src/video/gdk/SDL_gdktextinput.cpp index 0c6b1d30c1..b7c9aaabaa 100644 --- a/src/video/gdk/SDL_gdktextinput.cpp +++ b/src/video/gdk/SDL_gdktextinput.cpp @@ -27,7 +27,7 @@ #ifdef SDL_GDK_TEXTINPUT -/* GDK headers are weird here */ +// GDK headers are weird here #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -42,19 +42,19 @@ extern "C" { #include "../../events/SDL_keyboard_c.h" #include "../windows/SDL_windowsvideo.h" -/* TODO: Have a separate task queue for text input perhaps? */ +// TODO: Have a separate task queue for text input perhaps? static XTaskQueueHandle g_TextTaskQueue = NULL; -/* Global because there can be only one text entry shown at once. */ +// Global because there can be only one text entry shown at once. static XAsyncBlock *g_TextBlock = NULL; -/* Creation parameters */ +// Creation parameters static SDL_bool g_DidRegisterHints = SDL_FALSE; static char *g_TitleText = NULL; static char *g_DescriptionText = NULL; static char *g_DefaultText = NULL; static const Sint32 g_DefaultTextInputScope = (Sint32)XGameUiTextEntryInputScope::Default; static Sint32 g_TextInputScope = g_DefaultTextInputScope; -static const Sint32 g_DefaultMaxTextLength = 1024; /* as per doc: maximum allowed amount on consoles */ +static const Sint32 g_DefaultMaxTextLength = 1024; // as per doc: maximum allowed amount on consoles static Sint32 g_MaxTextLength = g_DefaultMaxTextLength; static void SDLCALL GDK_InternalHintCallback( @@ -67,11 +67,11 @@ static void SDLCALL GDK_InternalHintCallback( return; } - /* oldValue is ignored because we store it ourselves. */ - /* name is ignored because we deduce it from userdata */ + // oldValue is ignored because we store it ourselves. + // name is ignored because we deduce it from userdata if (userdata == &g_TextInputScope || userdata == &g_MaxTextLength) { - /* int32 hint */ + // int32 hint Sint32 intValue = (!newValue || newValue[0] == '\0') ? 0 : SDL_atoi(newValue); if (userdata == &g_MaxTextLength && intValue <= 0) { intValue = g_DefaultMaxTextLength; @@ -81,15 +81,15 @@ static void SDLCALL GDK_InternalHintCallback( *(Sint32 *)userdata = intValue; } else { - /* string hint */ + // string hint if (!newValue || newValue[0] == '\0') { - /* treat empty or NULL strings as just NULL for this impl */ + // treat empty or NULL strings as just NULL for this impl SDL_free(*(char **)userdata); *(char **)userdata = NULL; } else { char *newString = SDL_strdup(newValue); if (newString) { - /* free previous value and write the new one */ + // free previous value and write the new one SDL_free(*(char **)userdata); *(char **)userdata = newString; } @@ -101,7 +101,7 @@ static int GDK_InternalEnsureTaskQueue(void) { if (!g_TextTaskQueue) { if (SDL_GetGDKTaskQueue(&g_TextTaskQueue) < 0) { - /* SetError will be done for us. */ + // SetError will be done for us. return -1; } } @@ -116,17 +116,17 @@ static void CALLBACK GDK_InternalTextEntryCallback(XAsyncBlock *asyncBlock) Uint32 resultUsed = 0; char *resultBuffer = NULL; - /* The keyboard will be already hidden when we reach this code */ + // The keyboard will be already hidden when we reach this code if (FAILED(hR = XGameUiShowTextEntryResultSize( asyncBlock, &resultSize))) { SDL_SetError("XGameUiShowTextEntryResultSize failure with HRESULT of %08X", hR); } else if (resultSize > 0) { - /* +1 to be super sure that the buffer will be null terminated */ + // +1 to be super sure that the buffer will be null terminated resultBuffer = (char *)SDL_calloc(sizeof(*resultBuffer), 1 + (size_t)resultSize); if (resultBuffer) { - /* still pass the original size that we got from ResultSize */ + // still pass the original size that we got from ResultSize if (FAILED(hR = XGameUiShowTextEntryResult( asyncBlock, resultSize, @@ -134,21 +134,21 @@ static void CALLBACK GDK_InternalTextEntryCallback(XAsyncBlock *asyncBlock) &resultUsed))) { SDL_SetError("XGameUiShowTextEntryResult failure with HRESULT of %08X", hR); } - /* check that we have some text and that we weren't cancelled */ + // check that we have some text and that we weren't cancelled else if (resultUsed > 0 && resultBuffer[0] != '\0') { - /* it's null terminated so it's fine */ + // it's null terminated so it's fine SDL_SendKeyboardText(resultBuffer); } - /* we're done with the buffer */ + // we're done with the buffer SDL_free(resultBuffer); resultBuffer = NULL; } } - /* free the async block after we're done */ + // free the async block after we're done SDL_free(asyncBlock); asyncBlock = NULL; - g_TextBlock = NULL; /* once we do this we're fully done with the keyboard */ + g_TextBlock = NULL; // once we do this we're fully done with the keyboard } void GDK_EnsureHints(void) @@ -196,7 +196,7 @@ int GDK_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie int GDK_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) { - /* See notice in GDK_StartTextInput */ + // See notice in GDK_StartTextInput return 0; } @@ -216,13 +216,13 @@ int GDK_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) int GDK_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window) { - /* See notice in GDK_StartTextInput */ + // See notice in GDK_StartTextInput return 0; } SDL_bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - /* Currently always true for this input method */ + // Currently always true for this input method return SDL_TRUE; } @@ -239,12 +239,12 @@ void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prop HRESULT hR = S_OK; if (g_TextBlock) { - /* already showing the keyboard */ + // already showing the keyboard return; } if (GDK_InternalEnsureTaskQueue() < 0) { - /* unable to obtain the SDL GDK queue */ + // unable to obtain the SDL GDK queue return; } @@ -306,7 +306,7 @@ void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { if (g_TextBlock) { XAsyncCancel(g_TextBlock); - /* the completion callback will free the block */ + // the completion callback will free the block } } diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index 1a9a786cb0..c0f137ba81 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -87,7 +87,7 @@ class SDL_BView : public BView class SDL_BWin : public BWindow { public: - /* Constructor/Destructor */ + // Constructor/Destructor SDL_BWin(BRect bounds, window_look look, uint32 flags) : BWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags) { @@ -106,7 +106,7 @@ class SDL_BWin : public BWindow _prev_frame = NULL; _fullscreen = NULL; - /* Handle framebuffer stuff */ + // Handle framebuffer stuff _buffer_locker = new BLocker(); _bitmap = NULL; } @@ -135,7 +135,7 @@ class SDL_BWin : public BWindow delete _prev_frame; - /* Clean up framebuffer stuff */ + // Clean up framebuffer stuff _buffer_locker->Lock(); delete _buffer_locker; } @@ -225,29 +225,29 @@ class SDL_BWin : public BWindow #endif /* * * * * Event sending * * * * */ - /* Hook functions */ + // Hook functions virtual void FrameMoved(BPoint origin) { - /* Post a message to the BApp so that it can handle the window event */ + // 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); msg.AddInt32("window-y", (int)origin.y); _PostWindowEvent(msg); - /* Perform normal hook operations */ + // Perform normal hook operations BWindow::FrameMoved(origin); } void FrameResized(float width, float height) { - /* Post a message to the BApp so that it can handle the window event */ + // Post a message to the BApp so that it can handle the window event BMessage msg(BAPP_WINDOW_RESIZED); msg.AddInt32("window-w", (int)width + 1); msg.AddInt32("window-h", (int)height + 1); _PostWindowEvent(msg); - /* Perform normal hook operations */ + // Perform normal hook operations BWindow::FrameResized(width, height); } @@ -256,13 +256,13 @@ class SDL_BWin : public BWindow BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); _PostWindowEvent(msg); - /* We won't allow a quit unless asked by DestroyWindow() */ + // We won't allow a quit unless asked by DestroyWindow() return false; } void WindowActivated(bool active) { - BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ + BMessage msg(BAPP_KEYBOARD_FOCUS); // Mouse focus sold separately msg.AddBool("focusGained", active); _PostWindowEvent(msg); } @@ -271,18 +271,18 @@ class SDL_BWin : public BWindow float width, float height) { - BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ + BMessage msg(BAPP_MAXIMIZE); // Closest thing to maximization Haiku has _PostWindowEvent(msg); - /* Before the window zooms, record its size */ + // Before the window zooms, record its size if (!_prev_frame) _prev_frame = new BRect(Frame()); - /* Perform normal hook operations */ + // Perform normal hook operations BWindow::Zoom(origin, width, height); } - /* Member functions */ + // Member functions void Show() { while (IsHidden()) { @@ -320,12 +320,12 @@ class SDL_BWin : public BWindow } } - /* BView message interruption */ + // BView message interruption 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: @@ -368,14 +368,14 @@ class SDL_BWin : public BWindow } } 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); } @@ -387,18 +387,18 @@ class SDL_BWin : public BWindow - CTRL+Q to close window (and other shortcuts) - PrintScreen to make screenshot into /boot/home - etc.. */ - /* BWindow::DispatchMessage(msg, target); */ + // BWindow::DispatchMessage(msg, target); break; } BWindow::DispatchMessage(msg, target); } - /* Handle command messages */ + // Handle command messages void MessageReceived(BMessage *message) { switch (message->what) { - /* Handle commands from SDL */ + // Handle commands from SDL case BWIN_SET_TITLE: _SetTitle(message); break; @@ -467,13 +467,13 @@ class SDL_BWin : public BWindow break; } default: - /* Perform normal message handling */ + // Perform normal message handling BWindow::MessageReceived(message); break; } } - /* Accessor methods */ + // Accessor methods bool IsShown() { return _shown; } int32 GetID() { return _id; } BBitmap *GetBitmap() { return _bitmap; } @@ -487,7 +487,7 @@ class SDL_BWin : public BWindow Uint32 GetGLType() { return _gl_type; } #endif - /* Setter methods */ + // Setter methods void SetID(int32 id) { _id = id; } void LockBuffer() { _buffer_locker->Lock(); } void UnlockBuffer() { _buffer_locker->Unlock(); } @@ -499,16 +499,16 @@ class SDL_BWin : public BWindow } private: - /* Event redirection */ + // Event redirection void _MouseMotionEvent(BPoint &where, int32 transit) { if (transit == B_EXITED_VIEW) { - /* Change mouse focus */ + // Change mouse focus if (_mouse_focused) { _MouseFocusEvent(false); } } else { - /* Change mouse focus */ + // Change mouse focus if (!_mouse_focused) { _MouseFocusEvent(true); } @@ -559,7 +559,7 @@ class SDL_BWin : public BWindow void _MouseWheelEvent(int32 x, int32 y) { - /* Create a message to pass along to the BeApp thread */ + // Create a message to pass along to the BeApp thread BMessage msg(BAPP_MOUSE_WHEEL); msg.AddInt32("xticks", x); msg.AddInt32("yticks", y); @@ -568,7 +568,7 @@ class SDL_BWin : public BWindow void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState) { - /* Create a message to pass along to the BeApp thread */ + // Create a message to pass along to the BeApp thread BMessage msg(BAPP_KEY); msg.AddInt32("key-state", keyState); msg.AddInt32("key-scancode", keyCode); @@ -580,7 +580,7 @@ class SDL_BWin : public BWindow void _RepaintEvent() { - /* Force a repaint: Call the SDL exposed event */ + // Force a repaint: Call the SDL exposed event BMessage msg(BAPP_REPAINT); _PostWindowEvent(msg); } @@ -590,7 +590,7 @@ class SDL_BWin : public BWindow SDL_Looper->PostMessage(&msg); } - /* Command methods (functions called upon by SDL) */ + // Command methods (functions called upon by SDL) void _SetTitle(BMessage *msg) { const char *title; @@ -678,7 +678,7 @@ class SDL_BWin : public BWindow 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()); } @@ -711,7 +711,7 @@ class SDL_BWin : public BWindow } } - /* Members */ + // Members BView *_cur_view; SDL_BView *_SDL_View; @@ -721,19 +721,19 @@ class SDL_BWin : public BWindow #endif int32 _last_buttons; - int32 _id; /* Window id used by SDL_BApp */ - bool _mouse_focused; /* Does this window have mouse focus? */ + 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 */ + BRect *_prev_frame; // Previous position and size of the window bool _fullscreen; // valid only if fullscreen BRect _non_fullscreen_frame; bool _bordered; bool _resizable; - /* Framebuffer members */ + // Framebuffer members BLocker *_buffer_locker; BBitmap *_bitmap; }; @@ -752,4 +752,4 @@ class SDL_BWin : public BWindow * through a draw cycle. Occurs when the previous * buffer provided by DirectConnected() is invalidated. */ -#endif /* SDL_BWin_h_ */ +#endif // SDL_BWin_h_ diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index f33072f5f1..356f650855 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_HAIKU -/* BWindow based clipboard implementation */ +// BWindow based clipboard implementation #include #include @@ -39,7 +39,7 @@ int HAIKU_SetClipboardText(SDL_VideoDevice *_this, const char *text) { if (be_clipboard->Lock()) { be_clipboard->Clear(); if ((clip = be_clipboard->Data())) { - /* Presumably the string of characters is ascii-format */ + // Presumably the string of characters is ascii-format ssize_t asciiLength = 0; for (; text[asciiLength] != 0; ++asciiLength) {} clip->AddData("text/plain", B_MIME_TYPE, text, asciiLength); @@ -57,7 +57,7 @@ char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) { char *result; if (be_clipboard->Lock()) { if ((clip = be_clipboard->Data())) { - /* Presumably the string of characters is ascii-format */ + // Presumably the string of characters is ascii-format clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, &length); } @@ -67,7 +67,7 @@ char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) { if (!text) { result = SDL_strdup(""); } else { - /* Copy the data and pass on to SDL */ + // Copy the data and pass on to SDL result = (char *)SDL_malloc((length + 1) * sizeof(char)); SDL_strlcpy(result, text, length + 1); } @@ -89,4 +89,4 @@ SDL_bool HAIKU_HasClipboardText(SDL_VideoDevice *_this) { } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bevents.cc b/src/video/haiku/SDL_bevents.cc index c3af6c232d..e09ce0f32c 100644 --- a/src/video/haiku/SDL_bevents.cc +++ b/src/video/haiku/SDL_bevents.cc @@ -29,11 +29,11 @@ extern "C" { #endif void HAIKU_PumpEvents(SDL_VideoDevice *_this) { - /* Since the event thread is its own thread, this isn't really necessary */ + // Since the event thread is its own thread, this isn't really necessary } #ifdef __cplusplus } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bframebuffer.cc b/src/video/haiku/SDL_bframebuffer.cc index ffcb1a45e7..85a4383db2 100644 --- a/src/video/haiku/SDL_bframebuffer.cc +++ b/src/video/haiku/SDL_bframebuffer.cc @@ -52,25 +52,25 @@ int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, return -1; } - /* Make sure we have exclusive access to frame buffer data */ + // Make sure we have exclusive access to frame buffer data bwin->LockBuffer(); bwin->CreateView(); - /* format */ + // format display_mode bmode; bscreen.GetMode(&bmode); *format = HAIKU_ColorSpaceToSDLPxFormat(bmode.space); - /* Create the new bitmap object */ + // Create the new bitmap object BBitmap *bitmap = bwin->GetBitmap(); if (bitmap) { delete bitmap; } bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space, - false, /* Views not accepted */ - true); /* Contiguous memory required */ + false, // Views not accepted + true); // Contiguous memory required if (bitmap->InitCheck() != B_OK) { delete bitmap; @@ -80,10 +80,10 @@ int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, bwin->SetBitmap(bitmap); - /* Set the pixel pointer */ + // Set the pixel pointer *pixels = bitmap->Bits(); - /* pitch = width of window, in bytes */ + // pitch = width of window, in bytes *pitch = bitmap->BytesPerRow(); bwin->UnlockBuffer(); @@ -110,7 +110,7 @@ void HAIKU_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window) bwin->LockBuffer(); - /* Free and clear the window buffer */ + // Free and clear the window buffer BBitmap *bitmap = bwin->GetBitmap(); delete bitmap; bwin->SetBitmap(NULL); @@ -124,4 +124,4 @@ void HAIKU_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window) } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bkeyboard.cc b/src/video/haiku/SDL_bkeyboard.cc index 45b444dc4e..5a210371ea 100644 --- a/src/video/haiku/SDL_bkeyboard.cc +++ b/src/video/haiku/SDL_bkeyboard.cc @@ -148,7 +148,7 @@ void HAIKU_InitOSKeymap(void) keymap[0x66] = SDL_SCANCODE_LGUI; keymap[0x67] = SDL_SCANCODE_RGUI; keymap[0x68] = SDL_SCANCODE_MENU; - keymap[0x69] = SDL_SCANCODE_2; /* SDLK_EURO */ + keymap[0x69] = SDL_SCANCODE_2; // SDLK_EURO keymap[0x6a] = SDL_SCANCODE_KP_EQUALS; keymap[0x6b] = SDL_SCANCODE_POWER; } @@ -165,4 +165,4 @@ SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) { } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc index 8b929dc421..25f6f3de51 100644 --- a/src/video/haiku/SDL_bmessagebox.cc +++ b/src/video/haiku/SDL_bmessagebox.cc @@ -25,7 +25,7 @@ #ifdef SDL_VIDEO_DRIVER_HAIKU -/* For application signature. */ +// For application signature. #include "../../core/haiku/SDL_BeApp.h" #include @@ -380,4 +380,4 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bmessagebox.h b/src/video/haiku/SDL_bmessagebox.h index be2ccc19c2..07149c66f7 100644 --- a/src/video/haiku/SDL_bmessagebox.h +++ b/src/video/haiku/SDL_bmessagebox.h @@ -38,6 +38,6 @@ HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU #endif diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc index f8d07ccb39..39f0aa4b8b 100644 --- a/src/video/haiku/SDL_bmodes.cc +++ b/src/video/haiku/SDL_bmodes.cc @@ -38,7 +38,7 @@ extern "C" { #endif -#define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */ +#define WRAP_BMODE 1 // FIXME: Some debate as to whether this is necessary #if WRAP_BMODE /* This wrapper is here so that the internal can be freed without freeing @@ -64,7 +64,7 @@ static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) { #endif } -/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */ +// Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp static void get_refresh_rate(display_mode &mode, int *numerator, int *denominator) { *numerator = (mode.timing.pixel_clock * 1000); @@ -161,7 +161,7 @@ SDL_PixelFormat HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace) break; } - /* May never get here, but safer and needed to shut up compiler */ + // May never get here, but safer and needed to shut up compiler SDL_SetError("Invalid color space"); return SDL_PIXELFORMAT_UNKNOWN; } @@ -181,11 +181,11 @@ static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, SDL_DisplayMode * mode->internal = bmode; #endif - /* Set the format */ + // Set the format mode->format = HAIKU_ColorSpaceToSDLPxFormat(bmode->space); } -/* Later, there may be more than one monitor available */ +// Later, there may be more than one monitor available static void _AddDisplay(BScreen *screen) { SDL_DisplayMode mode; display_mode bmode; @@ -210,7 +210,7 @@ int HAIKU_InitModes(SDL_VideoDevice *_this) { } int HAIKU_QuitModes(SDL_VideoDevice *_this) { - /* FIXME: Nothing really needs to be done here at the moment? */ + // FIXME: Nothing really needs to be done here at the moment? return 0; } @@ -226,16 +226,16 @@ int HAIKU_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SD } int HAIKU_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) { - /* Get the current screen */ + // Get the current screen BScreen bscreen; - /* Iterate through all of the modes */ + // Iterate through all of the modes SDL_DisplayMode mode; display_mode this_bmode; display_mode *bmodes; uint32 count, i; - /* Get graphics-hardware supported modes */ + // Get graphics-hardware supported modes bscreen.GetModeList(&bmodes, &count); bscreen.GetMode(&this_bmode); @@ -246,23 +246,23 @@ int HAIKU_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) { SDL_AddFullscreenDisplayMode(display, &mode); } } - free(bmodes); /* This should not be SDL_free() */ + free(bmodes); // This should not be SDL_free() return 0; } int HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { - /* Get the current screen */ + // Get the current screen BScreen bscreen; if (!bscreen.IsValid()) { printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); } - /* Set the mode using the driver data */ + // Set the mode using the driver data display_mode *bmode = _ExtractBMode(mode); - /* FIXME: Is the first option always going to be the right one? */ + // FIXME: Is the first option always going to be the right one? uint32 c = 0, i; display_mode *bmode_list; bscreen.GetModeList(&bmode_list, &c); @@ -279,7 +279,7 @@ int HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_ return SDL_SetError("Bad video mode"); } - free(bmode_list); /* This should not be SDL_free() */ + free(bmode_list); // This should not be SDL_free() #ifdef SDL_VIDEO_OPENGL /* FIXME: Is there some way to reboot the OpenGL context? This doesn't @@ -294,4 +294,4 @@ int HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_ } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bopengl.cc b/src/video/haiku/SDL_bopengl.cc index 7c2d4b0578..55e303d457 100644 --- a/src/video/haiku/SDL_bopengl.cc +++ b/src/video/haiku/SDL_bopengl.cc @@ -43,10 +43,10 @@ static SDL_INLINE SDL_BLooper *_GetBeLooper() { return SDL_Looper; } -/* Passing a NULL path means load pointers from the application */ +// Passing a NULL path means load pointers from the application int HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) { -/* FIXME: Is this working correctly? */ +// FIXME: Is this working correctly? image_info info; int32 cookie = 0; while (get_next_image_info(0, &cookie, &info) == B_OK) { @@ -156,7 +156,7 @@ int HAIKU_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) { int HAIKU_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) { - /* TODO: Implement this, if necessary? */ + // TODO: Implement this, if necessary? return SDL_Unsupported(); } @@ -166,7 +166,7 @@ int HAIKU_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) { void HAIKU_GL_UnloadLibrary(SDL_VideoDevice *_this) { - /* TODO: Implement this, if necessary? */ + // TODO: Implement this, if necessary? } @@ -192,4 +192,4 @@ void HAIKU_GL_RebootContexts(SDL_VideoDevice *_this) { } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL diff --git a/src/video/haiku/SDL_bopengl.h b/src/video/haiku/SDL_bopengl.h index c17cb51342..f8cc10228e 100644 --- a/src/video/haiku/SDL_bopengl.h +++ b/src/video/haiku/SDL_bopengl.h @@ -30,13 +30,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); /* FIXME */ -extern SDL_FunctionPointer HAIKU_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); /* FIXME */ -extern void HAIKU_GL_UnloadLibrary(SDL_VideoDevice *_this); /* TODO */ +extern int HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); // FIXME +extern SDL_FunctionPointer HAIKU_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); // FIXME +extern void HAIKU_GL_UnloadLibrary(SDL_VideoDevice *_this); // TODO extern int HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); -extern int HAIKU_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); /* TODO */ -extern int HAIKU_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); /* TODO */ +extern int HAIKU_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); // TODO +extern int HAIKU_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); // TODO extern int HAIKU_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_GLContext HAIKU_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern int HAIKU_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); @@ -47,6 +47,6 @@ extern void HAIKU_GL_RebootContexts(SDL_VideoDevice *_this); } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL */ +#endif // SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL #endif diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 8b61285f91..8cb772c50a 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -51,15 +51,15 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void) { SDL_VideoDevice *device; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device->internal = NULL; /* FIXME: Is this the cause of some of the SDL_Quit() errors? */ -/* TODO: Figure out if any initialization needs to go here */ +// TODO: Figure out if any initialization needs to go here - /* Set the function pointers */ + // Set the function pointers device->VideoInit = HAIKU_VideoInit; device->VideoQuit = HAIKU_VideoQuit; device->GetDisplayBounds = HAIKU_GetDisplayBounds; @@ -265,30 +265,30 @@ static void HAIKU_MouseInit(SDL_VideoDevice *_this) int HAIKU_VideoInit(SDL_VideoDevice *_this) { - /* Initialize the Be Application for appserver interaction */ + // Initialize the Be Application for appserver interaction if (SDL_InitBeApp() < 0) { return -1; } - /* Initialize video modes */ + // Initialize video modes HAIKU_InitModes(_this); - /* Init the keymap */ + // Init the keymap HAIKU_InitOSKeymap(); HAIKU_MouseInit(_this); - /* Assume we have a mouse and keyboard */ + // Assume we have a mouse and keyboard SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); #ifdef SDL_VIDEO_OPENGL - /* testgl application doesn't load library, just tries to load symbols */ - /* is it correct? if so we have to load library here */ + // testgl application doesn't load library, just tries to load symbols + // is it correct? if so we have to load library here HAIKU_GL_LoadLibrary(_this, NULL); #endif - /* We're done! */ + // We're done! return 0; } @@ -313,4 +313,4 @@ int HAIKU_OpenURL(const char *url) } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index 121b9ed8d0..2f5e0bb8f5 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -26,7 +26,7 @@ #include "SDL_BWin.h" #include -/* Define a path to window's BWIN data */ +// Define a path to window's BWIN data #ifdef __cplusplus extern "C" { #endif @@ -51,11 +51,11 @@ static int _InitWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie ); if (window->flags & SDL_WINDOW_FULLSCREEN) { - /* TODO: Add support for this flag */ + // TODO: Add support for this flag printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__); } if (window->flags & SDL_WINDOW_OPENGL) { - /* TODO: Add support for this flag */ + // TODO: Add support for this flag } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE; @@ -81,7 +81,7 @@ int HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie return -1; } - /* Start window loop */ + // Start window loop _ToBeWin(window)->Show(); return 0; } @@ -130,7 +130,7 @@ void HAIKU_HideWindow(SDL_VideoDevice *_this, SDL_Window * window) { } void HAIKU_RaiseWindow(SDL_VideoDevice *_this, SDL_Window * window) { - BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */ + BMessage msg(BWIN_SHOW_WINDOW); // Activate this window and move to front _ToBeWin(window)->PostMessage(&msg); } @@ -151,7 +151,7 @@ void HAIKU_RestoreWindow(SDL_VideoDevice *_this, SDL_Window * window) { int HAIKU_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window * window, SDL_VideoDisplay * display, SDL_FullscreenOp fullscreen) { - /* Haiku tracks all video display information */ + // Haiku tracks all video display information BMessage msg(BWIN_FULLSCREEN); msg.AddBool("fullscreen", !!fullscreen); _ToBeWin(window)->PostMessage(&msg); @@ -167,13 +167,13 @@ void HAIKU_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window * window) { } int HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window * window, SDL_bool grabbed) { - /* TODO: Implement this! */ + // TODO: Implement this! return SDL_Unsupported(); } int HAIKU_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window) { if (modal_window->parent && modal_window->parent != parent_window) { - /* Remove from the subset of a previous parent. */ + // Remove from the subset of a previous parent. _ToBeWin(modal_window)->RemoveFromSubset(_ToBeWin(modal_window->parent)); } @@ -191,7 +191,7 @@ int HAIKU_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SD } void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window * window) { - _ToBeWin(window)->LockLooper(); /* This MUST be locked */ + _ToBeWin(window)->LockLooper(); // This MUST be locked _GetBeLooper()->ClearID(_ToBeWin(window)); _ToBeWin(window)->Quit(); window->internal = NULL; @@ -201,4 +201,4 @@ void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window * window) { } #endif -#endif /* SDL_VIDEO_DRIVER_HAIKU */ +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.c b/src/video/kmsdrm/SDL_kmsdrmdyn.c index d50b5e413f..2be54e027e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -65,15 +65,15 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule) #endif if (!fn) { - *pHasModule = 0; /* kill this module. */ + *pHasModule = 0; // kill this module. } return fn; } -#endif /* SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */ +#endif // SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC -/* Define all the function pointers and wrappers... */ +// 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; @@ -83,14 +83,14 @@ static int kmsdrm_load_refcount = 0; void SDL_KMSDRM_UnloadSymbols(void) { - /* Don't actually unload if more than one module is using the libs... */ + // Don't actually unload if more than one module is using the libs... if (kmsdrm_load_refcount > 0) { if (--kmsdrm_load_refcount == 0) { #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC int i; #endif - /* set all the function pointers to NULL. */ + // 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; @@ -108,12 +108,12 @@ void SDL_KMSDRM_UnloadSymbols(void) } } -/* returns non-zero if all needed symbols were loaded. */ +// returns non-zero if all needed symbols were loaded. 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... */ + // deal with multiple modules needing these symbols... if (kmsdrm_load_refcount++ == 0) { #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC int i; @@ -124,7 +124,7 @@ int SDL_KMSDRM_LoadSymbols(void) } } -#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */ +#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; @@ -133,17 +133,17 @@ int SDL_KMSDRM_LoadSymbols(void) #include "SDL_kmsdrmsym.h" if ((SDL_KMSDRM_HAVE_LIBDRM) && (SDL_KMSDRM_HAVE_GBM)) { - /* all required symbols loaded. */ + // all required symbols loaded. SDL_ClearError(); } else { - /* in case something got loaded... */ + // in case something got loaded... SDL_KMSDRM_UnloadSymbols(); 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_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" @@ -154,4 +154,4 @@ int SDL_KMSDRM_LoadSymbols(void) return rc; } -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.h b/src/video/kmsdrm/SDL_kmsdrmdyn.h index f9a292ec49..4a52f6381a 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.h +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.h @@ -35,7 +35,7 @@ extern "C" { int SDL_KMSDRM_LoadSymbols(void); void SDL_KMSDRM_UnloadSymbols(void); -/* Declare all the function pointers and wrappers... */ +// Declare all the function pointers and wrappers... #define SDL_KMSDRM_SYM(rc, fn, params) \ typedef rc(*SDL_DYNKMSDRMFN_##fn) params; \ extern SDL_DYNKMSDRMFN_##fn KMSDRM_##fn; @@ -48,4 +48,4 @@ void SDL_KMSDRM_UnloadSymbols(void); } #endif -#endif /* SDL_kmsdrmdyn_h_ */ +#endif // SDL_kmsdrmdyn_h_ diff --git a/src/video/kmsdrm/SDL_kmsdrmevents.c b/src/video/kmsdrm/SDL_kmsdrmevents.c index 1523520404..9bdd5d28ed 100644 --- a/src/video/kmsdrm/SDL_kmsdrmevents.c +++ b/src/video/kmsdrm/SDL_kmsdrmevents.c @@ -41,4 +41,4 @@ void KMSDRM_PumpEvents(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/src/video/kmsdrm/SDL_kmsdrmevents.h b/src/video/kmsdrm/SDL_kmsdrmevents.h index a67c5b3d3a..6b08dadaa9 100644 --- a/src/video/kmsdrm/SDL_kmsdrmevents.h +++ b/src/video/kmsdrm/SDL_kmsdrmevents.h @@ -26,4 +26,4 @@ extern void KMSDRM_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_kmsdrmevents_h_ */ +#endif // SDL_kmsdrmevents_h_ diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 503ac142dd..f186ec7a7e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -39,18 +39,18 @@ static int KMSDRM_MoveCursor(SDL_Cursor *cursor); static void KMSDRM_FreeCursor(SDL_Cursor *cursor); /**************************************************************************************/ -/* BEFORE CODING ANYTHING MOUSE/CURSOR RELATED, REMEMBER THIS. */ -/* How does SDL manage cursors internally? First, mouse =! cursor. The mouse can have */ -/* many cursors in mouse->cursors. */ -/* -SDL tells us to create a cursor with KMSDRM_CreateCursor(). It can create many */ -/* cursosr with this, not only one. */ -/* -SDL stores those cursors in a cursors array, in mouse->cursors. */ -/* -Whenever it wants (or the programmer wants) takes a cursor from that array */ -/* and shows it on screen with KMSDRM_ShowCursor(). */ -/* KMSDRM_ShowCursor() simply shows or hides the cursor it receives: it does NOT */ -/* mind if it's mouse->cur_cursor, etc. */ -/* -If KMSDRM_ShowCursor() returns successfully, that cursor becomes */ -/* mouse->cur_cursor and mouse->cursor_shown is 1. */ +// BEFORE CODING ANYTHING MOUSE/CURSOR RELATED, REMEMBER THIS. +// How does SDL manage cursors internally? First, mouse =! cursor. The mouse can have +// many cursors in mouse->cursors. +// -SDL tells us to create a cursor with KMSDRM_CreateCursor(). It can create many +// cursosr with this, not only one. +// -SDL stores those cursors in a cursors array, in mouse->cursors. +// -Whenever it wants (or the programmer wants) takes a cursor from that array +// and shows it on screen with KMSDRM_ShowCursor(). +// KMSDRM_ShowCursor() simply shows or hides the cursor it receives: it does NOT +// mind if it's mouse->cur_cursor, etc. +// -If KMSDRM_ShowCursor() returns successfully, that cursor becomes +// mouse->cur_cursor and mouse->cursor_shown is 1. /**************************************************************************************/ static SDL_Cursor *KMSDRM_CreateDefaultCursor(void) @@ -65,7 +65,7 @@ void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display) { SDL_DisplayData *dispdata = display->internal; - /* Destroy the curso GBM BO. */ + // Destroy the curso GBM BO. if (dispdata->cursor_bo) { KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); dispdata->cursor_bo = NULL; @@ -112,7 +112,7 @@ int KMSDRM_CreateCursorBO(SDL_VideoDisplay *display) return 0; } -/* Remove a cursor buffer from a display's DRM cursor BO. */ +// Remove a cursor buffer from a display's DRM cursor BO. static int KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) { int ret = 0; @@ -130,7 +130,7 @@ static int KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) return ret; } -/* Dump a cursor buffer to a display's DRM cursor BO. */ +// Dump a cursor buffer to a display's DRM cursor BO. static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) { SDL_DisplayData *dispdata = display->internal; @@ -163,19 +163,19 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) goto cleanup; } - /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO. */ + // 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]; SDL_memcpy(ready_buffer + (i * bo_stride), src_row, (size_t)4 * curdata->w); } - /* Dump the cursor buffer to our GBM BO. */ + // Dump the cursor buffer to our GBM BO. if (KMSDRM_gbm_bo_write(dispdata->cursor_bo, ready_buffer, bufsize)) { ret = SDL_SetError("Could not write to GBM cursor BO"); goto cleanup; } - /* Put the GBM BO buffer on screen using the DRM interface. */ + // Put the GBM BO buffer on screen using the DRM interface. 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, @@ -203,20 +203,20 @@ cleanup: return ret; } -/* This is only for freeing the SDL_cursor.*/ +// This is only for freeing the SDL_cursor. static void KMSDRM_FreeCursor(SDL_Cursor *cursor) { SDL_CursorData *curdata; - /* Even if the cursor is not ours, free it. */ + // Even if the cursor is not ours, free it. if (cursor) { curdata = cursor->internal; - /* Free cursor buffer */ + // Free cursor buffer if (curdata->buffer) { SDL_free(curdata->buffer); curdata->buffer = NULL; } - /* Free cursor itself */ + // Free cursor itself if (cursor->internal) { SDL_free(cursor->internal); } @@ -244,7 +244,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ goto cleanup; } - /* hox_x and hot_y are the coordinates of the "tip of the cursor" from it's base. */ + // hox_x and hot_y are the coordinates of the "tip of the cursor" from it's base. curdata->hot_x = hot_x; curdata->hot_y = hot_y; curdata->w = surface->w; @@ -289,7 +289,7 @@ cleanup: return ret; } -/* Show the specified cursor, or hide if cursor is NULL or has no focus. */ +// Show the specified cursor, or hide if cursor is NULL or has no focus. static int KMSDRM_ShowCursor(SDL_Cursor *cursor) { SDL_VideoDisplay *display; @@ -299,7 +299,7 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) int i; int ret = 0; - /* Get the mouse focused window, if any. */ + // Get the mouse focused window, if any. mouse = SDL_GetMouse(); if (!mouse) { @@ -317,7 +317,7 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) restore the system default cursor (makes no sense here). */ SDL_DisplayID *displays = SDL_GetDisplays(NULL); if (displays) { - /* Iterate on the displays, hiding the cursor. */ + // Iterate on the displays, hiding the cursor. for (i = 0; i < displays[i]; i++) { display = SDL_GetVideoDisplay(displays[i]); ret = KMSDRM_RemoveCursorFromBO(display); @@ -332,7 +332,7 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) on that display. */ ret = KMSDRM_DumpCursorToBO(display, cursor); } else { - /* Hide the cursor on that display. */ + // Hide the cursor on that display. ret = KMSDRM_RemoveCursorFromBO(display); } } @@ -350,10 +350,10 @@ static int KMSDRM_WarpMouseGlobal(float x, float y) SDL_Window *window = mouse->focus; SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); - /* Update internal mouse position. */ + // Update internal mouse position. SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); - /* And now update the cursor graphic position on screen. */ + // And now update the cursor graphic position on screen. if (dispdata->cursor_bo) { int ret = 0; @@ -376,7 +376,7 @@ static int KMSDRM_WarpMouseGlobal(float x, float y) static int KMSDRM_WarpMouse(SDL_Window *window, float x, float y) { - /* Only one global/fullscreen window is supported */ + // Only one global/fullscreen window is supported return KMSDRM_WarpMouseGlobal(x, y); } @@ -402,10 +402,10 @@ void KMSDRM_InitMouse(SDL_VideoDevice *_this, SDL_VideoDisplay *display) void KMSDRM_QuitMouse(SDL_VideoDevice *_this) { - /* TODO: ? */ + // TODO: ? } -/* This is called when a mouse motion event occurs */ +// This is called when a mouse motion event occurs static int KMSDRM_MoveCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -431,4 +431,4 @@ static int KMSDRM_MoveCursor(SDL_Cursor *cursor) return 0; } -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.h b/src/video/kmsdrm/SDL_kmsdrmmouse.h index 95196e273e..925fea20a5 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.h +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.h @@ -50,4 +50,4 @@ extern int KMSDRM_CreateCursorBO(SDL_VideoDisplay *display); extern void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display); extern void KMSDRM_InitCursor(void); -#endif /* SDL_KMSDRM_mouse_h_ */ +#endif // SDL_KMSDRM_mouse_h_ diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 059bd204e8..73ef66e9b4 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -32,7 +32,7 @@ #define EGL_PLATFORM_GBM_MESA 0x31D7 #endif -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) { @@ -96,14 +96,14 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) even if you do async flips. */ uint32_t flip_flags = DRM_MODE_PAGE_FLIP_EVENT; - /* Skip the swap if we've switched away to another VT */ + // Skip the swap if we've switched away to another VT if (windata->egl_surface == EGL_NO_SURFACE) { - /* Wait a bit, throttling to ~100 FPS */ + // Wait a bit, throttling to ~100 FPS SDL_Delay(10); return 0; } - /* Recreate the GBM / EGL surfaces if the display mode has changed */ + // Recreate the GBM / EGL surfaces if the display mode has changed if (windata->egl_surface_dirty) { KMSDRM_CreateSurfaces(_this, window); } @@ -115,7 +115,7 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) return 0; } - /* Release the previous front buffer */ + // Release the previous front buffer if (windata->bo) { KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); windata->bo = NULL; @@ -140,7 +140,7 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) return 0; } - /* Get an actual usable fb for the next front buffer. */ + // Get an actual usable fb for the next front buffer. fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); if (!fb_info) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); @@ -207,4 +207,4 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_EGL_MakeCurrent_impl(KMSDRM) -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.h b/src/video/kmsdrm/SDL_kmsdrmopengles.h index ff1989e982..6ef8b9c154 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.h +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define KMSDRM_GLES_GetAttribute SDL_EGL_GetAttribute #define KMSDRM_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define KMSDRM_GLES_DeleteContext SDL_EGL_DeleteContext @@ -41,6 +41,6 @@ extern SDL_GLContext KMSDRM_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Windo extern int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int KMSDRM_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM -#endif /* SDL_kmsdrmopengles_h_ */ +#endif // SDL_kmsdrmopengles_h_ diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h index a9556edaae..e612583ce5 100644 --- a/src/video/kmsdrm/SDL_kmsdrmsym.h +++ b/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #ifndef SDL_KMSDRM_MODULE #define SDL_KMSDRM_MODULE(modname) @@ -77,7 +77,7 @@ SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx)) SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t flags, void *user_data)) -/* Planes stuff. */ +// Planes stuff. SDL_KMSDRM_SYM(int,drmSetClientCap,(int fd, uint64_t capability, uint64_t value)) SDL_KMSDRM_SYM(drmModePlaneResPtr,drmModeGetPlaneResources,(int fd)) SDL_KMSDRM_SYM(drmModePlanePtr,drmModeGetPlane,(int fd, uint32_t plane_id)) @@ -97,7 +97,7 @@ SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, uint32_t crtc_w, uint32_t crtc_h, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h)) -/* Planes stuff ends. */ +// Planes stuff ends. SDL_KMSDRM_MODULE(GBM) SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm, @@ -135,4 +135,4 @@ SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *b #undef SDL_KMSDRM_SYM #undef SDL_KMSDRM_SYM_CONST -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 66d280fd2f..b9558641a2 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -27,7 +27,7 @@ * redefinition errors. it already includes SDL_sysvideo.h. */ #include "SDL_kmsdrmvulkan.h" -/* SDL internals */ +// SDL internals #include "../../events/SDL_events_c.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" @@ -38,7 +38,7 @@ #include "../../core/openbsd/SDL_wscons.h" #endif -/* KMS/DRM declarations */ +// KMS/DRM declarations #include "SDL_kmsdrmdyn.h" #include "SDL_kmsdrmevents.h" #include "SDL_kmsdrmmouse.h" @@ -83,7 +83,7 @@ static int get_driindex(void) 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. */ + return idx; // we'll take the user's request here. } } @@ -272,7 +272,7 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) device->internal = viddata; - /* Setup all functions which we can handle */ + // Setup all functions which we can handle device->VideoInit = KMSDRM_VideoInit; device->VideoQuit = KMSDRM_VideoQuit; device->GetDisplayModes = KMSDRM_GetDisplayModes; @@ -329,7 +329,7 @@ VideoBootStrap KMSDRM_bootstrap = { "kmsdrm", "KMS/DRM Video Driver", KMSDRM_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) @@ -352,7 +352,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo) Uint32 format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0; uint64_t modifiers[4] = { 0 }; - /* Check for an existing framebuffer */ + // Check for an existing framebuffer KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); if (fb_info) { @@ -404,7 +404,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, from BO %p", fb_info->fb_id, w, h, (void *)bo); - /* Associate our DRM framebuffer with this buffer object */ + // Associate our DRM framebuffer with this buffer object KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); return fb_info; @@ -462,16 +462,16 @@ SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) any requested event, so we immediately poll again. */ continue; } else { - /* There was another error. Don't pull again or we could get into a busy loop. */ + // There was another error. Don't pull again or we could get into a busy loop. SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error"); - return SDL_FALSE; /* Return number 1. */ + return SDL_FALSE; // Return number 1. } } if (pfd.revents & (POLLHUP | POLLERR)) { - /* An event arrived on the FD in time, but it's an error. */ + // An event arrived on the FD in time, but it's an error. SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error"); - return SDL_FALSE; /* Return number 2. */ + return SDL_FALSE; // Return number 2. } if (pfd.revents & POLLIN) { @@ -521,11 +521,11 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display, } /*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ +// SDL Video and Display initialization/handling functions /* _this is a SDL_VideoDevice * */ /*****************************************************************************/ -/* Deinitializes the internal of the SDL Displays in the SDL display list. */ +// Deinitializes the internal of the SDL Displays in the SDL display list. static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this) { SDL_DisplayID *displays; @@ -534,19 +534,19 @@ static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this) displays = SDL_GetDisplays(NULL); if (displays) { - /* Iterate on the SDL Display list. */ + // Iterate on the SDL Display list. for (i = 0; displays[i]; ++i) { - /* Get the internal for this display */ + // Get the internal for this display dispdata = SDL_GetDisplayDriverData(displays[i]); - /* Free connector */ + // Free connector if (dispdata && dispdata->connector) { KMSDRM_drmModeFreeConnector(dispdata->connector); dispdata->connector = NULL; } - /* Free CRTC */ + // Free CRTC if (dispdata && dispdata->crtc) { KMSDRM_drmModeFreeCrtc(dispdata->crtc); dispdata->crtc = NULL; @@ -740,7 +740,7 @@ static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id) if (drm_prop->prop_id == orientation_prop_id && (drm_prop->flags & DRM_MODE_PROP_ENUM)) { if (drm_prop->count_enums) { - /* "Normal" is the default of no rotation (0 degrees) */ + // "Normal" is the default of no rotation (0 degrees) if (SDL_strcmp(drm_prop->enums[0].name, "Left Side Up") == 0) { orientation = 90; } else if (SDL_strcmp(drm_prop->enums[0].name, "Upside Down") == 0) { @@ -778,7 +778,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto int i, j; int ret = 0; - /* Reserve memory for the new display's internal. */ + // Reserve memory for the new display's internal. dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); if (!dispdata) { ret = -1; @@ -797,7 +797,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto would have to hide and delete them at quit, not to mention the memory leak... */ dispdata->default_cursor_init = SDL_FALSE; - /* Try to find the connector's current encoder */ + // Try to find the connector's current encoder for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); @@ -814,7 +814,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto } if (!encoder) { - /* No encoder was connected, find the first supported one */ + // 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]); @@ -843,7 +843,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto goto cleanup; } - /* Try to find a CRTC connected to this encoder */ + // Try to find a CRTC connected to this encoder crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id); /* If no CRTC was connected to the encoder, find the first CRTC @@ -863,7 +863,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto goto cleanup; } - /* Find the index of the mode attached to this CRTC */ + // Find the index of the mode attached to this CRTC mode_index = -1; for (i = 0; i < connector->count_modes; i++) { @@ -878,7 +878,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto if (mode_index == -1) { int current_area, largest_area = 0; - /* Find the preferred mode or the highest resolution mode */ + // Find the preferred mode or the highest resolution mode for (i = 0; i < connector->count_modes; i++) { drmModeModeInfo *mode = &connector->modes[i]; @@ -904,11 +904,11 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto } /*********************************************/ - /* Create an SDL Display for this connector. */ + // Create an SDL Display for this connector. /*********************************************/ /*********************************************/ - /* Part 1: setup the SDL_Display internal. */ + // Part 1: setup the SDL_Display internal. /*********************************************/ /* Get the mode currently setup for this display, @@ -923,20 +923,20 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto goto cleanup; } - /* Store the connector and crtc for this display. */ + // Store the connector and crtc for this display. dispdata->connector = connector; dispdata->crtc = crtc; - /* save previous vrr state */ + // save previous vrr state dispdata->saved_vrr = KMSDRM_CrtcGetVrr(viddata->drm_fd, crtc->crtc_id); - /* try to enable vrr */ + // try to enable vrr if (KMSDRM_ConnectorCheckVrrCapable(viddata->drm_fd, connector->connector_id, "VRR_CAPABLE")) { SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Enabling VRR"); KMSDRM_CrtcSetVrr(viddata->drm_fd, crtc->crtc_id, SDL_TRUE); } /*****************************************/ - /* Part 2: setup the SDL_Display itself. */ + // Part 2: setup the SDL_Display itself. /*****************************************/ /* Setup the display. @@ -957,7 +957,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; display.desktop_mode.internal = modedata; - /* Add the display to the list of SDL displays. */ + // Add the display to the list of SDL displays. display_id = SDL_AddVideoDisplay(&display, SDL_FALSE); if (!display_id) { ret = -1; @@ -973,7 +973,7 @@ cleanup: KMSDRM_drmModeFreeEncoder(encoder); } if (ret) { - /* Error (complete) cleanup */ + // Error (complete) cleanup if (dispdata) { if (dispdata->connector) { KMSDRM_drmModeFreeConnector(dispdata->connector); @@ -986,7 +986,7 @@ cleanup: SDL_free(dispdata); } } -} /* NOLINT(clang-analyzer-unix.Malloc): If no error `dispdata` is saved in the display */ +} // NOLINT(clang-analyzer-unix.Malloc): If no error `dispdata` is saved in the display /* Initializes the list of SDL displays: we build a new display for each connecter connector we find. @@ -1004,7 +1004,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) int ret = 0; int i; - /* Open /dev/dri/cardNN (/dev/drmN if on OpenBSD version less than 6.9) */ + // Open /dev/dri/cardNN (/dev/drmN if on OpenBSD version less than 6.9) (void)SDL_snprintf(viddata->devpath, sizeof(viddata->devpath), "%s%d", kmsdrm_dri_cardpath, viddata->devindex); @@ -1018,7 +1018,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd); - /* Get all of the available connectors / devices / crtcs */ + // Get all of the available connectors / devices / crtcs resources = KMSDRM_drmModeGetResources(viddata->drm_fd); if (!resources) { ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); @@ -1042,18 +1042,18 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) connector etc...) we can keep looking for connected connectors. */ KMSDRM_AddDisplay(_this, connector, resources); } else { - /* If it's not, free it now. */ + // If it's not, free it now. KMSDRM_drmModeFreeConnector(connector); } } - /* Have we added any SDL displays? */ + // Have we added any SDL displays? if (SDL_GetPrimaryDisplay() == 0) { ret = SDL_SetError("No connected displays found."); goto cleanup; } - /* Determine if video hardware supports async pageflips. */ + // Determine if video hardware supports async pageflips. ret = KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_ASYNC_PAGE_FLIP, &async_pageflip); if (ret) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not determine async page flip capability."); @@ -1061,7 +1061,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) viddata->async_pageflip_support = async_pageflip ? SDL_TRUE : SDL_FALSE; /***********************************/ - /* Block for Vulkan compatibility. */ + // Block for Vulkan compatibility. /***********************************/ /* THIS IS FOR VULKAN! Leave the FD closed, so VK can work. @@ -1095,13 +1095,13 @@ static int KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) SDL_VideoData *viddata = _this->internal; int ret = 0; - /* Reopen the FD! */ + // Reopen the FD! viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); - /* Set the FD we just opened as current DRM master. */ + // Set the FD we just opened as current DRM master. KMSDRM_drmSetMaster(viddata->drm_fd); - /* Create the GBM device. */ + // Create the GBM device. viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd); if (!viddata->gbm_dev) { ret = SDL_SetError("Couldn't create gbm device."); @@ -1112,7 +1112,7 @@ static int KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) return ret; } -/* Deinit the Vulkan-incompatible KMSDRM stuff. */ +// Deinit the Vulkan-incompatible KMSDRM stuff. static void KMSDRM_GBMDeinit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) { SDL_VideoData *viddata = _this->internal; @@ -1124,7 +1124,7 @@ static void KMSDRM_GBMDeinit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) viddata->gbm_dev = NULL; } - /* Finally close DRM FD. May be reopen on next non-vulkan window creation. */ + // Finally close DRM FD. May be reopen on next non-vulkan window creation. if (viddata->drm_fd >= 0) { close(viddata->drm_fd); viddata->drm_fd = -1; @@ -1141,20 +1141,20 @@ static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) int ret; /**********************************************/ - /* Wait for last issued pageflip to complete. */ + // Wait for last issued pageflip to complete. /**********************************************/ - /*KMSDRM_WaitPageflip(_this, windata);*/ + // KMSDRM_WaitPageflip(_this, windata); /************************************************************************/ - /* Restore the original CRTC configuration: configure the crtc with the */ - /* original video mode and make it point to the original TTY buffer. */ + // Restore the original CRTC configuration: configure the crtc with the + // original video mode and make it point to the original TTY buffer. /************************************************************************/ ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, 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 preferred mode. */ + // If we failed to set the original mode, try to set the connector preferred 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, @@ -1166,7 +1166,7 @@ static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) } /***************************/ - /* Destroy the EGL surface */ + // Destroy the EGL surface /***************************/ SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -1177,7 +1177,7 @@ static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) } /***************************/ - /* Destroy the GBM buffers */ + // Destroy the GBM buffers /***************************/ if (windata->bo) { @@ -1191,7 +1191,7 @@ static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) } /***************************/ - /* Destroy the GBM surface */ + // Destroy the GBM surface /***************************/ if (windata->gs) { @@ -1249,7 +1249,7 @@ int KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window) int ret = 0; - /* If the current window already has surfaces, destroy them before creating other. */ + // If the current window already has surfaces, destroy them before creating other. if (windata->gs) { KMSDRM_DestroySurfaces(_this, window); } @@ -1300,7 +1300,7 @@ int KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window) cleanup: if (ret) { - /* Error (complete) cleanup. */ + // Error (complete) cleanup. if (windata->gs) { KMSDRM_gbm_surface_destroy(windata->gs); windata->gs = NULL; @@ -1340,7 +1340,7 @@ static void KMSDRM_AcquireVT(void *userdata) } } } -#endif /* defined SDL_INPUT_LINUXEV */ +#endif // defined SDL_INPUT_LINUXEV int KMSDRM_VideoInit(SDL_VideoDevice *_this) { @@ -1387,7 +1387,7 @@ void KMSDRM_VideoQuit(SDL_VideoDevice *_this) SDL_WSCONS_Quit(); #endif - /* Clear out the window list */ + // Clear out the window list SDL_free(viddata->windows); viddata->windows = NULL; viddata->max_windows = 0; @@ -1395,7 +1395,7 @@ void KMSDRM_VideoQuit(SDL_VideoDevice *_this) viddata->video_init = SDL_FALSE; } -/* Read modes from the connector modes, and store them in display->display_modes. */ +// Read modes from the connector modes, and store them in display->display_modes. int KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) { SDL_DisplayData *dispdata = display->internal; @@ -1435,7 +1435,7 @@ int KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL drmModeConnector *conn = dispdata->connector; int i; - /* Don't do anything if we are in Vulkan mode. */ + // Don't do anything if we are in Vulkan mode. if (viddata->vulkan_mode) { return 0; } @@ -1460,24 +1460,24 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *windata = window->internal; SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); SDL_VideoData *viddata; - SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ + SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? unsigned int i, j; if (!windata) { return; } - /* restore vrr state */ + // restore vrr state KMSDRM_CrtcSetVrr(windata->viddata->drm_fd, dispdata->crtc->crtc_id, dispdata->saved_vrr); viddata = windata->viddata; if (!is_vulkan && viddata->gbm_init) { - /* Destroy cursor GBM BO of the display of this window. */ + // Destroy cursor GBM BO of the display of this window. KMSDRM_DestroyCursorBO(_this, SDL_GetVideoDisplayForWindow(window)); - /* Destroy GBM surface and buffers. */ + // Destroy GBM surface and buffers. KMSDRM_DestroySurfaces(_this, window); /* Unload library and deinit GBM, but only if this is the last window. @@ -1487,26 +1487,26 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) added to the windows list. */ if (viddata->num_windows <= 1) { - /* Unload EGL/GL library and free egl_data. */ + // 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. */ + // Free display plane, and destroy GBM device. KMSDRM_GBMDeinit(_this, dispdata); } } else { - /* If we were in Vulkan mode, get out of it. */ + // If we were in Vulkan mode, get out of it. if (viddata->vulkan_mode) { viddata->vulkan_mode = SDL_FALSE; } } /********************************************/ - /* Remove from the internal SDL window list */ + // Remove from the internal SDL window list /********************************************/ for (i = 0; i < viddata->num_windows; i++) { @@ -1522,16 +1522,16 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } /*********************************************************************/ - /* Free the window internal. Bye bye, surface and buffer pointers! */ + // Free the window internal. Bye bye, surface and buffer pointers! /*********************************************************************/ SDL_free(window->internal); window->internal = NULL; } /**********************************************************************/ -/* 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. */ +// 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(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) { @@ -1539,19 +1539,19 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_VideoData *viddata = _this->internal; SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_DisplayData *dispdata = display->internal; - 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 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? NativeDisplayType egl_display; drmModeModeInfo *mode; int ret = 0; - /* Allocate window internal data */ + // Allocate window internal data windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!windata) { return -1; } - /* Setup driver data for this window */ + // Setup driver data for this window windata->viddata = viddata; window->internal = windata; @@ -1560,13 +1560,13 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_SetNumberProperty(props, SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER, viddata->drm_fd); SDL_SetPointerProperty(props, SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER, viddata->gbm_dev); - /* Do we want a double buffering scheme to get low video lag? */ + // Do we want a double buffering scheme to get low video lag? windata->double_buffer = SDL_FALSE; if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { windata->double_buffer = SDL_TRUE; } - if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */ + if (!is_vulkan && !vulkan_mode) { // NON-Vulkan block. /* Maybe you didn't ask for an OPENGL window, but that's what you will get. See following comments on why. */ @@ -1604,7 +1604,7 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti if (!_this->egl_data) { egl_display = (NativeDisplayType)_this->internal->gbm_dev; if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA) < 0) { - /* Try again with OpenGL ES 2.0 */ + // Try again with OpenGL ES 2.0 _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; @@ -1643,7 +1643,7 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti if (ret != 0) { return SDL_SetError("Can't window GBM/EGL surfaces on window creation."); } - } /* NON-Vulkan block ends. */ + } // NON-Vulkan block ends. /* Add window to the internal list of tracked windows. Note, while it may seem odd to support multiple fullscreen windows, some apps create an @@ -1662,7 +1662,7 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti viddata->windows[viddata->num_windows++] = window; - /* If we have just created a Vulkan window, establish that we are in Vulkan mode now. */ + // If we have just created a Vulkan window, establish that we are in Vulkan mode now. viddata->vulkan_mode = is_vulkan; /* Focus on the newly created window. @@ -1670,7 +1670,7 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); - /* Tell the app that the window has moved to top-left. */ + // Tell the app that the window has moved to top-left. SDL_Rect display_bounds; SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &display_bounds); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, display_bounds.x, display_bounds.y); @@ -1722,4 +1722,4 @@ void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) { } -#endif /* SDL_VIDEO_DRIVER_KMSDRM */ +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index e594df7538..75fd0b8b16 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -74,15 +74,15 @@ 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 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_Window **windows; int max_windows; @@ -107,7 +107,7 @@ 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 internal struct, @@ -141,21 +141,21 @@ 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 */ +// Helper functions int KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window); KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo); KMSDRM_FBInfo *KMSDRM_FBFromBO2(SDL_VideoDevice *_this, struct gbm_bo *bo, int w, int h); SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata); /****************************************************************************/ -/* SDL_VideoDevice functions declaration */ +// SDL_VideoDevice functions declaration /****************************************************************************/ -/* Display and window functions */ +// Display and window functions int KMSDRM_VideoInit(SDL_VideoDevice *_this); void KMSDRM_VideoQuit(SDL_VideoDevice *_this); int KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); @@ -173,7 +173,7 @@ void KMSDRM_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* OpenGL/OpenGL ES functions */ +// OpenGL/OpenGL ES functions int KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_FunctionPointer KMSDRM_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); void KMSDRM_GLES_UnloadLibrary(SDL_VideoDevice *_this); @@ -184,4 +184,4 @@ int KMSDRM_GLES_GetSwapInterval(SDL_VideoDevice *_this); int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int KMSDRM_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); -#endif /* SDL_kmsdrmvideo_h */ +#endif // SDL_kmsdrmvideo_h diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 7ca9e92d7a..926418edec 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -54,7 +54,7 @@ int KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan library */ + // Load the Vulkan library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } @@ -131,14 +131,14 @@ void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) } /*********************************************************************/ -/* Here we can put whatever Vulkan extensions we want to be enabled */ -/* at instance creation, which is done in the programs, not in SDL. */ -/* So: programs call SDL_Vulkan_GetInstanceExtensions() and here */ -/* we put the extensions specific to this backend so the programs */ -/* get a list with the extension we want, so they can include that */ -/* list in the ppEnabledExtensionNames and EnabledExtensionCount */ -/* members of the VkInstanceCreateInfo struct passed to */ -/* vkCreateInstance(). */ +// Here we can put whatever Vulkan extensions we want to be enabled +// at instance creation, which is done in the programs, not in SDL. +// So: programs call SDL_Vulkan_GetInstanceExtensions() and here +// we put the extensions specific to this backend so the programs +// get a list with the extension we want, so they can include that +// list in the ppEnabledExtensionNames and EnabledExtensionCount +// members of the VkInstanceCreateInfo struct passed to +// vkCreateInstance(). /*********************************************************************/ char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count) @@ -151,12 +151,12 @@ char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, } /***********************************************************************/ -/* First thing to know is that we don't call vkCreateInstance() here. */ -/* Instead, programs using SDL and Vulkan create their Vulkan instance */ -/* 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. */ +// First thing to know is that we don't call vkCreateInstance() here. +// Instead, programs using SDL and Vulkan create their Vulkan instance +// 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. /***********************************************************************/ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, @@ -186,7 +186,7 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, VkDisplayModeKHR display_mode = (VkDisplayModeKHR)0; VkDisplayModePropertiesKHR display_mode_props = { 0 }; VkDisplayModeParametersKHR new_mode_parameters = { { 0, 0 }, 0 }; - /* Prefer a plane that supports per-pixel alpha. */ + // Prefer a plane that supports per-pixel alpha. VkDisplayPlaneAlphaFlagBitsKHR alpha_mode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; VkResult result; @@ -195,11 +195,11 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, SDL_bool mode_found = SDL_FALSE; SDL_bool plane_supports_display = SDL_FALSE; - /* Get the display index from the display being used by the window. */ + // Get the display index from the display being used by the window. int display_index = SDL_GetDisplayIndex(SDL_GetDisplayForWindow(window)); int i, j; - /* Get the function pointers for the functions we will use. */ + // Get the function pointers for the functions we will use. PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; @@ -245,13 +245,13 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, } /*************************************/ - /* Block for vulkan surface creation */ + // Block for vulkan surface creation /*************************************/ /****************************************************************/ - /* If we got vkCreateDisplayPlaneSurfaceKHR() pointer, it means */ - /* that the VK_KHR_Display extension is active on the instance. */ - /* That's the central extension we need for x-less VK! */ + // If we got vkCreateDisplayPlaneSurfaceKHR() pointer, it means + // that the VK_KHR_Display extension is active on the instance. + // That's the central extension we need for x-less VK! /****************************************************************/ if (!vkCreateDisplayPlaneSurfaceKHR) { SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME @@ -267,7 +267,7 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, gpu = physical_devices[0], instead of probing, and go with that. */ - /* Get the physical device count. */ + // Get the physical device count. vkEnumeratePhysicalDevices(instance, &gpu_count, NULL); if (gpu_count == 0) { @@ -275,20 +275,20 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, goto clean; } - /* Get the physical devices. */ + // Get the physical devices. physical_devices = SDL_malloc(sizeof(VkPhysicalDevice) * gpu_count); device_props = SDL_malloc(sizeof(VkPhysicalDeviceProperties)); vkEnumeratePhysicalDevices(instance, &gpu_count, physical_devices); - /* Iterate on the physical devices. */ + // Iterate on the physical devices. for (i = 0; i < gpu_count; i++) { - /* Get the physical device properties. */ + // Get the physical device properties. vkGetPhysicalDeviceProperties( physical_devices[i], device_props); - /* Is this device a real GPU that supports API version 1 at least? */ + // 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)) { gpu = physical_devices[i]; @@ -311,16 +311,16 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, goto clean; } - /* Get the props of the displays of the physical device. */ + // Get the props of the displays of the physical device. display_props = (VkDisplayPropertiesKHR *)SDL_malloc(display_count * sizeof(*display_props)); vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, &display_count, display_props); - /* Get the chosen display based on the display index. */ + // Get the chosen display based on the display index. display = display_props[display_index].display; - /* Get the list of the display videomodes. */ + // Get the list of the display videomodes. vkGetDisplayModePropertiesKHR(gpu, display, &mode_count, NULL); @@ -354,7 +354,7 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, if (mode_found && display_mode_props.parameters.visibleRegion.width > 0 && display_mode_props.parameters.visibleRegion.height > 0) { - /* Found a suitable mode among the predefined ones. Use that. */ + // Found a suitable mode among the predefined ones. Use that. display_mode = display_mode_props.displayMode; } else { @@ -381,13 +381,13 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, } } - /* Just in case we get here without a display_mode. */ + // Just in case we get here without a display_mode. if (!display_mode) { SDL_SetError("Vulkan couldn't get a display mode."); goto clean; } - /* Get the list of the physical device planes. */ + // Get the list of the physical device planes. vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, NULL); if (plane_count == 0) { SDL_SetError("Vulkan can't find any planes."); @@ -406,14 +406,14 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, uint32_t supported_displays_count = 0; VkDisplayKHR *supported_displays; - /* See if the plane is compatible with the current display. */ + // See if the plane is compatible with the current display. vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, &supported_displays_count, NULL); if (supported_displays_count == 0) { - /* This plane doesn't support any displays. Continue to the next plane. */ + // This plane doesn't support any displays. Continue to the next plane. continue; } - /* Get the list of displays supported by this plane. */ + // Get the list of displays supported by this plane. supported_displays = (VkDisplayKHR *)SDL_malloc(sizeof(VkDisplayKHR) * supported_displays_count); vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, &supported_displays_count, supported_displays); @@ -434,33 +434,33 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, } } - /* Free the list of displays supported by this plane. */ + // Free the list of displays supported by this plane. if (supported_displays) { SDL_free(supported_displays); } - /* If the display is not supported by this plane, iterate to the next plane. */ + // If the display is not supported by this plane, iterate to the next plane. if (!plane_supports_display) { continue; } - /* Want a plane that supports the alpha mode we have chosen. */ + // Want a plane that supports the alpha mode we have chosen. vkGetDisplayPlaneCapabilitiesKHR(gpu, display_mode, i, &plane_caps); if (plane_caps.supportedAlpha == alpha_mode) { - /* Yep, this plane is alright. */ + // Yep, this plane is alright. plane = i; break; } } - /* If we couldn't find an appropriate plane, error out. */ + // If we couldn't find an appropriate plane, error out. if (plane == UINT32_MAX) { SDL_SetError("Vulkan couldn't find an appropriate plane."); goto clean; } /********************************************/ - /* Let's finally create the Vulkan surface! */ + // Let's finally create the Vulkan surface! /********************************************/ image_size.width = window->w; diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.h b/src/video/kmsdrm/SDL_kmsdrmvulkan.h index bdb476b849..7f0d2a98b0 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.h +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.h @@ -50,4 +50,4 @@ void KMSDRM_Vulkan_DestroySurface(SDL_VideoDevice *_this, #endif -#endif /* SDL_kmsdrm_vulkan_h_ */ +#endif // SDL_kmsdrm_vulkan_h_ diff --git a/src/video/n3ds/SDL_n3dsevents.c b/src/video/n3ds/SDL_n3dsevents.c index cecf444849..cda9b1c652 100644 --- a/src/video/n3ds/SDL_n3dsevents.c +++ b/src/video/n3ds/SDL_n3dsevents.c @@ -42,4 +42,4 @@ void N3DS_PumpEvents(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_N3DS */ +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/src/video/n3ds/SDL_n3dsevents_c.h b/src/video/n3ds/SDL_n3dsevents_c.h index 5a7b70dcef..a3b459a982 100644 --- a/src/video/n3ds/SDL_n3dsevents_c.h +++ b/src/video/n3ds/SDL_n3dsevents_c.h @@ -26,4 +26,4 @@ extern void N3DS_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_n3dsevents_c_h_ */ +#endif // SDL_n3dsevents_c_h_ diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index b1084ad415..b04cbb507c 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -78,7 +78,7 @@ int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, return SDL_SetError("%s: Unable to get the window surface.", __func__); } - /* Get the N3DS internal framebuffer and its size */ + // Get the N3DS internal framebuffer and its size framebuffer = gfxGetFramebuffer(drv_data->screen, GFX_LEFT, &width, &height); bufsize = width * height * 4; @@ -158,4 +158,4 @@ void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo SDL_ClearProperty(SDL_GetWindowProperties(window), N3DS_SURFACE); } -#endif /* SDL_VIDEO_DRIVER_N3DS */ +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/src/video/n3ds/SDL_n3dsframebuffer_c.h b/src/video/n3ds/SDL_n3dsframebuffer_c.h index c471b2d9d6..b2110e0fd6 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer_c.h +++ b/src/video/n3ds/SDL_n3dsframebuffer_c.h @@ -28,4 +28,4 @@ int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_n3dsframebuffer_c_h_ */ +#endif // SDL_n3dsframebuffer_c_h_ diff --git a/src/video/n3ds/SDL_n3dsswkb.c b/src/video/n3ds/SDL_n3dsswkb.c index d15d654895..d8c7e142d6 100644 --- a/src/video/n3ds/SDL_n3dsswkb.c +++ b/src/video/n3ds/SDL_n3dsswkb.c @@ -66,4 +66,4 @@ int N3DS_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -#endif /* SDL_VIDEO_DRIVER_N3DS */ +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/src/video/n3ds/SDL_n3dsswkb.h b/src/video/n3ds/SDL_n3dsswkb.h index 199e9e8c55..d47c4dc4f5 100644 --- a/src/video/n3ds/SDL_n3dsswkb.h +++ b/src/video/n3ds/SDL_n3dsswkb.h @@ -33,4 +33,4 @@ SDL_bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this); int N3DS_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); int N3DS_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_n3dskeyboard_h_ */ +#endif // SDL_n3dskeyboard_h_ diff --git a/src/video/n3ds/SDL_n3dstouch.c b/src/video/n3ds/SDL_n3dstouch.c index 1915e30d58..10bb0a6f4d 100644 --- a/src/video/n3ds/SDL_n3dstouch.c +++ b/src/video/n3ds/SDL_n3dstouch.c @@ -83,4 +83,4 @@ void N3DS_PollTouch(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_N3DS */ +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/src/video/n3ds/SDL_n3dstouch.h b/src/video/n3ds/SDL_n3dstouch.h index c5787cc0aa..204fbd5604 100644 --- a/src/video/n3ds/SDL_n3dstouch.h +++ b/src/video/n3ds/SDL_n3dstouch.h @@ -26,4 +26,4 @@ void N3DS_InitTouch(void); void N3DS_QuitTouch(void); void N3DS_PollTouch(SDL_VideoDevice *_this); -#endif /* SDL_n3dstouch_h_ */ +#endif // SDL_n3dstouch_h_ diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c index 4c168126bb..bf5dfae83d 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -63,7 +63,7 @@ static const struct { SDL_PIXELFORMAT_RGBA4444, GSP_RGBA4_OES } }; -/* N3DS driver bootstrap functions */ +// N3DS driver bootstrap functions static void N3DS_DeleteDevice(SDL_VideoDevice *device) { @@ -76,13 +76,13 @@ static SDL_VideoDevice *N3DS_CreateDevice(void) SDL_VideoDevice *device; SDL_VideoData *phdata; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal data */ + // Initialize internal data phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!phdata) { SDL_free(device); @@ -253,4 +253,4 @@ static void N3DS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_free(window->internal); } -#endif /* SDL_VIDEO_DRIVER_N3DS */ +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/src/video/n3ds/SDL_n3dsvideo.h b/src/video/n3ds/SDL_n3dsvideo.h index d2197632a4..adac2626d6 100644 --- a/src/video/n3ds/SDL_n3dsvideo.h +++ b/src/video/n3ds/SDL_n3dsvideo.h @@ -38,4 +38,4 @@ struct SDL_WindowData gfxScreen_t screen; /**< Keeps track of which N3DS screen is targeted */ }; -#endif /* SDL_n3dsvideo_h_ */ +#endif // SDL_n3dsvideo_h_ diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp index 91327d4a8f..7b0ab82311 100644 --- a/src/video/ngage/SDL_ngageevents.cpp +++ b/src/video/ngage/SDL_ngageevents.cpp @@ -57,7 +57,7 @@ void NGAGE_PumpEvents(SDL_VideoDevice *_this) } /*****************************************************************************/ -/* Internal */ +// Internal /*****************************************************************************/ #include @@ -153,19 +153,19 @@ int HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent) int posted = 0; switch (aWsEvent.Type()) { - case EEventKeyDown: /* Key events */ + case EEventKeyDown: // Key events SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), SDL_PRESSED); break; - case EEventKeyUp: /* Key events */ + case EEventKeyUp: // Key events SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), SDL_RELEASED); break; - case EEventFocusGained: /* SDL window got focus */ + case EEventFocusGained: // SDL window got focus data->NGAGE_IsWindowFocused = ETrue; - /* Draw window background and screen buffer */ + // Draw window background and screen buffer DisableKeyBlocking(_this); RedrawWindowL(_this); break; - case EEventFocusLost: /* SDL window lost focus */ + case EEventFocusLost: // SDL window lost focus { data->NGAGE_IsWindowFocused = EFalse; RWsSession s; @@ -191,4 +191,4 @@ int HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent) return posted; } -#endif /* SDL_VIDEO_DRIVER_NGAGE */ +#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp index 3675c54078..5fe1dcab5a 100644 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/src/video/ngage/SDL_ngageframebuffer.cpp @@ -51,23 +51,23 @@ int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB4444; int w, h; - /* Free the old framebuffer surface */ + // Free the old framebuffer surface SDL_NGAGE_DestroyWindowFramebuffer(_this, window); - /* Create a new one */ + // Create a new one SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); if (!surface) { return -1; } - /* Save the info and return! */ + // Save the info and return! SDL_SetWindowData(window, NGAGE_SURFACE, surface); *format = surface_format; *pixels = surface->pixels; *pitch = surface->pitch; - /* Initialise Epoc frame buffer */ + // Initialise Epoc frame buffer TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode(); @@ -120,7 +120,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window TRAPD(status, phdata->NGAGE_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode)); User::LeaveIfError(status); - /* Activate events for me */ + // Activate events for me phdata->NGAGE_WsEventStatus = KRequestPending; phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus); @@ -158,7 +158,7 @@ void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind } /*****************************************************************************/ -/* Runtime */ +// Runtime /*****************************************************************************/ #include @@ -172,7 +172,7 @@ EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01 &screenInfo2) } /*****************************************************************************/ -/* Internal */ +// Internal /*****************************************************************************/ int GetBpp(TDisplayMode displaymode) @@ -183,9 +183,9 @@ int GetBpp(TDisplayMode displaymode) void DrawBackground(SDL_VideoDevice *_this) { SDL_VideoData *phdata = _this->internal; - /* Draw background */ + // Draw background TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer; - /* Draw black background */ + // Draw black background Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen); } @@ -205,7 +205,7 @@ void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 * const TInt sourceScanlineLength = screenW; const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth; - /* Render the rectangles in the list */ + // Render the rectangles in the list for (i = 0; i < numrects; ++i) { const SDL_Rect ¤tRect = rects[i]; @@ -219,24 +219,24 @@ void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 * continue; } - /* All variables are measured in pixels */ + // All variables are measured in pixels - /* Check rects validity, i.e. upper and lower bounds */ + // Check rects validity, i.e. upper and lower bounds TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1); TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1); if (maxX < 0 || maxY < 0) /* sanity check */ { continue; } - /* Clip from bottom */ + // Clip from bottom maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight - 1); - /* TODO: Clip from the right side */ + // 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 TUint skipValue = 1; // 1 = No skip TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength; @@ -254,8 +254,8 @@ void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 * } } else { for (TInt y = 0; y < sourceRectHeight; y++) { - TUint16 *bitmapPos = bitmapLine; /* 2 bytes per pixel */ - TUint16 *screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ + 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)); @@ -278,9 +278,9 @@ void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 * 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 */ + 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)); @@ -295,9 +295,9 @@ void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 * 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 */ + 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)); @@ -344,7 +344,7 @@ void DirectUpdate(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects) TInt aBy = rects[i].h; TRect rect2 = TRect(aAx, aAy, aBx, aBy); - phdata->NGAGE_DrawDevice->UpdateRegion(rect2); /* Should we update rects parameter area only? */ + phdata->NGAGE_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only? phdata->NGAGE_DrawDevice->Update(); } } @@ -364,11 +364,11 @@ void RedrawWindowL(SDL_VideoDevice *_this) DrawBackground(_this); } - /* Tell the system that something has been drawn */ + // Tell the system that something has been drawn TRect rect = TRect(phdata->NGAGE_WsWindow.Size()); phdata->NGAGE_WsWindow.Invalidate(rect); - /* Draw current buffer */ + // Draw current buffer SDL_Rect fullScreen; fullScreen.x = 0; fullScreen.y = 0; @@ -377,4 +377,4 @@ void RedrawWindowL(SDL_VideoDevice *_this) DirectUpdate(_this, 1, &fullScreen); } -#endif /* SDL_VIDEO_DRIVER_NGAGE */ +#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngageframebuffer_c.h b/src/video/ngage/SDL_ngageframebuffer_c.h index 6358ff9bf3..ef80701e32 100644 --- a/src/video/ngage/SDL_ngageframebuffer_c.h +++ b/src/video/ngage/SDL_ngageframebuffer_c.h @@ -26,7 +26,7 @@ extern int SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window extern void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); /****************************************************************************/ -/* Runtime */ +// Runtime /****************************************************************************/ class NGAGE_Runtime diff --git a/src/video/ngage/SDL_ngagevideo.cpp b/src/video/ngage/SDL_ngagevideo.cpp index 6bae7de083..62e6961e86 100644 --- a/src/video/ngage/SDL_ngagevideo.cpp +++ b/src/video/ngage/SDL_ngagevideo.cpp @@ -46,20 +46,20 @@ extern "C" { #define NGAGEVID_DRIVER_NAME "ngage" -/* Initialization/Query functions */ +// Initialization/Query functions static int NGAGE_VideoInit(SDL_VideoDevice *_this); static void NGAGE_VideoQuit(SDL_VideoDevice *_this); -/* NGAGE driver bootstrap functions */ +// NGAGE driver bootstrap functions static void NGAGE_DeleteDevice(SDL_VideoDevice *device) { SDL_VideoData *phdata = device->internal; if (phdata) { - /* Free Epoc resources */ + // Free Epoc resources - /* Disable events for me */ + // Disable events for me if (phdata->NGAGE_WsEventStatus != KRequestPending) { phdata->NGAGE_WsSession.EventReadyCancel(); } @@ -67,7 +67,7 @@ static void NGAGE_DeleteDevice(SDL_VideoDevice *device) phdata->NGAGE_WsSession.RedrawReadyCancel(); } - free(phdata->NGAGE_DrawDevice); /* This should NOT be SDL_free() */ + free(phdata->NGAGE_DrawDevice); // This should NOT be SDL_free() if (phdata->NGAGE_WsWindow.WsHandle()) { phdata->NGAGE_WsWindow.Close(); @@ -102,20 +102,20 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) SDL_VideoDevice *device; SDL_VideoData *phdata; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal N-Gage specific data */ + // Initialize internal N-Gage specific data phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!phdata) { SDL_free(device); return NULL; } - /* General video */ + // General video device->VideoInit = NGAGE_VideoInit; device->VideoQuit = NGAGE_VideoQuit; device->PumpEvents = NGAGE_PumpEvents; @@ -124,11 +124,11 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer; device->free = NGAGE_DeleteDevice; - /* "Window" */ + // "Window" device->CreateSDLWindow = NGAGE_CreateWindow; device->DestroyWindow = NGAGE_DestroyWindow; - /* N-Gage specific data */ + // N-Gage specific data device->internal = phdata; return device; @@ -137,14 +137,14 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) VideoBootStrap NGAGE_bootstrap = { NGAGEVID_DRIVER_NAME, "SDL ngage video driver", NGAGE_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; int NGAGE_VideoInit(SDL_VideoDevice *_this) { SDL_DisplayMode mode; - /* Use 12-bpp desktop mode */ + // Use 12-bpp desktop mode SDL_zero(mode); mode.format = SDL_PIXELFORMAT_XRGB4444; mode.w = 176; @@ -153,7 +153,7 @@ int NGAGE_VideoInit(SDL_VideoDevice *_this) return -1; } - /* We're done! */ + // We're done! return 0; } @@ -161,4 +161,4 @@ void NGAGE_VideoQuit(SDL_VideoDevice *_this) { } -#endif /* SDL_VIDEO_DRIVER_NGAGE */ +#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngagevideo.h b/src/video/ngage/SDL_ngagevideo.h index 39dbed8a01..8f1b07b70a 100644 --- a/src/video/ngage/SDL_ngagevideo.h +++ b/src/video/ngage/SDL_ngagevideo.h @@ -36,7 +36,7 @@ struct SDL_VideoData { - /* Epoc window server info */ + // Epoc window server info RWsSession NGAGE_WsSession; RWindowGroup NGAGE_WsWindowGroup; TInt NGAGE_WsWindowGroupID; @@ -47,9 +47,9 @@ struct SDL_VideoData TRequestStatus NGAGE_RedrawEventStatus; TWsEvent NGAGE_WsEvent; CFbsDrawDevice *NGAGE_DrawDevice; - TBool NGAGE_IsWindowFocused; /* Not used yet */ + TBool NGAGE_IsWindowFocused; // Not used yet - /* Screen hardware frame buffer info */ + // Screen hardware frame buffer info TBool NGAGE_HasFrameBuffer; TInt NGAGE_BytesPerPixel; TInt NGAGE_BytesPerScanLine; @@ -62,4 +62,4 @@ struct SDL_VideoData CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation; }; -#endif /* SDL_ngagevideo_h */ +#endif // SDL_ngagevideo_h diff --git a/src/video/ngage/SDL_ngagewindow.cpp b/src/video/ngage/SDL_ngagewindow.cpp index 0fb8e9e9d8..f136142556 100644 --- a/src/video/ngage/SDL_ngagewindow.cpp +++ b/src/video/ngage/SDL_ngagewindow.cpp @@ -69,7 +69,7 @@ void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } /*****************************************************************************/ -/* Internal */ +// Internal /*****************************************************************************/ void DisableKeyBlocking(SDL_VideoDevice *_this) @@ -122,4 +122,4 @@ void ConstructWindowL(SDL_VideoDevice *_this) DisableKeyBlocking(_this); } -#endif /* SDL_VIDEO_DRIVER_NGAGE */ +#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngagewindow.h b/src/video/ngage/SDL_ngagewindow.h index 39b6c5b532..317e03b221 100644 --- a/src/video/ngage/SDL_ngagewindow.h +++ b/src/video/ngage/SDL_ngagewindow.h @@ -35,4 +35,4 @@ typedef struct extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); extern void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_ngagewindow */ +#endif // SDL_ngagewindow diff --git a/src/video/offscreen/SDL_offscreenevents.c b/src/video/offscreen/SDL_offscreenevents.c index ce8b50c4b4..fc2481137d 100644 --- a/src/video/offscreen/SDL_offscreenevents.c +++ b/src/video/offscreen/SDL_offscreenevents.c @@ -32,7 +32,7 @@ void OFFSCREEN_PumpEvents(SDL_VideoDevice *_this) { - /* do nothing. */ + // do nothing. } -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index e64a245251..dfea274183 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -35,14 +35,14 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888; int w, h; - /* Create a new framebuffer */ + // Create a new framebuffer SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); if (!surface) { return -1; } - /* Save the info and return! */ + // Save the info and return! SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE, surface); *format = surface_format; *pixels = surface->pixels; @@ -61,7 +61,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi return SDL_SetError("Couldn't find offscreen surface for window"); } - /* Send the data to the display */ + // Send the data to the display if (SDL_GetHintBoolean(SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES, SDL_FALSE)) { char file[128]; (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", @@ -76,4 +76,4 @@ void SDL_OFFSCREEN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * SDL_ClearProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE); } -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/src/video/offscreen/SDL_offscreenopengles.c b/src/video/offscreen/SDL_offscreenopengles.c index 2de9b88002..cd05b5a5b5 100644 --- a/src/video/offscreen/SDL_offscreenopengles.c +++ b/src/video/offscreen/SDL_offscreenopengles.c @@ -26,7 +26,7 @@ #include "SDL_offscreenvideo.h" #include "SDL_offscreenwindow.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support int OFFSCREEN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { @@ -81,4 +81,4 @@ int OFFSCREEN_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) return SDL_EGL_SwapBuffers(_this, offscreen_wind->egl_surface); } -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/offscreen/SDL_offscreenopengles.h b/src/video/offscreen/SDL_offscreenopengles.h index 280880f227..e343519087 100644 --- a/src/video/offscreen/SDL_offscreenopengles.h +++ b/src/video/offscreen/SDL_offscreenopengles.h @@ -39,6 +39,6 @@ extern SDL_GLContext OFFSCREEN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Wi extern int OFFSCREEN_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); extern int OFFSCREEN_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL -#endif /* SDL_offscreenopengles_h */ +#endif // SDL_offscreenopengles_h diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index d9835ab4e8..d04d287ea2 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -39,12 +39,12 @@ #define OFFSCREENVID_DRIVER_NAME "offscreen" -/* Initialization/Query functions */ +// Initialization/Query functions static int OFFSCREEN_VideoInit(SDL_VideoDevice *_this); static int OFFSCREEN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void OFFSCREEN_VideoQuit(SDL_VideoDevice *_this); -/* OFFSCREEN driver bootstrap functions */ +// OFFSCREEN driver bootstrap functions static void OFFSCREEN_DeleteDevice(SDL_VideoDevice *device) { @@ -70,13 +70,13 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) return NULL; } - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* General video */ + // General video device->VideoInit = OFFSCREEN_VideoInit; device->VideoQuit = OFFSCREEN_VideoQuit; device->SetDisplayMode = OFFSCREEN_SetDisplayMode; @@ -87,7 +87,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) device->free = OFFSCREEN_DeleteDevice; #ifdef SDL_VIDEO_OPENGL_EGL - /* GL context */ + // GL context device->GL_SwapWindow = OFFSCREEN_GLES_SwapWindow; device->GL_MakeCurrent = OFFSCREEN_GLES_MakeCurrent; device->GL_CreateContext = OFFSCREEN_GLES_CreateContext; @@ -107,7 +107,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) device->Vulkan_DestroySurface = OFFSCREEN_Vulkan_DestroySurface; #endif - /* "Window" */ + // "Window" device->CreateSDLWindow = OFFSCREEN_CreateWindow; device->DestroyWindow = OFFSCREEN_DestroyWindow; device->SetWindowSize = OFFSCREEN_SetWindowSize; @@ -118,14 +118,14 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) VideoBootStrap OFFSCREEN_bootstrap = { OFFSCREENVID_DRIVER_NAME, "SDL offscreen video driver", OFFSCREEN_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; int OFFSCREEN_VideoInit(SDL_VideoDevice *_this) { SDL_DisplayMode mode; - /* Use a fake 32-bpp desktop mode */ + // Use a fake 32-bpp desktop mode SDL_zero(mode); mode.format = SDL_PIXELFORMAT_XRGB8888; mode.w = 1024; @@ -134,7 +134,7 @@ int OFFSCREEN_VideoInit(SDL_VideoDevice *_this) return -1; } - /* We're done! */ + // We're done! return 0; } @@ -147,4 +147,4 @@ void OFFSCREEN_VideoQuit(SDL_VideoDevice *_this) { } -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/src/video/offscreen/SDL_offscreenvideo.h b/src/video/offscreen/SDL_offscreenvideo.h index 2a998a0d15..f7c7a7c0c2 100644 --- a/src/video/offscreen/SDL_offscreenvideo.h +++ b/src/video/offscreen/SDL_offscreenvideo.h @@ -25,4 +25,4 @@ #include "../SDL_sysvideo.h" -#endif /* SDL_offscreenvideo_h */ +#endif // SDL_offscreenvideo_h diff --git a/src/video/offscreen/SDL_offscreenvulkan.c b/src/video/offscreen/SDL_offscreenvulkan.c index 1727d997f2..044af7cebf 100644 --- a/src/video/offscreen/SDL_offscreenvulkan.c +++ b/src/video/offscreen/SDL_offscreenvulkan.c @@ -45,7 +45,7 @@ static const char *s_defaultPaths[] = { #if defined( SDL_PLATFORM_APPLE ) #include -/* Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. */ +// Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. #define DEFAULT_HANDLE RTLD_DEFAULT #endif @@ -72,14 +72,14 @@ int OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } #if defined(SDL_PLATFORM_APPLE) if (!path) { - /* Handle the case where Vulkan Portability is linked statically. */ + // Handle the case where Vulkan Portability is linked statically. vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, "vkGetInstanceProcAddr"); @@ -149,7 +149,7 @@ int OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_SetError("Installed Vulkan doesn't implement the " VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME " extension"); goto fail; #else - /*Let's at least leave a breadcrumb for people to find if they have issues*/ + // Let's at least leave a breadcrumb for people to find if they have issues SDL_Log("Installed Vulkan doesn't implement the " VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME " extension"); #endif } @@ -202,7 +202,7 @@ char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this if ( hasHeadlessSurfaceExtension == SDL_TRUE ) { *count = SDL_arraysize(returnExtensions); } else { - *count = SDL_arraysize(returnExtensions) - 1; /*assumes VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME is last*/ + *count = SDL_arraysize(returnExtensions) - 1; // assumes VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME is last } } # else diff --git a/src/video/offscreen/SDL_offscreenvulkan.h b/src/video/offscreen/SDL_offscreenvulkan.h index a7f70c5316..6f04ebf9db 100644 --- a/src/video/offscreen/SDL_offscreenvulkan.h +++ b/src/video/offscreen/SDL_offscreenvulkan.h @@ -33,6 +33,6 @@ extern char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice extern int OFFSCREEN_Vulkan_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface); extern void OFFSCREEN_Vulkan_DestroySurface(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_VULKAN */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_VULKAN -#endif /* SDL_offscreenvulkan_h */ +#endif // SDL_offscreenvulkan_h diff --git a/src/video/offscreen/SDL_offscreenwindow.c b/src/video/offscreen/SDL_offscreenwindow.c index 7796e65e55..c8086e57f6 100644 --- a/src/video/offscreen/SDL_offscreenwindow.c +++ b/src/video/offscreen/SDL_offscreenwindow.c @@ -64,7 +64,7 @@ int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prope } else { offscreen_window->egl_surface = EGL_NO_SURFACE; } -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL return 0; } @@ -87,4 +87,4 @@ void OFFSCREEN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->floating.w, window->floating.h); } -#endif /* SDL_VIDEO_DRIVER_OFFSCREEN */ +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/src/video/offscreen/SDL_offscreenwindow.h b/src/video/offscreen/SDL_offscreenwindow.h index a018803958..c273f5ccbf 100644 --- a/src/video/offscreen/SDL_offscreenwindow.h +++ b/src/video/offscreen/SDL_offscreenwindow.h @@ -37,4 +37,4 @@ extern int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SD extern void OFFSCREEN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void OFFSCREEN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_offscreenwindow_h */ +#endif // SDL_offscreenwindow_h diff --git a/src/video/ps2/SDL_ps2video.c b/src/video/ps2/SDL_ps2video.c index e470f3ccb7..7bcecf4579 100644 --- a/src/video/ps2/SDL_ps2video.c +++ b/src/video/ps2/SDL_ps2video.c @@ -43,7 +43,7 @@ #include "SDL_ps2video.h" -/* PS2 driver bootstrap functions */ +// PS2 driver bootstrap functions static int PS2_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) { @@ -59,7 +59,7 @@ static int PS2_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prop { SDL_SetKeyboardFocus(window); - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -72,7 +72,7 @@ static int PS2_VideoInit(SDL_VideoDevice *_this) mode.h = 480; mode.refresh_rate = 60.0f; - /* 32 bpp for default */ + // 32 bpp for default mode.format = SDL_PIXELFORMAT_ABGR8888; SDL_AddBasicVideoDisplay(&mode); @@ -86,20 +86,20 @@ static void PS2_VideoQuit(SDL_VideoDevice *_this) static void PS2_PumpEvents(SDL_VideoDevice *_this) { - /* do nothing. */ + // do nothing. } static SDL_VideoDevice *PS2_CreateDevice(void) { SDL_VideoDevice *device; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Set the function pointers */ + // Set the function pointers device->VideoInit = PS2_VideoInit; device->VideoQuit = PS2_VideoQuit; device->SetDisplayMode = PS2_SetDisplayMode; @@ -114,7 +114,7 @@ VideoBootStrap PS2_bootstrap = { "ps2", "PS2 Video Driver", PS2_CreateDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; -#endif /* SDL_VIDEO_DRIVER_PS2 */ +#endif // SDL_VIDEO_DRIVER_PS2 diff --git a/src/video/ps2/SDL_ps2video.h b/src/video/ps2/SDL_ps2video.h index 91d8a80466..72443a609d 100644 --- a/src/video/ps2/SDL_ps2video.h +++ b/src/video/ps2/SDL_ps2video.h @@ -43,4 +43,4 @@ #pragma GCC diagnostic pop #endif -#endif /* SDL_ps2video_h_ */ +#endif // SDL_ps2video_h_ diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index 0ba7c67eeb..6a72621297 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -38,7 +38,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_Scancode keymap[256]; @@ -67,7 +67,7 @@ int EventUpdate(void *data) SDL_WaitSemaphore(event_sem); sceHprmPeekCurrentKey((u32 *)&hprm); SDL_SignalSemaphore(event_sem); - /* Delay 1/60th of a second */ + // Delay 1/60th of a second sceKernelDelayThread(1000000 / 60); } return 0; @@ -84,7 +84,7 @@ void PSP_PumpEvents(SDL_VideoDevice *_this) keys = hprm; SDL_SignalSemaphore(event_sem); - /* HPRM Keyboard */ + // HPRM Keyboard changed = old_keys ^ keys; old_keys = keys; if (changed) { @@ -243,7 +243,7 @@ int PSP_EventInit(SDL_VideoDevice *_this) irkbd_ready = 0; } #endif - /* Start thread to read data */ + // Start thread to read data if ((event_sem = SDL_CreateSemaphore(1)) == NULL) { return SDL_SetError("Can't create input semaphore"); } @@ -267,6 +267,6 @@ void PSP_EventQuit(SDL_VideoDevice *_this) #endif } -/* end of SDL_pspevents.c ... */ +// end of SDL_pspevents.c ... -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspevents_c.h b/src/video/psp/SDL_pspevents_c.h index 8d41581b28..c2b10baebd 100644 --- a/src/video/psp/SDL_pspevents_c.h +++ b/src/video/psp/SDL_pspevents_c.h @@ -26,4 +26,4 @@ extern void PSP_PumpEvents(SDL_VideoDevice *_this); extern int PSP_EventInit(SDL_VideoDevice *_this); extern void PSP_EventQuit(SDL_VideoDevice *_this); -/* end of SDL_pspevents_c.h ... */ +// end of SDL_pspevents_c.h ... diff --git a/src/video/psp/SDL_pspgl.c b/src/video/psp/SDL_pspgl.c index 39f55865aa..8e3c8d16c3 100644 --- a/src/video/psp/SDL_pspgl.c +++ b/src/video/psp/SDL_pspgl.c @@ -29,7 +29,7 @@ #include "SDL_pspgl_c.h" /*****************************************************************************/ -/* SDL OpenGL/OpenGL ES functions */ +// SDL OpenGL/OpenGL ES functions /*****************************************************************************/ #define EGLCHK(stmt) \ do { \ @@ -80,13 +80,13 @@ SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) EGLint num_configs; int i; - /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */ + // EGL init taken from glutCreateWindow() in PSPGL's glut.c. EGLCHK(display = eglGetDisplay(0)); EGLCHK(eglInitialize(display, NULL, NULL)); wdata->uses_gles = SDL_TRUE; window->flags |= SDL_WINDOW_FULLSCREEN; - /* Setup the config based on SDL's current values. */ + // Setup the config based on SDL's current values. i = 0; attribs[i++] = EGL_RED_SIZE; attribs[i++] = _this->gl_config.red_size; @@ -143,11 +143,11 @@ int PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) EGLBoolean status; status = eglSwapInterval(_this->gl_data->display, interval); if (status == EGL_TRUE) { - /* Return success to upper level */ + // Return success to upper level _this->gl_data->swapinterval = interval; return 0; } - /* Failed to set swap interval */ + // Failed to set swap interval return SDL_SetError("Unable to set the EGL swap interval"); } @@ -174,12 +174,12 @@ int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return SDL_SetError("PSP: GLES initialization failed, no OpenGL ES support"); } - /* Check if OpenGL ES connection has been initialized */ + // Check if OpenGL ES connection has been initialized if (_this->gl_data->display != EGL_NO_DISPLAY) { if (context != EGL_NO_CONTEXT) { status = eglDestroyContext(_this->gl_data->display, context); if (status != EGL_TRUE) { - /* Error during OpenGL ES context destroying */ + // Error during OpenGL ES context destroying return SDL_SetError("PSP: OpenGL ES context destroy error"); } } @@ -187,4 +187,4 @@ int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspgl_c.h b/src/video/psp/SDL_pspgl_c.h index 72fb62790d..6cf6f0966d 100644 --- a/src/video/psp/SDL_pspgl_c.h +++ b/src/video/psp/SDL_pspgl_c.h @@ -47,4 +47,4 @@ extern void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this); extern int PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); extern int PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); -#endif /* SDL_pspgl_c_h_ */ +#endif // SDL_pspgl_c_h_ diff --git a/src/video/psp/SDL_pspmessagebox.c b/src/video/psp/SDL_pspmessagebox.c index e4e76fa7e4..4385a6930c 100644 --- a/src/video/psp/SDL_pspmessagebox.c +++ b/src/video/psp/SDL_pspmessagebox.c @@ -33,18 +33,18 @@ static void configure_dialog(pspUtilityMsgDialogParams *dialog, size_t dialog_size) { - /* clear structure and setup size */ + // clear structure and setup size SDL_memset(dialog, 0, dialog_size); dialog->base.size = dialog_size; - /* set language */ + // set language sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &dialog->base.language); - /* set X/O swap */ + // set X/O swap sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &dialog->base.buttonSwap); - /* set thread priorities */ - /* TODO: understand how these work */ + // set thread priorities + // TODO: understand how these work dialog->base.soundThread = 0x10; dialog->base.graphicsThread = 0x11; dialog->base.fontThread = 0x12; @@ -57,33 +57,33 @@ int PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) pspUtilityMsgDialogParams dialog; int status; - /* check if it's possible to do a messagebox now */ + // check if it's possible to do a messagebox now if (SDL_GetKeyboardFocus() == NULL) return SDL_SetError("No video context is available"); - /* configure dialog */ + // configure dialog configure_dialog(&dialog, sizeof(dialog)); - /* setup dialog options for text */ + // setup dialog options for text dialog.mode = PSP_UTILITY_MSGDIALOG_MODE_TEXT; dialog.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT; - /* copy the message in, 512 bytes max */ + // copy the message in, 512 bytes max SDL_snprintf(dialog.message, sizeof(dialog.message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message); - /* too many buttons */ + // too many buttons if (messageboxdata->numbuttons > 2) return SDL_SetError("messageboxdata->numbuttons valid values are 0, 1, 2"); - /* we only have two options, "yes/no" or "ok" */ + // we only have two options, "yes/no" or "ok" if (messageboxdata->numbuttons == 2) dialog.options |= PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS | PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO; - /* start dialog */ + // start dialog if (sceUtilityMsgDialogInitStart(&dialog) != 0) return SDL_SetError("sceUtilityMsgDialogInitStart() failed for some reason"); - /* loop while the dialog is active */ + // loop while the dialog is active status = PSP_UTILITY_DIALOG_NONE; do { @@ -112,7 +112,7 @@ int PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) } while (status != PSP_UTILITY_DIALOG_NONE); - /* success */ + // success if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES) *buttonID = messageboxdata->buttons[0].buttonID; else if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO) @@ -123,4 +123,4 @@ int PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) return 0; } -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspmessagebox.h b/src/video/psp/SDL_pspmessagebox.h index 4f32285069..6f9b0fe0a3 100644 --- a/src/video/psp/SDL_pspmessagebox.h +++ b/src/video/psp/SDL_pspmessagebox.h @@ -26,6 +26,6 @@ int PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP -#endif /* SDL_pspmessagebox_h_ */ +#endif // SDL_pspmessagebox_h_ diff --git a/src/video/psp/SDL_pspmouse.c b/src/video/psp/SDL_pspmouse.c index 42ec898eb6..5f95730c92 100644 --- a/src/video/psp/SDL_pspmouse.c +++ b/src/video/psp/SDL_pspmouse.c @@ -28,10 +28,10 @@ #include "SDL_pspmouse_c.h" -/* The implementation dependent data for the window manager cursor */ +// The implementation dependent data for the window manager cursor struct WMcursor { int unused; }; -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspmouse_c.h b/src/video/psp/SDL_pspmouse_c.h index a961232b55..23bc0ab7cb 100644 --- a/src/video/psp/SDL_pspmouse_c.h +++ b/src/video/psp/SDL_pspmouse_c.h @@ -21,4 +21,4 @@ #include "SDL_pspvideo.h" -/* Functions to be exported */ +// Functions to be exported diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index 1897e2ea6b..5be0f5e5e5 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -23,12 +23,12 @@ #ifdef SDL_VIDEO_DRIVER_PSP -/* SDL internals */ +// SDL internals #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" -/* PSP declarations */ +// PSP declarations #include "SDL_pspvideo.h" #include "SDL_pspevents_c.h" #include "SDL_pspgl_c.h" @@ -54,13 +54,13 @@ static SDL_VideoDevice *PSP_Create(void) SDL_VideoData *phdata; SDL_GLDriverData *gldata; - /* Initialize SDL_VideoDevice structure */ + // Initialize SDL_VideoDevice structure device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal PSP specific data */ + // Initialize internal PSP specific data phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!phdata) { SDL_free(device); @@ -79,13 +79,13 @@ static SDL_VideoDevice *PSP_Create(void) phdata->egl_initialized = SDL_TRUE; - /* Setup amount of available displays */ + // Setup amount of available displays device->num_displays = 0; - /* Set device free function */ + // Set device free function device->free = PSP_Destroy; - /* Setup all functions which we can handle */ + // Setup all functions which we can handle device->VideoInit = PSP_VideoInit; device->VideoQuit = PSP_VideoQuit; device->GetDisplayModes = PSP_GetDisplayModes; @@ -128,14 +128,14 @@ VideoBootStrap PSP_bootstrap = { }; /*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ +// SDL Video and Display initialization/handling functions /*****************************************************************************/ int PSP_VideoInit(SDL_VideoDevice *_this) { SDL_DisplayMode mode; if (PSP_EventInit(_this) == -1) { - return -1; /* error string would already be set */ + return -1; // error string would already be set } SDL_zero(mode); @@ -143,7 +143,7 @@ int PSP_VideoInit(SDL_VideoDevice *_this) mode.h = 272; mode.refresh_rate = 60.0f; - /* 32 bpp for default */ + // 32 bpp for default mode.format = SDL_PIXELFORMAT_ABGR8888; if (SDL_AddBasicVideoDisplay(&mode) == 0) { @@ -166,11 +166,11 @@ int PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) mode.h = 272; mode.refresh_rate = 60.0f; - /* 32 bpp for default */ + // 32 bpp for default mode.format = SDL_PIXELFORMAT_ABGR8888; SDL_AddFullscreenDisplayMode(display, &mode); - /* 16 bpp secondary mode */ + // 16 bpp secondary mode mode.format = SDL_PIXELFORMAT_BGR565; SDL_AddFullscreenDisplayMode(display, &mode); return 0; @@ -197,18 +197,18 @@ int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI { SDL_WindowData *wdata; - /* Allocate window internal data */ + // Allocate window internal data wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!wdata) { return -1; } - /* Setup driver data for this window */ + // Setup driver data for this window window->internal = wdata; SDL_SetKeyboardFocus(window); - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -354,4 +354,4 @@ SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) return SDL_FALSE; } -#endif /* SDL_VIDEO_DRIVER_PSP */ +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index 79351ffb99..3219f000ec 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -29,22 +29,22 @@ 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 }; 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_VideoDevice functions declaration */ +// SDL_VideoDevice functions declaration /****************************************************************************/ -/* Display and window functions */ +// Display and window functions int PSP_VideoInit(SDL_VideoDevice *_this); void PSP_VideoQuit(SDL_VideoDevice *_this); int PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); @@ -61,7 +61,7 @@ void PSP_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void PSP_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* OpenGL/OpenGL ES functions */ +// OpenGL/OpenGL ES functions int PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this); @@ -72,10 +72,10 @@ int PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); int PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); -/* PSP on screen keyboard */ +// PSP on screen keyboard SDL_bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_pspvideo_h_ */ +#endif // SDL_pspvideo_h_ diff --git a/src/video/qnx/SDL_qnxgl.c b/src/video/qnx/SDL_qnxgl.c index 8c499aebae..9d27d45559 100644 --- a/src/video/qnx/SDL_qnxgl.c +++ b/src/video/qnx/SDL_qnxgl.c @@ -227,7 +227,7 @@ int glSetSwapInterval(SDL_VideoDevice *_this, int interval) */ int glSwapWindow(SDL_VideoDevice *_this, SDL_Window *window) { - /* !!! FIXME: should we migrate this all over to use SDL_egl.c? */ + // !!! FIXME: should we migrate this all over to use SDL_egl.c? window_impl_t *impl = (window_impl_t *)window->internal; return eglSwapBuffers(egl_disp, impl->surface) == EGL_TRUE ? 0 : -1; } diff --git a/src/video/qnx/SDL_qnxvideo.c b/src/video/qnx/SDL_qnxvideo.c index 16f5c65abd..8ec8522592 100644 --- a/src/video/qnx/SDL_qnxvideo.c +++ b/src/video/qnx/SDL_qnxvideo.c @@ -52,7 +52,7 @@ static int videoInit(SDL_VideoDevice *_this) return -1; } - /* Assume we have a mouse and keyboard */ + // Assume we have a mouse and keyboard SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); @@ -346,5 +346,5 @@ static SDL_VideoDevice *createDevice(void) VideoBootStrap QNX_bootstrap = { "qnx", "QNX Screen", createDevice, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c index e592808ef5..3b5c12b94c 100644 --- a/src/video/raspberry/SDL_rpievents.c +++ b/src/video/raspberry/SDL_rpievents.c @@ -40,4 +40,4 @@ void RPI_PumpEvents(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_RPI */ +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/src/video/raspberry/SDL_rpievents_c.h b/src/video/raspberry/SDL_rpievents_c.h index 737e4c9ece..c9fcff43af 100644 --- a/src/video/raspberry/SDL_rpievents_c.h +++ b/src/video/raspberry/SDL_rpievents_c.h @@ -26,4 +26,4 @@ void RPI_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_rpievents_c_h_ */ +#endif // SDL_rpievents_c_h_ diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 016deceb8c..7448acb6ef 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -29,15 +29,15 @@ #include "../../events/SDL_mouse_c.h" #include "../../events/default_cursor.h" -/* Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file */ -/* Attributes changes flag mask */ +// 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) -/* End copied from vc_vchi_dispmanx.h */ +// 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); @@ -52,7 +52,7 @@ 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 */ +// Create a cursor from a surface static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { SDL_CursorData *curdata; @@ -79,7 +79,7 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int 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 */ + // 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); @@ -97,7 +97,7 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return cursor; } -/* Show the specified cursor, or hide if cursor is NULL */ +// Show the specified cursor, or hide if cursor is NULL static int RPI_ShowCursor(SDL_Cursor *cursor) { int ret; @@ -179,7 +179,7 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) return 0; } -/* Free a window manager cursor */ +// Free a window manager cursor static void RPI_FreeCursor(SDL_Cursor *cursor) { int ret; @@ -259,7 +259,7 @@ static int RPI_WarpMouseGlobalGraphically(float x, float y) return SDL_SetError("vc_dispmanx_element_change_attributes() failed"); } - /* Submit asynchronously, otherwise the performance suffers a lot */ + // Submit asynchronously, otherwise the performance suffers a lot ret = vc_dispmanx_update_submit(update, 0, NULL); if (ret != DISPMANX_SUCCESS) { return SDL_SetError("vc_dispmanx_update_submit() failed"); @@ -275,7 +275,7 @@ static int RPI_WarpMouseGlobal(float x, float y) return 0; } - /* Update internal mouse position. */ + // Update internal mouse position. SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); return RPI_WarpMouseGlobalGraphically(x, y); @@ -307,7 +307,7 @@ void RPI_QuitMouse(SDL_VideoDevice *_this) { } -/* This is called when a mouse motion event occurs */ +// This is called when a mouse motion event occurs static int RPI_MoveCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -316,4 +316,4 @@ static int RPI_MoveCursor(SDL_Cursor *cursor) return RPI_WarpMouseGlobalGraphically(mouse->x, mouse->y); } -#endif /* SDL_VIDEO_DRIVER_RPI */ +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/src/video/raspberry/SDL_rpimouse.h b/src/video/raspberry/SDL_rpimouse.h index 0b902b54fa..32d7393d3a 100644 --- a/src/video/raspberry/SDL_rpimouse.h +++ b/src/video/raspberry/SDL_rpimouse.h @@ -37,4 +37,4 @@ struct SDL_CursorData extern void RPI_InitMouse(SDL_VideoDevice *_this); extern void RPI_QuitMouse(SDL_VideoDevice *_this); -#endif /* SDL_RPI_mouse_h_ */ +#endif // SDL_RPI_mouse_h_ diff --git a/src/video/raspberry/SDL_rpiopengles.c b/src/video/raspberry/SDL_rpiopengles.c index 4f5f004a94..69c1f7e131 100644 --- a/src/video/raspberry/SDL_rpiopengles.c +++ b/src/video/raspberry/SDL_rpiopengles.c @@ -25,7 +25,7 @@ #include "SDL_rpivideo.h" #include "SDL_rpiopengles.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) { @@ -62,4 +62,4 @@ int RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_EGL_CreateContext_impl(RPI) SDL_EGL_MakeCurrent_impl(RPI) -#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/raspberry/SDL_rpiopengles.h b/src/video/raspberry/SDL_rpiopengles.h index 93fcc01199..0cc5b00f80 100644 --- a/src/video/raspberry/SDL_rpiopengles.h +++ b/src/video/raspberry/SDL_rpiopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define RPI_GLES_GetAttribute SDL_EGL_GetAttribute #define RPI_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define RPI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -42,6 +42,6 @@ extern int RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int RPI_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); extern void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor); -#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL -#endif /* SDL_rpiopengles_h_ */ +#endif // SDL_rpiopengles_h_ diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index bab989806d..9450ba796b 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -30,7 +30,7 @@ * http://cgit.freedesktop.org/wayland/weston/tree/src/compositor-rpi.c */ -/* SDL internals */ +// SDL internals #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" @@ -39,7 +39,7 @@ #include "../../core/linux/SDL_evdev.h" #endif -/* RPI declarations */ +// RPI declarations #include "SDL_rpivideo.h" #include "SDL_rpievents_c.h" #include "SDL_rpiopengles.h" @@ -70,7 +70,7 @@ static void RPI_GetRefreshRate(int *numerator, int *denominator) return; } - /* Failed to get display state, default to 60 */ + // Failed to get display state, default to 60 *numerator = 60; *denominator = 1; } @@ -80,13 +80,13 @@ static SDL_VideoDevice *RPI_Create(void) SDL_VideoDevice *device; SDL_VideoData *phdata; - /* Initialize SDL_VideoDevice structure */ + // Initialize SDL_VideoDevice structure device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal data */ + // Initialize internal data phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!phdata) { SDL_free(device); @@ -95,13 +95,13 @@ static SDL_VideoDevice *RPI_Create(void) device->internal = phdata; - /* Setup amount of available displays */ + // Setup amount of available displays device->num_displays = 0; - /* Set device free function */ + // Set device free function device->free = RPI_Destroy; - /* Setup all functions which we can handle */ + // Setup all functions which we can handle device->VideoInit = RPI_VideoInit; device->VideoQuit = RPI_VideoQuit; device->CreateSDLWindow = RPI_CreateWindow; @@ -135,11 +135,11 @@ VideoBootStrap RPI_bootstrap = { "rpi", "RPI Video Driver", RPI_Create, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; /*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ +// SDL Video and Display initialization/handling functions /*****************************************************************************/ static void AddDispManXDisplay(const int display_id) @@ -152,7 +152,7 @@ static void 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) { @@ -160,23 +160,23 @@ static void AddDispManXDisplay(const int display_id) return; } - /* RPI_GetRefreshRate() doesn't distinguish between displays. I'm not sure the hardware distinguishes either */ + // RPI_GetRefreshRate() doesn't distinguish between displays. I'm not sure the hardware distinguishes either SDL_zero(mode); mode.w = modeinfo.width; mode.h = modeinfo.height; RPI_GetRefreshRate(&mode.refresh_rate_numerator, &mode.refresh_rate_denominator); - /* 32 bpp for default */ + // 32 bpp for default mode.format = SDL_PIXELFORMAT_ABGR8888; SDL_zero(display); display.desktop_mode = mode; - /* Allocate display internal data */ + // Allocate display internal data data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); if (!data) { vc_dispmanx_display_close(handle); - return; /* oh well */ + return; // oh well } data->dispman_display = handle; @@ -188,11 +188,11 @@ static void AddDispManXDisplay(const int display_id) int RPI_VideoInit(SDL_VideoDevice *_this) { - /* Initialize BCM Host */ + // 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 if (SDL_EVDEV_Init() < 0) { @@ -233,12 +233,12 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI uint32_t layer = SDL_RPI_VIDEOLAYER; const char *env; - /* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */ + // 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.mask = 0; - /* Allocate window internal data */ + // Allocate window internal data wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!wdata) { return -1; @@ -246,14 +246,14 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI display = SDL_GetVideoDisplayForWindow(window); displaydata = display->internal; - /* Windows have one size for now */ + // Windows have one size for now window->w = display->desktop_mode.w; window->h = display->desktop_mode.h; - /* OpenGL ES is the law here, buddy */ + // OpenGL ES is the law here, buddy window->flags |= SDL_WINDOW_OPENGL; - /* Create a dispman element and associate a window to it */ + // Create a dispman element and associate a window to it dst_rect.x = 0; dst_rect.y = 0; dst_rect.width = window->w; @@ -295,7 +295,7 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return SDL_SetError("Could not create GLES window surface"); } - /* Start generating vsync callbacks if necessary */ + // Start generating vsync callbacks if necessary wdata->double_buffer = SDL_FALSE; if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { wdata->vsync_cond = SDL_CreateCondition(); @@ -304,14 +304,14 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata); } - /* Setup driver data for this window */ + // Setup driver data for this window window->internal = wdata; - /* One window, it always has focus */ + // One window, it always has focus SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -322,7 +322,7 @@ void RPI_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) if (data) { if (data->double_buffer) { - /* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */ + // Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed SDL_LockMutex(data->vsync_cond_mutex); SDL_WaitCondition(data->vsync_cond, data->vsync_cond_mutex); SDL_UnlockMutex(data->vsync_cond_mutex); @@ -372,4 +372,4 @@ void RPI_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) { } -#endif /* SDL_VIDEO_DRIVER_RPI */ +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h index ee0b612b7d..267fa970e6 100644 --- a/src/video/raspberry/SDL_rpivideo.h +++ b/src/video/raspberry/SDL_rpivideo.h @@ -30,7 +30,7 @@ struct SDL_VideoData { - uint32_t egl_refcount; /* OpenGL ES reference count */ + uint32_t egl_refcount; // OpenGL ES reference count }; struct SDL_DisplayData @@ -45,20 +45,20 @@ struct SDL_WindowData EGLSurface egl_surface; #endif - /* Vsync callback cond and mutex */ + // Vsync callback cond and mutex SDL_Condition *vsync_cond; SDL_Mutex *vsync_cond_mutex; SDL_bool double_buffer; }; -#define SDL_RPI_VIDEOLAYER 10000 /* High enough so to occlude everything */ +#define SDL_RPI_VIDEOLAYER 10000 // High enough so to occlude everything #define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1 /****************************************************************************/ -/* SDL_VideoDevice functions declaration */ +// SDL_VideoDevice functions declaration /****************************************************************************/ -/* Display and window functions */ +// Display and window functions int RPI_VideoInit(SDL_VideoDevice *_this); void RPI_VideoQuit(SDL_VideoDevice *_this); int RPI_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); @@ -75,7 +75,7 @@ void RPI_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void RPI_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); void RPI_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* OpenGL/OpenGL ES functions */ +// OpenGL/OpenGL ES functions int RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_FunctionPointer RPI_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); void RPI_GLES_UnloadLibrary(SDL_VideoDevice *_this); @@ -86,4 +86,4 @@ int RPI_GLES_GetSwapInterval(SDL_VideoDevice *_this); int RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int RPI_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); -#endif /* SDL_rpivideo_h */ +#endif // SDL_rpivideo_h diff --git a/src/video/riscos/SDL_riscosdefs.h b/src/video/riscos/SDL_riscosdefs.h index 890d61be87..c49ec866f4 100644 --- a/src/video/riscos/SDL_riscosdefs.h +++ b/src/video/riscos/SDL_riscosdefs.h @@ -25,27 +25,27 @@ typedef struct sprite_area { - int size; /* +0 */ - int count; /* +4 */ - int start; /* +8 */ - int end; /* +12 */ + int size; // +0 + int count; // +4 + int start; // +8 + int end; // +12 } sprite_area; SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16); typedef struct sprite_header { - int next; /* +0 */ - char name[12]; /* +4 */ - int width; /* +16 */ - int height; /* +20 */ - int first_bit; /* +24 */ - int last_bit; /* +28 */ - int image_offset; /* +32 */ - int mask_offset; /* +36 */ - int mode; /* +40 */ + int next; // +0 + char name[12]; // +4 + int width; // +16 + int height; // +20 + int first_bit; // +24 + int last_bit; // +28 + int image_offset; // +32 + int mask_offset; // +36 + int mode; // +40 } sprite_header; SDL_COMPILE_TIME_ASSERT(sprite_header, sizeof(sprite_header) == 44); -#endif /* SDL_riscosdefs_h_ */ +#endif // SDL_riscosdefs_h_ diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index c830747019..fd74a97ff8 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -54,7 +54,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this) Uint8 key = 2; int i; - /* Check for key releases */ + // Check for key releases for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { if (internal->key_pressed[i] != 255) { if ((_kernel_osbyte(129, internal->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) { @@ -64,16 +64,16 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this) } } - /* Check for key presses */ + // Check for key presses while (key < 0xff) { key = _kernel_osbyte(121, key + 1, 0) & 0xff; switch (key) { case 255: - /* Ignore mouse keys */ + // Ignore mouse keys case 9: case 10: case 11: - /* Ignore keys with multiple INKEY codes */ + // Ignore keys with multiple INKEY codes case 24: case 40: case 71: @@ -83,7 +83,7 @@ void RISCOS_PollKeyboard(SDL_VideoDevice *_this) default: SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, key, SDL_RISCOS_translate_keycode(key), SDL_PRESSED); - /* Record the press so we can detect release later. */ + // Record the press so we can detect release later. for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { if (internal->key_pressed[i] == key) { break; @@ -155,7 +155,7 @@ int RISCOS_InitEvents(SDL_VideoDevice *_this) _kernel_swi(OS_Mouse, ®s, ®s); internal->last_mouse_buttons = regs.r[2]; - /* Disable escape. */ + // Disable escape. _kernel_osbyte(229, 1, 0); return 0; @@ -169,8 +169,8 @@ void RISCOS_PumpEvents(SDL_VideoDevice *_this) void RISCOS_QuitEvents(SDL_VideoDevice *_this) { - /* Re-enable escape. */ + // Re-enable escape. _kernel_osbyte(229, 0, 0); } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosevents_c.h b/src/video/riscos/SDL_riscosevents_c.h index 2a62ccfc1c..1db55c753b 100644 --- a/src/video/riscos/SDL_riscosevents_c.h +++ b/src/video/riscos/SDL_riscosevents_c.h @@ -30,4 +30,4 @@ extern int RISCOS_InitEvents(SDL_VideoDevice *_this); extern void RISCOS_PumpEvents(SDL_VideoDevice *_this); extern void RISCOS_QuitEvents(SDL_VideoDevice *_this); -#endif /* SDL_riscosevents_c_h_ */ +#endif // SDL_riscosevents_c_h_ diff --git a/src/video/riscos/SDL_riscosframebuffer.c b/src/video/riscos/SDL_riscosframebuffer.c index d78ecd4a7f..6f10634a94 100644 --- a/src/video/riscos/SDL_riscosframebuffer.c +++ b/src/video/riscos/SDL_riscosframebuffer.c @@ -43,10 +43,10 @@ int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, S SDL_GetWindowSizeInPixels(window, &w, &h); - /* Free the old framebuffer surface */ + // Free the old framebuffer surface RISCOS_DestroyWindowFramebuffer(_this, window); - /* Create a new one */ + // Create a new one mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window)); if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) { *format = mode->format; @@ -56,10 +56,10 @@ int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, S sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27)); } - /* Calculate pitch */ + // Calculate pitch *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); - /* Allocate the sprite area */ + // Allocate the sprite area size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h); internal->fb_area = SDL_malloc(size); if (!internal->fb_area) { @@ -71,7 +71,7 @@ int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, S internal->fb_area->start = 16; internal->fb_area->end = 16; - /* Create the actual image */ + // Create the actual image regs.r[0] = 256 + 15; regs.r[1] = (int)internal->fb_area; regs.r[2] = (int)sprite_name; @@ -100,8 +100,8 @@ int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, c regs.r[0] = 512 + 52; regs.r[1] = (int)internal->fb_area; regs.r[2] = (int)internal->fb_sprite; - regs.r[3] = 0; /* window->x << 1; */ - regs.r[4] = 0; /* window->y << 1; */ + regs.r[3] = 0; // window->x << 1; + regs.r[4] = 0; // window->y << 1; regs.r[5] = 0x50; regs.r[6] = 0; regs.r[7] = 0; @@ -124,4 +124,4 @@ void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) internal->fb_sprite = NULL; } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosframebuffer_c.h b/src/video/riscos/SDL_riscosframebuffer_c.h index 20b9dad595..0c746fdc2c 100644 --- a/src/video/riscos/SDL_riscosframebuffer_c.h +++ b/src/video/riscos/SDL_riscosframebuffer_c.h @@ -28,4 +28,4 @@ extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi extern int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_riscosframebuffer_c_h_ */ +#endif // SDL_riscosframebuffer_c_h_ diff --git a/src/video/riscos/SDL_riscosmessagebox.c b/src/video/riscos/SDL_riscosmessagebox.c index 5ca0712141..1186ca5946 100644 --- a/src/video/riscos/SDL_riscosmessagebox.c +++ b/src/video/riscos/SDL_riscosmessagebox.c @@ -64,4 +64,4 @@ int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonI return 0; } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosmessagebox.h b/src/video/riscos/SDL_riscosmessagebox.h index 43d5d49055..87fce5a102 100644 --- a/src/video/riscos/SDL_riscosmessagebox.h +++ b/src/video/riscos/SDL_riscosmessagebox.h @@ -24,4 +24,4 @@ extern int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index d1ab4728f6..08a21ff76a 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -48,10 +48,10 @@ static const struct SDL_PixelFormat pixel_format; int modeflags, ncolour, log2bpp; } mode_to_pixelformat[] = { - /* { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, */ - /* { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 }, */ - /* { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 }, */ - /* { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 }, */ + // { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, + // { 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 }, @@ -296,15 +296,15 @@ int RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); } - /* Turn the text cursor off */ + // Turn the text cursor off for (i = 0; i < SDL_arraysize(disable_cursor); i++) { _kernel_oswrch(disable_cursor[i]); } - /* Update cursor visibility, since it may have been disabled by the mode change. */ + // Update cursor visibility, since it may have been disabled by the mode change. SDL_SetCursor(NULL); return 0; } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosmodes.h b/src/video/riscos/SDL_riscosmodes.h index 1307e6028a..4c8ed7d4e6 100644 --- a/src/video/riscos/SDL_riscosmodes.h +++ b/src/video/riscos/SDL_riscosmodes.h @@ -28,4 +28,4 @@ extern int RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *disp extern int RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); -#endif /* SDL_riscosmodes_h_ */ +#endif // SDL_riscosmodes_h_ diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index 90294eabc0..3101a0f0cf 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -32,7 +32,7 @@ static SDL_Cursor *RISCOS_CreateDefaultCursor(void) { SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { - /* NULL is used to indicate the default cursor */ + // NULL is used to indicate the default cursor cursor->internal = NULL; } @@ -47,10 +47,10 @@ static void RISCOS_FreeCursor(SDL_Cursor *cursor) static int RISCOS_ShowCursor(SDL_Cursor *cursor) { if (cursor) { - /* Turn the mouse pointer on */ + // Turn the mouse pointer on _kernel_osbyte(106, 1, 0); } else { - /* Turn the mouse pointer off */ + // Turn the mouse pointer off _kernel_osbyte(106, 0, 0); } @@ -61,19 +61,19 @@ int RISCOS_InitMouse(SDL_VideoDevice *_this) { SDL_Mouse *mouse = SDL_GetMouse(); - /* mouse->CreateCursor = RISCOS_CreateCursor; */ - /* mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; */ + // mouse->CreateCursor = RISCOS_CreateCursor; + // mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; mouse->ShowCursor = RISCOS_ShowCursor; mouse->FreeCursor = RISCOS_FreeCursor; - /* mouse->WarpMouse = RISCOS_WarpMouse; */ - /* mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; */ - /* mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; */ - /* mouse->CaptureMouse = RISCOS_CaptureMouse; */ - /* mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; */ + // mouse->WarpMouse = RISCOS_WarpMouse; + // mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; + // mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; + // mouse->CaptureMouse = RISCOS_CaptureMouse; + // mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor()); return 0; } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosmouse.h b/src/video/riscos/SDL_riscosmouse.h index a71e6558d0..29d7c24469 100644 --- a/src/video/riscos/SDL_riscosmouse.h +++ b/src/video/riscos/SDL_riscosmouse.h @@ -25,4 +25,4 @@ extern int RISCOS_InitMouse(SDL_VideoDevice *_this); -#endif /* SDL_riscosmouse_h_ */ +#endif // SDL_riscosmouse_h_ diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 917a4123be..993a684742 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -38,11 +38,11 @@ #define RISCOSVID_DRIVER_NAME "riscos" -/* Initialization/Query functions */ +// Initialization/Query functions static int RISCOS_VideoInit(SDL_VideoDevice *_this); static void RISCOS_VideoQuit(SDL_VideoDevice *_this); -/* RISC OS driver bootstrap functions */ +// RISC OS driver bootstrap functions static void RISCOS_DeleteDevice(SDL_VideoDevice *device) { @@ -55,13 +55,13 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) SDL_VideoDevice *device; SDL_VideoData *data; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal data */ + // Initialize internal data data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!data) { SDL_free(device); @@ -70,7 +70,7 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) device->internal = data; - /* Set the function pointers */ + // Set the function pointers device->VideoInit = RISCOS_VideoInit; device->VideoQuit = RISCOS_VideoQuit; device->PumpEvents = RISCOS_PumpEvents; @@ -87,7 +87,7 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) device->free = RISCOS_DeleteDevice; - /* TODO: Support windowed mode */ + // TODO: Support windowed mode device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY; return device; @@ -109,7 +109,7 @@ static int RISCOS_VideoInit(SDL_VideoDevice *_this) return -1; } - /* Assume we have a mouse and keyboard */ + // Assume we have a mouse and keyboard SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); @@ -117,7 +117,7 @@ static int RISCOS_VideoInit(SDL_VideoDevice *_this) return -1; } - /* We're done! */ + // We're done! return 0; } @@ -126,4 +126,4 @@ static void RISCOS_VideoQuit(SDL_VideoDevice *_this) RISCOS_QuitEvents(_this); } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscosvideo.h b/src/video/riscos/SDL_riscosvideo.h index 986bcc2ff1..91ee5a5896 100644 --- a/src/video/riscos/SDL_riscosvideo.h +++ b/src/video/riscos/SDL_riscosvideo.h @@ -33,4 +33,4 @@ struct SDL_VideoData Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED]; }; -#endif /* SDL_riscosvideo_h_ */ +#endif // SDL_riscosvideo_h_ diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index eab2b3f0d6..992ae8c267 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -40,7 +40,7 @@ int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_SetMouseFocus(window); - /* All done! */ + // All done! window->internal = data; return 0; } @@ -53,4 +53,4 @@ void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -#endif /* SDL_VIDEO_DRIVER_RISCOS */ +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/src/video/riscos/SDL_riscoswindow.h b/src/video/riscos/SDL_riscoswindow.h index a692f74759..794faea31f 100644 --- a/src/video/riscos/SDL_riscoswindow.h +++ b/src/video/riscos/SDL_riscoswindow.h @@ -35,4 +35,4 @@ struct SDL_WindowData extern int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_riscoswindow_h_ */ +#endif // SDL_riscoswindow_h_ diff --git a/src/video/riscos/scancodes_riscos.h b/src/video/riscos/scancodes_riscos.h index 8dfe14360a..a181b5b5bd 100644 --- a/src/video/riscos/scancodes_riscos.h +++ b/src/video/riscos/scancodes_riscos.h @@ -23,20 +23,20 @@ Sources: - https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off static SDL_Scancode const riscos_scancode_table[] = { - /* 0 */ SDL_SCANCODE_UNKNOWN, /* Shift */ - /* 1 */ SDL_SCANCODE_UNKNOWN, /* Ctrl */ - /* 2 */ SDL_SCANCODE_UNKNOWN, /* Alt */ + /* 0 */ SDL_SCANCODE_UNKNOWN, // Shift + /* 1 */ SDL_SCANCODE_UNKNOWN, // Ctrl + /* 2 */ SDL_SCANCODE_UNKNOWN, // Alt /* 3 */ SDL_SCANCODE_LSHIFT, /* 4 */ SDL_SCANCODE_LCTRL, /* 5 */ SDL_SCANCODE_LALT, /* 6 */ SDL_SCANCODE_RSHIFT, /* 7 */ SDL_SCANCODE_RCTRL, /* 8 */ SDL_SCANCODE_RALT, - /* 9 */ SDL_SCANCODE_UNKNOWN, /* Left mouse */ - /* 10 */ SDL_SCANCODE_UNKNOWN, /* Center mouse */ - /* 11 */ SDL_SCANCODE_UNKNOWN, /* Right mouse */ + /* 9 */ SDL_SCANCODE_UNKNOWN, // Left mouse + /* 10 */ SDL_SCANCODE_UNKNOWN, // Center mouse + /* 11 */ SDL_SCANCODE_UNKNOWN, // Right mouse /* 12 */ SDL_SCANCODE_UNKNOWN, /* 13 */ SDL_SCANCODE_UNKNOWN, /* 14 */ SDL_SCANCODE_UNKNOWN, @@ -49,7 +49,7 @@ static SDL_Scancode const riscos_scancode_table[] = { /* 21 */ SDL_SCANCODE_8, /* 22 */ SDL_SCANCODE_F7, /* 23 */ SDL_SCANCODE_MINUS, - /* 24 */ SDL_SCANCODE_6, /* Duplicate of 52 */ + /* 24 */ SDL_SCANCODE_6, // Duplicate of 52 /* 25 */ SDL_SCANCODE_LEFT, /* 26 */ SDL_SCANCODE_KP_6, /* 27 */ SDL_SCANCODE_KP_7, @@ -65,7 +65,7 @@ static SDL_Scancode const riscos_scancode_table[] = { /* 37 */ SDL_SCANCODE_I, /* 38 */ SDL_SCANCODE_9, /* 39 */ SDL_SCANCODE_0, - /* 40 */ SDL_SCANCODE_MINUS, /* Duplicate of 23 */ + /* 40 */ SDL_SCANCODE_MINUS, // Duplicate of 23 /* 41 */ SDL_SCANCODE_DOWN, /* 42 */ SDL_SCANCODE_KP_8, /* 43 */ SDL_SCANCODE_KP_9, @@ -96,8 +96,8 @@ static SDL_Scancode const riscos_scancode_table[] = { /* 68 */ SDL_SCANCODE_Y, /* 69 */ SDL_SCANCODE_J, /* 70 */ SDL_SCANCODE_K, - /* 71 */ SDL_SCANCODE_2, /* Duplicate of 49 */ - /* 72 */ SDL_SCANCODE_SEMICOLON, /* Duplicate of 87 */ + /* 71 */ SDL_SCANCODE_2, // Duplicate of 49 + /* 72 */ SDL_SCANCODE_SEMICOLON, // Duplicate of 87 /* 73 */ SDL_SCANCODE_RETURN, /* 74 */ SDL_SCANCODE_KP_DIVIDE, /* 75 */ SDL_SCANCODE_UNKNOWN, @@ -154,4 +154,4 @@ static SDL_Scancode const riscos_scancode_table[] = { /* 126 */ SDL_SCANCODE_RGUI, /* 127 */ SDL_SCANCODE_MENU }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/video/sdlgenblit.pl b/src/video/sdlgenblit.pl index 4cd78faa97..8e68dafd83 100755 --- a/src/video/sdlgenblit.pl +++ b/src/video/sdlgenblit.pl @@ -90,7 +90,7 @@ sub open_file { my $name = shift; open(FILE, ">$name.new") || die "Can't open $name.new: $!"; print FILE <<__EOF__; -/* DO NOT EDIT! This file is generated by sdlgenblit.pl */ +// DO NOT EDIT! This file is generated by sdlgenblit.pl /* Simple DirectMedia Layer Copyright (C) 1997-2024 Sam Lantinga @@ -116,7 +116,7 @@ sub open_file { #if SDL_HAVE_BLIT_AUTO -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off __EOF__ } @@ -124,9 +124,9 @@ __EOF__ sub close_file { my $name = shift; print FILE <<__EOF__; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on -#endif /* SDL_HAVE_BLIT_AUTO */ +#endif // SDL_HAVE_BLIT_AUTO __EOF__ close FILE; diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 3ed941c7c3..ba71b27bae 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -51,36 +51,36 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv { int i; - /* store arguments */ + // store arguments /* Note that we need to be careful about how we allocate/free memory here. * If the application calls SDL_SetMemoryFunctions(), we can't rely on * SDL_free() to use the same allocator after SDL_main() returns. */ forward_main = mainFunction; forward_argc = argc; - forward_argv = (char **)malloc((argc + 1) * sizeof(char *)); /* This should NOT be SDL_malloc() */ + forward_argv = (char **)malloc((argc + 1) * sizeof(char *)); // This should NOT be SDL_malloc() for (i = 0; i < argc; i++) { - forward_argv[i] = malloc((strlen(argv[i]) + 1) * sizeof(char)); /* This should NOT be SDL_malloc() */ + forward_argv[i] = malloc((strlen(argv[i]) + 1) * sizeof(char)); // This should NOT be SDL_malloc() strcpy(forward_argv[i], argv[i]); } forward_argv[i] = NULL; - /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ + // Give over control to run loop, SDLUIKitDelegate will handle most things from here @autoreleasepool { UIApplicationMain(argc, argv, nil, [SDLUIKitDelegate getAppDelegateClassName]); } - /* free the memory we used to hold copies of argc and argv */ + // free the memory we used to hold copies of argc and argv for (i = 0; i < forward_argc; i++) { - free(forward_argv[i]); /* This should NOT be SDL_free() */ + free(forward_argv[i]); // This should NOT be SDL_free() } - free(forward_argv); /* This should NOT be SDL_free() */ + free(forward_argv); // This should NOT be SDL_free() return exit_status; } #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) -/* Load a launch image using the old UILaunchImageFile-era naming rules. */ +// Load a launch image using the old UILaunchImageFile-era naming rules. static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) { UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; @@ -88,10 +88,10 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIImage *image = nil; if (idiom == UIUserInterfaceIdiomPhone && screenh == 568) { - /* The image name for the iPhone 5 uses its height as a suffix. */ + // The image name for the iPhone 5 uses its height as a suffix. image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-568h", name]]; } else if (idiom == UIUserInterfaceIdiomPad) { - /* iPad apps can launch in any orientation. */ + // iPad apps can launch in any orientation. if (UIInterfaceOrientationIsLandscape(curorient)) { if (curorient == UIInterfaceOrientationLandscapeLeft) { image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeLeft", name]]; @@ -170,7 +170,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } @end -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS @interface SDLLaunchScreenController () @@ -196,7 +196,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) NSString *screenname = nibNameOrNil; NSBundle *bundle = nibBundleOrNil; - /* A launch screen may not exist. Fall back to launch images in that case. */ + // A launch screen may not exist. Fall back to launch images in that case. if (screenname) { @try { self.view = [bundle loadNibNamed:screenname owner:self options:nil][0]; @@ -226,7 +226,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; - /* We always want portrait-oriented size, to match UILaunchImageSize. */ + // We always want portrait-oriented size, to match UILaunchImageSize. if (screenw > screenh) { int width = screenw; screenw = screenh; @@ -234,18 +234,18 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } #endif - /* Xcode 5 introduced a dictionary of launch images in Info.plist. */ + // Xcode 5 introduced a dictionary of launch images in Info.plist. if (launchimages) { for (NSDictionary *dict in launchimages) { NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"]; NSString *sizestring = dict[@"UILaunchImageSize"]; - /* Ignore this image if the current version is too low. */ + // Ignore this image if the current version is too low. if (minversion && !UIKit_IsSystemVersionAtLeast(minversion.doubleValue)) { continue; } - /* Ignore this image if the size doesn't match. */ + // Ignore this image if the size doesn't match. if (sizestring) { CGSize size = CGSizeFromString(sizestring); if ((int)(size.width + 0.5) != screenw || (int)(size.height + 0.5) != screenh) { @@ -269,7 +269,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } } - /* Ignore this image if the orientation doesn't match. */ + // Ignore this image if the orientation doesn't match. if ((orientmask & (1 << curorient)) == 0) { continue; } @@ -306,7 +306,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIImageOrientation imageorient = UIImageOrientationUp; #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) - /* Bugs observed / workaround tested in iOS 8.3. */ + // Bugs observed / workaround tested in iOS 8.3. if (UIInterfaceOrientationIsLandscape(curorient)) { if (image.size.width < image.size.height) { /* On iOS 8, portrait launch images displayed in forced- @@ -322,7 +322,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } #endif - /* Create the properly oriented image. */ + // Create the properly oriented image. view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient]; self.view = view; @@ -334,13 +334,13 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) - (void)loadView { - /* Do nothing. */ + // Do nothing. } #ifndef SDL_PLATFORM_TVOS - (BOOL)shouldAutorotate { - /* If YES, the launch image will be incorrectly rotated in some cases. */ + // If YES, the launch image will be incorrectly rotated in some cases. return NO; } @@ -351,7 +351,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) * the ones set here (it will cause an exception in that case.) */ return UIInterfaceOrientationMaskAll; } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS @end @@ -360,7 +360,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIWindow *launchWindow; } -/* convenience method */ +// convenience method + (id)sharedAppDelegate { /* the delegate is set in UIApplicationMain(), which is guaranteed to be @@ -386,14 +386,14 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) launchWindow = nil; - /* Do a nice animated fade-out (roughly matches the real launch behavior.) */ + // 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. */ + UIKit_ForceUpdateHomeIndicator(); // Wait for launch screen to hide so settings are applied to the actual view controller. }]; } @@ -403,7 +403,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) * have a chance to load resources while the launch screen is still up. */ [self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0]; - /* run the user's application, passing argc and argv */ + // run the user's application, passing argc and argv SDL_SetiOSEventPump(SDL_TRUE); exit_status = forward_main(forward_argc, forward_argv); SDL_SetiOSEventPump(SDL_FALSE); @@ -413,10 +413,10 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) launchWindow = nil; } - /* exit, passing the return status from the user's application */ + // exit, passing the return status from the user's application /* We don't actually exit to support applications that do setup in their * main function and then allow the Cocoa event loop to run. */ - /* exit(exit_status); */ + // exit(exit_status); } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions @@ -433,7 +433,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIViewController *vc = nil; NSString *screenname = nil; - /* tvOS only uses a plain launch image. */ + // tvOS only uses a plain launch image. #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"]; @@ -447,7 +447,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) vc = [[SDLLaunchStoryboardViewController alloc] initWithStoryboardViewController:storyboardVc]; } @catch (NSException *exception) { - /* Do nothing (there's more code to execute below). */ + // Do nothing (there's more code to execute below). } } #endif @@ -476,7 +476,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } #endif - /* Set working directory to resource path */ + // Set working directory to resource path [[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]]; SDL_SetMainReady(); @@ -502,7 +502,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) - (void)setWindow:(UIWindow *)window { - /* Do nothing. */ + // Do nothing. } - (void)sendDropFileForURL:(NSURL *)url fromSourceApplication:(NSString *)sourceApplication @@ -521,7 +521,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { - /* TODO: Handle options */ + // TODO: Handle options [self sendDropFileForURL:url fromSourceApplication:NULL]; return YES; } @@ -538,4 +538,4 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) @end -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitclipboard.h b/src/video/uikit/SDL_uikitclipboard.h index 584f35235d..9d508a9095 100644 --- a/src/video/uikit/SDL_uikitclipboard.h +++ b/src/video/uikit/SDL_uikitclipboard.h @@ -30,4 +30,4 @@ extern SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this); extern void UIKit_InitClipboard(SDL_VideoDevice *_this); extern void UIKit_QuitClipboard(SDL_VideoDevice *_this); -#endif /* SDL_uikitclipboard_h_ */ +#endif // SDL_uikitclipboard_h_ diff --git a/src/video/uikit/SDL_uikitclipboard.m b/src/video/uikit/SDL_uikitclipboard.m index 2c315f3146..3ccc6a2e5a 100644 --- a/src/video/uikit/SDL_uikitclipboard.m +++ b/src/video/uikit/SDL_uikitclipboard.m @@ -101,4 +101,4 @@ void UIKit_QuitClipboard(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitevents.h b/src/video/uikit/SDL_uikitevents.h index 683ad02e4f..6bf2392474 100644 --- a/src/video/uikit/SDL_uikitevents.h +++ b/src/video/uikit/SDL_uikitevents.h @@ -37,4 +37,4 @@ extern void SDL_InitGCMouse(void); extern SDL_bool SDL_GCMouseRelativeMode(void); extern void SDL_QuitGCMouse(void); -#endif /* SDL_uikitevents_h_ */ +#endif // SDL_uikitevents_h_ diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index 2f45a39e9a..efde5ef087 100644 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -158,18 +158,18 @@ void UIKit_PumpEvents(SDL_VideoDevice *_this) */ const CFTimeInterval seconds = 0.000002; - /* Pump most event types. */ + // Pump most event types. SInt32 result; do { result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE); } while (result == kCFRunLoopRunHandledSource); - /* Make sure UIScrollView objects scroll properly. */ + // Make sure UIScrollView objects scroll properly. do { result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE); } while (result == kCFRunLoopRunHandledSource); - /* See the comment in the function definition. */ + // See the comment in the function definition. #if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) UIKit_GL_RestoreCurrentContext(); #endif @@ -266,7 +266,7 @@ void SDL_QuitGCKeyboard(void) { } -#endif /* ENABLE_GCKEYBOARD */ +#endif // ENABLE_GCKEYBOARD #ifdef ENABLE_GCMOUSE @@ -277,7 +277,7 @@ static SDL_MouseWheelDirection mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; static void UpdateScrollDirection(void) { -#if 0 /* This code doesn't work for some reason */ +#if 0 // This code doesn't work for some reason NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if ([userDefaults boolForKey:@"com.apple.swipescrolldirection"]) { mouse_scroll_direction = SDL_MOUSEWHEEL_FLIPPED; @@ -288,7 +288,7 @@ static void UpdateScrollDirection(void) Boolean keyExistsAndHasValidFormat = NO; Boolean naturalScrollDirection = CFPreferencesGetAppBooleanValue(CFSTR("com.apple.swipescrolldirection"), kCFPreferencesAnyApplication, &keyExistsAndHasValidFormat); if (!keyExistsAndHasValidFormat) { - /* Couldn't read the preference, assume natural scrolling direction */ + // Couldn't read the preference, assume natural scrolling direction naturalScrollDirection = YES; } if (naturalScrollDirection) { @@ -360,7 +360,7 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14 float vertical = -xValue; float horizontal = yValue; if (mouse_scroll_direction == SDL_MOUSEWHEEL_FLIPPED) { - /* Since these are raw values, we need to flip them ourselves */ + // Since these are raw values, we need to flip them ourselves vertical = -vertical; horizontal = -horizontal; } @@ -397,7 +397,7 @@ static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios void SDL_InitGCMouse(void) { @autoreleasepool { - /* There is a bug where mouse accumulates duplicate deltas over time in iOS 14.0 */ + // There is a bug where mouse accumulates duplicate deltas over time in iOS 14.0 if (@available(iOS 14.1, tvOS 14.1, *)) { /* iOS will not send the new pointer touch events if you don't have this key, * and we need them to differentiate between mouse events and real touch events. @@ -479,6 +479,6 @@ void SDL_QuitGCMouse(void) { } -#endif /* ENABLE_GCMOUSE */ +#endif // ENABLE_GCMOUSE -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitmessagebox.h b/src/video/uikit/SDL_uikitmessagebox.h index 6d7b26eb0b..5f0bf9fced 100644 --- a/src/video/uikit/SDL_uikitmessagebox.h +++ b/src/video/uikit/SDL_uikitmessagebox.h @@ -26,4 +26,4 @@ extern SDL_bool UIKit_ShowingMessageBox(void); extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 9364f82d72..72da5bf53c 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -25,7 +25,7 @@ #include "SDL_uikitvideo.h" #include "SDL_uikitwindow.h" -/* Display a UIKit message box */ +// Display a UIKit message box static SDL_bool s_showingMessageBox = SDL_FALSE; @@ -39,8 +39,8 @@ static void UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messagebox *clickedindex = messageboxdata->numbuttons; @autoreleasepool { - /* Run the main event loop until the alert has finished */ - /* Note that this needs to be done on the main thread */ + // Run the main event loop until the alert has finished + // Note that this needs to be done on the main thread s_showingMessageBox = SDL_TRUE; while ((*clickedindex) == messageboxdata->numbuttons) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; @@ -151,4 +151,4 @@ int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID } } -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitmetalview.h b/src/video/uikit/SDL_uikitmetalview.h index 1bfde53636..fb996be78a 100644 --- a/src/video/uikit/SDL_uikitmetalview.h +++ b/src/video/uikit/SDL_uikitmetalview.h @@ -49,6 +49,6 @@ SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) void UIKit_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view); void *UIKit_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view); -#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ +#endif // SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) -#endif /* SDL_uikitmetalview_h_ */ +#endif // SDL_uikitmetalview_h_ diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index 0145031168..402ef4c4e1 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -38,7 +38,7 @@ @implementation SDL_uikitmetalview -/* Returns a Metal-compatible layer. */ +// Returns a Metal-compatible layer. + (Class)layerClass { return [CAMetalLayer class]; @@ -56,7 +56,7 @@ return self; } -/* Set the size of the metal drawables when the view is resized. */ +// Set the size of the metal drawables when the view is resized. - (void)layoutSubviews { [super layoutSubviews]; @@ -137,4 +137,4 @@ void *UIKit_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view) } } -#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */ +#endif // SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) diff --git a/src/video/uikit/SDL_uikitmodes.h b/src/video/uikit/SDL_uikitmodes.h index 75bb3b831a..f09547d4fe 100644 --- a/src/video/uikit/SDL_uikitmodes.h +++ b/src/video/uikit/SDL_uikitmodes.h @@ -64,4 +64,4 @@ extern int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay #define SDL_XR_SCREENHEIGHT 720 #endif -#endif /* SDL_uikitmodes_h_ */ +#endif // SDL_uikitmodes_h_ diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 50d6722016..31965cc0fc 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -105,7 +105,7 @@ static int UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode, SDL_UIKitDisplayModeData *data = nil; if (uiscreenmode != nil) { - /* Allocate the display mode data */ + // Allocate the display mode data data = [[SDL_UIKitDisplayModeData alloc] init]; if (!data) { return SDL_OutOfMemory(); @@ -171,7 +171,7 @@ static int UIKit_AddDisplayMode(SDL_VideoDisplay *display, int w, int h, } if (addRotation) { - /* Add the rotated version */ + // Add the rotated version if (UIKit_AddSingleDisplayMode(display, h, w, uiscreen, uiscreenmode) < 0) { return -1; } @@ -210,7 +210,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) SDL_VideoDisplay display; SDL_DisplayMode mode; - /* Make sure the width/height are oriented correctly */ + // Make sure the width/height are oriented correctly if (UIKit_IsDisplayLandscape(uiscreen) != (size.width > size.height)) { CGFloat height = size.width; size.width = size.height; @@ -231,7 +231,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) SDL_zero(display); #ifndef SDL_PLATFORM_TVOS if (uiscreen == [UIScreen mainScreen]) { - /* The natural orientation (used by sensors) is portrait */ + // The natural orientation (used by sensors) is portrait display.natural_orientation = SDL_ORIENTATION_PORTRAIT; } else #endif @@ -253,9 +253,9 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) display.HDR.HDR_headroom = uiscreen.potentialEDRHeadroom; } } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS - /* Allocate the display data */ + // Allocate the display data #ifdef SDL_PLATFORM_VISIONOS SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init]; #else @@ -336,7 +336,7 @@ SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) if (uiscreen == [UIScreen mainScreen]) { return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); } else -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS { CGSize size = uiscreen.bounds.size; return (size.width > size.height); @@ -390,7 +390,7 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) int w = (int)size.width; int h = (int)size.height; - /* Make sure the width/height are oriented correctly */ + // Make sure the width/height are oriented correctly if (isLandscape != (w > h)) { int tmp = w; w = h; @@ -465,7 +465,7 @@ void UIKit_QuitModes(SDL_VideoDevice *_this) [SDL_DisplayWatch stop]; #endif - /* Release Objective-C objects, so higher level doesn't free() them. */ + // Release Objective-C objects, so higher level doesn't free() them. int i, j; @autoreleasepool { for (i = 0; i < _this->num_displays; i++) { @@ -506,7 +506,7 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void) mode->h = height; } - /* Same deal with the fullscreen modes */ + // Same deal with the fullscreen modes for (i = 0; i < display->num_fullscreen_modes; ++i) { mode = &display->fullscreen_modes[i]; if (isLandscape != (mode->w > mode->h)) { @@ -524,11 +524,11 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void) orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED; break; case UIInterfaceOrientationLandscapeLeft: - /* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */ + // Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED; break; case UIInterfaceOrientationLandscapeRight: - /* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */ + // Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 orientation = SDL_ORIENTATION_LANDSCAPE; break; default: @@ -537,6 +537,6 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void) SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation, 0); } } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitopengles.h b/src/video/uikit/SDL_uikitopengles.h index 27f9f43104..3fd3328693 100644 --- a/src/video/uikit/SDL_uikitopengles.h +++ b/src/video/uikit/SDL_uikitopengles.h @@ -37,4 +37,4 @@ extern void UIKit_GL_RestoreCurrentContext(void); #endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 -#endif /* SDL_uikitopengles_ */ +#endif // SDL_uikitopengles_ diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index 30a6e7c041..8ede945a0c 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -35,7 +35,7 @@ @interface SDLEAGLContext : EAGLContext -/* The OpenGL ES context owns a view / drawable. */ +// The OpenGL ES context owns a view / drawable. @property(nonatomic, strong) SDL_uikitopenglview *sdlView; @end @@ -95,7 +95,7 @@ int UIKit_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) SDLEAGLContext *context = (__bridge SDLEAGLContext *)SDL_GL_GetCurrentContext(); #ifdef SDL_POWER_UIKIT - /* Check once a frame to see if we should turn off the battery monitor. */ + // Check once a frame to see if we should turn off the battery monitor. SDL_UIKit_UpdateBatteryMonitoring(); #endif @@ -125,7 +125,7 @@ SDL_GLContext UIKit_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) * versions. */ EAGLRenderingAPI api = major; - /* iOS currently doesn't support GLES >3.0. */ + // iOS currently doesn't support GLES >3.0. if (major > 3 || (major == 3 && minor > 0)) { SDL_SetError("OpenGL ES %d.%d context could not be created", major, minor); return NULL; @@ -153,7 +153,7 @@ SDL_GLContext UIKit_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) return NULL; } - /* construct our view, passing in SDL's OpenGL configuration data */ + // construct our view, passing in SDL's OpenGL configuration data view = [[SDL_uikitopenglview alloc] initWithFrame:frame scale:scale retainBacking:_this->gl_config.retained_backing @@ -176,7 +176,7 @@ SDL_GLContext UIKit_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER, view.drawableRenderbuffer); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER, view.msaaResolveFramebuffer); - /* The context owns the view / drawable. */ + // The context owns the view / drawable. context.sdlView = view; if (UIKit_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0) { @@ -218,4 +218,4 @@ void UIKit_GL_RestoreCurrentContext(void) } } -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h index 48a51cd95a..2c9f966be3 100644 --- a/src/video/uikit/SDL_uikitopenglview.h +++ b/src/video/uikit/SDL_uikitopenglview.h @@ -45,7 +45,7 @@ @property(nonatomic, readonly, weak) EAGLContext *context; -/* The width and height of the drawable in pixels (as opposed to points.) */ +// The width and height of the drawable in pixels (as opposed to points.) @property(nonatomic, readonly) int backingWidth; @property(nonatomic, readonly) int backingHeight; diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 965a86d894..1859c8d358 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -29,21 +29,21 @@ @implementation SDL_uikitopenglview { - /* The renderbuffer and framebuffer used to render to this layer. */ + // The renderbuffer and framebuffer used to render to this layer. GLuint viewRenderbuffer, viewFramebuffer; - /* The depth buffer that is attached to viewFramebuffer, if it exists. */ + // The depth buffer that is attached to viewFramebuffer, if it exists. GLuint depthRenderbuffer; GLenum colorBufferFormat; - /* format of depthRenderbuffer */ + // format of depthRenderbuffer GLenum depthBufferFormat; - /* The framebuffer and renderbuffer used for rendering with MSAA. */ + // The framebuffer and renderbuffer used for rendering with MSAA. GLuint msaaFramebuffer, msaaRenderbuffer; - /* The number of MSAA samples. */ + // The number of MSAA samples. int samples; BOOL retainedBacking; @@ -89,7 +89,7 @@ GLint maxsamples = 0; glGetIntegerv(GL_MAX_SAMPLES, &maxsamples); - /* Clamp the samples to the max supported count. */ + // Clamp the samples to the max supported count. samples = SDL_min(samples, maxsamples); } @@ -97,11 +97,11 @@ colorFormat = kEAGLColorFormatSRGBA8; colorBufferFormat = GL_SRGB8_ALPHA8; } else if (rBits >= 8 || gBits >= 8 || bBits >= 8 || aBits > 0) { - /* if user specifically requests rbg888 or some color format higher than 16bpp */ + // if user specifically requests rbg888 or some color format higher than 16bpp colorFormat = kEAGLColorFormatRGBA8; colorBufferFormat = GL_RGBA8; } else { - /* default case (potentially faster) */ + // default case (potentially faster) colorFormat = kEAGLColorFormatRGB565; colorBufferFormat = GL_RGB565; } @@ -114,10 +114,10 @@ kEAGLDrawablePropertyColorFormat : colorFormat }; - /* Set the appropriate scale (for retina display support) */ + // Set the appropriate scale (for retina display support) self.contentScaleFactor = scale; - /* Create the color Renderbuffer Object */ + // Create the color Renderbuffer Object glGenRenderbuffers(1, &viewRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); @@ -126,11 +126,11 @@ return nil; } - /* Create the Framebuffer Object */ + // Create the Framebuffer Object glGenFramebuffers(1, &viewFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer); - /* attach the color renderbuffer to the FBO */ + // attach the color renderbuffer to the FBO glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer); glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth); @@ -157,7 +157,7 @@ if (useDepthBuffer || useStencilBuffer) { if (useStencilBuffer) { - /* Apparently you need to pack stencil and depth into one buffer. */ + // Apparently you need to pack stencil and depth into one buffer. depthBufferFormat = GL_DEPTH24_STENCIL8_OES; } else if (useDepthBuffer) { /* iOS only uses 32-bit float (exposed as fixed point 24-bit) @@ -202,7 +202,7 @@ - (GLuint)drawableFramebuffer { - /* When MSAA is used, the MSAA draw framebuffer is used for drawing. */ + // When MSAA is used, the MSAA draw framebuffer is used for drawing. if (msaaFramebuffer) { return msaaFramebuffer; } else { @@ -292,7 +292,7 @@ glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST); if (!retainedBacking) { - /* Discard the contents of the MSAA drawable color buffer. */ + // Discard the contents of the MSAA drawable color buffer. glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 1, attachments); } } else { @@ -321,7 +321,7 @@ 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. */ + // Update the color and depth buffer storage if the layer size has changed. if (width != backingWidth || height != backingHeight) { EAGLContext *prevContext = [EAGLContext currentContext]; if (prevContext != context) { @@ -374,4 +374,4 @@ @end -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index b57e0a6f60..d82f231246 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -39,7 +39,7 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window); CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen); #endif -#endif /* __OBJC__ */ +#endif // __OBJC__ int UIKit_SuspendScreenSaver(SDL_VideoDevice *_this); @@ -49,4 +49,4 @@ SDL_bool UIKit_IsSystemVersionAtLeast(double version); SDL_SystemTheme UIKit_GetSystemTheme(void); -#endif /* SDL_uikitvideo_h_ */ +#endif // SDL_uikitvideo_h_ diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 827a7f2163..d58ef68f84 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -44,11 +44,11 @@ @end -/* Initialization/Query functions */ +// Initialization/Query functions static int UIKit_VideoInit(SDL_VideoDevice *_this); static void UIKit_VideoQuit(SDL_VideoDevice *_this); -/* DUMMY driver bootstrap functions */ +// DUMMY driver bootstrap functions static void UIKit_DeleteDevice(SDL_VideoDevice *device) { @@ -66,7 +66,7 @@ static SDL_VideoDevice *UIKit_CreateDevice(void) SDL_VideoDevice *device; SDL_UIKitVideoData *data; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; @@ -77,7 +77,7 @@ static SDL_VideoDevice *UIKit_CreateDevice(void) device->internal = (SDL_VideoData *)CFBridgingRetain(data); device->system_theme = UIKit_GetSystemTheme(); - /* Set the function pointers */ + // Set the function pointers device->VideoInit = UIKit_VideoInit; device->VideoQuit = UIKit_VideoQuit; device->GetDisplayModes = UIKit_GetDisplayModes; @@ -107,7 +107,7 @@ static SDL_VideoDevice *UIKit_CreateDevice(void) device->GetClipboardText = UIKit_GetClipboardText; device->HasClipboardText = UIKit_HasClipboardText; - /* OpenGL (ES) functions */ + // OpenGL (ES) functions #if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) device->GL_MakeCurrent = UIKit_GL_MakeCurrent; device->GL_SwapWindow = UIKit_GL_SwapWindow; @@ -177,7 +177,7 @@ int UIKit_SuspendScreenSaver(SDL_VideoDevice *_this) @autoreleasepool { UIApplication *app = [UIApplication sharedApplication]; - /* Prevent the display from dimming and going to sleep. */ + // Prevent the display from dimming and going to sleep. app.idleTimerDisabled = (_this->suspend_screensaver != SDL_FALSE); } return 0; @@ -253,7 +253,7 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen) void UIKit_ForceUpdateHomeIndicator(void) { #ifndef SDL_PLATFORM_TVOS - /* Force the main SDL window to re-evaluate home indicator state */ + // Force the main SDL window to re-evaluate home indicator state SDL_Window *focus = SDL_GetKeyboardFocus(); if (focus) { SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)focus->internal; @@ -267,7 +267,7 @@ void UIKit_ForceUpdateHomeIndicator(void) #pragma clang diagnostic pop } } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS } /* @@ -294,7 +294,7 @@ void SDL_NSLog(const char *prefix, const char *text) } } } -#endif /* SDL_VIDEO_DRIVER_COCOA */ +#endif // SDL_VIDEO_DRIVER_COCOA /* * iOS Tablet detection @@ -307,4 +307,4 @@ SDL_bool SDL_IsIPad(void) return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); } -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 8b4c66e17e..c32a2eb470 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -33,10 +33,10 @@ #include "SDL_uikitmodes.h" #include "SDL_uikitwindow.h" -/* The maximum number of mouse buttons we support */ +// The maximum number of mouse buttons we support #define MAX_MOUSE_BUTTONS 5 -/* This is defined in SDL_sysjoystick.m */ +// This is defined in SDL_sysjoystick.m #ifndef SDL_JOYSTICK_DISABLED extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif @@ -53,7 +53,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; { if ((self = [super initWithFrame:frame])) { #ifdef SDL_PLATFORM_TVOS - /* Apple TV Remote touchpad swipe gestures. */ + // Apple TV Remote touchpad swipe gestures. UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; swipeUp.direction = UISwipeGestureRecognizerDirectionUp; [self addGestureRecognizer:swipeUp]; @@ -100,7 +100,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; return; } - /* Remove ourself from the old window. */ + // Remove ourself from the old window. if (sdlwindow) { SDL_uikitview *view = nil; data = (__bridge SDL_UIKitWindowData *)sdlwindow->internal; @@ -109,7 +109,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; [self removeFromSuperview]; - /* Restore the next-oldest view in the old window. */ + // Restore the next-oldest view in the old window. view = data.views.lastObject; data.viewcontroller.view = view; @@ -122,14 +122,14 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; sdlwindow = window; - /* Add ourself to the new window. */ + // Add ourself to the new window. if (window) { data = (__bridge SDL_UIKitWindowData *)window->internal; - /* Make sure the SDL window has a strong reference to this view. */ + // Make sure the SDL window has a strong reference to this view. [data.views addObject:self]; - /* Replace the view controller's old view with this one. */ + // Replace the view controller's old view with this one. [data.viewcontroller.view removeFromSuperview]; data.viewcontroller.view = self; @@ -176,7 +176,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; return [UIPointerStyle hiddenPointerStyle]; } } -#endif /* !defined(SDL_PLATFORM_TVOS) && __IPHONE_13_4 */ +#endif // !defined(SDL_PLATFORM_TVOS) && __IPHONE_13_4 - (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch { @@ -272,7 +272,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; continue; } - /* FIXME, need to send: int clicks = (int) touch.tapCount; ? */ + // FIXME, need to send: int clicks = (int) touch.tapCount; ? CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), @@ -328,7 +328,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; continue; } - /* FIXME, need to send: int clicks = (int) touch.tapCount; ? */ + // FIXME, need to send: int clicks = (int) touch.tapCount; ? CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), @@ -351,7 +351,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4) if (@available(iOS 13.4, *)) { if (touch.type == UITouchTypeIndirectPointer) { - /* Already handled in pointerInteraction callback */ + // Already handled in pointerInteraction callback handled = YES; } } @@ -397,7 +397,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif #ifndef SDL_JOYSTICK_DISABLED - /* Presses from Apple TV remote */ + // Presses from Apple TV remote if (!SDL_AppleTVRemoteOpenedAsJoystick) { switch (press.type) { case UIPressTypeUpArrow: @@ -409,19 +409,19 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; case UIPressTypeRightArrow: return SDL_SCANCODE_RIGHT; case UIPressTypeSelect: - /* HIG says: "primary button behavior" */ + // HIG says: "primary button behavior" return SDL_SCANCODE_RETURN; case UIPressTypeMenu: - /* HIG says: "returns to previous screen" */ + // HIG says: "returns to previous screen" return SDL_SCANCODE_ESCAPE; case UIPressTypePlayPause: - /* HIG says: "secondary button behavior" */ + // HIG says: "secondary button behavior" return SDL_SCANCODE_PAUSE; default: break; } } -#endif /* !SDL_JOYSTICK_DISABLED */ +#endif // !SDL_JOYSTICK_DISABLED return SDL_SCANCODE_UNKNOWN; } @@ -467,18 +467,18 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; - (void)pressesChanged:(NSSet *)presses withEvent:(UIPressesEvent *)event { - /* This is only called when the force of a press changes. */ + // This is only called when the force of a press changes. if (SDL_TextInputActive(sdlwindow)) { [super pressesChanged:presses withEvent:event]; } } -#endif /* defined(SDL_PLATFORM_TVOS) || defined(__IPHONE_9_1) */ +#endif // defined(SDL_PLATFORM_TVOS) || defined(__IPHONE_9_1) #ifdef SDL_PLATFORM_TVOS - (void)swipeGesture:(UISwipeGestureRecognizer *)gesture { - /* Swipe gestures don't trigger begin states. */ + // Swipe gestures don't trigger begin states. if (gesture.state == UIGestureRecognizerStateEnded) { #ifndef SDL_JOYSTICK_DISABLED if (!SDL_AppleTVRemoteOpenedAsJoystick) { @@ -499,11 +499,11 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; break; } } -#endif /* !SDL_JOYSTICK_DISABLED */ +#endif // !SDL_JOYSTICK_DISABLED } } -#endif /* SDL_PLATFORM_TVOS */ +#endif // SDL_PLATFORM_TVOS @end -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index db85b25339..97e7b290c3 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -188,9 +188,9 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char - (void)doLoop:(CADisplayLink *)sender { - /* Don't run the game loop while a messagebox is up */ + // Don't run the game loop while a messagebox is up if (!UIKit_ShowingMessageBox()) { - /* See the comment in the function definition. */ + // See the comment in the function definition. #if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) UIKit_GL_RestoreCurrentContext(); #endif @@ -201,7 +201,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char - (void)loadView { - /* Do nothing. */ + // Do nothing. } - (void)viewDidLayoutSubviews @@ -244,7 +244,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char } } - /* By default, fullscreen and borderless windows get all screen gestures */ + // By default, fullscreen and borderless windows get all screen gestures if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) != 0) { return UIRectEdgeAll; } else { @@ -257,7 +257,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char return SDL_GCMouseRelativeMode() ? YES : NO; } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS /* ---- Keyboard related functionality below this line ---- @@ -268,13 +268,13 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char @synthesize keyboardHeight; @synthesize keyboardVisible; -/* Set ourselves up as a UITextFieldDelegate */ +// Set ourselves up as a UITextFieldDelegate - (void)initKeyboard { - obligateForBackspace = @" "; /* 64 space */ + obligateForBackspace = @" "; // 64 space textField = [[SDLUITextField alloc] initWithFrame:CGRectZero]; textField.delegate = self; - /* placeholder so there is something to delete! */ + // placeholder so there is something to delete! textField.text = obligateForBackspace; committedText = textField.text; @@ -481,7 +481,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char } } -/* reveal onscreen virtual keyboard */ +// reveal onscreen virtual keyboard - (void)showKeyboard { if (keyboardVisible) { @@ -495,7 +495,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char } } -/* hide onscreen virtual keyboard */ +// hide onscreen virtual keyboard - (void)hideKeyboard { if (!keyboardVisible) { @@ -565,7 +565,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char NSUInteger compareLength = SDL_min(textField.text.length, committedText.length); NSUInteger matchLength; - /* Backspace over characters that are no longer in the string */ + // Backspace over characters that are no longer in the string for (matchLength = 0; matchLength < compareLength; ++matchLength) { if ([committedText characterAtIndex:matchLength] != [textField.text characterAtIndex:matchLength]) { break; @@ -574,7 +574,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char if (matchLength < committedText.length) { size_t deleteLength = SDL_utf8strlen([[committedText substringFromIndex:matchLength] UTF8String]); while (deleteLength > 0) { - /* Send distinct down and up events for each backspace action */ + // Send distinct down and up events for each backspace action SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, SDL_PRESSED); SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, SDL_RELEASED); --deleteLength; @@ -623,7 +623,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char t.ty = 0.0; offset = CGPointApplyAffineTransform(offset, t); - /* Apply the updated offset to the view's frame. */ + // Apply the updated offset to the view's frame. frame.origin.x += offset.x; frame.origin.y += offset.y; @@ -637,7 +637,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char [self updateKeyboard]; } -/* UITextFieldDelegate method. Invoked when user types something. */ +// UITextFieldDelegate method. Invoked when user types something. - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField.markedTextRange == nil) { @@ -649,7 +649,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char return YES; } -/* Terminates the editing session */ +// Terminates the editing session - (BOOL)textFieldShouldReturn:(UITextField *)_textField { SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN); @@ -664,7 +664,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char @end -/* iPhone keyboard addition functions */ +// iPhone keyboard addition functions #ifdef SDL_IPHONE_KEYBOARD static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window *window) @@ -727,6 +727,6 @@ int UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -#endif /* SDL_IPHONE_KEYBOARD */ +#endif // SDL_IPHONE_KEYBOARD -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/uikit/SDL_uikitvulkan.h b/src/video/uikit/SDL_uikitvulkan.h index 29c20f4754..506fc14096 100644 --- a/src/video/uikit/SDL_uikitvulkan.h +++ b/src/video/uikit/SDL_uikitvulkan.h @@ -50,4 +50,4 @@ void UIKit_Vulkan_DestroySurface(SDL_VideoDevice *_this, #endif -#endif /* SDL_uikitvulkan_h_ */ +#endif // SDL_uikitvulkan_h_ diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m index 9d045535a6..d56cdf7153 100644 --- a/src/video/uikit/SDL_uikitvulkan.m +++ b/src/video/uikit/SDL_uikitvulkan.m @@ -57,13 +57,13 @@ int UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan Portability library is already loaded."); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } if (!path) { - /* Handle the case where Vulkan Portability is linked statically. */ + // Handle the case where Vulkan Portability is linked statically. vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, "vkGetInstanceProcAddr"); @@ -81,7 +81,7 @@ int UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) paths = &path; numPaths = 1; } else { - /* Look for the .dylib packaged with the application instead. */ + // Look for the .dylib packaged with the application instead. paths = defaultPaths; numPaths = SDL_arraysize(defaultPaths); } @@ -258,7 +258,7 @@ void UIKit_Vulkan_DestroySurface(SDL_VideoDevice *_this, { if (_this->vulkan_config.loader_handle) { SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); - /* TODO: Add CFBridgingRelease(metalview) here perhaps? */ + // TODO: Add CFBridgingRelease(metalview) here perhaps? } } diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index bb34f15b00..2f085f0691 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -48,9 +48,9 @@ extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window); @property(nonatomic, strong) UIWindow *uiwindow; @property(nonatomic, strong) SDL_uikitviewcontroller *viewcontroller; -/* Array of SDL_uikitviews owned by this window. */ +// Array of SDL_uikitviews owned by this window. @property(nonatomic, copy) NSMutableArray *views; @end -#endif /* SDL_uikitwindow_h_ */ +#endif // SDL_uikitwindow_h_ diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 9102de5f7e..1e108d5e9a 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -64,7 +64,7 @@ - (void)layoutSubviews { #ifndef SDL_PLATFORM_VISIONOS - /* Workaround to fix window orientation issues in iOS 8. */ + // Workaround to fix window orientation issues in iOS 8. /* As of July 1 2019, I haven't been able to reproduce any orientation * issues with this disabled on iOS 12. The issue this is meant to fix might * only happen on iOS 8, or it might have been fixed another way with other @@ -105,9 +105,9 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow #ifndef SDL_PLATFORM_VISIONOS 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. } #endif @@ -117,16 +117,16 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown)) != 0; - /* Make sure the width/height are oriented correctly */ + // Make sure the width/height are oriented correctly if ((width > height && !supportsLandscape) || (height > width && !supportsPortrait)) { int temp = width; width = height; height = temp; } } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS -#if 0 /* Don't set the x/y position, it's already placed on a display */ +#if 0 // Don't set the x/y position, it's already placed on a display window->x = 0; window->y = 0; #endif @@ -159,7 +159,7 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; SDL_Window *other; - /* We currently only handle a single window per display on iOS */ + // We currently only handle a single window per display on iOS for (other = _this->windows; other; other = other->next) { if (other != window && SDL_GetVideoDisplayForWindow(other) == display) { return SDL_SetError("Only one window allowed per display."); @@ -195,17 +195,17 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie [UIApplication sharedApplication].statusBarHidden = NO; } } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS - /* ignore the size user requested, and make a fullscreen window */ - /* !!! FIXME: can we have a smaller view? */ + // ignore the size user requested, and make a fullscreen window + // !!! FIXME: can we have a smaller view? #ifdef SDL_PLATFORM_VISIONOS UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:CGRectMake(window->x, window->y, window->w, window->h)]; #else UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds]; #endif - /* put the window on an external display if appropriate. */ + // put the window on an external display if appropriate. #ifndef SDL_PLATFORM_VISIONOS if (data.uiscreen != [UIScreen mainScreen]) { [uiwindow setScreen:data.uiscreen]; @@ -234,7 +234,7 @@ void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; [data.uiwindow makeKeyAndVisible]; - /* Make this window the current mouse focus for touch input */ + // Make this window the current mouse focus for touch input SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->internal; #ifndef SDL_PLATFORM_VISIONOS @@ -280,12 +280,12 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window) [viewcontroller setNeedsStatusBarAppearanceUpdate]; } - /* Update the view's frame to account for the status bar change. */ + // Update the view's frame to account for the status bar change. viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS #ifdef SDL_IPHONE_KEYBOARD - /* Make sure the view is offset correctly when the keyboard is visible. */ + // Make sure the view is offset correctly when the keyboard is visible. [viewcontroller updateKeyboard]; #endif @@ -325,8 +325,8 @@ void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window) [viewcontroller setNeedsUpdateOfPrefersPointerLocked]; } } -#endif /* defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 */ -#endif /* !SDL_PLATFORM_TVOS */ +#endif // defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 +#endif // !SDL_PLATFORM_TVOS } void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) @@ -422,7 +422,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window) } if (orientationMask == 0 && (window->flags & SDL_WINDOW_RESIZABLE)) { - /* any orientation is okay. */ + // any orientation is okay. orientationMask = UIInterfaceOrientationMaskAll; } @@ -435,7 +435,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window) } } - /* Don't allow upside-down orientation on phones, so answering calls is in the natural orientation */ + // Don't allow upside-down orientation on phones, so answering calls is in the natural orientation if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown; } @@ -450,7 +450,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window) return orientationMask; } -#endif /* !SDL_PLATFORM_TVOS */ +#endif // !SDL_PLATFORM_TVOS int SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam) { @@ -468,4 +468,4 @@ int SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimati return 0; } -#endif /* SDL_VIDEO_DRIVER_UIKIT */ +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/src/video/vita/SDL_vitaframebuffer.c b/src/video/vita/SDL_vitaframebuffer.c index 5c4e5db5f2..6ceda93b54 100644 --- a/src/video/vita/SDL_vitaframebuffer.c +++ b/src/video/vita/SDL_vitaframebuffer.c @@ -104,7 +104,7 @@ void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; if (!data) { - /* The window wasn't fully initialized */ + // The window wasn't fully initialized return; } @@ -113,4 +113,4 @@ void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) return; } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index 886a0a0f3c..72c77ba9e6 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -33,7 +33,7 @@ #define MAX_PATH 256 // vita limits are somehow wrong -/* Defaults */ +// Defaults static int FB_WIDTH = 960; static int FB_HEIGHT = 544; @@ -88,7 +88,7 @@ SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) int temp_minor = _this->gl_config.minor_version; int temp_profile = _this->gl_config.profile_mask; - /* Set version to 2.0 and PROFILE to ES */ + // Set version to 2.0 and PROFILE to ES _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; @@ -101,12 +101,12 @@ SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) set_getprocaddress((void *(*)(const char *))eglGetProcAddress); set_getmainfbsize(getFBSize); SDL_snprintf(gl_version, 3, "%d%d", temp_major, temp_minor); - gl4es_setenv("LIBGL_NOTEXRECT", "1", 1); /* Currently broken in driver */ + gl4es_setenv("LIBGL_NOTEXRECT", "1", 1); // Currently broken in driver gl4es_setenv("LIBGL_GL", gl_version, 1); initialize_gl4es(); } - /* Restore gl_config */ + // Restore gl_config _this->gl_config.major_version = temp_major; _this->gl_config.minor_version = temp_minor; _this->gl_config.profile_mask = temp_profile; @@ -119,4 +119,4 @@ SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *p return gl4es_GetProcAddress(proc); } -#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */ +#endif // SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR diff --git a/src/video/vita/SDL_vitagl_pvr_c.h b/src/video/vita/SDL_vitagl_pvr_c.h index 2b9444c6a6..2149039b47 100644 --- a/src/video/vita/SDL_vitagl_pvr_c.h +++ b/src/video/vita/SDL_vitagl_pvr_c.h @@ -28,4 +28,4 @@ extern SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *w extern int VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); -#endif /* SDL_vitagl_pvr_c_h_ */ +#endif // SDL_vitagl_pvr_c_h_ diff --git a/src/video/vita/SDL_vitagles.c b/src/video/vita/SDL_vitagles.c index b68a267c9c..51600a38fc 100644 --- a/src/video/vita/SDL_vitagles.c +++ b/src/video/vita/SDL_vitagles.c @@ -28,7 +28,7 @@ #include "SDL_vitagles_c.h" /*****************************************************************************/ -/* SDL OpenGL/OpenGL ES functions */ +// SDL OpenGL/OpenGL ES functions /*****************************************************************************/ #define EGLCHK(stmt) \ do { \ @@ -169,11 +169,11 @@ int VITA_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) EGLBoolean status; status = eglSwapInterval(_this->gl_data->display, interval); if (status == EGL_TRUE) { - /* Return success to upper level */ + // Return success to upper level _this->gl_data->swapinterval = interval; return 0; } - /* Failed to set swap interval */ + // Failed to set swap interval return SDL_SetError("Unable to set the EGL swap interval"); } @@ -200,12 +200,12 @@ int VITA_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support"); } - /* Check if OpenGL ES connection has been initialized */ + // Check if OpenGL ES connection has been initialized if (_this->gl_data->display != EGL_NO_DISPLAY) { if (context != EGL_NO_CONTEXT) { status = eglDestroyContext(_this->gl_data->display, context); if (status != EGL_TRUE) { - /* Error during OpenGL ES context destroying */ + // Error during OpenGL ES context destroying return SDL_SetError("VITA: OpenGL ES context destroy error"); } } @@ -214,4 +214,4 @@ int VITA_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitagles_c.h b/src/video/vita/SDL_vitagles_c.h index d2e89a2b3f..750d2bbf7a 100644 --- a/src/video/vita/SDL_vitagles_c.h +++ b/src/video/vita/SDL_vitagles_c.h @@ -50,4 +50,4 @@ extern void VITA_GLES_UnloadLibrary(SDL_VideoDevice *_this); extern int VITA_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); extern int VITA_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); -#endif /* SDL_vitagles_c_h_ */ +#endif // SDL_vitagles_c_h_ diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index acc9ba8f3d..0e69a96e98 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -89,4 +89,4 @@ int VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) return SDL_EGL_SwapBuffers(_this, window->internal->egl_surface); } -#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */ +#endif // SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR diff --git a/src/video/vita/SDL_vitagles_pvr_c.h b/src/video/vita/SDL_vitagles_pvr_c.h index d738e1da6f..9023966eaf 100644 --- a/src/video/vita/SDL_vitagles_pvr_c.h +++ b/src/video/vita/SDL_vitagles_pvr_c.h @@ -29,4 +29,4 @@ extern int VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern int VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); -#endif /* SDL_vitagles_pvr_c_h_ */ +#endif // SDL_vitagles_pvr_c_h_ diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c index 4c5a4bea6f..4502192569 100644 --- a/src/video/vita/SDL_vitakeyboard.c +++ b/src/video/vita/SDL_vitakeyboard.c @@ -187,4 +187,4 @@ void VITA_PollKeyboard(void) } } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitakeyboard.h b/src/video/vita/SDL_vitakeyboard.h index d5fa224f7a..a47ac5ffff 100644 --- a/src/video/vita/SDL_vitakeyboard.h +++ b/src/video/vita/SDL_vitakeyboard.h @@ -24,8 +24,8 @@ #include "SDL_internal.h" -/* Keyboard functions */ +// Keyboard functions extern void VITA_InitKeyboard(void); extern void VITA_PollKeyboard(void); -#endif /* SDL_vitakeyboard_h */ +#endif // SDL_vitakeyboard_h diff --git a/src/video/vita/SDL_vitamessagebox.c b/src/video/vita/SDL_vitamessagebox.c index b6b9b748f4..609155b2ba 100644 --- a/src/video/vita/SDL_vitamessagebox.c +++ b/src/video/vita/SDL_vitamessagebox.c @@ -28,7 +28,7 @@ #if SDL_VIDEO_RENDER_VITA_GXM #include "../../render/vitagxm/SDL_render_vita_gxm_tools.h" -#endif /* SDL_VIDEO_RENDER_VITA_GXM */ +#endif // SDL_VIDEO_RENDER_VITA_GXM int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { @@ -122,4 +122,4 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) #endif } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitamessagebox.h b/src/video/vita/SDL_vitamessagebox.h index 5b09953395..7f23cb5b1c 100644 --- a/src/video/vita/SDL_vitamessagebox.h +++ b/src/video/vita/SDL_vitamessagebox.h @@ -26,6 +26,6 @@ extern int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA -#endif /* SDL_vitamessagebox_h_ */ +#endif // SDL_vitamessagebox_h_ diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c index dfac1601f0..25fb610c2a 100644 --- a/src/video/vita/SDL_vitamouse.c +++ b/src/video/vita/SDL_vitamouse.c @@ -86,4 +86,4 @@ void VITA_PollMouse(void) } } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitamouse_c.h b/src/video/vita/SDL_vitamouse_c.h index 8efb8c0f68..c05c7785c5 100644 --- a/src/video/vita/SDL_vitamouse_c.h +++ b/src/video/vita/SDL_vitamouse_c.h @@ -24,8 +24,8 @@ #include "SDL_internal.h" -/* mouse functions */ +// mouse functions extern void VITA_InitMouse(void); extern void VITA_PollMouse(void); -#endif /* SDL_vitamouse_h */ +#endif // SDL_vitamouse_h diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index aab16cc5dc..94dee65bbd 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -183,4 +183,4 @@ void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita *sdl_y = y; } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitatouch.h b/src/video/vita/SDL_vitatouch.h index 5986f8dce9..f33f5ff420 100644 --- a/src/video/vita/SDL_vitatouch.h +++ b/src/video/vita/SDL_vitatouch.h @@ -24,10 +24,10 @@ #include "SDL_internal.h" -/* Touch functions */ +// Touch functions extern void VITA_InitTouch(void); extern void VITA_QuitTouch(void); extern void VITA_PollTouch(void); void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port); -#endif /* SDL_vitatouch_h */ +#endif // SDL_vitatouch_h diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index 3c6654c9b1..de784f2a57 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -23,12 +23,12 @@ #ifdef SDL_VIDEO_DRIVER_VITA -/* SDL internals */ +// SDL internals #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" -/* VITA declarations */ +// VITA declarations #include #include "SDL_vitavideo.h" #include "SDL_vitatouch.h" @@ -66,13 +66,13 @@ static SDL_VideoDevice *VITA_Create(void) #ifdef SDL_VIDEO_VITA_PIB SDL_GLDriverData *gldata; #endif - /* Initialize SDL_VideoDevice structure */ + // Initialize SDL_VideoDevice structure device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal VITA specific data */ + // Initialize internal VITA specific data phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!phdata) { SDL_free(device); @@ -93,13 +93,13 @@ static SDL_VideoDevice *VITA_Create(void) device->internal = phdata; - /* Setup amount of available displays and current display */ + // Setup amount of available displays and current display device->num_displays = 0; - /* Set device free function */ + // Set device free function device->free = VITA_Destroy; - /* Setup all functions which we can handle */ + // Setup all functions which we can handle device->VideoInit = VITA_VideoInit; device->VideoQuit = VITA_VideoQuit; device->CreateSDLWindow = VITA_CreateWindow; @@ -164,7 +164,7 @@ VideoBootStrap VITA_bootstrap = { }; /*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ +// SDL Video and Display initialization/handling functions /*****************************************************************************/ int VITA_VideoInit(SDL_VideoDevice *_this) { @@ -176,18 +176,18 @@ int VITA_VideoInit(SDL_VideoDevice *_this) #ifdef SDL_VIDEO_VITA_PVR if (res) { - /* 1088i for PSTV (Or Sharpscale) */ + // 1088i for PSTV (Or Sharpscale) if (SDL_strncmp(res, "1080", 4) == 0) { mode.w = 1920; mode.h = 1088; } - /* 725p for PSTV (Or Sharpscale) */ + // 725p for PSTV (Or Sharpscale) else if (SDL_strncmp(res, "720", 3) == 0) { mode.w = 1280; mode.h = 725; } } - /* 544p */ + // 544p else { #endif mode.w = 960; @@ -198,7 +198,7 @@ int VITA_VideoInit(SDL_VideoDevice *_this) mode.refresh_rate = 60.0f; - /* 32 bpp for default */ + // 32 bpp for default mode.format = SDL_PIXELFORMAT_ABGR8888; if (SDL_AddBasicVideoDisplay(&mode) == 0) { @@ -227,13 +227,13 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties int temp_profile = 0; #endif - /* Allocate window internal data */ + // Allocate window internal data wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!wdata) { return -1; } - /* Setup driver data for this window */ + // Setup driver data for this window window->internal = wdata; // Vita can only have one window @@ -248,22 +248,22 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties win.numFlipBuffers = 2; win.flipChainThrdAffinity = 0x20000; - /* 1088i for PSTV (Or Sharpscale) */ + // 1088i for PSTV (Or Sharpscale) if (window->w == 1920) { win.windowSize = PSP2_WINDOW_1920X1088; } - /* 725p for PSTV (Or Sharpscale) */ + // 725p for PSTV (Or Sharpscale) else if (window->w == 1280) { win.windowSize = PSP2_WINDOW_1280X725; } - /* 544p */ + // 544p else { win.windowSize = PSP2_WINDOW_960X544; } if (window->flags & SDL_WINDOW_OPENGL) { SDL_bool use_opengl = SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, SDL_FALSE); if (use_opengl) { - /* Set version to 2.1 and PROFILE to ES */ + // 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; @@ -277,7 +277,7 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties return SDL_SetError("Could not create GLES window surface"); } if (use_opengl) { - /* Revert */ + // Revert _this->gl_config.major_version = temp_major; _this->gl_config.minor_version = temp_minor; _this->gl_config.profile_mask = temp_profile; @@ -288,7 +288,7 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties // fix input, we need to find a better way SDL_SetKeyboardFocus(window); - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -588,4 +588,4 @@ void VITA_PumpEvents(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_VITA */ +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h index 61aa6646fa..a9956b3c0d 100644 --- a/src/video/vita/SDL_vitavideo.h +++ b/src/video/vita/SDL_vitavideo.h @@ -33,8 +33,8 @@ 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; @@ -54,10 +54,10 @@ struct SDL_WindowData extern SDL_Window *Vita_Window; /****************************************************************************/ -/* SDL_VideoDevice functions declaration */ +// SDL_VideoDevice functions declaration /****************************************************************************/ -/* Display and window functions */ +// Display and window functions int VITA_VideoInit(SDL_VideoDevice *_this); void VITA_VideoQuit(SDL_VideoDevice *_this); int VITA_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); @@ -77,13 +77,13 @@ void VITA_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); #ifdef SDL_VIDEO_DRIVER_VITA #ifdef SDL_VIDEO_VITA_PVR_OGL -/* OpenGL functions */ +// OpenGL functions int VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); #endif -/* OpenGLES functions */ +// OpenGLES functions int VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_FunctionPointer VITA_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); void VITA_GLES_UnloadLibrary(SDL_VideoDevice *_this); @@ -95,7 +95,7 @@ int VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int VITA_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); #endif -/* VITA on screen keyboard */ +// VITA on screen keyboard SDL_bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void VITA_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); @@ -103,4 +103,4 @@ SDL_bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); void VITA_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_pspvideo_h */ +#endif // SDL_pspvideo_h diff --git a/src/video/vivante/SDL_vivanteopengles.c b/src/video/vivante/SDL_vivanteopengles.c index 67c78e3e92..03592a5857 100644 --- a/src/video/vivante/SDL_vivanteopengles.c +++ b/src/video/vivante/SDL_vivanteopengles.c @@ -25,7 +25,7 @@ #include "SDL_vivanteopengles.h" #include "SDL_vivantevideo.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support int VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { @@ -38,4 +38,4 @@ SDL_EGL_CreateContext_impl(VIVANTE) SDL_EGL_SwapWindow_impl(VIVANTE) SDL_EGL_MakeCurrent_impl(VIVANTE) -#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/vivante/SDL_vivanteopengles.h b/src/video/vivante/SDL_vivanteopengles.h index b73e3c4c64..14a87019d9 100644 --- a/src/video/vivante/SDL_vivanteopengles.h +++ b/src/video/vivante/SDL_vivanteopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute #define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -41,6 +41,6 @@ extern SDL_GLContext VIVANTE_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Wind extern int VIVANTE_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int VIVANTE_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); -#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL -#endif /* SDL_vivanteopengles_h_ */ +#endif // SDL_vivanteopengles_h_ diff --git a/src/video/vivante/SDL_vivanteplatform.c b/src/video/vivante/SDL_vivanteplatform.c index 3ba8c7ddc5..cce23a874f 100644 --- a/src/video/vivante/SDL_vivanteplatform.c +++ b/src/video/vivante/SDL_vivanteplatform.c @@ -44,6 +44,6 @@ void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this) { } -#endif /* VIVANTE_PLATFORM_GENERIC */ +#endif // VIVANTE_PLATFORM_GENERIC -#endif /* SDL_VIDEO_DRIVER_VIVANTE */ +#endif // SDL_VIDEO_DRIVER_VIVANTE diff --git a/src/video/vivante/SDL_vivanteplatform.h b/src/video/vivante/SDL_vivanteplatform.h index 8831e17596..8422583594 100644 --- a/src/video/vivante/SDL_vivanteplatform.h +++ b/src/video/vivante/SDL_vivanteplatform.h @@ -40,6 +40,6 @@ extern char *VIVANTE_GetDisplayName(SDL_VideoDevice *_this); extern void VIVANTE_UpdateDisplayScale(SDL_VideoDevice *_this); extern void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this); -#endif /* SDL_VIDEO_DRIVER_VIVANTE */ +#endif // SDL_VIDEO_DRIVER_VIVANTE -#endif /* SDL_vivanteplatform_h_ */ +#endif // SDL_vivanteplatform_h_ diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index e79caa4987..a4bb94f1ef 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_VIVANTE -/* SDL internals */ +// SDL internals #include "../SDL_sysvideo.h" #include "../../events/SDL_events_c.h" @@ -46,13 +46,13 @@ static SDL_VideoDevice *VIVANTE_Create(void) SDL_VideoDevice *device; SDL_VideoData *data; - /* Initialize SDL_VideoDevice structure */ + // Initialize SDL_VideoDevice structure device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; } - /* Initialize internal data */ + // Initialize internal data data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); if (!data) { SDL_free(device); @@ -61,13 +61,13 @@ static SDL_VideoDevice *VIVANTE_Create(void) device->internal = data; - /* Setup amount of available displays */ + // Setup amount of available displays device->num_displays = 0; - /* Set device free function */ + // Set device free function device->free = VIVANTE_Destroy; - /* Setup all functions which we can handle */ + // Setup all functions which we can handle device->VideoInit = VIVANTE_VideoInit; device->VideoQuit = VIVANTE_VideoQuit; device->CreateSDLWindow = VIVANTE_CreateWindow; @@ -107,11 +107,11 @@ VideoBootStrap VIVANTE_bootstrap = { "vivante", "Vivante EGL Video Driver", VIVANTE_Create, - NULL /* no ShowMessageBox implementation */ + NULL // no ShowMessageBox implementation }; /*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ +// SDL Video and Display initialization/handling functions /*****************************************************************************/ static int VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) @@ -139,10 +139,10 @@ static int VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) videodata->fbGetDisplayInfo(data->native_display, &mode.w, &mode.h, &pixels, &pitch, &bpp); -#endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */ +#endif // SDL_VIDEO_DRIVER_VIVANTE_VDK switch (bpp) { - default: /* Is another format used? */ + default: // Is another format used? case 32: mode.format = SDL_PIXELFORMAT_ARGB8888; break; @@ -150,7 +150,7 @@ static int VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) mode.format = SDL_PIXELFORMAT_RGB565; break; } - /* FIXME: How do we query refresh rate? */ + // FIXME: How do we query refresh rate? mode.refresh_rate = 60.0f; SDL_zero(display); @@ -246,13 +246,13 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay()); - /* Allocate window internal data */ + // Allocate window internal data data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!data) { return -1; } - /* Setup driver data for this window */ + // Setup driver data for this window window->internal = data; SDL_PropertiesID props = SDL_GetWindowProperties(window); @@ -280,7 +280,7 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER, data->egl_surface); #endif - /* Window has been successfully created */ + // Window has been successfully created return 0; } @@ -320,13 +320,13 @@ void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) int VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) { - /* FIXME */ + // FIXME return SDL_Unsupported(); } void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) { - /* FIXME */ + // FIXME } void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) @@ -350,7 +350,7 @@ void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) } /*****************************************************************************/ -/* SDL event functions */ +// SDL event functions /*****************************************************************************/ void VIVANTE_PumpEvents(SDL_VideoDevice *_this) { @@ -359,4 +359,4 @@ void VIVANTE_PumpEvents(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_VIVANTE */ +#endif // SDL_VIDEO_DRIVER_VIVANTE diff --git a/src/video/vivante/SDL_vivantevideo.h b/src/video/vivante/SDL_vivantevideo.h index 038a17103a..adc9e8ab36 100644 --- a/src/video/vivante/SDL_vivantevideo.h +++ b/src/video/vivante/SDL_vivantevideo.h @@ -25,7 +25,7 @@ #include "../SDL_sysvideo.h" -/* Set up definitions for Vivante EGL */ +// Set up definitions for Vivante EGL #include #ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK @@ -39,7 +39,7 @@ struct SDL_VideoData #ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK vdkPrivate vdk_private; #else - void *egl_handle; /* EGL shared library handle */ + 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); @@ -64,10 +64,10 @@ struct SDL_WindowData }; /****************************************************************************/ -/* SDL_VideoDevice functions declaration */ +// SDL_VideoDevice functions declaration /****************************************************************************/ -/* Display and window functions */ +// Display and window functions int VIVANTE_VideoInit(SDL_VideoDevice *_this); void VIVANTE_VideoQuit(SDL_VideoDevice *_this); int VIVANTE_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); @@ -80,7 +80,7 @@ void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* Event functions */ +// Event functions void VIVANTE_PumpEvents(SDL_VideoDevice *_this); -#endif /* SDL_vivantevideo_h_ */ +#endif // SDL_vivantevideo_h_ diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index 8325efff13..8796580346 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -45,16 +45,16 @@ int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } if (!path) { - /* If no path set, try Vivante fb vulkan driver explicitly */ + // If no path set, try Vivante fb vulkan driver explicitly path = "libvulkan-fb.so"; _this->vulkan_config.loader_handle = SDL_LoadObject(path); if (!_this->vulkan_config.loader_handle) { - /* If that couldn't be loaded, fall back to default name */ + // If that couldn't be loaded, fall back to default name path = "libvulkan.so"; _this->vulkan_config.loader_handle = SDL_LoadObject(path); } diff --git a/src/video/vivante/SDL_vivantevulkan.h b/src/video/vivante/SDL_vivantevulkan.h index 3c78f60499..84ad4de43e 100644 --- a/src/video/vivante/SDL_vivantevulkan.h +++ b/src/video/vivante/SDL_vivantevulkan.h @@ -49,4 +49,4 @@ void VIVANTE_Vulkan_DestroySurface(SDL_VideoDevice *_this, #endif -#endif /* SDL_vivantevulkan_h_ */ +#endif // SDL_vivantevulkan_h_ diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index b156fa6d5b..2604b08d79 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -170,4 +170,4 @@ SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this) return result; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandclipboard.h b/src/video/wayland/SDL_waylandclipboard.h index 0209a9bd62..3ebd072eae 100644 --- a/src/video/wayland/SDL_waylandclipboard.h +++ b/src/video/wayland/SDL_waylandclipboard.h @@ -31,4 +31,4 @@ extern int Wayland_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *t extern char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this); extern SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this); -#endif /* SDL_waylandclipboard_h_ */ +#endif // SDL_waylandclipboard_h_ diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index dd0b8aeb71..e062e5f710 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -217,7 +217,7 @@ static size_t Wayland_send_data(const void *data, size_t length, int fd) if (length > 0 && data) { while (write_pipe(fd, data, length, &result) > 0) { - /* Just keep spinning */ + // Just keep spinning } } close(fd); @@ -372,7 +372,7 @@ void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, } else { wl_data_offer_receive(offer->offer, mime_type, pipefd[1]); - /* TODO: Needs pump and flush? */ + // TODO: Needs pump and flush? WAYLAND_wl_display_flush(data_device->video_data->display); close(pipefd[1]); @@ -408,7 +408,7 @@ void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer * } else { zwp_primary_selection_offer_v1_receive(offer->offer, mime_type, pipefd[1]); - /* TODO: Needs pump and flush? */ + // TODO: Needs pump and flush? WAYLAND_wl_display_flush(primary_selection_device->video_data->display); close(pipefd[1]); @@ -529,7 +529,7 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, Wayland_data_device_clear_selection(data_device); status = SDL_SetError("No mime data"); } else { - /* Only set if there is a valid serial if not set it later */ + // Only set if there is a valid serial if not set it later if (data_device->selection_serial != 0) { wl_data_device_set_selection(data_device->data_device, source->source, @@ -570,7 +570,7 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe Wayland_primary_selection_device_clear_selection(primary_selection_device); status = SDL_SetError("No mime data"); } else { - /* Only set if there is a valid serial if not set it later */ + // Only set if there is a valid serial if not set it later if (primary_selection_device->selection_serial != 0) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, source->source, @@ -594,7 +594,7 @@ int Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, if (data_device) { status = 0; - /* If there was no serial and there is a pending selection set it now. */ + // If there was no serial and there is a pending selection set it now. if (data_device->selection_serial == 0 && data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, data_device->selection_source->source, @@ -614,7 +614,7 @@ int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevic if (primary_selection_device) { status = 0; - /* If there was no serial and there is a pending selection set it now. */ + // 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) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, primary_selection_device->selection_source->source, @@ -627,4 +627,4 @@ int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevic return status; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylanddatamanager.h b/src/video/wayland/SDL_waylanddatamanager.h index 6b0f880adc..34deec58d8 100644 --- a/src/video/wayland/SDL_waylanddatamanager.h +++ b/src/video/wayland/SDL_waylanddatamanager.h @@ -81,14 +81,14 @@ typedef struct struct wl_data_device *data_device; SDL_VideoData *video_data; - /* Drag and Drop */ + // Drag and Drop uint32_t drag_serial; SDL_WaylandDataOffer *drag_offer; SDL_WaylandDataOffer *selection_offer; SDL_bool has_mime_file, has_mime_text; SDL_Window *dnd_window; - /* Clipboard and Primary Selection */ + // Clipboard and Primary Selection uint32_t selection_serial; SDL_WaylandDataSource *selection_source; } SDL_WaylandDataDevice; @@ -103,7 +103,7 @@ typedef struct SDL_WaylandPrimarySelectionOffer *selection_offer; } SDL_WaylandPrimarySelectionDevice; -/* Wayland Data Source / Primary Selection Source - (Sending) */ +// Wayland Data Source / Primary Selection Source - (Sending) extern SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this); extern SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_VideoDevice *_this); extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, @@ -126,7 +126,7 @@ extern void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelecti 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) */ +// Wayland Data / Primary Selection Offer - (Receiving) extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, const char *mime_type, size_t *length); @@ -144,7 +144,7 @@ extern int Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionO extern void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer); extern void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer); -/* Clipboard / Primary Selection */ +// Clipboard / Primary Selection extern int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device); extern int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *device); extern int Wayland_data_device_set_selection(SDL_WaylandDataDevice *device, @@ -159,4 +159,4 @@ extern int Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, uint32_t serial); extern int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *device, uint32_t serial); -#endif /* SDL_waylanddatamanager_h_ */ +#endif // SDL_waylanddatamanager_h_ diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index 6cb4061587..117ec954e6 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -73,7 +73,7 @@ static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool requir #endif if (!fn && required) { - *pHasModule = 0; /* kill this module. */ + *pHasModule = 0; // kill this module. } return fn; @@ -83,9 +83,9 @@ static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool requir #include -#endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ +#endif // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC -/* Define all the function pointers and wrappers... */ +// 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_SYM_OPT(rc, fn, params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL; @@ -96,14 +96,14 @@ static int wayland_load_refcount = 0; void SDL_WAYLAND_UnloadSymbols(void) { - /* Don't actually unload if more than one module is using the libs... */ + // 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 int i; #endif - /* set all the function pointers to NULL. */ + // 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_SYM_OPT(rc, fn, params) WAYLAND_##fn = NULL; @@ -122,12 +122,12 @@ void SDL_WAYLAND_UnloadSymbols(void) } } -/* returns non-zero if all needed symbols were loaded. */ +// returns non-zero if all needed symbols were loaded. 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... */ + // deal with multiple modules (dga, wayland, etc) needing these symbols... if (wayland_load_refcount++ == 0) { #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC int i; @@ -138,7 +138,7 @@ int SDL_WAYLAND_LoadSymbols(void) } } -#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ +#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; @@ -151,17 +151,17 @@ int SDL_WAYLAND_LoadSymbols(void) SDL_WAYLAND_HAVE_WAYLAND_CURSOR && SDL_WAYLAND_HAVE_WAYLAND_EGL && SDL_WAYLAND_HAVE_WAYLAND_XKB) { - /* All required symbols loaded, only libdecor is optional. */ + // All required symbols loaded, only libdecor is optional. SDL_ClearError(); } else { - /* in case something got loaded... */ + // in case something got loaded... SDL_WAYLAND_UnloadSymbols(); 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_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; // default yes #define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = fn; #define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = fn; #define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface; @@ -173,4 +173,4 @@ int SDL_WAYLAND_LoadSymbols(void) return rc; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylanddyn.h b/src/video/wayland/SDL_waylanddyn.h index 29e4e0a49d..b7ff68dab4 100644 --- a/src/video/wayland/SDL_waylanddyn.h +++ b/src/video/wayland/SDL_waylanddyn.h @@ -33,7 +33,7 @@ struct wl_display; struct wl_surface; struct wl_shm; -/* We also need some for libdecor */ +// We also need some for libdecor struct wl_seat; struct wl_output; struct libdecor; @@ -52,7 +52,7 @@ enum libdecor_window_state; #include "xkbcommon/xkbcommon.h" #include "xkbcommon/xkbcommon-compose.h" -/* Must be included before our #defines, see Bugzilla #4957 */ +// Must be included before our #defines, see Bugzilla #4957 #include "wayland-client-core.h" #define SDL_WAYLAND_CHECK_VERSION(x, y, z) \ @@ -137,7 +137,7 @@ void SDL_WAYLAND_UnloadSymbols(void); #include "wayland-egl.h" #ifdef HAVE_LIBDECOR_H -/* Must be included before our defines */ +// Must be included before our defines #include #define libdecor_unref (*WAYLAND_libdecor_unref) @@ -177,7 +177,7 @@ void SDL_WAYLAND_UnloadSymbols(void); #define libdecor_dispatch (*WAYLAND_libdecor_dispatch) #endif -#else /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ +#else // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC /* * These must be included before libdecor.h, otherwise the libdecor header @@ -190,6 +190,6 @@ void SDL_WAYLAND_UnloadSymbols(void); #include #endif -#endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ +#endif // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC -#endif /* SDL_waylanddyn_h_ */ +#endif // SDL_waylanddyn_h_ diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 72b09d542d..c0a1abc2fc 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -65,19 +65,19 @@ #include #include "cursor-shape-v1-client-protocol.h" -/* Weston uses a ratio of 10 units per scroll tick */ +// Weston uses a ratio of 10 units per scroll tick #define WAYLAND_WHEEL_AXIS_UNIT 10 -/* xkbcommon as of 1.4.1 doesn't have a name macro for the mode key */ +// xkbcommon as of 1.4.1 doesn't have a name macro for the mode key #ifndef XKB_MOD_NAME_MODE #define XKB_MOD_NAME_MODE "Mod5" #endif -/* Keyboard and mouse names to match XWayland */ +// Keyboard and mouse names to match XWayland #define WAYLAND_DEFAULT_KEYBOARD_NAME "Virtual core keyboard" #define WAYLAND_DEFAULT_POINTER_NAME "Virtual core pointer" -/* Focus clickthrough timeout */ +// Focus clickthrough timeout #define WAYLAND_FOCUS_CLICK_TIMEOUT_NS SDL_MS_TO_NS(10) struct SDL_WaylandTouchPoint @@ -164,7 +164,7 @@ static Uint64 Wayland_GetEventTimestamp(Uint64 nsTimestamp) const Uint64 now = SDL_GetTicksNS(); if (nsTimestamp < last) { - /* 32-bit timer rollover, bump the offset */ + // 32-bit timer rollover, bump the offset timestamp_offset += SDL_MS_TO_NS(0x100000000LLU); } last = nsTimestamp; @@ -261,7 +261,7 @@ void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input) } } -/* Returns SDL_TRUE if a key repeat event was due */ +// Returns SDL_TRUE if a key repeat event was due static SDL_bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, Uint64 elapsed) { SDL_bool ret = SDL_FALSE; @@ -335,7 +335,7 @@ static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_inf static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data) { - /* Nothing to do, just destroy the callback */ + // Nothing to do, just destroy the callback wl_callback_destroy(callback); } @@ -392,11 +392,11 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) SDL_DBus_PumpEvents(); #endif - /* If key repeat is active, we'll need to cap our maximum wait time to handle repeats */ + // If key repeat is active, we'll need to cap our maximum wait time to handle repeats if (input && keyboard_repeat_is_set(&input->keyboard_repeat)) { const Uint64 elapsed = SDL_GetTicksNS() - input->keyboard_repeat.sdl_press_time_ns; if (keyboard_repeat_handle(&input->keyboard_repeat, elapsed)) { - /* A repeat key event was already due */ + // A repeat key event was already due return 1; } else { const Uint64 next_repeat_wait_time = (input->keyboard_repeat.next_repeat_ns - elapsed) + 1; @@ -412,17 +412,17 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) /* wl_display_prepare_read() will return -1 if the default queue is not empty. * If the default queue is empty, it will prepare us for our SDL_IOReady() call. */ if (WAYLAND_wl_display_prepare_read(d->display) == 0) { - /* Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait */ + // Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait int err = SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_IOR_READ | SDL_IOR_NO_RETRY, timeoutNS); if (err > 0) { - /* There are new events available to read */ + // There are new events available to read WAYLAND_wl_display_read_events(d->display); return dispatch_queued_events(d); } else if (err == 0) { - /* No events available within the timeout */ + // No events available within the timeout WAYLAND_wl_display_cancel_read(d->display); - /* If key repeat is active, we might have woken up to generate a key event */ + // If key repeat is active, we might have woken up to generate a key event if (key_repeat_active) { const Uint64 elapsed = SDL_GetTicksNS() - input->keyboard_repeat.sdl_press_time_ns; if (keyboard_repeat_handle(&input->keyboard_repeat, elapsed)) { @@ -432,7 +432,7 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) return 0; } else { - /* Error returned from poll()/select() */ + // Error returned from poll()/select() WAYLAND_wl_display_cancel_read(d->display); if (errno == EINTR) { @@ -444,7 +444,7 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) } } } else { - /* We already had pending events */ + // We already had pending events return dispatch_queued_events(d); } } @@ -484,7 +484,7 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this) } } - /* Dispatch any pre-existing pending events or new events we may have read */ + // Dispatch any pre-existing pending events or new events we may have read err = WAYLAND_wl_display_dispatch_pending(d->display); if (input && keyboard_repeat_is_set(&input->keyboard_repeat)) { @@ -547,7 +547,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer, SDL_WindowData *window; if (!surface) { - /* enter event for a window we've just destroyed */ + // enter event for a window we've just destroyed return; } @@ -590,7 +590,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, SDL_WindowData *wind = Wayland_GetWindowDataForOwnedSurface(surface); if (wind) { - /* Clear the capture flag and raise all buttons */ + // Clear the capture flag and raise all buttons wind->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_RELEASED, SDL_BUTTON_LEFT); @@ -705,7 +705,7 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_ case BTN_LEFT: sdl_button = SDL_BUTTON_LEFT; if (ProcessHitTest(input->pointer_focus, input->seat, input->sx_w, input->sy_w, serial)) { - return; /* don't pass this event on to app. */ + return; // don't pass this event on to app. } break; case BTN_MIDDLE: @@ -724,7 +724,7 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_ return; } - /* Possibly ignore this click if it was to gain focus. */ + // Possibly ignore this click if it was to gain focus. if (window->last_focus_event_time_ns) { if (state == WL_POINTER_BUTTON_STATE_PRESSED && (SDL_GetTicksNS() - window->last_focus_event_time_ns) < WAYLAND_FOCUS_CLICK_TIMEOUT_NS) { @@ -739,13 +739,13 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_ * 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)); } - /* Don't modify the capture flag in relative mode. */ + // Don't modify the capture flag in relative mode. if (!viddata->relative_mouse_mode) { if (input->buttons_pressed != 0) { window->sdlwindow->flags |= SDL_WINDOW_MOUSE_CAPTURE; @@ -832,7 +832,7 @@ static void pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_ } break; case AXIS_EVENT_CONTINUOUS: - /* Only process continuous events if no discrete events have been received. */ + // Only process continuous events if no discrete events have been received. if (input->pointer_curr_axis_info.y_axis_type == AXIS_EVENT_CONTINUOUS) { input->pointer_curr_axis_info.y = 0 - (float)wl_fixed_to_double(value); } @@ -863,7 +863,7 @@ static void pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_ } break; case AXIS_EVENT_CONTINUOUS: - /* Only process continuous events if no discrete events have been received. */ + // Only process continuous events if no discrete events have been received. if (input->pointer_curr_axis_info.x_axis_type == AXIS_EVENT_CONTINUOUS) { input->pointer_curr_axis_info.x = (float)wl_fixed_to_double(value); } @@ -941,7 +941,7 @@ static void pointer_handle_frame(void *data, struct wl_pointer *pointer) break; } - /* clear pointer_curr_axis_info for next frame */ + // clear pointer_curr_axis_info for next frame SDL_memset(&input->pointer_curr_axis_info, 0, sizeof(input->pointer_curr_axis_info)); if (x != 0.0f || y != 0.0f) { @@ -953,13 +953,13 @@ static void 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) { - /* unimplemented */ + // unimplemented } static void pointer_handle_axis_stop(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis) { - /* unimplemented */ + // unimplemented } static void pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer, @@ -984,12 +984,12 @@ 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_axis_relative_direction /* Version 9 */ + 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_axis_relative_direction // Version 9 }; static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t serial, @@ -999,7 +999,7 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; SDL_WindowData *window_data; - /* Check that this surface is valid. */ + // Check that this surface is valid. if (!surface) { return; } @@ -1094,8 +1094,8 @@ static const struct wl_touch_listener touch_listener = { touch_handler_motion, touch_handler_frame, touch_handler_cancel, - NULL, /* shape */ - NULL, /* orientation */ + NULL, // shape + NULL, // orientation }; typedef struct Wayland_Keymap @@ -1122,7 +1122,7 @@ static void Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, vo if (!keycode) { const SDL_Scancode sc = SDL_GetScancodeFromKeySym(syms[0], key); - /* Note: The default SDL scancode table sets this to right alt instead of AltGr/Mode, so handle it separately. */ + // Note: The default SDL scancode table sets this to right alt instead of AltGr/Mode, so handle it separately. if (syms[0] != XKB_KEY_ISO_Level3_Shift) { keycode = SDL_GetKeymapKeycode(NULL, sc, sdlKeymap->modstate); } else { @@ -1202,7 +1202,7 @@ static void Wayland_UpdateKeymap(struct SDL_WaylandInput *input) WAYLAND_xkb_state_unref(keymap.state); SDL_SetKeymap(keymap.keymap, SDL_TRUE); } else { - /* Virtual keyboards use the default keymap. */ + // Virtual keyboards use the default keymap. SDL_SetKeymap(NULL, SDL_TRUE); } } @@ -1281,7 +1281,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, */ input->keyboard_is_virtual = WAYLAND_xkb_keymap_layout_get_name(input->xkb.keymap, 0) == NULL; - /* Update the keymap if changed. */ + // Update the keymap if changed. if (input->xkb.current_group != XKB_GROUP_INVALID) { Wayland_UpdateKeymap(input); } @@ -1291,7 +1291,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, * for further explanation on dead keys in Wayland. */ - /* Look up the preferred locale, falling back to "C" as default */ + // Look up the preferred locale, falling back to "C" as default locale = SDL_getenv("LC_ALL"); if (!locale) { locale = SDL_getenv("LC_CTYPE"); @@ -1303,7 +1303,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, } } - /* Set up XKB compose table */ + // Set up XKB compose table if (input->xkb.compose_table != NULL) { WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); input->xkb.compose_table = NULL; @@ -1311,7 +1311,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, input->xkb.compose_table = WAYLAND_xkb_compose_table_new_from_locale(input->display->xkb_context, locale, XKB_COMPOSE_COMPILE_NO_FLAGS); if (input->xkb.compose_table) { - /* Set up XKB compose state */ + // Set up XKB compose state if (input->xkb.compose_state != NULL) { WAYLAND_xkb_compose_state_unref(input->xkb.compose_state); input->xkb.compose_state = NULL; @@ -1348,7 +1348,7 @@ static SDL_Scancode Wayland_get_scancode_from_key(struct SDL_WaylandInput *input static void Wayland_ReconcileModifiers(struct SDL_WaylandInput *input) { - /* Handle pressed modifiers for virtual keyboards that may not send keystrokes. */ + // Handle pressed modifiers for virtual keyboards that may not send keystrokes. if (input->keyboard_is_virtual) { if (input->xkb.wl_pressed_modifiers & input->xkb.idx_shift) { input->pressed_modifiers |= SDL_KMOD_SHIFT; @@ -1439,7 +1439,7 @@ static void Wayland_ReconcileModifiers(struct SDL_WaylandInput *input) input->locked_modifiers &= ~SDL_KMOD_MODE; } - /* Capslock and Numlock can only be locked, not pressed. */ + // Capslock and Numlock can only be locked, not pressed. if (input->xkb.wl_locked_modifiers & input->xkb.idx_caps) { input->locked_modifiers |= SDL_KMOD_CAPS; } else { @@ -1510,7 +1510,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t *key; if (!surface) { - /* enter event for a window we've just destroyed */ + // enter event for a window we've just destroyed return; } @@ -1523,7 +1523,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, input->keyboard_focus = window; window->keyboard_device = input; - /* Restore the keyboard focus to the child popup that was holding it */ + // Restore the keyboard focus to the child popup that was holding it SDL_SetKeyboardFocus(window->keyboard_focus ? window->keyboard_focus : window->sdlwindow); #ifdef SDL_USE_IME @@ -1576,14 +1576,14 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, wind->keyboard_device = NULL; window = wind->sdlwindow; - /* Stop key repeat before clearing keyboard focus */ + // Stop key repeat before clearing keyboard focus keyboard_repeat_clear(&input->keyboard_repeat); - /* This will release any keys still pressed */ + // This will release any keys still pressed SDL_SetKeyboardFocus(NULL); input->keyboard_focus = NULL; - /* Clear the pressed modifiers. */ + // Clear the pressed modifiers. input->pressed_modifiers = SDL_KMOD_NONE; #ifdef SDL_USE_IME @@ -1610,7 +1610,7 @@ static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandIn return SDL_FALSE; } - /* TODO: Can this happen? */ + // TODO: Can this happen? if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) { return SDL_FALSE; } @@ -1720,7 +1720,7 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, Wayland_ReconcileModifiers(input); - /* If a key is repeating, update the text to apply the modifier. */ + // If a key is repeating, update the text to apply the modifier. if (keyboard_repeat_is_set(&input->keyboard_repeat)) { char text[8]; const uint32_t key = keyboard_repeat_get_key(&input->keyboard_repeat); @@ -1734,7 +1734,7 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, return; } - /* The layout changed, remap and fire an event. Virtual keyboards use the default keymap. */ + // The layout changed, remap and fire an event. Virtual keyboards use the default keymap. input->xkb.current_group = group; Wayland_UpdateKeymap(input); } @@ -1754,7 +1754,7 @@ 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, @@ -1820,12 +1820,12 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) { - /* unimplemented */ + // 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, @@ -1864,9 +1864,9 @@ static const struct wl_data_source_listener data_source_listener = { data_source_handle_target, data_source_handle_send, data_source_handle_cancelled, - data_source_handle_dnd_drop_performed, /* Version 3 */ - data_source_handle_dnd_finished, /* Version 3 */ - data_source_handle_action, /* Version 3 */ + data_source_handle_dnd_drop_performed, // Version 3 + data_source_handle_dnd_finished, // Version 3 + 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, @@ -1982,8 +1982,8 @@ static void data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_ static const struct wl_data_offer_listener data_offer_listener = { data_offer_handle_offer, - data_offer_handle_source_actions, /* Version 3 */ - data_offer_handle_actions, /* Version 3 */ + data_offer_handle_source_actions, // Version 3 + 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, @@ -2031,7 +2031,7 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ if (id) { data_device->drag_offer = wl_data_offer_get_user_data(id); - /* TODO: SDL Support more mime types */ + // TODO: SDL Support more mime types #ifdef SDL_USE_LIBDBUS if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { data_device->has_mime_file = SDL_TRUE; @@ -2048,11 +2048,11 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ wl_data_offer_accept(id, serial, TEXT_MIME); } - /* SDL only supports "copy" style drag and drop */ + // SDL only supports "copy" style drag and drop if (data_device->has_mime_file || data_device->has_mime_text) { dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; } else { - /* drag_mime is NULL this will decline the offer */ + // drag_mime is NULL this will decline the offer wl_data_offer_accept(id, serial, NULL); } if (wl_data_offer_get_version(data_device->drag_offer->offer) >= @@ -2061,7 +2061,7 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ dnd_action, dnd_action); } - /* find the current window */ + // find the current window if (surface) { SDL_WindowData *window = Wayland_GetWindowDataForOwnedSurface(surface); if (window) { @@ -2155,7 +2155,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d ". In wl_data_device_listener . data_device_handle_drop on data_offer 0x%08x in window %d serial %d\n", WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer), SDL_GetWindowID(data_device->dnd_window), data_device->drag_serial); - /* TODO: SDL Support more mime types */ + // TODO: SDL Support more mime types size_t length; SDL_bool drop_handled = SDL_FALSE; #ifdef SDL_USE_LIBDBUS @@ -2167,7 +2167,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d if (dbus) { int path_count = 0; char **paths = SDL_DBus_DocumentsPortalRetrieveFiles(buffer, &path_count); - /* If dropped files contain a directory the list is empty */ + // If dropped files contain a directory the list is empty if (paths && path_count > 0) { int i; for (i = 0; i < path_count; i++) { @@ -2318,14 +2318,14 @@ static void text_input_enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, struct wl_surface *surface) { - /* No-op */ + // No-op } static void text_input_leave(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, struct wl_surface *surface) { - /* No-op */ + // No-op } static void text_input_preedit_string(void *data, @@ -2367,7 +2367,7 @@ static void text_input_delete_surrounding_text(void *data, uint32_t before_length, uint32_t after_length) { - /* FIXME: Do we care about this event? */ + // FIXME: Do we care about this event? } static void text_input_done(void *data, @@ -2395,7 +2395,7 @@ void Wayland_create_data_device(SDL_VideoData *d) SDL_WaylandDataDevice *data_device = NULL; if (!d->input->seat) { - /* No seat yet, will be initialized later. */ + // No seat yet, will be initialized later. return; } @@ -2423,7 +2423,7 @@ void Wayland_create_primary_selection_device(SDL_VideoData *d) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; if (!d->input->seat) { - /* No seat yet, will be initialized later. */ + // No seat yet, will be initialized later. return; } @@ -2452,7 +2452,7 @@ void Wayland_create_text_input(SDL_VideoData *d) SDL_WaylandTextInput *text_input = NULL; if (!d->input->seat) { - /* No seat yet, will be initialized later. */ + // No seat yet, will be initialized later. return; } @@ -2636,14 +2636,14 @@ static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *too int sdlbutton; switch (button) { - /* see %{_includedir}/linux/input-event-codes.h */ - case 0x14b: /* BTN_STYLUS */ + // see %{_includedir}/linux/input-event-codes.h + case 0x14b: // BTN_STYLUS sdlbutton = 1; break; - case 0x14c: /* BTN_STYLUS2 */ + case 0x14c: // BTN_STYLUS2 sdlbutton = 2; break; - case 0x149: /* BTN_STYLUS3 */ + case 0x149: // BTN_STYLUS3 sdlbutton = 3; break; default: @@ -2977,7 +2977,7 @@ static void relative_pointer_handle_relative_motion(void *data, double dx_unaccel; double dy_unaccel; - /* Relative pointer event times are in microsecond granularity. */ + // Relative pointer event times are in microsecond granularity. const Uint64 timestamp = SDL_US_TO_NS(((Uint64)time_hi << 32) | (Uint64)time_lo); dx_unaccel = wl_fixed_to_double(dx_unaccel_w); @@ -3018,7 +3018,7 @@ int Wayland_input_lock_pointer(struct SDL_WaylandInput *input, SDL_Window *windo if (!w->locked_pointer) { if (w->confined_pointer) { - /* If the pointer is already confined to the surface, the lock will fail with a protocol error. */ + // If the pointer is already confined to the surface, the lock will fail with a protocol error. Wayland_input_unconfine_pointer(input, window); } @@ -3044,7 +3044,7 @@ int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input, SDL_Window *win w->locked_pointer = NULL; } - /* Restore existing pointer confinement. */ + // Restore existing pointer confinement. Wayland_input_confine_pointer(input, window); return 0; @@ -3168,7 +3168,7 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi return 0; } - /* Don't confine the pointer if it shouldn't be confined. */ + // Don't confine the pointer if it shouldn't be confined. if (SDL_RectEmpty(&window->mouse_rect) && !(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { return 0; } @@ -3257,4 +3257,4 @@ void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandInput *input, Uint32 ser } } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandevents_c.h b/src/video/wayland/SDL_waylandevents_c.h index fb6e72e67a..6e41895db0 100644 --- a/src/video/wayland/SDL_waylandevents_c.h +++ b/src/video/wayland/SDL_waylandevents_c.h @@ -49,16 +49,16 @@ typedef struct SDL_WaylandTabletInput typedef struct { - int32_t repeat_rate; /* Repeat rate in range of [1, 1000] character(s) per second */ - int32_t repeat_delay_ms; /* Time to first repeat event in milliseconds */ - Uint32 keyboard_id; /* ID of the source keyboard. */ + int32_t repeat_rate; // Repeat rate in range of [1, 1000] character(s) per second + int32_t repeat_delay_ms; // Time to first repeat event in milliseconds + Uint32 keyboard_id; // ID of the source keyboard. SDL_bool is_initialized; SDL_bool is_key_down; uint32_t key; - Uint64 wl_press_time_ns; /* Key press time as reported by the Wayland API */ - Uint64 sdl_press_time_ns; /* Key press time expressed in SDL ticks */ - Uint64 next_repeat_ns; /* Next repeat event in nanoseconds */ + Uint64 wl_press_time_ns; // Key press time as reported by the Wayland API + Uint64 sdl_press_time_ns; // Key press time expressed in SDL ticks + Uint64 next_repeat_ns; // Next repeat event in nanoseconds uint32_t scancode; char text[8]; } SDL_WaylandKeyboardRepeat; @@ -85,18 +85,18 @@ struct SDL_WaylandInput Uint32 pointer_id; uint32_t pointer_enter_serial; - /* High-resolution event timestamps */ + // High-resolution event timestamps Uint64 keyboard_timestamp_ns; Uint64 pointer_timestamp_ns; Uint64 touch_timestamp_ns; - /* Last motion location */ + // Last motion location wl_fixed_t sx_w; wl_fixed_t sy_w; uint32_t buttons_pressed; - /* The serial of the last implicit grab event for window activation and selection data. */ + // The serial of the last implicit grab event for window activation and selection data. Uint32 last_implicit_grab_serial; struct @@ -106,10 +106,10 @@ struct SDL_WaylandInput struct xkb_compose_table *compose_table; struct xkb_compose_state *compose_state; - /* Keyboard layout "group" */ + // Keyboard layout "group" uint32_t current_group; - /* Modifier bitshift values */ + // Modifier bitshift values uint32_t idx_shift; uint32_t idx_ctrl; uint32_t idx_alt; @@ -118,12 +118,12 @@ struct SDL_WaylandInput uint32_t idx_num; uint32_t idx_caps; - /* Current system modifier flags */ + // Current system modifier flags uint32_t wl_pressed_modifiers; uint32_t wl_locked_modifiers; } xkb; - /* information about axis events on current frame */ + // information about axis events on current frame struct { enum SDL_WaylandAxisEvent x_axis_type; @@ -132,7 +132,7 @@ struct SDL_WaylandInput enum SDL_WaylandAxisEvent y_axis_type; float y; - /* Event timestamp in nanoseconds */ + // Event timestamp in nanoseconds Uint64 timestamp_ns; SDL_MouseWheelDirection direction; } pointer_curr_axis_info; @@ -143,7 +143,7 @@ struct SDL_WaylandInput SDL_bool keyboard_is_virtual; - /* Current SDL modifier flags */ + // Current SDL modifier flags SDL_Keymod pressed_modifiers; SDL_Keymod locked_modifiers; }; @@ -189,4 +189,4 @@ extern void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input); */ extern void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandInput *input, Uint32 serial); -#endif /* SDL_waylandevents_h_ */ +#endif // SDL_waylandevents_h_ diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index 88152c95fb..2065a4f169 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -122,10 +122,10 @@ int Wayland_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prope zwp_text_input_v3_enable(input->text_input->text_input); - /* Now that it's enabled, set the input properties */ + // Now that it's enabled, set the input properties zwp_text_input_v3_set_content_type(input->text_input->text_input, hint, purpose); if (!SDL_RectEmpty(rect)) { - /* This gets reset on enable so we have to cache it */ + // This gets reset on enable so we have to cache it zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, rect->x, rect->y, @@ -137,7 +137,7 @@ int Wayland_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prope } if (input && input->xkb.compose_state) { - /* Reset compose state so composite and dead keys don't carry over */ + // Reset compose state so composite and dead keys don't carry over WAYLAND_xkb_compose_state_reset(input->xkb.compose_state); } @@ -162,7 +162,7 @@ int Wayland_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) #endif if (input && input->xkb.compose_state) { - /* Reset compose state so composite and dead keys don't carry over */ + // Reset compose state so composite and dead keys don't carry over WAYLAND_xkb_compose_state_reset(input->xkb.compose_state); } return 0; @@ -206,4 +206,4 @@ SDL_bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this) return !haskeyboard && hastextmanager; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandkeyboard.h b/src/video/wayland/SDL_waylandkeyboard.h index c85bfc84b7..6f4fd16537 100644 --- a/src/video/wayland/SDL_waylandkeyboard.h +++ b/src/video/wayland/SDL_waylandkeyboard.h @@ -37,4 +37,4 @@ extern int Wayland_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); extern int Wayland_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this); -#endif /* SDL_waylandkeyboard_h_ */ +#endif // SDL_waylandkeyboard_h_ diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c index 2167e2ab0d..5e5fc01e70 100644 --- a/src/video/wayland/SDL_waylandmessagebox.c +++ b/src/video/wayland/SDL_waylandmessagebox.c @@ -23,18 +23,18 @@ #ifdef SDL_VIDEO_DRIVER_WAYLAND -#include /* fgets */ -#include /* FILE, STDOUT_FILENO, fdopen, fclose */ -#include /* pid_t, pipe, fork, close, dup2, execvp, _exit */ -#include /* waitpid, WIFEXITED, WEXITSTATUS */ -#include /* strerr */ +#include // fgets +#include // FILE, STDOUT_FILENO, fdopen, fclose +#include // pid_t, pipe, fork, close, dup2, execvp, _exit +#include // waitpid, WIFEXITED, WEXITSTATUS +#include // strerr #include #include "SDL_waylandmessagebox.h" -#define ZENITY_VERSION_LEN 32 /* Number of bytes to read from zenity --version (including NUL)*/ +#define ZENITY_VERSION_LEN 32 // Number of bytes to read from zenity --version (including NUL) -#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ +#define MAX_BUTTONS 8 // Maximum number of buttons supported static int run_zenity(const char **args, int fd_pipe[2]) { @@ -42,9 +42,9 @@ static int run_zenity(const char **args, int fd_pipe[2]) pid_t pid1; pid1 = fork(); - if (pid1 == 0) { /* child process */ - close(fd_pipe[0]); /* no reading from pipe */ - /* write stdout in pipe */ + if (pid1 == 0) { // child process + close(fd_pipe[0]); // no reading from pipe + // write stdout in pipe if (dup2(fd_pipe[1], STDOUT_FILENO) == -1) { _exit(128); } @@ -55,9 +55,9 @@ static int run_zenity(const char **args, int fd_pipe[2]) */ execvp("zenity", (char **)args); _exit(129); - } else if (pid1 < 0) { /* fork() failed */ + } else if (pid1 < 0) { // fork() failed return SDL_SetError("fork() failed: %s", strerror(errno)); - } else { /* parent process */ + } else { // parent process if (waitpid(pid1, &status, 0) != pid1) { return SDL_SetError("Waiting on zenity failed: %s", strerror(errno)); } @@ -70,16 +70,16 @@ static int run_zenity(const char **args, int fd_pipe[2]) return SDL_SetError("zenity reported error or failed to launch: %d", WEXITSTATUS(status)); } - return 0; /* success! */ + return 0; // success! } } static int get_zenity_version(int *major, int *minor) { - int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */ + int fd_pipe[2]; // fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe const char *argv[] = { "zenity", "--version", NULL }; - if (pipe(fd_pipe) != 0) { /* create a pipe */ + if (pipe(fd_pipe) != 0) { // create a pipe return SDL_SetError("pipe() failed: %s", strerror(errno)); } @@ -97,7 +97,7 @@ static int get_zenity_version(int *major, int *minor) } version_ptr = fgets(version_str, ZENITY_VERSION_LEN, outputfp); - (void)fclose(outputfp); /* will close underlying fd */ + (void)fclose(outputfp); // will close underlying fd if (!version_ptr) { return SDL_SetError("failed to read zenity version string"); @@ -113,7 +113,7 @@ static int get_zenity_version(int *major, int *minor) *major = tmp; if (*end_ptr == '.') { - version_ptr = end_ptr + 1; /* skip the dot */ + version_ptr = end_ptr + 1; // skip the dot tmp = (int) SDL_strtol(version_ptr, &end_ptr, 10); if (tmp == 0 && end_ptr == version_ptr) { return SDL_SetError("failed to get zenity minor version number"); @@ -123,24 +123,24 @@ static int get_zenity_version(int *major, int *minor) *minor = 0; } - return 0; /* success */ + return 0; // success } close(fd_pipe[0]); close(fd_pipe[1]); - return -1; /* run_zenity should've called SDL_SetError() */ + return -1; // run_zenity should've called SDL_SetError() } 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 */ + int fd_pipe[2]; // fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe int zenity_major = 0, zenity_minor = 0, output_len = 0; int argc = 5, i; const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = { "zenity", "--question", "--switch", "--no-wrap", "--no-markup" }; - /* Are we trying to connect to or are currently in a Wayland session? */ + // Are we trying to connect to or are currently in a Wayland session? if (!SDL_getenv("WAYLAND_DISPLAY")) { const char *session = SDL_getenv("XDG_SESSION_TYPE"); if (session && SDL_strcasecmp(session, "wayland") != 0) { @@ -152,12 +152,12 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS); } - /* get zenity version so we know which arg to use */ + // get zenity version so we know which arg to use if (get_zenity_version(&zenity_major, &zenity_minor) != 0) { - return -1; /* get_zenity_version() calls SDL_SetError(), so message is already set */ + return -1; // get_zenity_version() calls SDL_SetError(), so message is already set } - if (pipe(fd_pipe) != 0) { /* create a pipe */ + if (pipe(fd_pipe) != 0) { // create a pipe return SDL_SetError("pipe() failed: %s", strerror(errno)); } @@ -215,9 +215,9 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button close(fd_pipe[1]); if (!buttonID) { - /* if we don't need buttonID, we can return immediately */ + // if we don't need buttonID, we can return immediately close(fd_pipe[0]); - return 0; /* success */ + return 0; // success } *buttonID = -1; @@ -239,16 +239,16 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button if ((!tmp) || (*tmp == '\0') || (*tmp == '\n')) { SDL_free(output); - return 0; /* User simply closed the dialog */ + return 0; // User simply closed the dialog } - /* It likes to add a newline... */ + // It likes to add a newline... tmp = SDL_strrchr(output, '\n'); if (tmp) { *tmp = '\0'; } - /* Check which button got pressed */ + // Check which button got pressed for (i = 0; i < messageboxdata->numbuttons; i += 1) { if (messageboxdata->buttons[i].text) { if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { @@ -259,12 +259,12 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button } SDL_free(output); - return 0; /* success! */ + return 0; // success! } close(fd_pipe[0]); close(fd_pipe[1]); - return -1; /* run_zenity() calls SDL_SetError(), so message is already set */ + return -1; // run_zenity() calls SDL_SetError(), so message is already set } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandmessagebox.h b/src/video/wayland/SDL_waylandmessagebox.h index f89b032837..ad844066de 100644 --- a/src/video/wayland/SDL_waylandmessagebox.h +++ b/src/video/wayland/SDL_waylandmessagebox.h @@ -26,6 +26,6 @@ extern int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND -#endif /* SDL_waylandmessagebox_h_ */ +#endif // SDL_waylandmessagebox_h_ diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 3a88fcf06d..f80d5b5a0c 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -128,7 +128,7 @@ static DBusMessage *Wayland_ReadDBusProperty(SDL_DBusContext *dbus, const char * DBusMessage *msg = dbus->message_new_method_call(CURSOR_NODE, CURSOR_PATH, CURSOR_INTERFACE, - "Read"); /* Method */ + "Read"); // Method if (msg) { if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { @@ -174,7 +174,7 @@ static DBusHandlerResult Wayland_DBusCursorMessageFilter(DBusConnection *conn, D const char *namespace, *key; dbus->message_iter_init(msg, &signal_iter); - /* Check if the parameters are what we expect */ + // Check if the parameters are what we expect if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING) { goto not_our_signal; } @@ -206,7 +206,7 @@ static DBusHandlerResult Wayland_DBusCursorMessageFilter(DBusConnection *conn, D if (dbus_cursor_size != new_cursor_size) { dbus_cursor_size = new_cursor_size; - SDL_SetCursor(NULL); /* Force cursor update */ + SDL_SetCursor(NULL); // Force cursor update } } else if (SDL_strcmp(CURSOR_THEME_KEY, key) == 0) { const char *new_cursor_theme = NULL; @@ -231,7 +231,7 @@ static DBusHandlerResult Wayland_DBusCursorMessageFilter(DBusConnection *conn, D dbus_cursor_theme = NULL; } - /* Purge the current cached themes and force a cursor refresh. */ + // Purge the current cached themes and force a cursor refresh. Wayland_FreeCursorThemes(vdata); SDL_SetCursor(NULL); } @@ -275,7 +275,7 @@ static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) dbus->message_unref(reply); } - /* Only add the filter if at least one of the settings we want is present. */ + // Only add the filter if at least one of the settings we want is present. if (add_filter) { dbus->bus_add_match(dbus->session_conn, "type='signal', interface='" CURSOR_INTERFACE "'," @@ -311,11 +311,11 @@ static void cursor_frame_done(void *data, struct wl_callback *cb, uint32_t time) c->cursor_data.system.frame_callback = wl_surface_frame(c->surface); wl_callback_add_listener(c->cursor_data.system.frame_callback, &cursor_frame_listener, data); - /* Calculate the next frame based on the elapsed duration. */ + // Calculate the next frame based on the elapsed duration. for (Uint64 t = c->cursor_data.system.frames[next].duration; t <= elapsed; t += c->cursor_data.system.frames[next].duration) { next = (next + 1) % c->cursor_data.system.num_frames; - /* Make sure we don't end up in an infinite loop if a cursor has frame durations of 0. */ + // Make sure we don't end up in an infinite loop if a cursor has frame durations of 0. if (!c->cursor_data.system.frames[next].duration) { break; } @@ -343,7 +343,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * SDL_Window *focus; - /* Fallback envvar if the DBus properties don't exist */ + // Fallback envvar if the DBus properties don't exist if (size <= 0) { const char *xcursor_size = SDL_getenv("XCURSOR_SIZE"); if (xcursor_size) { @@ -353,10 +353,10 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * if (size <= 0) { size = 24; } - /* First, find the appropriate theme based on the current scale... */ + // First, find the appropriate theme based on the current scale... focus = SDL_GetMouse()->focus; if (focus) { - /* TODO: Use the fractional scale once GNOME supports viewports on cursor surfaces. */ + // TODO: Use the fractional scale once GNOME supports viewports on cursor surfaces. *scale = SDL_ceilf(focus->internal->windowed_scale_factor); } else { *scale = 1.0f; @@ -379,7 +379,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * } vdata->cursor_themes = new_cursor_themes; - /* Fallback envvar if the DBus properties don't exist */ + // Fallback envvar if the DBus properties don't exist if (!xcursor_theme) { xcursor_theme = SDL_getenv("XCURSOR_THEME"); } @@ -395,11 +395,11 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, fallback_name); } - /* Fallback to the default cursor if the chosen one wasn't found */ + // Fallback to the default cursor if the chosen one wasn't found if (!cursor) { cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "default"); } - /* Try the old X11 name as a last resort */ + // Try the old X11 name as a last resort if (!cursor) { cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); } @@ -415,7 +415,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * } } - /* ... Set the cursor data, finally. */ + // ... Set the cursor data, finally. cdata->cursor_data.system.num_frames = cursor->image_count; cdata->cursor_data.system.total_duration = 0; for (int i = 0; i < cursor->image_count; ++i) { @@ -441,12 +441,12 @@ static Wayland_CachedCustomCursor *Wayland_GetCachedCustomCursor(SDL_Cursor *cur scale = focus->internal->windowed_scale_factor; } - /* Only use fractional scale values if viewports are available. */ + // Only use fractional scale values if viewports are available. if (!wd->viewporter) { scale = SDL_ceilf(scale); } - /* Is this cursor already cached at the target scale? */ + // Is this cursor already cached at the target scale? wl_list_for_each(cache, &data->cursor_data.custom.cursor_cache, node) { if (cache->scale == scale) { return cache; @@ -464,14 +464,14 @@ static Wayland_CachedCustomCursor *Wayland_GetCachedCustomCursor(SDL_Cursor *cur return NULL; } - /* Allocate shared memory buffer for this cursor */ + // Allocate shared memory buffer for this cursor if (Wayland_AllocSHMBuffer(surface->w, surface->h, &cache->shmBuffer) != 0) { SDL_free(cache); SDL_DestroySurface(surface); return NULL; } - /* Wayland requires premultiplied alpha for its surfaces. */ + // Wayland requires premultiplied alpha for its surfaces. SDL_PremultiplyAlpha(surface->w, surface->h, surface->format, surface->pixels, surface->pitch, SDL_PIXELFORMAT_ARGB8888, cache->shmBuffer.shm_data, surface->w * 4, SDL_TRUE); @@ -507,7 +507,7 @@ static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot data->cursor_data.custom.sdl_cursor_surface = surface; ++surface->refcount; - /* If the cursor has only one size, just prepare it now. */ + // If the cursor has only one size, just prepare it now. if (!SDL_SurfaceHasAlternateImages(surface)) { Wayland_GetCachedCustomCursor(cursor); } @@ -552,7 +552,7 @@ static SDL_Cursor *Wayland_CreateDefaultCursor(void) static void Wayland_FreeCursorData(SDL_CursorData *d) { - /* Buffers for system cursors must not be destroyed. */ + // Buffers for system cursors must not be destroyed. if (d->is_system_cursor) { if (d->cursor_data.system.frame_callback) { wl_callback_destroy(d->cursor_data.system.frame_callback); @@ -585,7 +585,7 @@ static void Wayland_FreeCursor(SDL_Cursor *cursor) return; } - /* Probably not a cursor we own */ + // Probably not a cursor we own if (!cursor->internal) { return; } @@ -662,7 +662,7 @@ static void Wayland_SetSystemCursorShape(struct SDL_WaylandInput *input, SDL_Sys shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE; break; default: - SDL_assert(0); /* Should never be here... */ + SDL_assert(0); // Should never be here... shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT; } @@ -683,7 +683,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) return -1; } - /* Stop the frame callback for old animated cursors. */ + // Stop the frame callback for old animated cursors. if (input->current_cursor && input->current_cursor->is_system_cursor && input->current_cursor->cursor_data.system.frame_callback) { wl_callback_destroy(input->current_cursor->cursor_data.system.frame_callback); @@ -709,7 +709,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) if (data->is_system_cursor) { wl_surface_attach(data->surface, data->cursor_data.system.frames[0].wl_buffer, 0, 0); - /* If more than one frame is available, create a frame callback to run the animation. */ + // If more than one frame is available, create a frame callback to run the animation. if (data->cursor_data.system.num_frames > 1) { data->cursor_data.system.last_frame_time_ms = SDL_GetTicks(); data->cursor_data.system.current_frame = 0; @@ -727,7 +727,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) wl_surface_attach(data->surface, cached->shmBuffer.wl_buffer, 0, 0); } - /* TODO: Make the viewport path the default in all cases once GNOME finally supports viewports on cursor surfaces. */ + // TODO: Make the viewport path the default in all cases once GNOME finally supports viewports on cursor surfaces. if (SDL_ceilf(scale) != scale && d->viewporter) { if (!data->viewport) { data->viewport = wp_viewporter_get_viewport(d->viewporter, data->surface); @@ -807,7 +807,7 @@ static int Wayland_WarpMouseGlobal(float x, float y) struct SDL_WaylandInput *input = d->input; SDL_WindowData *wind = input->pointer_focus; - /* If the client wants the coordinates warped to within the focused window, just convert the coordinates to relative. */ + // If the client wants the coordinates warped to within the focused window, just convert the coordinates to relative. if (wind) { SDL_Window *window = wind->sdlwindow; return Wayland_WarpMouse(window, x - (float)window->x, y - (float)window->y); @@ -857,19 +857,19 @@ static SDL_MouseButtonFlags SDLCALL Wayland_GetGlobalMouseState(float *x, float return ret; } -#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ +#if 0 // TODO RECONNECT: See waylandvideo.c for more information! static void Wayland_RecreateCursor(SDL_Cursor *cursor, SDL_VideoData *vdata) { SDL_CursorData *cdata = cursor->internal; - /* Probably not a cursor we own */ + // Probably not a cursor we own if (cdata == NULL) { return; } Wayland_FreeCursorData(cdata); - /* We're not currently freeing this, so... yolo? */ + // We're not currently freeing this, so... yolo? if (cdata->shm_data != NULL) { void *old_data_pointer = cdata->shm_data; int stride = cdata->w * 4; @@ -911,7 +911,7 @@ void Wayland_RecreateCursors(void) } } } -#endif /* 0 */ +#endif // 0 void Wayland_InitMouse(void) { @@ -995,4 +995,4 @@ void Wayland_SetHitTestCursor(SDL_HitTestResult rc) } } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandmouse.h b/src/video/wayland/SDL_waylandmouse.h index 028259f79a..fbc55224dd 100644 --- a/src/video/wayland/SDL_waylandmouse.h +++ b/src/video/wayland/SDL_waylandmouse.h @@ -27,8 +27,8 @@ extern void Wayland_InitMouse(void); extern void Wayland_FiniMouse(SDL_VideoData *data); extern void Wayland_SetHitTestCursor(SDL_HitTestResult rc); -#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 */ +#endif // 0 #endif diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index 0fad3bcf3a..3b99edbbda 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c @@ -32,7 +32,7 @@ #include "xdg-shell-client-protocol.h" -/* EGL implementation of SDL OpenGL ES support */ +// EGL implementation of SDL OpenGL ES support int Wayland_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { @@ -86,7 +86,7 @@ int Wayland_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) interval = -1; } - /* !!! FIXME: technically, this should be per-context, right? */ + // !!! FIXME: technically, this should be per-context, right? _this->egl_data->egl_swapinterval = interval; _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); return 0; @@ -125,7 +125,7 @@ int Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) * immediately for the Wayland frame callback. */ if (data->double_buffer) { - /* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */ + // Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) { return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); } @@ -133,11 +133,11 @@ int Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) WAYLAND_wl_display_flush(data->waylandData->display); } - /* Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval */ + // Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval if (swap_interval != 0 && data->surface_status == WAYLAND_SURFACE_STATUS_SHOWN) { SDL_VideoData *videodata = _this->internal; struct wl_display *display = videodata->display; - /* 20hz, so we'll progress even if throttled to zero. */ + // 20hz, so we'll progress even if throttled to zero. const Uint64 max_wait = SDL_GetTicksNS() + (SDL_NS_PER_SECOND / 20); while (SDL_AtomicGet(&data->swap_interval_ready) == 0) { Uint64 now; @@ -147,27 +147,27 @@ int Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) /* wl_display_prepare_read_queue() will return -1 if the event queue is not empty. * If the event queue is empty, it will prepare us for our SDL_IOReady() call. */ if (WAYLAND_wl_display_prepare_read_queue(display, data->gles_swap_frame_event_queue) != 0) { - /* We have some pending events. Check if the frame callback happened. */ + // We have some pending events. Check if the frame callback happened. WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue); continue; } - /* Beyond this point, we must either call wl_display_cancel_read() or wl_display_read_events() */ + // Beyond this point, we must either call wl_display_cancel_read() or wl_display_read_events() now = SDL_GetTicksNS(); if (now >= max_wait) { - /* Timeout expired. Cancel the read. */ + // Timeout expired. Cancel the read. WAYLAND_wl_display_cancel_read(display); break; } if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_IOR_READ, max_wait - now) <= 0) { - /* Error or timeout expired without any events for us. Cancel the read. */ + // Error or timeout expired without any events for us. Cancel the read. WAYLAND_wl_display_cancel_read(display); break; } - /* We have events. Read and dispatch them. */ + // We have events. Read and dispatch them. WAYLAND_wl_display_read_events(display); WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue); } @@ -175,7 +175,7 @@ int Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) } if (!data->double_buffer) { - /* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */ + // Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) { return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); } @@ -198,7 +198,7 @@ int Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLC WAYLAND_wl_display_flush(_this->internal->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; } @@ -217,4 +217,4 @@ EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window return windowdata->egl_surface; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */ +#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 97dae93fe8..fc2e69ac00 100644 --- a/src/video/wayland/SDL_waylandopengles.h +++ b/src/video/wayland/SDL_waylandopengles.h @@ -31,7 +31,7 @@ typedef struct SDL_PrivateGLESData int dummy; } SDL_PrivateGLESData; -/* OpenGLES functions */ +// OpenGLES functions #define Wayland_GLES_GetAttribute SDL_EGL_GetAttribute #define Wayland_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define Wayland_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -45,4 +45,4 @@ extern int Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, extern int Wayland_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); extern SDL_EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_waylandopengles_h_ */ +#endif // SDL_waylandopengles_h_ diff --git a/src/video/wayland/SDL_waylandshmbuffer.c b/src/video/wayland/SDL_waylandshmbuffer.c index 97d3cc24fc..030bf0cc64 100644 --- a/src/video/wayland/SDL_waylandshmbuffer.c +++ b/src/video/wayland/SDL_waylandshmbuffer.c @@ -93,7 +93,7 @@ static int CreateTempFD(off_t size) return -1; } - /* Need to manually unlink the temp files, or they can persist after close and fill up the temp storage. */ + // Need to manually unlink the temp files, or they can persist after close and fill up the temp storage. unlink(tmp_path); } @@ -107,7 +107,7 @@ static int CreateTempFD(off_t size) static void buffer_handle_release(void *data, struct wl_buffer *wl_buffer) { - /* NOP */ + // NOP } static struct wl_buffer_listener buffer_listener = { diff --git a/src/video/wayland/SDL_waylandshmbuffer.h b/src/video/wayland/SDL_waylandshmbuffer.h index 7d1c5adf87..2ec02e3eb7 100644 --- a/src/video/wayland/SDL_waylandshmbuffer.h +++ b/src/video/wayland/SDL_waylandshmbuffer.h @@ -31,7 +31,7 @@ struct Wayland_SHMBuffer int shm_data_size; }; -/* Allocates an SHM buffer with the format WL_SHM_FORMAT_ARGB8888 */ +// Allocates an SHM buffer with the format WL_SHM_FORMAT_ARGB8888 extern int Wayland_AllocSHMBuffer(int width, int height, struct Wayland_SHMBuffer *shmBuffer); extern void Wayland_ReleaseSHMBuffer(struct Wayland_SHMBuffer *shmBuffer); diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h index 25fec030ff..293a679efa 100644 --- a/src/video/wayland/SDL_waylandsym.h +++ b/src/video/wayland/SDL_waylandsym.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #ifndef SDL_WAYLAND_MODULE #define SDL_WAYLAND_MODULE(modname) @@ -90,11 +90,11 @@ SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_flags, (struct wl_proxy *prox SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_array_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, union wl_argument *args)) #endif -#if 0 /* TODO RECONNECT: See waylandvideo.c for more information! */ +#if 0 // TODO RECONNECT: See waylandvideo.c for more information! #if SDL_WAYLAND_CHECK_VERSION(broken, on, purpose) SDL_WAYLAND_SYM(int, wl_display_reconnect, (struct wl_display*)) #endif -#endif /* 0 */ +#endif // 0 SDL_WAYLAND_INTERFACE(wl_seat_interface) SDL_WAYLAND_INTERFACE(wl_surface_interface) @@ -221,7 +221,7 @@ SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_ SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int)) #if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || SDL_LIBDECOR_CHECK_VERSION(0, 2, 0) -/* Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. */ +// Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (const struct libdecor_frame *,\ int *,\ int *)) @@ -237,4 +237,4 @@ SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (const struct lib #undef SDL_WAYLAND_SYM_OPT #undef SDL_WAYLAND_INTERFACE -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 1fae5d6e79..76af7b4fd6 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -70,7 +70,7 @@ #define WAYLANDVID_DRIVER_NAME "wayland" -/* Clamp certain core protocol versions on older versions of libwayland. */ +// Clamp certain core protocol versions on older versions of libwayland. #if SDL_WAYLAND_CHECK_VERSION(1, 22, 0) #define SDL_WL_COMPOSITOR_VERSION 6 #else @@ -122,25 +122,25 @@ static SDL_bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) } if (reply) { - /* Serial (don't care) */ + // Serial (don't care) dbus->message_iter_init(reply, &iter[0]); if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_UINT32) { goto error; } - /* Physical monitor array (don't care) */ + // Physical monitor array (don't care) dbus->message_iter_next(&iter[0]); if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_ARRAY) { goto error; } - /* Logical monitor array of structs */ + // Logical monitor array of structs dbus->message_iter_next(&iter[0]); if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_ARRAY) { goto error; } - /* First logical monitor struct */ + // First logical monitor struct dbus->message_iter_recurse(&iter[0], &iter[1]); if (dbus->message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_STRUCT) { goto error; @@ -150,33 +150,33 @@ static SDL_bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) int logical_x, logical_y; dbus_bool_t primary; - /* Logical X */ + // Logical X dbus->message_iter_recurse(&iter[1], &iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_INT32) { goto error; } dbus->message_iter_get_basic(&iter[2], &logical_x); - /* Logical Y */ + // Logical Y dbus->message_iter_next(&iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_INT32) { goto error; } dbus->message_iter_get_basic(&iter[2], &logical_y); - /* Scale (don't care) */ + // Scale (don't care) dbus->message_iter_next(&iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_DOUBLE) { goto error; } - /* Transform (don't care) */ + // Transform (don't care) dbus->message_iter_next(&iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_UINT32) { goto error; } - /* Primary display boolean */ + // Primary display boolean dbus->message_iter_next(&iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_BOOLEAN) { goto error; @@ -187,7 +187,7 @@ static SDL_bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) *x = logical_x; *y = logical_y; - /* We found the primary display: success. */ + // We found the primary display: success. dbus->message_unref(reply); return SDL_TRUE; } @@ -220,7 +220,7 @@ static void handle_kde_output_order_output(void *data, struct kde_output_order_v { SDL_VideoData *vid = (SDL_VideoData *)data; - /* Starting a new list, flush the old. */ + // Starting a new list, flush the old. if (vid->output_order_finalized) { Wayland_FlushOutputOrder(vid); } @@ -255,12 +255,12 @@ static void Wayland_SortOutputs(SDL_VideoData *vid) struct wl_list sorted_list; SDL_WaylandConnectorName *c; - /* Sort the outputs by connector name. */ + // Sort the outputs by connector name. WAYLAND_wl_list_init(&sorted_list); wl_list_for_each (c, &vid->output_order, link) { wl_list_for_each (d, &vid->output_list, link) { if (d->wl_output_name && SDL_strcmp(c->wl_output_name, d->wl_output_name) == 0) { - /* Remove from the current list and Append the next node to the end of the new list. */ + // Remove from the current list and Append the next node to the end of the new list. WAYLAND_wl_list_remove(&d->link); WAYLAND_wl_list_insert(sorted_list.prev, &d->link); break; @@ -275,7 +275,7 @@ static void Wayland_SortOutputs(SDL_VideoData *vid) WAYLAND_wl_list_insert_list(sorted_list.prev, &vid->output_list); } - /* Set the output list to the sorted list. */ + // Set the output list to the sorted list. WAYLAND_wl_list_init(&vid->output_list); WAYLAND_wl_list_insert_list(&vid->output_list, &sorted_list); } else if (Wayland_GetGNOMEPrimaryDisplayCoordinates(&p_x, &p_y)) { @@ -295,7 +295,7 @@ static void Wayland_SortOutputs(SDL_VideoData *vid) static void display_handle_done(void *data, struct wl_output *output); -/* Initialization/Query functions */ +// Initialization/Query functions static int Wayland_VideoInit(SDL_VideoDevice *_this); static int Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); @@ -392,7 +392,7 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry static void wayland_preferred_check_remove_global(void *data, struct wl_registry *registry, uint32_t id) { - /* No need to do anything here. */ + // No need to do anything here. } static const struct wl_registry_listener preferred_registry_listener = { @@ -428,7 +428,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocol SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, NULL); SDL_bool display_is_external = !!display; - /* Are we trying to connect to or are currently in a Wayland session? */ + // Are we trying to connect to or are currently in a Wayland session? if (!SDL_getenv("WAYLAND_DISPLAY")) { const char *session = SDL_getenv("XDG_SESSION_TYPE"); if (session && SDL_strcasecmp(session, "wayland") != 0) { @@ -489,7 +489,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocol WAYLAND_wl_list_init(&data->output_order); WAYLAND_wl_list_init(&external_window_list); - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_free(input); @@ -507,7 +507,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocol device->internal = data; device->wakeup_lock = SDL_CreateMutex(); - /* Set the function pointers */ + // Set the function pointers device->VideoInit = Wayland_VideoInit; device->VideoQuit = Wayland_VideoQuit; device->GetDisplayBounds = Wayland_GetDisplayBounds; @@ -653,7 +653,7 @@ static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output { SDL_DisplayData *internal = (SDL_DisplayData *)data; - /* Deprecated as of wl_output v4. */ + // Deprecated as of wl_output v4. if (wl_output_get_version(internal->output) < WL_OUTPUT_NAME_SINCE_VERSION && internal->display == 0) { SDL_free(internal->wl_output_name); @@ -666,10 +666,10 @@ static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg { SDL_DisplayData *internal = (SDL_DisplayData *)data; - /* Deprecated as of wl_output v4. */ + // Deprecated as of wl_output v4. if (wl_output_get_version(internal->output) < WL_OUTPUT_DESCRIPTION_SINCE_VERSION && internal->display == 0) { - /* xdg-output descriptions, if available, supersede wl-output model names. */ + // xdg-output descriptions, if available, supersede wl-output model names. SDL_free(internal->placeholder.name); internal->placeholder.name = SDL_strdup(description); } @@ -691,9 +691,9 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na int h; }; - /* Resolution lists courtesy of XWayland */ + // Resolution lists courtesy of XWayland const struct EmulatedMode mode_list[] = { - /* 16:9 (1.77) */ + // 16:9 (1.77) { 7680, 4320 }, { 6144, 3160 }, { 5120, 2880 }, @@ -709,17 +709,17 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na { 1280, 720 }, { 864, 486 }, - /* 16:10 (1.6) */ + // 16:10 (1.6) { 2560, 1600 }, { 1920, 1200 }, { 1680, 1050 }, { 1440, 900 }, { 1280, 800 }, - /* 3:2 (1.5) */ + // 3:2 (1.5) { 720, 480 }, - /* 4:3 (1.33) */ + // 4:3 (1.33) { 2048, 1536 }, { 1920, 1440 }, { 1600, 1200 }, @@ -736,7 +736,7 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na int i; SDL_DisplayMode mode; SDL_VideoDisplay *dpy = dispdata->display ? SDL_GetVideoDisplay(dispdata->display) : &dispdata->placeholder; - const SDL_bool rot_90 = native_width < native_height; /* Reverse width/height for portrait displays. */ + const SDL_bool rot_90 = native_width < native_height; // Reverse width/height for portrait displays. for (i = 0; i < SDL_arraysize(mode_list); ++i) { SDL_zero(mode); @@ -752,7 +752,7 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na mode.h = mode_list[i].h; } - /* Only add modes that are smaller than the native mode. */ + // Only add modes that are smaller than the native mode. if ((mode.w < native_width && mode.h < native_height) || (mode.w < native_width && mode.h == native_height) || (mode.w == native_width && mode.h < native_height)) { @@ -774,7 +774,7 @@ static void display_handle_geometry(void *data, { SDL_DisplayData *internal = (SDL_DisplayData *)data; - /* Apply the change from wl-output only if xdg-output is not supported */ + // Apply the change from wl-output only if xdg-output is not supported if (!internal->has_logical_position) { internal->x = x; internal->y = y; @@ -782,7 +782,7 @@ static void display_handle_geometry(void *data, internal->physical_width = physical_width; internal->physical_height = physical_height; - /* The model is only used for the output name if wl_output or xdg-output haven't provided a description. */ + // The model is only used for the output name if wl_output or xdg-output haven't provided a description. if (internal->display == 0 && !internal->placeholder.name) { internal->placeholder.name = SDL_strdup(model); } @@ -867,17 +867,17 @@ static void display_handle_done(void *data, return; } - /* If the display was already created, reset and rebuild the mode list. */ + // If the display was already created, reset and rebuild the mode list. dpy = SDL_GetVideoDisplay(internal->display); if (dpy) { SDL_ResetFullscreenDisplayModes(dpy); } - /* The native display resolution */ + // The native display resolution SDL_zero(native_mode); native_mode.format = SDL_PIXELFORMAT_XRGB8888; - /* Transform the pixel values, if necessary. */ + // Transform the pixel values, if necessary. if (internal->transform & WL_OUTPUT_TRANSFORM_90) { native_mode.w = internal->pixel_height; native_mode.h = internal->pixel_width; @@ -888,14 +888,14 @@ static void display_handle_done(void *data, native_mode.refresh_rate_numerator = internal->refresh; native_mode.refresh_rate_denominator = 1000; - if (internal->has_logical_size) { /* If xdg-output is present... */ + if (internal->has_logical_size) { // If xdg-output is present... if (native_mode.w != internal->screen_width || native_mode.h != internal->screen_height) { - /* ...and the compositor scales the logical viewport... */ + // ...and the compositor scales the logical viewport... if (video->viewporter) { - /* ...and viewports are supported, calculate the true scale of the output. */ + // ...and viewports are supported, calculate the true scale of the output. internal->scale_factor = (float)native_mode.w / (float)internal->screen_width; } else { - /* ...otherwise, the 'native' pixel values are a multiple of the logical screen size. */ + // ...otherwise, the 'native' pixel values are a multiple of the logical screen size. internal->pixel_width = internal->screen_width * (int)internal->scale_factor; internal->pixel_height = internal->screen_height * (int)internal->scale_factor; } @@ -914,7 +914,7 @@ static void display_handle_done(void *data, internal->screen_height = native_mode.h / (int)internal->scale_factor; } - /* The scaled desktop mode */ + // The scaled desktop mode SDL_zero(desktop_mode); desktop_mode.format = SDL_PIXELFORMAT_XRGB8888; @@ -941,14 +941,14 @@ static void display_handle_done(void *data, SDL_SetDisplayContentScale(dpy, internal->scale_factor); } - /* Set the desktop display mode. */ + // Set the desktop display mode. SDL_SetDesktopDisplayMode(dpy, &desktop_mode); - /* Expose the unscaled, native resolution if the scale is 1.0 or viewports are available... */ + // Expose the unscaled, native resolution if the scale is 1.0 or viewports are available... if (internal->scale_factor == 1.0f || video->viewporter) { SDL_AddFullscreenDisplayMode(dpy, &native_mode); } else { - /* ...otherwise expose the integer scaled variants of the desktop resolution down to 1. */ + // ...otherwise expose the integer scaled variants of the desktop resolution down to 1. int i; desktop_mode.pixel_density = 1.0f; @@ -960,14 +960,14 @@ static void display_handle_done(void *data, } } - /* Add emulated modes if wp_viewporter is supported and mode emulation is enabled. */ + // Add emulated modes if wp_viewporter is supported and mode emulation is enabled. if (video->viewporter && mode_emulation_enabled) { - /* The transformed display pixel width/height must be used here. */ + // The transformed display pixel width/height must be used here. AddEmulatedModes(internal, native_mode.w, native_mode.h); } if (internal->display == 0) { - /* First time getting display info, initialize the VideoDisplay */ + // First time getting display info, initialize the VideoDisplay if (internal->physical_width >= internal->physical_height) { internal->placeholder.natural_orientation = SDL_ORIENTATION_LANDSCAPE; } else { @@ -976,7 +976,7 @@ static void display_handle_done(void *data, internal->placeholder.current_orientation = internal->orientation; internal->placeholder.internal = internal; - /* During initialization, the displays will be added after enumeration is complete. */ + // During initialization, the displays will be added after enumeration is complete. if (!video->initializing) { internal->display = SDL_AddVideoDisplay(&internal->placeholder, SDL_TRUE); SDL_free(internal->placeholder.name); @@ -1008,19 +1008,19 @@ static void display_handle_description(void *data, struct wl_output *wl_output, SDL_DisplayData *internal = (SDL_DisplayData *)data; if (internal->display == 0) { - /* The description, if available, supersedes the model name. */ + // The description, if available, supersedes the model name. SDL_free(internal->placeholder.name); internal->placeholder.name = SDL_strdup(description); } } static const struct wl_output_listener output_listener = { - display_handle_geometry, /* Version 1 */ - display_handle_mode, /* Version 1 */ - display_handle_done, /* Version 2 */ - display_handle_scale, /* Version 2 */ - display_handle_name, /* Version 4 */ - display_handle_description /* Version 4 */ + display_handle_geometry, // Version 1 + display_handle_mode, // Version 1 + display_handle_done, // Version 2 + display_handle_scale, // Version 2 + display_handle_name, // Version 4 + display_handle_description // Version 4 }; static int Wayland_add_display(SDL_VideoData *d, uint32_t id, uint32_t version) @@ -1041,7 +1041,7 @@ static int Wayland_add_display(SDL_VideoData *d, uint32_t id, uint32_t version) wl_output_add_listener(output, &output_listener, data); SDL_WAYLAND_register_output(output); - /* Keep a list of outputs for deferred xdg-output initialization. */ + // Keep a list of outputs for deferred xdg-output initialization. WAYLAND_wl_list_insert(d->output_list.prev, &data->link); if (data->videodata->xdg_output_manager) { @@ -1075,7 +1075,7 @@ static void Wayland_free_display(SDL_VideoDisplay *display) wl_output_destroy(display_data->output); } - /* Unlink this display. */ + // Unlink this display. WAYLAND_wl_list_remove(&display_data->link); SDL_DelVideoDisplay(display->id, SDL_FALSE); @@ -1130,7 +1130,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint { SDL_VideoData *d = data; - /*printf("WAYLAND INTERFACE: %s\n", interface);*/ + // printf("WAYLAND INTERFACE: %s\n", interface); if (SDL_strcmp(interface, "wl_compositor") == 0) { d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, SDL_min(SDL_WL_COMPOSITOR_VERSION, version)); @@ -1169,7 +1169,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint d->tablet_manager = wl_registry_bind(d->registry, id, &zwp_tablet_manager_v2_interface, 1); Wayland_input_init_tablet_support(d->input, d->tablet_manager); } else if (SDL_strcmp(interface, "zxdg_output_manager_v1") == 0) { - version = SDL_min(version, 3); /* Versions 1 through 3 are supported. */ + version = SDL_min(version, 3); // Versions 1 through 3 are supported. d->xdg_output_manager = wl_registry_bind(d->registry, id, &zxdg_output_manager_v1_interface, version); Wayland_init_xdg_output(d); } else if (SDL_strcmp(interface, "wp_viewporter") == 0) { @@ -1205,7 +1205,7 @@ static void display_remove_global(void *data, struct wl_registry *registry, uint SDL_VideoData *d = data; SDL_DisplayData *node; - /* We don't get an interface, just an ID, so assume it's a wl_output :shrug: */ + // We don't get an interface, just an ID, so assume it's a wl_output :shrug: wl_list_for_each (node, &d->output_list, link) { if (node->registry_id == id) { Wayland_free_display(SDL_GetVideoDisplay(node->display)); @@ -1250,7 +1250,7 @@ SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg) { #ifdef HAVE_LIBDECOR_H if (data->shell.libdecor != NULL) { - return SDL_TRUE; /* Already loaded! */ + return SDL_TRUE; // Already loaded! } if (should_use_libdecor(data, ignore_xdg)) { data->shell.libdecor = libdecor_new(data->display, &libdecor_interface); @@ -1285,7 +1285,7 @@ int Wayland_VideoInit(SDL_VideoDevice *_this) data->scale_to_display_enabled = SDL_FALSE; } - /* Now that we have all the protocols, load libdecor if applicable */ + // Now that we have all the protocols, load libdecor if applicable Wayland_LoadLibdecor(data, SDL_FALSE); // Second roundtrip to receive all output events. @@ -1317,7 +1317,7 @@ static int Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *di rect->x = internal->x; rect->y = internal->y; - /* When an emulated, exclusive fullscreen window has focus, treat the mode dimensions as the display bounds. */ + // When an emulated, exclusive fullscreen window has focus, treat the mode dimensions as the display bounds. if (display->fullscreen_window && display->fullscreen_window->fullscreen_exclusive && display->fullscreen_window->internal->active && @@ -1485,7 +1485,7 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this) SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this) { -#if 0 /* TODO RECONNECT: Uncomment all when https://invent.kde.org/plasma/kwin/-/wikis/Restarting is completed */ +#if 0 // TODO RECONNECT: Uncomment all when https://invent.kde.org/plasma/kwin/-/wikis/Restarting is completed SDL_VideoData *data = _this->internal; SDL_Window *window = NULL; @@ -1527,7 +1527,7 @@ SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this) return SDL_TRUE; #else return SDL_FALSE; -#endif /* 0 */ +#endif // 0 } void Wayland_VideoQuit(SDL_VideoDevice *_this) @@ -1543,4 +1543,4 @@ void Wayland_VideoQuit(SDL_VideoDevice *_this) #endif } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h index 51b821aa1c..e2865484d1 100644 --- a/src/video/wayland/SDL_waylandvideo.h +++ b/src/video/wayland/SDL_waylandvideo.h @@ -117,7 +117,7 @@ struct SDL_DisplayData struct wl_list link; }; -/* Needed here to get wl_surface declaration, fixes GitHub#4594 */ +// Needed here to get wl_surface declaration, fixes GitHub#4594 #include "SDL_waylanddyn.h" extern void SDL_WAYLAND_register_surface(struct wl_surface *surface); @@ -133,4 +133,4 @@ extern SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg); extern SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this); -#endif /* SDL_waylandvideo_h_ */ +#endif // SDL_waylandvideo_h_ diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 97cb61426f..d3f4b5778f 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -52,7 +52,7 @@ int Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } diff --git a/src/video/wayland/SDL_waylandvulkan.h b/src/video/wayland/SDL_waylandvulkan.h index b71433c40b..6425cb266e 100644 --- a/src/video/wayland/SDL_waylandvulkan.h +++ b/src/video/wayland/SDL_waylandvulkan.h @@ -53,4 +53,4 @@ SDL_bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, #endif -#endif /* SDL_waylandvulkan_h_ */ +#endif // SDL_waylandvulkan_h_ diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 986275ecda..6402982169 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -50,7 +50,7 @@ /* These are *NOT* roundtrip safe! */ static int PointToPixel(SDL_Window *window, int point) { - /* Rounds halfway away from zero as per the Wayland fractional scaling protocol spec. */ + // Rounds halfway away from zero as per the Wayland fractional scaling protocol spec. return (int)SDL_lroundf((float)point * window->internal->windowed_scale_factor); } @@ -118,12 +118,12 @@ static void GetBufferSize(SDL_Window *window, int *width, int *height) int buf_width; int buf_height; - /* Exclusive fullscreen modes always have a pixel density of 1 */ + // Exclusive fullscreen modes always have a pixel density of 1 if (data->is_fullscreen && window->fullscreen_exclusive) { buf_width = window->current_fullscreen_mode.w; buf_height = window->current_fullscreen_mode.h; } else if (!data->scale_to_display) { - /* Round fractional backbuffer sizes halfway away from zero. */ + // Round fractional backbuffer sizes halfway away from zero. buf_width = PointToPixel(window, data->requested.logical_width); buf_height = PointToPixel(window, data->requested.logical_height); } else { @@ -177,7 +177,7 @@ static void SetMinMaxDimensions(SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.initial_configure_seen || !wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } /* No need to change these values if the window is non-resizable, * as libdecor will just overwrite them internally. @@ -194,7 +194,7 @@ static void SetMinMaxDimensions(SDL_Window *window) #endif if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } xdg_toplevel_set_min_size(wind->shell_surface.xdg.roleobj.toplevel, min_width, @@ -244,7 +244,7 @@ static void EnsurePopupPositionIsValid(SDL_Window *window, int *x, int *y) static void AdjustPopupOffset(SDL_Window *popup, int *x, int *y) { - /* Adjust the popup positioning, if necessary */ + // Adjust the popup positioning, if necessary #ifdef HAVE_LIBDECOR_H if (popup->parent->internal->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { int adj_x, adj_y; @@ -304,7 +304,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) int window_width, window_height; SDL_bool window_size_changed; - /* Set the drawable backbuffer size. */ + // Set the drawable backbuffer size. GetBufferSize(window, &data->current.pixel_width, &data->current.pixel_height); const SDL_bool buffer_size_changed = data->current.pixel_width != old_pixel_width || data->current.pixel_height != old_pixel_height; @@ -363,7 +363,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) data->current.logical_width = output_width; data->current.logical_height = output_height; } else { - /* Calculate the integer scale from the mode and output. */ + // Calculate the integer scale from the mode and output. const int32_t int_scale = SDL_max(window->current_fullscreen_mode.w / output_width, 1); wl_surface_set_buffer_scale(data->surface, int_scale); @@ -384,11 +384,11 @@ static void ConfigureWindowGeometry(SDL_Window *window) if (data->viewport) { wp_viewport_set_destination(data->viewport, window_width, window_height); } else if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { - /* Don't change this if the DPI awareness flag is unset, as an application may have set this manually on a custom or external surface. */ + // Don't change this if the DPI awareness flag is unset, as an application may have set this manually on a custom or external surface. wl_surface_set_buffer_scale(data->surface, (int32_t)data->windowed_scale_factor); } - /* Clamp the physical window size to the system minimum required size. */ + // Clamp the physical window size to the system minimum required size. data->current.logical_width = SDL_max(window_width, data->system_limits.min_width); data->current.logical_height = SDL_max(window_height, data->system_limits.min_height); @@ -417,7 +417,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) SetSurfaceOpaqueRegion(data, !(window->flags & SDL_WINDOW_TRANSPARENT) && window->opacity == 1.0f); - /* Ensure that child popup windows are still in bounds. */ + // Ensure that child popup windows are still in bounds. for (SDL_Window *child = window->first_child; child; child = child->next_sibling) { RepositionPopup(child, SDL_TRUE); } @@ -428,7 +428,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) */ SetMinMaxDimensions(window); - /* Unconditionally send the window and drawable size, the video core will deduplicate when required. */ + // Unconditionally send the window and drawable size, the video core will deduplicate when required. if (!data->scale_to_display) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window_width, window_height); } else { @@ -469,7 +469,7 @@ static void CommitLibdecorFrame(SDL_Window *window) static void fullscreen_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data) { - /* Get the window from the ID as it may have been destroyed */ + // Get the window from the ID as it may have been destroyed SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); SDL_Window *window = SDL_GetWindowFromID(windowID); @@ -486,7 +486,7 @@ static struct wl_callback_listener fullscreen_deadline_listener = { static void maximized_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data) { - /* Get the window from the ID as it may have been destroyed */ + // Get the window from the ID as it may have been destroyed SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); SDL_Window *window = SDL_GetWindowFromID(windowID); @@ -521,7 +521,7 @@ static void Wayland_move_window(SDL_Window *window) if (wind->outputs && wind->num_outputs) { display = wind->outputs[wind->num_outputs - 1]; } else { - /* A window may not be on any displays if minimized. */ + // A window may not be on any displays if minimized. return; } @@ -571,7 +571,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : SDL_FALSE; @@ -588,7 +588,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) #endif if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : SDL_FALSE; @@ -603,7 +603,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) } } - /* Queue a deadline event */ + // Queue a deadline event struct wl_callback *cb = wl_display_sync(viddata->display); wl_callback_add_listener(cb, &fullscreen_deadline_listener, (void *)((uintptr_t)window->id)); } @@ -634,7 +634,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) } } } else { - /* Don't change the fullscreen flags if the window is hidden or being hidden. */ + // Don't change the fullscreen flags if the window is hidden or being hidden. if ((window->flags & SDL_WINDOW_FULLSCREEN) && !window->is_hiding && !(window->flags & SDL_WINDOW_HIDDEN)) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_FALSE); @@ -667,7 +667,7 @@ static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time if (wind->surface_status == WAYLAND_SURFACE_STATUS_WAITING_FOR_FRAME) { wind->surface_status = WAYLAND_SURFACE_STATUS_SHOWN; - /* If any child windows are waiting on this window to be shown, show them now */ + // If any child windows are waiting on this window to be shown, show them now for (SDL_Window *w = wind->sdlwindow->first_child; w; w = w->next_sibling) { if (w->internal->surface_status == WAYLAND_SURFACE_STATUS_SHOW_PENDING) { Wayland_ShowWindow(SDL_GetVideoDevice(), w); @@ -698,9 +698,9 @@ 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) { SDL_WindowData *wind = (SDL_WindowData *)data; - SDL_AtomicSet(&wind->swap_interval_ready, 1); /* mark window as ready to present again. */ + 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. */ + // 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); wl_callback_destroy(cb); wl_callback_add_listener(wind->gles_swap_frame_callback, &gles_swap_frame_listener, data); @@ -781,7 +781,7 @@ static void handle_configure_xdg_toplevel(void *data, */ if (active || !(window->flags & SDL_WINDOW_MINIMIZED)) { if (window->flags & SDL_WINDOW_MINIMIZED) { - /* If we were minimized, send a restored event before possibly sending maximized. */ + // If we were minimized, send a restored event before possibly sending maximized. SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); } SDL_SendWindowEvent(window, @@ -872,7 +872,7 @@ static void handle_configure_xdg_toplevel(void *data, } wind->requested.logical_height = SDL_max(wind->requested.logical_height, window->min_h); - /* Aspect correction. */ + // Aspect correction. const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; if (window->min_aspect != 0.f && aspect < window->min_aspect) { @@ -891,7 +891,7 @@ static void handle_configure_xdg_toplevel(void *data, } wind->requested.pixel_height = SDL_max(wind->requested.pixel_height, window->min_h); - /* Aspect correction. */ + // Aspect correction. const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; if (window->min_aspect != 0.f && aspect < window->min_aspect) { @@ -905,7 +905,7 @@ static void handle_configure_xdg_toplevel(void *data, } } } else { - /* Fullscreen windows know their exact size. */ + // Fullscreen windows know their exact size. if (width == 0 || height == 0) { width = wind->requested.logical_width; height = wind->requested.logical_height; @@ -942,21 +942,21 @@ static void handle_xdg_configure_toplevel_bounds(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) { - /* NOP */ + // NOP } void handle_xdg_toplevel_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel, struct wl_array *capabilities) { - /* NOP */ + // NOP } static const struct xdg_toplevel_listener toplevel_listener_xdg = { handle_configure_xdg_toplevel, handle_close_xdg_toplevel, - handle_xdg_configure_toplevel_bounds, /* Version 4 */ - handle_xdg_toplevel_wm_capabilities /* Version 5 */ + handle_xdg_configure_toplevel_bounds, // Version 4 + handle_xdg_toplevel_wm_capabilities // Version 5 }; static void handle_configure_xdg_popup(void *data, @@ -969,7 +969,7 @@ static void handle_configure_xdg_popup(void *data, SDL_WindowData *wind = (SDL_WindowData *)data; int offset_x = 0, offset_y = 0; - /* Adjust the position if it was offset for libdecor */ + // Adjust the position if it was offset for libdecor AdjustPopupOffset(wind->sdlwindow, &offset_x, &offset_y); x -= offset_x; y -= offset_y; @@ -1001,7 +1001,7 @@ 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 */ + // No-op, configure does all the work we care about } static const struct xdg_popup_listener popup_listener_xdg = { @@ -1025,11 +1025,11 @@ static void handle_configure_zxdg_decoration(void *data, */ if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE) { if (window->flags & SDL_WINDOW_BORDERLESS) { - /* borderless windows do request CSD, so we got what we wanted */ + // borderless windows do request CSD, so we got what we wanted return; } if (!Wayland_LoadLibdecor(internal->waylandData, SDL_TRUE)) { - /* libdecor isn't available, so no borders for you... oh well */ + // libdecor isn't available, so no borders for you... oh well return; } WAYLAND_wl_display_roundtrip(internal->waylandData->display); @@ -1110,7 +1110,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, 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 */ + // Window State if (libdecor_configuration_get_window_state(configuration, &window_state)) { fullscreen = (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) != 0; maximized = (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) != 0; @@ -1134,7 +1134,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, */ if (active || !(window->flags & SDL_WINDOW_MINIMIZED)) { if (window->flags & SDL_WINDOW_MINIMIZED) { - /* If we were minimized, send a restored event before possibly sending maximized. */ + // If we were minimized, send a restored event before possibly sending maximized. SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); } SDL_SendWindowEvent(window, @@ -1150,7 +1150,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, width = wind->requested.logical_width; height = wind->requested.logical_height; } else { - /* Fullscreen windows know their exact size. */ + // Fullscreen windows know their exact size. wind->requested.logical_width = width; wind->requested.logical_height = height; @@ -1249,7 +1249,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, } wind->requested.logical_height = SDL_max(wind->requested.logical_height, window->min_h); - /* Aspect correction. */ + // Aspect correction. const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; if (window->min_aspect != 0.f && aspect < window->min_aspect) { @@ -1268,7 +1268,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, } wind->requested.pixel_height = SDL_max(wind->requested.pixel_height, window->min_h); - /* Aspect correction. */ + // Aspect correction. const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; if (window->min_aspect != 0.f && aspect < window->min_aspect) { @@ -1283,7 +1283,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, } } - /* Store the new state. */ + // Store the new state. wind->last_configure.width = width; wind->last_configure.height = height; wind->floating = floating; @@ -1291,10 +1291,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame, wind->active = active; window->tiled = tiled; - /* Calculate the new window geometry */ + // Calculate the new window geometry ConfigureWindowGeometry(window); - /* ... then commit the changes on the libdecor side. */ + // ... then commit the changes on the libdecor side. state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); @@ -1347,11 +1347,11 @@ static void Wayland_HandlePreferredScaleChanged(SDL_WindowData *window_data, flo const float old_factor = window_data->windowed_scale_factor; if (!(window_data->sdlwindow->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) && !window_data->scale_to_display) { - /* Scale will always be 1, just ignore this */ + // Scale will always be 1, just ignore this return; } - /* Round the scale factor if viewports aren't available. */ + // Round the scale factor if viewports aren't available. if (!window_data->viewport) { factor = SDL_ceilf(factor); } @@ -1393,14 +1393,14 @@ static void Wayland_MaybeUpdateScaleFactor(SDL_WindowData *window) } if (window->num_outputs != 0) { - /* Check every display's factor, use the highest */ + // Check every display's factor, use the highest factor = 0.0f; for (i = 0; i < window->num_outputs; i++) { SDL_DisplayData *internal = window->outputs[i]; factor = SDL_max(factor, internal->scale_factor); } } else { - /* All outputs removed, just fall back. */ + // All outputs removed, just fall back. factor = window->windowed_scale_factor; } @@ -1410,7 +1410,7 @@ static void Wayland_MaybeUpdateScaleFactor(SDL_WindowData *window) void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data) { for (int i = 0; i < window->num_outputs; i++) { - if (window->outputs[i] == display_data) { /* remove this one */ + if (window->outputs[i] == display_data) { // remove this one if (i == (window->num_outputs - 1)) { window->outputs[i] = NULL; } else { @@ -1450,7 +1450,7 @@ static void handle_surface_enter(void *data, struct wl_surface *surface, struct window->outputs = new_outputs; window->outputs[window->num_outputs++] = internal; - /* Update the scale factor after the move so that fullscreen outputs are updated. */ + // Update the scale factor after the move so that fullscreen outputs are updated. if (!window->is_fullscreen || window->num_outputs == 1) { Wayland_move_window(window->sdlwindow); Wayland_MaybeUpdateScaleFactor(window); @@ -1483,7 +1483,7 @@ static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surf static void handle_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform) { - /* Nothing to do here. */ + // Nothing to do here. } static const struct wl_surface_listener surface_listener = { @@ -1495,7 +1495,7 @@ static const struct wl_surface_listener surface_listener = { static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) { - const float factor = scale / 120.f; /* 120 is a magic number defined in the spec as a common denominator */ + const float factor = scale / 120.f; // 120 is a magic number defined in the spec as a common denominator Wayland_HandlePreferredScaleChanged(data, factor); } @@ -1548,7 +1548,7 @@ static void SetKeyboardFocus(SDL_Window *window) { SDL_Window *topmost = window; - /* Find the topmost parent */ + // Find the topmost parent while (topmost->parent) { topmost = topmost->parent; } @@ -1560,7 +1560,7 @@ static void SetKeyboardFocus(SDL_Window *window) 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(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window) @@ -1574,7 +1574,7 @@ int Wayland_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, modal_data->modal_reparenting_required = SDL_FALSE; if (parent_data && parent_data->surface_status != WAYLAND_SURFACE_STATUS_SHOWN) { - /* Need to wait for the parent to become mapped, or it's the same as setting a null parent. */ + // Need to wait for the parent to become mapped, or it's the same as setting a null parent. modal_data->modal_reparenting_required = SDL_TRUE; return 0; } @@ -1624,7 +1624,7 @@ int Wayland_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, static void show_hide_sync_handler(void *data, struct wl_callback *callback, uint32_t callback_data) { - /* Get the window from the ID as it may have been destroyed */ + // Get the window from the ID as it may have been destroyed SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); SDL_Window *window = SDL_GetWindowFromID(windowID); @@ -1658,7 +1658,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; SDL_PropertiesID props = SDL_GetWindowProperties(window); - /* Custom surfaces don't get toplevels and are always considered 'shown'; nothing to do here. */ + // Custom surfaces don't get toplevels and are always considered 'shown'; nothing to do here. if (data->shell_surface_type == WAYLAND_SURFACE_CUSTOM) { return; } @@ -1704,7 +1704,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) wl_surface_attach(data->surface, NULL, 0, 0); wl_surface_commit(data->surface); - /* Create the shell surface and map the toplevel/popup */ + // Create the shell surface and map the toplevel/popup #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, @@ -1739,7 +1739,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) struct xdg_surface *parent_xdg_surface = NULL; int position_x = 0, position_y = 0; - /* Configure the popup parameters */ + // Configure the popup parameters #ifdef HAVE_LIBDECOR_H if (parent_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { parent_xdg_surface = libdecor_frame_get_xdg_surface(parent_data->shell_surface.libdecor.frame); @@ -1750,7 +1750,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) parent_xdg_surface = parent_data->shell_surface.xdg.surface; } - /* Set up the positioner for the popup and configure the constraints */ + // Set up the positioner for the popup and configure the constraints data->shell_surface.xdg.roleobj.popup.positioner = xdg_wm_base_create_positioner(c->shell.xdg); xdg_positioner_set_anchor(data->shell_surface.xdg.roleobj.popup.positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT); xdg_positioner_set_anchor_rect(data->shell_surface.xdg.roleobj.popup.positioner, 0, 0, parent->internal->current.logical_width, parent->internal->current.logical_width); @@ -1759,7 +1759,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) xdg_positioner_set_gravity(data->shell_surface.xdg.roleobj.popup.positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT); xdg_positioner_set_size(data->shell_surface.xdg.roleobj.popup.positioner, data->current.logical_width, data->current.logical_height); - /* Set the popup initial position */ + // Set the popup initial position position_x = window->x; position_y = window->y; EnsurePopupPositionIsValid(window, &position_x, &position_y); @@ -1770,7 +1770,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) AdjustPopupOffset(window, &position_x, &position_y); xdg_positioner_set_offset(data->shell_surface.xdg.roleobj.popup.positioner, position_x, position_y); - /* Assign the popup role */ + // Assign the popup role data->shell_surface.xdg.roleobj.popup.popup = xdg_surface_get_popup(data->shell_surface.xdg.surface, parent_xdg_surface, data->shell_surface.xdg.roleobj.popup.positioner); @@ -1779,7 +1779,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) if (window->flags & SDL_WINDOW_TOOLTIP) { struct wl_region *region; - /* Tooltips can't be interacted with, so turn off the input region to avoid blocking anything behind them */ + // Tooltips can't be interacted with, so turn off the input region to avoid blocking anything behind them region = wl_compositor_create_region(c->compositor); wl_region_add(region, 0, 0, 0, 0); wl_surface_set_input_region(data->surface, region); @@ -1806,7 +1806,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) } } - /* Restore state that was set prior to this call */ + // Restore state that was set prior to this call if (window->flags & SDL_WINDOW_MODAL) { Wayland_SetWindowModalFor(_this, window, window->parent); } @@ -1839,7 +1839,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) } } - /* Create the window decorations */ + // Create the window decorations if (data->shell_surface_type != WAYLAND_SURFACE_XDG_POPUP && data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) { data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel); zxdg_toplevel_decoration_v1_add_listener(data->server_decoration, @@ -1847,11 +1847,11 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) window); } } else { - /* Nothing to see here, just commit. */ + // Nothing to see here, just commit. wl_surface_commit(data->surface); } - /* Make sure the window can't be resized to 0 or it can be spuriously closed by the window manager. */ + // Make sure the window can't be resized to 0 or it can be spuriously closed by the window manager. data->system_limits.min_width = SDL_max(data->system_limits.min_width, 1); data->system_limits.min_height = SDL_max(data->system_limits.min_height, 1); @@ -1861,11 +1861,11 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) */ #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - /* Libdecor plugins can enforce minimum window sizes, so adjust if the initial window size is too small. */ + // Libdecor plugins can enforce minimum window sizes, so adjust if the initial window size is too small. if (window->windowed.w < data->system_limits.min_width || window->windowed.h < data->system_limits.min_height) { - /* Warn if the window frame will be larger than the content surface. */ + // Warn if the window frame will be larger than the content surface. SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Window dimensions (%i, %i) are smaller than the system enforced minimum (%i, %i); window borders will be larger than the content surface.", window->windowed.w, window->windowed.h, data->system_limits.min_width, data->system_limits.min_height); @@ -1879,7 +1879,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) Wayland_SetWindowResizable(_this, window, !!(window->flags & SDL_WINDOW_RESIZABLE)); Wayland_SetWindowBordered(_this, window, !(window->flags & SDL_WINDOW_BORDERLESS)); - /* We're finally done putting the window together, raise if possible */ + // We're finally done putting the window together, raise if possible if (c->activation_manager) { /* Note that we don't check for empty strings, as that is still * considered a valid activation token! @@ -1890,7 +1890,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) activation_token, data->surface); - /* Clear this variable, per the protocol's request */ + // Clear this variable, per the protocol's request unsetenv("XDG_ACTIVATION_TOKEN"); } } @@ -1899,7 +1899,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) struct wl_callback *cb = wl_display_sync(_this->internal->display); wl_callback_add_listener(cb, &show_hide_sync_listener, (void*)((uintptr_t)window->id)); - /* Send an exposure event to signal that the client should draw. */ + // Send an exposure event to signal that the client should draw. if (data->surface_status == WAYLAND_SURFACE_STATUS_WAITING_FOR_FRAME) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); } @@ -1909,7 +1909,7 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) { SDL_WindowData *popupdata; - /* Basic sanity checks to weed out the weird popup closures */ + // Basic sanity checks to weed out the weird popup closures if (!SDL_ObjectValid(popup, SDL_OBJECT_TYPE_WINDOW)) { return; } @@ -1918,7 +1918,7 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) return; } - /* This may already be freed by a parent popup! */ + // This may already be freed by a parent popup! if (popupdata->shell_surface.xdg.roleobj.popup.popup == NULL) { return; } @@ -1927,7 +1927,7 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) if (popup == SDL_GetKeyboardFocus()) { SDL_Window *new_focus = popup->parent; - /* Find the highest level window that isn't being hidden or destroyed. */ + // Find the highest level window that isn't being hidden or destroyed. while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1952,7 +1952,7 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *wind = window->internal; SDL_PropertiesID props = SDL_GetWindowProperties(window); - /* Custom surfaces have nothing to destroy and are always considered to be 'shown'; nothing to do here. */ + // Custom surfaces have nothing to destroy and are always considered to be 'shown'; nothing to do here. if (wind->shell_surface_type == WAYLAND_SURFACE_CUSTOM) { return; } @@ -1971,13 +1971,13 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) wind->server_decoration = NULL; } - /* Be sure to detach after this is done, otherwise ShowWindow crashes! */ + // Be sure to detach after this is done, otherwise ShowWindow crashes! if (wind->shell_surface_type != WAYLAND_SURFACE_XDG_POPUP) { wl_surface_attach(wind->surface, NULL, 0, 0); wl_surface_commit(wind->surface); } - /* Clean up the export handle. */ + // Clean up the export handle. if (wind->exported) { zxdg_exported_v2_destroy(wind->exported); wind->exported = NULL; @@ -2065,7 +2065,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ if (data->activation_manager) { if (target_wind->activation_token) { - /* We're about to overwrite this with a new request */ + // We're about to overwrite this with a new request xdg_activation_token_v1_destroy(target_wind->activation_token); } @@ -2082,7 +2082,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ * -flibit */ if (requesting_surface) { - /* This specifies the surface from which the activation request is originating, not the activation target surface. */ + // This specifies the surface from which the activation request is originating, not the activation target surface. xdg_activation_token_v1_set_surface(target_wind->activation_token, requesting_surface); } if (set_serial && input && input->seat) { @@ -2112,7 +2112,7 @@ int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_WindowData *wind = window->internal; struct wl_output *output = display->internal->output; - /* Custom surfaces have no toplevel to make fullscreen. */ + // Custom surfaces have no toplevel to make fullscreen. if (wind->shell_surface_type == WAYLAND_SURFACE_CUSTOM) { return -1; } @@ -2121,7 +2121,7 @@ int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, WAYLAND_wl_display_roundtrip(_this->internal->display); } - /* Flushing old events pending a new one, ignore this request. */ + // Flushing old events pending a new one, ignore this request. if (wind->drop_fullscreen_requests) { return 0; } @@ -2130,18 +2130,18 @@ int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, FlushPendingEvents(window); wind->drop_fullscreen_requests = SDL_FALSE; - /* Nothing to do if the window is not fullscreen, and this isn't an explicit enter request. */ + // Nothing to do if the window is not fullscreen, and this isn't an explicit enter request. if (!wind->is_fullscreen) { if (fullscreen == SDL_FULLSCREEN_OP_UPDATE) { - /* Request was out of date; return 1 to signal the video core not to update any state. */ + // Request was out of date; return 1 to signal the video core not to update any state. return 1; } else if (fullscreen == SDL_FULLSCREEN_OP_LEAVE) { - /* Already not fullscreen; nothing to do. */ + // Already not fullscreen; nothing to do. return 0; } } - /* Don't send redundant fullscreen set/unset events. */ + // Don't send redundant fullscreen set/unset events. if (fullscreen != wind->is_fullscreen) { wind->fullscreen_was_positioned = fullscreen; SetFullscreen(window, fullscreen ? output : NULL); @@ -2174,15 +2174,15 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); } else #endif - /* Note that xdg-shell does NOT provide a way to unset minimize! */ + // Note that xdg-shell does NOT provide a way to unset minimize! if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } xdg_toplevel_unset_maximized(wind->shell_surface.xdg.roleobj.toplevel); } @@ -2215,7 +2215,7 @@ void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_ if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } if (libdecor_frame_has_capability(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE)) { if (!resizable) { @@ -2246,20 +2246,20 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } - /* Commit to preserve any pending size data. */ + // Commit to preserve any pending size data. wl_surface_commit(wind->surface); libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); } else #endif if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } - /* Commit to preserve any pending size data. */ + // Commit to preserve any pending size data. wl_surface_commit(wind->surface); xdg_toplevel_set_maximized(wind->shell_surface.xdg.roleobj.toplevel); } @@ -2273,11 +2273,11 @@ void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *wind = window->internal; - /* TODO: Check compositor capabilities to see if minimizing is supported */ + // TODO: Check compositor capabilities to see if minimizing is supported #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (!wind->shell_surface.libdecor.frame) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); @@ -2285,7 +2285,7 @@ void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) #endif if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { - return; /* Can't do anything yet, wait for ShowWindow */ + return; // Can't do anything yet, wait for ShowWindow } xdg_toplevel_set_minimized(wind->shell_surface.xdg.roleobj.toplevel); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); @@ -2379,7 +2379,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert data->num_outputs = 0; data->scale_to_display = c->scale_to_display_enabled; - /* Cache the app_id at creation time, as it may change before the window is mapped. */ + // Cache the app_id at creation time, as it may change before the window is mapped. data->app_id = SDL_strdup(SDL_GetAppID()); if (!data->scale_to_display) { @@ -2415,7 +2415,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert if (c->viewporter) { data->viewport = wp_viewporter_get_viewport(c->viewporter, data->surface); - /* The viewport always uses the entire buffer. */ + // The viewport always uses the entire buffer. wp_viewport_set_source(data->viewport, wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1)); @@ -2438,7 +2438,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert } } - /* Must be called before EGL configuration to set the drawable backbuffer size. */ + // Must be called before EGL configuration to set the drawable backbuffer size. ConfigureWindowGeometry(window); /* Fire a callback when the compositor wants a new frame rendered. @@ -2454,9 +2454,9 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert wl_callback_add_listener(data->gles_swap_frame_callback, &gles_swap_frame_listener, data); } - /* No frame callback on external surfaces as it may already have one attached. */ + // No frame callback on external surfaces as it may already have one attached. if (!external_surface) { - /* Fire a callback when the compositor wants a new frame to set the surface damage region. */ + // Fire a callback when the compositor wants a new frame to set the surface damage region. data->surface_frame_callback = wl_surface_frame(data->surface); wl_callback_add_listener(data->surface_frame_callback, &surface_frame_listener, data); } @@ -2473,11 +2473,11 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert #ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { - /* Create the GLES window surface */ + // Create the GLES window surface data->egl_surface = SDL_EGL_CreateSurface(_this, window, (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 @@ -2486,7 +2486,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert Wayland_input_enable_relative_pointer(c->input); } - /* We may need to create an idle inhibitor for this new window */ + // We may need to create an idle inhibitor for this new window Wayland_SuspendScreenSaver(_this); if (!custom_surface_role) { @@ -2501,9 +2501,9 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert } else { data->shell_surface_type = WAYLAND_SURFACE_XDG_TOPLEVEL; } - } /* All other cases will be WAYLAND_SURFACE_UNKNOWN */ + } // All other cases will be WAYLAND_SURFACE_UNKNOWN } else { - /* Roleless and external surfaces are always considered to be in the shown state by the backend. */ + // Roleless and external surfaces are always considered to be in the shown state by the backend. data->shell_surface_type = WAYLAND_SURFACE_CUSTOM; data->surface_status = WAYLAND_SURFACE_STATUS_SHOWN; } @@ -2524,13 +2524,13 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert void Wayland_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window) { - /* Will be committed when Wayland_SetWindowSize() is called by the video core. */ + // Will be committed when Wayland_SetWindowSize() is called by the video core. SetMinMaxDimensions(window); } void Wayland_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window) { - /* Will be committed when Wayland_SetWindowSize() is called by the video core. */ + // Will be committed when Wayland_SetWindowSize() is called by the video core. SetMinMaxDimensions(window); } @@ -2538,7 +2538,7 @@ int Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *wind = window->internal; - /* Only popup windows can be positioned relative to the parent. */ + // Only popup windows can be positioned relative to the parent. if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { if (wind->shell_surface.xdg.roleobj.popup.popup && xdg_popup_get_version(wind->shell_surface.xdg.roleobj.popup.popup) < XDG_POPUP_REPOSITION_SINCE_VERSION) { @@ -2614,7 +2614,7 @@ void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) wind->pending_restored_size = SDL_TRUE; } - /* Always commit, as this may be in response to a min/max limit change. */ + // Always commit, as this may be in response to a min/max limit change. CommitLibdecorFrame(window); } @@ -2809,4 +2809,4 @@ void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) window->internal = NULL; } -#endif /* SDL_VIDEO_DRIVER_WAYLAND */ +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 01c30c7673..6b70b89396 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -116,41 +116,41 @@ struct SDL_WindowData float y; } pointer_scale; - /* The in-flight window size request. */ + // The in-flight window size request. struct { - /* The requested logical window size. */ + // The requested logical window size. int logical_width; int logical_height; - /* The size of the window in pixels, when using screen space scaling. */ + // The size of the window in pixels, when using screen space scaling. int pixel_width; int pixel_height; } requested; - /* The current size of the window and drawable backing store. */ + // The current size of the window and drawable backing store. struct { - /* The size of the underlying window. */ + // The size of the underlying window. int logical_width; int logical_height; - /* The size of the window backbuffer in pixels. */ + // The size of the window backbuffer in pixels. int pixel_width; int pixel_height; } current; - /* The last compositor requested parameters; used for deduplication of window geometry configuration. */ + // The last compositor requested parameters; used for deduplication of window geometry configuration. struct { int width; int height; } last_configure; - /* System enforced window size limits. */ + // System enforced window size limits. struct { - /* Minimum allowed logical window size. */ + // Minimum allowed logical window size. int min_width; int min_height; } system_limits; @@ -211,4 +211,4 @@ extern int Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data); -#endif /* SDL_waylandwindow_h_ */ +#endif // SDL_waylandwindow_h_ diff --git a/src/video/windows/SDL_msctf.h b/src/video/windows/SDL_msctf.h index 738696f017..76e1f4aad2 100644 --- a/src/video/windows/SDL_msctf.h +++ b/src/video/windows/SDL_msctf.h @@ -28,7 +28,7 @@ #define TF_IPSINK_FLAG_ACTIVE 0x0001 #define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off typedef struct ITfThreadMgr ITfThreadMgr; typedef struct ITfDocumentMgr ITfDocumentMgr; @@ -241,6 +241,6 @@ struct ITfSource const struct ITfSourceVtbl *lpVtbl; }; -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on -#endif /* SDL_msctf_h_ */ +#endif // SDL_msctf_h_ diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 3a23e1ed09..8c9b190d82 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -35,14 +35,14 @@ #define IMAGE_FORMAT CF_DIB #define IMAGE_MIME_TYPE "image/bmp" -#define BFT_BITMAP 0x4d42 /* 'BM' */ +#define BFT_BITMAP 0x4d42 // 'BM' -/* Assume we can directly read and write BMP fields without byte swapping */ +// Assume we can directly read and write BMP fields without byte swapping SDL_COMPILE_TIME_ASSERT(verify_byte_order, SDL_BYTEORDER == SDL_LIL_ENDIAN); static BOOL WIN_OpenClipboard(SDL_VideoDevice *_this) { - /* Retry to open the clipboard in case another application has it open */ + // Retry to open the clipboard in case another application has it open const int MAX_ATTEMPTS = 3; int attempt; HWND hwnd = NULL; @@ -149,12 +149,12 @@ static int WIN_SetClipboardImage(SDL_VideoDevice *_this) clipboard_data = _this->clipboard_callback(_this->clipboard_userdata, IMAGE_MIME_TYPE, &clipboard_data_size); hMem = WIN_ConvertBMPtoDIB(clipboard_data, clipboard_data_size); if (hMem) { - /* Save the image to the clipboard */ + // Save the image to the clipboard if (!SetClipboardData(IMAGE_FORMAT, hMem)) { result = WIN_SetError("Couldn't set clipboard data"); } } else { - /* WIN_ConvertBMPtoDIB() set the error */ + // WIN_ConvertBMPtoDIB() set the error result = -1; } return result; @@ -175,21 +175,21 @@ static int WIN_SetClipboardText(SDL_VideoDevice *_this, const char *mime_type) return SDL_SetError("Couldn't convert text from UTF-8"); } - /* Find out the size of the data */ + // 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')) { - /* We're going to insert a carriage return */ + // We're going to insert a carriage return ++size; } } size = (size + 1) * sizeof(*tstr); - /* Save the data to the clipboard */ + // Save the data to the clipboard hMem = GlobalAlloc(GMEM_MOVEABLE, size); if (hMem) { LPTSTR dst = (LPTSTR)GlobalLock(hMem); if (dst) { - /* Copy the text over, adding carriage returns as necessary */ + // 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')) { *dst++ = '\r'; @@ -225,7 +225,7 @@ int WIN_SetClipboardData(SDL_VideoDevice *_this) if (WIN_OpenClipboard(_this)) { EmptyClipboard(); - /* Set the clipboard text */ + // Set the clipboard text for (i = 0; i < _this->num_clipboard_mime_types; ++i) { const char *mime_type = _this->clipboard_mime_types[i]; @@ -233,12 +233,12 @@ int WIN_SetClipboardData(SDL_VideoDevice *_this) if (WIN_SetClipboardText(_this, mime_type) < 0) { result = -1; } - /* Only set the first clipboard text */ + // Only set the first clipboard text break; } } - /* Set the clipboard image */ + // Set the clipboard image for (i = 0; i < _this->num_clipboard_mime_types; ++i) { const char *mime_type = _this->clipboard_mime_types[i]; @@ -340,4 +340,4 @@ void WIN_CheckClipboardUpdate(struct SDL_VideoData *data) } } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsclipboard.h b/src/video/windows/SDL_windowsclipboard.h index 5606ef865a..2a70b2c418 100644 --- a/src/video/windows/SDL_windowsclipboard.h +++ b/src/video/windows/SDL_windowsclipboard.h @@ -23,7 +23,7 @@ #ifndef SDL_windowsclipboard_h_ #define SDL_windowsclipboard_h_ -/* Forward declaration */ +// Forward declaration struct SDL_VideoData; extern int WIN_SetClipboardData(SDL_VideoDevice *_this); @@ -31,4 +31,4 @@ extern void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, extern SDL_bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); extern void WIN_CheckClipboardUpdate(struct SDL_VideoData *data); -#endif /* SDL_windowsclipboard_h_ */ +#endif // SDL_windowsclipboard_h_ diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 367f8f0273..055713f005 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -29,19 +29,19 @@ #include "../../main/SDL_main_callbacks.h" #include "../../core/windows/SDL_hid.h" -/* Dropfile support */ +// Dropfile support #include -/* Device names */ +// Device names #include -/* For GET_X_LPARAM, GET_Y_LPARAM. */ +// For GET_X_LPARAM, GET_Y_LPARAM. #include -/* For WM_TABLET_QUERYSYSTEMGESTURESTATUS et. al. */ +// For WM_TABLET_QUERYSYSTEMGESTURESTATUS et. al. #ifdef HAVE_TPCSHRD_H #include -#endif /* HAVE_TPCSHRD_H */ +#endif // HAVE_TPCSHRD_H #if 0 #define WMMSG_DEBUG @@ -55,9 +55,9 @@ #include "../../core/gdk/SDL_gdk.h" #endif -/* #define HIGHDPI_DEBUG */ +// #define HIGHDPI_DEBUG -/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ +// Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... #ifndef WM_XBUTTONDOWN #define WM_XBUTTONDOWN 0x020B #endif @@ -111,7 +111,7 @@ #define USER_TIMER_MINIMUM 0x0000000A #endif -/* Used to compare Windows message timestamps */ +// Used to compare Windows message timestamps #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) #ifdef _WIN64 @@ -133,7 +133,7 @@ static Uint64 WIN_GetEventTimestamp(void) Uint64 timestamp, now; if (!SDL_processing_messages) { - /* message_tick isn't valid, just use the current time */ + // message_tick isn't valid, just use the current time return 0; } @@ -176,7 +176,7 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, U if ((keyFlags & KF_EXTENDED) == KF_EXTENDED) { scanCode = MAKEWORD(scanCode, 0xe0); } else if (scanCode == 0x45) { - /* Pause */ + // Pause scanCode = 0xe046; } } else { @@ -186,7 +186,7 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, U /* Windows may not report scan codes for some buttons (multimedia buttons etc). * Get scan code from the VK code.*/ scanCode = LOWORD(MapVirtualKey(vkCode, WIN_IsWindowsXP() ? MAPVK_VK_TO_VSC : MAPVK_VK_TO_VSC_EX)); -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Pause/Break key have a special scan code with 0xe1 prefix. * Use Pause scan code that is used in Win32. */ @@ -195,7 +195,7 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, U } } - /* Pack scan code into one byte to make the index. */ + // Pack scan code into one byte to make the index. index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00); code = windows_scancode_table[index]; *rawcode = scanCode; @@ -221,7 +221,7 @@ static void WIN_CheckWParamMouseButton(Uint64 timestamp, SDL_bool bwParamMousePr } if (data->focus_click_pending & SDL_BUTTON(button)) { - /* Ignore the button click for activation */ + // Ignore the button click for activation if (!bwParamMousePressed) { data->focus_click_pending &= ~SDL_BUTTON(button); WIN_UpdateClipCursor(data->window); @@ -247,7 +247,7 @@ static void WIN_CheckWParamMouseButtons(Uint64 timestamp, WPARAM wParam, SDL_Win if (wParam != data->mouse_button_flags) { SDL_MouseButtonFlags mouseFlags = SDL_GetMouseState(NULL, NULL); - /* WM_LBUTTONDOWN and friends handle button swapping for us. No need to check SM_SWAPBUTTON here. */ + // WM_LBUTTONDOWN and friends handle button swapping for us. No need to check SM_SWAPBUTTON here. WIN_CheckWParamMouseButton(timestamp, (wParam & MK_LBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_LEFT, mouseID); WIN_CheckWParamMouseButton(timestamp, (wParam & MK_MBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_MIDDLE, mouseID); WIN_CheckWParamMouseButton(timestamp, (wParam & MK_RBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_RIGHT, mouseID); @@ -327,7 +327,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) SDL_SetKeyboardFocus(data->keyboard_focus ? data->keyboard_focus : window); - /* In relative mode we are guaranteed to have mouse focus if we have keyboard focus */ + // In relative mode we are guaranteed to have mouse focus if we have keyboard focus if (!SDL_GetMouse()->relative_mode) { GetCursorPos(&cursorPos); ScreenToClient(hwnd, &cursorPos); @@ -353,7 +353,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) data->in_window_deactivation = SDL_TRUE; SDL_SetKeyboardFocus(NULL); - /* In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus */ + // In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus if (SDL_GetMouse()->relative_mode) { SDL_SetMouseFocus(NULL); } @@ -367,7 +367,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) data->in_window_deactivation = SDL_FALSE; } } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static SDL_bool ShouldGenerateWindowCloseOnAltF4(void) { @@ -390,7 +390,7 @@ static SDL_bool ShouldClearWindowOnEraseBackground(SDL_WindowData *data) } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -/* We want to generate mouse events from mouse and pen, and touch events from touchscreens */ +// 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 @@ -405,7 +405,7 @@ typedef enum static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource(ULONG extrainfo) { - /* Mouse data (ignoring synthetic mouse events generated for touchscreens) */ + // Mouse data (ignoring synthetic mouse events generated for touchscreens) /* Versions below Vista will set the low 7 bits to the Mouse ID and don't use bit 7: Check bits 8-31 for the signature (which will indicate a Tablet PC Pen or Touch Device). Only check bit 7 when Vista and up(Cleared=Pen, Set=Touch(which we need to filter out)), @@ -424,7 +424,7 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource(ULONG extrainfo) } return SDL_MOUSE_EVENT_SOURCE_MOUSE; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static SDL_WindowData *WIN_GetWindowDataFromHWND(HWND hwnd) { @@ -478,7 +478,7 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) scanCode = SDL_SCANCODE_RCTRL; break; - /* These are required to intercept Alt+Tab and Alt+Esc on Windows 7 */ + // These are required to intercept Alt+Tab and Alt+Esc on Windows 7 case VK_TAB: scanCode = SDL_SCANCODE_TAB; break; @@ -516,7 +516,7 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) static SDL_bool WIN_SwapButtons(HANDLE hDevice) { if (hDevice == NULL) { - /* Touchpad, already has buttons swapped */ + // Touchpad, already has buttons swapped return SDL_FALSE; } return GetSystemMetrics(SM_SWAPBUTTON) != 0; @@ -565,7 +565,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL int y = normalized_coordinates ? (int)(((float)rawmouse->lLastY / 65535.0f) * h) : (int)rawmouse->lLastY; int relX, relY; - /* Calculate relative motion */ + // 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; @@ -579,9 +579,9 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL 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 */ + // 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 */ + // Wobble the cursor position so it's not ignored if the last warp didn't have any effect RECT rect = windowdata->cursor_clipped_rect; int warpX = rect.left + ((rect.right - rect.left) / 2) + wobble; int warpY = rect.top + ((rect.bottom - rect.top) / 2); @@ -608,7 +608,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL 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 */ + // Ignore this motion, probably a pen lift and drop } else { SDL_SendMouseMotion(timestamp, window, mouseID, SDL_TRUE, (float)relX, (float)relY); } @@ -652,7 +652,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL } if (windowdata->focus_click_pending & SDL_BUTTON(button)) { - /* Ignore the button click for activation */ + // Ignore the button click for activation if (!state) { windowdata->focus_click_pending &= ~SDL_BUTTON(button); WIN_UpdateClipCursor(window); @@ -750,12 +750,12 @@ void WIN_PollRawInput(SDL_VideoDevice *_this) data->rawinput_offset = sizeof(RAWINPUTHEADER); if (IsWow64Process(GetCurrentProcess(), &isWow64) && isWow64) { - /* We're going to get 64-bit data, so use the 64-bit RAWINPUTHEADER size */ + // We're going to get 64-bit data, so use the 64-bit RAWINPUTHEADER size data->rawinput_offset += 8; } } - /* Get all available events */ + // Get all available events input = (RAWINPUT *)data->rawinput; for (;;) { size = data->rawinput_size - (UINT)((BYTE *)input - data->rawinput); @@ -794,11 +794,11 @@ void WIN_PollRawInput(SDL_VideoDevice *_this) } } if (total_mouse > 1 && delta <= SDL_MS_TO_NS(100)) { - /* We'll spread these events over the time since the last poll */ + // We'll spread these events over the time since the last poll mouse_timestamp = data->last_rawinput_poll; mouse_increment = delta / total_mouse; } else { - /* Do we want to track the update rate per device? */ + // Do we want to track the update rate per device? mouse_timestamp = now; mouse_increment = 0; } @@ -816,14 +816,14 @@ void WIN_PollRawInput(SDL_VideoDevice *_this) data->last_rawinput_poll = now; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) { int new_count = (*count + 1); Uint32 *new_list = (Uint32 *)SDL_realloc(*list, new_count * sizeof(*new_list)); if (!new_list) { - /* Oh well, we'll drop this one */ + // Oh well, we'll drop this one return; } new_list[new_count - 1] = deviceID; @@ -884,7 +884,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c SDL_MouseID *new_mice = NULL; SDL_bool send_event = !initial_check; - /* Check to see if anything has changed */ + // Check to see if anything has changed static Uint64 s_last_device_change; Uint64 last_device_change = WIN_GetLastDeviceNotification(); if (!initial_check && last_device_change == s_last_device_change) { @@ -893,19 +893,19 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c s_last_device_change = last_device_change; if ((GetRawInputDeviceList(NULL, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!raw_device_count)) { - return; /* oh well. */ + return; // oh well. } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); if (!raw_devices) { - return; /* oh well. */ + return; // oh well. } raw_device_count = GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)); if (raw_device_count == (UINT)-1) { SDL_free(raw_devices); raw_devices = NULL; - return; /* oh well. */ + return; // oh well. } HDEVINFO devinfo = SetupDiGetClassDevsA(NULL, NULL, NULL, (DIGCF_ALLCLASSES | DIGCF_PRESENT)); @@ -932,7 +932,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c continue; } - /* Extract the device instance */ + // Extract the device instance instance = devName; while (*instance == '\\' || *instance == '?') { ++instance; @@ -999,7 +999,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c SDL_free(raw_devices); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Return SDL_TRUE if spurious LCtrl is pressed // LCtrl is sent when RAltGR is pressed @@ -1029,7 +1029,7 @@ static SDL_bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam) } } } -#endif /* !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) return SDL_FALSE; } @@ -1039,11 +1039,11 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SDL_WindowData *data; LRESULT returnCode = -1; - /* Get the window data for the window */ + // Get the window data for the window data = WIN_GetWindowDataFromHWND(hwnd); #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (!data) { - /* Fallback */ + // Fallback data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); } #endif @@ -1061,7 +1061,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } OutputDebugStringA(message); } -#endif /* WMMSG_DEBUG */ +#endif // WMMSG_DEBUG #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (WIN_HandleIMEMessage(hwnd, msg, wParam, &lParam, data->videodata)) { @@ -1083,7 +1083,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) case WM_NCACTIVATE: { - /* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */ + // 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 @@ -1094,7 +1094,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_ACTIVATE: { - /* Update the focus in case we changed focus to a child window and then away from the application */ + // 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; @@ -1107,14 +1107,14 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_SETFOCUS: { - /* Update the focus in case it's changing between top-level windows in the same application */ + // 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 */ + // Update the focus in case it's changing between top-level windows in the same application WIN_UpdateFocus(data->window, SDL_FALSE); } break; @@ -1141,7 +1141,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } if (!data->videodata->raw_mouse_enabled) { - /* Only generate mouse events for real mouse */ + // Only generate mouse events for real mouse if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH && lParam != data->last_pointer_update) { SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam)); @@ -1171,14 +1171,14 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } } break; -#if 0 /* We handle raw input all at once instead of using a syscall for each mouse event */ +#if 0 // We handle raw input all at once instead of using a syscall for each mouse event case WM_INPUT: { HRAWINPUT hRawInput = (HRAWINPUT)lParam; RAWINPUT inp; UINT size = sizeof(inp); - /* Relative mouse motion is delivered to the window with keyboard focus */ + // Relative mouse motion is delivered to the window with keyboard focus if (data->window != SDL_GetKeyboardFocus()) { break; } @@ -1214,30 +1214,30 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara GetCursorPos(&cursorPos); ScreenToClient(hwnd, &cursorPos); mouse = SDL_GetMouse(); - if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */ + if (!mouse->was_touch_mouse_events) { // we're not a touch handler causing a mouse leave? SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); - } else { /* touch handling? */ - mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */ - if (mouse->touch_mouse_events) { /* convert touch to mouse events */ + } else { // touch handling? + mouse->was_touch_mouse_events = SDL_FALSE; // not anymore + if (mouse->touch_mouse_events) { // convert touch to mouse events SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); - } else { /* normal handling */ + } else { // normal handling SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); } } } if (!SDL_GetMouse()->relative_mode) { - /* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */ + // When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window SDL_SetMouseFocus(NULL); } } - /* Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked */ + // Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked data->mouse_tracked = SDL_FALSE; returnCode = 0; break; -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) case WM_KEYDOWN: case WM_SYSKEYDOWN: @@ -1251,9 +1251,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara Uint16 rawcode = 0; SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key); - /* Detect relevant keyboard shortcuts */ + // Detect relevant keyboard shortcuts if (code == SDL_SCANCODE_F4 && (SDL_GetModState() & SDL_KMOD_ALT)) { - /* ALT+F4: Close window */ + // ALT+F4: Close window if (ShouldGenerateWindowCloseOnAltF4()) { SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); } @@ -1341,7 +1341,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } returnCode = 1; break; -#endif /* WM_INPUTLANGCHANGE */ +#endif // WM_INPUTLANGCHANGE case WM_NCLBUTTONDOWN: { @@ -1352,7 +1352,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara { data->in_title_click = SDL_FALSE; - /* The mouse may have been released during a modal loop */ + // The mouse may have been released during a modal loop WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); } break; @@ -1367,17 +1367,17 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara int max_w, max_h; BOOL constrain_max_size; - /* If this is an expected size change, allow it */ + // If this is an expected size change, allow it if (data->expected_resize) { break; } - /* Get the current position of our window */ + // Get the current position of our window GetWindowRect(hwnd, &size); x = size.left; y = size.top; - /* Calculate current size of our window */ + // 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); @@ -1407,7 +1407,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara #endif } - /* Fix our size to the current size */ + // 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) { @@ -1437,7 +1437,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } returnCode = 0; break; -#endif /* WM_GETMINMAXINFO */ +#endif // WM_GETMINMAXINFO case WM_WINDOWPOSCHANGING: { @@ -1450,7 +1450,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara !IsZoomed(hwnd) && (data->window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED)) && !(data->window->flags & SDL_WINDOW_FULLSCREEN)) { - /* If a new floating size is pending, apply it if moving from a fixed-size to floating state. */ + // If a new floating size is pending, apply it if moving from a fixed-size to floating state. WINDOWPOS *windowpos = (WINDOWPOS*)lParam; int fx, fy, fw, fh; @@ -1484,7 +1484,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); } else if (zoomed) { if (data->window->flags & SDL_WINDOW_MINIMIZED) { - /* If going from minimized to maximized, send the restored event first. */ + // If going from minimized to maximized, send the restored event first. SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); } SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); @@ -1496,7 +1496,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); } - /* When the window is minimized it's resized to the dock icon size, ignore this */ + // When the window is minimized it's resized to the dock icon size, ignore this if (iconic) { break; } @@ -1516,7 +1516,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MOVED, x, y); } - /* Moving the window from one display to another can change the size of the window (in the handling of SDL_EVENT_WINDOW_MOVED), so we need to re-query the bounds */ + // Moving the window from one display to another can change the size of the window (in the handling of SDL_EVENT_WINDOW_MOVED), so we need to re-query the bounds if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) { w = rect.right; h = rect.bottom; @@ -1526,23 +1526,23 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara WIN_UpdateClipCursor(data->window); - /* Update the window display position */ + // Update the window display position data->last_displayID = SDL_GetDisplayForWindow(data->window); if (data->last_displayID != original_displayID) { - /* Display changed, check ICC profile */ + // Display changed, check ICC profile WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); } - /* Update the position of any child windows */ + // Update the position of any child windows for (win = data->window->first_child; win; win = win->next_sibling) { - /* Don't update hidden child windows, their relative position doesn't change */ + // Don't update hidden child windows, their relative position doesn't change if (!(win->flags & SDL_WINDOW_HIDDEN)) { WIN_SetWindowPositionInternal(win, SWP_NOCOPYBITS | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); } } - /* Forces a WM_PAINT event */ + // Forces a WM_PAINT event InvalidateRect(hwnd, NULL, FALSE); } break; @@ -1582,12 +1582,12 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara LONG w, h; float new_aspect; - /* if aspect ratio constraints are not enabled then skip this message */ + // if aspect ratio constraints are not enabled then skip this message if (data->window->min_aspect <= 0 && data->window->max_aspect <= 0) { break; } - /* unadjust the dragRect from the window rect to the client rect */ + // unadjust the dragRect from the window rect to the client rect SetRectEmpty(&rc); if (!AdjustWindowRectEx(&rc, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd))) { break; @@ -1602,7 +1602,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara h = clientDragRect.bottom - clientDragRect.top; new_aspect = w / (float)h; - /* handle the special case in which the min ar and max ar are the same so the window can size symmetrically */ + // handle the special case in which the min ar and max ar are the same so the window can size symmetrically if (lock_aspect_ratio) { switch (edge) { case WMSZ_LEFT: @@ -1610,7 +1610,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara h = (int)(w / data->window->max_aspect); break; default: - /* resizing via corners or top or bottom */ + // resizing via corners or top or bottom w = (int)(h*data->window->max_aspect); break; } @@ -1634,7 +1634,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; default: - /* resizing via corners */ + // resizing via corners if (data->window->max_aspect > 0.0f && new_aspect > data->window->max_aspect) { w = (int)SDL_roundf(h * data->window->max_aspect); } else if (data->window->min_aspect > 0.0f && new_aspect < data->window->min_aspect) { @@ -1691,7 +1691,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } - /* convert the client rect to a window rect */ + // convert the client rect to a window rect if (!AdjustWindowRectEx(&clientDragRect, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd))) { break; } @@ -1714,7 +1714,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } } break; - /* We were occluded, refresh our display */ + // We were occluded, refresh our display case WM_PAINT: { RECT rect; @@ -1736,7 +1736,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara returnCode = 0; break; - /* We'll do our own drawing, prevent flicker */ + // We'll do our own drawing, prevent flicker case WM_ERASEBKGND: if (ShouldClearWindowOnEraseBackground(data)) { RECT client_rect; @@ -1758,14 +1758,14 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) - /* Don't start the screensaver or blank the monitor in fullscreen apps */ + // 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 */ +#endif // System has screensaver support } break; case WM_CLOSE: @@ -1812,7 +1812,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara continue; } - /* Get the normalized coordinates for the window */ + // Get the normalized coordinates for the window if (w <= 1) { x = 0.5f; } else { @@ -1824,7 +1824,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara y = (float)(input->y - rect.top) / (h - 1); } - /* FIXME: Should we use the input->dwTime field for the tick source of the timestamp? */ + // FIXME: Should we use the input->dwTime field for the tick source of the timestamp? if (input->dwFlags & TOUCHEVENTF_DOWN) { SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_TRUE, x, y, 1.0f); } @@ -1850,12 +1850,12 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara * 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 */ +#endif // HAVE_TPCSHRD_H case WM_DROPFILES: { @@ -1889,7 +1889,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara { SDL_WindowFlags 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 */ + // 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; @@ -1949,12 +1949,12 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return HTCLIENT; } } - /* If we didn't return, this will call DefWindowProc below. */ + // If we didn't return, this will call DefWindowProc below. } } break; case WM_GETDPISCALEDSIZE: - /* Windows 10 Creators Update+ */ + // 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 @@ -1983,7 +1983,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara prevDPI, nextDPI, sizeInOut->cx, sizeInOut->cy); #endif - /* Subtract the window frame size that would have been used at prevDPI */ + // Subtract the window frame size that would have been used at prevDPI { RECT rect = { 0 }; @@ -1998,7 +1998,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara query_client_h_win = sizeInOut->cy - frame_h; } - /* Add the window frame size that would be used at nextDPI */ + // Add the window frame size that would be used at nextDPI { RECT rect = { 0 }; rect.right = query_client_w_win; @@ -2008,7 +2008,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara WIN_AdjustWindowRectForHWND(hwnd, &rect, nextDPI); } - /* This is supposed to control the suggested rect param of WM_DPICHANGED */ + // This is supposed to control the suggested rect param of WM_DPICHANGED sizeInOut->cx = rect.right - rect.left; sizeInOut->cy = rect.bottom - rect.top; } @@ -2021,7 +2021,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_DPICHANGED: - /* Windows 8.1+ */ + // Windows 8.1+ { const int newDPI = HIWORD(wParam); RECT *const suggestedRect = (RECT *)lParam; @@ -2042,7 +2042,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return 0; } - /* Interactive user-initiated resizing/movement */ + // Interactive user-initiated resizing/movement { /* Calculate the new frame w/h such that the client area size is maintained. */ @@ -2087,10 +2087,10 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } break; -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) } - /* If there's a window proc, assume it's going to handle messages */ + // If there's a window proc, assume it's going to handle messages if (data->wndproc) { return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); } else if (returnCode >= 0) { @@ -2149,9 +2149,9 @@ static void WIN_UpdateMouseCapture(void) } } } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -/* A message hook called before TranslateMessage() */ +// A message hook called before TranslateMessage() static SDL_WindowsMessageHook g_WindowsMessageHook = NULL; static void *g_WindowsMessageHookData = NULL; @@ -2174,7 +2174,7 @@ int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) return 0; } #else - /* MsgWaitForMultipleObjects is desktop-only. */ + // MsgWaitForMultipleObjects is desktop-only. MSG msg; BOOL message_result; UINT_PTR timer_id = 0; @@ -2196,16 +2196,16 @@ int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) return 1; } } - /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */ + // Always translate the message in case it's a non-SDL window (e.g. with Qt integration) TranslateMessage(&msg); DispatchMessage(&msg); return 1; } else { return 0; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) } else { - /* Fail the wait so the caller falls back to polling */ + // Fail the wait so the caller falls back to polling return -1; } } @@ -2219,7 +2219,7 @@ void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) void WIN_PumpEvents(SDL_VideoDevice *_this) { MSG msg; -#ifdef _MSC_VER /* We explicitly want to use GetTickCount(), not GetTickCount64() */ +#ifdef _MSC_VER // We explicitly want to use GetTickCount(), not GetTickCount64() #pragma warning(push) #pragma warning(disable : 28159) #endif @@ -2248,24 +2248,24 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* Don't dispatch any mouse motion queued prior to or including the last mouse warp */ + // Don't dispatch any mouse motion queued prior to or including the last mouse warp if (msg.message == WM_MOUSEMOVE && SDL_last_warp_time) { if (!SDL_TICKS_PASSED(msg.time, (SDL_last_warp_time + 1))) { continue; } - /* This mouse message happened after the warp */ + // This mouse message happened after the warp SDL_last_warp_time = 0; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) WIN_SetMessageTick(msg.time); - /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */ + // Always translate the message in case it's a non-SDL window (e.g. with Qt integration) TranslateMessage(&msg); DispatchMessage(&msg); - /* Make sure we don't busy loop here forever if there are lots of events coming in */ + // Make sure we don't busy loop here forever if there are lots of events coming in if (SDL_TICKS_PASSED(msg.time, end_ticks)) { /* We might get a few new messages generated by the Steam overlay or other application hooks In this case those messages will be processed before any pending input, so we want to continue after those messages. @@ -2308,10 +2308,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) } } - /* Update the clipping rect in case someone else has stolen it */ + // Update the clipping rect in case someone else has stolen it WIN_UpdateClipCursorForWindows(); - /* Update mouse capture */ + // Update mouse capture WIN_UpdateMouseCapture(); if (!_this->internal->gameinput_context) { @@ -2320,7 +2320,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) WIN_UpdateIMECandidates(_this); -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef SDL_PLATFORM_GDK GDK_DispatchTaskQueue(); @@ -2351,18 +2351,18 @@ static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, L { WNDCLASSEX *wcex = (WNDCLASSEX *)lParam; - (void)lpType; /* We already know that the resource type is RT_GROUP_ICON. */ + (void)lpType; // We already know that the resource type is RT_GROUP_ICON. /* We leave hIconSm as NULL as it will allow Windows to automatically choose the appropriate small icon size to suit the current DPI. */ wcex->hIcon = LoadIcon(hModule, lpName); - /* Do not bother enumerating any more. */ + // Do not bother enumerating any more. return FALSE; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -/* Register the class for this application */ +// Register the class for this application int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { WNDCLASSEX wcex; @@ -2370,7 +2370,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) const char *hint; #endif - /* Only do this once... */ + // Only do this once... if (app_registered) { ++app_registered; return 0; @@ -2386,7 +2386,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) SDL_Appstyle = style; SDL_Instance = hInst ? (HINSTANCE)hInst : GetModuleHandle(NULL); - /* Register the application class */ + // Register the application class wcex.cbSize = sizeof(WNDCLASSEX); wcex.hCursor = NULL; wcex.hIcon = NULL; @@ -2410,10 +2410,10 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) wcex.hIconSm = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); } } else { - /* Use the first icon as a default icon, like in the Explorer. */ + // Use the first icon as a default icon, like in the Explorer. EnumResourceNames(SDL_Instance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (!RegisterClassEx(&wcex)) { WIN_CleanRegisterApp(wcex); @@ -2424,21 +2424,21 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) return 0; } -/* Unregisters the windowclass registered in SDL_RegisterApp above. */ +// Unregisters the windowclass registered in SDL_RegisterApp above. void SDL_UnregisterApp(void) { WNDCLASSEX wcex; - /* SDL_RegisterApp might not have been called before */ + // SDL_RegisterApp might not have been called before if (!app_registered) { return; } --app_registered; if (app_registered == 0) { - /* Ensure the icons are initialized. */ + // Ensure the icons are initialized. wcex.hIcon = NULL; wcex.hIconSm = NULL; - /* Check for any registered window classes. */ + // Check for any registered window classes. #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) { UnregisterClass(SDL_Appname, SDL_Instance); @@ -2448,4 +2448,4 @@ void SDL_UnregisterApp(void) } } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsevents.h b/src/video/windows/SDL_windowsevents.h index 5acd69b12c..9e57cb2fab 100644 --- a/src/video/windows/SDL_windowsevents.h +++ b/src/video/windows/SDL_windowsevents.h @@ -36,4 +36,4 @@ extern void WIN_PumpEvents(SDL_VideoDevice *_this); extern void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); extern int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); -#endif /* SDL_windowsevents_h_ */ +#endif // SDL_windowsevents_h_ diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 37dd919776..d8331dea2c 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -35,7 +35,7 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ SDL_GetWindowSizeInPixels(window, &w, &h); - /* Free the old framebuffer surface */ + // Free the old framebuffer surface if (data->mdc) { DeleteDC(data->mdc); } @@ -43,7 +43,7 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ DeleteObject(data->hbm); } - /* Find out the format of the screen */ + // Find out the format of the screen size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); info = (LPBITMAPINFO)SDL_small_alloc(Uint8, size, &isstack); if (!info) { @@ -53,7 +53,7 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ SDL_memset(info, 0, size); info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - /* The second call to GetDIBits() fills in the bitfields */ + // The second call to GetDIBits() fills in the bitfields hbm = CreateCompatibleBitmap(data->hdc, 1, 1); GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); @@ -69,10 +69,10 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ *format = SDL_GetPixelFormatForMasks(bpp, masks[0], masks[1], masks[2], 0); } if (*format == SDL_PIXELFORMAT_UNKNOWN) { - /* We'll use RGB format for now */ + // We'll use RGB format for now *format = SDL_PIXELFORMAT_XRGB8888; - /* Create a new one */ + // Create a new one SDL_memset(info, 0, size); info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info->bmiHeader.biPlanes = 1; @@ -80,10 +80,10 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ info->bmiHeader.biCompression = BI_RGB; } - /* Fill in the size information */ + // Fill in the size information *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); info->bmiHeader.biWidth = w; - info->bmiHeader.biHeight = -h; /* negative for topdown bitmap */ + info->bmiHeader.biHeight = -h; // negative for topdown bitmap info->bmiHeader.biSizeImage = (DWORD)h * (*pitch); data->mdc = CreateCompatibleDC(data->hdc); @@ -115,7 +115,7 @@ void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; if (!data) { - /* The window wasn't fully initialized */ + // The window wasn't fully initialized return; } @@ -129,4 +129,4 @@ void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) } } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsgameinput.c b/src/video/windows/SDL_windowsgameinput.c index 2cdb3e8029..80f20b63cf 100644 --- a/src/video/windows/SDL_windowsgameinput.c +++ b/src/video/windows/SDL_windowsgameinput.c @@ -50,7 +50,7 @@ typedef struct GAMEINPUT_Device IGameInputDevice *pDevice; const GameInputDeviceInfo *info; char *name; - Uint32 instance_id; /* generated by SDL */ + Uint32 instance_id; // generated by SDL SDL_bool registered; SDL_bool delete_requested; IGameInputReading *last_mouse_reading; @@ -83,7 +83,7 @@ static int GAMEINPUT_InternalAddOrFind(WIN_GameInputData *data, IGameInputDevice for (int i = 0; i < data->num_devices; ++i) { device = data->devices[i]; if (device && device->pDevice == pDevice) { - /* we're already added */ + // we're already added device->delete_requested = SDL_FALSE; retval = 0; goto done; @@ -102,11 +102,11 @@ static int GAMEINPUT_InternalAddOrFind(WIN_GameInputData *data, IGameInputDevice } if (info->deviceStrings) { - /* In theory we could get the manufacturer and product strings here, but they're NULL for all the devices I've tested */ + // In theory we could get the manufacturer and product strings here, but they're NULL for all the devices I've tested } if (info->displayName) { - /* This could give us a product string, but it's NULL for all the devices I've tested */ + // This could give us a product string, but it's NULL for all the devices I've tested } IGameInputDevice_AddRef(pDevice); @@ -163,7 +163,7 @@ static int GAMEINPUT_InternalRemoveByIndex(WIN_GameInputData *data, int idx) data->devices[idx] = NULL; if (data->num_devices == 1) { - /* last element in the list, free the entire list then */ + // last element in the list, free the entire list then SDL_free(data->devices); data->devices = NULL; } else { @@ -173,7 +173,7 @@ static int GAMEINPUT_InternalRemoveByIndex(WIN_GameInputData *data, int idx) } } - /* decrement the count and return */ + // decrement the count and return retval = data->num_devices--; } done: @@ -195,7 +195,7 @@ static void CALLBACK GAMEINPUT_InternalDeviceCallback( GAMEINPUT_Device *device = NULL; if (!pDevice) { - /* This should never happen, but ignore it if it does */ + // This should never happen, but ignore it if it does return; } @@ -205,7 +205,7 @@ static void CALLBACK GAMEINPUT_InternalDeviceCallback( for (idx = 0; idx < data->num_devices; ++idx) { device = data->devices[idx]; if (device && device->pDevice == pDevice) { - /* will be deleted on the next Detect call */ + // will be deleted on the next Detect call device->delete_requested = SDL_TRUE; break; } @@ -567,13 +567,13 @@ void WIN_QuitGameInput(SDL_VideoDevice *_this) } if (data->pGameInput) { - /* free the callback */ + // free the callback if (data->gameinput_callback_token != GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE) { IGameInput_UnregisterCallback(data->pGameInput, data->gameinput_callback_token, /*timeoutInUs:*/ 10000); data->gameinput_callback_token = GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE; } - /* free the list */ + // free the list while (data->num_devices > 0) { GAMEINPUT_InternalRemoveByIndex(data, 0); } @@ -596,7 +596,7 @@ void WIN_QuitGameInput(SDL_VideoDevice *_this) _this->internal->gameinput_context = NULL; } -#else /* !HAVE_GAMEINPUT_H */ +#else // !HAVE_GAMEINPUT_H int WIN_InitGameInput(SDL_VideoDevice* _this) { @@ -618,4 +618,4 @@ void WIN_QuitGameInput(SDL_VideoDevice* _this) return; } -#endif /* HAVE_GAMEINPUT_H */ +#endif // HAVE_GAMEINPUT_H diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index f9a40e441a..ab6232fe23 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -45,7 +45,7 @@ static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd); static void IME_Quit(SDL_VideoData *videodata); #else static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor); -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME #ifndef MAPVK_VK_TO_VSC #define MAPVK_VK_TO_VSC 0 @@ -54,7 +54,7 @@ static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_ #define MAPVK_VSC_TO_VK 1 #endif -/* Alphabetic scancodes for PC keyboards */ +// Alphabetic scancodes for PC keyboards void WIN_InitKeyboard(SDL_VideoDevice *_this) { #ifndef SDL_DISABLE_WINDOWS_IME @@ -63,7 +63,7 @@ void WIN_InitKeyboard(SDL_VideoDevice *_this) data->ime_candlistindexbase = 1; data->ime_composition_length = 32 * sizeof(WCHAR); data->ime_composition = (WCHAR *)SDL_calloc(data->ime_composition_length, sizeof(WCHAR)); -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME WIN_UpdateKeymap(SDL_FALSE); @@ -71,7 +71,7 @@ void WIN_InitKeyboard(SDL_VideoDevice *_this) SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows"); - /* Are system caps/num/scroll lock active? Set our state to match. */ + // Are system caps/num/scroll lock active? Set our state to match. SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? SDL_TRUE : SDL_FALSE); SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? SDL_TRUE : SDL_FALSE); SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? SDL_TRUE : SDL_FALSE); @@ -103,13 +103,13 @@ void WIN_UpdateKeymap(SDL_bool send_event) int vk, sc, result; Uint32 *ch = 0; - /* Make sure this scancode is a valid character scancode */ + // Make sure this scancode is a valid character scancode scancode = windows_scancode_table[i]; if (scancode == SDL_SCANCODE_UNKNOWN || scancode == SDL_SCANCODE_DELETE || (SDL_GetKeymapKeycode(NULL, scancode, SDL_KMOD_NONE) & SDLK_SCANCODE_MASK)) { - /* The Colemak mapping swaps Backspace and CapsLock */ + // The Colemak mapping swaps Backspace and CapsLock if (mods[m] == SDL_KMOD_NONE && (scancode == SDL_SCANCODE_CAPSLOCK || scancode == SDL_SCANCODE_BACKSPACE)) { @@ -123,7 +123,7 @@ void WIN_UpdateKeymap(SDL_bool send_event) continue; } - /* Unpack the single byte index to make the scan code. */ + // Unpack the single byte index to make the scan code. sc = MAKEWORD(i & 0x7f, (i & 0x80) ? 0xe0 : 0x00); vk = LOBYTE(MapVirtualKey(sc, MAPVK_VSC_TO_VK)); if (!vk) { @@ -139,7 +139,7 @@ void WIN_UpdateKeymap(SDL_bool send_event) result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0); buffer[SDL_abs(result)] = 0; - /* Convert UTF-16 to UTF-32 code points */ + // Convert UTF-16 to UTF-32 code points ch = (Uint32 *)SDL_iconv_string("UTF-32LE", "UTF-16LE", (const char *)buffer, (SDL_abs(result) + 1) * sizeof(WCHAR)); if (ch) { /* Windows keyboard layouts can emit several UTF-32 code points on a single key press. @@ -174,7 +174,7 @@ void WIN_QuitKeyboard(SDL_VideoDevice *_this) SDL_free(data->ime_composition); data->ime_composition = NULL; } -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME } void WIN_ResetDeadKeys(void) @@ -195,14 +195,14 @@ void WIN_ResetDeadKeys(void) vk = VK_SPACE; sc = MapVirtualKey(vk, MAPVK_VK_TO_VSC); if (sc == 0) { - /* the keyboard doesn't have this key */ + // the keyboard doesn't have this key return; } for (i = 0; i < 5; i++) { result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0); if (result > 0) { - /* success */ + // success return; } } @@ -219,7 +219,7 @@ int WIN_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie IME_Enable(videodata, hwnd); WIN_UpdateTextInputArea(_this, window); -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME return 0; } @@ -233,7 +233,7 @@ int WIN_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) SDL_VideoData *videodata = _this->internal; IME_Init(videodata, window); IME_Disable(videodata, hwnd); -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME return 0; } @@ -337,12 +337,12 @@ static int IME_Init(SDL_VideoData *videodata, SDL_Window *window) SDL_ClearError(); return 0; } - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on IME_SetWindow(videodata, window); videodata->ime_himc = ImmGetContext(hwnd); @@ -621,12 +621,12 @@ static void IME_SetupAPI(SDL_VideoData *videodata) return; } - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on if (videodata->ShowReadingWindow) { HIMC himc = ImmGetContext(videodata->ime_hwnd_current); @@ -1140,6 +1140,6 @@ void WIN_UpdateIMECandidates(SDL_VideoDevice *_this) } } -#endif /* SDL_DISABLE_WINDOWS_IME */ +#endif // SDL_DISABLE_WINDOWS_IME -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowskeyboard.h b/src/video/windows/SDL_windowskeyboard.h index efdff742d3..15558fb18c 100644 --- a/src/video/windows/SDL_windowskeyboard.h +++ b/src/video/windows/SDL_windowskeyboard.h @@ -37,4 +37,4 @@ extern int WIN_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); extern void WIN_UpdateIMECandidates(SDL_VideoDevice *_this); -#endif /* SDL_windowskeyboard_h_ */ +#endif // SDL_windowskeyboard_h_ diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 2baaf56310..22582b7a20 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -45,13 +45,13 @@ #define IDCANCEL 2 #endif -/* Custom dialog return codes */ +// Custom dialog return codes #define IDCLOSED 20 #define IDINVALPTRINIT 50 #define IDINVALPTRCOMMAND 51 #define IDINVALPTRSETFOCUS 52 #define IDINVALPTRDLGITEM 53 -/* First button ID */ +// First button ID #define IDBUTTONINDEX0 100 #define DLGITEMTYPEBUTTON 0x0080 @@ -64,7 +64,7 @@ */ #define MAX_BUTTONS (0xffff - 100) -/* Display a Windows message box */ +// Display a Windows message box typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData); @@ -263,14 +263,14 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { - /* Focus on the first default return-key button */ + // Focus on the first default return-key button HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex)); if (!buttonctl) { EndDialog(hDlg, IDINVALPTRDLGITEM); } PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE); } else { - /* Give the focus to the dialog window instead */ + // Give the focus to the dialog window instead SetFocus(hDlg); } return FALSE; @@ -281,7 +281,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return TRUE; } - /* Let the default button be focused if there is one. Otherwise, prevent any initial focus. */ + // Let the default button be focused if there is one. Otherwise, prevent any initial focus. if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { return FALSE; } @@ -293,7 +293,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return TRUE; } - /* Return the ID of the button that was pushed */ + // Return the ID of the button that was pushed if (wParam == IDOK) { if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex); @@ -302,7 +302,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, &buttonindex)) { EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex); } else { - /* Closing of window was requested by user or system. It would be rude not to comply. */ + // Closing of window was requested by user or system. It would be rude not to comply. EndDialog(hDlg, IDCLOSED); } } else if (wParam >= IDBUTTONINDEX0 && (int)wParam - IDBUTTONINDEX0 < messageboxdata->numbuttons) { @@ -318,12 +318,12 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) { - /* Growing memory in 64 KiB steps. */ + // Growing memory in 64 KiB steps. const size_t sizestep = 0x10000; size_t size = dialog->size; if (size == 0) { - /* Start with 4 KiB or a multiple of 64 KiB to fit the data. */ + // Start with 4 KiB or a multiple of 64 KiB to fit the data. size = 0x1000; if (SIZE_MAX - sizestep < space) { size = space; @@ -334,10 +334,10 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) SDL_OutOfMemory(); return SDL_FALSE; } else if (SIZE_MAX - (dialog->used + space) < sizestep) { - /* Close to the maximum. */ + // Close to the maximum. size = dialog->used + space; } else if (size < dialog->used + space) { - /* Round up to the next 64 KiB block. */ + // Round up to the next 64 KiB block. size = dialog->used + space; size += sizestep - size % sizestep; } @@ -395,7 +395,7 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) return SDL_FALSE; } - /* Find out how many characters we have, including null terminator */ + // Find out how many characters we have, including null terminator count = 0; for (p = wstring; *p; ++p) { ++count; @@ -411,7 +411,7 @@ static int s_BaseUnitsX; static int s_BaseUnitsY; static void Vec2ToDLU(short *x, short *y) { - SDL_assert(s_BaseUnitsX != 0); /* we init in WIN_ShowMessageBox(), which is the only public function... */ + SDL_assert(s_BaseUnitsX != 0); // we init in WIN_ShowMessageBox(), which is the only public function... *x = (short)MulDiv(*x, 4, s_BaseUnitsX); *y = (short)MulDiv(*y, 8, s_BaseUnitsY); @@ -490,7 +490,7 @@ static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int } else { style |= BS_PUSHBUTTON; } - /* The first button marks the start of the group. */ + // The first button marks the start of the group. if (dialog->numbuttons == 0) { style |= WS_GROUP; } @@ -529,26 +529,26 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) return NULL; } - /* No menu */ + // No menu WordToPass = 0; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - /* No custom class */ + // No custom class if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - /* title */ + // title if (!AddDialogString(dialog, caption)) { FreeDialogData(dialog); return NULL; } - /* Font stuff */ + // Font stuff { /* * We want to use the system messagebox font. @@ -559,12 +559,12 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) NCM.cbSize = sizeof(NCM); SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0); - /* Font size - convert to logical font size for dialog parameter. */ + // Font size - convert to logical font size for dialog parameter. { HDC ScreenDC = GetDC(NULL); int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY); if (!LogicalPixelsY) { - LogicalPixelsY = 72; /* This can happen if the application runs out of GDI handles */ + LogicalPixelsY = 72; // This can happen if the application runs out of GDI handles } WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY); @@ -576,28 +576,28 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) return NULL; } - /* Font weight */ + // Font weight WordToPass = (WORD)NCM.lfMessageFont.lfWeight; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - /* italic? */ + // italic? ToPass = NCM.lfMessageFont.lfItalic; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } - /* charset? */ + // charset? ToPass = NCM.lfMessageFont.lfCharSet; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } - /* font typeface. */ + // font typeface. if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) { FreeDialogData(dialog); return NULL; @@ -635,14 +635,14 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) srclen++; if (ampcount == 0) { - /* Nothing to do. */ + // Nothing to do. return src; } if (SIZE_MAX - srclen < ampcount) { return NULL; } if (!*dst || *dstlen < srclen + ampcount) { - /* Allocating extra space in case the next strings are a bit longer. */ + // Allocating extra space in case the next strings are a bit longer. size_t extraspace = SIZE_MAX - (srclen + ampcount); if (extraspace > 512) { extraspace = 512; @@ -659,7 +659,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) newdst = *dst; } - /* The escape character is the ampersand itself. */ + // The escape character is the ampersand itself. while (srclen--) { if (*src == '&') { *newdst++ = '&'; @@ -670,7 +670,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) return *dst; } -/* This function is called if a Task Dialog is unsupported. */ +// This function is called if a Task Dialog is unsupported. static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { WIN_DialogData *dialog; @@ -745,7 +745,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * FontDC = CreateCompatibleDC(0); { - /* Create a duplicate of the font used in system message boxes. */ + // Create a duplicate of the font used in system message boxes. LOGFONT lf; NONCLIENTMETRICS NCM; NCM.cbSize = sizeof(NCM); @@ -754,11 +754,11 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * DialogFont = CreateFontIndirect(&lf); } - /* Select the font in to our DC */ + // Select the font in to our DC SelectObject(FontDC, DialogFont); { - /* Get the metrics to try and figure our DLU conversion. */ + // Get the metrics to try and figure our DLU conversion. GetTextMetrics(FontDC, &TM); /* Calculation from the following documentation: @@ -770,7 +770,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * GetTextExtentPoint32A(FontDC, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &extent); s_BaseUnitsX = (extent.cx / 26 + 1) / 2; } - /*s_BaseUnitsX = TM.tmAveCharWidth + 1;*/ + // s_BaseUnitsX = TM.tmAveCharWidth + 1; s_BaseUnitsY = TM.tmHeight; } @@ -779,40 +779,40 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * SDL_zero(TextSize); DrawTextW(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL); - /* Add margins and some padding for hangs, etc. */ + // Add margins and some padding for hangs, etc. TextSize.left += TextMargin; TextSize.right += TextMargin + 2; TextSize.top += TextMargin; TextSize.bottom += TextMargin + 2; - /* Done with the DC, and the string */ + // Done with the DC, and the string DeleteDC(FontDC); SDL_free(wmessage); - /* Increase the size of the dialog by some border spacing around the text. */ + // Increase the size of the dialog by some border spacing around the text. Size.cx = TextSize.right - TextSize.left; Size.cy = TextSize.bottom - TextSize.top; Size.cx += TextMargin * 2; Size.cy += TextMargin * 2; - /* Make dialog wider and shift text over for the icon. */ + // Make dialog wider and shift text over for the icon. if (icon) { Size.cx += IconMargin + IconWidth; TextSize.left += IconMargin + IconWidth; TextSize.right += IconMargin + IconWidth; } - /* Ensure the size is wide enough for all of the buttons. */ + // Ensure the size is wide enough for all of the buttons. if (Size.cx < (LONG)messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin) { Size.cx = (LONG)messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin; } - /* Reset the height to the icon size if it is actually bigger than the text. */ + // Reset the height to the icon size if it is actually bigger than the text. if (icon && Size.cy < (LONG)IconMargin * 2 + IconHeight) { Size.cy = (LONG)IconMargin * 2 + IconHeight; } - /* Add vertical space for the buttons and border. */ + // Add vertical space for the buttons and border. Size.cy += ButtonHeight + TextMargin; dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); @@ -830,7 +830,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * return -1; } - /* Align the buttons to the right/bottom. */ + // Align the buttons to the right/bottom. x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons; y = Size.cy - ButtonHeight - ButtonMargin; for (i = 0; i < messageboxdata->numbuttons; i++) { @@ -878,8 +878,8 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * *buttonID = messageboxdata->buttons[result - IDBUTTONINDEX0].buttonID; retval = 0; } else if (result == IDCLOSED) { - /* Dialog window closed by user or system. */ - /* This could use a special return code. */ + // Dialog window closed by user or system. + // This could use a special return code. retval = 0; *buttonID = -1; } else { @@ -904,9 +904,9 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * /* TaskDialogIndirect procedure * This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK. */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off typedef HRESULT (FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked); -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { @@ -929,7 +929,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) return SDL_OutOfMemory(); } - /* If we cannot load comctl32.dll use the old messagebox! */ + // If we cannot load comctl32.dll use the old messagebox! hComctl32 = LoadLibrary(TEXT("comctl32.dll")); if (!hComctl32) { return WIN_ShowOldMessageBox(messageboxdata, buttonID); @@ -1010,10 +1010,10 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) } TaskConfig.pButtons = pButtons; - /* Show the Task Dialog */ + // Show the Task Dialog hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL); - /* Free everything */ + // Free everything FreeLibrary(hComctl32); SDL_free(ampescape); SDL_free(wmessage); @@ -1023,7 +1023,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) } SDL_free(pButtons); - /* Check the Task Dialog was successful and give the result */ + // Check the Task Dialog was successful and give the result if (SUCCEEDED(hr)) { if (nButton == IDCANCEL) { *buttonID = nCancelButton; @@ -1035,8 +1035,8 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) return 0; } - /* We failed showing the Task Dialog, use the old message box! */ + // We failed showing the Task Dialog, use the old message box! return WIN_ShowOldMessageBox(messageboxdata, buttonID); } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsmessagebox.h b/src/video/windows/SDL_windowsmessagebox.h index a89ddd6abc..25eeed72fc 100644 --- a/src/video/windows/SDL_windowsmessagebox.h +++ b/src/video/windows/SDL_windowsmessagebox.h @@ -24,4 +24,4 @@ extern int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 54cb9ef719..bc1179447e 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -30,13 +30,13 @@ #include #endif -/* Windows CE compatibility */ +// Windows CE compatibility #ifndef CDS_FULLSCREEN #define CDS_FULLSCREEN 0 #endif -/* #define DEBUG_MODES */ -/* #define HIGHDPI_DEBUG_VERBOSE */ +// #define DEBUG_MODES +// #define HIGHDPI_DEBUG_VERBOSE static void WIN_UpdateDisplayMode(SDL_VideoDevice *_this, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode) { @@ -45,7 +45,7 @@ static void WIN_UpdateDisplayMode(SDL_VideoDevice *_this, LPCWSTR deviceName, DW data->DeviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS); - /* NOLINTNEXTLINE(bugprone-assignment-in-if-condition): No simple way to extract the assignment */ + // NOLINTNEXTLINE(bugprone-assignment-in-if-condition): No simple way to extract the assignment if (index == ENUM_CURRENT_SETTINGS && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) { char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)]; LPBITMAPINFO bmi; @@ -85,7 +85,7 @@ static void WIN_UpdateDisplayMode(SDL_VideoDevice *_this, LPCWSTR deviceName, DW } } } else if (mode->format == SDL_PIXELFORMAT_UNKNOWN) { - /* FIXME: Can we tell what this will be? */ + // FIXME: Can we tell what this will be? if ((data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) { switch (data->DeviceMode.dmBitsPerPel) { case 32: @@ -163,7 +163,7 @@ static SDL_DisplayOrientation WIN_GetNaturalOrientation(DEVMODE *mode) int width = mode->dmPelsWidth; int height = mode->dmPelsHeight; - /* Use unrotated width/height to guess orientation */ + // Use unrotated width/height to guess orientation if (mode->dmDisplayOrientation == DMDO_90 || mode->dmDisplayOrientation == DMDO_270) { int temp = width; width = height; @@ -210,7 +210,7 @@ static SDL_DisplayOrientation WIN_GetDisplayOrientation(DEVMODE *mode) static void WIN_GetRefreshRate(void *dxgi_output, DEVMODE *mode, int *numerator, int *denominator) { - /* We're not currently using DXGI to query display modes, so fake NTSC timings */ + // We're not currently using DXGI to query display modes, so fake NTSC timings switch (mode->dmDisplayFrequency) { case 119: case 59: @@ -257,7 +257,7 @@ static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor) } } if (dpi == 0) { - /* Window 8.0 and below: same DPI for all monitors */ + // Window 8.0 and below: same DPI for all monitors HDC hdc = GetDC(NULL); if (hdc) { dpi = GetDeviceCaps(hdc, LOGPIXELSX); @@ -265,7 +265,7 @@ static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor) } } if (dpi == 0) { - /* Safe default */ + // Safe default dpi = USER_DEFAULT_SCREEN_DPI; } return dpi / (float)USER_DEFAULT_SCREEN_DPI; @@ -296,7 +296,7 @@ static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HM mode->h = data->DeviceMode.dmPelsHeight; WIN_GetRefreshRate(dxgi_output, &data->DeviceMode, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator); - /* Fill in the mode information */ + // Fill in the mode information WIN_UpdateDisplayMode(_this, deviceName, index, mode); if (natural_orientation) { @@ -524,7 +524,7 @@ static float WIN_GetSDRWhitePoint(SDL_VideoDevice *_this, HMONITOR hMonitor) white_level.header.size = sizeof(white_level); white_level.header.adapterId = path_info.targetInfo.adapterId; white_level.header.id = path_info.targetInfo.id; - /* WIN_GetMonitorPathInfo() succeeded: DisplayConfigGetDeviceInfo is not NULL */ + // WIN_GetMonitorPathInfo() succeeded: DisplayConfigGetDeviceInfo is not NULL if (videodata->DisplayConfigGetDeviceInfo(&white_level.header) == ERROR_SUCCESS && white_level.SDRWhiteLevel > 0) { SDR_white_level = (white_level.SDRWhiteLevel / 1000.0f); @@ -546,7 +546,7 @@ static void WIN_GetHDRProperties(SDL_VideoDevice *_this, HMONITOR hMonitor, SDL_ } } } -#endif /* HAVE_DXGI1_6_H */ +#endif // HAVE_DXGI1_6_H static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONITORINFOEXW *info, int *display_index) { @@ -580,12 +580,12 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI SDL_bool changed_bounds = SDL_FALSE; if (internal->state != DisplayRemoved) { - /* We've already enumerated this display, don't move it */ + // We've already enumerated this display, don't move it return; } if (index >= _this->num_displays) { - /* This should never happen due to the check above, but just in case... */ + // This should never happen due to the check above, but just in case... return; } @@ -774,7 +774,7 @@ int WIN_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) break; } if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) { - /* We don't support palettized modes now */ + // We don't support palettized modes now SDL_free(mode.internal); continue; } @@ -920,7 +920,7 @@ void WIN_RefreshDisplays(SDL_VideoDevice *_this) void WIN_QuitModes(SDL_VideoDevice *_this) { - /* All fullscreen windows should have restored modes by now */ + // All fullscreen windows should have restored modes by now } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsmodes.h b/src/video/windows/SDL_windowsmodes.h index 8e2a3a2c4c..6b8062848c 100644 --- a/src/video/windows/SDL_windowsmodes.h +++ b/src/video/windows/SDL_windowsmodes.h @@ -52,4 +52,4 @@ extern int WIN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, extern void WIN_RefreshDisplays(SDL_VideoDevice *_this); extern void WIN_QuitModes(SDL_VideoDevice *_this); -#endif /* SDL_windowsmodes_h_ */ +#endif // SDL_windowsmodes_h_ diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index b9f177a970..cf1774fec6 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -87,12 +87,12 @@ static SDL_bool IsMonochromeSurface(SDL_Surface *surface) for (x = 0; x < surface->w; x++) { SDL_ReadSurfacePixel(surface, x, y, &r, &g, &b, &a); - /* Black or white pixel. */ + // Black or white pixel. if (!((r == 0x00 && g == 0x00 && b == 0x00) || (r == 0xff && g == 0xff && b == 0xff))) { return SDL_FALSE; } - /* Transparent or opaque pixel. */ + // Transparent or opaque pixel. if (!(a == 0x00 || a == 0xff)) { return SDL_FALSE; } @@ -113,7 +113,7 @@ static HBITMAP CreateColorBitmap(SDL_Surface *surface) SDL_zero(bi); bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = surface->w; - bi.bmiHeader.biHeight = -surface->h; /* Invert height to make the top-down DIB. */ + bi.bmiHeader.biHeight = -surface->h; // Invert height to make the top-down DIB. bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; @@ -155,7 +155,7 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, SDL_bool is_monochrome) dst = (Uint8 *)pixels; - /* Make the mask completely transparent. */ + // Make the mask completely transparent. SDL_memset(dst, 0xff, size); if (is_monochrome) { SDL_memset(dst + size, 0x00, size); @@ -166,12 +166,12 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, SDL_bool is_monochrome) SDL_ReadSurfacePixel(surface, x, y, &r, &g, &b, &a); if (a != 0) { - /* Reset bit of an opaque pixel. */ + // Reset bit of an opaque pixel. dst[x >> 3] &= ~masks[x & 7]; } if (is_monochrome && !(r == 0x00 && g == 0x00 && b == 0x00)) { - /* Set bit of white or inverted pixel. */ + // Set bit of white or inverted pixel. dst[size + (x >> 3)] |= masks[x & 7]; } } @@ -428,13 +428,13 @@ static int WIN_ShowCursor(SDL_Cursor *cursor) void WIN_SetCursorPos(int x, int y) { - /* We need to jitter the value because otherwise Windows will occasionally inexplicably ignore the SetCursorPos() or SendInput() */ + // 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, y); - /* Flush any mouse motion prior to or associated with this warp */ -#ifdef _MSC_VER /* We explicitly want to use GetTickCount(), not GetTickCount64() */ + // Flush any mouse motion prior to or associated with this warp +#ifdef _MSC_VER // We explicitly want to use GetTickCount(), not GetTickCount64() #pragma warning(push) #pragma warning(disable : 28159) #endif @@ -453,7 +453,7 @@ static int WIN_WarpMouse(SDL_Window *window, float x, float y) HWND hwnd = data->hwnd; POINT pt; - /* Don't warp the mouse while we're doing a modal interaction */ + // Don't warp the mouse while we're doing a modal interaction if (data->in_title_click || data->focus_click_pending) { return 0; } @@ -463,7 +463,7 @@ static int WIN_WarpMouse(SDL_Window *window, float x, float y) ClientToScreen(hwnd, &pt); WIN_SetCursorPos(pt.x, pt.y); - /* Send the exact mouse motion associated with this warp */ + // Send the exact mouse motion associated with this warp SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); return 0; } @@ -650,4 +650,4 @@ void WIN_UpdateMouseSystemScale(void) } } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsmouse.h b/src/video/windows/SDL_windowsmouse.h index 50c5032793..ba298b736f 100644 --- a/src/video/windows/SDL_windowsmouse.h +++ b/src/video/windows/SDL_windowsmouse.h @@ -31,4 +31,4 @@ extern void WIN_QuitMouse(SDL_VideoDevice *_this); extern void WIN_SetCursorPos(int x, int y); extern void WIN_UpdateMouseSystemScale(); -#endif /* SDL_windowsmouse_h_ */ +#endif // SDL_windowsmouse_h_ diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 0f18eb28e3..616ecff675 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -25,7 +25,7 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsopengles.h" -/* WGL implementation of SDL OpenGL support */ +// WGL implementation of SDL OpenGL support #ifdef SDL_VIDEO_OPENGL_WGL #include @@ -122,15 +122,15 @@ int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); - /* Allocate OpenGL memory */ + // Allocate OpenGL memory _this->gl_data = (struct SDL_GLDriverData *)SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { return -1; } - /* Load function pointers */ + // Load function pointers handle = _this->gl_config.dll_handle; - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off _this->gl_data->wglGetProcAddress = (PROC (WINAPI *)(const char *)) SDL_LoadFunction(handle, "wglGetProcAddress"); _this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) @@ -141,7 +141,7 @@ int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_LoadFunction(handle, "wglMakeCurrent"); _this->gl_data->wglShareLists = (BOOL (WINAPI *)(HGLRC, HGLRC)) SDL_LoadFunction(handle, "wglShareLists"); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) _this->gl_data->wglSwapBuffers = (BOOL(WINAPI *)(HDC)) @@ -216,10 +216,10 @@ SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *pr { SDL_FunctionPointer func; - /* This is to pick up extensions */ + // This is to pick up extensions func = (SDL_FunctionPointer)_this->gl_data->wglGetProcAddress(proc); if (!func) { - /* This is probably a normal GL function */ + // This is probably a normal GL function func = (SDL_FunctionPointer)GetProcAddress((HMODULE)_this->gl_config.dll_handle, proc); } return func; @@ -230,7 +230,7 @@ void WIN_GL_UnloadLibrary(SDL_VideoDevice *_this) SDL_UnloadObject(_this->gl_config.dll_handle); _this->gl_config.dll_handle = NULL; - /* Free OpenGL memory */ + // Free OpenGL memory SDL_free(_this->gl_data); _this->gl_data = NULL; } @@ -374,7 +374,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) const char *start; const char *where, *terminator; - /* Extension names should not have spaces. */ + // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { return SDL_FALSE; @@ -410,9 +410,9 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) void WIN_GL_InitExtensions(SDL_VideoDevice *_this) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off const char *(WINAPI * wglGetExtensionsStringARB)(HDC) = 0; - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on const char *extensions; HWND hwnd; HDC hdc; @@ -443,27 +443,27 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) } _this->gl_data->wglMakeCurrent(hdc, hglrc); - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off wglGetExtensionsStringARB = (const char *(WINAPI *)(HDC)) _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on if (wglGetExtensionsStringARB) { extensions = wglGetExtensionsStringARB(hdc); } else { extensions = NULL; } - /* Check for WGL_ARB_pixel_format */ + // Check for WGL_ARB_pixel_format _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE; if (HasExtension("WGL_ARB_pixel_format", extensions)) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 *)) WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB"); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on if ((_this->gl_data->wglChoosePixelFormatARB != NULL) && (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { @@ -471,7 +471,7 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) } } - /* Check for WGL_EXT_swap_control */ + // Check for WGL_EXT_swap_control _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE; if (HasExtension("WGL_EXT_swap_control", extensions)) { _this->gl_data->wglSwapIntervalEXT = @@ -488,24 +488,24 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) _this->gl_data->wglGetSwapIntervalEXT = NULL; } - /* Check for WGL_EXT_create_context_es2_profile */ + // Check for WGL_EXT_create_context_es2_profile 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); } - /* Check for WGL_ARB_context_flush_control */ + // Check for WGL_ARB_context_flush_control if (HasExtension("WGL_ARB_context_flush_control", extensions)) { _this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE; } - /* Check for WGL_ARB_create_context_robustness */ + // Check for WGL_ARB_create_context_robustness if (HasExtension("WGL_ARB_create_context_robustness", extensions)) { _this->gl_data->HAS_WGL_ARB_create_context_robustness = SDL_TRUE; } - /* Check for WGL_ARB_create_context_no_error */ + // Check for WGL_ARB_create_context_no_error if (HasExtension("WGL_ARB_create_context_no_error", extensions)) { _this->gl_data->HAS_WGL_ARB_create_context_no_error = SDL_TRUE; } @@ -549,7 +549,7 @@ static int WIN_GL_ChoosePixelFormatARB(SDL_VideoDevice *_this, int *iAttribs, fl 1, &pixel_format, &matching); - /* Check whether we actually got an SRGB capable buffer */ + // Check whether we actually got an SRGB capable buffer _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0, 1, &qAttrib, &srgb); _this->gl_config.framebuffer_srgb_capable = srgb; } @@ -564,7 +564,7 @@ static int WIN_GL_ChoosePixelFormatARB(SDL_VideoDevice *_this, int *iAttribs, fl return pixel_format; } -/* actual work of WIN_GL_SetupWindow() happens here. */ +// actual work of WIN_GL_SetupWindow() happens here. static int WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *window) { HDC hdc = window->internal->hdc; @@ -577,7 +577,7 @@ static int WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *window WIN_GL_SetupPixelFormat(_this, &pfd); - /* setup WGL_ARB_pixel_format attribs */ + // setup WGL_ARB_pixel_format attribs iAttr = &iAttribs[0]; *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; @@ -664,14 +664,14 @@ static int WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *window *iAttr = 0; - /* Choose and set the closest available pixel format */ + // Choose and set the closest available pixel format pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); - /* App said "don't care about accel" and FULL accel failed. Try NO. */ + // App said "don't care about accel" and FULL accel failed. Try NO. 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(_this, hdc, &pfd); @@ -687,7 +687,7 @@ static int WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *window int WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) { - /* The current context is lost in here; save it and reset it. */ + // The current context is lost in here; save it and reset it. SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); const int retval = WIN_GL_SetupWindowInternal(_this, window); @@ -700,7 +700,7 @@ SDL_bool WIN_GL_UseEGL(SDL_VideoDevice *_this) SDL_assert(_this->gl_data != NULL); 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 || _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); /* No WGL extension for OpenGL ES 1.x profiles. */ + return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 || _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); // No WGL extension for OpenGL ES 1.x profiles. } SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) @@ -710,7 +710,7 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) { #ifdef SDL_VIDEO_OPENGL_EGL - /* Switch to EGL based functions */ + // Switch to EGL based functions WIN_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GLES_LoadLibrary; _this->GL_GetProcAddress = WIN_GLES_GetProcAddress; @@ -743,7 +743,7 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) if (_this->gl_config.major_version < 3 && _this->gl_config.profile_mask == 0 && _this->gl_config.flags == 0) { - /* Create legacy context */ + // Create legacy context context = _this->gl_data->wglCreateContext(hdc); if (share_context != 0) { _this->gl_data->wglShareLists(share_context, context); @@ -756,7 +756,7 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) return NULL; } - /* Make the context current */ + // Make the context current if (WIN_GL_MakeCurrent(_this, window, (SDL_GLContext)temp_context) < 0) { WIN_GL_DeleteContext(_this, (SDL_GLContext)temp_context); return NULL; @@ -768,7 +768,7 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) 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; @@ -776,31 +776,31 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) attribs[iattr++] = WGL_CONTEXT_MINOR_VERSION_ARB; attribs[iattr++] = _this->gl_config.minor_version; - /* SDL profile bits match WGL profile bits */ + // SDL profile bits match WGL profile bits if (_this->gl_config.profile_mask != 0) { attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB; attribs[iattr++] = _this->gl_config.profile_mask; } - /* SDL flags match WGL flags */ + // SDL flags match WGL flags if (_this->gl_config.flags != 0) { attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB; attribs[iattr++] = _this->gl_config.flags; } - /* only set if wgl extension is available and not the default setting */ + // only set if wgl extension is available and not the default setting if ((_this->gl_data->HAS_WGL_ARB_context_flush_control) && (_this->gl_config.release_behavior == 0)) { 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; } - /* only set if wgl extension is available and not the default setting */ + // only set if wgl extension is available and not the default setting if ((_this->gl_data->HAS_WGL_ARB_create_context_robustness) && (_this->gl_config.reset_notification != 0)) { 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; } - /* only set if wgl extension is available and not the default setting */ + // only set if wgl extension is available and not the default setting if ((_this->gl_data->HAS_WGL_ARB_create_context_no_error) && (_this->gl_config.no_error != 0)) { attribs[iattr++] = WGL_CONTEXT_OPENGL_NO_ERROR_ARB; attribs[iattr++] = _this->gl_config.no_error; @@ -808,9 +808,9 @@ SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) attribs[iattr++] = 0; - /* Create the GL 3.x context */ + // Create the GL 3.x context context = wglCreateContextAttribsARB(hdc, share_context, attribs); - /* Delete the GL 2.x context */ + // Delete the GL 2.x context _this->gl_data->wglDeleteContext(temp_context); } } @@ -836,7 +836,7 @@ int WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext return SDL_SetError("OpenGL not initialized"); } - /* sanity check that higher level handled this. */ + // sanity check that higher level handled this. SDL_assert(window || (window == NULL && !context)); /* Some Windows drivers freak out if hdc is NULL, even when context is @@ -847,7 +847,7 @@ int WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext window = SDL_GL_GetCurrentWindow(); if (!window) { SDL_assert(SDL_GL_GetCurrentContext() == NULL); - return 0; /* already done. */ + return 0; // already done. } } @@ -901,6 +901,6 @@ int WIN_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -#endif /* SDL_VIDEO_OPENGL_WGL */ +#endif // SDL_VIDEO_OPENGL_WGL -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index ee987d91d2..cb4816232b 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -75,7 +75,7 @@ struct SDL_GLDriverData int minor; } es_profile_max_supported_version; - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off PROC (WINAPI *wglGetProcAddress)(const char *proc); HGLRC (WINAPI *wglCreateContext)(HDC hdc); BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc); @@ -98,10 +98,10 @@ struct SDL_GLDriverData const PIXELFORMATDESCRIPTOR *ppfd); int (WINAPI *wglGetPixelFormat)(HDC hdc); #endif - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on }; -/* OpenGL functions */ +// OpenGL functions extern int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); extern void WIN_GL_UnloadLibrary(SDL_VideoDevice *_this); @@ -173,6 +173,6 @@ extern void WIN_GL_InitExtensions(SDL_VideoDevice *_this); #define WGL_SAMPLES_ARB 0x2042 #endif -#endif /* SDL_VIDEO_OPENGL_WGL */ +#endif // SDL_VIDEO_OPENGL_WGL -#endif /* SDL_windowsopengl_h_ */ +#endif // SDL_windowsopengl_h_ diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index 48ff20d1d6..319a3ff666 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -27,12 +27,12 @@ #include "SDL_windowsopengl.h" #include "SDL_windowswindow.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support int WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - /* If the profile requested is not GL ES, switch over to WIN_GL functions */ + // 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 && !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { #ifdef SDL_VIDEO_OPENGL_WGL @@ -68,7 +68,7 @@ SDL_GLContext WIN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) #ifdef SDL_VIDEO_OPENGL_WGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES && !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { - /* Switch to WGL based functions */ + // Switch to WGL based functions WIN_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GL_LoadLibrary; _this->GL_GetProcAddress = WIN_GL_GetProcAddress; @@ -99,21 +99,21 @@ int WIN_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off SDL_EGL_SwapWindow_impl(WIN) SDL_EGL_MakeCurrent_impl(WIN) -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on int WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) { - /* The current context is lost in here; save it and reset it. */ + // The current context is lost in here; save it and reset it. SDL_WindowData *windowdata = window->internal; SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); if (!_this->egl_data) { -/* !!! 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, _this->gl_config.egl_platform) < 0) { @@ -123,7 +123,7 @@ int WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) _this->gl_config.driver_loaded = 1; } - /* Create the GLES window surface */ + // Create the GLES window surface windowdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)windowdata->hwnd); if (windowdata->egl_surface == EGL_NO_SURFACE) { @@ -141,4 +141,4 @@ WIN_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window) return windowdata->egl_surface; } -#endif /* SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL */ +#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 5a40f777f5..3c28064bc0 100644 --- a/src/video/windows/SDL_windowsopengles.h +++ b/src/video/windows/SDL_windowsopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define WIN_GLES_GetAttribute SDL_EGL_GetAttribute #define WIN_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define WIN_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -43,6 +43,6 @@ extern int WIN_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) extern int WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_EGLSurface WIN_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL -#endif /* SDL_winopengles_h_ */ +#endif // SDL_winopengles_h_ diff --git a/src/video/windows/SDL_windowsrawinput.c b/src/video/windows/SDL_windowsrawinput.c index 68fee93e32..ad7fc0756b 100644 --- a/src/video/windows/SDL_windowsrawinput.c +++ b/src/video/windows/SDL_windowsrawinput.c @@ -84,10 +84,10 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param) return 0; } - /* Make sure we get events as soon as possible */ + // Make sure we get events as soon as possible SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - /* Tell the parent we're ready to go! */ + // Tell the parent we're ready to go! SetEvent(data->ready_event); while (!data->done) { @@ -95,7 +95,7 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param) break; } - /* Clear the queue status so MsgWaitForMultipleObjects() will wait again */ + // Clear the queue status so MsgWaitForMultipleObjects() will wait again (void)GetQueueStatus(QS_RAWINPUT); WIN_PollRawInput(_this); @@ -160,7 +160,7 @@ static int WIN_SetRawInputEnabled(SDL_VideoDevice *_this, Uint32 flags) goto done; } - /* Wait for the thread to signal ready or exit */ + // Wait for the thread to signal ready or exit handles[0] = thread_data.ready_event; handles[1] = thread_data.thread; if (WaitForMultipleObjects(2, handles, FALSE, INFINITE) != WAIT_OBJECT_0) { @@ -247,6 +247,6 @@ int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled) return SDL_Unsupported(); } -#endif /* !SDL_PLATFORM_XBOXONE && !SDL_PLATFORM_XBOXSERIES */ +#endif // !SDL_PLATFORM_XBOXONE && !SDL_PLATFORM_XBOXSERIES -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsrawinput.h b/src/video/windows/SDL_windowsrawinput.h index 1ace796629..ddf6ed3d54 100644 --- a/src/video/windows/SDL_windowsrawinput.h +++ b/src/video/windows/SDL_windowsrawinput.h @@ -26,4 +26,4 @@ extern int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, SDL_bool enabled); extern int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled); -#endif /* SDL_windowsrawinput_h_ */ +#endif // SDL_windowsrawinput_h_ diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 0abf374f38..7a11e5909b 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -61,7 +61,7 @@ static HRGN GenerateSpanListRegion(SDL_Surface *shape, int offset_x, int offset_ a += 4; } if (span_start != -1) { - /* Add the final span */ + // Add the final span AddRegion(&mask, offset_x + span_start, offset_y + y, offset_x + x, offset_y + y + 1); span_start = -1; } @@ -74,7 +74,7 @@ int WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfac SDL_WindowData *data = window->internal; HRGN mask = NULL; - /* Generate a set of spans for the region */ + // Generate a set of spans for the region if (shape) { SDL_Surface *stretched = NULL; RECT rect; @@ -102,14 +102,14 @@ int WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfac mask = GenerateSpanListRegion(shape, -rect.left, -rect.top); if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) { - /* Add the window borders */ - /* top */ + // Add the window borders + // top AddRegion(&mask, 0, 0, -rect.left + shape->w + rect.right + 1, -rect.top + 1); - /* left */ + // left AddRegion(&mask, 0, -rect.top, -rect.left + 1, -rect.top + shape->h + 1); - /* right */ + // right AddRegion(&mask, -rect.left + shape->w, -rect.top, -rect.left + shape->w + rect.right + 1, -rect.top + shape->h + 1); - /* bottom */ + // bottom AddRegion(&mask, 0, -rect.top + shape->h, -rect.left + shape->w + rect.right + 1, -rect.top + shape->h + rect.bottom + 1); } @@ -123,4 +123,4 @@ int WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfac return 0; } -#endif /* defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) diff --git a/src/video/windows/SDL_windowsshape.h b/src/video/windows/SDL_windowsshape.h index 380fe0b8ff..7bffbc4833 100644 --- a/src/video/windows/SDL_windowsshape.h +++ b/src/video/windows/SDL_windowsshape.h @@ -25,4 +25,4 @@ extern int WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); -#endif /* SDL_windowsshape_h_ */ +#endif // SDL_windowsshape_h_ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 440e21db2d..4f38cc06e3 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -40,13 +40,13 @@ #include "../gdk/SDL_gdktextinput.h" #endif -/* #define HIGHDPI_DEBUG */ +// #define HIGHDPI_DEBUG -/* Initialization/Query functions */ +// Initialization/Query functions static int WIN_VideoInit(SDL_VideoDevice *_this); static void WIN_VideoQuit(SDL_VideoDevice *_this); -/* Hints */ +// Hints SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE; SDL_bool g_WindowsEnableMenuMnemonics = SDL_FALSE; SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE; @@ -89,7 +89,7 @@ static int WIN_SuspendScreenSaver(SDL_VideoDevice *_this) extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); #endif -/* Windows driver bootstrap functions */ +// Windows driver bootstrap functions static void WIN_DeleteDevice(SDL_VideoDevice *device) { @@ -127,7 +127,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) SDL_RegisterApp(NULL, 0, NULL); - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); @@ -145,7 +145,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) data->userDLL = SDL_LoadObject("USER32.DLL"); if (data->userDLL) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *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"); @@ -162,28 +162,28 @@ static SDL_VideoDevice *WIN_CreateDevice(void) data->GetDisplayConfigBufferSizes = (LONG (WINAPI *)(UINT32,UINT32*,UINT32* ))SDL_LoadFunction(data->userDLL, "GetDisplayConfigBufferSizes"); data->QueryDisplayConfig = (LONG (WINAPI *)(UINT32,UINT32*,DISPLAYCONFIG_PATH_INFO*,UINT32*,DISPLAYCONFIG_MODE_INFO*,DISPLAYCONFIG_TOPOLOGY_ID*))SDL_LoadFunction(data->userDLL, "QueryDisplayConfig"); data->DisplayConfigGetDeviceInfo = (LONG (WINAPI *)(DISPLAYCONFIG_DEVICE_INFO_HEADER*))SDL_LoadFunction(data->userDLL, "DisplayConfigGetDeviceInfo"); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on } else { SDL_ClearError(); } data->shcoreDLL = SDL_LoadObject("SHCORE.DLL"); if (data->shcoreDLL) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on } else { SDL_ClearError(); } -#endif /* #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef HAVE_DXGI_H data->dxgiDLL = SDL_LoadObject("DXGI.DLL"); if (data->dxgiDLL) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off typedef HRESULT (WINAPI *CreateDXGI_t)(REFIID riid, void **ppFactory); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on CreateDXGI_t CreateDXGI; CreateDXGI = (CreateDXGI_t)SDL_LoadFunction(data->dxgiDLL, "CreateDXGIFactory"); @@ -194,7 +194,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) } #endif - /* Set the function pointers */ + // Set the function pointers device->VideoInit = WIN_VideoInit; device->VideoQuit = WIN_VideoQuit; #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -266,7 +266,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) #ifdef SDL_VIDEO_OPENGL_WGL if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { #endif - /* Use EGL based functions */ + // Use EGL based functions device->GL_LoadLibrary = WIN_GLES_LoadLibrary; device->GL_GetProcAddress = WIN_GLES_GetProcAddress; device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; @@ -340,7 +340,7 @@ static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this) if (data->SetProcessDpiAwarenessContext) { return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE); } else if (data->SetProcessDpiAwareness) { - /* Windows 8.1 */ + // Windows 8.1 return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_DPI_UNAWARE)); } #endif @@ -353,13 +353,13 @@ static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this) SDL_VideoData *data = _this->internal; if (data->SetProcessDpiAwarenessContext) { - /* Windows 10, version 1607 */ + // Windows 10, version 1607 return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); } else if (data->SetProcessDpiAwareness) { - /* Windows 8.1 */ + // Windows 8.1 return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)); } else if (data->SetProcessDPIAware) { - /* Windows Vista */ + // Windows Vista return data->SetProcessDPIAware(); } #endif @@ -372,13 +372,13 @@ static BOOL WIN_DeclareDPIAwarePerMonitor(SDL_VideoDevice *_this) SDL_VideoData *data = _this->internal; if (data->SetProcessDpiAwarenessContext) { - /* Windows 10, version 1607 */ + // Windows 10, version 1607 return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); } else if (data->SetProcessDpiAwareness) { - /* Windows 8.1 */ + // Windows 8.1 return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)); } else { - /* Older OS: fall back to system DPI aware */ + // Older OS: fall back to system DPI aware return WIN_DeclareDPIAwareSystem(_this); } #else @@ -393,9 +393,9 @@ static BOOL WIN_DeclareDPIAwarePerMonitorV2(SDL_VideoDevice *_this) #else SDL_VideoData *data = _this->internal; - /* Declare DPI aware (may have been done in external code or a manifest, as well) */ + // Declare DPI aware (may have been done in external code or a manifest, as well) if (data->SetProcessDpiAwarenessContext) { - /* Windows 10, version 1607 */ + // Windows 10, version 1607 /* NOTE: SetThreadDpiAwarenessContext doesn't work here with OpenGL - the OpenGL contents end up still getting OS scaled. (tested on Windows 10 21H1 19043.1348, NVIDIA 496.49) @@ -418,7 +418,7 @@ static BOOL WIN_DeclareDPIAwarePerMonitorV2(SDL_VideoDevice *_this) return WIN_DeclareDPIAwarePerMonitor(_this); } } else { - /* Older OS: fall back to per-monitor (or system) */ + // Older OS: fall back to per-monitor (or system) return WIN_DeclareDPIAwarePerMonitor(_this); } #endif @@ -480,7 +480,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) } else { SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "OleInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr); } -#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) } else { SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "CoInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr); } @@ -496,7 +496,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) } #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - /* For Xbox, we just need to create the single display */ + // For Xbox, we just need to create the single display { SDL_DisplayMode mode; @@ -507,7 +507,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) SDL_AddBasicVideoDisplay(&mode); } -#else /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#else // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (WIN_InitModes(_this) < 0) { return -1; } @@ -555,7 +555,7 @@ void WIN_VideoQuit(SDL_VideoDevice *_this) OleUninitialize(); data->oleinitialized = SDL_FALSE; } -#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) if (data->coinitialized) { WIN_CoUninitialize(); @@ -574,7 +574,7 @@ void WIN_VideoQuit(SDL_VideoDevice *_this) #ifndef D3D9b_SDK_VERSION #define D3D9b_SDK_VERSION (31 | 0x80000000) #endif -#else /**/ +#else // #ifndef D3D_SDK_VERSION #define D3D_SDK_VERSION 32 #endif @@ -587,10 +587,10 @@ SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); if (*pD3DDLL) { - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on Direct3DCreate9_t Direct3DCreate9Func; if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, SDL_FALSE)) { @@ -639,7 +639,7 @@ int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) if (!pData) { SDL_SetError("Invalid display index"); - adapterIndex = -1; /* make sure we return something invalid */ + adapterIndex = -1; // make sure we return something invalid } else { char *displayName = WIN_StringToUTF8W(pData->DeviceName); unsigned int count = IDirect3D9_GetAdapterCount(pD3D); @@ -656,14 +656,14 @@ int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) SDL_free(displayName); } - /* free up the D3D stuff we inited */ + // free up the D3D stuff we inited IDirect3D9_Release(pD3D); SDL_UnloadObject(pD3DDLL); return adapterIndex; } } -#endif /* !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) int SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) { @@ -735,7 +735,7 @@ SDL_SystemTheme WIN_GetSystemTheme(void) DWORD value = ~0U; DWORD length = sizeof(value); - /* Technically this isn't the system theme, but it's the preference for applications */ + // Technically this isn't the system theme, but it's the preference for applications if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { if (RegQueryValueExW(hKey, L"AppsUseLightTheme", 0, &dwType, (LPBYTE)&value, &length) == ERROR_SUCCESS) { if (value == 0) { @@ -753,11 +753,11 @@ SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) SDL_VideoData *data = _this->internal; if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) { - /* Windows 10, version 1607 */ + // Windows 10, version 1607 return data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, data->GetThreadDpiAwarenessContext()); } #endif return SDL_FALSE; } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index 9ad6a65f58..eb46c2cd77 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -65,7 +65,7 @@ #endif #if WINVER < 0x0601 -/* Touch input definitions */ +// Touch input definitions #define TWF_FINETOUCH 1 #define TWF_WANTPALM 2 @@ -89,8 +89,8 @@ typedef struct _TOUCHINPUT DWORD cyContact; } TOUCHINPUT, *PTOUCHINPUT; -/* More-robust display information in Vista... */ -/* This is a huge amount of data to be stuffing into three API calls. :( */ +// 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; @@ -285,7 +285,7 @@ typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME #define QDC_ONLY_ACTIVE_PATHS 0x00000002 -#endif /* WINVER < 0x0601 */ +#endif // WINVER < 0x0601 #ifndef HAVE_SHELLSCALINGAPI_H @@ -324,17 +324,17 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); #define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) -#endif /* _DPI_AWARENESS_CONTEXTS_ */ +#endif // _DPI_AWARENESS_CONTEXTS_ -/* Windows 10 Creators Update */ +// Windows 10 Creators Update #if NTDDI_VERSION < 0x0A000003 #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) -#endif /* NTDDI_VERSION < 0x0A000003 */ +#endif // NTDDI_VERSION < 0x0A000003 -/* Windows 10 version 1809 */ +// Windows 10 version 1809 #if NTDDI_VERSION < 0x0A000006 #define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) -#endif /* NTDDI_VERSION < 0x0A000006 */ +#endif // NTDDI_VERSION < 0x0A000006 typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); typedef void (*PFCoordTransform)(SDL_Window *, POINT *); @@ -347,7 +347,7 @@ typedef struct } TSFSink; #ifndef SDL_DISABLE_WINDOWS_IME -/* Definition from Win98DDK version of IMM.H */ +// Definition from Win98DDK version of IMM.H typedef struct tagINPUTCONTEXT2 { HWND hWnd; @@ -374,7 +374,7 @@ typedef struct tagINPUTCONTEXT2 } INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2; #endif -/* Private display data */ +// Private display data struct SDL_VideoData { @@ -383,14 +383,14 @@ struct SDL_VideoData SDL_bool coinitialized; #if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) SDL_bool oleinitialized; -#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) DWORD clipboard_count; -#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/ - /* Touch input functions */ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Xbox doesn't support user32/shcore + // Touch input functions void *userDLL; - /* *INDENT-OFF* */ /* clang-format off */ + /* *INDENT-OFF* */ // clang-format off BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); @@ -404,21 +404,21 @@ struct SDL_VideoData UINT (WINAPI *GetDpiForWindow)( HWND ); BOOL (WINAPI *AreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT); BOOL (WINAPI *IsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); - /* DisplayConfig functions */ + // DisplayConfig functions LONG (WINAPI *GetDisplayConfigBufferSizes)( UINT32, UINT32*, UINT32* ); LONG (WINAPI *QueryDisplayConfig)( UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO*, UINT32*, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*); LONG (WINAPI *DisplayConfigGetDeviceInfo)( DISPLAYCONFIG_DEVICE_INFO_HEADER*); - /* *INDENT-ON* */ /* clang-format on */ + /* *INDENT-ON* */ // clang-format on void *shcoreDLL; - /* *INDENT-OFF* */ /* clang-format off */ + /* *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); - /* *INDENT-ON* */ /* clang-format on */ -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ + /* *INDENT-ON* */ // clang-format on +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef HAVE_DXGI_H void *dxgiDLL; @@ -471,21 +471,21 @@ struct SDL_VideoData #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) COMPOSITIONFORM ime_composition_area; CANDIDATEFORM ime_candidate_area; -#endif /* !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifndef SDL_DISABLE_WINDOWS_IME HKL ime_hkl; void *ime_himm32; - /* *INDENT-OFF* */ /* clang-format off */ + /* *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 */ + /* *INDENT-ON* */ // clang-format on -#endif /* !SDL_DISABLE_WINDOWS_IME */ +#endif // !SDL_DISABLE_WINDOWS_IME BYTE pre_hook_key_state[256]; UINT _SDL_WAKEUP; @@ -501,4 +501,4 @@ extern SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface); extern SDL_SystemTheme WIN_GetSystemTheme(void); extern SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this); -#endif /* SDL_windowsvideo_h_ */ +#endif // SDL_windowsvideo_h_ diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index f8f0cb7622..79f275e9ae 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -47,7 +47,7 @@ int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } diff --git a/src/video/windows/SDL_windowsvulkan.h b/src/video/windows/SDL_windowsvulkan.h index ea74856cb3..79c9f4dbf5 100644 --- a/src/video/windows/SDL_windowsvulkan.h +++ b/src/video/windows/SDL_windowsvulkan.h @@ -53,4 +53,4 @@ SDL_bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, #endif -#endif /* SDL_windowsvulkan_h_ */ +#endif // SDL_windowsvulkan_h_ diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 0a234ccd98..99a0df623c 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -35,19 +35,19 @@ #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" -/* Dropfile support */ +// Dropfile support #include -/* DWM setting support */ +// DWM setting support typedef HRESULT (WINAPI *DwmSetWindowAttribute_t)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); typedef HRESULT (WINAPI *DwmGetWindowAttribute_t)(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute); -/* Dark mode support*/ +// Dark mode support #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif -/* Corner rounding support (Win 11+) */ +// Corner rounding support (Win 11+) #ifndef DWMWA_WINDOW_CORNER_PREFERENCE #define DWMWA_WINDOW_CORNER_PREFERENCE 33 #endif @@ -58,7 +58,7 @@ typedef enum { DWMWCP_ROUNDSMALL = 3 } DWM_WINDOW_CORNER_PREFERENCE; -/* Border Color support (Win 11+) */ +// Border Color support (Win 11+) #ifndef DWMWA_BORDER_COLOR #define DWMWA_BORDER_COLOR 34 #endif @@ -71,7 +71,7 @@ typedef enum { #define DWMWA_COLOR_NONE 0xFFFFFFFE #endif -/* Transparent window support */ +// Transparent window support #ifndef DWM_BB_ENABLE #define DWM_BB_ENABLE 0x00000001 #endif @@ -87,7 +87,7 @@ typedef struct } DWM_BLURBEHIND; typedef HRESULT(WINAPI *DwmEnableBlurBehindWindow_t)(HWND hwnd, const DWM_BLURBEHIND *pBlurBehind); -/* Windows CE compatibility */ +// Windows CE compatibility #ifndef SWP_NOCOPYBITS #define SWP_NOCOPYBITS 0 #endif @@ -100,9 +100,9 @@ typedef HRESULT(WINAPI *DwmEnableBlurBehindWindow_t)(HWND hwnd, const DWM_BLURBE #define WM_POPUPSYSTEMMENU 0x313 #endif -/* #define HIGHDPI_DEBUG */ +// #define HIGHDPI_DEBUG -/* Fake window to help with DirectInput events. */ +// Fake window to help with DirectInput events. HWND SDL_HelperWindow = NULL; static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow"); @@ -157,7 +157,7 @@ static DWORD GetWindowStyle(SDL_Window *window) } } - /* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */ + // Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window if (window->flags & SDL_WINDOW_MINIMIZED) { style |= WS_MINIMIZE; } @@ -187,7 +187,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD SDL_VideoData *videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->internal : NULL; RECT rect; - /* Client rect, in points */ + // Client rect, in points switch (rect_type) { case SDL_WINDOWRECT_CURRENT: SDL_RelativeToGlobalForWindow(window, window->x, window->y, x, y); @@ -205,7 +205,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD *height = window->floating.h; break; default: - /* Should never be here */ + // Should never be here SDL_assert_release(SDL_FALSE); *width = 0; *height = 0; @@ -245,7 +245,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD #endif } - /* Final rect in Windows screen space, including the frame */ + // Final rect in Windows screen space, including the frame *x += rect.left; *y += rect.top; *width = (rect.right - rect.left); @@ -298,7 +298,7 @@ int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi) AdjustWindowRectEx(lpRect, style, menu, styleEx); #else if (WIN_IsPerMonitorV2DPIAware(videodevice)) { - /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */ + // With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. if (!frame_dpi) { frame_dpi = videodata->GetDpiForWindow ? videodata->GetDpiForWindow(hwnd) : USER_DEFAULT_SCREEN_DPI; } @@ -324,7 +324,7 @@ int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect int w, h; int result = 0; - /* Figure out what the window area will be */ + // Figure out what the window area will be if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_ALWAYS_ON_TOP)) { top = HWND_TOPMOST; } else { @@ -339,7 +339,7 @@ int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect } data->expected_resize = SDL_FALSE; - /* Update any child windows */ + // Update any child windows for (child_window = window->first_child; child_window; child_window = child_window->next_sibling) { if (WIN_SetWindowPositionInternal(child_window, flags, SDL_WINDOWRECT_CURRENT) < 0) { result = -1; @@ -383,7 +383,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd SDL_VideoData *videodata = _this->internal; SDL_WindowData *data; - /* Allocate the window data */ + // Allocate the window data data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); if (!data) { return -1; @@ -418,7 +418,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data); #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* Associate the data with the window */ + // Associate the data with the window if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); SDL_free(data); @@ -428,7 +428,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd window->internal = data; - /* Set up the window proc function */ + // Set up the window proc function #ifdef GWLP_WNDPROC data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC); if (data->wndproc == WIN_WindowProc) { @@ -445,7 +445,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd } #endif - /* Fill in the SDL window with the window state */ + // Fill in the SDL window with the window state { DWORD style = GetWindowLong(hwnd, GWL_STYLE); if (style & WS_VISIBLE) { @@ -490,9 +490,9 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd window->floating.w = window->windowed.w = window->w = w; window->floating.h = window->windowed.h = window->h = h; } else if ((window->windowed.w && window->windowed.w != w) || (window->windowed.h && window->windowed.h != h)) { - /* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */ + // We tried to create a window larger than the desktop and Windows didn't allow it. Override! int x, y; - /* Figure out what the window area will be */ + // Figure out what the window area will be WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_WINDOWRECT_FLOATING); data->expected_resize = SDL_TRUE; SetWindowPos(hwnd, NULL, x, y, w, h, data->copybits_flag | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); @@ -538,7 +538,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* Enable multi-touch */ + // Enable multi-touch if (videodata->RegisterTouchWindow) { videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH | TWF_WANTPALM)); } @@ -552,7 +552,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (window->flags & SDL_WINDOW_EXTERNAL) { - /* Query the title from the existing window */ + // Query the title from the existing window LPTSTR title; int titleLen; SDL_bool isstack; @@ -571,14 +571,14 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd SDL_small_free(title, isstack); } } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_PropertiesID props = SDL_GetWindowProperties(window); SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, data->hwnd); SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HDC_POINTER, data->hdc); SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER, data->hinstance); - /* All done! */ + // All done! return 0; } @@ -608,7 +608,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) DestroyWindow(data->parent); } } else { - /* Restore any original event handler... */ + // Restore any original event handler... if (data->wndproc) { #ifdef GWLP_WNDPROC SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, @@ -626,7 +626,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) static void WIN_ConstrainPopup(SDL_Window *window) { - /* Clamp popup windows to the output borders */ + // Clamp popup windows to the output borders if (SDL_WINDOW_IS_POPUP(window)) { SDL_Window *w; SDL_DisplayID displayID; @@ -635,7 +635,7 @@ static void WIN_ConstrainPopup(SDL_Window *window) int abs_y = window->floating.y; int offset_x = 0, offset_y = 0; - /* Calculate the total offset from the parents */ + // Calculate the total offset from the parents for (w = window->parent; w->parent; w = w->parent) { offset_x += w->x; offset_y += w->y; @@ -646,7 +646,7 @@ static void WIN_ConstrainPopup(SDL_Window *window) abs_x += offset_x; abs_y += offset_y; - /* Constrain the popup window to the display of the toplevel parent */ + // Constrain the popup window to the display of the toplevel parent displayID = SDL_GetDisplayForWindow(w); SDL_GetDisplayBounds(displayID, &rect); if (abs_x + window->floating.w > rect.x + rect.w) { @@ -667,7 +667,7 @@ static void WIN_SetKeyboardFocus(SDL_Window *window) { SDL_Window *topmost = window; - /* Find the topmost parent */ + // Find the topmost parent while (topmost->parent) { topmost = topmost->parent; } @@ -701,7 +701,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI style |= GetWindowStyle(window); styleEx |= GetWindowStyleEx(window); - /* Figure out what the window area will be */ + // Figure out what the window area will be WIN_ConstrainPopup(window); WIN_AdjustWindowRectWithStyle(window, style, styleEx, FALSE, &x, &y, &w, &h, SDL_WINDOWRECT_FLOATING); @@ -723,7 +723,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return -1; } - /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */ + // Inform Windows of the frame change so we can respond to WM_NCCALCSIZE SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); if (window->flags & SDL_WINDOW_MINIMIZED) { @@ -737,7 +737,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - /* FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) */ + // FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) if (window->flags & SDL_WINDOW_TRANSPARENT) { void *handle = SDL_LoadObject("dwmapi.dll"); if (handle) { @@ -779,13 +779,13 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return 0; } - /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ + // The rest of this macro mess is for OpenGL or OpenGL ES windows #ifdef SDL_VIDEO_OPENGL_ES2 if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES || SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) #ifdef SDL_VIDEO_OPENGL_WGL && (!_this->gl_data || WIN_GL_UseEGL(_this)) -#endif /* SDL_VIDEO_OPENGL_WGL */ +#endif // SDL_VIDEO_OPENGL_WGL ) { #ifdef SDL_VIDEO_OPENGL_EGL if (WIN_GLES_SetupWindow(_this, window) < 0) { @@ -795,9 +795,9 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI 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_EGL } -#endif /* SDL_VIDEO_OPENGL_ES2 */ +#endif // SDL_VIDEO_OPENGL_ES2 #ifdef SDL_VIDEO_OPENGL_WGL if (WIN_GL_SetupWindow(_this, window) < 0) { @@ -808,7 +808,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return SDL_SetError("Could not create GL window (WGL support not configured)"); #endif } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) return 0; } @@ -835,13 +835,13 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i SDL_bool isstack; int retval = 0; - /* Create temporary buffer for ICONIMAGE structure */ + // 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); icon_len = sizeof(BITMAPINFOHEADER) + icon->h * icon->w * sizeof(Uint32) + mask_len; icon_bmp = SDL_small_alloc(BYTE, icon_len, &isstack); - /* Write the BITMAPINFO header */ + // Write the BITMAPINFO header bmi = (BITMAPINFOHEADER *)icon_bmp; bmi->biSize = SDL_Swap32LE(sizeof(BITMAPINFOHEADER)); bmi->biWidth = SDL_Swap32LE(icon->w); @@ -855,7 +855,7 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i bmi->biClrUsed = SDL_Swap32LE(0); bmi->biClrImportant = SDL_Swap32LE(0); - /* Write the pixels upside down into the bitmap buffer */ + // Write the pixels upside down into the bitmap buffer SDL_assert(icon->format == SDL_PIXELFORMAT_ARGB8888); dst = &icon_bmp[sizeof(BITMAPINFOHEADER)]; row_len = icon->w * sizeof(Uint32); @@ -866,7 +866,7 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i dst += row_len; } - /* Write the mask */ + // Write the mask SDL_memset(icon_bmp + icon_len - mask_len, 0xFF, mask_len); hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000); @@ -877,10 +877,10 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i retval = SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError()); } - /* Set the icon for the window */ + // Set the icon for the window SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon); - /* Set the icon in the task manager (should we do this?) */ + // Set the icon in the task manager (should we do this?) SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon); return retval; #else @@ -934,7 +934,7 @@ int WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *to *right = rcClient.right; return 0; -#else /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#else // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) HWND hwnd = window->internal->hwnd; RECT rcClient, rcWindow; POINT ptDiff; @@ -982,7 +982,7 @@ int WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *to *right = rcWindow.right - rcClient.right; return 0; -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) } void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) @@ -998,7 +998,7 @@ void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int * *w = window->last_pixel_w; *h = window->last_pixel_h; } else { - /* Probably created minimized, use the restored size */ + // Probably created minimized, use the restored size *w = window->floating.w; *h = window->floating.h; } @@ -1012,7 +1012,7 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE); if (window->parent) { - /* Update our position in case our parent moved while we were hidden */ + // Update our position in case our parent moved while we were hidden WIN_SetWindowPosition(_this, window); } @@ -1020,7 +1020,7 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) if (window->flags & SDL_WINDOW_MODAL) { EnableWindow(window->parent->internal->hwnd, FALSE); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) hwnd = window->internal->hwnd; style = GetWindowLong(hwnd, GWL_EXSTYLE); @@ -1030,7 +1030,7 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) if (bActivate) { ShowWindow(hwnd, SW_SHOW); } else { - /* Use SetWindowPos instead of ShowWindow to avoid activating the parent window if this is a child window */ + // Use SetWindowPos instead of ShowWindow to avoid activating the parent window if this is a child window SetWindowPos(hwnd, NULL, 0, 0, 0, 0, window->internal->copybits_flag | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); } @@ -1049,16 +1049,16 @@ void WIN_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) if (window->flags & SDL_WINDOW_MODAL) { EnableWindow(window->parent->internal->hwnd, TRUE); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) ShowWindow(hwnd, SW_HIDE); - /* Transfer keyboard focus back to the parent */ + // Transfer keyboard focus back to the parent if (window->flags & SDL_WINDOW_POPUP_MENU) { if (window == SDL_GetKeyboardFocus()) { SDL_Window *new_focus = window->parent; - /* Find the highest level window that isn't being hidden or destroyed. */ + // Find the highest level window that isn't being hidden or destroyed. while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1114,7 +1114,7 @@ void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) SetFocus(hwnd); SetActiveWindow(hwnd); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) } void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) @@ -1299,7 +1299,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide style &= ~WS_MAXIMIZE; } - /* Disable corner rounding & border color (Windows 11+) so the window fills the full screen */ + // Disable corner rounding & border color (Windows 11+) so the window fills the full screen data->windowed_mode_corner_rounding = WIN_UpdateCornerRoundingForHWND(hwnd, DWMWCP_DONOTROUND); data->dwma_border_color = WIN_UpdateBorderColorForHWND(hwnd, DWMWA_COLOR_NONE); } else { @@ -1341,7 +1341,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h); #endif -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) return 0; } @@ -1357,7 +1357,7 @@ void WIN_UpdateWindowICCProfile(SDL_Window *window, SDL_bool send_event) WCHAR fileName[MAX_PATH]; DWORD fileNameSize = SDL_arraysize(fileName); if (GetICMProfileW(hdc, &fileNameSize, fileName)) { - /* fileNameSize includes '\0' on return */ + // fileNameSize includes '\0' on return if (!data->ICMFileName || SDL_wcscmp(data->ICMFileName, fileName) != 0) { if (data->ICMFileName) { @@ -1412,7 +1412,7 @@ static void WIN_GrabKeyboard(SDL_Window *window) return; } - /* Capture a snapshot of the current keyboard state before the hook */ + // Capture a snapshot of the current keyboard state before the hook if (!GetKeyboardState(data->videodata->pre_hook_key_state)) { return; } @@ -1457,7 +1457,7 @@ int WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bo return 0; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { @@ -1472,24 +1472,24 @@ int SDL_HelperWindowCreate(void) HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASS wce; - /* Make sure window isn't created twice. */ + // Make sure window isn't created twice. if (SDL_HelperWindow != NULL) { return 0; } - /* Create the class. */ + // Create the class. SDL_zero(wce); wce.lpfnWndProc = DefWindowProc; wce.lpszClassName = SDL_HelperWindowClassName; wce.hInstance = hInstance; - /* Register the class. */ + // Register the class. SDL_HelperWindowClass = RegisterClass(&wce); if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) { return WIN_SetError("Unable to create Helper Window Class"); } - /* Create the window. */ + // Create the window. SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName, SDL_HelperWindowName, WS_OVERLAPPED, CW_USEDEFAULT, @@ -1511,7 +1511,7 @@ void SDL_HelperWindowDestroy(void) { HINSTANCE hInstance = GetModuleHandle(NULL); - /* Destroy the window. */ + // Destroy the window. if (SDL_HelperWindow != NULL) { if (DestroyWindow(SDL_HelperWindow) == 0) { WIN_SetError("Unable to destroy Helper Window"); @@ -1520,7 +1520,7 @@ void SDL_HelperWindowDestroy(void) SDL_HelperWindow = NULL; } - /* Unregister the class. */ + // Unregister the class. if (SDL_HelperWindowClass != 0) { if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) { WIN_SetError("Unable to destroy Helper Window Class"); @@ -1536,7 +1536,7 @@ void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; if (!data || !data->hwnd) { - /* The window wasn't fully initialized */ + // The window wasn't fully initialized return; } @@ -1547,9 +1547,9 @@ void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window) static BOOL GetClientScreenRect(HWND hwnd, RECT *rect) { - return GetClientRect(hwnd, rect) && /* RECT( left , top , right , bottom ) */ - ClientToScreen(hwnd, (LPPOINT)rect) && /* POINT( left , top ) */ - ClientToScreen(hwnd, (LPPOINT)rect + 1); /* POINT( right , bottom ) */ + return GetClientRect(hwnd, rect) && // RECT( left , top , right , bottom ) + ClientToScreen(hwnd, (LPPOINT)rect) && // POINT( left , top ) + ClientToScreen(hwnd, (LPPOINT)rect + 1); // POINT( right , bottom ) } void WIN_UpdateClipCursor(SDL_Window *window) @@ -1574,14 +1574,14 @@ void WIN_UpdateClipCursor(SDL_Window *window) (window->flags & SDL_WINDOW_INPUT_FOCUS)) { if (mouse->relative_mode && !mouse->relative_mode_warp && data->mouse_relative_mode_center) { if (GetClientScreenRect(data->hwnd, &rect)) { - /* WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 */ + // WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0; LONG cx, cy; cx = (rect.left + rect.right) / 2; cy = (rect.top + rect.bottom) / 2; - /* Make an absurdly small clip rect */ + // Make an absurdly small clip rect rect.left = cx - remote_desktop_adjustment; rect.right = cx + 1 + remote_desktop_adjustment; rect.top = cy; @@ -1599,10 +1599,10 @@ void WIN_UpdateClipCursor(SDL_Window *window) SDL_Rect mouse_rect_win_client; RECT mouse_rect, intersection; - /* mouse_rect_win_client is the mouse rect in Windows client space */ + // mouse_rect_win_client is the mouse rect in Windows client space mouse_rect_win_client = window->mouse_rect; - /* mouse_rect is the rect in Windows screen space */ + // mouse_rect is the rect in Windows screen space mouse_rect.left = rect.left + mouse_rect_win_client.x; mouse_rect.top = rect.top + mouse_rect_win_client.y; mouse_rect.right = mouse_rect.left + mouse_rect_win_client.w; @@ -1610,7 +1610,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) if (IntersectRect(&intersection, &rect, &mouse_rect)) { SDL_memcpy(&rect, &intersection, sizeof(rect)); } else if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { - /* Mouse rect was invalid, just do the normal grab */ + // Mouse rect was invalid, just do the normal grab } else { SDL_zero(rect); } @@ -1630,7 +1630,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) } else { SDL_bool unclip_cursor = SDL_FALSE; - /* If the cursor is clipped to the screen, clear the clip state */ + // If the cursor is clipped to the screen, clear the clip state if (!videodevice || (clipped_rect.left == videodevice->desktop_bounds.x && clipped_rect.top == videodevice->desktop_bounds.y)) { @@ -1657,9 +1657,9 @@ void WIN_UpdateClipCursor(SDL_Window *window) 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(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) { @@ -1673,7 +1673,7 @@ int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opaci SDL_assert(style != 0); if (opacity == 1.0f) { - /* want it fully opaque, just mark it unlayered if necessary. */ + // want it fully opaque, just mark it unlayered if necessary. if (style & WS_EX_LAYERED) { if (SetWindowLong(hwnd, GWL_EXSTYLE, style & ~WS_EX_LAYERED) == 0) { return WIN_SetError("SetWindowLong()"); @@ -1681,7 +1681,7 @@ int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opaci } } else { const BYTE alpha = (BYTE)((int)(opacity * 255.0f)); - /* want it transparent, mark it layered if necessary. */ + // want it transparent, mark it layered if necessary. if (!(style & WS_EX_LAYERED)) { if (SetWindowLong(hwnd, GWL_EXSTYLE, style | WS_EX_LAYERED) == 0) { return WIN_SetError("SetWindowLong()"); @@ -1694,7 +1694,7 @@ int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opaci } return 0; -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -2223,7 +2223,7 @@ int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool return 0; } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) void WIN_UpdateDarkModeForHWND(HWND hwnd) { @@ -2231,7 +2231,7 @@ void WIN_UpdateDarkModeForHWND(HWND hwnd) if (handle) { DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); if (DwmSetWindowAttributeFunc) { - /* FIXME: Do we need to traverse children? */ + // FIXME: Do we need to traverse children? BOOL value = (SDL_GetSystemTheme() == SDL_SYSTEM_THEME_DARK) ? TRUE : FALSE; DwmSetWindowAttributeFunc(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value)); } @@ -2251,7 +2251,7 @@ int WIN_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_ return 0; } - /* Reenable the old parent window. */ + // Reenable the old parent window. if (old_ptr) { EnableWindow((HWND)old_ptr, TRUE); } @@ -2267,13 +2267,13 @@ int WIN_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_ SetParent(modal_data->hwnd, (HWND)parent_hwnd); } - /* Disable the new parent window if the modal window is visible. */ + // Disable the new parent window if the modal window is visible. if (!(modal_window->flags & SDL_WINDOW_HIDDEN) && parent_hwnd) { EnableWindow((HWND)parent_hwnd, FALSE); } -#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) return 0; } -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 1b3ebfb0bb..14205950c8 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -29,7 +29,7 @@ #include "../SDL_sysvideo.h" #endif -/* Set up for C function definitions, even when using C++ */ +// Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif @@ -97,7 +97,7 @@ struct SDL_WindowData EGLSurface egl_surface; #endif - /* Whether we retain the content of the window when changing state */ + // Whether we retain the content of the window when changing state UINT copybits_flag; SDLDropTarget *drop_target; }; @@ -139,9 +139,9 @@ extern int WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, extern int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi); extern int WIN_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window); -/* Ends C function definitions when using C++ */ +// Ends C function definitions when using C++ #ifdef __cplusplus } #endif -#endif /* SDL_windowswindow_h_ */ +#endif // SDL_windowswindow_h_ diff --git a/src/video/winrt/SDL_winrtevents.cpp b/src/video/winrt/SDL_winrtevents.cpp index f5be65f88d..2543fb12b1 100644 --- a/src/video/winrt/SDL_winrtevents.cpp +++ b/src/video/winrt/SDL_winrtevents.cpp @@ -43,10 +43,10 @@ extern "C" { #include "../../events/SDL_events_c.h" } -/* Forward declarations */ +// Forward declarations static void WINRT_YieldXAMLThread(); -/* Global event management */ +// Global event management void WINRT_PumpEvents(SDL_VideoDevice *_this) { @@ -57,7 +57,7 @@ void WINRT_PumpEvents(SDL_VideoDevice *_this) } } -/* XAML Thread management */ +// XAML Thread management enum SDL_XAMLAppThreadState { @@ -140,4 +140,4 @@ void WINRT_CycleXAMLThread(void) } } -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h index 55a20f921d..2c56a672c2 100644 --- a/src/video/winrt/SDL_winrtevents_c.h +++ b/src/video/winrt/SDL_winrtevents_c.h @@ -44,7 +44,7 @@ extern void WINRT_PumpEvents(SDL_VideoDevice *_this); */ #ifdef __cplusplus_winrt -/* Pointers (Mice, Touch, etc.) */ +// Pointers (Mice, Touch, etc.) typedef enum { NormalizeZeroToOne, @@ -62,7 +62,7 @@ extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Inp 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 */ +// Keyboard extern void WINRT_ProcessAcceleratorKeyActivated(Windows::UI::Core::AcceleratorKeyEventArgs ^ args); extern void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI::Core::CharacterReceivedEventArgs ^ args); @@ -74,7 +74,7 @@ extern void WINRT_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) extern SDL_bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); #endif // NTDDI_VERSION >= ... -/* XAML Thread Management */ +// XAML Thread Management extern void WINRT_CycleXAMLThread(void); #endif // ifdef __cplusplus_winrt diff --git a/src/video/winrt/SDL_winrtgamebar.cpp b/src/video/winrt/SDL_winrtgamebar.cpp index 18bbbc9c0d..2a6155e23c 100644 --- a/src/video/winrt/SDL_winrtgamebar.cpp +++ b/src/video/winrt/SDL_winrtgamebar.cpp @@ -22,12 +22,12 @@ #ifdef SDL_VIDEO_DRIVER_WINRT -/* Windows includes */ +// Windows includes #include #include #include -/* SDL includes */ +// SDL includes extern "C" { #include "../SDL_sysvideo.h" } @@ -69,7 +69,7 @@ IGameBarStatics_ : public IInspectable boolean * value) = 0; }; -/* Declare the game bar's COM GUID */ +// Declare the game bar's COM GUID static GUID IID_IGameBarStatics_ = { MAKELONG(0xA292, 0x1DB9), 0xCC78, 0x4173, { 0xBE, 0x45, 0xB6, 0x1E, 0x67, 0x28, 0x3E, 0xA7 } }; /* Retrieves a pointer to the game bar, or NULL if it is not available. @@ -111,12 +111,12 @@ static void WINRT_HandleGameBarIsInputRedirected_MainThread() IGameBarStatics_ *gameBar; boolean isInputRedirected = 0; if (!WINRT_MainThreadDispatcher) { - /* The game bar event handler has been deregistered! */ + // The game bar event handler has been deregistered! return; } gameBar = WINRT_GetGameBar(); if (!gameBar) { - /* Shouldn't happen, but just in case... */ + // Shouldn't happen, but just in case... return; } if (SUCCEEDED(gameBar->get_IsInputRedirected(&isInputRedirected))) { @@ -182,4 +182,4 @@ void WINRT_QuitGameBar(SDL_VideoDevice *_this) gameBar->Release(); } -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtgamebar_cpp.h b/src/video/winrt/SDL_winrtgamebar_cpp.h index 51c54628c0..3a3026464f 100644 --- a/src/video/winrt/SDL_winrtgamebar_cpp.h +++ b/src/video/winrt/SDL_winrtgamebar_cpp.h @@ -30,4 +30,4 @@ extern void WINRT_InitGameBar(SDL_VideoDevice *_this); extern void WINRT_QuitGameBar(SDL_VideoDevice *_this); #endif -#endif /* SDL_winrtgamebar_h_ */ +#endif // SDL_winrtgamebar_h_ diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp index c2b5649da4..843c1a133d 100644 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/src/video/winrt/SDL_winrtkeyboard.cpp @@ -22,11 +22,11 @@ #ifdef SDL_VIDEO_DRIVER_WINRT -/* Windows-specific includes */ +// Windows-specific includes #include #include -/* SDL-specific includes */ +// SDL-specific includes #include "SDL_winrtevents_c.h" extern "C" { @@ -49,7 +49,7 @@ static SDL_Scancode WINRT_TranslateKeycode(Windows::System::VirtualKey virtualKe scanCode = 0xe046; } - /* Pack scan code into one byte to make the index. */ + // Pack scan code into one byte to make the index. index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00); code = windows_scancode_table[index]; *rawcode = scanCode; diff --git a/src/video/winrt/SDL_winrtmessagebox.cpp b/src/video/winrt/SDL_winrtmessagebox.cpp index 648ce967bc..0e5abc84d5 100644 --- a/src/video/winrt/SDL_winrtmessagebox.cpp +++ b/src/video/winrt/SDL_winrtmessagebox.cpp @@ -67,7 +67,7 @@ extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, in maxbuttons, platform, messageboxdata->numbuttons); } - /* Build a MessageDialog object and its buttons */ + // Build a MessageDialog object and its buttons MessageDialog ^ dialog = ref new MessageDialog(WINRT_UTF8ToPlatformString(messageboxdata->message)); dialog->Title = WINRT_UTF8ToPlatformString(messageboxdata->title); for (int i = 0; i < messageboxdata->numbuttons; ++i) { @@ -88,14 +88,14 @@ extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, in } } - /* Display the MessageDialog, then wait for it to be closed */ - /* TODO, WinRT: Find a way to redraw MessageDialog instances if a GPU device-reset occurs during the following event-loop */ + // Display the MessageDialog, then wait for it to be closed + // TODO, WinRT: Find a way to redraw MessageDialog instances if a GPU device-reset occurs during the following event-loop auto operation = dialog->ShowAsync(); while (operation->Status == Windows::Foundation::AsyncStatus::Started) { WINRT_PumpEvents(_this); } - /* Retrieve results from the MessageDialog and process them accordingly */ + // Retrieve results from the MessageDialog and process them accordingly if (operation->Status != Windows::Foundation::AsyncStatus::Completed) { return SDL_SetError("An unknown error occurred in displaying the WinRT MessageDialog"); } @@ -105,7 +105,7 @@ extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, in *buttonID = messageboxdata->buttons[clicked_index].buttonID; } return 0; -#endif /* if SDL_WINAPI_FAMILY_PHONE / else */ +#endif // if SDL_WINAPI_FAMILY_PHONE / else } -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmessagebox.h b/src/video/winrt/SDL_winrtmessagebox.h index 535780fd81..c53667d1e4 100644 --- a/src/video/winrt/SDL_winrtmessagebox.h +++ b/src/video/winrt/SDL_winrtmessagebox.h @@ -24,4 +24,4 @@ extern int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmouse.cpp b/src/video/winrt/SDL_winrtmouse.cpp index 236bb59532..09b3ef444e 100644 --- a/src/video/winrt/SDL_winrtmouse.cpp +++ b/src/video/winrt/SDL_winrtmouse.cpp @@ -252,4 +252,4 @@ void WINRT_QuitMouse(SDL_VideoDevice *_this) { } -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmouse_c.h b/src/video/winrt/SDL_winrtmouse_c.h index 61deedf317..afa32dee94 100644 --- a/src/video/winrt/SDL_winrtmouse_c.h +++ b/src/video/winrt/SDL_winrtmouse_c.h @@ -35,4 +35,4 @@ extern SDL_bool WINRT_UsingRelativeMouseMode; } #endif -#endif /* SDL_winrtmouse_h_ */ +#endif // SDL_winrtmouse_h_ diff --git a/src/video/winrt/SDL_winrtopengles.cpp b/src/video/winrt/SDL_winrtopengles.cpp index ee1de1ee85..1a6b7dca71 100644 --- a/src/video/winrt/SDL_winrtopengles.cpp +++ b/src/video/winrt/SDL_winrtopengles.cpp @@ -22,7 +22,7 @@ #if defined(SDL_VIDEO_DRIVER_WINRT) && defined(SDL_VIDEO_OPENGL_EGL) -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support #include "SDL_winrtvideo_cpp.h" extern "C" { @@ -30,11 +30,11 @@ extern "C" { #include "../SDL_egl_c.h" } -/* Windows includes */ +// Windows includes #include using namespace Windows::UI::Core; -/* ANGLE/WinRT constants */ +// 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 @@ -60,7 +60,7 @@ WINRT_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) return -1; } - /* Load ANGLE/WinRT-specific functions */ + // Load ANGLE/WinRT-specific functions 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 @@ -68,8 +68,8 @@ WINRT_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) * as appropriate to this version of ANGLE. */ - /* Create an ANGLE/WinRT EGL-window */ - /* TODO, WinRT: check for XAML usage before accessing the CoreWindow, as not doing so could lead to a crash */ + // Create an ANGLE/WinRT EGL-window + // TODO, WinRT: check for XAML usage before accessing the CoreWindow, as not doing so could lead to a crash CoreWindow ^ native_win = CoreWindow::GetForCurrentThread(); Microsoft::WRL::ComPtr cpp_win = reinterpret_cast(native_win); HRESULT result = CreateWinrtEglWindow(cpp_win, ANGLE_D3D_FEATURE_LEVEL_ANY, &(video_data->winrtEglWindow)); @@ -188,13 +188,13 @@ WINRT_GLES_UnloadLibrary(SDL_VideoDevice *_this) { SDL_VideoData *video_data = _this->internal; - /* Release SDL's own COM reference to the ANGLE/WinRT IWinrtEglWindow */ + // Release SDL's own COM reference to the ANGLE/WinRT IWinrtEglWindow if (video_data->winrtEglWindow) { video_data->winrtEglWindow->Release(); video_data->winrtEglWindow = nullptr; } - /* Perform the bulk of the unloading */ + // Perform the bulk of the unloading SDL_EGL_UnloadLibrary(_this); } @@ -204,4 +204,4 @@ SDL_EGL_CreateContext_impl(WINRT) SDL_EGL_MakeCurrent_impl(WINRT) } -#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/winrt/SDL_winrtopengles.h b/src/video/winrt/SDL_winrtopengles.h index 0b00f176d1..d7336dd328 100644 --- a/src/video/winrt/SDL_winrtopengles.h +++ b/src/video/winrt/SDL_winrtopengles.h @@ -28,7 +28,7 @@ #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" -/* OpenGLES functions */ +// OpenGLES functions #define WINRT_GLES_GetAttribute SDL_EGL_GetAttribute #define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval @@ -55,13 +55,13 @@ typedef EGLDisplay(EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindo 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 */ +#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 *); -#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL -#endif /* SDL_winrtopengles_h_ */ +#endif // SDL_winrtopengles_h_ diff --git a/src/video/winrt/SDL_winrtpointerinput.cpp b/src/video/winrt/SDL_winrtpointerinput.cpp index 41dc30f307..1138bae766 100644 --- a/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/src/video/winrt/SDL_winrtpointerinput.cpp @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_WINRT -/* SDL includes */ +// SDL includes #include "SDL_winrtevents_c.h" #include "SDL_winrtmouse_c.h" #include "SDL_winrtvideo_cpp.h" @@ -34,7 +34,7 @@ extern "C" { #include "../../events/SDL_touch_c.h" } -/* File-specific globals: */ +// File-specific globals: static SDL_TouchID WINRT_TouchID = 1; void WINRT_InitTouch(SDL_VideoDevice *_this) @@ -246,7 +246,7 @@ void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::Poin Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); if (!WINRT_IsTouchEvent(pointerPoint)) { - /* For some odd reason Moved events are used for multiple mouse buttons */ + // For some odd reason Moved events are used for multiple mouse buttons Uint8 button, pressed; if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) { SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, pressed, button); diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 7ede65be10..19b5dc1d82 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -28,11 +28,11 @@ was based off of SDL's "dummy" video driver. */ -/* Standard C++11 includes */ +// Standard C++11 includes #include #include -/* Windows includes */ +// Windows includes #include #include #include @@ -44,11 +44,11 @@ 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 */ +// [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 } }; -/* SDL includes */ +// SDL includes extern "C" { #include "../../core/windows/SDL_windows.h" #include "../../events/SDL_events_c.h" @@ -66,26 +66,26 @@ extern "C" { #include "SDL_winrtmouse_c.h" #include "SDL_winrtvideo_cpp.h" -/* Initialization/Query functions */ +// Initialization/Query functions static int WINRT_VideoInit(SDL_VideoDevice *_this); static int WINRT_InitModes(SDL_VideoDevice *_this); static int WINRT_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void WINRT_VideoQuit(SDL_VideoDevice *_this); -/* Window functions */ +// Window functions static int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); static void WINRT_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); static int WINRT_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); static void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* Misc functions */ +// Misc functions static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this); extern int WINRT_SuspendScreenSaver(SDL_VideoDevice *_this); -/* SDL-internal globals: */ +// SDL-internal globals: SDL_Window *WINRT_GlobalSDLWindow = NULL; -/* WinRT driver bootstrap functions */ +// WinRT driver bootstrap functions static void WINRT_DeleteDevice(SDL_VideoDevice *device) { @@ -105,7 +105,7 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) SDL_VideoDevice *device; SDL_VideoData *data; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; @@ -118,7 +118,7 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) } device->internal = data; - /* Set the function pointers */ + // Set the function pointers device->VideoInit = WINRT_VideoInit; device->VideoQuit = WINRT_VideoQuit; device->CreateSDLWindow = WINRT_CreateWindow; @@ -235,11 +235,11 @@ int WINRT_VideoInit(SDL_VideoDevice *_this) WINRT_InitTouch(_this); WINRT_InitGameBar(_this); if (internal) { - /* Initialize screensaver-disabling support */ + // Initialize screensaver-disabling support internal->displayRequest = WINRT_CreateDisplayRequest(_this); } - /* Assume we have a mouse and keyboard */ + // Assume we have a mouse and keyboard SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); @@ -266,7 +266,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg SDL_VideoDisplay display; UINT numModes; DXGI_MODE_DESC *dxgiModes = NULL; - int functionResult = -1; /* -1 for failure, 0 for success */ + int functionResult = -1; // -1 for failure, 0 for success DXGI_MODE_DESC modeToMatch, closestMatch; SDL_zero(display); @@ -341,7 +341,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg goto done; } - functionResult = 0; /* 0 for Success! */ + functionResult = 0; // 0 for Success! done: if (dxgiModes) { SDL_free(dxgiModes); @@ -588,7 +588,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie 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(); } @@ -610,16 +610,16 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie } SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WINRT_WINDOW_POINTER, reinterpret_cast(data->coreWindow.Get())); - /* Make note of the requested window flags, before they start getting changed. */ + // Make note of the requested window flags, before they start getting changed. const Uint32 requestedFlags = window->flags; #ifdef SDL_VIDEO_OPENGL_EGL - /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */ + // Setup the EGL surface, but only if OpenGL ES 2 was requested. if (!(window->flags & SDL_WINDOW_OPENGL)) { - /* OpenGL ES 2 wasn't requested. Don't set up an EGL surface. */ + // OpenGL ES 2 wasn't requested. Don't set up an EGL surface. data->egl_surface = EGL_NO_SURFACE; } else { - /* OpenGL ES 2 was requested. Set up an EGL surface. */ + // OpenGL ES 2 was requested. Set up an EGL surface. SDL_VideoData *video_data = _this->internal; /* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly, @@ -628,11 +628,11 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie * be passed into eglCreateWindowSurface. */ if (SDL_EGL_ChooseConfig(_this) != 0) { - /* SDL_EGL_ChooseConfig failed, SDL_GetError() should have info */ + // SDL_EGL_ChooseConfig failed, SDL_GetError() should have info 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: */ @@ -663,7 +663,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie } #endif - /* Determine as many flags dynamically, as possible. */ + // Determine as many flags dynamically, as possible. window->flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE; @@ -675,7 +675,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie #endif if (WINRT_XAMLWasEnabled) { - /* TODO, WinRT: set SDL_Window size, maybe position too, from XAML control */ + // TODO, WinRT: set SDL_Window size, maybe position too, from XAML control window->x = 0; window->y = 0; window->flags &= ~SDL_WINDOW_HIDDEN; @@ -690,7 +690,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie window->x = (int)SDL_lroundf(data->coreWindow->Bounds.Left); window->y = (int)SDL_lroundf(data->coreWindow->Bounds.Top); #if NTDDI_VERSION < NTDDI_WIN10 - /* On WinRT 8.x / pre-Win10, just use the size we were given. */ + // On WinRT 8.x / pre-Win10, just use the size we were given. window->w = (int)SDL_floorf(data->coreWindow->Bounds.Width); window->h = (int)SDL_floorf(data->coreWindow->Bounds.Height); #else @@ -713,10 +713,10 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie 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 */ + // Try detecting if the window is active bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get()); if (isWindowActive) { SDL_SetKeyboardFocus(window); @@ -728,7 +728,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie */ WINRT_GlobalSDLWindow = window; - /* All done! */ + // All done! return 0; } @@ -782,7 +782,7 @@ void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this) { - /* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */ + // Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests const wchar_t *wClassName = L"Windows.System.Display.DisplayRequest"; HSTRING hClassName; IActivationFactory *pActivationFactory = NULL; @@ -838,4 +838,4 @@ int WINRT_SuspendScreenSaver(SDL_VideoDevice *_this) return 0; } -#endif /* SDL_VIDEO_DRIVER_WINRT */ +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtvideo_cpp.h b/src/video/winrt/SDL_winrtvideo_cpp.h index 00cfa3ebeb..18fb58d822 100644 --- a/src/video/winrt/SDL_winrtvideo_cpp.h +++ b/src/video/winrt/SDL_winrtvideo_cpp.h @@ -19,13 +19,13 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* Windows includes: */ +// Windows includes: #include #ifdef __cplusplus_winrt #include #endif -/* SDL includes: */ +// SDL includes: #if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes \ useful for SDL in Win[Phone] 8.1 and up. \ @@ -38,7 +38,7 @@ extern "C" { #include "../SDL_egl_c.h" } -/* Private display data */ +// Private display data struct SDL_VideoData { /* An object created by ANGLE/WinRT (OpenGL ES 2 for WinRT) that gets @@ -68,9 +68,9 @@ extern SDL_Window *WINRT_GlobalSDLWindow; SDL_Window flags that can be updated should be specified in 'mask'. */ extern void WINRT_UpdateWindowFlags(SDL_Window *window, SDL_WindowFlags mask); -extern "C" SDL_WindowFlags WINRT_DetectWindowFlags(SDL_Window *window); /* detects flags w/o applying them */ +extern "C" SDL_WindowFlags WINRT_DetectWindowFlags(SDL_Window *window); // detects flags w/o applying them -/* Display mode internals */ +// Display mode internals // typedef struct //{ // Windows::Graphics::Display::DisplayOrientations currentOrientation; @@ -78,18 +78,18 @@ extern "C" SDL_WindowFlags WINRT_DetectWindowFlags(SDL_Window *window); /* detec #ifdef __cplusplus_winrt -/* A convenience macro to get a WinRT display property */ +// A convenience macro to get a WinRT display property #if NTDDI_VERSION > NTDDI_WIN8 #define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->NAME) #else #define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayProperties::NAME) #endif -/* Converts DIPS to/from physical pixels */ +// 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)) -/* Internal window data */ +// Internal window data struct SDL_WindowData { SDL_Window *sdlWindow; diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 66316ba5c3..06511200be 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_X11 -#include /* For INT_MAX */ +#include // For INT_MAX #include "SDL_x11video.h" #include "SDL_x11clipboard.h" @@ -37,7 +37,7 @@ static const char *text_mime_types[] = { "STRING" }; -/* Get any application owned window handle for clipboard association */ +// Get any application owned window handle for clipboard association static Window GetWindow(SDL_VideoDevice *_this) { SDL_VideoData *data = _this->internal; @@ -83,7 +83,7 @@ static int SetSelectionData(SDL_VideoDevice *_this, Atom selection, SDL_Clipboar clipboard_owner = X11_XGetSelectionOwner(display, selection) == window; - /* If we are cancelling our own data we need to clean it up */ + // If we are cancelling our own data we need to clean it up if (clipboard_owner && clipboard->sequence == 0) { SDL_free(clipboard->userdata); } @@ -141,7 +141,7 @@ static SDL_bool WaitForSelection(SDL_VideoDevice *_this, Atom selection_type, SD while (*flag) { SDL_PumpEvents(); waitElapsed = SDL_GetTicks() - waitStart; - /* Wait one second for a selection response. */ + // Wait one second for a selection response. if (waitElapsed > 1000) { *flag = SDL_FALSE; SDL_SetError("Selection timeout"); @@ -178,11 +178,11 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, *length = 0; - /* Get the window that holds the selection */ + // Get the window that holds the selection window = GetWindow(_this); owner = X11_XGetSelectionOwner(display, selection_type); if (owner == None) { - /* This requires a fallback to ancient X10 cut-buffers. We will just skip those for now */ + // This requires a fallback to ancient X10 cut-buffers. We will just skip those for now data = NULL; } else if (owner == window) { owner = DefaultRootWindow(display); @@ -197,7 +197,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, data = CloneDataBuffer(clipboard_data, *length); } } else { - /* Request that the selection owner copy the data to our window */ + // Request that the selection owner copy the data to our window owner = window; selection = X11_XInternAtom(display, "SDL_SELECTION", False); X11_XConvertSelection(display, selection_type, XA_MIME, selection, owner, @@ -337,4 +337,4 @@ void X11_QuitClipboard(SDL_VideoDevice *_this) } } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11clipboard.h b/src/video/x11/SDL_x11clipboard.h index 2d9c0f1518..1ca4d16033 100644 --- a/src/video/x11/SDL_x11clipboard.h +++ b/src/video/x11/SDL_x11clipboard.h @@ -42,4 +42,4 @@ extern char *X11_GetPrimarySelectionText(SDL_VideoDevice *_this); extern SDL_bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this); extern void X11_QuitClipboard(SDL_VideoDevice *_this); -#endif /* SDL_x11clipboard_h_ */ +#endif // SDL_x11clipboard_h_ diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index aaf77d28a6..d6152f91fc 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -88,19 +88,19 @@ static void *X11_GetSym(const char *fnname, int *pHasModule) #endif if (!fn) { - *pHasModule = 0; /* kill this module. */ + *pHasModule = 0; // kill this module. } return fn; } -#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ +#endif // SDL_VIDEO_DRIVER_X11_DYNAMIC -/* Define all the function pointers and wrappers... */ +// Define all the function pointers and wrappers... #define SDL_X11_SYM(rc, fn, params, args, ret) SDL_DYNX11FN_##fn X11_##fn = NULL; #include "SDL_x11sym.h" -/* Annoying varargs entry point... */ +// Annoying varargs entry point... #ifdef X_HAVE_UTF8_STRING SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL; SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL; @@ -114,14 +114,14 @@ static int x11_load_refcount = 0; void SDL_X11_UnloadSymbols(void) { - /* Don't actually unload if more than one module is using the libs... */ + // Don't actually unload if more than one module is using the libs... if (x11_load_refcount > 0) { if (--x11_load_refcount == 0) { #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC int i; #endif - /* set all the function pointers to NULL. */ + // 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; #include "SDL_x11sym.h" @@ -143,12 +143,12 @@ void SDL_X11_UnloadSymbols(void) } } -/* returns non-zero if all needed symbols were loaded. */ +// returns non-zero if all needed symbols were loaded. 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... */ + // deal with multiple modules (dga, x11, etc) needing these symbols... if (x11_load_refcount++ == 0) { #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC int i; @@ -159,7 +159,7 @@ int SDL_X11_LoadSymbols(void) } } -#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ +#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; @@ -174,17 +174,17 @@ int SDL_X11_LoadSymbols(void) #endif if (SDL_X11_HAVE_BASEXLIB) { - /* all required symbols loaded. */ + // all required symbols loaded. SDL_ClearError(); } else { - /* in case something got loaded... */ + // in case something got loaded... SDL_X11_UnloadSymbols(); 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_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" @@ -198,4 +198,4 @@ int SDL_X11_LoadSymbols(void) return rc; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index b045d12cbc..2b95c40dbc 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -32,7 +32,7 @@ #include #endif -/* Apparently some X11 systems can't include this multiple times... */ +// Apparently some X11 systems can't include this multiple times... #ifndef SDL_INCLUDED_XLIBINT_H #define SDL_INCLUDED_XLIBINT_H 1 #include @@ -73,7 +73,7 @@ extern "C" { #endif -/* evil function signatures... */ +// 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 *); @@ -81,13 +81,13 @@ 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... */ +// Declare all the function pointers and wrappers... #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... */ +// Annoying varargs entry point... #ifdef X_HAVE_UTF8_STRING typedef XIC (*SDL_DYNX11FN_XCreateIC)(XIM, ...); typedef char *(*SDL_DYNX11FN_XGetICValues)(XIC, ...); @@ -103,4 +103,4 @@ extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; } #endif -#endif /* !defined SDL_x11dyn_h_ */ +#endif // !defined SDL_x11dyn_h_ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 4f6aab611e..182db6184a 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -26,7 +26,7 @@ #include #include #include -#include /* For INT_MAX */ +#include // For INT_MAX #include "SDL_x11video.h" #include "SDL_x11pen.h" @@ -126,13 +126,13 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) int i; for (i = 0; i < list_count && request == None; i++) { name = X11_XGetAtomName(disp, list[i]); - /* Preferred MIME targets */ + // Preferred MIME targets if ((SDL_strcmp("text/uri-list", name) == 0) || (SDL_strcmp("text/plain;charset=utf-8", name) == 0) || (SDL_strcmp("UTF8_STRING", name) == 0)) { request = list[i]; } - /* Fallback MIME targets */ + // Fallback MIME targets if ((SDL_strcmp("text/plain", name) == 0) || (SDL_strcmp("TEXT", name) == 0)) { if (request == None) { @@ -199,7 +199,7 @@ static SDL_bool X11_IsWheelEvent(Display *display, int button, int *xticks, int However, the defacto standard is that the vertical wheel is X buttons 4 (up) and 5 (down) and a horizontal wheel is 6 (left) and 7 (right). */ - /* Xlib defines "Button1" through 5, so we just use literals here. */ + // Xlib defines "Button1" through 5, so we just use literals here. switch (button) { case 4: *yticks = 1; @@ -219,7 +219,7 @@ static SDL_bool X11_IsWheelEvent(Display *display, int button, int *xticks, int return SDL_FALSE; } -/* An X11 event hook */ +// An X11 event hook static SDL_X11EventHook g_X11EventHook = NULL; static void *g_X11EventHookData = NULL; @@ -234,7 +234,7 @@ static void X11_HandleGenericEvent(SDL_VideoDevice *_this, XEvent *xev) { SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; - /* event is a union, so cookie == &event, but this is type safe. */ + // event is a union, so cookie == &event, but this is type safe. XGenericEventCookie *cookie = &xev->xcookie; if (X11_XGetEventData(videodata->display, cookie)) { if (!g_X11EventHook || g_X11EventHook(g_X11EventHookData, xev)) { @@ -243,7 +243,7 @@ static void X11_HandleGenericEvent(SDL_VideoDevice *_this, XEvent *xev) X11_XFreeEventData(videodata->display, cookie); } } -#endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ +#endif // SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS static unsigned X11_GetNumLockModifierMask(SDL_VideoDevice *_this) { @@ -308,7 +308,7 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this) X11_XQueryKeymap(display, keys); - /* Sync up the keyboard modifier state */ + // Sync up the keyboard modifier state if (X11_XQueryPointer(display, DefaultRootWindow(display), &junk_window, &junk_window, &x, &y, &x, &y, &mask)) { SDL_ToggleModState(SDL_KMOD_CAPS, (mask & LockMask) ? SDL_TRUE : SDL_FALSE); SDL_ToggleModState(SDL_KMOD_NUM, (mask & X11_GetNumLockModifierMask(_this)) ? SDL_TRUE : SDL_FALSE); @@ -322,7 +322,7 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this) SDL_bool sdlKeyPressed = keyboardState[scancode] == SDL_PRESSED; if (x11KeyPressed && !sdlKeyPressed) { - /* Only update modifier state for keys that are pressed in another application */ + // Only update modifier state for keys that are pressed in another application switch (SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, SDL_FALSE)) { case SDLK_LCTRL: case SDLK_RCTRL: @@ -409,7 +409,7 @@ static void DispatchWindowMove(SDL_VideoDevice *_this, const SDL_WindowData *dat Display *display = videodata->display; XEvent evt; - /* !!! FIXME: we need to regrab this if necessary when the drag is done. */ + // !!! FIXME: we need to regrab this if necessary when the drag is done. X11_XUngrabPointer(display, 0L); X11_XFlush(display); @@ -444,7 +444,7 @@ static void InitiateWindowResize(SDL_VideoDevice *_this, const SDL_WindowData *d return; } - /* !!! FIXME: we need to regrab this if necessary when the drag is done. */ + // !!! FIXME: we need to regrab this if necessary when the drag is done. X11_XUngrabPointer(display, 0L); X11_XFlush(display); @@ -545,7 +545,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven SDL_assert(xevent->xany.window == videodata->clipboard_window); switch (xevent->type) { - /* Copy the selection from our own CUTBUFFER to the requested property */ + // Copy the selection from our own CUTBUFFER to the requested property case SelectionRequest: { const XSelectionRequestEvent *req = &xevent->xselectionrequest; @@ -576,7 +576,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven sevent.xany.type = SelectionNotify; sevent.xselection.selection = req->selection; sevent.xselection.target = None; - sevent.xselection.property = None; /* tell them no by default */ + sevent.xselection.property = None; // tell them no by default sevent.xselection.requestor = req->requestor; sevent.xselection.time = req->time; @@ -607,8 +607,8 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven continue; } - /* FIXME: We don't support the X11 INCR protocol for large clipboards. Do we want that? - Yes, yes we do. */ - /* This is a safe cast, XChangeProperty() doesn't take a const value, but it doesn't modify the data */ + // FIXME: We don't support the X11 INCR protocol for large clipboards. Do we want that? - Yes, yes we do. + // This is a safe cast, XChangeProperty() doesn't take a const value, but it doesn't modify the data seln_data = (unsigned char *)clipboard->callback(clipboard->userdata, mime_type, &seln_length); if (seln_data) { X11_XChangeProperty(display, req->requestor, req->property, @@ -636,7 +636,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven case SelectionClear: { - /* !!! FIXME: cache atoms */ + // !!! FIXME: cache atoms Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); SDLX11_ClipboardData *clipboard = NULL; @@ -774,7 +774,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ keycode, keycode - min_keycode, keysym, X11_XKeysymToString(keysym)); } -#endif /* DEBUG SCANCODES */ +#endif // DEBUG SCANCODES text[0] = '\0'; @@ -787,13 +787,13 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ KeyCode orig_keycode = xevent->xkey.keycode; #endif - /* filter events catches XIM events and sends them to the correct handler */ + // filter events catches XIM events and sends them to the correct handler if (X11_XFilterEvent(xevent, None)) { #ifdef DEBUG_XEVENTS SDL_Log("Filtered event type = %d display = %p window = 0x%lx\n", xevent->type, xevent->xany.display, xevent->xany.window); #endif - /* Make sure dead key press/release events are sent */ + // Make sure dead key press/release events are sent /* But only if we're using one of the DBus IMEs, otherwise some XIM IMEs will generate duplicate events */ #if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX) @@ -828,7 +828,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ 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 */ + // 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(0, keyboardID, keycode, videodata->key_layout[keycode], SDL_PRESSED); } @@ -838,7 +838,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ } } else { if (X11_KeyRepeat(display, xevent)) { - /* We're about to get a repeated key down, ignore the key up */ + // We're about to get a repeated key down, ignore the key up return; } SDL_SendKeyboardKey(0, keyboardID, keycode, videodata->key_layout[keycode], SDL_RELEASED); @@ -866,7 +866,7 @@ void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, S if (button == Button1) { if (X11_TriggerHitTestAction(_this, windowdata, x, y)) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; /* don't pass this event on to app. */ + return; // 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, ... @@ -892,14 +892,14 @@ void X11_HandleButtonRelease(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_Window *window = windowdata->window; const SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; Display *display = videodata->display; - /* The X server sends a Release event for each Press for wheels. Ignore them. */ + // The X server sends a Release event for each Press for wheels. Ignore them. int xticks = 0, yticks = 0; #ifdef DEBUG_XEVENTS SDL_Log("window 0x%lx: ButtonRelease (X11 button = %d)\n", windowdata->xwindow, button); #endif if (!X11_IsWheelEvent(display, button, &xticks, &yticks)) { if (button > 7) { - /* see explanation at case ButtonPress */ + // see explanation at case ButtonPress button -= (8 - SDL_BUTTON_X1); } SDL_SendMouseButton(0, window, mouseID, SDL_RELEASED, button); @@ -916,7 +916,7 @@ void X11_GetBorderValues(SDL_WindowData *data) unsigned long nitems, bytes_after; unsigned char *property; - /* Some compositors will send extents even when the border hint is turned off. Ignore them in this case. */ + // Some compositors will send extents even when the border hint is turned off. Ignore them in this case. if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) { 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) { @@ -947,8 +947,8 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_assert(videodata != NULL); display = videodata->display; - /* filter events catches XIM events and sends them to the correct handler */ - /* Key press/release events are filtered in X11_HandleKeyEvent() */ + // filter events catches XIM events and sends them to the correct handler + // Key press/release events are filtered in X11_HandleKeyEvent() if (xevent->type != KeyPress && xevent->type != KeyRelease) { if (X11_XFilterEvent(xevent, None)) { #ifdef DEBUG_XEVENTS @@ -966,7 +966,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #endif - /* Calling the event hook for generic events happens in X11_HandleGenericEvent(), where the event data is available */ + // Calling the event hook for generic events happens in X11_HandleGenericEvent(), where the event data is available if (g_X11EventHook) { if (!g_X11EventHook(g_X11EventHookData, xevent)) { return; @@ -989,7 +989,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) xevent->type == X11_GetXFixesSelectionNotifyEvent()) { XFixesSelectionNotifyEvent *ev = (XFixesSelectionNotifyEvent *)xevent; - /* !!! FIXME: cache atoms */ + // !!! FIXME: cache atoms Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); #ifdef DEBUG_XEVENTS @@ -1003,7 +1003,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) return; } } -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES if ((videodata->clipboard_window != None) && (videodata->clipboard_window == xevent->xany.window)) { @@ -1020,7 +1020,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) data = X11_FindWindow(_this, xevent->xany.window); if (!data) { - /* The window for KeymapNotify, etc events is 0 */ + // The window for KeymapNotify, etc events is 0 if (xevent->type == KeymapNotify) { #ifdef DEBUG_XEVENTS SDL_Log("window 0x%lx: KeymapNotify!\n", xevent->xany.window); @@ -1031,7 +1031,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) XkbStateRec state; if (X11_XkbGetState(videodata->display, XkbUseCoreKbd, &state) == Success) { if (state.group != videodata->xkb_group) { - /* Only rebuild the keymap if the layout has changed. */ + // Only rebuild the keymap if the layout has changed. X11_UpdateKeymap(_this, SDL_TRUE); } } @@ -1040,7 +1040,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) X11_ReconcileKeyboardState(_this); } } else if (xevent->type == MappingNotify) { - /* Has the keyboard layout changed? */ + // Has the keyboard layout changed? const int request = xevent->xmapping.request; #ifdef DEBUG_XEVENTS @@ -1084,7 +1084,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) switch (xevent->type) { - /* Gaining mouse coverage? */ + // Gaining mouse coverage? case EnterNotify: { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1107,7 +1107,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES { - /* Only create the barriers if we have input focus */ + // Only create the barriers if we have input focus SDL_WindowData *windowdata = data->window->internal; 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); @@ -1119,12 +1119,12 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); } - /* We ungrab in LeaveNotify, so we may need to grab again here */ + // We ungrab in LeaveNotify, so we may need to grab again here SDL_UpdateWindowGrab(data->window); X11_ProcessHitTest(_this, data, mouse->last_x, mouse->last_y, SDL_TRUE); } break; - /* Losing mouse coverage? */ + // Losing mouse coverage? case LeaveNotify: { #ifdef DEBUG_XEVENTS @@ -1157,11 +1157,11 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } } break; - /* Gaining input focus? */ + // Gaining input focus? case FocusIn: { if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { - /* Someone is handling a global hotkey, ignore it */ + // Someone is handling a global hotkey, ignore it #ifdef DEBUG_XEVENTS SDL_Log("window 0x%lx: FocusIn (NotifyGrab/NotifyUngrab, ignoring)\n", xevent->xany.window); #endif @@ -1188,11 +1188,11 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) data->last_focus_event_time = SDL_GetTicks(); } break; - /* Losing input focus? */ + // Losing input focus? case FocusOut: { if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { - /* Someone is handling a global hotkey, ignore it */ + // Someone is handling a global hotkey, ignore it #ifdef DEBUG_XEVENTS SDL_Log("window 0x%lx: FocusOut (NotifyGrab/NotifyUngrab, ignoring)\n", xevent->xany.window); #endif @@ -1220,15 +1220,15 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - /* Disable confinement if it is activated. */ + // 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 */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES } break; - /* Have we been iconified? */ + // Have we been iconified? case UnmapNotify: { XEvent ev; @@ -1244,14 +1244,14 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - /* Disable confinement if the window gets hidden. */ + // 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 */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES } break; - /* Have we been restored? */ + // Have we been restored? case MapNotify: { #ifdef DEBUG_XEVENTS @@ -1260,14 +1260,14 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) X11_DispatchMapNotify(data); #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - /* Enable confinement if it was activated. */ + // 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 */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES } break; - /* Have we been resized or moved? */ + // Have we been resized or moved? case ConfigureNotify: { #ifdef DEBUG_XEVENTS @@ -1275,13 +1275,13 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) 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. */ + // 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 coordinates back to relative to root */ + // Translate these coordinates 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), @@ -1303,12 +1303,12 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #ifdef SDL_USE_IME if (SDL_TextInputActive(data->window)) { - /* Update IME candidate list position */ + // Update IME candidate list position SDL_IME_UpdateTextInputArea(NULL); } #endif for (w = data->window->first_child; w; w = w->next_sibling) { - /* Don't update hidden child windows, their relative position doesn't change */ + // Don't update hidden child windows, their relative position doesn't change if (!(w->flags & SDL_WINDOW_HIDDEN)) { X11_UpdateWindowPosition(w, SDL_TRUE); } @@ -1328,7 +1328,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) data->last_xconfigure = xevent->xconfigure; } break; - /* Have we been requested to quit (or another client message?) */ + // Have we been requested to quit (or another client message?) case ClientMessage: { @@ -1346,14 +1346,14 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #endif if (use_list) { - /* fetch conversion targets */ + // fetch conversion targets SDL_x11Prop p; X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); - /* pick one */ + // pick one data->xdnd_req = X11_PickTarget(display, (Atom *)p.data, p.count); X11_XFree(p.data); } else { - /* pick from list of three */ + // 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) { @@ -1366,19 +1366,19 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_Log("Action requested by user is : %s\n", X11_XGetAtomName(display, act)); #endif { - /* Drag and Drop position */ + // Drag and Drop position int root_x, root_y, window_x, window_y; Window ChildReturn; root_x = xevent->xclient.data.l[2] >> 16; root_y = xevent->xclient.data.l[2] & 0xffff; - /* Translate from root to current window position */ + // Translate from root to current window position X11_XTranslateCoordinates(display, DefaultRootWindow(display), data->xwindow, root_x, root_y, &window_x, &window_y, &ChildReturn); SDL_SendDropPosition(data->window, (float)window_x, (float)window_y); } - /* reply with status */ + // reply with status SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent->xclient.display; @@ -1387,15 +1387,15 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) 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[2] = 0; // specify an empty rectangle m.data.l[3] = 0; - m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ + 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! */ + // say again - not interested! SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent->xclient.display; @@ -1404,10 +1404,10 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) m.format = 32; m.data.l[0] = data->xwindow; m.data.l[1] = 0; - m.data.l[2] = None; /* fail! */ + m.data.l[2] = None; // fail! X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent *)&m); } else { - /* convert */ + // convert if (xdnd_version >= 1) { X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent->xclient.data.l[2]); } else { @@ -1439,7 +1439,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } } break; - /* Do we need to refresh ourselves? */ + // Do we need to refresh ourselves? case Expose: { #ifdef DEBUG_XEVENTS @@ -1581,7 +1581,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (status == Success) { X11_XFree(propdata); } -#endif /* DEBUG_XEVENTS */ +#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 @@ -1636,10 +1636,10 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_zero(data->requested_fullscreen_mode); - /* Need to restore or update any limits changed while the window was fullscreen. */ + // Need to restore or update any limits changed while the window was fullscreen. X11_SetWindowMinMax(data->window, !!(flags & SDL_WINDOW_MAXIMIZED)); - /* Toggle the borders if they were forced on while creating a borderless fullscreen window. */ + // Toggle the borders if they were forced on while creating a borderless fullscreen window. if (data->fullscreen_borders_forced_on) { data->toggle_borders = SDL_TRUE; data->fullscreen_borders_forced_on = SDL_FALSE; @@ -1679,7 +1679,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) data->pending_operation &= ~X11_PENDING_OP_MAXIMIZE; if ((changed & SDL_WINDOW_MINIMIZED)) { data->pending_operation &= ~X11_PENDING_OP_RESTORE; - /* If coming out of minimized, send a restore event before sending maximized. */ + // If coming out of minimized, send a restore event before sending maximized. SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); } SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); @@ -1691,7 +1691,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (!(flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { data->pending_operation &= ~X11_PENDING_OP_RESTORE; if (SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0)) { - /* Restore the last known floating state if leaving maximized mode */ + // Restore the last known floating state if leaving maximized mode if (!(flags & SDL_WINDOW_FULLSCREEN)) { data->pending_operation |= X11_PENDING_OP_MOVE | X11_PENDING_OP_RESIZE; data->expected.x = data->window->floating.x - data->border_left; @@ -1729,7 +1729,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) data->disable_size_position_events = SDL_FALSE; X11_GetBorderValues(data); if (data->border_top != 0 || data->border_left != 0 || data->border_right != 0 || data->border_bottom != 0) { - /* Adjust if the window size/position changed to accommodate the borders. */ + // Adjust if the window size/position changed to accommodate the borders. if (data->window->flags & SDL_WINDOW_MAXIMIZED) { data->pending_operation |= X11_PENDING_OP_RESIZE; data->expected.w = data->window->windowed.w; @@ -1759,7 +1759,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) xevent->xselection.requestor, xevent->xselection.target); #endif if (target == data->xdnd_req) { - /* read data */ + // read data SDL_x11Prop p; X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY); @@ -1787,7 +1787,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } X11_XFree(p.data); - /* send reply */ + // send reply SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = display; @@ -1878,14 +1878,14 @@ int X11_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) SDL_zero(xevent); - /* Flush and poll to grab any events already read and queued */ + // Flush and poll to grab any events already read and queued X11_XFlush(display); if (X11_PollEvent(display, &xevent)) { - /* Fall through */ + // Fall through } else if (timeoutNS == 0) { return 0; } else { - /* Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait */ + // Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait int err = SDL_IOReady(ConnectionNumber(display), SDL_IOR_READ | SDL_IOR_NO_RETRY, timeoutNS); if (err > 0) { if (!X11_PollEvent(display, &xevent)) { @@ -1894,10 +1894,10 @@ int X11_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) return 1; } } else if (err == 0) { - /* Timeout */ + // Timeout return 0; } else { - /* Error returned from poll()/select() */ + // Error returned from poll()/select() if (errno == EINTR) { /* If the wait was interrupted by a signal, we may have generated a @@ -1947,11 +1947,11 @@ void X11_PumpEvents(SDL_VideoDevice *_this) if (data->last_mode_change_deadline) { if (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. } } - /* Update activity every 30 seconds to prevent screensaver */ + // Update activity every 30 seconds to prevent screensaver if (_this->suspend_screensaver) { Uint64 now = SDL_GetTicks(); if (!data->screensaver_activity || now >= (data->screensaver_activity + 30000)) { @@ -1967,7 +1967,7 @@ void X11_PumpEvents(SDL_VideoDevice *_this) SDL_zero(xevent); - /* Keep processing pending events */ + // Keep processing pending events while (X11_PollEvent(data->display, &xevent)) { X11_DispatchEvent(_this, &xevent); } @@ -1983,10 +1983,10 @@ void X11_PumpEvents(SDL_VideoDevice *_this) SDL_DBus_PumpEvents(); #endif - /* FIXME: Only need to do this when there are pending focus changes */ + // FIXME: Only need to do this when there are pending focus changes X11_HandleFocusChanges(_this); - /* FIXME: Only need to do this when there are flashing windows */ + // FIXME: Only need to do this when there are flashing windows for (i = 0; i < data->numwindows; ++i) { if (data->windowlist[i] != NULL && data->windowlist[i]->flash_cancel_time && @@ -2007,7 +2007,7 @@ int X11_SuspendScreenSaver(SDL_VideoDevice *_this) SDL_VideoData *data = _this->internal; int dummy; int major_version, minor_version; -#endif /* SDL_VIDEO_DRIVER_X11_XSCRNSAVER */ +#endif // SDL_VIDEO_DRIVER_X11_XSCRNSAVER #ifdef SDL_USE_LIBDBUS if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { @@ -2021,7 +2021,7 @@ int X11_SuspendScreenSaver(SDL_VideoDevice *_this) #ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER if (SDL_X11_HAVE_XSS) { - /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ + // 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) || @@ -2037,4 +2037,4 @@ int X11_SuspendScreenSaver(SDL_VideoDevice *_this) return SDL_Unsupported(); } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11events.h b/src/video/x11/SDL_x11events.h index 4a95a558a3..7805f0a423 100644 --- a/src/video/x11/SDL_x11events.h +++ b/src/video/x11/SDL_x11events.h @@ -36,4 +36,4 @@ extern SDL_WindowData *X11_FindWindow(SDL_VideoDevice *_this, Window window); extern SDL_bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, SDL_bool force_new_result); extern SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y); -#endif /* SDL_x11events_h_ */ +#endif // SDL_x11events_h_ diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index e5181f346e..ad26988619 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -27,7 +27,7 @@ #ifndef NO_SHARED_MEMORY -/* Shared memory error handler routine */ +// Shared memory error handler routine static int shm_error; static int (*X_handler)(Display *, XErrorEvent *) = NULL; static int shm_errhandler(Display *d, XErrorEvent *e) @@ -41,11 +41,11 @@ static int shm_errhandler(Display *d, XErrorEvent *e) static SDL_bool have_mitshm(Display *dpy) { - /* Only use shared memory on local X servers */ + // Only use shared memory on local X servers return X11_XShmQueryExtension(dpy) ? SDL_X11_HAVE_SHM : SDL_FALSE; } -#endif /* !NO_SHARED_MEMORY */ +#endif // !NO_SHARED_MEMORY int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) @@ -58,17 +58,17 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ SDL_GetWindowSizeInPixels(window, &w, &h); - /* Free the old framebuffer surface */ + // Free the old framebuffer surface X11_DestroyWindowFramebuffer(_this, window); - /* Create the graphics context for drawing */ + // Create the graphics context for drawing gcv.graphics_exposures = False; data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); if (!data->gc) { return SDL_SetError("Couldn't create graphics context"); } - /* Find out the pixel format and depth */ + // Find out the pixel format and depth if (X11_GetVisualInfoFromVisual(display, data->visual, &vinfo) < 0) { return SDL_SetError("Couldn't get window visual information"); } @@ -78,10 +78,10 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ return SDL_SetError("Unknown window pixel format"); } - /* Calculate pitch */ + // Calculate pitch *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); - /* Create the actual image */ + // Create the actual image #ifndef NO_SHARED_MEMORY if (have_mitshm(display)) { XShmSegmentInfo *shminfo = &data->shminfo; @@ -116,7 +116,7 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ X11_XSync(display, False); shmdt(shminfo->shmaddr); } else { - /* Done! */ + // Done! data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst; data->use_mitshm = SDL_TRUE; *pixels = shminfo->shmaddr; @@ -124,7 +124,7 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ } } } -#endif /* not NO_SHARED_MEMORY */ +#endif // not NO_SHARED_MEMORY *pixels = SDL_malloc((size_t)h * (*pitch)); if (!*pixels) { @@ -162,7 +162,7 @@ int X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, cons h = rects[i].h; if (w <= 0 || h <= 0 || (x + w) <= 0 || (y + h) <= 0) { - /* Clipped? */ + // Clipped? continue; } if (x < 0) { @@ -184,7 +184,7 @@ int X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, cons x, y, x, y, w, h, False); } } else -#endif /* !NO_SHARED_MEMORY */ +#endif // !NO_SHARED_MEMORY { for (i = 0; i < numrects; ++i) { x = rects[i].x; @@ -193,7 +193,7 @@ int X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, cons h = rects[i].h; if (w <= 0 || h <= 0 || (x + w) <= 0 || (y + h) <= 0) { - /* Clipped? */ + // Clipped? continue; } if (x < 0) { @@ -227,7 +227,7 @@ void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) Display *display; if (!data) { - /* The window wasn't fully initialized */ + // The window wasn't fully initialized return; } @@ -243,7 +243,7 @@ void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) shmdt(data->shminfo.shmaddr); data->use_mitshm = SDL_FALSE; } -#endif /* !NO_SHARED_MEMORY */ +#endif // !NO_SHARED_MEMORY data->ximage = NULL; } @@ -253,4 +253,4 @@ void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) } } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11framebuffer.h b/src/video/x11/SDL_x11framebuffer.h index a96fb223c3..62bed1f24d 100644 --- a/src/video/x11/SDL_x11framebuffer.h +++ b/src/video/x11/SDL_x11framebuffer.h @@ -31,4 +31,4 @@ extern int X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo const SDL_Rect *rects, int numrects); extern void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_x11framebuffer_h_ */ +#endif // SDL_x11framebuffer_h_ diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index c1a0566890..333b37c5f7 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -69,7 +69,7 @@ static SDL_bool X11_ScancodeIsRemappable(SDL_Scancode scancode) } } -/* This function only correctly maps letters and numbers for keyboards in US QWERTY layout */ +// This function only correctly maps letters and numbers for keyboards in US QWERTY layout static SDL_Scancode X11_KeyCodeToSDLScancode(SDL_VideoDevice *_this, KeyCode keycode) { const KeySym keysym = X11_KeyCodeToSym(_this, keycode, 0, 0); @@ -116,7 +116,7 @@ KeySym X11_KeyCodeToSym(SDL_VideoDevice *_this, KeyCode keycode, unsigned char g } else #endif { - /* TODO: Handle groups and modifiers on the legacy path. */ + // TODO: Handle groups and modifiers on the legacy path. keysym = X11_XKeycodeToKeysym(data->display, keycode, 0); } @@ -156,12 +156,12 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) data->xkb = X11_XkbGetMap(data->display, XkbAllClientInfoMask, XkbUseCoreKbd); } - /* This will remove KeyRelease events for held keys */ + // This will remove KeyRelease events for held keys X11_XkbSetDetectableAutoRepeat(data->display, True, &xkb_repeat); } #endif - /* Open a connection to the X input manager */ + // 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 @@ -213,7 +213,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) } } #endif - /* Try to determine which scancodes are being used based on fingerprint */ + // Try to determine which scancodes are being used based on fingerprint best_distance = SDL_arraysize(fingerprint) + 1; best_index = -1; X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode); @@ -238,7 +238,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) } } if (best_index < 0 || best_distance > 2) { - /* This is likely to be SDL_SCANCODE_TABLE_XFREE86_2 with remapped keys, double check a rarely remapped value */ + // This is likely to be SDL_SCANCODE_TABLE_XFREE86_2 with remapped keys, double check a rarely remapped value int fingerprint_value = X11_XKeysymToKeycode(data->display, 0x1008FF5B /* XF86Documents */) - min_keycode; if (fingerprint_value == 235) { for (i = 0; i < SDL_arraysize(scancode_set); ++i) { @@ -257,7 +257,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) #ifdef DEBUG_KEYBOARD SDL_Log("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", best_index, min_keycode, max_keycode, table_size); #endif - /* This should never happen, but just in case... */ + // This should never happen, but just in case... if (table_size > (SDL_arraysize(data->key_layout) - min_keycode)) { table_size = (SDL_arraysize(data->key_layout) - min_keycode); } @@ -281,7 +281,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) continue; } if ((SDL_GetKeymapKeycode(NULL, scancode, SDL_KMOD_NONE) & SDLK_SCANCODE_MASK) && X11_ScancodeIsRemappable(scancode)) { - /* Not a character key and the scancode is safe to remap */ + // Not a character key and the scancode is safe to remap #ifdef DEBUG_KEYBOARD SDL_Log("Changing scancode, was %d (%s), now %d (%s)\n", data->key_layout[i], SDL_GetScancodeName(data->key_layout[i]), scancode, SDL_GetScancodeName(scancode)); #endif @@ -293,7 +293,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) SDL_Log("Keyboard layout unknown, please report the following to the SDL forums/mailing list (https://discourse.libsdl.org/):\n"); #endif - /* Determine key_layout - only works on US QWERTY layout */ + // Determine key_layout - only works on US QWERTY layout for (i = min_keycode; i <= max_keycode; ++i) { SDL_Scancode scancode = X11_KeyCodeToSDLScancode(_this, i); #ifdef DEBUG_SCANCODES @@ -365,7 +365,7 @@ void X11_UpdateKeymap(SDL_VideoDevice *_this, SDL_bool send_event) for (i = 0; i < SDL_arraysize(data->key_layout); i++) { SDL_Keycode keycode; - /* Make sure this is a valid scancode */ + // Make sure this is a valid scancode scancode = data->key_layout[i]; if (scancode == SDL_SCANCODE_UNKNOWN) { continue; @@ -373,7 +373,7 @@ void X11_UpdateKeymap(SDL_VideoDevice *_this, SDL_bool send_event) KeySym keysym = X11_KeyCodeToSym(_this, i, data->xkb_group, keymod_masks[m].xkb_mask); - /* Note: The default SDL scancode table sets this to right alt instead of AltGr/Mode, so handle it separately. */ + // Note: The default SDL scancode table sets this to right alt instead of AltGr/Mode, so handle it separately. if (keysym != XK_ISO_Level3_Shift) { keycode = SDL_KeySymToUcs4(keysym); } else { @@ -412,7 +412,7 @@ static void X11_ResetXIM(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; if (data && data->ic) { - /* Clear any partially entered dead keys */ + // Clear any partially entered dead keys char *contents = X11_Xutf8ResetIC(data->ic); if (contents) { X11_XFree(contents); @@ -508,4 +508,4 @@ SDL_bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) return videodata->steam_keyboard_open; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11keyboard.h b/src/video/x11/SDL_x11keyboard.h index 364e1bc678..0781890deb 100644 --- a/src/video/x11/SDL_x11keyboard.h +++ b/src/video/x11/SDL_x11keyboard.h @@ -35,4 +35,4 @@ extern void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); extern KeySym X11_KeyCodeToSym(SDL_VideoDevice *_this, KeyCode, unsigned char group, unsigned int mod_mask); -#endif /* SDL_x11keyboard_h_ */ +#endif // SDL_x11keyboard_h_ diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 8a97b30068..cef93c7b35 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -40,20 +40,20 @@ #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, */ - { 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, */ + { 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, }; #define SDL_MAKE_RGB(_r, _g, _b) (((Uint32)(_r) << 16) | \ @@ -62,20 +62,20 @@ static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_MAX] = { typedef struct SDL_MessageBoxButtonDataX11 { - int x, y; /* Text position */ - int length; /* Text length */ - int text_width; /* Text width */ + 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 */ + 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,28 +85,28 @@ typedef struct SDL_MessageBoxDataX11 Window window; #ifdef 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]; @@ -115,13 +115,13 @@ typedef struct SDL_MessageBoxDataX11 const SDL_MessageBoxData *messageboxdata; } SDL_MessageBoxDataX11; -/* Maximum helper for ints. */ +// Maximum helper for ints. static SDL_INLINE int IntMax(int a, int b) { return (a > b) ? a : b; } -/* Return width and height for a string. */ +// Return width and height for a string. static void GetTextWidthHeight(SDL_MessageBoxDataX11 *data, const char *str, int nbytes, int *pwidth, int *pheight) { #ifdef X_HAVE_UTF8_STRING @@ -143,7 +143,7 @@ static void GetTextWidthHeight(SDL_MessageBoxDataX11 *data, const char *str, int } } -/* Return index of button if position x,y is contained therein. */ +// Return index of button if position x,y is contained therein. static int GetHitButtonIndex(SDL_MessageBoxDataX11 *data, int x, int y) { int i; @@ -164,7 +164,7 @@ static int GetHitButtonIndex(SDL_MessageBoxDataX11 *data, int x, int y) return -1; } -/* Initialize SDL_MessageBoxData structure and Display, etc. */ +// Initialize SDL_MessageBoxData structure and Display, etc. static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData *messageboxdata, int *pbuttonid) { int i; @@ -215,7 +215,7 @@ static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxD colorhints = g_default_colors; } - /* Convert our SDL_MessageBoxColor r,g,b values to packed RGB format. */ + // 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); } @@ -228,13 +228,13 @@ 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. */ +// Calculate and initialize text and button locations. static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) { int i; @@ -244,7 +244,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) int button_width = MIN_BUTTON_WIDTH; const SDL_MessageBoxData *messageboxdata = data->messageboxdata; - /* Go over text and break linefeeds into separate lines. */ + // Go over text and break linefeeds into separate lines. if (messageboxdata && messageboxdata->message[0]) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); @@ -266,7 +266,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) GetTextWidthHeight(data, text, length, &plinedata->width, &height); - /* Text and widths are the largest we've ever seen. */ + // 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); @@ -277,17 +277,17 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) text += length + 1; - /* Break if there are no more linefeeds. */ + // Break if there are no more linefeeds. if (!lf) { break; } } - /* Bump up the text height slightly. */ + // Bump up the text height slightly. data->text_height += 2; } - /* Loop through all buttons and calculate the button widths and height. */ + // Loop through all buttons and calculate the button widths and height. for (i = 0; i < data->numbuttons; i++) { int height; @@ -302,18 +302,18 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) } if (data->numlines) { - /* x,y for this line of text. */ + // 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. */ + // Bump button y down to bottom of text. ybuttons = 3 * data->ytext / 2 + (data->numlines - 1) * data->text_height; - /* Bump the dialog box width and height up if needed. */ + // 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); } else { - /* Button y starts at height of button text. */ + // Button y starts at height of button text. ybuttons = button_text_height; } @@ -323,17 +323,17 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) int button_spacing = button_text_height; int button_height = 2 * button_text_height; - /* Bump button width up a bit. */ + // Bump button width up a bit. button_width += button_text_height; - /* Get width of all buttons lined up. */ + // Get width of all buttons lined up. width_of_buttons = data->numbuttons * button_width + (data->numbuttons - 1) * button_spacing; - /* Bump up dialog width and height if buttons are wider than text. */ + // 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); - /* Location for first button. */ + // 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); } else { @@ -342,17 +342,17 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) y = ybuttons + (data->dialog_height - ybuttons - button_height) / 2; for (i = 0; i < data->numbuttons; i++) { - /* Button coordinates. */ + // 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; - /* Button text coordinates. */ + // 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; - /* Scoot over for next button. */ + // Scoot over for next button. if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { x -= button_width + button_spacing; } else { @@ -364,7 +364,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) return 0; } -/* Free SDL_MessageBoxData data. */ +// Free SDL_MessageBoxData data. static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) { if (data->font_set) { @@ -397,7 +397,7 @@ static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) SDL_free(data->linedata); } -/* Create and set up our X11 dialog box indow. */ +// Create and set up our X11 dialog box indow. static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) { int x, y; @@ -435,8 +435,8 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) Atom _NET_WM_STATE = X11_XInternAtom(display, "_NET_WM_STATE", False); Atom stateatoms[16]; size_t statecount = 0; - /* Set some message-boxy window states when attached to a parent window... */ - /* we skip the taskbar since this will pop to the front when the parent window is clicked in the taskbar, etc */ + // Set some message-boxy window states when attached to a parent window... + // we skip the taskbar since this will pop to the front when the parent window is clicked in the taskbar, etc stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR", False); stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_SKIP_PAGER", False); stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_FOCUSED", False); @@ -445,20 +445,20 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) X11_XChangeProperty(display, data->window, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)stateatoms, statecount); - /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */ + // http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR X11_XSetTransientForHint(display, data->window, windowdata->xwindow); } SDL_X11_SetWindowTitle(display, data->window, (char *)messageboxdata->title); - /* Let the window manager know this is a dialog box */ + // 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); - /* Allow the window to be deleted by the window manager */ + // 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); @@ -478,7 +478,7 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) const SDL_DisplayData *dpydata = dpy->internal; 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. */ + } 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; } @@ -504,7 +504,7 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) X11_XMapRaised(display, data->window); #ifdef SDL_VIDEO_DRIVER_X11_XDBE - /* Initialise a back buffer for double buffering */ + // Initialise a back buffer for double buffering if (SDL_X11_HAVE_XDBE) { int xdbe_major, xdbe_minor; if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) { @@ -519,7 +519,7 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) return 0; } -/* Draw our message box. */ +// Draw our message box. static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) { int i; @@ -598,14 +598,14 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) #endif } -/* NOLINTNEXTLINE(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef */ +// NOLINTNEXTLINE(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef static Bool X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer 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. */ +// Loop and handle message box event messages until something kills it. static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) { GC ctx; @@ -634,15 +634,15 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) 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) { 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. */ + // 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); /* If X11_XFilterEvent returns True, then some input method has filtered the @@ -659,12 +659,12 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) break; case FocusIn: - /* Got focus. */ + // Got focus. has_focus = SDL_TRUE; break; case FocusOut: - /* lost focus. Reset button and mouse info. */ + // lost focus. Reset button and mouse info. has_focus = SDL_FALSE; data->button_press_index = -1; data->mouse_over_index = -1; @@ -672,7 +672,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) case MotionNotify: if (has_focus) { - /* Mouse moved... */ + // Mouse moved... const int previndex = data->mouse_over_index; data->mouse_over_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); if (data->mouse_over_index == previndex) { @@ -690,7 +690,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) break; case KeyPress: - /* Store key press - we make sure in key release that we got both. */ + // Store key press - we make sure in key release that we got both. last_key_pressed = X11_XLookupKeysym(&e.xkey, 0); break; @@ -699,7 +699,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) Uint32 mask = 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 this is a key release for something we didn't get the key down for, then bail. if (key != last_key_pressed) { break; } @@ -713,7 +713,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) if (mask) { int i; - /* Look for first button with this mask set, and return it if found. */ + // 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]; @@ -730,13 +730,13 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) case ButtonPress: data->button_press_index = -1; if (e.xbutton.button == Button1) { - /* Find index of button they clicked on. */ + // Find index of button they clicked on. 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 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); @@ -752,7 +752,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) } if (draw) { - /* Draw our dialog box. */ + // Draw our dialog box. X11_MessageBoxDraw(data, ctx); } } @@ -786,13 +786,13 @@ static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int } #endif - /* This code could get called from multiple threads maybe? */ + // This code could get called from multiple threads maybe? X11_XInitThreads(); - /* Initialize the return buttonID value to -1 (for error or dialogbox closed). */ + // Initialize the return buttonID value to -1 (for error or dialogbox closed). *buttonID = -1; - /* Init and display the message box. */ + // Init and display the message box. ret = X11_MessageBoxInit(&data, messageboxdata, buttonID); if (ret != -1) { ret = X11_MessageBoxInitPositions(&data); @@ -816,25 +816,25 @@ static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int return ret; } -/* Display an x11 message box. */ +// Display an x11 message box. int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { #if SDL_FORK_MESSAGEBOX - /* Use a child process to protect against setlocale(). Annoying. */ + // Use a child process to protect against setlocale(). Annoying. pid_t pid; int fds[2]; int status = 0; if (pipe(fds) == -1) { - return X11_ShowMessageBoxImpl(messageboxdata, buttonID); /* oh well. */ + return X11_ShowMessageBoxImpl(messageboxdata, buttonID); // oh well. } 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 */ + return X11_ShowMessageBoxImpl(messageboxdata, buttonID); // oh well. + } else if (pid == 0) { // we're the child int exitcode = 0; close(fds[0]); status = X11_ShowMessageBoxImpl(messageboxdata, buttonID); @@ -844,15 +844,15 @@ int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) 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"); @@ -869,4 +869,4 @@ int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) return X11_ShowMessageBoxImpl(messageboxdata, buttonID); #endif } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11messagebox.h b/src/video/x11/SDL_x11messagebox.h index 01b0ac1131..25459e470e 100644 --- a/src/video/x11/SDL_x11messagebox.h +++ b/src/video/x11/SDL_x11messagebox.h @@ -26,6 +26,6 @@ extern int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 -#endif /* SDL_x11messagebox_h_ */ +#endif // SDL_x11messagebox_h_ diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 61854feff7..723bf9d6a3 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -27,7 +27,7 @@ #include "edid.h" #include "../../events/SDL_displayevents_c.h" -/* #define X11MODES_DEBUG */ +// #define X11MODES_DEBUG /* Timeout and revert mode switches if the timespan has elapsed without the window becoming fullscreen. * 5 seconds seems good from testing. @@ -44,7 +44,7 @@ * * However, many people swear by it, so let them swear at it. :) */ -/* #define XRANDR_DISABLED_BY_DEFAULT */ +// #define XRANDR_DISABLED_BY_DEFAULT #ifdef SDL_USE_LIBDBUS @@ -63,7 +63,7 @@ static DBusMessage *ReadDBusSetting(SDL_DBusContext *dbus, const char *key) DBusMessage *msg = dbus->message_new_method_call(SCALE_FACTOR_NODE, SCALE_FACTOR_PATH, SCALE_FACTOR_INTERFACE, - "Read"); /* Method */ + "Read"); // Method if (msg) { if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { @@ -122,7 +122,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m const char *namespace, *key; dbus->message_iter_init(msg, &signal_iter); - /* Check if the parameters are what we expect */ + // Check if the parameters are what we expect if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING) { goto not_our_signal; } @@ -172,7 +172,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) if (scale_factor <= 0.0) { - /* First use the forced scaling factor specified by the app/user */ + // First use the forced scaling factor specified by the app/user const char *hint = SDL_GetHint(SDL_HINT_VIDEO_X11_SCALING_FACTOR); if (hint && *hint) { double value = SDL_atof(hint); @@ -181,7 +181,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) } } - /* Next try the settings portal via D-Bus for the text scaling factor (aka 'Global Scale' on KDE) */ + // Next try the settings portal via D-Bus for the text scaling factor (aka 'Global Scale' on KDE) #ifdef SDL_USE_LIBDBUS if (scale_factor <= 0.0) { @@ -191,7 +191,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) if (dbus) { if ((reply = ReadDBusSetting(dbus, SCALE_FACTOR_KEY))) { if (ParseDBusReply(dbus, reply, DBUS_TYPE_DOUBLE, &scale_factor)) { - /* If the setting exists, register a listener for scale changes. */ + // If the setting exists, register a listener for scale changes. dbus->bus_add_match(dbus->session_conn, "type='signal', interface='"SCALE_FACTOR_INTERFACE"'," "member='"SCALE_FACTOR_SIGNAL_NAME"', arg0='"SCALE_FACTOR_NAMESPACE"'," @@ -205,7 +205,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) } #endif - /* If that failed, try "Xft.dpi" from the XResourcesDatabase... */ + // If that failed, try "Xft.dpi" from the XResourcesDatabase... if (scale_factor <= 0.0) { SDL_VideoData *data = _this->internal; @@ -232,11 +232,11 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) } } - /* If that failed, try the XSETTINGS keys... */ + // If that failed, try the XSETTINGS keys... if (scale_factor <= 0.0) { scale_factor = X11_GetXsettingsIntKey(_this, "Gdk/WindowScalingFactor", -1); - /* The Xft/DPI key is stored in increments of 1024th */ + // The Xft/DPI key is stored in increments of 1024th if (scale_factor <= 0.0) { int dpi = X11_GetXsettingsIntKey(_this, "Xft/DPI", -1); if (dpi > 0) { @@ -246,7 +246,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) } } - /* If that failed, try the GDK_SCALE envvar... */ + // If that failed, try the GDK_SCALE envvar... if (scale_factor <= 0.0) { const char *scale_str = SDL_getenv("GDK_SCALE"); if (scale_str) { @@ -254,7 +254,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this) } } - /* Nothing or a bad value, just fall back to 1.0 */ + // Nothing or a bad value, just fall back to 1.0 if (scale_factor <= 0.0) { scale_factor = 1.0; } @@ -268,7 +268,7 @@ static int get_visualinfo(Display *display, int screen, XVisualInfo *vinfo) const char *visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_VISUALID); int depth; - /* Look for an exact visual, if requested */ + // Look for an exact visual, if requested if (visual_id && *visual_id) { XVisualInfo *vi, template; int nvis; @@ -352,14 +352,14 @@ SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo * } else { return SDL_PIXELFORMAT_INDEX4MSB; } - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break case 1: if (BitmapBitOrder(display) == LSBFirst) { return SDL_PIXELFORMAT_INDEX1LSB; } else { return SDL_PIXELFORMAT_INDEX1MSB; } - /* break; -Wunreachable-code-break */ + // break; -Wunreachable-code-break } } @@ -369,10 +369,10 @@ SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo * #ifdef SDL_VIDEO_DRIVER_X11_XRANDR static SDL_bool CheckXRandR(Display *display, int *major, int *minor) { - /* Default the extension not available */ + // Default the extension not available *major = *minor = 0; - /* Allow environment override */ + // Allow environment override #ifdef XRANDR_DISABLED_BY_DEFAULT if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_FALSE)) { #ifdef X11MODES_DEBUG @@ -387,7 +387,7 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor) #endif return SDL_FALSE; } -#endif /* XRANDR_DISABLED_BY_DEFAULT */ +#endif // XRANDR_DISABLED_BY_DEFAULT if (!SDL_X11_HAVE_XRANDR) { #ifdef X11MODES_DEBUG @@ -396,9 +396,9 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor) return SDL_FALSE; } - /* Query the extension version */ + // Query the extension version *major = 1; - *minor = 3; /* we want 1.3 */ + *minor = 3; // we want 1.3 if (!X11_XRRQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XRandR not active on the display\n"); @@ -420,13 +420,13 @@ static void CalculateXRandRRefreshRate(const XRRModeInfo *info, int *numerator, unsigned int vTotal = info->vTotal; if (info->modeFlags & RR_DoubleScan) { - /* doublescan doubles the number of lines */ + // doublescan doubles the number of lines vTotal *= 2; } if (info->modeFlags & RR_Interlace) { - /* interlace splits the frame into two fields */ - /* the field rate is what is typically reported by monitors */ + // interlace splits the frame into two fields + // the field rate is what is typically reported by monitors vTotal /= 2; } @@ -483,7 +483,7 @@ static SDL_bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRC 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 */ + // See if we can get the EDID data for the real monitor name int inches; int nprop; Atom *props = X11_XRRListOutputProperties(dpy, output, &nprop); @@ -549,16 +549,16 @@ static int X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int s int i, n; if (!display || !display_name) { - return -1; /* invalid parameters */ + return -1; // invalid parameters } if (get_visualinfo(dpy, screen, &vinfo) < 0) { - return -1; /* uh, skip this screen? */ + return -1; // uh, skip this screen? } pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo); if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) { - return -1; /* Palettized video modes are no longer supported, ignore this one. */ + return -1; // Palettized video modes are no longer supported, ignore this one. } scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8; @@ -576,7 +576,7 @@ static int X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int s output_info = X11_XRRGetOutputInfo(dpy, res, outputid); if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { X11_XRRFreeOutputInfo(output_info); - return -1; /* ignore this one. */ + return -1; // ignore this one. } SDL_strlcpy(display_name, output_info->name, display_name_size); @@ -587,7 +587,7 @@ static int X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int s crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); if (!crtc) { - return -1; /* oh well, ignore it. */ + return -1; // oh well, ignore it. } SDL_zero(mode); @@ -644,7 +644,7 @@ static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen char display_name[128]; if (X11_FillXRandRDisplayInfo(_this, dpy, screen, outputid, res, &display, display_name, sizeof(display_name)) == -1) { - return 0; /* failed to query data, skip this display */ + return 0; // failed to query data, skip this display } if (SDL_AddVideoDisplay(&display, send_event) == 0) { @@ -661,13 +661,13 @@ static int X11_UpdateXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int scr char display_name[128]; if (X11_FillXRandRDisplayInfo(_this, dpy, screen, outputid, res, &display, display_name, sizeof(display_name)) == -1) { - return -1; /* failed to query current display state */ + return -1; // failed to query current display state } - /* update mode - this call takes ownership of display.desktop_mode.internal */ + // update mode - this call takes ownership of display.desktop_mode.internal SDL_SetDesktopDisplayMode(existing_display, &display.desktop_mode); - /* update bounds */ + // update bounds if (existing_display->internal->x != display.internal->x || existing_display->internal->y != display.internal->y) { existing_display->internal->x = display.internal->x; @@ -675,10 +675,10 @@ static int X11_UpdateXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int scr SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_MOVED, 0, 0); } - /* update scale */ + // update scale SDL_SetDisplayContentScale(existing_display, display.content_scale); - /* SDL_DisplayData is updated piece-meal above, free our local copy of this data */ + // SDL_DisplayData is updated piece-meal above, free our local copy of this data SDL_free( display.internal ); return 0; @@ -707,11 +707,11 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput SDL_free(displays); } - if (ev->connection == RR_Disconnected) { /* output is going away */ + if (ev->connection == RR_Disconnected) { // output is going away if (display) { SDL_DelVideoDisplay(display->id, SDL_TRUE); } - } else if (ev->connection == RR_Connected) { /* output is coming online */ + } else if (ev->connection == RR_Connected) { // output is coming online Display *dpy = ev->display; const int screen = DefaultScreen(dpy); XVisualInfo vinfo; @@ -772,7 +772,7 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) for (looking_for_primary = 1; looking_for_primary >= 0; looking_for_primary--) { for (screen = 0; screen < screencount; screen++) { - /* we want the primary output first, and then skipped later. */ + // we want the primary output first, and then skipped later. if (looking_for_primary && (screen != default_screen)) { continue; } @@ -790,7 +790,7 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) } for (output = 0; output < res->noutput; output++) { - /* The primary output _should_ always be sorted first, but just in case... */ + // The primary output _should_ always be sorted first, but just in case... if ((looking_for_primary && (res->outputs[output] != primary)) || (!looking_for_primary && (screen == default_screen) && (res->outputs[output] == primary))) { continue; @@ -802,7 +802,7 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) X11_XRRFreeScreenResources(res); - /* This will generate events for displays that come and go at runtime. */ + // This will generate events for displays that come and go at runtime. X11_XRRSelectInput(dpy, RootWindow(dpy, screen), RROutputChangeNotifyMask); } } @@ -813,14 +813,14 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) return 0; } -#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ +#endif // SDL_VIDEO_DRIVER_X11_XRANDR /* This is used if there's no better functionality--like XRandR--to use. It won't attempt to supply different display modes at all, but it can enumerate the current displays and their current sizes. */ static int X11_InitModes_StdXlib(SDL_VideoDevice *_this) { - /* !!! FIXME: a lot of copy/paste from X11_InitModes_XRandR in this function. */ + // !!! FIXME: a lot of copy/paste from X11_InitModes_XRandR in this function. SDL_VideoData *data = _this->internal; Display *dpy = data->display; const int default_screen = DefaultScreen(dpy); @@ -834,7 +834,7 @@ static int X11_InitModes_StdXlib(SDL_VideoDevice *_this) XVisualInfo vinfo; SDL_VideoDisplay display; - /* note that generally even if you have a multiple physical monitors, ScreenCount(dpy) still only reports ONE screen. */ + // note that generally even if you have a multiple physical monitors, ScreenCount(dpy) still only reports ONE screen. if (get_visualinfo(dpy, default_screen, &vinfo) < 0) { return SDL_SetError("Failed to find an X11 visual for the primary display"); @@ -903,16 +903,16 @@ int X11_InitModes(SDL_VideoDevice *_this) { SDL_VideoData *data = _this->internal; int xrandr_major, xrandr_minor; - /* require at least XRandR v1.3 */ + // require at least XRandR v1.3 if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) && (xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3)) && X11_InitModes_XRandR(_this) == 0) { return 0; } } -#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ +#endif // SDL_VIDEO_DRIVER_X11_XRANDR - /* still here? Just set up an extremely basic display. */ + // still here? Just set up an extremely basic display. return X11_InitModes_StdXlib(_this); } @@ -960,18 +960,18 @@ int X11_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display) X11_XRRFreeScreenResources(res); } } -#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ +#endif // SDL_VIDEO_DRIVER_X11_XRANDR return 0; } #ifdef SDL_VIDEO_DRIVER_X11_XRANDR -/* This catches an error from XRRSetScreenSize, as a workaround for now. */ -/* !!! FIXME: remove this later when we have a better solution. */ +// 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) { - /* BadMatch: https://github.com/libsdl-org/SDL/issues/4561 */ - /* BadValue: https://github.com/libsdl-org/SDL/issues/4840 */ + // BadMatch: https://github.com/libsdl-org/SDL/issues/4561 + // BadValue: https://github.com/libsdl-org/SDL/issues/4840 if ((e->error_code == BadMatch) || (e->error_code == BadValue)) { return 0; } @@ -987,7 +987,7 @@ int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SD viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2); - /* XWayland mode switches are emulated with viewports and thus instantaneous. */ + // XWayland mode switches are emulated with viewports and thus instantaneous. if (!viddata->is_xwayland) { if (sdl_display->current_mode != mode) { data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS; @@ -1074,7 +1074,7 @@ int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SD } #else (void)data; -#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ +#endif // SDL_VIDEO_DRIVER_X11_XRANDR return 0; } @@ -1130,4 +1130,4 @@ int X11_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_dis return retval; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11modes.h b/src/video/x11/SDL_x11modes.h index 113db3957c..937269dd4b 100644 --- a/src/video/x11/SDL_x11modes.h +++ b/src/video/x11/SDL_x11modes.h @@ -46,7 +46,7 @@ struct SDL_DisplayModeData #ifdef 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 }; @@ -55,7 +55,7 @@ extern int X11_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display extern int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); extern void X11_QuitModes(SDL_VideoDevice *_this); -/* Some utility functions for working with visuals */ +// Some utility functions for working with visuals extern int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo); extern SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo); extern int X11_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); @@ -65,4 +65,4 @@ extern int X11_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay * extern void X11_HandleXRandREvent(SDL_VideoDevice *_this, const XEvent *xevent); #endif -#endif /* SDL_x11modes_h_ */ +#endif // SDL_x11modes_h_ diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 835863b32d..e8aaa0ba73 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -34,7 +34,7 @@ struct SDL_CursorData Cursor cursor; }; -/* FIXME: Find a better place to put this... */ +// FIXME: Find a better place to put this... static Cursor x11_empty_cursor = None; static SDL_bool x11_cursor_visible = SDL_TRUE; @@ -91,7 +91,7 @@ static SDL_Cursor *X11_CreateCursorAndData(Cursor x11_cursor) static SDL_Cursor *X11_CreateDefaultCursor(void) { - /* None is used to indicate the default cursor */ + // None is used to indicate the default cursor return X11_CreateCursorAndData(None); } @@ -121,7 +121,7 @@ static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y return cursor; } -#endif /* SDL_VIDEO_DRIVER_X11_XCURSOR */ +#endif // SDL_VIDEO_DRIVER_X11_XCURSOR static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) { @@ -146,7 +146,7 @@ static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) return None; } - /* Code below assumes ARGB pixel format */ + // Code below assumes ARGB pixel format SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0; @@ -227,8 +227,8 @@ static SDL_Cursor *X11_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) static unsigned int GetLegacySystemCursorShape(SDL_SystemCursor id) { switch (id) { - /* X Font Cursors reference: */ - /* http://tronche.com/gui/x/xlib/appendix/b/ */ + // X Font Cursors reference: + // http://tronche.com/gui/x/xlib/appendix/b/ case SDL_SYSTEM_CURSOR_DEFAULT: return XC_left_ptr; case SDL_SYSTEM_CURSOR_TEXT: return XC_xterm; case SDL_SYSTEM_CURSOR_WAIT: return XC_watch; @@ -249,7 +249,7 @@ static unsigned int GetLegacySystemCursorShape(SDL_SystemCursor id) case SDL_SYSTEM_CURSOR_S_RESIZE: return XC_bottom_side; case SDL_SYSTEM_CURSOR_SW_RESIZE: return XC_bottom_left_corner; case SDL_SYSTEM_CURSOR_W_RESIZE: return XC_left_side; - case SDL_NUM_SYSTEM_CURSORS: break; /* so the compiler might notice if an enum value is missing here. */ + case SDL_NUM_SYSTEM_CURSORS: break; // so the compiler might notice if an enum value is missing here. } SDL_assert(0); @@ -300,7 +300,7 @@ static int X11_ShowCursor(SDL_Cursor *cursor) x11_cursor = X11_CreateEmptyCursor(); } - /* FIXME: Is there a better way than this? */ + // FIXME: Is there a better way than this? { SDL_VideoDevice *video = SDL_GetVideoDevice(); Display *display = GetDisplay(); @@ -329,7 +329,7 @@ static void X11_WarpMouseInternal(Window xwindow, float x, float y) Display *display = videodata->display; SDL_bool warp_hack = SDL_FALSE; - /* XWayland will only warp the cursor if it is hidden, so this workaround is required. */ + // XWayland will only warp the cursor if it is hidden, so this workaround is required. if (videodata->is_xwayland && x11_cursor_visible) { warp_hack = SDL_TRUE; } @@ -368,7 +368,7 @@ static int X11_WarpMouse(SDL_Window *window, float x, float y) SDL_WindowData *data = window->internal; #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - /* If we have no barrier, we need to warp */ + // If we have no barrier, we need to warp if (data->pointer_barrier_active == SDL_FALSE) { X11_WarpMouseInternal(data->xwindow, x, y); } @@ -431,14 +431,14 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y) Display *display = GetDisplay(); int i; - /* !!! FIXME: should we XSync() here first? */ + // !!! FIXME: should we XSync() here first? if (!X11_Xinput2IsInitialized()) { videodata->global_mouse_changed = SDL_TRUE; } - /* check if we have this cached since XInput last saw the mouse move. */ - /* !!! FIXME: can we just calculate this from XInput's events? */ + // check if we have this cached since XInput last saw the mouse move. + // !!! FIXME: can we just calculate this from XInput's events? if (videodata->global_mouse_changed) { displays = SDL_GetDisplays(NULL); if (displays) { @@ -454,7 +454,7 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y) buttons |= (mask & Button1Mask) ? SDL_BUTTON_LMASK : 0; 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 */ + // Use the SDL state for the extended buttons - it's better than nothing 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). @@ -473,7 +473,7 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *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 = (float)videodata->global_mouse_position.x; *y = (float)videodata->global_mouse_position.y; @@ -544,4 +544,4 @@ void X11_SetHitTestCursor(SDL_HitTestResult rc) } } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11mouse.h b/src/video/x11/SDL_x11mouse.h index bbe61eb57e..e8a993d177 100644 --- a/src/video/x11/SDL_x11mouse.h +++ b/src/video/x11/SDL_x11mouse.h @@ -37,4 +37,4 @@ extern void X11_InitMouse(SDL_VideoDevice *_this); extern void X11_QuitMouse(SDL_VideoDevice *_this); extern void X11_SetHitTestCursor(SDL_HitTestResult rc); -#endif /* SDL_x11mouse_h_ */ +#endif // SDL_x11mouse_h_ diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index b393ec260e..89592b6b67 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -25,7 +25,7 @@ #include "SDL_x11video.h" -/* GLX implementation of SDL OpenGL support */ +// GLX implementation of SDL OpenGL support #ifdef SDL_VIDEO_OPENGL_GLX #include "SDL_x11opengles.h" @@ -75,7 +75,7 @@ #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 for the GL 3.0 context creation function typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display *dpy, GLXFBConfig config, GLXContext @@ -170,7 +170,7 @@ int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("OpenGL context already created"); } - /* Load the OpenGL library */ + // Load the OpenGL library if (path == NULL) { path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); } @@ -187,7 +187,7 @@ int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); - /* Allocate OpenGL memory */ + // Allocate OpenGL memory _this->gl_data = (struct SDL_GLDriverData *)SDL_calloc(1, sizeof(struct @@ -196,7 +196,7 @@ int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) return -1; } - /* Load function pointers */ + // Load function pointers handle = _this->gl_config.dll_handle; _this->gl_data->glXQueryExtension = (Bool(*)(Display *, int *, int *)) @@ -239,7 +239,7 @@ int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNTESTED; - /* Initialize extensions */ + // Initialize extensions /* See lengthy comment about the inc/dec in ../windows/SDL_windowsopengl.c. */ ++_this->gl_config.driver_loaded; @@ -291,7 +291,7 @@ void X11_GL_UnloadLibrary(SDL_VideoDevice *_this) _this->gl_config.dll_handle = NULL; #endif - /* Free OpenGL memory */ + // Free OpenGL memory SDL_free(_this->gl_data); _this->gl_data = NULL; } @@ -305,7 +305,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } - /* Extension names should not have spaces. */ + // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { return SDL_FALSE; @@ -390,7 +390,7 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) extensions = NULL; } - /* Check for GLX_EXT_swap_control(_tear) */ + // Check for GLX_EXT_swap_control(_tear) _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE; if (HasExtension("GLX_EXT_swap_control", extensions)) { _this->gl_data->glXSwapIntervalEXT = @@ -401,7 +401,7 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) } } - /* Check for GLX_MESA_swap_control */ + // Check for GLX_MESA_swap_control if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); @@ -410,13 +410,13 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) "glXGetSwapIntervalMESA"); } - /* Check for GLX_SGI_swap_control */ + // Check for GLX_SGI_swap_control if (HasExtension("GLX_SGI_swap_control", extensions)) { _this->gl_data->glXSwapIntervalSGI = (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); } - /* Check for GLX_ARB_create_context */ + // Check for GLX_ARB_create_context if (HasExtension("GLX_ARB_create_context", extensions)) { _this->gl_data->glXCreateContextAttribsARB = (GLXContext(*)(Display *, GLXFBConfig, GLXContext, Bool, const int *)) @@ -429,20 +429,20 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) X11_GL_GetProcAddress(_this, "glXGetVisualFromFBConfig"); } - /* Check for GLX_EXT_visual_rating */ + // Check for GLX_EXT_visual_rating if (HasExtension("GLX_EXT_visual_rating", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; } - /* Check for GLX_EXT_visual_info */ + // Check for GLX_EXT_visual_info 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 */ + // 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. */ - /* !!! FIXME: it would be nice not to make a context here though! */ + // this wants to call glGetString(), so it needs a context. + // !!! FIXME: it would be nice not to make a context here though! if (context) { SDL_GL_DeduceMaxSupportedESProfile( &_this->gl_data->es_profile_max_supported_version.major, @@ -450,17 +450,17 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) } } - /* Check for GLX_ARB_context_flush_control */ + // Check for GLX_ARB_context_flush_control if (HasExtension("GLX_ARB_context_flush_control", extensions)) { _this->gl_data->HAS_GLX_ARB_context_flush_control = SDL_TRUE; } - /* Check for GLX_ARB_create_context_robustness */ + // Check for GLX_ARB_create_context_robustness if (HasExtension("GLX_ARB_create_context_robustness", extensions)) { _this->gl_data->HAS_GLX_ARB_create_context_robustness = SDL_TRUE; } - /* Check for GLX_ARB_create_context_no_error */ + // Check for GLX_ARB_create_context_no_error if (HasExtension("GLX_ARB_create_context_no_error", extensions)) { _this->gl_data->HAS_GLX_ARB_create_context_no_error = SDL_TRUE; } @@ -492,10 +492,10 @@ static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int sc const int MAX_ATTRIBUTES = 64; int *pvistypeattr = NULL; - /* assert buffer is large enough to hold all SDL attributes. */ + // assert buffer is large enough to hold all SDL attributes. SDL_assert(size >= MAX_ATTRIBUTES); - /* Setup our GLX attributes according to the gl_config. */ + // Setup our GLX attributes according to the gl_config. if (for_FBConfig) { attribs[i++] = GLX_RENDER_TYPE; if (_this->gl_config.floatbuffers) { @@ -577,7 +577,7 @@ static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int sc 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 && @@ -586,7 +586,7 @@ static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int sc attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT : GLX_SLOW_VISUAL_EXT; } - /* Un-wanted when we request a transparent buffer */ + // Un-wanted when we request a transparent buffer if (!transparent) { /* If we're supposed to use DirectColor visuals, and we've got the EXT_visual_info extension, then add GLX_X_VISUAL_TYPE_EXT. */ @@ -610,13 +610,13 @@ static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int sc XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, SDL_bool transparent) { - /* 64 seems nice. */ + // 64 seems nice. int attribs[64]; XVisualInfo *vinfo = NULL; int *pvistypeattr = NULL; if (!_this->gl_data) { - /* The OpenGL library wasn't loaded, SDL_GetError() should have info */ + // The OpenGL library wasn't loaded, SDL_GetError() should have info return NULL; } @@ -633,13 +633,13 @@ XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int scre } if (transparent) { - /* Return the first transparent Visual */ + // Return the first transparent Visual int i; for (i = 0; i < fbcount; i++) { Uint32 format; vinfo = _this->gl_data->glXGetVisualFromFBConfig(display, framebuffer_config[i]); format = X11_GetPixelFormatFromVisualInfo(display, vinfo); - if (SDL_ISPIXELFORMAT_ALPHA(format)) { /* found! */ + if (SDL_ISPIXELFORMAT_ALPHA(format)) { // found! X11_XFree(framebuffer_config); framebuffer_config = NULL; break; @@ -700,12 +700,12 @@ SDL_bool X11_GL_UseEGL(SDL_VideoDevice *_this) { SDL_assert(_this->gl_data != NULL); if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { - /* use of EGL has been requested, even for desktop GL */ + // use of EGL has been requested, even for desktop GL return SDL_TRUE; } 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. */ + 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)); } @@ -727,7 +727,7 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) share_context = NULL; } - /* We do this to create a clean separation between X and GLX errors. */ + // We do this to create a clean separation between X and GLX errors. X11_XSync(display, False); errorHandlerOperation = "create GL context"; errorBase = _this->gl_data->errorBase; @@ -741,11 +741,11 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) if (_this->gl_config.major_version < 3 && _this->gl_config.profile_mask == 0 && _this->gl_config.flags == 0 && !transparent) { - /* Create legacy context */ + // Create legacy context context = (SDL_GLContext)_this->gl_data->glXCreateContext(display, vinfo, share_context, True); } else { - /* max 14 attributes plus terminator */ + // max 14 attributes plus terminator int attribs[15] = { GLX_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, @@ -755,33 +755,33 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) }; int iattr = 4; - /* SDL profile bits match GLX profile bits */ + // SDL profile bits match GLX profile bits 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 */ + // SDL flags match GLX flags 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 and not the default setting */ + // only set if glx extension is available and not the default setting if ((_this->gl_data->HAS_GLX_ARB_context_flush_control) && (_this->gl_config.release_behavior == 0)) { 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; } - /* only set if glx extension is available and not the default setting */ + // only set if glx extension is available and not the default setting if ((_this->gl_data->HAS_GLX_ARB_create_context_robustness) && (_this->gl_config.reset_notification != 0)) { 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; } - /* only set if glx extension is available and not the default setting */ + // only set if glx extension is available and not the default setting if ((_this->gl_data->HAS_GLX_ARB_create_context_no_error) && (_this->gl_config.no_error != 0)) { attribs[iattr++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB; attribs[iattr++] = _this->gl_config.no_error; @@ -789,13 +789,13 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) attribs[iattr++] = 0; - /* Get a pointer to the context creation function for GL 3.0 */ + // Get a pointer to the context creation function for GL 3.0 if (!_this->gl_data->glXCreateContextAttribsARB) { SDL_SetError("OpenGL 3.0 and later are not supported by this system"); } else { int glxAttribs[64]; - /* Create a GL 3.x context */ + // Create a GL 3.x context GLXFBConfig *framebuffer_config = NULL; int fbcount = 0; int *pvistypeattr = NULL; @@ -855,7 +855,7 @@ int X11_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext return SDL_SetError("OpenGL not initialized"); } - /* We do this to create a clean separation between X and GLX errors. */ + // We do this to create a clean separation between X and GLX errors. X11_XSync(display, False); errorHandlerOperation = "make GL context current"; errorBase = _this->gl_data->errorBase; @@ -864,9 +864,9 @@ int X11_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext 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"); } @@ -951,22 +951,22 @@ static SDL_GLSwapIntervalTearBehavior CheckSwapIntervalTearBehavior(SDL_VideoDev */ _this->gl_data->glXSwapIntervalEXT(display, drawable, current_val); - /* set it to no swap interval and see how it affects GLX_LATE_SWAPS_TEAR_EXT... */ + // set it to no swap interval and see how it affects GLX_LATE_SWAPS_TEAR_EXT... _this->gl_data->glXSwapIntervalEXT(display, drawable, 0); _this->gl_data->glXQueryDrawable(display, drawable, GLX_LATE_SWAPS_TEAR_EXT, &allow_late_swap_tearing); - if (allow_late_swap_tearing == 0) { /* GLX_LATE_SWAPS_TEAR_EXT says whether late swapping is currently in use */ + if (allow_late_swap_tearing == 0) { // GLX_LATE_SWAPS_TEAR_EXT says whether late swapping is currently in use _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_NVIDIA; if (current_allow_late) { original_val = -original_val; } - } else if (allow_late_swap_tearing == 1) { /* GLX_LATE_SWAPS_TEAR_EXT says whether the Drawable can use late swapping at all */ + } else if (allow_late_swap_tearing == 1) { // GLX_LATE_SWAPS_TEAR_EXT says whether the Drawable can use late swapping at all _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_MESA; - } else { /* unexpected outcome! */ + } else { // unexpected outcome! _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNKNOWN; } - /* set us back to what it was originally... */ + // set us back to what it was originally... _this->gl_data->glXSwapIntervalEXT(display, drawable, original_val); } } @@ -985,7 +985,7 @@ int X11_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) unsigned int val = 0; if (_this->gl_data->HAS_GLX_EXT_swap_control_tear) { - allow_late_swap_tearing = 22; /* set this to nonsense. */ + allow_late_swap_tearing = 22; // set this to nonsense. _this->gl_data->glXQueryDrawable(display, drawable, GLX_LATE_SWAPS_TEAR_EXT, &allow_late_swap_tearing); @@ -998,7 +998,7 @@ int X11_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) switch (CheckSwapIntervalTearBehavior(_this, drawable, val, allow_late_swap_tearing)) { case SDL_SWAPINTERVALTEAR_MESA: - *interval = (int)val; /* unsigned int cast to signed that generates negative value if necessary. */ + *interval = (int)val; // unsigned int cast to signed that generates negative value if necessary. break; case SDL_SWAPINTERVALTEAR_NVIDIA: @@ -1045,6 +1045,6 @@ int X11_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) return 0; } -#endif /* SDL_VIDEO_OPENGL_GLX */ +#endif // SDL_VIDEO_OPENGL_GLX -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index 240081f746..c2c494edb6 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -77,7 +77,7 @@ struct SDL_GLDriverData int (*glXGetSwapIntervalMESA)(void); }; -/* OpenGL functions */ +// OpenGL functions extern int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer X11_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); extern void X11_GL_UnloadLibrary(SDL_VideoDevice *_this); @@ -91,6 +91,6 @@ extern int X11_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); extern int X11_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); -#endif /* SDL_VIDEO_OPENGL_GLX */ +#endif // SDL_VIDEO_OPENGL_GLX -#endif /* SDL_x11opengl_h_ */ +#endif // SDL_x11opengl_h_ diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index cdf26fe97b..072f39db11 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -26,13 +26,13 @@ #include "SDL_x11opengles.h" #include "SDL_x11opengl.h" -/* EGL implementation of SDL OpenGL support */ +// EGL implementation of SDL OpenGL support int X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { SDL_VideoData *data = _this->internal; - /* If the profile requested is not GL ES, switch over to X11_GL functions */ + // 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) && !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { #ifdef SDL_VIDEO_OPENGL_GLX @@ -64,7 +64,7 @@ XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int sc int out_count; if (!_this->egl_data) { - /* The EGL library wasn't loaded, SDL_GetError() should have info */ + // The EGL library wasn't loaded, SDL_GetError() should have info return NULL; } @@ -73,20 +73,20 @@ XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int sc EGL_NATIVE_VISUAL_ID, &visual_id) == EGL_FALSE || !visual_id) { - /* Use the default visual when all else fails */ + // Use the default visual when all else fails vi_in.screen = screen; egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask, &vi_in, &out_count); - /* Return the first transparent Visual */ + // Return the first transparent Visual if (transparent) { int i; for (i = 0; i < out_count; i++) { XVisualInfo *v = &egl_visualinfo[i]; Uint32 format = X11_GetPixelFormatFromVisualInfo(display, v); - if (SDL_ISPIXELFORMAT_ALPHA(format)) { /* found! */ - /* re-request it to have a copy that can be X11_XFree'ed later */ + if (SDL_ISPIXELFORMAT_ALPHA(format)) { // found! + // re-request it to have a copy that can be X11_XFree'ed later vi_in.screen = screen; vi_in.visualid = v->visualid; X11_XFree(egl_visualinfo); @@ -126,4 +126,4 @@ SDL_EGLSurface X11_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window SDL_EGL_SwapWindow_impl(X11) SDL_EGL_MakeCurrent_impl(X11) -#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h index d6158581d0..a99d076936 100644 --- a/src/video/x11/SDL_x11opengles.h +++ b/src/video/x11/SDL_x11opengles.h @@ -30,12 +30,12 @@ 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] */ + // 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 */ +// OpenGLES functions #define X11_GLES_GetAttribute SDL_EGL_GetAttribute #define X11_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal #define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary @@ -50,6 +50,6 @@ extern int X11_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); extern SDL_EGLSurface X11_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL -#endif /* SDL_x11opengles_h_ */ +#endif // SDL_x11opengles_h_ diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c index 4cc7337c16..d85d2d238f 100644 --- a/src/video/x11/SDL_x11pen.c +++ b/src/video/x11/SDL_x11pen.c @@ -28,7 +28,7 @@ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 -/* Does this device have a valuator for pressure sensitivity? */ +// Does this device have a valuator for pressure sensitivity? static SDL_bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev) { const SDL_VideoData *data = (SDL_VideoData *)_this->internal; @@ -45,10 +45,10 @@ static SDL_bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInf return SDL_FALSE; } -/* Heuristically determines if device is an eraser */ +// Heuristically determines if device is an eraser static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, char *devicename) { - #define PEN_ERASER_NAME_TAG "eraser" /* String constant to identify erasers */ + #define PEN_ERASER_NAME_TAG "eraser" // String constant to identify erasers SDL_VideoData *data = (SDL_VideoData *)_this->internal; if (data->pen_atom_wacom_tool_type != None) { @@ -58,7 +58,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha unsigned long bytes_after_return; unsigned char *tooltype_name_info = NULL; - /* Try Wacom-specific method */ + // Try Wacom-specific method if (Success == X11_XIGetProperty(data->display, deviceid, data->pen_atom_wacom_tool_type, 0, 32, False, @@ -71,7 +71,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha char *tooltype_name = NULL; if (type_return == XA_ATOM) { - /* Atom instead of string? Un-intern */ + // Atom instead of string? Un-intern Atom atom = *((Atom *)tooltype_name_info); if (atom != None) { tooltype_name = X11_XGetAtomName(data->display, atom); @@ -91,7 +91,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha } } - /* Non-Wacom device? */ + // Non-Wacom device? /* We assume that a device is an eraser if its name contains the string "eraser". * Unfortunately there doesn't seem to be a clean way to distinguish these cases (as of 2022-03). */ @@ -335,7 +335,7 @@ void X11_QuitPen(SDL_VideoDevice *_this) static void X11_XInput2NormalizePenAxes(const X11_PenHandle *pen, float *coords) { - /* Normalise axes */ + // Normalise axes for (int axis = 0; axis < SDL_PEN_NUM_AXES; ++axis) { const int valuator = pen->valuator_for_axis[axis]; if (valuator == SDL_X11_PEN_AXIS_VALUATOR_MISSING) { diff --git a/src/video/x11/SDL_x11settings.c b/src/video/x11/SDL_x11settings.c index 8dbf44f974..7a7ae01318 100644 --- a/src/video/x11/SDL_x11settings.c +++ b/src/video/x11/SDL_x11settings.c @@ -126,4 +126,4 @@ no_key: return res; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11settings.h b/src/video/x11/SDL_x11settings.h index 3a72cbac52..5b368846ed 100644 --- a/src/video/x11/SDL_x11settings.h +++ b/src/video/x11/SDL_x11settings.h @@ -36,4 +36,4 @@ extern void X11_QuitXsettings(SDL_VideoDevice *_this); extern void X11_HandleXsettings(SDL_VideoDevice *_this, const XEvent *xevent); extern int X11_GetXsettingsIntKey(SDL_VideoDevice *_this, const char *key, int fallback_value); -#endif /* SDL_x11settings_h_ */ +#endif // SDL_x11settings_h_ diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 81da584d44..2d4be12045 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -53,7 +53,7 @@ static Uint8 *GenerateShapeMask(SDL_Surface *shape) } return mask; } -#endif /* SDL_VIDEO_DRIVER_X11_XSHAPE */ +#endif // SDL_VIDEO_DRIVER_X11_XSHAPE int X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape) { @@ -62,7 +62,7 @@ int X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfac #ifdef SDL_VIDEO_DRIVER_X11_XSHAPE SDL_WindowData *windowdata = window->internal; - /* Generate a set of spans for the region */ + // Generate a set of spans for the region if (shape) { SDL_Surface *stretched = NULL; Uint8 *mask; @@ -105,9 +105,9 @@ int X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfac X11_XDestroyRegion(region); result = 0; } -#endif /* SDL_VIDEO_DRIVER_X11_XSHAPE */ +#endif // SDL_VIDEO_DRIVER_X11_XSHAPE return result; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h index 7d9b52dd6f..784a3ef9ab 100644 --- a/src/video/x11/SDL_x11shape.h +++ b/src/video/x11/SDL_x11shape.h @@ -25,4 +25,4 @@ extern int X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); -#endif /* SDL_x11shape_h_ */ +#endif // SDL_x11shape_h_ diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index b21c8e7a5b..a5c800ad74 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* *INDENT-OFF* */ /* clang-format off */ +/* *INDENT-OFF* */ // clang-format off #ifndef SDL_X11_MODULE #define SDL_X11_MODULE(modname) @@ -168,7 +168,7 @@ SDL_X11_SYM(Bool,XrmGetResource,(XrmDatabase db, char* str_name, char* str_class SDL_X11_MODULE(XFIXES) SDL_X11_SYM(PointerBarrier, XFixesCreatePointerBarrier, (Display* a, Window b, int c, int d, int e, int f, int g, int h, int *i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(void, XFixesDestroyPointerBarrier, (Display* a, PointerBarrier b), (a,b),) -SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return) /* this is actually Xinput2 */ +SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return) // this is actually Xinput2 SDL_X11_SYM(Status, XFixesQueryVersion,(Display* a, int* b, int* c), (a,b,c), return) SDL_X11_SYM(Status, XFixesSelectSelectionInput, (Display* a, Window b, Atom c, unsigned long d), (a,b,c,d), return) #endif @@ -193,7 +193,7 @@ SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),) SDL_X11_SYM(Bool,XkbSetDetectableAutoRepeat,(Display* a, Bool b, Bool* c),(a,b,c),return) #endif -/* XKeycodeToKeysym is a deprecated function */ +// XKeycodeToKeysym is a deprecated function #ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -211,7 +211,7 @@ SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) SDL_X11_MODULE(UTF8) SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) SDL_X11_SYM(int,Xutf8LookupString,(XIC a,XKeyPressedEvent* b,char* c,int d,KeySym* e,Status* f),(a,b,c,d,e,f),return) -/* SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ +// SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! SDL_X11_SYM(void,XDestroyIC,(XIC a),(a),) /* SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),) @@ -255,7 +255,7 @@ SDL_X11_SYM(int,ipAllocateData,(ChannelPtr a,IPCard b,IPDataPtr * c),(a,b,c),ret SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return) #endif -/* XCursor support */ +// XCursor support #ifdef SDL_VIDEO_DRIVER_X11_XCURSOR SDL_X11_MODULE(XCURSOR) SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return) @@ -264,7 +264,7 @@ SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a, SDL_X11_SYM(Cursor,XcursorLibraryLoadCursor,(Display *a, const char *b),(a,b),return) #endif -/* Xdbe support */ +// Xdbe support #ifdef SDL_VIDEO_DRIVER_X11_XDBE SDL_X11_MODULE(XDBE) SDL_X11_SYM(Status,XdbeQueryExtension,(Display *dpy,int *major_version_return,int *minor_version_return),(dpy,major_version_return,minor_version_return),return) @@ -278,7 +278,7 @@ SDL_X11_SYM(void,XdbeFreeVisualInfo,(XdbeScreenVisualInfo *visual_info),(visual_ SDL_X11_SYM(XdbeBackBufferAttributes*,XdbeGetBackBufferAttributes,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return) #endif -/* XInput2 support for multiple mice, tablets, etc. */ +// XInput2 support for multiple mice, tablets, etc. #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_X11_MODULE(XINPUT2) SDL_X11_SYM(XIDeviceInfo*,XIQueryDevice,(Display *a,int b,int *c),(a,b,c),return) @@ -293,7 +293,7 @@ SDL_X11_SYM(Bool,XIWarpPointer,(Display *a,int b,Window c,Window d,double e,doub SDL_X11_SYM(Status,XIGetProperty,(Display *a,int b,Atom c,long d,long e,Bool f, Atom g, Atom *h, int *i, unsigned long *j, unsigned long *k, unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return); #endif -/* XRandR support */ +// XRandR support #ifdef SDL_VIDEO_DRIVER_X11_XRANDR SDL_X11_MODULE(XRANDR) SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) @@ -323,7 +323,7 @@ SDL_X11_SYM(void,XRRSelectInput,(Display *dpy, Window window, int mask),(dpy,win SDL_X11_SYM(Status,XRRGetCrtcTransform,(Display *dpy,RRCrtc crtc,XRRCrtcTransformAttributes **attributes),(dpy,crtc,attributes),return) #endif -/* MIT-SCREEN-SAVER support */ +// MIT-SCREEN-SAVER support #ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER SDL_X11_MODULE(XSS) SDL_X11_SYM(Bool,XScreenSaverQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) @@ -340,4 +340,4 @@ SDL_X11_SYM(void,XShapeCombineRegion,(Display *a,Window b,int c,int d,int e,Regi #undef SDL_X11_MODULE #undef SDL_X11_SYM -/* *INDENT-ON* */ /* clang-format on */ +/* *INDENT-ON* */ // clang-format on diff --git a/src/video/x11/SDL_x11touch.c b/src/video/x11/SDL_x11touch.c index 9b2a86ce36..cbd9c9baa3 100644 --- a/src/video/x11/SDL_x11touch.c +++ b/src/video/x11/SDL_x11touch.c @@ -43,4 +43,4 @@ void X11_ResetTouch(SDL_VideoDevice *_this) X11_InitTouch(_this); } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11touch.h b/src/video/x11/SDL_x11touch.h index 2343faa5b4..35abf5aabd 100644 --- a/src/video/x11/SDL_x11touch.h +++ b/src/video/x11/SDL_x11touch.h @@ -27,4 +27,4 @@ extern void X11_InitTouch(SDL_VideoDevice *_this); extern void X11_QuitTouch(SDL_VideoDevice *_this); extern void X11_ResetTouch(SDL_VideoDevice *_this); -#endif /* SDL_x11touch_h_ */ +#endif // SDL_x11touch_h_ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 860f486fce..86dabf6824 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_X11 -#include /* For getpid() and readlink() */ +#include // For getpid() and readlink() #include "../../core/linux/SDL_system_theme.h" #include "../../events/SDL_keyboard_c.h" @@ -43,11 +43,11 @@ #include "SDL_x11opengles.h" #endif -/* Initialization/Query functions */ +// Initialization/Query functions static int X11_VideoInit(SDL_VideoDevice *_this); static void X11_VideoQuit(SDL_VideoDevice *_this); -/* X11 driver bootstrap functions */ +// X11 driver bootstrap functions static int (*orig_x11_errhandler)(Display *, XErrorEvent *) = NULL; @@ -74,12 +74,12 @@ static void X11_DeleteDevice(SDL_VideoDevice *device) SDL_X11_UnloadSymbols(); } -/* An error handler to reset the vidmode and then call the default handler. */ +// 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) { SDL_VideoDevice *device = NULL; - /* if we trigger an error in our error handler, don't try again. */ + // if we trigger an error in our error handler, don't try again. if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; device = SDL_GetVideoDevice(); @@ -95,7 +95,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) } if (orig_x11_errhandler) { - return orig_x11_errhandler(d, e); /* probably terminate. */ + return orig_x11_errhandler(d, e); // probably terminate. } return 0; @@ -111,7 +111,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; - const char *display = NULL; /* Use the DISPLAY environment variable */ + const char *display = NULL; // Use the DISPLAY environment variable Display *x11_display = NULL; if (!SDL_X11_LoadSymbols()) { @@ -122,7 +122,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) nVidia driver to be threaded. */ X11_XInitThreads(); - /* Open the display first to be sure that X11 is available */ + // Open the display first to be sure that X11 is available x11_display = X11_XOpenDisplay(display); if (!x11_display) { @@ -130,7 +130,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) return NULL; } - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { return NULL; @@ -146,7 +146,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES data->active_cursor_confined_window = NULL; -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES data->display = x11_display; data->request_display = X11_XOpenDisplay(display); @@ -164,7 +164,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) X11_XSynchronize(data->display, True); #endif - /* Hook up an X11 error handler to recover the desktop resolution. */ + // Hook up an X11 error handler to recover the desktop resolution. safety_net_triggered = SDL_FALSE; orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); @@ -173,7 +173,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) */ data->is_steam_deck = SDL_GetHintBoolean("SteamDeck", SDL_FALSE); - /* Set the function pointers */ + // Set the function pointers device->VideoInit = X11_VideoInit; device->VideoQuit = X11_VideoQuit; device->ResetTouch = X11_ResetTouch; @@ -224,7 +224,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES device->SetWindowMouseRect = X11_SetWindowMouseRect; -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES #ifdef SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; @@ -330,7 +330,7 @@ static void X11_CheckWindowManager(SDL_VideoDevice *_this) char *wm_name; #endif - /* Set up a handler to gracefully catch errors */ + // Set up a handler to gracefully catch errors X11_XSync(display, False); handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler); @@ -357,7 +357,7 @@ static void X11_CheckWindowManager(SDL_VideoDevice *_this) } } - /* Reset the error handler, we're done checking */ + // Reset the error handler, we're done checking X11_XSync(display, False); X11_XSetErrorHandler(handler); @@ -380,13 +380,13 @@ int X11_VideoInit(SDL_VideoDevice *_this) { SDL_VideoData *data = _this->internal; - /* Get the process PID to be associated to the window */ + // Get the process PID to be associated to the window data->pid = getpid(); - /* I have no idea how random this actually is, or has to be. */ + // I have no idea how random this actually is, or has to be. data->window_group = (XID)(((size_t)data->pid) ^ ((size_t)_this)); - /* Look up some useful Atoms */ + // Look up some useful Atoms #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); @@ -426,7 +426,7 @@ int X11_VideoInit(SDL_VideoDevice *_this) GET_ATOM(XdndSelection); GET_ATOM(XKLAVIER_STATE); - /* Detect the window manager */ + // Detect the window manager X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { @@ -434,14 +434,14 @@ int X11_VideoInit(SDL_VideoDevice *_this) } if (!X11_InitXinput2(_this)) { - /* Assume a mouse and keyboard are attached */ + // Assume a mouse and keyboard are attached SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); } #ifdef SDL_VIDEO_DRIVER_X11_XFIXES X11_InitXfixes(_this); -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES X11_InitXsettings(_this); @@ -496,4 +496,4 @@ SDL_bool X11_UseDirectColorVisuals(void) return SDL_TRUE; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 328ac0c8e4..4a442b587a 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -40,7 +40,7 @@ #include "SDL_x11window.h" #include "SDL_x11vulkan.h" -/* Private display data */ +// Private display data struct SDL_VideoData { @@ -58,14 +58,14 @@ struct SDL_VideoData SDLX11_ClipboardData primary_selection; #ifdef SDL_VIDEO_DRIVER_X11_XFIXES SDL_Window *active_cursor_confined_window; -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES Window xsettings_window; SDLX11_SettingsData xsettings_data; - /* This is true for ICCCM2.0-compliant window managers */ + // This is true for ICCCM2.0-compliant window managers SDL_bool net_wm; - /* Useful atoms */ + // Useful atoms Atom WM_PROTOCOLS; Atom WM_DELETE_WINDOW; Atom WM_TAKE_FOCUS; @@ -104,7 +104,7 @@ struct SDL_VideoData Atom XdndSelection; Atom XKLAVIER_STATE; - /* Pen atoms (these have names that don't map well to C symbols) */ + // Pen atoms (these have names that don't map well to C symbols) Atom pen_atom_device_product_id; Atom pen_atom_abs_pressure; Atom pen_atom_abs_tilt_x; @@ -116,7 +116,7 @@ struct SDL_VideoData SDL_bool selection_waiting; SDL_bool selection_incr_waiting; - SDL_bool broken_pointer_grab; /* true if XGrabPointer seems unreliable. */ + SDL_bool broken_pointer_grab; // true if XGrabPointer seems unreliable. Uint64 last_mode_change_deadline; @@ -139,12 +139,12 @@ struct SDL_VideoData Time filter_time; #ifdef SDL_VIDEO_VULKAN - /* Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL */ + // Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL void *vulkan_xlib_xcb_library; PFN_XGetXCBConnection vulkan_XGetXCBConnection; #endif - /* Used to interact with the on-screen keyboard */ + // Used to interact with the on-screen keyboard SDL_bool is_steam_deck; SDL_bool steam_keyboard_open; @@ -153,4 +153,4 @@ struct SDL_VideoData extern SDL_bool X11_UseDirectColorVisuals(void); -#endif /* SDL_x11video_h_ */ +#endif // SDL_x11video_h_ diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index 67b526bcb3..b8cba1d21e 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -29,7 +29,7 @@ #include "SDL_x11vulkan.h" #include -/*#include */ +// #include #ifdef SDL_PLATFORM_OPENBSD #define DEFAULT_VULKAN "libvulkan.so" @@ -56,7 +56,7 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_SetError("Vulkan already loaded"); } - /* Load the Vulkan loader library */ + // Load the Vulkan loader library if (!path) { path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); } diff --git a/src/video/x11/SDL_x11vulkan.h b/src/video/x11/SDL_x11vulkan.h index 23d9161609..86a2fa9da8 100644 --- a/src/video/x11/SDL_x11vulkan.h +++ b/src/video/x11/SDL_x11vulkan.h @@ -50,4 +50,4 @@ SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, #endif -#endif /* SDL_x11vulkan_h_ */ +#endif // SDL_x11vulkan_h_ diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 7d1d2fab67..490e2438d8 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -57,11 +57,11 @@ return SDL_SetError("Invalid display driver data"); \ } -static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win) /* NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef */ +static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win) // NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef { return ev->type == MapNotify && ev->xmap.window == *((Window *)win); } -static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win) /* NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef */ +static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win) // NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef { return ev->type == UnmapNotify && ev->xunmap.window == *((Window *)win); } @@ -122,15 +122,15 @@ static SDL_bool X11_IsActionAllowed(SDL_Window *window, Atom action) } return ret; } -#endif /* 0 */ +#endif // 0 void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, SDL_WindowFlags flags) { SDL_VideoData *videodata = _this->internal; Display *display = videodata->display; - /* !!! FIXME: just dereference videodata below instead of copying to locals. */ + // !!! FIXME: just dereference videodata below instead of copying to locals. Atom _NET_WM_STATE = videodata->_NET_WM_STATE; - /* Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */ + // Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED; Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT; Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ; @@ -184,7 +184,7 @@ void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, SDL_WindowFlags f static void X11_ConstrainPopup(SDL_Window *window) { - /* Clamp popup windows to the output borders */ + // Clamp popup windows to the output borders if (SDL_WINDOW_IS_POPUP(window)) { SDL_Window *w; SDL_DisplayID displayID; @@ -193,7 +193,7 @@ static void X11_ConstrainPopup(SDL_Window *window) int abs_y = window->floating.y; int offset_x = 0, offset_y = 0; - /* Calculate the total offset from the parents */ + // Calculate the total offset from the parents for (w = window->parent; w->parent; w = w->parent) { offset_x += w->x; offset_y += w->y; @@ -225,7 +225,7 @@ static void X11_SetKeyboardFocus(SDL_Window *window) { SDL_Window *topmost = window; - /* Find the topmost parent */ + // Find the topmost parent while (topmost->parent) { topmost = topmost->parent; } @@ -275,10 +275,10 @@ Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwin if (fullscreen == 1) { if (window->flags & SDL_WINDOW_FULLSCREEN) { - /* Pick whatever state the window expects */ + // Pick whatever state the window expects flags |= (window->flags & SDL_WINDOW_FULLSCREEN); } else { - /* Assume we're fullscreen desktop */ + // Assume we're fullscreen desktop flags |= SDL_WINDOW_FULLSCREEN; } } @@ -314,8 +314,8 @@ Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwin X11_XFree(propertyValue); } - /* FIXME, check the size hints for resizable */ - /* flags |= SDL_WINDOW_RESIZABLE; */ + // FIXME, check the size hints for resizable + // flags |= SDL_WINDOW_RESIZABLE; return flags; } @@ -329,7 +329,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) int windowlistlength = videodata->windowlistlength; SDL_WindowData **windowlist = videodata->windowlist; - /* Allocate the window data */ + // Allocate the window data data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); if (!data) { return -1; @@ -348,7 +348,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) #endif data->videodata = videodata; - /* Associate the data with the window */ + // Associate the data with the window if (numwindows < windowlistlength) { windowlist[numwindows] = data; @@ -366,7 +366,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) videodata->windowlist = windowlist; } - /* Fill in the SDL window with the window data */ + // Fill in the SDL window with the window data { XWindowAttributes attrib; @@ -401,12 +401,12 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) } if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { - /* Tell x11 to clip mouse */ + // Tell x11 to clip mouse } } if (window->flags & SDL_WINDOW_EXTERNAL) { - /* Query the title from the existing window */ + // Query the title from the existing window window->title = X11_GetWindowTitle(_this, w); } @@ -416,7 +416,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_SCREEN_NUMBER, screen); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, data->xwindow); - /* All done! */ + // All done! window->internal = data; return 0; } @@ -441,7 +441,7 @@ static void SetupWindowInput(SDL_VideoDevice *_this, SDL_Window *window) X11_Xinput2SelectMouseAndKeyboard(_this, window); - /* If XInput2 can handle pointer and keyboard events, we don't track them here */ + // If XInput2 can handle pointer and keyboard events, we don't track them here if (data->xinput2_keyboard_enabled) { x11_keyboard_events = 0; } @@ -467,7 +467,7 @@ static void SetWindowBordered(Display *display, int screen, Window window, SDL_b Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { - /* Hints used by Motif compliant window managers */ + // Hints used by Motif compliant window managers struct { unsigned long flags; @@ -482,7 +482,7 @@ static void SetWindowBordered(Display *display, int screen, Window window, SDL_b 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 */ + } else { // set the transient hints instead, if necessary X11_XSetTransientForHint(display, window, RootWindow(display, screen)); } } @@ -597,12 +597,12 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); - /* If we can't create a colormap, then we must die */ + // If we can't create a colormap, then we must die if (!xattr.colormap) { return SDL_SetError("Could not create writable colormap"); } - /* OK, we got a colormap, now fill it in as best as we can */ + // OK, we got a colormap, now fill it in as best as we can colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); if (!colorcells) { return -1; @@ -633,7 +633,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI bmask >>= 1; } - /* build the color table pixel values */ + // build the color table pixel values for (i = 0; i < ncolors; i++) { Uint32 red = (rmax * i) / (ncolors - 1); Uint32 green = (gmax * i) / (ncolors - 1); @@ -701,7 +701,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } sizehints = X11_XAllocSizeHints(); - /* Setup the normal size hints */ + // Setup the normal size hints sizehints->flags = 0; if (!(window->flags & SDL_WINDOW_RESIZABLE)) { sizehints->min_width = sizehints->max_width = window->floating.w; @@ -714,24 +714,24 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI sizehints->flags |= USPosition; } - /* Setup the input hints so we get keyboard input */ + // Setup the input hints so we get keyboard input wmhints = X11_XAllocWMHints(); wmhints->input = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE) ? True : False; wmhints->window_group = data->window_group; wmhints->flags = InputHint | WindowGroupHint; - /* Setup the class hints so we can get an icon (AfterStep) */ + // Setup the class hints so we can get an icon (AfterStep) classhints = X11_XAllocClassHint(); classhints->res_name = (char *)SDL_GetExeName(); classhints->res_class = (char *)SDL_GetAppID(); - /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */ + // Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); X11_XFree(sizehints); X11_XFree(wmhints); X11_XFree(classhints); - /* Set the PID related to the window for the given hostname, if possible */ + // Set the PID related to the window for the given hostname, if possible if (data->pid > 0) { long pid = (long)data->pid; _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False); @@ -739,10 +739,10 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI (unsigned char *)&pid, 1); } - /* Set the window manager state */ + // 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 hint = SDL_GetHint(SDL_HINT_X11_WINDOW_TYPE); if (window->flags & SDL_WINDOW_UTILITY) { wintype_name = "_NET_WM_WINDOW_TYPE_UTILITY"; @@ -754,10 +754,10 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI 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. */ + // 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, @@ -773,12 +773,12 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI Atom protocols[3]; 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_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 - /* Default to using ping if there is no hint */ + // Default to using ping if there is no hint if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, SDL_TRUE)) { - protocols[proto_count++] = data->_NET_WM_PING; /* Respond so WM knows we're alive */ + protocols[proto_count++] = data->_NET_WM_PING; // Respond so WM knows we're alive } SDL_assert(proto_count <= sizeof(protocols) / sizeof(protocols[0])); @@ -792,7 +792,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } windowdata = window->internal; - /* Set the flag if the borders were forced on when creating a fullscreen window for later removal. */ + // Set the flag if the borders were forced on when creating a fullscreen window for later removal. windowdata->fullscreen_borders_forced_on = !!(window->pending_flags & SDL_WINDOW_FULLSCREEN) && !!(window->flags & SDL_WINDOW_BORDERLESS); @@ -809,7 +809,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return -1; } - /* Create the GLES window surface */ + // Create the GLES window surface windowdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)w); if (windowdata->egl_surface == EGL_NO_SURFACE) { @@ -817,12 +817,12 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } #else return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); -#endif /* SDL_VIDEO_OPENGL_EGL */ +#endif // SDL_VIDEO_OPENGL_EGL } #endif #ifdef SDL_VIDEO_DRIVER_X11_XSHAPE - /* Tooltips do not receive input */ + // Tooltips do not receive input if (window->flags & SDL_WINDOW_TOOLTIP) { Region region = X11_XCreateRegion(); X11_XShapeCombineRegion(display, w, ShapeInput, 0, 0, region, ShapeSet); @@ -832,7 +832,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI SetupWindowInput(_this, window); - /* For _ICC_PROFILE. */ + // For _ICC_PROFILE. X11_XSelectInput(display, RootWindow(display, screen), PropertyChangeMask); X11_XFlush(display); @@ -924,7 +924,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin if (force_exit || (window->x == data->expected.x + data->border_left && window->y == data->expected.y + data->border_top && window->w == data->expected.w && window->h == data->expected.h)) { - /* The window is in the expected state and nothing is pending. Done. */ + // The window is in the expected state and nothing is pending. Done. break; } @@ -935,7 +935,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin } if (SDL_GetTicksNS() >= timeout) { - /* Timed out without the expected values. Update the requested data so future sync calls won't block. */ + // Timed out without the expected values. Update the requested data so future sync calls won't block. data->expected.x = window->x; data->expected.y = window->y; data->expected.w = window->w; @@ -977,7 +977,7 @@ int X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i Uint32 *src; long *dst; - /* Set the _NET_WM_ICON property */ + // Set the _NET_WM_ICON property SDL_assert(icon->format == SDL_PIXELFORMAT_ARGB8888); propsize = 2 + (icon->w * icon->h); propdata = SDL_malloc(propsize * sizeof(long)); @@ -1031,19 +1031,19 @@ void X11_UpdateWindowPosition(SDL_Window *window, SDL_bool use_current_position) rel_x - data->border_left, rel_y - data->border_top, &data->expected.x, &data->expected.y); - /* Attempt to move the window */ + // Attempt to move the window data->pending_operation |= X11_PENDING_OP_MOVE; X11_XMoveWindow(display, data->xwindow, data->expected.x, data->expected.y); } int X11_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) { - /* Sync any pending fullscreen or maximize events. */ + // Sync any pending fullscreen or maximize events. if (window->internal->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MAXIMIZE)) { X11_SyncWindow(_this, window); } - /* Position will be set when window is de-maximized */ + // Position will be set when window is de-maximized if (window->flags & SDL_WINDOW_MAXIMIZED) { return 0; } @@ -1119,7 +1119,7 @@ void X11_SetWindowMinMax(SDL_Window *window, SDL_bool use_current) SDL_CalculateFraction(data->window->max_aspect, &sizehints->max_aspect.x, &sizehints->max_aspect.y); } } else { - /* Set the min/max to the same values to make the window non-resizable */ + // Set the min/max to the same values to make the window non-resizable sizehints->flags |= PMinSize | PMaxSize; sizehints->min_width = sizehints->max_width = use_current ? data->window->floating.w : window->windowed.w; sizehints->min_height = sizehints->max_height = use_current ? data->window->floating.h : window->windowed.h; @@ -1174,7 +1174,7 @@ void X11_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) X11_SyncWindow(_this, window); } - /* Don't try to resize a maximized or fullscreen window, it will be done on restore. */ + // Don't try to resize a maximized or fullscreen window, it will be done on restore. if (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) { return; } @@ -1291,7 +1291,7 @@ void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool X11_SyncWindow(_this, window); } - /* If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. */ + // If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { SetWindowBordered(display, displaydata->screen, data->xwindow, bordered); X11_XFlush(display); @@ -1308,19 +1308,19 @@ void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool } } - /* make sure these don't make it to the real event queue if they fired here. */ + // make sure these don't make it to the real event queue if they fired here. X11_XSync(display, False); X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); - /* Turning the borders off doesn't send an extent event, so they must be cleared here. */ + // Turning the borders off doesn't send an extent event, so they must be cleared here. X11_GetBorderValues(data); - /* Make sure the window manager didn't resize our window for the difference. */ + // Make sure the window manager didn't resize our window for the difference. X11_XResizeWindow(display, data->xwindow, window->floating.w, window->floating.h); X11_XSync(display, False); } else { - /* If fullscreen, set a flag to toggle the borders when returning to windowed mode. */ + // If fullscreen, set a flag to toggle the borders when returning to windowed mode. data->toggle_borders = SDL_TRUE; data->fullscreen_borders_forced_on = SDL_FALSE; } @@ -1334,7 +1334,7 @@ void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool X11_SyncWindow(_this, window); } - /* If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. */ + // If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { X11_SetWindowMinMax(window, SDL_TRUE); } @@ -1377,7 +1377,7 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) XEvent event; if (window->parent) { - /* Update our position in case our parent moved while we were hidden */ + // Update our position in case our parent moved while we were hidden X11_UpdateWindowPosition(window, SDL_TRUE); } @@ -1397,20 +1397,20 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) } if (!data->videodata->net_wm) { - /* no WM means no FocusIn event, which confuses us. Force it. */ + // no WM means no FocusIn event, which confuses us. Force it. X11_XSync(display, False); X11_XSetInputFocus(display, data->xwindow, RevertToNone, CurrentTime); X11_XFlush(display); } - /* Popup menus grab the keyboard */ + // Popup menus grab the keyboard if (window->flags & SDL_WINDOW_POPUP_MENU) { if (window->parent == SDL_GetKeyboardFocus()) { X11_SetKeyboardFocus(window); } } - /* Get some valid border values, if we haven't received them yet */ + // Get some valid border values, if we haven't received them yet if (data->border_left == 0 && data->border_right == 0 && data->border_top == 0 && data->border_bottom == 0) { X11_GetBorderValues(data); } @@ -1425,13 +1425,13 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) X11_XSync(display, False); X11_PumpEvents(_this); - /* If a configure event was received (type is non-zero), send the final window size and coordinates. */ + // If a configure event was received (type is non-zero), send the final window size and coordinates. if (data->last_xconfigure.type) { int x = data->last_xconfigure.x; int y = data->last_xconfigure.y; SDL_GlobalToRelativeForWindow(data->window, x, y, &x, &y); - /* If the borders appeared, this happened automatically in the event system, otherwise, set the position now. */ + // If the borders appeared, this happened automatically in the event system, otherwise, set the position now. if (data->disable_size_position_events && (window->x != x || window->y != y)) { data->pending_operation = X11_PENDING_OP_MOVE; X11_XMoveWindow(display, data->xwindow, window->x, window->y); @@ -1454,19 +1454,19 @@ void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) if (X11_IsWindowMapped(_this, window)) { X11_XWithdrawWindow(display, data->xwindow, screen); - /* Blocking wait for "UnmapNotify" event */ + // Blocking wait for "UnmapNotify" event if (!(window->flags & SDL_WINDOW_EXTERNAL)) { X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); } X11_XFlush(display); } - /* Transfer keyboard focus back to the parent */ + // Transfer keyboard focus back to the parent if (window->flags & SDL_WINDOW_POPUP_MENU) { if (window == SDL_GetKeyboardFocus()) { SDL_Window *new_focus = window->parent; - /* Find the highest level window that isn't being hidden or destroyed. */ + // Find the highest level window that isn't being hidden or destroyed. while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1491,14 +1491,14 @@ static int X11_SetWindowActive(SDL_VideoDevice *_this, SDL_Window *window) if (X11_IsWindowMapped(_this, window)) { XEvent e; - /*printf("SDL Window %p: sending _NET_ACTIVE_WINDOW with timestamp %lu\n", window, data->user_time);*/ + // printf("SDL Window %p: sending _NET_ACTIVE_WINDOW with timestamp %lu\n", window, data->user_time); SDL_zero(e); e.xany.type = ClientMessage; 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; @@ -1619,7 +1619,7 @@ void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) window->internal->pending_operation |= X11_PENDING_OP_RESTORE; } - /* If the window was minimized while maximized, restore as maximized. */ + // If the window was minimized while maximized, restore as maximized. const SDL_bool maximize = !!(window->flags & SDL_WINDOW_MINIMIZED) && window->internal->window_was_maximized; window->internal->window_was_maximized = SDL_FALSE; X11_SetWindowMaximized(_this, window, maximize); @@ -1627,7 +1627,7 @@ void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) X11_SetWindowActive(_this, window); } -/* This asks the Window Manager to handle fullscreen for us. This is the modern way. */ +// This asks the Window Manager to handle fullscreen for us. This is the modern way. static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *_display, SDL_FullscreenOp fullscreen) { CHECK_WINDOW_DATA(window); @@ -1642,17 +1642,17 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind if (X11_IsWindowMapped(_this, window)) { XEvent e; - /* Flush any pending fullscreen events. */ + // Flush any pending fullscreen events. if (data->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MAXIMIZE | X11_PENDING_OP_MOVE)) { X11_SyncWindow(_this, window); } if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (fullscreen == SDL_FULLSCREEN_OP_UPDATE) { - /* Request was out of date; set -1 to signal the video core to undo a mode switch. */ + // Request was out of date; set -1 to signal the video core to undo a mode switch. return -1; } else if (fullscreen == SDL_FULLSCREEN_OP_LEAVE) { - /* Nothing to do. */ + // Nothing to do. return 0; } } @@ -1663,7 +1663,7 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind XSizeHints *sizehints = X11_XAllocSizeHints(); long flags = 0; X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags); - /* we are going fullscreen so turn the flags off */ + // we are going fullscreen so turn the flags off sizehints->flags &= ~(PMinSize | PMaxSize | PAspect); X11_XSetWMNormalHints(display, data->xwindow, sizehints); X11_XFree(sizehints); @@ -1686,7 +1686,7 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind data->pending_operation |= X11_PENDING_OP_FULLSCREEN; } - /* Set the position so the window will be on the target display */ + // Set the position so the window will be on the target display if (fullscreen) { SDL_DisplayID current = SDL_GetDisplayForWindowPosition(window); SDL_copyp(&data->requested_fullscreen_mode, &window->current_fullscreen_mode); @@ -1698,7 +1698,7 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind data->expected.w = _display->current_mode->w; data->expected.h = _display->current_mode->h; - /* Only move the window if it isn't fullscreen or already on the target display. */ + // Only move the window if it isn't fullscreen or already on the target display. if (!(window->flags & SDL_WINDOW_FULLSCREEN) || (!current || current != _display->id)) { X11_XMoveWindow(display, data->xwindow, displaydata->x, displaydata->y); data->pending_operation |= X11_PENDING_OP_MOVE; @@ -1863,13 +1863,13 @@ int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool X11_XUngrabPointer(display, CurrentTime); } - /* Try to grab the mouse */ + // Try to grab the mouse if (!data->videodata->broken_pointer_grab) { const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask; int attempts; int result = 0; - /* Try for up to 5000ms (5s) to grab. If it still fails, stop trying. */ + // 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, False, mask, GrabModeAsync, GrabModeAsync, data->xwindow, None, CurrentTime); @@ -1881,13 +1881,13 @@ int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool } if (result != GrabSuccess) { - data->videodata->broken_pointer_grab = SDL_TRUE; /* don't try again. */ + data->videodata->broken_pointer_grab = SDL_TRUE; // don't try again. } } X11_Xinput2GrabTouch(_this, window); - /* Raise the window if we grab the mouse */ + // Raise the window if we grab the mouse X11_XRaiseWindow(display, data->xwindow); } else { X11_XUngrabPointer(display, CurrentTime); @@ -1965,18 +1965,18 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_free(data); #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - /* If the pointer barriers are active for this, deactivate it.*/ + // If the pointer barriers are active for this, deactivate it. if (videodata->active_cursor_confined_window == window) { X11_DestroyPointerBarrier(_this, window); } -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES } window->internal = NULL; } 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) @@ -2011,13 +2011,13 @@ int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati switch (operation) { case SDL_FLASH_CANCEL: - /* Taken care of above */ + // Taken care of above break; case SDL_FLASH_BRIEFLY: if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { wmhints->flags |= XUrgencyHint; data->flashing_window = SDL_TRUE; - /* On Ubuntu 21.04 this causes a dialog to pop up, so leave it up for a full second so users can see it */ + // On Ubuntu 21.04 this causes a dialog to pop up, so leave it up for a full second so users can see it data->flash_cancel_time = SDL_GetTicks() + 1000; } break; @@ -2050,10 +2050,10 @@ 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 */ + } else { // conv > 0 SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%d characters were not convertible to the current locale!", conv); return 0; } @@ -2088,9 +2088,9 @@ void X11_ShowWindowSystemMenu(SDL_Window *window, int x, int y) e.type = ClientMessage; e.window = data->xwindow; e.message_type = X11_XInternAtom(display, "_GTK_SHOW_WINDOW_MENU", 0); - e.data.l[0] = 0; /* GTK device ID (unused) */ - e.data.l[1] = wx; /* X coordinate relative to root */ - e.data.l[2] = wy; /* Y coordinate relative to root */ + e.data.l[0] = 0; // GTK device ID (unused) + e.data.l[1] = wx; // X coordinate relative to root + e.data.l[2] = wy; // Y coordinate relative to root e.format = 32; X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&e); @@ -2102,7 +2102,7 @@ int X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) const Uint64 current_time = SDL_GetTicksNS(); Uint64 timeout = 0; - /* Allow time for any pending mode switches to complete. */ + // Allow time for any pending mode switches to complete. for (int i = 0; i < _this->num_displays; ++i) { if (_this->displays[i]->internal->mode_switch_deadline_ns && current_time < _this->displays[i]->internal->mode_switch_deadline_ns) { @@ -2138,4 +2138,4 @@ int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool return 0; } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 5e4866766b..615ee9087c 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -47,7 +47,7 @@ struct SDL_WindowData Visual *visual; Colormap colormap; #ifndef NO_SHARED_MEMORY - /* MIT shared memory extension information */ + // MIT shared memory extension information SDL_bool use_mitshm; XShmSegmentInfo shminfo; #endif @@ -82,7 +82,7 @@ struct SDL_WindowData SDL_bool pointer_barrier_active; PointerBarrier barrier[4]; SDL_Rect barrier_rect; -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES SDL_Rect expected; SDL_DisplayMode requested_fullscreen_mode; @@ -145,4 +145,4 @@ int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title); void X11_UpdateWindowPosition(SDL_Window *window, SDL_bool use_current_position); void X11_SetWindowMinMax(SDL_Window *window, SDL_bool use_current); -#endif /* SDL_x11window_h_ */ +#endif // SDL_x11window_h_ diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index f101dd2f2f..1adcc63894 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -33,7 +33,7 @@ static int xfixes_selection_notify_event = 0; 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. */ + // 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; } @@ -58,17 +58,17 @@ void X11_InitXfixes(SDL_VideoDevice *_this) return; } - /* Selection tracking is available in all versions of XFixes */ + // Selection tracking is available in all versions of XFixes xfixes_selection_notify_event = event + XFixesSelectionNotify; X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), XA_CLIPBOARD, XFixesSetSelectionOwnerNotifyMask); X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask); - /* We need at least 5.0 for barriers. */ + // We need at least 5.0 for barriers. version = query_xfixes_version(data->display, 5, 0); if (!xfixes_version_atleast(version, 5, 0)) { - return; /* X server does not support the version we want at all. */ + return; // X server does not support the version we want at all. } xfixes_initialized = 1; @@ -92,7 +92,7 @@ int X11_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) if (window->flags & SDL_WINDOW_INPUT_FOCUS) { X11_ConfineCursorWithFlags(_this, window, &window->mouse_rect, 0); } else { - /* Save the state for when we get focus again */ + // Save the state for when we get focus again SDL_WindowData *wdata = window->internal; SDL_memcpy(&wdata->barrier_rect, &window->mouse_rect, sizeof(wdata->barrier_rect)); @@ -117,7 +117,7 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const return SDL_Unsupported(); } - /* If there is already a set of barriers active, disable them. */ + // 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); } @@ -146,7 +146,7 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const wdata->barrier_rect = *rect; } - /* Use the display bounds to ensure the barriers don't have corner gaps */ + // Use the display bounds to ensure the barriers don't have corner gaps SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &bounds); /** Create the left barrier */ @@ -176,7 +176,7 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const X11_XFlush(data->display); - /* Lets remember current active confined window. */ + // Lets remember current active confined window. data->active_cursor_confined_window = window; /* User activated the confinement for this window. We use this later to reactivate @@ -185,7 +185,7 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const } else { X11_DestroyPointerBarrier(_this, window); - /* Only set barrier inactive when user specified NULL and not handled by focus out. */ + // Only set barrier inactive when user specified NULL and not handled by focus out. if (flags != X11_BARRIER_HANDLED_BY_EVENT) { wdata->pointer_barrier_active = SDL_FALSE; } @@ -211,4 +211,4 @@ void X11_DestroyPointerBarrier(SDL_VideoDevice *_this, SDL_Window *window) data->active_cursor_confined_window = NULL; } -#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_DRIVER_X11_XFIXES diff --git a/src/video/x11/SDL_x11xfixes.h b/src/video/x11/SDL_x11xfixes.h index 7c2fa90585..098b97ad65 100644 --- a/src/video/x11/SDL_x11xfixes.h +++ b/src/video/x11/SDL_x11xfixes.h @@ -34,6 +34,6 @@ extern int X11_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rect, int flags); extern void X11_DestroyPointerBarrier(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GetXFixesSelectionNotifyEvent(void); -#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ +#endif // SDL_VIDEO_DRIVER_X11_XFIXES -#endif /* SDL_x11xfixes_h_ */ +#endif // SDL_x11xfixes_h_ diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 5470747d6b..67f8a410bd 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -67,7 +67,7 @@ static void parse_valuators(const double *input_values, const unsigned char *mas 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. */ + // 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; } @@ -115,9 +115,9 @@ static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, *out_y = (float)in_y; } } -#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */ +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH -#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */ +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) { @@ -140,22 +140,22 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) */ if (!SDL_X11_HAVE_XINPUT2 || !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { - return SDL_FALSE; /* X server does not have XInput at all */ + return SDL_FALSE; // X server does not have XInput at all } - /* We need at least 2.2 for Multitouch, 2.0 otherwise. */ + // We need at least 2.2 for Multitouch, 2.0 otherwise. version = query_xinput2_version(data->display, 2, 2); if (!xinput2_version_atleast(version, 2, 0)) { - return SDL_FALSE; /* X server does not support the version we want at all. */ + return SDL_FALSE; // X server does not support the version we want at all. } xinput2_initialized = 1; -#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH // Multitouch needs XInput 2.2 xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2); #endif - /* Enable raw motion events for this display */ + // Enable raw motion events for this display SDL_zero(eventmask); SDL_zeroa(mask); eventmask.deviceid = XIAllMasterDevices; @@ -167,7 +167,7 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) XISetMask(mask, XI_RawButtonRelease); #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - /* Enable raw touch events if supported */ + // Enable raw touch events if supported if (X11_Xinput2IsMultitouchSupported()) { XISetMask(mask, XI_RawTouchBegin); XISetMask(mask, XI_RawTouchUpdate); @@ -195,7 +195,7 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) } #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 -/* xi2 device went away? take it out of the list. */ +// xi2 device went away? take it out of the list. static void xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) { SDL_XInput2DeviceInfo *prev = NULL; @@ -218,7 +218,7 @@ static void xinput2_remove_device_info(SDL_VideoData *videodata, const int devic static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) { - /* cache device info as we see new devices. */ + // cache device info as we see new devices. SDL_XInput2DeviceInfo *prev = NULL; SDL_XInput2DeviceInfo *devinfo; XIDeviceInfo *xidevinfo; @@ -228,7 +228,7 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev) { /* move this to the front of the list, assuming we'll get more from this one. */ + if (prev) { // 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; @@ -238,7 +238,7 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, prev = devinfo; } - /* don't know about this device yet, query and cache it. */ + // don't know about this device yet, query and cache it. devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); if (!devinfo) { return NULL; @@ -329,14 +329,14 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) break; } - /* Relative mouse motion is delivered to the window with keyboard focus */ + // Relative mouse motion is delivered to the window with keyboard focus if (!SDL_GetKeyboardFocus()) { break; } devinfo = xinput2_get_device_info(videodata, rawev->deviceid); if (!devinfo) { - break; /* oh well. */ + break; // oh well. } parse_valuators(rawev->raw_values, rawev->valuators.mask, @@ -346,7 +346,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) if (devinfo->relative[i]) { processed_coords[i] = coords[i]; } else { - processed_coords[i] = devinfo->prev_coords[i] - coords[i]; /* convert absolute to relative */ + processed_coords[i] = devinfo->prev_coords[i] - coords[i]; // convert absolute to relative } } @@ -363,7 +363,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) XEvent xevent; if (xev->deviceid != xev->sourceid) { - /* Discard events from "Master" devices to avoid duplicates. */ + // Discard events from "Master" devices to avoid duplicates. break; } @@ -418,11 +418,11 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) SDL_SendPenButton(0, pen->pen, window, pressed ? SDL_PRESSED : SDL_RELEASED, button - 1); } } else { - /* Otherwise assume a regular mouse */ + // Otherwise assume a regular mouse SDL_WindowData *windowdata = xinput2_get_sdlwindowdata(videodata, xev->event); if (xev->deviceid != xev->sourceid) { - /* Discard events from "Master" devices to avoid duplicates. */ + // Discard events from "Master" devices to avoid duplicates. break; } @@ -449,7 +449,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) videodata->global_mouse_changed = SDL_TRUE; if (xev->deviceid != xev->sourceid) { - /* Discard events from "Master" devices to avoid duplicates. */ + // Discard events from "Master" devices to avoid duplicates. break; } @@ -505,9 +505,9 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); SDL_SendTouchMotion(0, xev->sourceid, xev->detail, window, x, y, 1.0); } break; -#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */ +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH } -#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */ +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 } void X11_InitXinput2Multitouch(SDL_VideoDevice *_this) @@ -566,7 +566,7 @@ SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *w eventmask.mask = mask; eventmask.deviceid = XIAllDevices; -/* This is not enabled by default because these events are only delivered to the window with mouse focus, not keyboard focus */ +// This is not enabled by default because these events are only delivered to the window with mouse focus, not keyboard focus #ifdef USE_XINPUT2_KEYBOARD XISetMask(mask, XI_KeyPress); XISetMask(mask, XI_KeyRelease); @@ -581,10 +581,10 @@ SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *w XISetMask(mask, XI_Enter); XISetMask(mask, XI_Leave); - /* Hotplugging: */ + // Hotplugging: XISetMask(mask, XI_DeviceChanged); XISetMask(mask, XI_HierarchyChanged); - XISetMask(mask, XI_PropertyEvent); /* E.g., when swapping tablet pens */ + XISetMask(mask, XI_PropertyEvent); // E.g., when swapping tablet pens if (X11_XISelectEvents(data->display, windowdata->xwindow, &eventmask, 1) != Success) { SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Could not enable XInput2 event handling\n"); @@ -665,7 +665,7 @@ static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) int new_count = (*count + 1); Uint32 *new_list = (Uint32 *)SDL_realloc(*list, new_count * sizeof(*new_list)); if (!new_list) { - /* Oh well, we'll drop this one */ + // Oh well, we'll drop this one return; } new_list[new_count - 1] = deviceID; @@ -689,7 +689,7 @@ static void AddDeviceID64(Uint64 deviceID, Uint64 **list, int *count) int new_count = (*count + 1); Uint64 *new_list = (Uint64 *)SDL_realloc(*list, new_count * sizeof(*new_list)); if (!new_list) { - /* Oh well, we'll drop this one */ + // Oh well, we'll drop this one return; } new_list[new_count - 1] = deviceID; @@ -773,7 +773,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check) XIAnyClassInfo *class = dev->classes[j]; XITouchClassInfo *t = (XITouchClassInfo *)class; - /* Only touch devices */ + // Only touch devices if (class->type != XITouchClass) { continue; } @@ -783,7 +783,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check) if (!HasDeviceID64(touchID, old_touch_devices, old_touch_count)) { if (t->mode == XIDependentTouch) { touchType = SDL_TOUCH_DEVICE_INDIRECT_RELATIVE; - } else { /* XIDirectTouch */ + } else { // XIDirectTouch touchType = SDL_TOUCH_DEVICE_DIRECT; } SDL_AddTouch(touchID, touchType, dev->name); @@ -822,4 +822,4 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check) #endif // SDL_VIDEO_DRIVER_X11_XINPUT2 } -#endif /* SDL_VIDEO_DRIVER_X11 */ +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index 71a0976a92..8f16525d8a 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -41,4 +41,4 @@ extern void X11_Xinput2UngrabTouch(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check); -#endif /* SDL_x11xinput2_h_ */ +#endif // SDL_x11xinput2_h_ diff --git a/src/video/x11/edid.h b/src/video/x11/edid.h index 37abbec631..2abc7085ac 100644 --- a/src/video/x11/edid.h +++ b/src/video/x11/edid.h @@ -84,9 +84,9 @@ struct MonitorInfo 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 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; @@ -120,11 +120,11 @@ struct MonitorInfo } 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; @@ -143,7 +143,7 @@ struct MonitorInfo double white_x; double white_y; - Timing established[24]; /* Terminated by 0x0x0 */ + Timing established[24]; // Terminated by 0x0x0 Timing standard[8]; int n_detailed_timings; @@ -155,10 +155,10 @@ struct MonitorInfo * bit. */ - /* Optional product description */ + // Optional product description char dsc_serial_number[14]; char dsc_product_name[14]; - char dsc_string[14]; /* Unspecified ASCII data */ + char dsc_string[14]; // Unspecified ASCII data }; MonitorInfo *decode_edid(const uchar *data);