Commit Graph

120 Commits

Author SHA1 Message Date
Eric Warmenhoven 280dcb32f9 Fix several warnings 2023-07-02 05:46:45 +02:00
libretroadmin 7ebab640d7 Cleanups/style nits 2023-02-23 13:15:14 +01:00
serakeri 347ea8157c
Various memory access fixes to prevent crashes (#14459) (#15000)
Prevent double free and null dereference when the controller is quickly reconnected.
Handle error when controller device query returns null instead of crashing.
2023-02-21 06:09:36 +01:00
reallibretroadmin 78e935b7a9 (IOHIDManager) Buildfix 2023-02-19 12:20:11 +01:00
libretroadmin 6728d5a2fa (Subsystem) Cleanups 2023-02-19 12:15:45 +01:00
gblues a4b934b71a
Fix some HID bugs (#14435)
* Fix Sixaxis gamepad operation

== DETAILS
It looks like commit 78e7d23c14 broke
the DualShock. Sorry, @revvv, but this is probably going to break the
Retrode driver. We'll need to figure out a different solution.

* Fix a bunch of HID implementations

== DETAILS
As mentioned in the previous commit, the thing that broke the DS3
driver was a change to the wiiu HID handler, which did some pointer
math on the data buffer.

The thing is.. there's no reason to do that pointer math. Yet, I found
the same thing on almost every other HID driver: OSX, libusb, wiiusb.
The only other HID driver that did not do this was the Bluetooth
HID driver.

It doesn't make any sense. The only reason it doesn't crash is because
the memory right before the buffer is valid memory.

Change summary:
- remove the weird pointer math from all HID controllers
- remove the `#ifdef apple ...` in the ds3 and gamecube adapter
  drivers, because it's no longer needed.
- in the pad packet handlers, decrement data buffer offset references
  to account for the removal of the buffer manipulation.

* Fix DualShock 4

== DETAILS
Should've only subtracted 1, not 2; and now the pad works.

Also, added a PID to cover newer model DS4s. I picked "R2" out of the air
for the constant.

Tested on Mac OS

* Really really fix iohidmanager_set_report

A huge apology to @23rd for insulting your fix. I was wrong to call you
wrong.

That left the question: why did that change break the DS3?

Well, it's because `IOHIDDeviceSetReport` expects the report buffer to be
just the report. All of RA's HID SetReport calls include the report number
in the first byte, so we have to trim that off.

We actually do this in a different invocation of `IOHIDDeviceSetReport`
elsewhere in the file! This commit applies that same logic to
`iohidmanager_set_report`

This has two benefits:

1. The DS3 works
2. The DS3 no longer requres the user to press the PS button to activate
   it the first time. You plug it in and it Just Works, just like on Wii U.
2022-09-26 14:32:49 +02:00
23rd 171a79e879
Fixed sending of report id to HID device on macOS. (#14430) 2022-09-19 18:01:27 +02:00
twinaphex 619398bbe4 Backport parts of 73c0760236 2021-11-09 23:12:57 +01:00
twinaphex 5ec93d2493 (HID) Fix some warnings 2021-10-20 02:23:01 +02:00
Nathan Strong 81c6d3809a Finish up the OSX DS3 driver
== DETAILS
Put the finishing touches on getting the DS3 to work on Mac OSX.

Basically, there's some differences in the HID interface bewtween
wiiu and osx where OSX expects the first byte of the report to be
the report ID, while wiiu expects that byte to be trimmed off.

I was able to put this behavior in the respective HID
implementations, which eliminated the confusing packet offset
ifdefs.

And, I was able to get the LEDs working again.
2021-10-16 14:52:56 -07:00
Nathan Strong 729c219f1a Rewrite DS3 driver
== DETAILS
The DS3 driver previously only worked with the Wii U HID implementation.

I adapted this driver from the Linux driver for the DS3. It's not quite
100%--I haven't got the LEDs to work properly--but it's functional.

Going to continue tweaking it to see if I can get the LEDs to work.
2021-10-16 14:52:56 -07:00
Nathan Strong ea249b3827 Get the WIIU GCA working on Mac OSX
== DETAILS
The GCA uses a weird HID class that our current filters don't
catch, so we add it.

Needed to do a small amount of tweaking on the GCA driver to
account for iohidmanager weirdness.
2021-10-06 23:11:22 -07:00
ComradeEcho 35c2ec993b
Remove code that duplicates controllers 2021-08-07 11:43:50 -05:00
Adie ce4fce12c0 Implement changes to fix macOS controller duplication bug 2021-08-06 22:02:43 -05:00
twinaphex f459472f6d Fix leaks - we were not honoring the ownership policy/create rule
for various CoreFoundation functions with 'Copy' or 'Create' in the title
2021-08-07 03:46:08 +02:00
twinaphex c1ed271a12 (Mac/IOHIDManager) Fix leak of elements_raw and elements in iohidmanager_hid_device_add_device 2021-08-07 03:30:17 +02:00
twinaphex 3607d03ff8 Get rid of warning on older OSX SDK versions 2021-02-09 16:20:40 +01:00
twinaphex bf806f09ac kIOHIDElementTypeInput_NULL is apparently not available on previous OSX SDK versions 2021-02-09 16:14:20 +01:00
Autechre e282cfe2fe
(IOHIDManager) Fix enumeration value 'kIOHIDElementTypeInput_NULL' (#11944)
not handled in switch warning
2021-01-26 19:39:36 +01:00
James Montgomerie f83f706565 Make style of if statment conform to the one already in use in the file/ 2020-09-06 18:36:32 -07:00
James Montgomerie 5c58c6969e Allow controllers with no/empty names to work. 2020-09-06 18:24:32 -07:00
twinaphex 708a029665 (HID) Hardcode 'hid' name for passing to input_autoconfig_connect 2020-08-28 19:01:24 +02:00
twinaphex ed3ee2511f Cleanups - add local variable 2020-07-29 05:31:23 +02:00
rsn8887 78c9dbbd20 Fix input port assignments 2020-07-28 16:35:16 -05:00
twinaphex 005a9c005e (IOHIDManager) Cleanup 2020-07-20 01:30:42 +02:00
twinaphex 18dcda09d0 (IOHIDManager) Another buildfix 2020-07-19 03:39:32 +02:00
twinaphex b8f9e38b7e (IOHIDManager) Buildfix 2020-07-19 03:38:07 +02:00
twinaphex de73e3bff9 Buildfixes 2020-07-19 03:25:30 +02:00
twinaphex d97e590aaf Reimplement multi button state functions 2020-07-19 03:18:12 +02:00
twinaphex cb5b22b6ac (Android) Refactor axis functions 2020-07-18 22:38:23 +02:00
twinaphex 08ad00f5d3 Start preparing for being able to grab multiple buttons at the same time 2020-07-18 19:51:14 +02:00
twinaphex 8b078662cd Change function signature of joypad driver's 'button' 2020-07-18 18:07:57 +02:00
A Schain 1e751d00ea
In case last hatswitch does not match cookie
For the mayflash N64 adapter, I was getting a BAD EXC ADDRESS (in mac OS 10.13) for this line (tmp was NULL). Retroarch would crash in the gui if I pressed a button from the DPAD on controller 2. With this change, it no longer crashes in the gui and still registers the button push.
2020-04-30 13:27:44 -04:00
twinaphex a034909ae9 Cleanups 2020-01-30 16:35:59 +01:00
twinaphex 0257e01bee Refactor input_autoconfigure_connect - don't return
value - set input device name upon failure implicitly
2019-07-16 15:28:22 +02:00
twinaphex 6d17d11132 Rewrite '== false' to '!' for our own code 2019-06-06 13:50:39 +02:00
Twinaphex 077a5dd685 (OSX) CXX_BUILD buildfix 2019-04-22 10:33:30 +02:00
orbea 28ff4b391a Clean up white space. 2019-02-03 16:00:50 -08:00
orbea bfc366decc Squeeze extra blank lines with cat(1).
Example:

find . -type f -iname '*.c' | while read -r i; do
  cat -s "$i" > "$i.new"
  mv "$i.new" "$i"
done
2019-01-08 11:04:58 -08:00
twinaphex dac4034954 Add PPC ifdefs; kIOHIDUniqueKey is not available on OSX 10.5 2018-08-30 15:56:02 +02:00
greso 2c9fda1798 (macOS) Fix input issues
For my Xbox One Controller the min input for the hat is 1 and not 0. 0
points to the default state that is called after each button press.

On top of that the two axis for the trigger buttons were ignored. I
added some additional axis that are not present on my controller but
will probably help for other input devices.
2018-08-07 19:51:50 +02:00
Twinaphex fd11b205da Silence bunch of warnings 2018-06-21 07:52:01 +02:00
ceb33 bafd2af885 remove custom debug output 2018-05-05 13:33:15 +02:00
ceb33 67784c85cf update and merge to current Retroarch version 2018-05-05 12:59:04 +02:00
ceb33 9008684651 re-add callback to manage usb device plugged in while retroarch is running 2018-05-05 12:48:01 +02:00
Twinaphex de1bf58997 Buildfix 2018-05-03 20:39:03 +02:00
twinaphex 3796e52018 (OSX) Go back to old code - connect handler was broken 2018-05-03 20:31:28 +02:00
twinaphex a82bb0ec94 Create special type input_bits_t 2018-04-08 20:21:12 +02:00
twinaphex 94254e4c79 (IOHIDManager) Cleanups 2018-03-30 11:49:25 +02:00
ceb33 c6d6fc7098 fix memory leak 2018-03-30 11:00:38 +02:00