diff --git a/src/SDL.c b/src/SDL.c index 5a1e0febe..6d7e16662 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -124,11 +124,11 @@ SDL_InitSubSystem(Uint32 flags) } #if SDL_VIDEO_DRIVER_WINDOWS - if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { - if (SDL_HelperWindowCreate() < 0) { - return -1; - } - } + if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { + if (SDL_HelperWindowCreate() < 0) { + return -1; + } + } #endif #if !SDL_TIMERS_DISABLED @@ -263,8 +263,8 @@ SDL_QuitSubSystem(Uint32 flags) #if !SDL_SENSOR_DISABLED if ((flags & SDL_INIT_SENSOR)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) { - SDL_SensorQuit(); - } + SDL_SensorQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR); } #endif diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 48b9c0cae..eff192b7e 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -445,7 +445,7 @@ static void ALSA_CloseDevice(_THIS) { if (this->hidden->pcm_handle) { - /* Wait for the submitted audio to drain + /* Wait for the submitted audio to drain ALSA_snd_pcm_drop() can hang, so don't use that. */ Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2; diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index 4e3ebf2ce..47bad4bd4 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -39,7 +39,7 @@ #include "SDL_name.h" #include "SDL_loadso.h" #else -#define SDL_NAME(X) X +#define SDL_NAME(X) X #endif #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 09b83aedf..a943ba29e 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -477,8 +477,8 @@ DSOUND_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) SDL_bool tried_format = SDL_FALSE; SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); LPGUID guid = (LPGUID) handle; - DWORD bufsize; - + DWORD bufsize; + /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); @@ -526,7 +526,7 @@ DSOUND_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) (int) (DSBSIZE_MAX / numchunks)); } else { int rc; - WAVEFORMATEX wfmt; + WAVEFORMATEX wfmt; SDL_zero(wfmt); if (SDL_AUDIO_ISFLOAT(this->spec.format)) { wfmt.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 1e9858063..053a1c34a 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -109,7 +109,7 @@ static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *, pa_stream_success_cb_t, void *); static int (*PULSEAUDIO_pa_stream_peek) (pa_stream *, const void **, size_t *); static int (*PULSEAUDIO_pa_stream_drop) (pa_stream *); -static pa_operation * (*PULSEAUDIO_pa_stream_flush) (pa_stream *, +static pa_operation * (*PULSEAUDIO_pa_stream_flush) (pa_stream *, pa_stream_success_cb_t, void *); static int (*PULSEAUDIO_pa_stream_disconnect) (pa_stream *); static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *); diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index 8e5c17ba1..20426f13a 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -78,7 +78,7 @@ static void DetectWave##typ##Devs(void) { \ capstyp##2W caps; \ UINT i; \ for (i = 0; i < devcount; i++) { \ - if (wave##typ##GetDevCaps(i,(LP##capstyp##W)&caps,sizeof(caps))==MMSYSERR_NOERROR) { \ + if (wave##typ##GetDevCaps(i,(LP##capstyp##W)&caps,sizeof(caps))==MMSYSERR_NOERROR) { \ char *name = WIN_LookupAudioDeviceName(caps.szPname,&caps.NameGuid); \ if (name != NULL) { \ SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i+1)); \ @@ -375,8 +375,7 @@ WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) #endif /* Create the audio buffer semaphore */ - this->hidden->audio_sem = - CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL); + this->hidden->audio_sem = CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL); if (this->hidden->audio_sem == NULL) { return SDL_SetError("Couldn't create semaphore"); } diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 91786042d..15a1a74f2 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -77,7 +77,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv* env, jclass jcls, jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jint format, jfloat rate); + jint deviceWidth, jint deviceHeight, jint format, jfloat rate); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)( JNIEnv* env, jclass jcls); @@ -537,7 +537,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv* env, jclass jcls, jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jint format, jfloat rate) + jint deviceWidth, jint deviceHeight, jint format, jfloat rate) { Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate); } diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index 062543d46..aa787f223 100644 --- a/src/core/linux/SDL_dbus.h +++ b/src/core/linux/SDL_dbus.h @@ -39,9 +39,8 @@ typedef struct SDL_DBusContext { void (*bus_add_match)(DBusConnection *, const char *, DBusError *); DBusConnection * (*connection_open_private)(const char *, DBusError *); void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t); - dbus_bool_t (*connection_get_is_connected)(DBusConnection *); - dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, - void *, DBusFreeFunction); + dbus_bool_t (*connection_get_is_connected)(DBusConnection *); + dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction); dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *, const DBusObjectPathVTable *, void *, DBusError *); dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *); @@ -51,7 +50,7 @@ typedef struct SDL_DBusContext { void (*connection_flush)(DBusConnection *); dbus_bool_t (*connection_read_write)(DBusConnection *, int); DBusDispatchStatus (*connection_dispatch)(DBusConnection *); - dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); + dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *); dbus_bool_t (*message_append_args)(DBusMessage *, int, ...); dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list); @@ -61,7 +60,7 @@ typedef struct SDL_DBusContext { dbus_bool_t (*message_iter_next)(DBusMessageIter *); void (*message_iter_get_basic)(DBusMessageIter *, void *); int (*message_iter_get_arg_type)(DBusMessageIter *); - void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); + void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); void (*message_unref)(DBusMessage *); void (*error_init)(DBusError *); dbus_bool_t (*error_is_set)(const DBusError *); diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index edf51870b..033a2998b 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -77,9 +77,9 @@ typedef struct SDL_UDEV_PrivateData const char *(*udev_device_get_action)(struct udev_device *); const char *(*udev_device_get_devnode)(struct udev_device *); const char *(*udev_device_get_subsystem)(struct udev_device *); - struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype); + struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype); const char *(*udev_device_get_property_value)(struct udev_device *, const char *); - const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr); + const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr); struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *); void (*udev_device_unref)(struct udev_device *); int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *); diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp index 9789d036f..7e2aac8a7 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -44,7 +44,7 @@ SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; #if WINAPI_FAMILY == WINAPI_FAMILY_APP extern "C" ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; -static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; +static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; #endif diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index baf85e58b..15a44a843 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -1027,7 +1027,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const } #ifdef __ANDROID__ if (!mapping && name && !SDL_IsJoystickHIDAPI(guid)) { - mapping = SDL_CreateMappingForAndroidController(name, guid); + mapping = SDL_CreateMappingForAndroidController(name, guid); } #endif if (!mapping) { diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index d274444fd..5dece76fc 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -1141,13 +1141,13 @@ SDL_IsJoystickSteamController(Uint16 vendor, Uint16 product) SDL_bool SDL_IsJoystickXbox360(Uint16 vendor, Uint16 product) { - /* Filter out some bogus values here */ - if (vendor == 0x0000 && product == 0x0000) { - return SDL_FALSE; - } - if (vendor == 0x0001 && product == 0x0001) { - return SDL_FALSE; - } + /* Filter out some bogus values here */ + if (vendor == 0x0000 && product == 0x0000) { + return SDL_FALSE; + } + if (vendor == 0x0001 && product == 0x0001) { + return SDL_FALSE; + } return (GuessControllerType(vendor, product) == k_eControllerType_XBox360Controller); } diff --git a/src/joystick/controller_type.h b/src/joystick/controller_type.h index b5a5193b9..26054edfa 100644 --- a/src/joystick/controller_type.h +++ b/src/joystick/controller_type.h @@ -43,9 +43,6 @@ typedef enum k_eControllerType_SteamController = 2, k_eControllerType_SteamControllerV2 = 3, - // IR Remote controls on Steambox - k_eControllerType_FrontPanelBoard = 20, - // Other Controllers k_eControllerType_UnknownNonSteamController = 30, k_eControllerType_XBox360Controller = 31, @@ -73,49 +70,6 @@ static inline bool BIsSteamController( EControllerType eType ) return ( eType == k_eControllerType_SteamController || eType == k_eControllerType_SteamControllerV2 ); } -#if 0 /* these are currently unused, so #if 0'd out to prevent compiler warnings for now */ -static inline bool BIsSteamHardwareDevice( EControllerType eType ) -{ - return ( eType == k_eControllerType_SteamController || eType == k_eControllerType_SteamControllerV2 || eType == k_eControllerType_FrontPanelBoard ); -} - -static inline bool BIsXInputController( EControllerType eType ) -{ - return ( eType == k_eControllerType_XBox360Controller || eType == k_eControllerType_XBoxOneController || eType == k_eControllerType_UnknownNonSteamController ); -} - -static inline bool BIsSwitchController( EControllerType eType ) -{ - return ( eType == k_eControllerType_SwitchJoyConLeft || eType == k_eControllerType_SwitchJoyConRight || - eType == k_eControllerType_SwitchJoyConPair || eType == k_eControllerType_SwitchProController || - eType == k_eControllerType_SwitchInputOnlyController ); -} - -/* XXX: this should be updated when we ship nintentdo switch controller support */ -static inline bool BIsRawHIDDevice( EControllerType eType ) -{ - return BIsSteamHardwareDevice( eType) || eType == k_eControllerType_PS4Controller || BIsSwitchController( eType ); -} - -// 'Full' here means that the controller has a full complement of buttons, joysticks, etc, as compared to -// the single Joy-Con's that only have around half of the controls that a normal controller has -static inline bool BIsFullSwitchController( EControllerType eType ) -{ - return ( eType == k_eControllerType_SwitchJoyConPair || eType == k_eControllerType_SwitchProController ); -} - -static inline bool BIsCompatibleType( EControllerType eTypeA, EControllerType eTypeB ) -{ - if ( BIsSteamController( eTypeA ) && BIsSteamController( eTypeB ) ) - return true; - if ( BIsXInputController( eTypeA ) && BIsXInputController( eTypeB ) ) - return true; - if ( eTypeA == eTypeB ) - return true; - return false; -} -#endif - #define MAKE_CONTROLLER_ID( nVID, nPID ) (unsigned int)( nVID << 16 | nPID ) typedef struct { @@ -168,7 +122,6 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x146b, 0x0603 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x044f, 0xb315 ), k_eControllerType_PS3Controller }, // Firestorm Dual Analog 3 { MAKE_CONTROLLER_ID( 0x0925, 0x8888 ), k_eControllerType_PS3Controller }, // Actually ps2 -maybe break out later Lakeview Research WiseGroup Ltd, MP-8866 Dual Joypad - { MAKE_CONTROLLER_ID( 0x146b, 0x0602 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x0f0d, 0x004d ), k_eControllerType_PS3Controller }, // Horipad 3 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0009 ), k_eControllerType_PS3Controller }, // HORI BDA GP1 { MAKE_CONTROLLER_ID( 0x0e8f, 0x0008 ), k_eControllerType_PS3Controller }, // Green Asia @@ -214,8 +167,8 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x1532, 0x1000 ), k_eControllerType_PS4Controller }, // Razer Raiju PS4 Controller { MAKE_CONTROLLER_ID( 0x1532, 0X0401 ), k_eControllerType_PS4Controller }, // Razer Panthera PS4 Controller { MAKE_CONTROLLER_ID( 0x054c, 0x05c5 ), k_eControllerType_PS4Controller }, // STRIKEPAD PS4 Grip Add-on - { MAKE_CONTROLLER_ID( 0x146b, 0x0d01 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller - { MAKE_CONTROLLER_ID( 0x146b, 0x0d02 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller v2 + { MAKE_CONTROLLER_ID( 0x146b, 0x0d01 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller - has gyro + { MAKE_CONTROLLER_ID( 0x146b, 0x0d02 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller v2 - has gyro { MAKE_CONTROLLER_ID( 0x0f0d, 0x00a0 ), k_eControllerType_PS4Controller }, // HORI TAC4 mousething { MAKE_CONTROLLER_ID( 0x0f0d, 0x009c ), k_eControllerType_PS4Controller }, // HORI TAC PRO mousething { MAKE_CONTROLLER_ID( 0x0c12, 0x0ef6 ), k_eControllerType_PS4Controller }, // Hitbox Arcade Stick @@ -224,7 +177,15 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0f0d, 0x00ee ), k_eControllerType_PS4Controller }, // Hori mini wired https://www.playstation.com/en-us/explore/accessories/gaming-controllers/mini-wired-gamepad/ { MAKE_CONTROLLER_ID( 0x0738, 0x8481 ), k_eControllerType_PS4Controller }, // Mad Catz FightStick TE 2+ PS4 { MAKE_CONTROLLER_ID( 0x0738, 0x8480 ), k_eControllerType_PS4Controller }, // Mad Catz FightStick TE 2 PS4 - { MAKE_CONTROLLER_ID( 0x7545, 0x0104 ), k_eControllerType_PS4Controller }, // Armor 3 or Level Up Cobra + { MAKE_CONTROLLER_ID( 0x7545, 0x0104 ), k_eControllerType_PS4Controller }, // Armor 3 or Level Up Cobra - At least one variant has gyro + { MAKE_CONTROLLER_ID( 0x0c12, 0x0e15 ), k_eControllerType_PS4Controller }, // Game:Pad 4 + { MAKE_CONTROLLER_ID( 0x11c0, 0x4001 ), k_eControllerType_PS4Controller }, // "PS4 Fun Controller" added from user log + + { MAKE_CONTROLLER_ID( 0x1532, 0x1007 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Tournament edition USB- untested and added for razer + { MAKE_CONTROLLER_ID( 0x1532, 0x100A ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Tournament edition BT - untested and added for razer + { MAKE_CONTROLLER_ID( 0x1532, 0x1004 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Ultimate USB - untested and added for razer + { MAKE_CONTROLLER_ID( 0x1532, 0x1009 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Ultimate BT - untested and added for razer + { MAKE_CONTROLLER_ID( 0x1532, 0x1008 ), k_eControllerType_PS4Controller }, // Razer Panthera Evo Fightstick - untested and added for razer { MAKE_CONTROLLER_ID( 0x056e, 0x2004 ), k_eControllerType_XBox360Controller }, // Elecom JC-U3613M { MAKE_CONTROLLER_ID( 0x06a3, 0xf51a ), k_eControllerType_XBox360Controller }, // Saitek P3600 @@ -400,32 +361,42 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0079, 0x187c ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x189c ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x1874 ), k_eControllerType_XBox360Controller }, // Unknown Controller + + { MAKE_CONTROLLER_ID( 0x1038, 0xb360 ), k_eControllerType_XBox360Controller }, // SteelSeries Nimbus/Stratus XL + //{ MAKE_CONTROLLER_ID( 0x1949, 0x0402 ), /*android*/ }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x05ac, 0x0001 ), k_eControllerType_AppleController }, // MFI Extended Gamepad (generic entry for iOS/tvOS) { MAKE_CONTROLLER_ID( 0x05ac, 0x0002 ), k_eControllerType_AppleController }, // MFI Standard Gamepad (generic entry for iOS/tvOS) - { MAKE_CONTROLLER_ID( 0x1038, 0xb360 ), k_eControllerType_AppleController }, // SteelSeries Nimbus // We currently don't support using a pair of Switch Joy-Con's as a single // controller and we don't want to support using them individually for the // time being, so these should be disabled until one of the above is true // { MAKE_CONTROLLER_ID( 0x057e, 0x2006 ), k_eControllerType_SwitchJoyConLeft }, // Nintendo Switch Joy-Con (Left) // { MAKE_CONTROLLER_ID( 0x057e, 0x2007 ), k_eControllerType_SwitchJoyConRight }, // Nintendo Switch Joy-Con (Right) + + // This same controller ID is spoofed by many 3rd-party Switch controllers. + // The ones we currently know of are: + // * Any 8bitdo controller with Switch support + // * ORTZ Gaming Wireless Pro Controller + // * ZhiXu Gamepad Wireless + // * Sunwaytek Wireless Motion Controller for Nintendo Switch { MAKE_CONTROLLER_ID( 0x057e, 0x2009 ), k_eControllerType_SwitchProController }, // Nintendo Switch Pro Controller + { MAKE_CONTROLLER_ID( 0x0f0d, 0x00c1 ), k_eControllerType_SwitchInputOnlyController }, // HORIPAD for Nintendo Switch { MAKE_CONTROLLER_ID( 0x20d6, 0xa711 ), k_eControllerType_SwitchInputOnlyController }, // PowerA Wired Controller Plus + { MAKE_CONTROLLER_ID( 0x0f0d, 0x0092 ), k_eControllerType_SwitchInputOnlyController }, // HORI Pokken Tournament DX Pro Pad // Valve products - don't add to public list - { MAKE_CONTROLLER_ID( 0x0000, 0x11fa ), k_eControllerType_MobileTouch }, // Streaming mobile touch virtual controls + { MAKE_CONTROLLER_ID( 0x0000, 0x11fb ), k_eControllerType_MobileTouch }, // Streaming mobile touch virtual controls { MAKE_CONTROLLER_ID( 0x28de, 0x1101 ), k_eControllerType_SteamController }, // Valve Legacy Steam Controller (CHELL) { MAKE_CONTROLLER_ID( 0x28de, 0x1102 ), k_eControllerType_SteamController }, // Valve wired Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1105 ), k_eControllerType_SteamControllerV2 }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1106 ), k_eControllerType_SteamControllerV2 }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1142 ), k_eControllerType_SteamController }, // Valve wireless Steam Controller { MAKE_CONTROLLER_ID( 0x28de, 0x1201 ), k_eControllerType_SteamController }, // Valve wired Steam Controller (HEADCRAB) - { MAKE_CONTROLLER_ID( 0x28de, 0x1202 ), k_eControllerType_SteamControllerV2 }, // Valve Bluetooth Steam Controller (HEADCRAB) }; diff --git a/src/joystick/haiku/SDL_haikujoystick.cc b/src/joystick/haiku/SDL_haikujoystick.cc index 30f919ca8..b3b0467f1 100644 --- a/src/joystick/haiku/SDL_haikujoystick.cc +++ b/src/joystick/haiku/SDL_haikujoystick.cc @@ -36,7 +36,7 @@ extern "C" /* The maximum number of joysticks we'll detect */ -#define MAX_JOYSTICKS 16 +#define MAX_JOYSTICKS 16 /* A list of available joysticks */ static char *SDL_joyport[MAX_JOYSTICKS]; diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 4ae17cc8e..ebd15a810 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -255,7 +255,7 @@ SDL_JoystickThread(void *_data) /* WM_DEVICECHANGE not working, no XINPUT, no point in keeping thread alive */ break; #endif /* SDL_JOYSTICK_XINPUT */ - } + } if (s_bWindowsDeviceChanged || bXInputChanged) { s_bDeviceRemoved = SDL_TRUE; diff --git a/src/main/haiku/SDL_BApp.h b/src/main/haiku/SDL_BApp.h index 3c4167535..7adbd007d 100644 --- a/src/main/haiku/SDL_BApp.h +++ b/src/main/haiku/SDL_BApp.h @@ -198,7 +198,7 @@ public: _current_context->UnlockGL(); _current_context = newContext; if (_current_context) - _current_context->LockGL(); + _current_context->LockGL(); } #endif diff --git a/src/main/haiku/SDL_BeApp.cc b/src/main/haiku/SDL_BeApp.cc index f4ee17951..cbd21293b 100644 --- a/src/main/haiku/SDL_BeApp.cc +++ b/src/main/haiku/SDL_BeApp.cc @@ -31,7 +31,7 @@ #include #include -#include "SDL_BApp.h" /* SDL_BApp class definition */ +#include "SDL_BApp.h" /* SDL_BApp class definition */ #include "SDL_BeApp.h" #include "SDL_timer.h" #include "SDL_error.h" @@ -53,24 +53,24 @@ StartBeApp(void *unused) { BApplication *App; - // default application signature - const char *signature = "application/x-SDL-executable"; - // dig resources for correct signature - image_info info; - int32 cookie = 0; - if (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { - BFile f(info.name, O_RDONLY); - if (f.InitCheck() == B_OK) { - BAppFileInfo app_info(&f); - if (app_info.InitCheck() == B_OK) { - char sig[B_MIME_TYPE_LENGTH]; - if (app_info.GetSignature(sig) == B_OK) - signature = strndup(sig, B_MIME_TYPE_LENGTH); - } - } - } + // default application signature + const char *signature = "application/x-SDL-executable"; + // dig resources for correct signature + image_info info; + int32 cookie = 0; + if (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + BFile f(info.name, O_RDONLY); + if (f.InitCheck() == B_OK) { + BAppFileInfo app_info(&f); + if (app_info.InitCheck() == B_OK) { + char sig[B_MIME_TYPE_LENGTH]; + if (app_info.GetSignature(sig) == B_OK) + signature = strndup(sig, B_MIME_TYPE_LENGTH); + } + } + } - App = new SDL_BApp(signature); + App = new SDL_BApp(signature); App->Run(); delete App; @@ -144,12 +144,12 @@ SDL_QuitBeApp(void) /* SDL_BApp functions */ void SDL_BApp::ClearID(SDL_BWin *bwin) { - _SetSDLWindow(NULL, bwin->GetID()); - int32 i = _GetNumWindowSlots() - 1; - while(i >= 0 && GetSDLWindow(i) == NULL) { - _PopBackWindow(); - --i; - } + _SetSDLWindow(NULL, bwin->GetID()); + int32 i = _GetNumWindowSlots() - 1; + while(i >= 0 && GetSDLWindow(i) == NULL) { + _PopBackWindow(); + --i; + } } #endif /* __HAIKU__ */ diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index f8dbc9fa7..e2e3a3f86 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -89,13 +89,13 @@ SDL_iconv(SDL_iconv_t cd, #else /* Lots of useful information on Unicode at: - http://www.cl.cam.ac.uk/~mgk25/unicode.html + http://www.cl.cam.ac.uk/~mgk25/unicode.html */ -#define UNICODE_BOM 0xFEFF +#define UNICODE_BOM 0xFEFF -#define UNKNOWN_ASCII '?' -#define UNKNOWN_UNICODE 0xFFFD +#define UNKNOWN_ASCII '?' +#define UNKNOWN_UNICODE 0xFFFD enum { @@ -115,13 +115,13 @@ enum ENCODING_UCS4LE, }; #if SDL_BYTEORDER == SDL_BIG_ENDIAN -#define ENCODING_UTF16NATIVE ENCODING_UTF16BE -#define ENCODING_UTF32NATIVE ENCODING_UTF32BE +#define ENCODING_UTF16NATIVE ENCODING_UTF16BE +#define ENCODING_UTF32NATIVE ENCODING_UTF32BE #define ENCODING_UCS2NATIVE ENCODING_UCS2BE #define ENCODING_UCS4NATIVE ENCODING_UCS4BE #else -#define ENCODING_UTF16NATIVE ENCODING_UTF16LE -#define ENCODING_UTF32NATIVE ENCODING_UTF32LE +#define ENCODING_UTF16NATIVE ENCODING_UTF16LE +#define ENCODING_UTF32NATIVE ENCODING_UTF32LE #define ENCODING_UCS2NATIVE ENCODING_UCS2LE #define ENCODING_UCS4NATIVE ENCODING_UCS4LE #endif diff --git a/src/video/SDL_blit_1.c b/src/video/SDL_blit_1.c index b7c5412ee..56ccf15fc 100644 --- a/src/video/SDL_blit_1.c +++ b/src/video/SDL_blit_1.c @@ -49,13 +49,13 @@ Blit1to1(SDL_BlitInfo * info) while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ - DUFFS_LOOP( - { - *dst = map[*src]; - } - dst++; - src++; - , width); + DUFFS_LOOP( + { + *dst = map[*src]; + } + dst++; + src++; + , width); /* *INDENT-ON* */ #else for (c = width; c; --c) { @@ -72,11 +72,11 @@ Blit1to1(SDL_BlitInfo * info) /* This is now endian dependent */ #ifndef USE_DUFFS_LOOP # if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) -# define HI 1 -# define LO 0 +# define HI 1 +# define LO 0 # else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ -# define HI 0 -# define LO 1 +# define HI 0 +# define LO 1 # endif #endif static void @@ -101,14 +101,14 @@ Blit1to2(SDL_BlitInfo * info) #ifdef USE_DUFFS_LOOP while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - *(Uint16 *)dst = map[*src++]; - dst += 2; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + *(Uint16 *)dst = map[*src++]; + dst += 2; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -208,18 +208,18 @@ Blit1to3(SDL_BlitInfo * info) while (height--) { #ifdef USE_DUFFS_LOOP - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - o = *src * 4; - dst[0] = map[o++]; - dst[1] = map[o++]; - dst[2] = map[o++]; - } - src++; - dst += 3; - , width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + o = *src * 4; + dst[0] = map[o++]; + dst[1] = map[o++]; + dst[2] = map[o++]; + } + src++; + dst += 3; + , width); + /* *INDENT-ON* */ #else for (c = width; c; --c) { o = *src * 4; @@ -257,11 +257,11 @@ Blit1to4(SDL_BlitInfo * info) while (height--) { #ifdef USE_DUFFS_LOOP - /* *INDENT-OFF* */ - DUFFS_LOOP( - *dst++ = map[*src++]; - , width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + *dst++ = map[*src++]; + , width); + /* *INDENT-ON* */ #else for (c = width / 4; c; --c) { *dst++ = map[*src++]; @@ -297,33 +297,33 @@ Blit1to1Key(SDL_BlitInfo * info) if (palmap) { while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - *dst = palmap[*src]; - } - dst++; - src++; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + *dst = palmap[*src]; + } + dst++; + src++; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } } else { while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - *dst = *src; - } - dst++; - src++; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + *dst = *src; + } + dst++; + src++; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -346,17 +346,17 @@ Blit1to2Key(SDL_BlitInfo * info) dstskip /= 2; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - *dstp=palmap[*src]; - } - src++; - dstp++; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + *dstp=palmap[*src]; + } + src++; + dstp++; + }, + width); + /* *INDENT-ON* */ src += srcskip; dstp += dstskip; } @@ -376,20 +376,20 @@ Blit1to3Key(SDL_BlitInfo * info) int o; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - o = *src * 4; - dst[0] = palmap[o++]; - dst[1] = palmap[o++]; - dst[2] = palmap[o++]; - } - src++; - dst += 3; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + o = *src * 4; + dst[0] = palmap[o++]; + dst[1] = palmap[o++]; + dst[2] = palmap[o++]; + } + src++; + dst += 3; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -411,17 +411,17 @@ Blit1to4Key(SDL_BlitInfo * info) dstskip /= 4; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - *dstp = palmap[*src]; - } - src++; - dstp++; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + *dstp = palmap[*src]; + } + src++; + dstp++; + }, + width); + /* *INDENT-ON* */ src += srcskip; dstp += dstskip; } @@ -489,22 +489,22 @@ Blit1toNAlphaKey(SDL_BlitInfo * info) dstbpp = dstfmt->BytesPerPixel; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - if ( *src != ckey ) { - sR = srcpal[*src].r; - sG = srcpal[*src].g; - sB = srcpal[*src].b; - DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); - ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); - ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); - } - src++; - dst += dstbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + if ( *src != ckey ) { + sR = srcpal[*src].r; + sG = srcpal[*src].g; + sB = srcpal[*src].b; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src++; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 1e9c9d89b..350793294 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -45,28 +45,28 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info) const unsigned A = info->a; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4( - { - DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); - dR = dstfmt->palette->colors[*dst].r; - dG = dstfmt->palette->colors[*dst].g; - dB = dstfmt->palette->colors[*dst].b; - ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); - dR &= 0xff; - dG &= 0xff; - dB &= 0xff; - /* Pack RGB into 8bit pixel */ - if ( palmap == NULL ) { - *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)); - } else { - *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; - } - dst++; - src += srcbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + dR = dstfmt->palette->colors[*dst].r; + dG = dstfmt->palette->colors[*dst].g; + dB = dstfmt->palette->colors[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + /* Pack RGB into 8bit pixel */ + if ( palmap == NULL ) { + *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)); + } else { + *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -91,28 +91,28 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info) unsigned dR, dG, dB; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4( - { - DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); - dR = dstfmt->palette->colors[*dst].r; - dG = dstfmt->palette->colors[*dst].g; - dB = dstfmt->palette->colors[*dst].b; - ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB); - dR &= 0xff; - dG &= 0xff; - dB &= 0xff; - /* Pack RGB into 8bit pixel */ - if ( palmap == NULL ) { - *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)); - } else { - *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; - } - dst++; - src += srcbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4( + { + DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); + dR = dstfmt->palette->colors[*dst].r; + dG = dstfmt->palette->colors[*dst].g; + dB = dstfmt->palette->colors[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + /* Pack RGB into 8bit pixel */ + if ( palmap == NULL ) { + *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)); + } else { + *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -139,30 +139,30 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) const unsigned A = info->a; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP( - { - DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); - if ( Pixel != ckey ) { - dR = dstfmt->palette->colors[*dst].r; - dG = dstfmt->palette->colors[*dst].g; - dB = dstfmt->palette->colors[*dst].b; - ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); - dR &= 0xff; - dG &= 0xff; - dB &= 0xff; - /* Pack RGB into 8bit pixel */ - if ( palmap == NULL ) { + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + if ( Pixel != ckey ) { + dR = dstfmt->palette->colors[*dst].r; + dG = dstfmt->palette->colors[*dst].g; + dB = dstfmt->palette->colors[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + /* Pack RGB into 8bit pixel */ + if ( palmap == NULL ) { *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)); - } else { + } else { *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; - } - } - dst++; - src += srcbpp; - }, - width); - /* *INDENT-ON* */ + } + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -342,45 +342,45 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = 0x00FF; - multmask <<= (ashift * 2); - multmask2 = 0x00FF00FF00FF00FFULL; + multmask <<= (ashift * 2); + multmask2 = 0x00FF00FF00FF00FFULL; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 alpha = *srcp & amask; - if (alpha == 0) { - /* do nothing */ - } else if (alpha == amask) { - *dstp = *srcp; - } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ - src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 alpha = *srcp & amask; + if (alpha == 0) { + /* do nothing */ + } else if (alpha == amask) { + *dstp = *srcp; + } else { + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ + src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ - dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ + dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ - mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ - mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ - mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ - mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ - mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ + mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ + mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ - /* blend */ - src1 = _mm_mullo_pi16(src1, mm_alpha); - src1 = _mm_srli_pi16(src1, 8); - dst1 = _mm_mullo_pi16(dst1, mm_alpha2); - dst1 = _mm_srli_pi16(dst1, 8); - dst1 = _mm_add_pi16(src1, dst1); - dst1 = _mm_packs_pu16(dst1, mm_zero); - - *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ - } - ++srcp; - ++dstp; - }, width); - /* *INDENT-ON* */ + /* blend */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); + + *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ + } + ++srcp; + ++dstp; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -401,14 +401,14 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) int dstskip = info->dst_skip >> 2; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 s = *srcp++; - Uint32 d = *dstp; - *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) - + (s & d & 0x00010101)) | 0xff000000; - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + + (s & d & 0x00010101)) | 0xff000000; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -434,22 +434,22 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) Uint32 d1; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - s = *srcp; - d = *dstp; - s1 = s & 0xff00ff; - d1 = d & 0xff00ff; - d1 = (d1 + ((s1 - d1) * alpha >> 8)) - & 0xff00ff; - s &= 0xff00; - d &= 0xff00; - d = (d + ((s - d) * alpha >> 8)) & 0xff00; - *dstp = d1 | d | 0xff000000; - ++srcp; - ++dstp; - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + s = *srcp; + d = *dstp; + s1 = s & 0xff00ff; + d1 = d & 0xff00ff; + d1 = (d1 + ((s1 - d1) * alpha >> 8)) + & 0xff00ff; + s &= 0xff00; + d &= 0xff00; + d = (d + ((s - d) * alpha >> 8)) & 0xff00; + *dstp = d1 | d | 0xff000000; + ++srcp; + ++dstp; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -468,42 +468,42 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) int dstskip = info->dst_skip >> 2; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 dalpha; - Uint32 d; - Uint32 s1; - Uint32 d1; - Uint32 s = *srcp; - Uint32 alpha = s >> 24; - /* 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? - Benchmark this! */ - if (alpha) { - if (alpha == SDL_ALPHA_OPAQUE) { - *dstp = *srcp; - } else { - /* - * take out the middle component (green), and process - * the other two in parallel. One multiply less. - */ - d = *dstp; - dalpha = d >> 24; - s1 = s & 0xff00ff; - d1 = d & 0xff00ff; - d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; - s &= 0xff00; - d &= 0xff00; - d = (d + ((s - d) * alpha >> 8)) & 0xff00; - dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8); - *dstp = d1 | d | (dalpha << 24); - } - } - ++srcp; - ++dstp; - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 dalpha; + Uint32 d; + Uint32 s1; + Uint32 d1; + Uint32 s = *srcp; + Uint32 alpha = s >> 24; + /* 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? + Benchmark this! */ + if (alpha) { + if (alpha == SDL_ALPHA_OPAQUE) { + *dstp = *srcp; + } else { + /* + * take out the middle component (green), and process + * the other two in parallel. One multiply less. + */ + d = *dstp; + dalpha = d >> 24; + s1 = s & 0xff00ff; + d1 = d & 0xff00ff; + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; + s &= 0xff00; + d &= 0xff00; + d = (d + ((s - d) * alpha >> 8)) & 0xff00; + dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8); + *dstp = d1 | d | (dalpha << 24); + } + } + ++srcp; + ++dstp; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -533,47 +533,47 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) multmask2 = 0x00FF00FF00FF00FFULL; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 alpha; + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 alpha; - _m_prefetch(srcp + 16); - _m_prefetch(dstp + 16); + _m_prefetch(srcp + 16); + _m_prefetch(dstp + 16); - alpha = *srcp & amask; - if (alpha == 0) { - /* do nothing */ - } else if (alpha == amask) { - *dstp = *srcp; - } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ - src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ + alpha = *srcp & amask; + if (alpha == 0) { + /* do nothing */ + } else if (alpha == amask) { + *dstp = *srcp; + } else { + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ + src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ - dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ + dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ - mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ - mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ - mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ - mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ - mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ + mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ + mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ - /* blend */ - src1 = _mm_mullo_pi16(src1, mm_alpha); - src1 = _mm_srli_pi16(src1, 8); - dst1 = _mm_mullo_pi16(dst1, mm_alpha2); - dst1 = _mm_srli_pi16(dst1, 8); - dst1 = _mm_add_pi16(src1, dst1); - dst1 = _mm_packs_pu16(dst1, mm_zero); - - *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ - } - ++srcp; - ++dstp; - }, width); - /* *INDENT-ON* */ + /* blend */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); + + *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ + } + ++srcp; + ++dstp; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -585,13 +585,13 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) /* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */ /* blend a single 16 bit pixel at 50% */ -#define BLEND16_50(d, s, mask) \ - ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) +#define BLEND16_50(d, s, mask) \ + ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) /* blend two 16 bit pixels at 50% */ -#define BLEND2x16_50(d, s, mask) \ - (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ - + (s & d & (~(mask | mask << 16)))) +#define BLEND2x16_50(d, s, mask) \ + (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ + + (s & d & (~(mask | mask << 16)))) static void Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) @@ -727,103 +727,103 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP_124( - { - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x07e0f81f; - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp++ = (Uint16)(d | d >> 16); - },{ - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x07e0f81f; - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp++ = (Uint16)(d | d >> 16); - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x07e0f81f; - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp++ = (Uint16)(d | d >> 16); - },{ - src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ - dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ + /* *INDENT-OFF* */ + DUFFS_LOOP_124( + { + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ + dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ - /* red */ - src2 = src1; - src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 [000r 000r 000r 000r] */ + /* red */ + src2 = src1; + 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 = dst1; + dst2 = _mm_srli_pi16(dst2, 11); /* dst2 >> 11 -> dst2 [000r 000r 000r 000r] */ - /* 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 */ + /* 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 */ - mm_res = dst2; /* RED -> mm_res */ + mm_res = dst2; /* RED -> mm_res */ - /* green -- process the bits in place */ - src2 = src1; - src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ + /* green -- process the bits in place */ + src2 = src1; + src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ - dst2 = dst1; - dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ + dst2 = dst1; + dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ - /* 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 */ + /* 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 */ - 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; - src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ + /* blue */ + src2 = src1; + 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 = dst1; + dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ - /* 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 */ + /* 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 */ - 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* */ + srcp += 4; + dstp += 4; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -865,103 +865,103 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP_124( - { - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x03e07c1f; - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp++ = (Uint16)(d | d >> 16); - },{ - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x03e07c1f; - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp++ = (Uint16)(d | d >> 16); - s = *srcp++; - d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x03e07c1f; - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp++ = (Uint16)(d | d >> 16); - },{ - src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ - dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ + /* *INDENT-OFF* */ + DUFFS_LOOP_124( + { + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ + dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ - /* red -- process the bits in place */ - src2 = src1; - src2 = _mm_and_si64(src2, rmask); /* src & MASKRED -> src2 */ + /* red -- process the bits in place */ + src2 = src1; + src2 = _mm_and_si64(src2, rmask); /* src & MASKRED -> src2 */ - dst2 = dst1; - dst2 = _mm_and_si64(dst2, rmask); /* dst & MASKRED -> dst2 */ + dst2 = dst1; + dst2 = _mm_and_si64(dst2, rmask); /* dst & MASKRED -> dst2 */ - /* 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 */ + /* 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 */ - mm_res = dst2; /* RED -> mm_res */ - - /* green -- process the bits in place */ - src2 = src1; - src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ + mm_res = dst2; /* RED -> mm_res */ + + /* green -- process the bits in place */ + src2 = src1; + src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ - dst2 = dst1; - dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ + dst2 = dst1; + dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ - /* 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 */ + /* 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 */ - 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 */ - 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 */ + /* 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 */ - 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* */ + srcp += 4; + dstp += 4; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -988,22 +988,22 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info) alpha >>= 3; /* downscale alpha to 5 bits */ while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 s = *srcp++; - Uint32 d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x07e0f81f; - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp++ = (Uint16)(d | d >> 16); - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -1027,22 +1027,22 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info) alpha >>= 3; /* downscale alpha to 5 bits */ while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 s = *srcp++; - Uint32 d = *dstp; - /* - * shift out the middle component (green) to - * the high 16 bits, and process all three RGB - * components at the same time. - */ - s = (s | s << 16) & 0x03e07c1f; - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp++ = (Uint16)(d | d >> 16); - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -1061,35 +1061,35 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info) int dstskip = info->dst_skip >> 1; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - Uint32 s = *srcp; - 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? - Benchmark this! */ - if(alpha) { - if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { - *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f)); - } else { - Uint32 d = *dstp; - /* - * convert source and destination to G0RAB65565 - * and blend all components at the same time - */ - s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) - + (s >> 3 & 0x1f); - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp = (Uint16)(d | d >> 16); - } - } - srcp++; - dstp++; - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + Uint32 s = *srcp; + 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? + Benchmark this! */ + if(alpha) { + if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { + *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f)); + } else { + Uint32 d = *dstp; + /* + * convert source and destination to G0RAB65565 + * and blend all components at the same time + */ + s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) + + (s >> 3 & 0x1f); + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp = (Uint16)(d | d >> 16); + } + } + srcp++; + dstp++; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -1107,36 +1107,36 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info) int dstskip = info->dst_skip >> 1; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4({ - unsigned alpha; - Uint32 s = *srcp; - 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? - Benchmark this! */ - if(alpha) { - if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { - *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f)); - } else { - Uint32 d = *dstp; - /* - * convert source and destination to G0RAB65565 - * and blend all components at the same time - */ - s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) - + (s >> 3 & 0x1f); - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp = (Uint16)(d | d >> 16); - } - } - srcp++; - dstp++; - }, width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4({ + unsigned alpha; + Uint32 s = *srcp; + 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? + Benchmark this! */ + if(alpha) { + if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { + *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f)); + } else { + Uint32 d = *dstp; + /* + * convert source and destination to G0RAB65565 + * and blend all components at the same time + */ + s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) + + (s >> 3 & 0x1f); + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp = (Uint16)(d | d >> 16); + } + } + srcp++; + dstp++; + }, width); + /* *INDENT-ON* */ srcp += srcskip; dstp += dstskip; } @@ -1163,18 +1163,18 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) if (sA) { while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4( - { - DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); - DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); - ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); - ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); - src += srcbpp; - dst += dstbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -1202,21 +1202,21 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) const unsigned sA = info->a; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4( - { - RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); - if(sA && Pixel != ckey) { - RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); - DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); - ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); - ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); - } - src += srcbpp; - dst += dstbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4( + { + RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); + if(sA && Pixel != ckey) { + RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } @@ -1245,20 +1245,20 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info) dstbpp = dstfmt->BytesPerPixel; while (height--) { - /* *INDENT-OFF* */ - DUFFS_LOOP4( - { - DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); - if(sA) { - DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); - ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); - ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); - } - src += srcbpp; - dst += dstbpp; - }, - width); - /* *INDENT-ON* */ + /* *INDENT-OFF* */ + DUFFS_LOOP4( + { + DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); + if(sA) { + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ src += srcskip; dst += dstskip; } diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 96f02cd1c..c3b437608 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -836,7 +836,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) /* max 2 values plus terminator. */ EGLint attribs[3]; int attr = 0; - + EGLSurface * surface; if (SDL_EGL_ChooseConfig(_this) != 0) { @@ -868,7 +868,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) return EGL_NO_SURFACE; } } - + attribs[attr++] = EGL_NONE; surface = _this->egl_data->eglCreateWindowSurface( diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 2e263955c..c2e41632f 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -326,7 +326,7 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, if (Rmask == 0) { return SDL_PIXELFORMAT_RGB555; } - /* fallthrough */ + /* fallthrough */ case 16: if (Rmask == 0) { return SDL_PIXELFORMAT_RGB565; diff --git a/src/video/SDL_shape_internals.h b/src/video/SDL_shape_internals.h index 3af175cdf..49a8786a1 100644 --- a/src/video/SDL_shape_internals.h +++ b/src/video/SDL_shape_internals.h @@ -36,21 +36,21 @@ extern "C" { #endif typedef struct { - struct SDL_ShapeTree *upleft,*upright,*downleft,*downright; + struct SDL_ShapeTree *upleft,*upright,*downleft,*downright; } SDL_QuadTreeChildren; typedef union { - SDL_QuadTreeChildren children; - SDL_Rect shape; + SDL_QuadTreeChildren children; + SDL_Rect shape; } SDL_ShapeUnion; typedef enum { QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind; typedef struct { - SDL_ShapeKind kind; - SDL_ShapeUnion data; + SDL_ShapeKind kind; + SDL_ShapeUnion data; } SDL_ShapeTree; - + typedef void(*SDL_TraversalFunction)(SDL_ShapeTree*,void*); extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ae6fee9c7..336fdaa50 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1540,11 +1540,12 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) return NULL; } - // Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation, - // but it's important or window focus will get broken on windows! + /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation, + * but it's important or window focus will get broken on windows! + */ #if !defined(__WIN32__) - if (window->flags & SDL_WINDOW_MINIMIZED) { - window->flags &= ~SDL_WINDOW_MINIMIZED; + if (window->flags & SDL_WINDOW_MINIMIZED) { + window->flags &= ~SDL_WINDOW_MINIMIZED; } #endif diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c index d4cbed4d9..1b242f132 100644 --- a/src/video/SDL_vulkan_utils.c +++ b/src/video/SDL_vulkan_utils.c @@ -123,10 +123,10 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( { retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null } - else - { - retval = SDL_calloc(count, sizeof(VkExtensionProperties)); - } + else + { + retval = SDL_calloc(count, sizeof(VkExtensionProperties)); + } if(!retval) { SDL_OutOfMemory(); diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index 50910a5f7..7c1e6b467 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -89,10 +89,10 @@ static SDL_bool IsPacked4Format(Uint32 format) } static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, int yuv_pitch, - const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride) + const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride) { - const Uint8 *planes[3] = { NULL, NULL, NULL }; - int pitches[3] = { 0, 0, 0 }; + const Uint8 *planes[3] = { NULL, NULL, NULL }; + int pitches[3] = { 0, 0, 0 }; switch (format) { case SDL_PIXELFORMAT_YV12: @@ -180,10 +180,10 @@ static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, i static SDL_bool yuv_rgb_sse( Uint32 src_format, Uint32 dst_format, - Uint32 width, Uint32 height, - const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, - Uint8 *rgb, Uint32 rgb_stride, - YCbCrType yuv_type) + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) { #ifdef __SSE2__ if (!SDL_HasSSE2()) { @@ -289,10 +289,10 @@ static SDL_bool yuv_rgb_sse( static SDL_bool yuv_rgb_std( Uint32 src_format, Uint32 dst_format, - Uint32 width, Uint32 height, - const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, - Uint8 *rgb, Uint32 rgb_stride, - YCbCrType yuv_type) + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) { if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) { @@ -395,7 +395,7 @@ SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch) { - const Uint8 *y = NULL; + const Uint8 *y = NULL; const Uint8 *u = NULL; const Uint8 *v = NULL; Uint32 y_stride = 0; @@ -553,7 +553,7 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr Uint32 y_stride, uv_stride, y_skip, uv_skip; GetYUVPlanes(width, height, dst_format, dst, dst_pitch, - (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, + (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, &y_stride, &uv_stride); plane_interleaved_uv = (plane_y + height * y_stride); y_skip = (y_stride - width); diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 3cf5040b8..589461afb 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -214,12 +214,12 @@ Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * h void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate) { - SDL_VideoDevice* device; - SDL_VideoDisplay *display; + SDL_VideoDevice* device; + SDL_VideoDisplay *display; Android_SurfaceWidth = surfaceWidth; Android_SurfaceHeight = surfaceHeight; - Android_DeviceWidth = deviceWidth; - Android_DeviceHeight = deviceHeight; + Android_DeviceWidth = deviceWidth; + Android_DeviceHeight = deviceHeight; Android_ScreenFormat = format; Android_ScreenRate = rate; diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 38f4ba676..76d235e3b 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -390,8 +390,8 @@ Cocoa_RegisterApp(void) if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - } - + } + if ([NSApp mainMenu] == nil) { CreateApplicationMenus(); } diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index f28b74362..8b7a697a4 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -39,7 +39,7 @@ /* Return a Metal-compatible layer. */ + (Class)layerClass { - return NSClassFromString(@"CAMetalLayer"); + return NSClassFromString(@"CAMetalLayer"); } /* Indicate the view wants to draw using a backing layer instead of drawRect. */ @@ -59,7 +59,7 @@ - (instancetype)initWithFrame:(NSRect)frame scale:(CGFloat)scale { - if ((self = [super initWithFrame:frame])) { + if ((self = [super initWithFrame:frame])) { _tag = METALVIEW_TAG; self.wantsLayer = YES; @@ -71,7 +71,7 @@ self.layer.contentsScale = scale; } - return self; + return self; } /* Set the size of the metal drawables when the view is resized. */ diff --git a/src/video/cocoa/SDL_cocoamousetap.m b/src/video/cocoa/SDL_cocoamousetap.m index 3c4fcf23e..05a7d77d8 100644 --- a/src/video/cocoa/SDL_cocoamousetap.m +++ b/src/video/cocoa/SDL_cocoamousetap.m @@ -211,7 +211,7 @@ Cocoa_InitMouseEventTap(SDL_MouseData* driverdata) tapdata->thread = SDL_CreateThreadInternal(&Cocoa_MouseTapThread, "Event Tap Loop", 512 * 1024, tapdata); if (tapdata->thread) { /* Success - early out. Ownership transferred to thread. */ - return; + return; } CFRelease(tapdata->tap); } diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 0cf7ec335..71ff8db1b 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -241,7 +241,7 @@ ScheduleContextUpdates(SDL_WindowData *data) static int GetHintCtrlClickEmulateRightClick() { - return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); } static NSUInteger @@ -908,7 +908,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) switch ([theEvent buttonNumber]) { case 0: if (([theEvent modifierFlags] & NSEventModifierFlagControl) && - GetHintCtrlClickEmulateRightClick()) { + GetHintCtrlClickEmulateRightClick()) { wasCtrlLeft = YES; button = SDL_BUTTON_RIGHT; } else { diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index e253c584b..8740ce111 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -324,7 +324,7 @@ static const struct { { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */ { DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */ { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */ - { DSPF_ABGR, SDL_PIXELFORMAT_ABGR8888 }, /* 32 bit ABGR (4 byte, alpha 8@24, blue 8@16, green 8@8, red 8@0) */ + { DSPF_ABGR, SDL_PIXELFORMAT_ABGR8888 }, /* 32 bit ABGR (4 byte, alpha 8@24, blue 8@16, green 8@8, red 8@0) */ #if (ENABLE_LUT8) { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */ #endif diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index b38554011..b22f74b25 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -538,7 +538,7 @@ private: msg.AddInt32("key-state", keyState); msg.AddInt32("key-scancode", keyCode); if (keyUtf8 != NULL) { - msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len); + msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len); } be_app->PostMessage(&msg); } diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index 0727fd177..3138603d8 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -36,54 +36,54 @@ extern "C" { #endif int HAIKU_SetClipboardText(_THIS, const char *text) { - BMessage *clip = NULL; - if(be_clipboard->Lock()) { - be_clipboard->Clear(); - if((clip = be_clipboard->Data())) { - /* 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); - be_clipboard->Commit(); - } - be_clipboard->Unlock(); - } - return 0; + BMessage *clip = NULL; + if(be_clipboard->Lock()) { + be_clipboard->Clear(); + if((clip = be_clipboard->Data())) { + /* 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); + be_clipboard->Commit(); + } + be_clipboard->Unlock(); + } + return 0; } char *HAIKU_GetClipboardText(_THIS) { - BMessage *clip = NULL; - const char *text = NULL; - ssize_t length; - char *result; - if(be_clipboard->Lock()) { - if((clip = be_clipboard->Data())) { - /* Presumably the string of characters is ascii-format */ - clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, - &length); - } - be_clipboard->Unlock(); - } - - if (!text) { - result = SDL_strdup(""); - } else { - /* Copy the data and pass on to SDL */ - result = (char *)SDL_malloc((length + 1) * sizeof(char)); - SDL_strlcpy(result, text, length + 1); - } - - return result; + BMessage *clip = NULL; + const char *text = NULL; + ssize_t length; + char *result; + if(be_clipboard->Lock()) { + if((clip = be_clipboard->Data())) { + /* Presumably the string of characters is ascii-format */ + clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, + &length); + } + be_clipboard->Unlock(); + } + + if (!text) { + result = SDL_strdup(""); + } else { + /* Copy the data and pass on to SDL */ + result = (char *)SDL_malloc((length + 1) * sizeof(char)); + SDL_strlcpy(result, text, length + 1); + } + + return result; } SDL_bool HAIKU_HasClipboardText(_THIS) { - SDL_bool result = SDL_FALSE; - char *text = HAIKU_GetClipboardText(_this); - if (text) { - result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; - SDL_free(text); - } - return result; + SDL_bool result = SDL_FALSE; + char *text = HAIKU_GetClipboardText(_this); + if (text) { + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } #ifdef __cplusplus diff --git a/src/video/haiku/SDL_bevents.cc b/src/video/haiku/SDL_bevents.cc index e3884d3da..c918ab243 100644 --- a/src/video/haiku/SDL_bevents.cc +++ b/src/video/haiku/SDL_bevents.cc @@ -29,7 +29,7 @@ extern "C" { #endif void HAIKU_PumpEvents(_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 diff --git a/src/video/haiku/SDL_bframebuffer.cc b/src/video/haiku/SDL_bframebuffer.cc index 848d7352e..967570612 100644 --- a/src/video/haiku/SDL_bframebuffer.cc +++ b/src/video/haiku/SDL_bframebuffer.cc @@ -40,158 +40,158 @@ static int32 HAIKU_UpdateOnce(SDL_Window *window); #endif static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { - return ((SDL_BWin*)(window->driverdata)); + return ((SDL_BWin*)(window->driverdata)); } static SDL_INLINE SDL_BApp *_GetBeApp() { - return ((SDL_BApp*)be_app); + return ((SDL_BApp*)be_app); } int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) { - SDL_BWin *bwin = _ToBeWin(window); - BScreen bscreen; - if(!bscreen.IsValid()) { - return -1; - } + SDL_BWin *bwin = _ToBeWin(window); + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } - while(!bwin->Connected()) { snooze(100); } - - /* Make sure we have exclusive access to frame buffer data */ - bwin->LockBuffer(); + while(!bwin->Connected()) { snooze(100); } + + /* Make sure we have exclusive access to frame buffer data */ + bwin->LockBuffer(); - /* format */ - display_mode bmode; - bscreen.GetMode(&bmode); - int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space); - *format = HAIKU_BPPToSDLPxFormat(bpp); + /* format */ + display_mode bmode; + bscreen.GetMode(&bmode); + int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space); + *format = HAIKU_BPPToSDLPxFormat(bpp); - /* Create the new bitmap object */ - BBitmap *bitmap = bwin->GetBitmap(); + /* 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 */ - - if(bitmap->InitCheck() != B_OK) { - delete bitmap; - return SDL_SetError("Could not initialize back buffer!"); - } + if(bitmap) { + delete bitmap; + } + bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space, + false, /* Views not accepted */ + true); /* Contiguous memory required */ + + if(bitmap->InitCheck() != B_OK) { + delete bitmap; + return SDL_SetError("Could not initialize back buffer!"); + } - bwin->SetBitmap(bitmap); - - /* Set the pixel pointer */ - *pixels = bitmap->Bits(); + bwin->SetBitmap(bitmap); + + /* Set the pixel pointer */ + *pixels = bitmap->Bits(); - /* pitch = width of window, in bytes */ - *pitch = bitmap->BytesPerRow(); + /* pitch = width of window, in bytes */ + *pitch = bitmap->BytesPerRow(); - bwin->SetBufferExists(true); - bwin->SetTrashBuffer(false); - bwin->UnlockBuffer(); - return 0; + bwin->SetBufferExists(true); + bwin->SetTrashBuffer(false); + bwin->UnlockBuffer(); + return 0; } int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) { - if(!window) - return 0; + if(!window) + return 0; - SDL_BWin *bwin = _ToBeWin(window); + SDL_BWin *bwin = _ToBeWin(window); -#ifdef DRAWTHREAD - bwin->LockBuffer(); - bwin->SetBufferDirty(true); - bwin->UnlockBuffer(); +#ifdef DRAWTHREAD + bwin->LockBuffer(); + bwin->SetBufferDirty(true); + bwin->UnlockBuffer(); #else - bwin->SetBufferDirty(true); - HAIKU_UpdateOnce(window); + bwin->SetBufferDirty(true); + HAIKU_UpdateOnce(window); #endif - return 0; + return 0; } int32 HAIKU_DrawThread(void *data) { - SDL_BWin *bwin = (SDL_BWin*)data; - - BScreen bscreen; - if(!bscreen.IsValid()) { - return -1; - } + SDL_BWin *bwin = (SDL_BWin*)data; + + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } - while(bwin->ConnectionEnabled()) { - if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) { - bwin->LockBuffer(); - BBitmap *bitmap = NULL; - bitmap = bwin->GetBitmap(); - int32 windowPitch = bitmap->BytesPerRow(); - int32 bufferPitch = bwin->GetRowBytes(); - uint8 *windowpx; - uint8 *bufferpx; + while(bwin->ConnectionEnabled()) { + if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) { + bwin->LockBuffer(); + BBitmap *bitmap = NULL; + bitmap = bwin->GetBitmap(); + int32 windowPitch = bitmap->BytesPerRow(); + int32 bufferPitch = bwin->GetRowBytes(); + uint8 *windowpx; + uint8 *bufferpx; - int32 BPP = bwin->GetBytesPerPx(); - int32 windowSub = bwin->GetFbX() * BPP + - bwin->GetFbY() * windowPitch; - clipping_rect *clips = bwin->GetClips(); - int32 numClips = bwin->GetNumClips(); - int i, y; + int32 BPP = bwin->GetBytesPerPx(); + int32 windowSub = bwin->GetFbX() * BPP + + bwin->GetFbY() * windowPitch; + clipping_rect *clips = bwin->GetClips(); + int32 numClips = bwin->GetNumClips(); + int i, y; - /* Blit each clipping rectangle */ - bscreen.WaitForRetrace(); - for(i = 0; i < numClips; ++i) { - /* Get addresses of the start of each clipping rectangle */ - int32 width = clips[i].right - clips[i].left + 1; - int32 height = clips[i].bottom - clips[i].top + 1; - bufferpx = bwin->GetBufferPx() + - clips[i].top * bufferPitch + clips[i].left * BPP; - windowpx = (uint8*)bitmap->Bits() + - clips[i].top * windowPitch + clips[i].left * BPP - - windowSub; + /* Blit each clipping rectangle */ + bscreen.WaitForRetrace(); + for(i = 0; i < numClips; ++i) { + /* Get addresses of the start of each clipping rectangle */ + int32 width = clips[i].right - clips[i].left + 1; + int32 height = clips[i].bottom - clips[i].top + 1; + bufferpx = bwin->GetBufferPx() + + clips[i].top * bufferPitch + clips[i].left * BPP; + windowpx = (uint8*)bitmap->Bits() + + clips[i].top * windowPitch + clips[i].left * BPP - + windowSub; - /* Copy each row of pixels from the window buffer into the frame - buffer */ - for(y = 0; y < height; ++y) - { + /* Copy each row of pixels from the window buffer into the frame + buffer */ + for(y = 0; y < height; ++y) + { - if(bwin->CanTrashWindowBuffer()) { - goto escape; /* Break out before the buffer is killed */ - } + if(bwin->CanTrashWindowBuffer()) { + goto escape; /* Break out before the buffer is killed */ + } - memcpy(bufferpx, windowpx, width * BPP); - bufferpx += bufferPitch; - windowpx += windowPitch; - } - } + memcpy(bufferpx, windowpx, width * BPP); + bufferpx += bufferPitch; + windowpx += windowPitch; + } + } - bwin->SetBufferDirty(false); + bwin->SetBufferDirty(false); escape: - bwin->UnlockBuffer(); - } else { - snooze(16000); - } - } - - return B_OK; + bwin->UnlockBuffer(); + } else { + snooze(16000); + } + } + + return B_OK; } void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) { - SDL_BWin *bwin = _ToBeWin(window); - - bwin->LockBuffer(); - - /* Free and clear the window buffer */ - BBitmap *bitmap = bwin->GetBitmap(); - delete bitmap; - bwin->SetBitmap(NULL); - bwin->SetBufferExists(false); - bwin->UnlockBuffer(); + SDL_BWin *bwin = _ToBeWin(window); + + bwin->LockBuffer(); + + /* Free and clear the window buffer */ + BBitmap *bitmap = bwin->GetBitmap(); + delete bitmap; + bwin->SetBitmap(NULL); + bwin->SetBufferExists(false); + bwin->UnlockBuffer(); } @@ -203,50 +203,50 @@ void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) { */ #ifndef DRAWTHREAD static int32 HAIKU_UpdateOnce(SDL_Window *window) { - SDL_BWin *bwin = _ToBeWin(window); - BScreen bscreen; - if(!bscreen.IsValid()) { - return -1; - } + SDL_BWin *bwin = _ToBeWin(window); + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } - if(bwin->ConnectionEnabled() && bwin->Connected()) { - bwin->LockBuffer(); - int32 windowPitch = window->surface->pitch; - int32 bufferPitch = bwin->GetRowBytes(); - uint8 *windowpx; - uint8 *bufferpx; + if(bwin->ConnectionEnabled() && bwin->Connected()) { + bwin->LockBuffer(); + int32 windowPitch = window->surface->pitch; + int32 bufferPitch = bwin->GetRowBytes(); + uint8 *windowpx; + uint8 *bufferpx; - int32 BPP = bwin->GetBytesPerPx(); - uint8 *windowBaseAddress = (uint8*)window->surface->pixels; - int32 windowSub = bwin->GetFbX() * BPP + - bwin->GetFbY() * windowPitch; - clipping_rect *clips = bwin->GetClips(); - int32 numClips = bwin->GetNumClips(); - int i, y; + int32 BPP = bwin->GetBytesPerPx(); + uint8 *windowBaseAddress = (uint8*)window->surface->pixels; + int32 windowSub = bwin->GetFbX() * BPP + + bwin->GetFbY() * windowPitch; + clipping_rect *clips = bwin->GetClips(); + int32 numClips = bwin->GetNumClips(); + int i, y; - /* Blit each clipping rectangle */ - bscreen.WaitForRetrace(); - for(i = 0; i < numClips; ++i) { - /* Get addresses of the start of each clipping rectangle */ - int32 width = clips[i].right - clips[i].left + 1; - int32 height = clips[i].bottom - clips[i].top + 1; - bufferpx = bwin->GetBufferPx() + - clips[i].top * bufferPitch + clips[i].left * BPP; - windowpx = windowBaseAddress + - clips[i].top * windowPitch + clips[i].left * BPP - windowSub; + /* Blit each clipping rectangle */ + bscreen.WaitForRetrace(); + for(i = 0; i < numClips; ++i) { + /* Get addresses of the start of each clipping rectangle */ + int32 width = clips[i].right - clips[i].left + 1; + int32 height = clips[i].bottom - clips[i].top + 1; + bufferpx = bwin->GetBufferPx() + + clips[i].top * bufferPitch + clips[i].left * BPP; + windowpx = windowBaseAddress + + clips[i].top * windowPitch + clips[i].left * BPP - windowSub; - /* Copy each row of pixels from the window buffer into the frame - buffer */ - for(y = 0; y < height; ++y) - { - memcpy(bufferpx, windowpx, width * BPP); - bufferpx += bufferPitch; - windowpx += windowPitch; - } - } - bwin->UnlockBuffer(); - } - return 0; + /* Copy each row of pixels from the window buffer into the frame + buffer */ + for(y = 0; y < height; ++y) + { + memcpy(bufferpx, windowpx, width * BPP); + bufferpx += bufferPitch; + windowpx += windowPitch; + } + } + bwin->UnlockBuffer(); + } + return 0; } #endif diff --git a/src/video/haiku/SDL_bkeyboard.cc b/src/video/haiku/SDL_bkeyboard.cc index d12d238cd..9a8b9a4a9 100644 --- a/src/video/haiku/SDL_bkeyboard.cc +++ b/src/video/haiku/SDL_bkeyboard.cc @@ -42,143 +42,143 @@ static SDL_Scancode keymap[KEYMAP_SIZE]; static int8 keystate[KEYMAP_SIZE]; void HAIKU_InitOSKeymap(void) { - for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) { - keymap[i] = SDL_SCANCODE_UNKNOWN; - } + for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) { + keymap[i] = SDL_SCANCODE_UNKNOWN; + } - for( uint i = 0; i < KEYMAP_SIZE; ++i ) { - keystate[i] = SDL_RELEASED; - } + for( uint i = 0; i < KEYMAP_SIZE; ++i ) { + keystate[i] = SDL_RELEASED; + } - keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE); - keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1); - keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2); - keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3); - keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4); - keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5); - keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6); - keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7); - keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8); - keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9); - keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10); - keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11); - keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12); - keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN); - keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK); - keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE); - keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE); - keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1); - keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2); - keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3); - keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4); - keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5); - keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6); - keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7); - keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8); - keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9); - keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0); - keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS); - keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS); - keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE); - keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT); - keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME); - keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP); - keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR); - keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE); - keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY); - keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS); - keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB); - keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q); - keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w); - keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e); - keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r); - keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t); - keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y); - keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u); - keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i); - keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o); - keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p); - keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET); - keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET); - keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH); - keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE); - keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END); - keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN); - keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7); - keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8); - keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9); - keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS); - keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK); - keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a); - keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s); - keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d); - keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f); - keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g); - keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h); - keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j); - keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k); - keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l); - keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON); - keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE); - keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN); - keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4); - keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5); - keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6); - keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT); - keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z); - keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x); - keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c); - keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v); - keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b); - keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n); - keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m); - keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA); - keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD); - keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH); - keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT); - keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP); - keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1); - keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2); - keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3); - keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER); - keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL); - keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT); - keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE); - keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT); - keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL); - keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT); - keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN); - keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT); - keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0); - keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD); - keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI); - keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI); - keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU); - keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */ - keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS); - keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER); + keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE); + keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1); + keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2); + keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3); + keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4); + keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5); + keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6); + keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7); + keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8); + keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9); + keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10); + keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11); + keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12); + keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN); + keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK); + keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE); + keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE); + keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1); + keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2); + keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3); + keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4); + keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5); + keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6); + keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7); + keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8); + keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9); + keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0); + keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS); + keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS); + keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE); + keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT); + keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME); + keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP); + keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR); + keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE); + keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY); + keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS); + keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB); + keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q); + keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w); + keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e); + keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r); + keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t); + keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y); + keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u); + keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i); + keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o); + keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p); + keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET); + keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET); + keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH); + keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE); + keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END); + keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN); + keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7); + keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8); + keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9); + keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS); + keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK); + keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a); + keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s); + keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d); + keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f); + keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g); + keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h); + keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j); + keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k); + keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l); + keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON); + keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE); + keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN); + keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4); + keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5); + keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6); + keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT); + keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z); + keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x); + keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c); + keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v); + keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b); + keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n); + keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m); + keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA); + keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD); + keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH); + keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT); + keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP); + keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1); + keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2); + keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3); + keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER); + keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL); + keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT); + keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE); + keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT); + keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL); + keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT); + keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN); + keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT); + keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0); + keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD); + keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI); + keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI); + keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU); + keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */ + keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS); + keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER); } SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) { - if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) { - return keymap[bkey]; - } else { - return SDL_SCANCODE_UNKNOWN; - } + if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) { + return keymap[bkey]; + } else { + return SDL_SCANCODE_UNKNOWN; + } } int8 HAIKU_GetKeyState(int32 bkey) { - if(bkey > 0 && bkey < KEYMAP_SIZE) { - return keystate[bkey]; - } else { - return SDL_RELEASED; - } + if(bkey > 0 && bkey < KEYMAP_SIZE) { + return keystate[bkey]; + } else { + return SDL_RELEASED; + } } void HAIKU_SetKeyState(int32 bkey, int8 state) { - if(bkey > 0 && bkey < KEYMAP_SIZE) { - keystate[bkey] = state; - } + if(bkey > 0 && bkey < KEYMAP_SIZE) { + keystate[bkey] = state; + } } #ifdef __cplusplus diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc index 1d8682115..9d7199673 100644 --- a/src/video/haiku/SDL_bmodes.cc +++ b/src/video/haiku/SDL_bmodes.cc @@ -44,30 +44,30 @@ extern "C" { /* This wrapper is here so that the driverdata can be freed without freeing the display_mode structure */ struct SDL_DisplayModeData { - display_mode *bmode; + display_mode *bmode; }; #endif static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { - return ((SDL_BWin*)(window->driverdata)); + return ((SDL_BWin*)(window->driverdata)); } static SDL_INLINE SDL_BApp *_GetBeApp() { - return ((SDL_BApp*)be_app); + return ((SDL_BApp*)be_app); } static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) { #if WRAP_BMODE - return ((SDL_DisplayModeData*)mode->driverdata)->bmode; + return ((SDL_DisplayModeData*)mode->driverdata)->bmode; #else - return (display_mode*)(mode->driverdata); + return (display_mode*)(mode->driverdata); #endif } /* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */ static float get_refresh_rate(display_mode &mode) { - return float(mode.timing.pixel_clock * 1000) - / float(mode.timing.h_total * mode.timing.v_total); + return float(mode.timing.pixel_clock * 1000) + / float(mode.timing.h_total * mode.timing.v_total); } @@ -76,57 +76,57 @@ static float get_refresh_rate(display_mode &mode) { * This is a useful debugging tool. Uncomment and insert into code as needed. */ void _SpoutModeData(display_mode *bmode) { - printf("BMode:\n"); - printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height); - printf("\th,v = (%i,%i)\n", bmode->h_display_start, - bmode->v_display_start); - if(bmode->flags) { - printf("\tFlags:\n"); - if(bmode->flags & B_SCROLL) { - printf("\t\tB_SCROLL\n"); - } - if(bmode->flags & B_8_BIT_DAC) { - printf("\t\tB_8_BIT_DAC\n"); - } - if(bmode->flags & B_HARDWARE_CURSOR) { - printf("\t\tB_HARDWARE_CURSOR\n"); - } - if(bmode->flags & B_PARALLEL_ACCESS) { - printf("\t\tB_PARALLEL_ACCESS\n"); - } - if(bmode->flags & B_DPMS) { - printf("\t\tB_DPMS\n"); - } - if(bmode->flags & B_IO_FB_NA) { - printf("\t\tB_IO_FB_NA\n"); - } - } - printf("\tTiming:\n"); - printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock); - printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n", - bmode->timing.h_display, bmode->timing.h_sync_start, - bmode->timing.h_sync_end, bmode->timing.h_total); - printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n", - bmode->timing.v_display, bmode->timing.v_sync_start, - bmode->timing.v_sync_end, bmode->timing.v_total); - if(bmode->timing.flags) { - printf("\t\tFlags:\n"); - if(bmode->timing.flags & B_BLANK_PEDESTAL) { - printf("\t\t\tB_BLANK_PEDESTAL\n"); - } - if(bmode->timing.flags & B_TIMING_INTERLACED) { - printf("\t\t\tB_TIMING_INTERLACED\n"); - } - if(bmode->timing.flags & B_POSITIVE_HSYNC) { - printf("\t\t\tB_POSITIVE_HSYNC\n"); - } - if(bmode->timing.flags & B_POSITIVE_VSYNC) { - printf("\t\t\tB_POSITIVE_VSYNC\n"); - } - if(bmode->timing.flags & B_SYNC_ON_GREEN) { - printf("\t\t\tB_SYNC_ON_GREEN\n"); - } - } + printf("BMode:\n"); + printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height); + printf("\th,v = (%i,%i)\n", bmode->h_display_start, + bmode->v_display_start); + if(bmode->flags) { + printf("\tFlags:\n"); + if(bmode->flags & B_SCROLL) { + printf("\t\tB_SCROLL\n"); + } + if(bmode->flags & B_8_BIT_DAC) { + printf("\t\tB_8_BIT_DAC\n"); + } + if(bmode->flags & B_HARDWARE_CURSOR) { + printf("\t\tB_HARDWARE_CURSOR\n"); + } + if(bmode->flags & B_PARALLEL_ACCESS) { + printf("\t\tB_PARALLEL_ACCESS\n"); + } + if(bmode->flags & B_DPMS) { + printf("\t\tB_DPMS\n"); + } + if(bmode->flags & B_IO_FB_NA) { + printf("\t\tB_IO_FB_NA\n"); + } + } + printf("\tTiming:\n"); + printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock); + printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.h_display, bmode->timing.h_sync_start, + bmode->timing.h_sync_end, bmode->timing.h_total); + printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.v_display, bmode->timing.v_sync_start, + bmode->timing.v_sync_end, bmode->timing.v_total); + if(bmode->timing.flags) { + printf("\t\tFlags:\n"); + if(bmode->timing.flags & B_BLANK_PEDESTAL) { + printf("\t\t\tB_BLANK_PEDESTAL\n"); + } + if(bmode->timing.flags & B_TIMING_INTERLACED) { + printf("\t\t\tB_TIMING_INTERLACED\n"); + } + if(bmode->timing.flags & B_POSITIVE_HSYNC) { + printf("\t\t\tB_POSITIVE_HSYNC\n"); + } + if(bmode->timing.flags & B_POSITIVE_VSYNC) { + printf("\t\t\tB_POSITIVE_VSYNC\n"); + } + if(bmode->timing.flags & B_SYNC_ON_GREEN) { + printf("\t\t\tB_SYNC_ON_GREEN\n"); + } + } } #endif @@ -134,101 +134,101 @@ void _SpoutModeData(display_mode *bmode) { int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace) { - int bitsperpixel; + int bitsperpixel; - bitsperpixel = 0; - switch (colorspace) { - case B_CMAP8: - bitsperpixel = 8; - break; - case B_RGB15: - case B_RGBA15: - case B_RGB15_BIG: - case B_RGBA15_BIG: - bitsperpixel = 15; - break; - case B_RGB16: - case B_RGB16_BIG: - bitsperpixel = 16; - break; - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - bitsperpixel = 32; - break; - default: - break; - } - return(bitsperpixel); + bitsperpixel = 0; + switch (colorspace) { + case B_CMAP8: + bitsperpixel = 8; + break; + case B_RGB15: + case B_RGBA15: + case B_RGB15_BIG: + case B_RGBA15_BIG: + bitsperpixel = 15; + break; + case B_RGB16: + case B_RGB16_BIG: + bitsperpixel = 16; + break; + case B_RGB32: + case B_RGBA32: + case B_RGB32_BIG: + case B_RGBA32_BIG: + bitsperpixel = 32; + break; + default: + break; + } + return(bitsperpixel); } int32 HAIKU_BPPToSDLPxFormat(int32 bpp) { - /* Translation taken from SDL_windowsmodes.c */ - switch (bpp) { - case 32: - return SDL_PIXELFORMAT_RGB888; - break; - case 24: /* May not be supported by Haiku */ - return SDL_PIXELFORMAT_RGB24; - break; - case 16: - return SDL_PIXELFORMAT_RGB565; - break; - case 15: - return SDL_PIXELFORMAT_RGB555; - break; - case 8: - return SDL_PIXELFORMAT_INDEX8; - break; - case 4: /* May not be supported by Haiku */ - return SDL_PIXELFORMAT_INDEX4LSB; - break; - } + /* Translation taken from SDL_windowsmodes.c */ + switch (bpp) { + case 32: + return SDL_PIXELFORMAT_RGB888; + break; + case 24: /* May not be supported by Haiku */ + return SDL_PIXELFORMAT_RGB24; + break; + case 16: + return SDL_PIXELFORMAT_RGB565; + break; + case 15: + return SDL_PIXELFORMAT_RGB555; + break; + case 8: + return SDL_PIXELFORMAT_INDEX8; + break; + case 4: /* May not be supported by Haiku */ + return SDL_PIXELFORMAT_INDEX4LSB; + break; + } - /* May never get here, but safer and needed to shut up compiler */ - SDL_SetError("Invalid bpp value"); - return 0; + /* May never get here, but safer and needed to shut up compiler */ + SDL_SetError("Invalid bpp value"); + return 0; } static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, - SDL_DisplayMode *mode) { - mode->w = bmode->virtual_width; - mode->h = bmode->virtual_height; - mode->refresh_rate = (int)get_refresh_rate(*bmode); + SDL_DisplayMode *mode) { + mode->w = bmode->virtual_width; + mode->h = bmode->virtual_height; + mode->refresh_rate = (int)get_refresh_rate(*bmode); #if WRAP_BMODE - SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, - sizeof(SDL_DisplayModeData)); - data->bmode = bmode; - - mode->driverdata = data; + SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, + sizeof(SDL_DisplayModeData)); + data->bmode = bmode; + + mode->driverdata = data; #else - mode->driverdata = bmode; + mode->driverdata = bmode; #endif - /* Set the format */ - int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space); - mode->format = HAIKU_BPPToSDLPxFormat(bpp); + /* Set the format */ + int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space); + mode->format = HAIKU_BPPToSDLPxFormat(bpp); } /* Later, there may be more than one monitor available */ static void _AddDisplay(BScreen *screen) { - SDL_VideoDisplay display; - SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, - sizeof(SDL_DisplayMode)); - display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode)); - screen->GetMode(bmode); + SDL_VideoDisplay display; + SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, + sizeof(SDL_DisplayMode)); + display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode)); + screen->GetMode(bmode); - _BDisplayModeToSdlDisplayMode(bmode, mode); - - SDL_zero(display); - display.desktop_mode = *mode; - display.current_mode = *mode; - - SDL_AddVideoDisplay(&display); + _BDisplayModeToSdlDisplayMode(bmode, mode); + + SDL_zero(display); + display.desktop_mode = *mode; + display.current_mode = *mode; + + SDL_AddVideoDisplay(&display); } /* @@ -236,92 +236,92 @@ static void _AddDisplay(BScreen *screen) { */ int HAIKU_InitModes(_THIS) { - BScreen screen; + BScreen screen; - /* TODO: When Haiku supports multiple display screens, call - _AddDisplayScreen() for each of them. */ - _AddDisplay(&screen); - return 0; + /* TODO: When Haiku supports multiple display screens, call + _AddDisplayScreen() for each of them. */ + _AddDisplay(&screen); + return 0; } int HAIKU_QuitModes(_THIS) { - /* FIXME: Nothing really needs to be done here at the moment? */ - return 0; + /* FIXME: Nothing really needs to be done here at the moment? */ + return 0; } int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { - BScreen bscreen; - BRect rc = bscreen.Frame(); - rect->x = (int)rc.left; - rect->y = (int)rc.top; - rect->w = (int)rc.Width() + 1; - rect->h = (int)rc.Height() + 1; - return 0; + BScreen bscreen; + BRect rc = bscreen.Frame(); + rect->x = (int)rc.left; + rect->y = (int)rc.top; + rect->w = (int)rc.Width() + 1; + rect->h = (int)rc.Height() + 1; + return 0; } void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { - /* Get the current screen */ - BScreen bscreen; + /* Get the current screen */ + BScreen bscreen; - /* Iterate through all of the modes */ - SDL_DisplayMode mode; - display_mode this_bmode; - display_mode *bmodes; - uint32 count, i; - - /* Get graphics-hardware supported modes */ - bscreen.GetModeList(&bmodes, &count); - bscreen.GetMode(&this_bmode); - - for(i = 0; i < count; ++i) { - // FIXME: Apparently there are errors with colorspace changes - if (bmodes[i].space == this_bmode.space) { - _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); - SDL_AddDisplayMode(display, &mode); - } - } - free(bmodes); + /* Iterate through all of the modes */ + SDL_DisplayMode mode; + display_mode this_bmode; + display_mode *bmodes; + uint32 count, i; + + /* Get graphics-hardware supported modes */ + bscreen.GetModeList(&bmodes, &count); + bscreen.GetMode(&this_bmode); + + for(i = 0; i < count; ++i) { + // FIXME: Apparently there are errors with colorspace changes + if (bmodes[i].space == this_bmode.space) { + _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); + SDL_AddDisplayMode(display, &mode); + } + } + free(bmodes); } int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ - /* Get the current screen */ - BScreen bscreen; - if(!bscreen.IsValid()) { - printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); - } + /* Get the current screen */ + BScreen bscreen; + if(!bscreen.IsValid()) { + printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); + } - /* Set the mode using the driver data */ - display_mode *bmode = _ExtractBMode(mode); + /* Set the mode using the driver data */ + display_mode *bmode = _ExtractBMode(mode); - /* 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); - for(i = 0; i < c; ++i) { - if( bmode_list[i].space == bmode->space && - bmode_list[i].virtual_width == bmode->virtual_width && - bmode_list[i].virtual_height == bmode->virtual_height ) { - bmode = &bmode_list[i]; - break; - } - } + /* 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); + for(i = 0; i < c; ++i) { + if( bmode_list[i].space == bmode->space && + bmode_list[i].virtual_width == bmode->virtual_width && + bmode_list[i].virtual_height == bmode->virtual_height ) { + bmode = &bmode_list[i]; + break; + } + } - if(bscreen.SetMode(bmode) != B_OK) { - return SDL_SetError("Bad video mode"); - } - - free(bmode_list); - + if(bscreen.SetMode(bmode) != B_OK) { + return SDL_SetError("Bad video mode"); + } + + free(bmode_list); + #if SDL_VIDEO_OPENGL - /* FIXME: Is there some way to reboot the OpenGL context? This doesn't - help */ -// HAIKU_GL_RebootContexts(_this); + /* FIXME: Is there some way to reboot the OpenGL context? This doesn't + help */ +// HAIKU_GL_RebootContexts(_this); #endif - return 0; + return 0; } #ifdef __cplusplus diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index e6a9736d0..e7b4b6e30 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -56,7 +56,7 @@ HAIKU_CreateDevice(int devindex) device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device->driverdata = NULL; /* FIXME: Is this the cause of some of the - SDL_Quit() errors? */ + SDL_Quit() errors? */ /* TODO: Figure out if any initialization needs to go here */ @@ -122,37 +122,36 @@ HAIKU_CreateDevice(int devindex) } VideoBootStrap HAIKU_bootstrap = { - "haiku", "Haiku graphics", - HAIKU_Available, HAIKU_CreateDevice + "haiku", "Haiku graphics", + HAIKU_Available, HAIKU_CreateDevice }; void HAIKU_DeleteDevice(SDL_VideoDevice * device) { - SDL_free(device->driverdata); - SDL_free(device); + SDL_free(device->driverdata); + SDL_free(device); } int HAIKU_VideoInit(_THIS) { - /* Initialize the Be Application for appserver interaction */ - if (SDL_InitBeApp() < 0) { - return -1; - } - - /* Initialize video modes */ - HAIKU_InitModes(_this); + /* Initialize the Be Application for appserver interaction */ + if (SDL_InitBeApp() < 0) { + return -1; + } + + /* Initialize video modes */ + HAIKU_InitModes(_this); + + /* Init the keymap */ + HAIKU_InitOSKeymap(); - /* Init the keymap */ - HAIKU_InitOSKeymap(); - - #if 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 */ HAIKU_GL_LoadLibrary(_this, NULL); #endif - /* We're done! */ + /* We're done! */ return (0); } diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index e89be1eb6..142a3fa18 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -32,36 +32,36 @@ extern "C" { #endif static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { - return ((SDL_BWin*)(window->driverdata)); + return ((SDL_BWin*)(window->driverdata)); } static SDL_INLINE SDL_BApp *_GetBeApp() { - return ((SDL_BApp*)be_app); + return ((SDL_BApp*)be_app); } static int _InitWindow(_THIS, SDL_Window *window) { - uint32 flags = 0; - window_look look = B_TITLED_WINDOW_LOOK; + uint32 flags = 0; + window_look look = B_TITLED_WINDOW_LOOK; - BRect bounds( + BRect bounds( window->x, window->y, - window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing + window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing window->y + window->h - 1 ); if(window->flags & SDL_WINDOW_FULLSCREEN) { - /* TODO: Add support for this flag */ - printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__); + /* 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; + flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE; } if(window->flags & SDL_WINDOW_BORDERLESS) { - look = B_NO_BORDER_WINDOW_LOOK; + look = B_NO_BORDER_WINDOW_LOOK; } SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags); @@ -79,35 +79,35 @@ int HAIKU_CreateWindow(_THIS, SDL_Window *window) { if (_InitWindow(_this, window) < 0) { return -1; } - - /* Start window loop */ + + /* Start window loop */ _ToBeWin(window)->Show(); return 0; } int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { - SDL_BWin *otherBWin = (SDL_BWin*)data; - if(!otherBWin->LockLooper()) - return -1; - - /* Create the new window and initialize its members */ - window->x = (int)otherBWin->Frame().left; - window->y = (int)otherBWin->Frame().top; - window->w = (int)otherBWin->Frame().Width(); - window->h = (int)otherBWin->Frame().Height(); - - /* Set SDL flags */ - if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) { - window->flags |= SDL_WINDOW_RESIZABLE; - } - - /* If we are out of memory, return the error code */ + SDL_BWin *otherBWin = (SDL_BWin*)data; + if(!otherBWin->LockLooper()) + return -1; + + /* Create the new window and initialize its members */ + window->x = (int)otherBWin->Frame().left; + window->y = (int)otherBWin->Frame().top; + window->w = (int)otherBWin->Frame().Width(); + window->h = (int)otherBWin->Frame().Height(); + + /* Set SDL flags */ + if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) { + window->flags |= SDL_WINDOW_RESIZABLE; + } + + /* If we are out of memory, return the error code */ if (_InitWindow(_this, window) < 0) { return -1; } - - /* TODO: Add any other SDL-supported window attributes here */ + + /* TODO: Add any other SDL-supported window attributes here */ _ToBeWin(window)->SetTitle(otherBWin->Title()); /* Start window loop and unlock the other window */ @@ -118,106 +118,106 @@ int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { } void HAIKU_SetWindowTitle(_THIS, SDL_Window * window) { - BMessage msg(BWIN_SET_TITLE); - msg.AddString("window-title", window->title); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_SET_TITLE); + msg.AddString("window-title", window->title); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) { - /* FIXME: Icons not supported by Haiku */ + /* FIXME: Icons not supported by Haiku */ } void HAIKU_SetWindowPosition(_THIS, SDL_Window * window) { - BMessage msg(BWIN_MOVE_WINDOW); - msg.AddInt32("window-x", window->x); - msg.AddInt32("window-y", window->y); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_MOVE_WINDOW); + msg.AddInt32("window-x", window->x); + msg.AddInt32("window-y", window->y); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_SetWindowSize(_THIS, SDL_Window * window) { - BMessage msg(BWIN_RESIZE_WINDOW); - msg.AddInt32("window-w", window->w - 1); - msg.AddInt32("window-h", window->h - 1); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_RESIZE_WINDOW); + msg.AddInt32("window-w", window->w - 1); + msg.AddInt32("window-h", window->h - 1); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) { - BMessage msg(BWIN_SET_BORDERED); - msg.AddBool("window-border", bordered != SDL_FALSE); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_SET_BORDERED); + msg.AddBool("window-border", bordered != SDL_FALSE); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) { - BMessage msg(BWIN_SET_RESIZABLE); - msg.AddBool("window-resizable", resizable != SDL_FALSE); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_SET_RESIZABLE); + msg.AddBool("window-resizable", resizable != SDL_FALSE); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_ShowWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_SHOW_WINDOW); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_SHOW_WINDOW); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_HideWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_HIDE_WINDOW); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_HIDE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_RaiseWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */ - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */ + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_MaximizeWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_MAXIMIZE_WINDOW); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_MAXIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_MinimizeWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_MINIMIZE_WINDOW); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_MINIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_RestoreWindow(_THIS, SDL_Window * window) { - BMessage msg(BWIN_RESTORE_WINDOW); - _ToBeWin(window)->PostMessage(&msg); + BMessage msg(BWIN_RESTORE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); } void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window, - SDL_VideoDisplay * display, SDL_bool fullscreen) { - /* Haiku tracks all video display information */ - BMessage msg(BWIN_FULLSCREEN); - msg.AddBool("fullscreen", fullscreen); - _ToBeWin(window)->PostMessage(&msg); - + SDL_VideoDisplay * display, SDL_bool fullscreen) { + /* Haiku tracks all video display information */ + BMessage msg(BWIN_FULLSCREEN); + msg.AddBool("fullscreen", fullscreen); + _ToBeWin(window)->PostMessage(&msg); + } int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) { - /* FIXME: Not Haiku supported */ - return -1; + /* FIXME: Not Haiku supported */ + return -1; } int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) { - /* FIXME: Not Haiku supported */ - return -1; + /* FIXME: Not Haiku supported */ + return -1; } void HAIKU_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { - /* TODO: Implement this! */ + /* TODO: Implement this! */ } void HAIKU_DestroyWindow(_THIS, SDL_Window * window) { - _ToBeWin(window)->LockLooper(); /* This MUST be locked */ - _GetBeApp()->ClearID(_ToBeWin(window)); - _ToBeWin(window)->Quit(); - window->driverdata = NULL; + _ToBeWin(window)->LockLooper(); /* This MUST be locked */ + _GetBeApp()->ClearID(_ToBeWin(window)); + _ToBeWin(window)->Quit(); + window->driverdata = NULL; } SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) { - /* FIXME: What is the point of this? What information should be included? */ - return SDL_FALSE; + /* FIXME: What is the point of this? What information should be included? */ + return SDL_FALSE; } diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index e23dd1310..04740899f 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -487,12 +487,12 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor) That's why we move the cursor graphic ONLY. */ if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata; - drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo)); - ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y); + drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo)); + ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y); - if (ret) { - SDL_SetError("drmModeMoveCursor() failed."); - } + if (ret) { + SDL_SetError("drmModeMoveCursor() failed."); + } } } diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 7a0b079ff..7e8fae725 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -50,23 +50,23 @@ KMSDRM_GLES_SetupCrtc(_THIS, SDL_Window * window) { KMSDRM_FBInfo *fb_info; if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed on CRTC setup"); - return SDL_FALSE; + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed on CRTC setup"); + return SDL_FALSE; } wdata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs); if (wdata->next_bo == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup"); - return SDL_FALSE; + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup"); + return SDL_FALSE; } fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo); if (fb_info == NULL) { - return SDL_FALSE; + return SDL_FALSE; } if(KMSDRM_drmModeSetCrtc(vdata->drm_fd, displaydata->crtc_id, fb_info->fb_id, - 0, 0, &vdata->saved_conn_id, 1, &displaydata->cur_mode) != 0) { + 0, 0, &vdata->saved_conn_id, 1, &displaydata->cur_mode) != 0) { SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not set up CRTC to a GBM buffer"); return SDL_FALSE; @@ -153,14 +153,14 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { } else { /* Queue page flip at vsync */ - /* Have we already setup the CRTC to one of the GBM buffers? Do so if we have not, + /* Have we already setup the CRTC to one of the GBM buffers? Do so if we have not, or FlipPage won't work in some cases. */ - if (!wdata->crtc_ready) { + if (!wdata->crtc_ready) { if(!KMSDRM_GLES_SetupCrtc(_this, window)) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set up CRTC for doing vsync-ed pageflips"); return 0; } - } + } /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModePageFlip(%d, %u, %u, DRM_MODE_PAGE_FLIP_EVENT, &wdata->waiting_for_flip)", vdata->drm_fd, displaydata->crtc_id, fb_info->fb_id); */ diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index e3863803a..c4f4a6069 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -343,17 +343,17 @@ RPI_DestroyWindow(_THIS, SDL_Window * window) SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; if(data) { - if (data->double_buffer) { - /* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */ - SDL_LockMutex(data->vsync_cond_mutex); - SDL_CondWait(data->vsync_cond, data->vsync_cond_mutex); - SDL_UnlockMutex(data->vsync_cond_mutex); + if (data->double_buffer) { + /* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */ + SDL_LockMutex(data->vsync_cond_mutex); + SDL_CondWait(data->vsync_cond, data->vsync_cond_mutex); + SDL_UnlockMutex(data->vsync_cond_mutex); - vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL); + vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL); - SDL_DestroyCond(data->vsync_cond); - SDL_DestroyMutex(data->vsync_cond_mutex); - } + SDL_DestroyCond(data->vsync_cond); + SDL_DestroyMutex(data->vsync_cond_mutex); + } #if SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index e8ecebe11..15762d2bf 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -445,7 +445,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh) #if !TARGET_OS_TV - (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation { - SDL_OnApplicationDidChangeStatusBarOrientation(); + SDL_OnApplicationDidChangeStatusBarOrientation(); } #endif diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index acf739b61..7ddf1078a 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -191,7 +191,7 @@ UIKit_InitModes(_THIS) } } #if !TARGET_OS_TV - SDL_OnApplicationDidChangeStatusBarOrientation(); + SDL_OnApplicationDidChangeStatusBarOrientation(); #endif } diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index bd60c552f..caabfac07 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -252,34 +252,34 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; - (void)pressesBegan:(NSSet *)presses withEvent:(UIPressesEvent *)event { - if (!SDL_AppleTVRemoteOpenedAsJoystick) { - for (UIPress *press in presses) { - SDL_Scancode scancode = [self scancodeFromPressType:press.type]; - SDL_SendKeyboardKey(SDL_PRESSED, scancode); - } - } + if (!SDL_AppleTVRemoteOpenedAsJoystick) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPressType:press.type]; + SDL_SendKeyboardKey(SDL_PRESSED, scancode); + } + } [super pressesBegan:presses withEvent:event]; } - (void)pressesEnded:(NSSet *)presses withEvent:(UIPressesEvent *)event { - if (!SDL_AppleTVRemoteOpenedAsJoystick) { - for (UIPress *press in presses) { - SDL_Scancode scancode = [self scancodeFromPressType:press.type]; - SDL_SendKeyboardKey(SDL_RELEASED, scancode); - } - } + if (!SDL_AppleTVRemoteOpenedAsJoystick) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPressType:press.type]; + SDL_SendKeyboardKey(SDL_RELEASED, scancode); + } + } [super pressesEnded:presses withEvent:event]; } - (void)pressesCancelled:(NSSet *)presses withEvent:(UIPressesEvent *)event { - if (!SDL_AppleTVRemoteOpenedAsJoystick) { - for (UIPress *press in presses) { - SDL_Scancode scancode = [self scancodeFromPressType:press.type]; - SDL_SendKeyboardKey(SDL_RELEASED, scancode); - } - } + if (!SDL_AppleTVRemoteOpenedAsJoystick) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPressType:press.type]; + SDL_SendKeyboardKey(SDL_RELEASED, scancode); + } + } [super pressesCancelled:presses withEvent:event]; } diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index b8be6087f..5ee76afea 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -747,7 +747,7 @@ static const struct wl_data_offer_listener data_offer_listener = { static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, - struct wl_data_offer *id) + struct wl_data_offer *id) { SDL_WaylandDataOffer *data_offer = NULL; @@ -765,7 +765,7 @@ data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, - uint32_t serial, struct wl_surface *surface, + uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; @@ -808,7 +808,7 @@ data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) static void data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, - uint32_t time, wl_fixed_t x, wl_fixed_t y) + uint32_t time, wl_fixed_t x, wl_fixed_t y) { } @@ -847,7 +847,7 @@ data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) static void data_device_handle_selection(void *data, struct wl_data_device *wl_data_device, - struct wl_data_offer *id) + struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c index 005b47f58..1cf37c1a2 100644 --- a/src/video/wayland/SDL_waylandtouch.c +++ b/src/video/wayland/SDL_waylandtouch.c @@ -89,9 +89,9 @@ touch_handle_touch(void *data, */ SDL_TouchID deviceId = 1; - if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) { - SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); - } + if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) { + SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); + } switch (touchState) { case QtWaylandTouchPointPressed: diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 06230277f..b6155e76d 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -68,10 +68,10 @@ static char * get_classname() { /* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec: - "The surface class identifies the general class of applications - to which the surface belongs. A common convention is to use the - file name (or the full path if it is a non-standard location) of - the application's .desktop file as the class." */ + "The surface class identifies the general class of applications + to which the surface belongs. A common convention is to use the + file name (or the full path if it is a non-standard location) of + the application's .desktop file as the class." */ char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 7055336d6..aaebea9ac 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -134,10 +134,10 @@ static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = { static void handle_configure_zxdg_toplevel(void *data, - struct zxdg_toplevel_v6 *zxdg_toplevel_v6, - int32_t width, - int32_t height, - struct wl_array *states) + struct zxdg_toplevel_v6 *zxdg_toplevel_v6, + int32_t width, + int32_t height, + struct wl_array *states) { SDL_WindowData *wind = (SDL_WindowData *)data; SDL_Window *window = wind->sdlwindow; @@ -213,10 +213,10 @@ static const struct xdg_surface_listener shell_surface_listener_xdg = { static void handle_configure_xdg_toplevel(void *data, - struct xdg_toplevel *xdg_toplevel, - int32_t width, - int32_t height, - struct wl_array *states) + struct xdg_toplevel *xdg_toplevel, + int32_t width, + int32_t height, + struct wl_array *states) { SDL_WindowData *wind = (SDL_WindowData *)data; SDL_Window *window = wind->sdlwindow; diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index 75b4898c3..87044117c 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -33,31 +33,31 @@ struct SDL_GLDriverData SDL_bool HAS_WGL_ARB_create_context_robustness; SDL_bool HAS_WGL_ARB_create_context_no_error; - /* Max version of OpenGL ES context that can be created if the - implementation supports WGL_EXT_create_context_es2_profile. - major = minor = 0 when unsupported. - */ - struct { - int major; - int minor; - } es_profile_max_supported_version; + /* Max version of OpenGL ES context that can be created if the + implementation supports WGL_EXT_create_context_es2_profile. + major = minor = 0 when unsupported. + */ + struct { + int major; + int minor; + } es_profile_max_supported_version; - void *(WINAPI * wglGetProcAddress) (const char *proc); - HGLRC(WINAPI * wglCreateContext) (HDC hdc); - BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc); - BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc); - BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2); - BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc, - const int *piAttribIList, - const FLOAT * pfAttribFList, - UINT nMaxFormats, - int *piFormats, - UINT * nNumFormats); - BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat, - int iLayerPlane, - UINT nAttributes, - const int *piAttributes, - int *piValues); + void *(WINAPI * wglGetProcAddress) (const char *proc); + HGLRC(WINAPI * wglCreateContext) (HDC hdc); + BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc); + BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc); + BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2); + BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc, + const int *piAttribIList, + const FLOAT * pfAttribFList, + UINT nMaxFormats, + int *piFormats, + UINT * nNumFormats); + BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + int *piValues); BOOL (WINAPI * wglSwapIntervalEXT) (int interval); int (WINAPI * wglGetSwapIntervalEXT) (void); }; diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index c4b34f0db..6bb8f2a42 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -40,7 +40,7 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; - Uint32 i; + Uint32 i; SDL_bool hasSurfaceExtension = SDL_FALSE; SDL_bool hasWin32SurfaceExtension = SDL_FALSE; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index 1a26ea099..7331b71ff 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -38,14 +38,14 @@ struct SDL_GLDriverData SDL_bool HAS_GLX_ARB_create_context_robustness; SDL_bool HAS_GLX_ARB_create_context_no_error; - /* Max version of OpenGL ES context that can be created if the - implementation supports GLX_EXT_create_context_es2_profile. - major = minor = 0 when unsupported. - */ - struct { - int major; - int minor; - } es_profile_max_supported_version; + /* Max version of OpenGL ES context that can be created if the + implementation supports GLX_EXT_create_context_es2_profile. + major = minor = 0 when unsupported. + */ + struct { + int major; + int minor; + } es_profile_max_supported_version; Bool (*glXQueryExtension) (Display*,int*,int*); void *(*glXGetProcAddress) (const GLubyte*); diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index a07a0309c..a4c6d1db0 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -45,7 +45,7 @@ SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char * SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return) -SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return) +SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return) SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return) SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return) @@ -201,7 +201,7 @@ SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return) SDL_X11_SYM(void,Xutf8DrawString,(Display *a, Drawable b, XFontSet c, GC d, int e, int f, _Xconst char *g, int h),(a,b,c,d,e,f,g,h),) -SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return) SDL_X11_SYM(char*,XSetLocaleModifiers,(const char *a),(a),return) SDL_X11_SYM(char*,Xutf8ResetIC,(XIC a),(a),return) #endif