Commit Graph

2901 Commits

Author SHA1 Message Date
gblues
7954dab835 Progress on I/O handling
== DETAILS

Starting to implement the I/O handling on the HID driver.

The old implementation basically had a never-ending HIDRead() callback
set up, so that callback N would start the read process for invocation
N+1.

We will take the same approach here; but now that the I/O thread is
happenning on its own core, we should be able to let it run full-
throttle without impacting emulator performance.

Of course, this hinges on the callback actually running on the same
core as the syscall was initiated on.

== TESTING
Can confirm that the read_loop_callback gets invoked on the same core
that the HIDRead() was invoked on.
2017-12-30 04:41:25 +01:00
gblues
661e5bf50b Implement new functions in hid_driver_t in WiiU driver
== DETAILS

This implements the WiiU-specific functions.

Since the wiiu_hid_t data structure contains the handle and interface
index, the method signatures can be simplified quite a bit. And since
(at least for now) we want these to be synchronous, we don't need to
expose the callback parameters.
2017-12-30 04:41:19 +01:00
gblues
678c4093c1 Start adapting the dual shock 3 driver to use the new driver format.
== DETAILS

The handshake stuff is derived from the old HID2VPAD, just in knowing
what data goes in what report.

- Added the HID_REPORT_ flags to syshid.h
- Renamed the generic "REPORT_TYPE" flags to be meaningful
- also fixed incorrect parameter list for set_protocol
== TESTING
The functions aren't implemented in wiiu_hid.c just yet,
so this is gonna crash if you try to run it.
2017-12-30 04:41:12 +01:00
gblues
982d6893b0 Set the send_control pointer on the drivers
== DETAIL

One minor detail missed in the last commit: actually putting the
send_control function into the driver declaration. Woops.

Not doing the Wii U because it will be using the other methods.
2017-12-30 04:41:07 +01:00
gblues
5b37ced196 Update HID pad driver architecture
== DETAILS

The current HID implementation assumes a very low-level USB library
is being used. This causes a problem on Wii U, because the Cafe OS
only exposes a high-level interface.

To get these functions exposed to the HID pad drivers, I had to make
three changes:

1. I added the legacy "send_control" function to the HID driver
   interface
2. I modified the signature of pad_connection_pad_init() to send the
   driver pointer instead of the function pointer
3. I updated the HID pad drivers to keep the pointer to the driver
   instead of the function pointer, and updated the calls into the
   send_control function as appropriate
4. I updated the HID drivers to use the new pad init signature

== TESTING
Untested, in theory it should work without a hitch because at this
point all I've done is abstract things a little. I still need to
update the HID pad drivers to use the Wii U-specific calls as
appropriate.
2017-12-30 04:41:01 +01:00
gblues
d0adbd194e Revert changes to joypad API
== DETAILS

Premature. Still learning my way around the codebase.
2017-12-30 04:40:53 +01:00
gblues
c1496a8600 WIP - reorganizing input data
== DETAILS

Looking at the apple input driver gave me an idea--moving the
HID driver into the wiiu_input_t data instead of piggy-backing
it off the wiiu_joypad driver.

- Remove changes to wiiu_joypad
- Add equivalent to wiiu_input

This is probably broke as hell. Haven't tried to compile.
2017-12-30 04:40:43 +01:00
gblues
5804233ca8 Start fleshing out wiiu_hid driver
== DETAILS

- Added entrypoints into `input/connect/joypad_connection.c` to allow
  a max value to be passed in, instead of using single macro value
- Created a hand-off between the HID attach handler and the worker thread
- Created a pad initializer in `wiiu_hid.c` leveraging the new functionality
  added to `joypad_connection.c`

== TESTING
Compiles cleanly. At best, doesn't do anything. Might crash--not ready
to test quite yet.
2017-12-30 04:40:39 +01:00
gblues
e98b006715 HID worker thread is now operational
== DETAILS
After wasting some cycles trying to isolate a crash, I went back to
basics.

I enabled the network logging, and put in a bunch of logging lines,
and noticed that the HID thread wasn't actually starting.

I did quite a bit of experimenting, working with different
memory alignments, and finally got it working.

== TESTING
As you can see, I put a log output inside the worker thread. When
I run the build, I can see the TICK messages. I can also see that
the thread shuts down as expected.

