Compare commits

..
Author SHA1 Message Date
Sam Lantinga d9fd3ce83c Fixed Visual Studio warning 4459
(cherry picked from commit d135daad5b)
2024-04-24 01:22:24 +03:00
Julian Uy 7fa9f1559c PS2 use WaitSemaEx for waiting for semaphore with timeout
(cherry picked from commit 557d8e2f24)
2024-04-24 01:22:04 +03:00
Ozkan Sezer b2ec286e35 CI, macOS: install autoconf.
Reference issue: https://github.com/libsdl-org/SDL/issues/9606 .

(cherry picked from commit 26e3d65ea8)
2024-04-24 00:33:56 +03:00
Sam Lantinga 05eb08053d Fixed IOS_SupportedHIDDevice() returning SDL_FALSE before initialization
(cherry picked from commit 34392db9c3)
(cherry picked from commit cc7c0a2dab)
2023-11-14 10:58:45 -08:00
Sam Lantinga c2ebe1024b Added SDL_HINT_JOYSTICK_IOKIT and SDL_HINT_JOYSTICK_MFI to control whether the IOKit and GCController drivers should be used for joystick support.
This can be used to work around issues where the Apple GCController driver doesn't work for some controllers but there's no way to know which GCController maps to which IOKit device.

(cherry picked from commit 708f18d49e)
(cherry picked from commit 76cc24e34a)
2023-11-14 10:35:14 -08:00
Sam Lantinga 1a722ef500 Fixed a memory leak at window creation.
Windows updates the desktop display mode once at video init (in WIN_InitModes()) and once when creating a window (in WIN_RefreshDisplays())

Fixes https://github.com/libsdl-org/SDL/issues/7982
Fixes https://github.com/libsdl-org/SDL/issues/8189

(cherry picked from commit bea34c5380)
(cherry picked from commit 0ec1209eab)
2023-11-14 10:35:14 -08:00
Sam Lantinga 6303197b20 Revert "Check to make sure the Windows joystick device has buttons and axes"
This reverts commit ad0af48883.

It turns out the ROG PUGIO II actually enumerates as a gamepad, so this change didn't have any effect anyway. We're getting lots of reports of people's racing pedals and similar devices no longer showing up, so we'll revert this again.

Fixes https://github.com/libsdl-org/SDL/issues/8227
Fixes https://github.com/libsdl-org/SDL/issues/8484

(cherry picked from commit 2c1fbe1967)
(cherry picked from commit cc20d0147e)
2023-11-13 21:37:50 -08:00
Sam Lantinga 6c0a114efb Fixed the ROG PUGIO II showing up as a game controller
This mouse actually enumerates as a gamepad with 2 axes, 8 buttons and a hat.

We'll ignore it like the other ROG mice, unless someone specifically wants to use it as a gamepad.

(cherry picked from commit edd044e901)
(cherry picked from commit 8c82b73027)
2023-11-13 21:37:50 -08:00
Sam Lantinga e5ccc80aba Removed useless branch test
Fixes https://github.com/libsdl-org/SDL/issues/8286
2023-11-08 01:34:42 -08:00
Sam Lantinga 00096baf18 Actually we need to enumerate the 8BitDo Xbox SKUs
At the point we're calling SDL_IsJoystickXboxSeriesX(), we don't know for sure that the controller is an Xbox controller.

Fixes https://github.com/libsdl-org/SDL/issues/8174

(cherry picked from commit 15bc12165a)
(cherry picked from commit af7fe2cf9b)
2023-11-08 00:43:57 -08:00
Sam Lantinga 1dbe85efd1 Assume all 8BitDo Xbox controllers have a share button
Fixes https://github.com/libsdl-org/SDL/issues/8174

(cherry picked from commit 8049af3355)
(cherry picked from commit 524ccf033f)
2023-11-08 00:36:49 -08:00
Sam Lantinga 52bffcbcd5 Destroy the window surface if we've created it for the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/8011

(cherry picked from commit 624905a7f1)
2023-11-07 21:47:24 -08:00
Sam Lantinga 89433c2339 Added a mapping for the Atari VCS controller connected over Bluetooth (thanks @WizzardSK!)
Fixes https://github.com/libsdl-org/SDL/issues/7116

