13 Commits

Author SHA1 Message Date
gblues
1d84c0eca1 Fix analog for DS3, plus some cleanups
== DETAILS

- DS3 analog wasn't working mainly because I forgot to actually declare the
  axes in input/input_autoconfig.c when declaring the pad. Whoops.
- I also moved the axis decoding logic to a more central place, because it
  clearly is not Wii U specific.
- Removed some dead commented-out code

== TESTING

Can use analog inputs on both GCA and DS3. Tested in Mario 3 on Nestopia core.

Haven't tested with any actual analog games, but I did confirm via logging
that the correct ranges are produced.
2018-04-23 23:22:27 -07:00
gblues
f7135bcee6 Fix analog reading on GCA
== DETAILS
After a little trial and error, I got analog input working for the
Wii U GC adapter.

DS3 might work, but it's untested.
2018-04-22 23:47:07 -07:00
gblues
ed742c48e0 Fix hotplugging
== DETAILS
So, it turns out that there *is* a autoconfig disconnect handler. Took digging
through tasks/task_autodetect.c to find it!

So, I added a call to the handler when the pad gets disconnected.

This seems to solve the problem of the pad not disappearing from the menu.

(At the very least, the user's pad index reverts to "none" which is still
an improvement)

== TESTING
Tested manually, made sure it didn't crash or leak slots.
2018-04-22 17:34:20 -07:00
gblues
4cd301bd92 Add pad unregistration
== DETAILS

I think this will fix the problem with duplicate pads--pads weren't properly
de-initializing and registering as disconnected. When a pad is disconnected,
the slot should properly release now.
2018-04-14 21:30:44 -07:00
gblues
6ab91a422e Small cleanup to adapt to upstream code changes
retro_bits_t turned into input_bits_t and there were parts of my
code that needed to update.

== TESTING
No idea if upstream changes broke anything, but it compiles cleanly
now.
2018-04-14 14:34:13 -07:00
gblues
97e09d179f Fix deadlocks when device is unplugged
== DETAILS
TIL that it's bad to call synchronization code from callbacks.

To avoid that, I made the following changes:

- Implemented an atomic swap (see previous commit) to avoid explicit
  locking when working with the event list
- ensure locks are only acquired in either the main thread or the
  I/O polling thread
- use an explicit polling loop; we still use async reads, but the
  read doesn't immediately re-invoke itself.
- remove the sleep in the polling thread.
- remove unnecessary locking in the thread cleanup call--verified that
  the list can't be modified while it is being executed.

== TESTING
I tested locally, and was able to disconnect/reconnect USB devices several times without the worker thread getting deadlocked.
2018-04-14 13:30:34 -07:00
gblues
4433cbebc6 Get digital inputs for Sony DualShock 3 working
== DETAILS

- fix the bitshift math
- read the right bytes out of the ds3 data packet
- remove verbose logging in critical path
- stop caring about errors in the hid read loop -- seems to just
  be benign "device not ready" -- or at least, that's what I'm assuming
  given that the read eventually succeeds.

== TESTING
Played Mario 3 with the DS3 with no issues.
2018-04-05 23:03:38 -07:00
gblues
af08e5015a More work on Dual Shock 3 driver
== DETAILS

- update to not try starting the read loop until after the device
  is successfully initialized
- add new HID wrapper macros needed by ds3 driver
- add some debug logging to help with troubleshooting
- add button map for DS3

== TESTING
Tested with local build. DS3 init is not working.
2018-04-02 23:16:49 -07:00
gblues
39e4167df6 Start work on DualShock 3 driver
== DETAILS

The WiiU GC adapter is working!

Next up: DualShock 3

I have the skeleton of the driver started, need to work out the
activation packet.

== TESTING

The DS3 driver is broke as hell right now.
2018-03-30 23:00:14 -07:00
gblues
180d6a28bf Fix up HID device driver initialization
== DETAILS
Turns out the cause of the crash was a bad cast, resulting in a
function call to nowhere.

Also, I think the DSI exception handler only works on the primary core;
when this was happening in the background thread, I got a black
screen error instead.

Next up: finishing up the GCA driver.
2018-03-29 23:37:11 -07:00
gblues
0100d58ffb WIP: evolve driver implementation
== DETAILS

I've created the concept of a hid_driver_instance_t which is basically
a central place to store the hid pad driver, hid subsystem driver,
the pad list, and the instance data for the above in a central location.

The HID pad device drivers can use it to perform HID operations in a
generic manner.

This is more-or-less a pause point so I can catch up with upstream.

== TESTING

Haven't tested this yet. Compiles without warnings though!
2018-03-29 23:37:11 -07:00
gblues
41ce8853d7 Add name for hid device; implement detect
== DETAILS

- detect() methods in device_* files now check for VID/PID
  instead of just returning false
- add "name" field on hid device, mainly for logging purposes

== TESTING
Verified my WiiU GC adapter detected properly
2018-03-29 23:37:11 -07:00
gblues
ae19eed00f implement hid device search 2018-03-29 23:37:11 -07:00