201 Commits

Author SHA1 Message Date
libretroadmin
c7f2e6e163 Buildfix 2023-02-23 19:06:55 +01:00
libretroadmin
8507c4ba20 (input/connect) Cleanups 2023-02-23 18:53:17 +01:00
libretroadmin
7ebab640d7 Cleanups/style nits 2023-02-23 13:15:14 +01:00
DiktatorShadaloo
5587ab4f8b
Adding some usb hid drivers (#14581)
* Added usb hid controllers for the famous ZeroDelay encoder and also for "Kade: Kick Ass Dynamic Encoder" to be able to use some custom arcade sticks.

* Add accidentally missing change to Makefile

Co-authored-by: DiktatorShadaloo <diktatorshadaloo@gmail.com>
2022-11-03 03:00:42 +01:00
LibretroAdmin
1571035fb7 (DS3/connect) Fix some warnings 2022-09-26 16:12:31 +02:00
gblues
a4b934b71a
Fix some HID bugs (#14435)
* Fix Sixaxis gamepad operation

== DETAILS
It looks like commit 78e7d23c144c862d65ae1bf7ee41a1228bdfa380 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
gblues
cdd39a6364
MacOS: Fix Sixaxis (DS3) support (#14402)
* MacOS: Fix sixaxis on MacOS 12.x

== DETAILS
Mac OS 12.x "Monterey" dropped some built-in support for the
Sixaxis controller--exactly what changed is unclear, but other
projects reported similar issues with the OS.

This commit ports the work done on SDL, which is basically to
read two feature reports after writing out the activation report.
I think we did this at one point in the past, but it got lost
among HID driver rewrites.

I've tested this locally and it resolves the issue; after connecting
the sixaxis and pressing the Playstation button, the pad is registered
and works successfully.

I have not tested this on other platforms.

* Gracefully handle incomplete HID implementations

== DETAILS
Not all HID drivers implement all HID methods; since this controller
has a magic sequence that requires the ability to set and get HID
reports, we need to make sure we don't crash if we're running on
an incomplete implementation.

- Add a null check for the driver methods and log useful info if checks
  fail
- Fix minor formatting
2022-09-11 09:40:38 +02:00
LibretroAdmin
2dec44188b (connect_ps3.c) Buildfixg 2022-09-09 23:58:00 +02:00
LibretroAdmin
2bdb5d488b (connect/ps3) Remove unused variable, style nits 2022-09-09 21:26:47 +02:00
LibretroAdmin
f5fc1fb24e Fix build 2022-09-09 19:26:21 +02:00
LibretroAdmin
4cd63c20f4 (input/connect) Use calloc for setting DualShock3 struct 2022-09-09 19:22:29 +02:00
LibretroAdmin
dfff8e127a Simplify joypad_connection.c 2022-09-04 02:03:20 +02:00
LibretroAdmin
29774f5b7a
Small opts (#14186)
* (joypad_connection) Small optimizations -
* Turn functions static where possible
* Hose strlen call out of loop

* (input_driver.c) General cleanups:
* Some small code/style nits

task_screenshot.c:
* Move widget callback function for screenshots to task_screenshot.c

(file_path.c):
* Turn get_pathname_num_slashes into static function
* path_linked_list_free - always returns true, so get rid of return value
* path_linked_list_new - fix function signature
* path_get_archive_delim - do not NULL-terminate string, already done by strlcpy later on

General:
* Slight optimizations - use int/size_t for loop counter variable instead of unsigned
* Take advantage of fact that strlcpy already NULL-terminates, so don't do this explicitly
outside if we're just going to end up calling strlcpy/fill_pathname_join on it anyway
2022-07-19 10:01:33 +02:00
twinaphex
c8d57fe667 (CXX_BUILD) Some CXX_BUILD fixes 2022-03-30 15:13:28 +02:00
revvv
1cd6413e24 Wii U: Fix USB get_device_name(), don't truncate to three chars 2022-03-29 18:25:27 +01:00
revvv
b6ae697fad Make find_connection_entry() more specific
Controllers with same VID/PID are distinguished by the device name.
1. The Wii U only sends a prefix of the device name.
2. The check preferred the device name over VID/PID which was not
   intended.

Example: The device name "USB Gamepad" is truncated to "USB" which
was mapped to "Generic SNES USB Controller", although VID/PID did not
match.
2022-03-27 04:35:06 +01:00
revvv
75f94950bf Use "Retrode" as device name
Otherwise autoconfig file can't be found on the Wii U:
VID/PID are not available, so it has to match with 'input_device' and I
don't want to add additional autoconfig files with different
'input_device' strings.
2022-03-27 04:35:06 +01:00
revvv
b98b9471d9 Refactored to use new multi_pad interface 2022-03-22 18:17:50 +01:00
revvv
492a83e6d5 Wii: Fix find_connection_entry(): needs unsigned int
Otherwise the USB gamepad cannot be found, if VID/PID has leading zero.
For example: Retrode gamepad adapter:
             vid=1027 (0x403) pid=38849      (0x97c1) becomes
             vid=1027 (0x403) pid=-26687 (0xffff97c1)
2022-03-15 17:43:46 +01:00
twinaphex
bfeffb2423 Fix local header path includes 2021-12-04 16:11:02 +01:00
twinaphex
21beb6064a Silence some warnings 2021-11-05 03:58:26 +01:00
Jamiras
088aa7dcb9
add github action for c89 build (#13186)
* add retroarch.yml

* fix c89 errors

* attempt to add dependencies

* update comments
2021-11-05 00:05:13 +01:00
twinaphex
5ec93d2493 (HID) Fix some warnings 2021-10-20 02:23:01 +02:00
Nathan Strong
12a44e0365 Fix crashes reported by ploggy
== DETAILS

The crashes he reported in the gbatemp thread are due to iface
being null (since it's an unsupported device) and unchecked
iface dereferences.
2021-10-17 00:13:48 -07: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
7ed3ca7f97 WIP commit
Start trying to adapt the linux DS3 driver instead of our
hacked-together support.
2021-10-16 14:52:56 -07:00
Autechre
0a888f7868
Move video state to gfx/video_driver.c - reduces filesize of retroarch.c to 809kb (#13104)
* Move video state to gfx/video_driver.c - reduces filesize of retroarch.c
to 809Kb
2021-10-13 14:56:22 +02:00
gblues
dd6c70a083
Fix a couple regressions (#13101)
== DETAILS

- rewrote the HID deregistration algorithm; it should no longer
  cause issues when dealing with multiple pads of the same HID/VID
  combo
- fix initialization bug that caused wiimotes to fail to register
  without an accessory attached
2021-10-11 09:39:13 +02:00
twinaphex
bcc7581250 (joypad_connection.c) Cleanups - style nits - comment out some logs
that were generating warnings
2021-10-09 16:19:54 +02: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
Nathan Strong
01e96585a3 Fix crash when connecting DS3 to Mac
== DETAILS
The OSX HID driver doesn't implement `set_protocol()` and crashes
with an NPE, so we guard it.
2021-10-05 23:57:09 -07:00
twinaphex
55bf2b0083 (input/connect) Style nits 2021-10-06 02:52:19 +02:00
twinaphex
f81a231481 (joypad_connection) Cleanups - get rid of warning for old-style function
definition
2021-10-06 02:28:55 +02:00
Nathan Strong
e8ec65ecf7 squelch format warning 2021-10-05 19:05:12 +00:00
Nathan Strong
3e91e3fbc9 fix up non-wiiu side of ifdefs for ds3 2021-10-05 18:15:19 +00:00
Nathan Strong
002c9a30c0 Implement button() for most HID drivers
== DETAILS
The HID drivers in `input/connect/` were missing an implementation
for button(), so I added it. The only exception is the wii driver,
which is really complicated and more than I wanted to try to tackle--
especially since WIIU has its own wiimote drivers.
2021-10-05 17:43:03 +00:00
Nathan Strong
e02e345a28 Make GCA driver compatible with other HID drivers
== DETAILS
Use a little trickery to ensure the GCA driver continues working
with other HID implementation.

I've expanded the joypad implementation to support multi-pad devices.
However, this requires changes to each HID implementation to actually
function.

I've made the necessary changes for WIIU, but I don't have the means
of making the change in the other HID implementations.

So, I've built in a backwards-compatibilty mode for the driver.

The trick is to have an identifier byte at the top of both data structs
that the driver returns. We can then use that byte to determine which
of the structs has been passed to the pad functions and act accordingly.

In the GCA case, for non-wiiu platforms, it will simply expose port 1
of the GCA and the other 3 ports do nothing.
2021-10-05 09:47:03 -07:00
Nathan Strong
2715b4c9c0 get gamecube adapter working 2021-10-05 09:23:08 -07:00
Nathan Strong
c832828ddb Figured out the cause of crash
== DETAILS
cause of crash: trying to deference init when it's null
the reason it was going into deregister: the HID/VID lookup was
failing because it wasn't getting initialized first
cause of 2nd crash: the "end of pad list" method looked for an entry
with a magic value, so we add an end marker
2021-10-05 09:23:08 -07:00
Nathan Strong
a4d8ce7753 Try to support multi-pad HID devices
== DETAILS
I tried to modify the joypad connection interface to support
multi-pad HID devices ... it doesn't work. I'm not sure why.
2021-10-05 09:23:08 -07:00
Nathan Strong
9846ebb171 enable GCA adapter, minor cleanup
== DETAILS

I'm going to need to re-implement the abstraction between HID device
and gamepad; the changes here lay down some foundation for that work.

- reduce logging priority of some statements I modified while debugging
- factor out the pad driver lookup into its own method
- fix so the pad driver list isn't re-initialized every invocation
- add the button() method for the GCA driver
2021-10-05 09:23:08 -07:00
Nathan Strong
5da1cd08ff Unify the HID driver architecture
== DETAILS
When I first implemented the Wii U HID architecture, I ended up
having to design my own implementation because, at the time, I did
not have a way to read the HID device string to allow the existing
code to successfully detect the gamepad.

After spending some time experimenting, I've figured out how to
do this. And that means I can better align the HID driver with other
platforms.

change summary:

- create a single state structure for all three sub-types of wiiu pads
  (kpad, wpad, and hid)
- eliminate confusing duplicate pad lists
- eliminate confusing duplicate HID pad drivers (ds3, gamecube
  adapter, etc)
- ensure the ds3 driver still works
2021-10-05 09:23:08 -07:00
Nathan Strong
feb4f266fa WIIU: Fix L3/R3 buttons
== DETAILS
After a bisect, the culprit was changing the gamepad interface from
returing a single button (bool) to multiple (int16).

The issue is that the Wii U gamepad (and presumably the Pro controller too)
have more than 16 buttons, which means some buttons get lost. Notably, L3 (18)
and R3 (17).

The solution: use int32 instead of int16.

I did a test build and confirmed that this change restores L3/R3 functionality
with the gamepad. Don't have a pro controller to test, but it should work too.
2021-08-07 23:23:33 -07:00
Adie
ce4fce12c0 Implement changes to fix macOS controller duplication bug 2021-08-06 22:02:43 -05:00
James Montgomerie
5c58c6969e Allow controllers with no/empty names to work. 2020-09-06 18:24:32 -07:00
twinaphex
e2e9d0fbb6 Cleanup 2020-09-05 20:30:33 +02:00
twinaphex
09423bf272 Fix C89_BUILD issue 2020-09-05 20:29:57 +02:00
Sergei Nikitin
7475f6230a [Wii] Added HID support for HORI mini wired ps4 gamepad 2020-09-04 17:50:10 +06:00
twinaphex
93f9d69742 Cleanups 2020-08-28 20:42:55 +02:00