(cherry picked from commit 28e623c504)
(cherry picked from commit 4ace02df5f)
2023-11-07 18:09:14 -08:00
Sam Lantinga b0fd3fad53 Make sure we include the null terminator in XLookupStringAsUTF8()
Fixes https://github.com/libsdl-org/SDL/issues/6728

(cherry picked from commit 4106697774)
(cherry picked from commit 70adacf08a)
2023-11-07 16:25:27 -08:00
Sam Lantinga 31dfc10c3b Fixed connecting and disconnecting real-joysticks closing virtual joysticks in Emscripten (thanks David!)
Emscripten was using its own, private integer in order to allocate
new SDL_JoystickIDs.  SDL keeps a similar integer for allocating
joystick-ids, one which is shared across multiple joystick backends.

SDL 2.0.13 introduces a new joystick-backend, a Virtual joystick
backend, which allows for software-driven joysticks, and which is
designed to sit alongside joystick-backends that provide access to
physical joysticks.

The Emscripten and the Virtual backends were, at times, getting
allocated the same SDL_JoystickIDs, if and when both backends were used
simultaneously.  This could happen if, for example, an application
was using a virtual joystick in order to drive a touch-screen
based joystick, while also supporting physical joysticks through the
Emscripten backend.

When two joysticks end up with the same SDL_JoystickID, conflicts
can occur.  For example, disconnecting a physical joystick with
the same SDL_JoystickID as a virtual one, can lead to the virtual
joystick being closed, inadvertently.

This fix makes the Emscripten backend use SDL's cross-joystick-backend
integer counter, which is shared among joystick backends, for allocating
new SDL_JoystickIDs, rather than a private, Emscripten-specific
counter.

Fixes https://github.com/libsdl-org/SDL/issues/3647

(cherry picked from commit 07cb7c10a1)
(cherry picked from commit 0c85173d5b)
2023-11-06 17:13:30 -08:00
Sam Lantinga 66399e4211 Revert "cmake: fold HAVE_INPUT_EVENTS into HAVE_LINUX_INPUT_H"
This reverts commit 01eb305493.
2023-11-06 12:17:15 -08:00
Sam Lantinga 45075eec86 Revert "configure: move HAVE_LINUX_INPUT_H to CheckInputEvents()"
This reverts commit 221d6ea8a8.

Fixes https://github.com/libsdl-org/SDL/issues/8488
2023-11-06 12:16:44 -08:00
Ozkan Sezer 9b2c70c9c8 fix a possible memory leak in SDL_vasprintf()
(cherry picked from commit 1a83bf2399)
2023-11-05 20:02:10 +03:00
Sam Lantinga ac23faf0a6 Fixed potential uninitialized memory access (thanks Mathieu!)
GetRawInputDeviceList() can return a different number of devices than was allocated.

Fixes https://github.com/libsdl-org/SDL/issues/2759

(cherry picked from commit b9784feb24)
(cherry picked from commit aa129c9257)
2023-11-04 21:12:36 -07:00
Ozkan Sezer 221d6ea8a8 configure: move HAVE_LINUX_INPUT_H to CheckInputEvents()
c.f.: https://github.com/libsdl-org/SDL/pull/8459.
Ref. issue https://github.com/libsdl-org/SDL/issues/8450
(cherry picked from commit e226008d83)
2023-11-02 23:33:50 +03:00
Anonymous Maarten 01eb305493 cmake: fold HAVE_INPUT_EVENTS into HAVE_LINUX_INPUT_H
(cherry picked from commit 8b1b6734f6)
2023-11-02 21:29:23 +01:00
19 changed files with 68 additions and 46 deletions

No files matched your search