Also! The HID callback works as expected too! I have the GC
adapter, and when I register the HID callback it fires and I get the
following data:

    [INFO] USB device attach event
    [INFO]                 handle: 2058729
    [INFO]   physical_device_inst: 0
    [INFO]                    vid: 0x7e05
    [INFO]                    pid: 0x3703
    [INFO]        interface_index: 0
    [INFO]              sub_class: 0
    [INFO]               protocol: 0
    [INFO]     max_packet_size_rx: 37
    [INFO]     max_packet_size_tx: 5

Note that these are raw dumps of the data passed to the method,
so e.g. the VID/PID might be byte-swapped from how they're usually
represented.

Have not done the stress test to try to reproduce the crash.
2017-12-30 04:40:33 +01:00
gblues
192f5875b9 Simplify, add logging, revert some of the changes
== DETAILS
The old code was crashing; I did a minimalized branch and the crash
went away, so I'm bringing that over here. Meaning I'll have to
redo some of the other work I'd put in, but oh well.

(now watch it start crashing again)

== TESTING
Can confirm it builds. Wii U is busy ATM so I can't test.
2017-12-30 04:40:23 +01:00
gblues
1beba28d02 Only call HIDSetup/HidTeardown once
== DETAILS
I did a minimalist edit of the HID thread that stripped out all
HID* syscalls, and this stopped the crashing. I then re-added just
the HIDSetup() and HIDTeardown() calls, and the crash came back.

This smells like an OS bug. To work around it, I've put the
HIDSetup() and HIDTeardown() calls into the app init/shutdown
section, so they only get called once in the application lifetime
and not each time the input driver is initialized.
2017-12-30 04:40:15 +01:00
gblues
5c5e5be649 More progress on the HID driver
== DETAILS
I think I've about got the thread startup/teardown code worked
out. Logically, anyway, if not accurately.

The challenge has been figuring out how best to integrate the
features of HID2VPAD.

I found `input/connect/joypad_connection.c` and this seems like
the logical place for:

- Special-case driver for the Switch Pro controller
- Any other special cases HIDTOVPAD supports that core RetroArch
  doesn't
- Parsing of HIDTOVPAD config file to add custom button mapping

== TESTING
Compiles. Haven't tested with a real Wii U. Probably doesn't work
though. I very likely have the threading bit wrong.
2017-12-30 04:40:01 +01:00
gblues
c3736adb77 Start implementing HID polling thread
== DETAILS

Looking at the other HID USB drivers, it looks like the typical
implementation is to start up a background thread to do the
polling, rather than wait for RA to invoke the poll() method.

This commit sets up the skeleton of the background thread:

- The thread gets created in init()
- The thread gets stopped in free()

Right now the body of the thread is a 10ms sleep.

== TESTING

It compiles cleanly, and links. Don't know if it actually works.
2017-12-30 04:39:56 +01:00
gblues
203876a206 More progress on the HID driver
== DETAILS
I think I've about got the thread startup/teardown code worked
out. Logically, anyway, if not accurately.

The challenge has been figuring out how best to integrate the
features of HID2VPAD.

I found `input/connect/joypad_connection.c` and this seems like
the logical place for:

- Special-case driver for the Switch Pro controller
- Any other special cases HIDTOVPAD supports that core RetroArch
  doesn't
- Parsing of HIDTOVPAD config file to add custom button mapping

== TESTING
Compiles. Haven't tested with a real Wii U. Probably doesn't work
though. I very likely have the threading bit wrong.
2017-12-30 04:39:44 +01:00
gblues
1657079c45 Start implementing HID polling thread
== DETAILS

Looking at the other HID USB drivers, it looks like the typical
implementation is to start up a background thread to do the
polling, rather than wait for RA to invoke the poll() method.

This commit sets up the skeleton of the background thread:

- The thread gets created in init()
- The thread gets stopped in free()

Right now the body of the thread is a 10ms sleep.

== TESTING

It compiles cleanly, and links. Don't know if it actually works.
2017-12-30 04:39:39 +01:00
gblues
7e56881b88 Some cleanups 2017-12-30 04:39:34 +01:00
gblues
3b92cce6bf Start wiring up the HID driver
- add alloc/free for necessary objects
- register callback with Wii U OS

Don't think I've put the unregister bit in, so this is very likely
broken.
2017-12-30 04:39:25 +01:00
Nathan Strong
e80d99dbae Delete controller_patcher; start on proper HID driver
== DETAILS

We discovered that the controller_patcher code was causing
the WiiU to intermittently crash when switching ROMs.

Changes:

- Completely extricates the controller_patcher code
- Create a skeleton wiiu_hid driver
- Wire up the build system to build/link it successfully

== TESTING

Has not been tested. Probably doesn't crash, since the
skeleton driver is just a copy of the null driver.
2017-12-30 04:38:57 +01:00
twinaphex
d49b7b28b6 input_poll - cleanup 2017-12-29 23:12:35 +01:00
twinaphex
a6afddae04 current_input_data and current_input are no longer globals 2017-12-29 23:03:25 +01:00
twinaphex
5c876647ed (NSW) Small cleanups 2017-12-29 00:45:00 +01:00
misson20000
6d2a7b1f26 Nintendo Switch (libtransistor) port 2017-12-29 00:10:01 +01:00
Twinaphex
c7c71cb01f Fix Apple build 2017-12-27 22:36:10 +01:00
Twinaphex
b1c0fe7d0d Fix CXX_BUILD for Apple 2017-12-27 22:33:32 +01:00
radius
2cab3a7e4e fix some nits 2017-12-27 15:43:03 -05:00
radius
c3e6ac96aa only reinit when HID devices are attached 2017-12-27 15:34:18 -05:00
Twinaphex
d64154bf40
Merge pull request #5965 from fr500/master
avoid dinput reinitialization on unrelated WM_DEVICECHANGE events
2017-12-27 05:55:38 +01:00
bparker06
2dcd2bc5c6
Fix relative path 2017-12-26 22:02:11 -05:00
radius
ab54fda509 avoid dinput reinitialization on unrelated WM_DEVICECHANGE events 2017-12-26 20:17:26 -05:00
radius
7d9193555a fix menu toggle with keymapper active 2017-12-26 01:20:36 -05:00
Brad Parker
6d484b7724 xinput: check for valid function pointers before calling them 2017-12-23 23:02:29 -05:00
twinaphex
95e807749d Simplification/cleanup 2017-12-18 07:09:44 +01:00
twinaphex
422ce9396c Cleanup - input_key_pressed 2017-12-18 06:14:48 +01:00
twinaphex
69f85556a3 Get rid of meta_key_pressed 2017-12-18 05:59:57 +01:00
twinaphex
7b210ccf37 Don't call meta key pressed if not bound 2017-12-18 05:49:17 +01:00
twinaphex
1978689dcb Rewrite input_keys_pressed_iterate 2017-12-18 05:22:45 +01:00
twinaphex
9b9cf7b036 Cleanups 2017-12-18 05:13:57 +01:00
twinaphex
3c5d2f047c Create input_keys_pressed_iterate 2017-12-18 05:09:16 +01:00
Twinaphex
26f483b22d
Merge pull request #5882 from hiddenasbestos/dolphinbar
Mayflash DolphinBar
2017-12-17 16:48:26 +01:00
David Walters
02f6301607 fix reversed logic 2017-12-17 12:46:21 +00:00
David Walters
adffa5fc4c Fixes for overlay buttons 2017-12-17 12:36:18 +00:00
Brad Parker
8c0adf3594 move path_file_rename and path_file_remove into VFS 2017-12-14 13:32:26 -05:00
gblues
0f7de204f7 Last batch of whitespace cleanup (post-rebase)
-- looks like a few files committed with DOS line endings
2017-12-12 00:24:46 -08:00
gblues
6904101c44 Clean up trailing whitespace
== DETAILS

Really simple code cleanup, because my editor flags trailing whitespaces
and it's pretty annoying.
2017-12-12 00:24:18 -08:00
twinaphex
c950613098 C comments 2017-12-11 11:28:48 +01:00
Peter Y. Hammond
b14598657c Fixed a bug where the joypad devices were not always being assigned in the same order as they were numbered under /dev/input/. This showed up mainly when using an external USB Bluetooth dongle. In that case, controllers would be assigned often in reverse order. 2017-12-10 22:22:01 -07:00
Monroe88
cfde6a44db input_driver: Map Delete key to Y button for non-unified menu keyboard controls 2017-12-09 14:17:54 -06:00
Fabio
0d58d9ca0d
Added label to wii controllers, inverted the right stick Y axis of classic controller
The right stick Y axis of classic controller was wrong
2017-12-09 08:24:19 +01:00
David Walters
124ddcd27a Add dolphin bar VID/PID - treat like a wii over bluetooth connection 2017-12-07 23:44:29 +00:00
twinaphex
de9b0127f8 (MSVC) Buildfix 2017-12-06 04:33:54 +01:00