summaryrefslogtreecommitdiff
path: root/platform/osx/joypad_osx.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-11-17 16:35:21 +0100
committerGitHub <noreply@github.com>2021-11-17 16:35:21 +0100
commitf7b482d3ae36cf43c21a554df7d1154aad374a50 (patch)
tree465df0fd489f0bd6939968eed7f2f8e1410366cf /platform/osx/joypad_osx.cpp
parent0ef092a138cab6e79ae994b3f0f94173ee8b8faa (diff)
parent283e31a3e23a2b11ccbb9879b4832abef6ded50f (diff)
Merge pull request #55034 from plucky-git/macos-fix-crash-on-joypad-removal
Diffstat (limited to 'platform/osx/joypad_osx.cpp')
-rw-r--r--platform/osx/joypad_osx.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index d4ba7879f1..8405ed1da1 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -58,6 +58,7 @@ void joypad::free() {
if (ff_device) {
FFDeviceReleaseEffect(ff_device, ff_object);
FFReleaseDevice(ff_device);
+ ff_device = nullptr;
memfree(ff_axes);
memfree(ff_directions);
}
@@ -243,7 +244,7 @@ void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) {
if (is_joypad(p_device)) {
configure_joypad(p_device, &new_joypad);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (IOHIDDeviceGetService != nullptr) {
+ if (IOHIDDeviceGetService) {
#endif
const io_service_t ioservice = IOHIDDeviceGetService(p_device);
if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK) && new_joypad.config_force_feedback(ioservice)) {
@@ -348,6 +349,7 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
{ \
if (ret != FF_OK) { \
FFReleaseDevice(ff_device); \
+ ff_device = nullptr; \
return false; \
} \
}
@@ -367,6 +369,7 @@ bool joypad::config_force_feedback(io_service_t p_service) {
return true;
}
FFReleaseDevice(ff_device);
+ ff_device = nullptr;
return false;
}
#undef FF_ERR
@@ -601,7 +604,7 @@ JoypadOSX::JoypadOSX(Input *in) {
if (array) {
hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
- if (hid_manager != nullptr) {
+ if (hid_manager) {
config_hid_manager(array);
}
CFRelease(array);