+1
View File
@@ -64,6 +64,7 @@ jobs:
if: runner.os == 'macOS' if: runner.os == 'macOS'
run: | run: |
brew install \ brew install \
autoconf \
ninja \ ninja \
pkg-config pkg-config
+18
View File
@@ -965,6 +965,24 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED"
/**
* A variable controlling whether IOKit should be used for controller handling.
*
* This variable can be set to the following values:
* "0" - IOKit is not used
* "1" - IOKit is used (the default)
*/
#define SDL_HINT_JOYSTICK_IOKIT "SDL_JOYSTICK_IOKIT"
/**
* A variable controlling whether GCController should be used for controller handling.
*
* This variable can be set to the following values:
* "0" - GCController is not used
* "1" - GCController is used (the default)
*/
#define SDL_HINT_JOYSTICK_MFI "SDL_JOYSTICK_MFI"
/** /**
* \brief A variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices. * \brief A variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices.
* *
+1
View File
@@ -593,6 +593,7 @@ static const char *s_ControllerMappings[] = {
"05000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,", "05000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,",
"03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", "03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a2,righty:a3,start:b8,x:b2,y:b3,",
"05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,", "05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,",
"05000000503200000210000000000000128804098,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,",
"030000005e0400008e02000047010000,Atari Xbox 360 Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000047010000,Atari Xbox 360 Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
"03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
+3 -1
View File
@@ -2346,7 +2346,8 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id)
} }
} }
if (vendor_id == USB_VENDOR_8BITDO) { if (vendor_id == USB_VENDOR_8BITDO) {
if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER) { if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 ||
product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER2) {
return SDL_TRUE; return SDL_TRUE;
} }
} }
@@ -2792,6 +2793,7 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
}; };
static Uint32 rog_chakram_list[] = { static Uint32 rog_chakram_list[] = {
MAKE_VIDPID(0x0b05, 0x1906), /* ROG Pugio II */
MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */ MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */
MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */ MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */
MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */ MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */
+8 -6
View File
@@ -657,8 +657,8 @@ static SDL_bool CreateHIDManager(void)
static int DARWIN_JoystickInit(void) static int DARWIN_JoystickInit(void)
{ {
if (gpDeviceList) { if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_IOKIT, SDL_TRUE)) {
return SDL_SetError("Joystick: Device list already inited."); return 0;
} }
if (!CreateHIDManager()) { if (!CreateHIDManager()) {
@@ -694,10 +694,12 @@ static void DARWIN_JoystickDetect(void)
} }
} }
/* run this after the checks above so we don't set device->removed and delete the device before if (hidman) {
DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ /* run this after the checks above so we don't set device->removed and delete the device before
while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */
/* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) {
/* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */
}
} }
} }
+1 -3
View File
@@ -37,7 +37,6 @@ static SDL_joylist_item *JoystickByIndex(int index);
static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist = NULL;
static SDL_joylist_item *SDL_joylist_tail = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL;
static int numjoysticks = 0; static int numjoysticks = 0;
static int instance_counter = 0;
static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData)
{ {
@@ -72,7 +71,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep
item->naxes = gamepadEvent->numAxes; item->naxes = gamepadEvent->numAxes;
item->nbuttons = gamepadEvent->numButtons; item->nbuttons = gamepadEvent->numButtons;
item->device_instance = instance_counter++; item->device_instance = SDL_GetNextJoystickInstanceID();
item->timestamp = gamepadEvent->timestamp; item->timestamp = gamepadEvent->timestamp;
@@ -168,7 +167,6 @@ static void EMSCRIPTEN_JoystickQuit(void)
SDL_joylist = SDL_joylist_tail = NULL; SDL_joylist = SDL_joylist_tail = NULL;
numjoysticks = 0; numjoysticks = 0;
instance_counter = 0;
emscripten_set_gamepadconnected_callback(NULL, 0, NULL); emscripten_set_gamepadconnected_callback(NULL, 0, NULL);
emscripten_set_gamepaddisconnected_callback(NULL, 0, NULL); emscripten_set_gamepaddisconnected_callback(NULL, 0, NULL);
+8
View File
@@ -663,6 +663,10 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char
static int IOS_JoystickInit(void) static int IOS_JoystickInit(void)
{ {
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) {
return 0;
}
#if defined(__MACOSX__) #if defined(__MACOSX__)
#if _SDL_HAS_BUILTIN(__builtin_available) #if _SDL_HAS_BUILTIN(__builtin_available)
if (@available(macOS 10.16, *)) { if (@available(macOS 10.16, *)) {
@@ -1680,6 +1684,10 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi
#if defined(SDL_JOYSTICK_MFI) && defined(__MACOSX__) #if defined(SDL_JOYSTICK_MFI) && defined(__MACOSX__)
SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
{ {
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) {
return SDL_FALSE;
}
if (@available(macOS 10.16, *)) { if (@available(macOS 10.16, *)) {
const int MAX_ATTEMPTS = 3; const int MAX_ATTEMPTS = 3;
for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) { for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
+2 -1
View File
@@ -52,7 +52,8 @@
#define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_VALVE 0x28de
#define USB_VENDOR_ZEROPLUS 0x0c12 #define USB_VENDOR_ZEROPLUS 0x0c12
#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER 0x2002 #define USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 0x2002 /* Ultimate Wired Controller for Xbox */
#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER2 0x3106 /* Ultimate Wireless / Pro 2 Wired Controller */
#define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 #define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419
#define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024 #define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024
#define USB_PRODUCT_BACKBONE_ONE_IOS 0x0103 #define USB_PRODUCT_BACKBONE_ONE_IOS 0x0103
@@ -453,7 +453,6 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
char *hidPath = NULL; char *hidPath = NULL;
char *name = NULL; char *name = NULL;
LPDIRECTINPUTDEVICE8 device = NULL; LPDIRECTINPUTDEVICE8 device = NULL;
DIDEVCAPS caps;
/* We are only supporting HID devices. */ /* We are only supporting HID devices. */
CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID); CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID);
@@ -463,13 +462,6 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
CHECK(QueryDevicePath(device, &hidPath)); CHECK(QueryDevicePath(device, &hidPath));
CHECK(QueryDeviceInfo(device, &vendor, &product)); CHECK(QueryDeviceInfo(device, &vendor, &product));
/* Check to make sure the device has buttons and axes.
* This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10
*/
caps.dwSize = sizeof(caps);
CHECK(SUCCEEDED(IDirectInputDevice8_GetCapabilities(device, &caps)));
CHECK(caps.dwAxes > 0 && caps.dwButtons > 0);
CHECK(!SDL_IsXInputDevice(vendor, product, hidPath)); CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));
pNewJoystick = *(JoyStick_DeviceData **)pContext; pNewJoystick = *(JoyStick_DeviceData **)pContext;
+2 -1
View File
@@ -988,7 +988,8 @@ static void RAWINPUT_DetectDevices(void)
devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count);
if (devices) { if (devices) {
if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) != -1) { device_count = GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST));
if (device_count != (UINT)-1) {
for (i = 0; i < device_count; ++i) { for (i = 0; i < device_count; ++i) {
RAWINPUT_AddDevice(devices[i].hDevice); RAWINPUT_AddDevice(devices[i].hDevice);
} }
@@ -136,7 +136,8 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
return SDL_FALSE; return SDL_FALSE;
} }
if (GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { raw_device_count = GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST));
if (raw_device_count == (UINT)-1) {
SDL_free(raw_devices); SDL_free(raw_devices);
raw_devices = NULL; raw_devices = NULL;
return SDL_FALSE; /* oh well. */ return SDL_FALSE; /* oh well. */
+2 -1
View File
@@ -134,7 +134,8 @@ static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *
return; return;
} }
if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { device_count = GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST));
if (device_count == (UINT)-1) {
SDL_free(devices); SDL_free(devices);
return; /* oh well. */ return; /* oh well. */
} }
+4 -2
View File
@@ -980,8 +980,12 @@ static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static void SW_DestroyRenderer(SDL_Renderer *renderer) static void SW_DestroyRenderer(SDL_Renderer *renderer)
{ {
SDL_Window *window = renderer->window;
SW_RenderData *data = (SW_RenderData *)renderer->driverdata; SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
if (window) {
SDL_DestroyWindowSurface(window);
}
SDL_free(data); SDL_free(data);
SDL_free(renderer); SDL_free(renderer);
} }
@@ -1035,8 +1039,6 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
renderer->info = SW_RenderDriver.info; renderer->info = SW_RenderDriver.info;
renderer->driverdata = data; renderer->driverdata = data;
SW_ActivateRenderer(renderer);
return renderer; return renderer;
} }
+1 -6
View File
@@ -339,12 +339,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
if (is_uniform) { if (is_uniform) {
Uint32 color; Uint32 color;
if (tmp) { if (tmp) {
if (dst->format->Amask) { color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
} else {
// color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
}
} else { } else {
color = SDL_MapRGBA(dst->format, c0.r, c0.g, c0.b, c0.a); color = SDL_MapRGBA(dst->format, c0.r, c0.g, c0.b, c0.a);
} }
+1 -2
View File
@@ -1989,6 +1989,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
/* Check error code */ /* Check error code */
if (retval < 0) { if (retval < 0) {
SDL_free(p);
return retval; return retval;
} }
@@ -2010,5 +2011,3 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
} }
} }
} }
/* vi: set ts=4 sw=4 expandtab: */
+8 -11
View File
@@ -26,7 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <timer_alarm.h> #include <kernel_util.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
@@ -38,11 +38,6 @@ struct SDL_semaphore
s32 semid; s32 semid;
}; };
static void usercb(struct timer_alarm_t *alarm, void *arg)
{
iReleaseWaitThread((int)arg);
}
/* Create a semaphore */ /* Create a semaphore */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
@@ -85,8 +80,8 @@ void SDL_DestroySemaphore(SDL_sem *sem)
int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{ {
int ret; int ret;
struct timer_alarm_t alarm; u64 timeout_usec;
InitializeTimerAlarm(&alarm); u64 *timeout_ptr;
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");
@@ -99,12 +94,14 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
return 0; return 0;
} }
timeout_ptr = NULL;
if (timeout != SDL_MUTEX_MAXWAIT) { if (timeout != SDL_MUTEX_MAXWAIT) {
SetTimerAlarm(&alarm, MSec2TimerBusClock(timeout), &usercb, (void *)GetThreadId()); timeout_usec = timeout * 1000;
timeout_ptr = &timeout_usec;
} }
ret = WaitSema(sem->semid); ret = WaitSemaEx(sem->semid, 1, timeout_ptr);
StopTimerAlarm(&alarm);
if (ret < 0) { if (ret < 0) {
return SDL_MUTEX_TIMEDOUT; return SDL_MUTEX_TIMEDOUT;
+3
View File
@@ -825,6 +825,9 @@ void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode
void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
{ {
if (display->desktop_mode.driverdata) {
SDL_free(display->desktop_mode.driverdata);
}
SDL_memcpy(&display->desktop_mode, mode, sizeof(*mode)); SDL_memcpy(&display->desktop_mode, mode, sizeof(*mode));
} }
+2 -2
View File
@@ -1321,9 +1321,9 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags) STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags)
{ {
static const GUID TF_PROFILE_DAYI = { 0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A } }; static const GUID SDL_TF_PROFILE_DAYI = { 0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A } };
SDL_VideoData *videodata = (SDL_VideoData *)sink->data; SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
videodata->ime_candlistindexbase = WIN_IsEqualGUID(&TF_PROFILE_DAYI, guidProfile) ? 0 : 1; videodata->ime_candlistindexbase = WIN_IsEqualGUID(&SDL_TF_PROFILE_DAYI, guidProfile) ? 0 : 1;
if (WIN_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE)) { if (WIN_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE)) {
IME_InputLangChanged((SDL_VideoData *)sink->data); IME_InputLangChanged((SDL_VideoData *)sink->data);
} }
+1 -1
View File
@@ -756,7 +756,7 @@ static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int
{ {
int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out); int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out);
if (IsHighLatin1(buffer_return, result)) { if (IsHighLatin1(buffer_return, result)) {
char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result); char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result + 1);
if (utf8_text) { if (utf8_text) {
SDL_strlcpy(buffer_return, utf8_text, bytes_buffer); SDL_strlcpy(buffer_return, utf8_text, bytes_buffer);
SDL_free(utf8_text); SDL_free(utf8_text);