Commit Graph

3152 Commits

Author SHA1 Message Date
radius 066d181535 cleanup 2018-04-08 16:58:48 -05:00
twinaphex 4cd4de3bd3 Simplify input_overlay_add_inputs_inner 2018-04-08 23:20:06 +02:00
Twinaphex 8dc63653e5 Remove unused variables 2018-04-08 23:17:45 +02:00
twinaphex 3a4d094277 MSVC buildfix 2018-04-08 23:13:20 +02:00
twinaphex bc70477005 (input_mapper.c) Some more refactors 2018-04-08 23:08:21 +02:00
twinaphex a646fd3e65 (input_mapper.c) Small non-functional cleanups 2018-04-08 22:36:48 +02:00
radius 968c692a04 remap-redux: allow the menu to display manual keybinds 2018-04-08 14:50:30 -05:00
twinaphex 1dd73f86b7 Simplify this code somewhat 2018-04-08 21:45:10 +02:00
twinaphex 9bcaac1abc Simplify input_mapper_state 2018-04-08 21:38:57 +02:00
twinaphex 24b694d674 Grab joypad_driver only once 2018-04-08 21:07:04 +02:00
twinaphex 30090db941 Simplify input_get_state_for_port for analogs 2018-04-08 21:04:42 +02:00
twinaphex 0ed69fd170 Simplify input_state analog code remapping somewhat 2018-04-08 20:49:02 +02:00
twinaphex a82bb0ec94 Create special type input_bits_t 2018-04-08 20:21:12 +02:00
radius 2b9b829459 remap-redux part2: fix saving, loading and set defaults 2018-04-08 12:13:51 -05:00
radius f517ca3b56 remap-redux part2: fix right stick 2018-04-08 12:13:50 -05:00
radius 72065aee0b remap-redux part2: analog to analog input rules are working for left stick to left stick and left stick to right, for some reason not for right stick to right
stick
(inverting axes) or right stick to left...
2018-04-08 12:13:50 -05:00
radius c608951ff8 remap-redux part2:
- remapping analogs to buttons works 100%
    - remapping to analogs needs the "new input rules written" based on the value and the new axis
2018-04-08 12:13:50 -05:00
radius 0ed9f05571 remap-redux part2:
- remapping analogs to buttons works 100%
- remapping analogs to other analogs still messed up for some reason
- need to reset input of the original axis in input_driver.c still
2018-04-08 12:13:49 -05:00
radius f662d9f65f remap-redux part2: start adding analog remapping 2018-04-08 12:13:49 -05:00
radius 06860bf704 remap-redux part2: rewrite keymapper to work like gamepad mapper 2018-04-08 12:13:49 -05:00
radius 3792a5e502 remap-redux part2: cleanup 2018-04-08 12:13:49 -05:00
radius fa3dfd5f63 remap-redux part2: finally user 2 mapping works! 2018-04-08 12:13:48 -05:00
radius 4260423e48 remap-redux part2: let's use this function instead, add logging 2018-04-08 12:13:48 -05:00
radius 1fa28f0e31 remap-redux part2: let's use this function instead, add logging 2018-04-08 12:13:47 -05:00
radius d8d22a9c40 remap-redux part2: simplify this code a bit, still not working 2018-04-08 12:13:47 -05:00
radius e42e79db28 remap-redux part2: rename variable 2018-04-08 12:13:47 -05:00
radius 958216ede9 remap-redux part2: change remap file labels because old ones are incompatible 2018-04-08 12:13:46 -05:00
radius e130afff73 remap-redux part2: cleanup 2018-04-08 12:13:46 -05:00
radius 5efba1c257 remap-redux part2: better wraparound, skip analogs, add RARCH_UNMAPPED 2018-04-08 12:13:46 -05:00
radius be2c648596 remap-redux part2: after 60 attempsts, new mapper works, N:1 mapping too 2018-04-08 12:13:43 -05:00
radius 7f5fe5ebff remap-redux part 2: add controller sublabel 2018-04-08 12:13:43 -05:00
radius c4754815b6 remap-redux part 2: fix small issue with keymapper 2018-04-08 12:13:43 -05:00
radius 34649d1abf remap-redux part 2: start inverting the gamepad mapper columns 2018-04-08 12:13:42 -05:00
radius 51edf47ed2 remap-redux part 2: cleanup keymapper code 2018-04-08 12:13:42 -05:00
radius f6ee035011 remap-redux part 2: only add items for devices set to RETRO_DEVICE_KEYBOARD (or a subclass) 2018-04-08 12:13:41 -05:00
radius c57f8722e5 remap-redux part 2: restore original var names 2018-04-08 12:13:41 -05:00
radius 2bfb5ec0df remap-redux part 2: fix nits, hookup left/right callbacks 2018-04-08 12:13:40 -05:00
radius ed334cd1dd remap-redux part 2: allow multiple gamepads to work for the keymapper 2018-04-08 12:13:40 -05: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 46dad14d5f Merge branch 'master' into gblues/hid 2018-04-03 20:30:06 -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 9bc5a15c2d Enable pads to register in any order
== DETAILS

Whereas the last commit had a hack (that disabled the wiimote
driver in the process), this has.. well, a *different* hack that
allows pads to register in any order.

Note that due to the initialization routines, the gamepad will still
likely always get slot 0. Not sure if this can be overridden via config
or not.

== TESTING

Tested locally with GC adapter
2018-04-01 18:52:26 -07:00
gblues 2cf89feb86 Code clean-up
== DETAILS

Now that I have a working implementation, it's time to tidy up a bit:

- there was no need for the HID subsystem's object data to have a reference
  to the global hid state (since it's global), so removed it.
- refactored the users of that member to use the global state, defining
  reusable macros.
- reorganized the information in *.h files
- removing the hid state also made the constructor changes to the hid driver
  unneeded, so I reverted those changes.

== TESTING
Confirmed clean build. Haven't tested the build yet to make sure everything
still works, though.
2018-03-31 22:25:30 -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 d65bd90e67 Fix GC pad button mapping 2018-03-30 18:57:34 -07:00
twinaphex 8acc085dec (input_overlay.c) Get rid of some forward declarations 2018-03-30 13:57:50 +02:00
twinaphex 94254e4c79 (IOHIDManager) Cleanups 2018-03-30 11:49:25 +02:00
Twinaphex 86bfd8f4fc
Merge pull request #6497 from ceb33/master
fix to have a deterministic HID device registration
2018-03-30 11:40:24 +02:00
ceb33 c6d6fc7098 fix memory leak 2018-03-30 11:00:38 +02:00
ceb33 82e2cc7c73 set hid device registration deterministic (sorting by ascending location_id), this solve the issue where game with same vid and pid where sometime swapped by the OS 2018-03-30 10:43:54 +02:00
gblues 5060c2aac4 More fixes, GC pad kinda sorta works
== DETAILS

- Added a new method to the joypad_connection_t interface for
  getting a single button
- wired everything into the hidpad driver
- for testing purposes, hacking the top-level joypad driver
  so that kpad isn't used
- add a new RARCH_LOG_BUFFER method to verbosity for logging the
  contents of a binary buffer (useful for writing/debugging pad drivers)
- fix a few bugs in the wiiu GC pad driver

The button mapping isn't quite right, and I'm not sure what's
going wrong.
2018-03-29 23:37:11 -07:00
gblues 89c1ba7929 Keep HID pads from clobbering gamepad/wiimotes
== DETAILS

Trying to do weird pad math just wasn't working so I bit the bullet and just
let it allocate all 16 pads in the slot list, then just mark 0-4 as
connected so that the slot allocator would start at 5.

I can see it detect the pad, but no idea if it works. Out of time for
today.
2018-03-29 23:37:11 -07:00
gblues 1eea48d0c8 Fix crash on exit bug
== DETAILS

Turns out freeing memory that's already been freed is.. bad.

Fix two double-free instances; one due to over-freeing and the other
due to wrong order-of-operations causing a double free.

Also updated logging a little.

== TESTING

The GC adapter still clobbers slot 0, but the "emergency exit" sequence
works to quit RA cleanly.
2018-03-29 23:37:11 -07:00
gblues 8a4c5086fb Finish HID implementation for WiiU GCA adapter
== DETAILS

(I think)

- Uncomment the call in the read loop to start feeding packets to the
  driver
- implement the GCA packet driver
- implement the pad interface
- fix indentations in GCA driver

== TESTING
Compiles. Haven't tested yet.
2018-03-29 23:37:11 -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 dc6f4c23ed Rename hid_driver_instance members for clarity 2018-03-29 23:37:11 -07:00
gblues 4b9d5c0ab7 Start implementing "detach" code path
== DETAILS
We're at a point where we need to do more than just
clean up a local data structure, so I've started
implementing the "detach" part of the code so that
everything gets cleaned up properly.

Also, added error handling inside the polling
thread.

== TESTING

Have not tested yet.
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
twinaphex 1103f4f630 (input_overlay.c) Cleanups 2018-03-29 19:43:04 +02:00
Ash aeea0e6ca8
[WiiU] Fix OOB read/write in keyboard driver
This code used a keyboardState size of 256 and indexed it with a
retro_key, which can be any value (RETROK_RALT is 307). This fixes
that by using RETROK_LAST as the array size.

Should fix #6322.
2018-03-17 13:00:47 +11:00
twinaphex 6653818dc8 Revert "(input_overlay.c) Cleanups"
This reverts commit 56389466aa.
2018-03-15 06:39:06 +01:00
Ryunam c5775fd73c Implement Slow motion toggle 2018-03-10 18:42:45 +01:00
Twinaphex 4dc9c408d4
Merge pull request #6329 from markand/fix-vid-pid
Use EVIOCGID's ioctl to get vendor/product id, #6325
2018-02-26 18:39:33 +01:00
twinaphex fae9223641 Remove hashes from task_overlay 2018-02-25 13:03:54 +01:00
David Demelier e99049a8ff Use EVIOCGID's ioctl to get vendor/product id, #6325
The current code get the USB vendor/product controller, in case of
bluetooth connection this means that you get the bluetooth dongle ids
instead of gamepads. This is not fine as we match gamepads using their
product and vendor ids.

Credits go to SDL which helped me to figure out this issue.

http://hg.libsdl.org/SDL/file/f7c6b974d5af/src/joystick/linux/SDL_sysjoystick.c#l208
2018-02-23 09:19:43 +01:00
twinaphex 5139241e87 Fix Python codepath 2018-02-19 09:11:33 +01:00
twinaphex 070c09faec Avoid more pointer grabbing for video driver ptr 2018-02-16 20:42:37 +01:00
twinaphex 2b02616512 Disable ENABLE_TOUCH_SCREEN_MOUSE for now until issues are resolved 2018-02-15 14:50:14 +01:00
twinaphex 56389466aa (input_overlay.c) Cleanups 2018-02-11 17:58:24 +01:00
Brad Parker 039da3bb83 C89 buildfix 2018-02-06 22:17:32 -05:00
Twinaphex 0c3a684e2c
Merge pull request #6192 from gblues/master
Fix memory management bugs
2018-01-28 08:48:21 +01:00
gblues f2ea5dde11 Fix memory management bugs
== DETAILS

 * Fix double-free in hidpad shutdown code
 * Fix possible double-free in hidpad error handling code
 * Fix memory leak in adapter delete method
2018-01-27 22:54:59 -08:00
Olivier PARRA 8bff69eae8 1.[IOS9]Remove HID entry from menu as IOKIT is not available 2.[OSX]Add robustness and determinism to HID buttons detection code (add controller buttons in a sorted list) 2018-01-25 02:20:52 +01:00
twinaphex 80b17668b6 Add initial VS2013 solution 2018-01-24 01:29:45 +01:00
Twinaphex 4a6a97be60
Merge pull request #5429 from GregorR/netplay-input-upgrades-1
Netplay input upgrades 1
2018-01-23 05:01:45 +01:00
twinaphex 3fc2ddb8d2 (IOHIDManager) Add improvements - https://github.com/libretro/RetroArch/issues/4816#issuecomment-359145035 2018-01-22 06:48:56 +01:00
twinaphex c5ffd06778 Revert "(xdk_joypad.c) Cleanups"
This reverts commit 49c399217d.
2018-01-21 01:48:28 +01:00
twinaphex 6c73cea470 Revert "Buildfix"
This reverts commit 832cf07247.
2018-01-21 01:48:21 +01:00
twinaphex 832cf07247 Buildfix 2018-01-21 01:44:18 +01:00
twinaphex 49c399217d (xdk_joypad.c) Cleanups 2018-01-21 01:43:19 +01:00
twinaphex 932904e07e (Xbox 360) Buildfixes 2018-01-20 23:42:10 +01:00
twinaphex b7bbf368fe (XBox XDK) Input should work again completely 2018-01-20 23:38:32 +01:00
Twinaphex f08031345e
Merge pull request #6144 from aliaspider/master
various / build fixes.
2018-01-20 21:54:37 +01:00
aliaspider 5db96f35fa (WIN32) various build fixes. 2018-01-20 20:05:32 +01:00
twinaphex 528e4d8cc4 xdk_joypad_axis - implement case 4/5 for Xbox 360 2018-01-20 19:57:14 +01:00
twinaphex 6311885824 (XDK1) Change D-pad to hat controls - make gamepad D-pad and analog
stick work properly
2018-01-20 19:48:29 +01:00
twinaphex 13da6bf4a2 With Xbox OG, some of the face buttons are analog buttons -
need to implement this in _button callback function
2018-01-20 19:34:01 +01:00
twinaphex b4bb6e2ef4 Start making xdk_joypad code more similar to PC code 2018-01-20 19:05:39 +01:00
twinaphex 64e0861aee remove iteration variables 2018-01-20 18:57:19 +01:00
twinaphex 3ba978caa9 Make axis function more like PC version 2018-01-20 18:55:28 +01:00
twinaphex e16d962c01 Start getting rid of analog_state 2018-01-20 18:54:21 +01:00
twinaphex f25306ba22 memset g_xinput_states to 0 2018-01-20 18:50:24 +01:00
twinaphex 03a745e5b4 Remove xdk_joypad_get_buttons 2018-01-20 18:47:39 +01:00
twinaphex 0550b22a35 (XDK) Buildfix 2018-01-20 18:46:13 +01:00
twinaphex f74e399bdf Start rewriting xdk_joypad.c 2018-01-20 18:44:35 +01:00
twinaphex 41575a63ac (XDK joypad) Cleanups 2018-01-20 17:59:59 +01:00
twinaphex e6f637ea6b Set autoconfig binds for Xbox 2018-01-20 03:14:17 +01:00
twinaphex d01b9c4a09 Cleanups 2018-01-19 21:25:35 +01:00
twinaphex 82f721145c (XDK) Refactor xdk_joypad.c 2018-01-19 21:24:28 +01:00
twinaphex b4b5ed1630 Rely on xbox input subsystem to attach/detach gamepads 2018-01-19 07:02:47 +01:00
twinaphex 0731a79a4f Pass this to XInputOpen 2018-01-19 06:56:44 +01:00
twinaphex f71bbeae9f (XDK) Try to autodetect all pads at startup 2018-01-19 06:49:52 +01:00
twinaphex 897c1654ab Reduce usage of string_is_not_equal_fast 2018-01-17 01:03:48 +01:00
twinaphex 61ff51be2f Start using string_is_equal predominantly 2018-01-16 22:53:38 +01:00
Toad King ccb45a068d fix compiler warning 2018-01-15 04:52:35 -06:00
Toad King 460ceaef97 queue keyboard events and only process them when polling
fixes hitting enter from search box also selecting underlying menu item
2018-01-14 14:37:25 -06:00
Toad King 4fd750b48a add builtin autoconf script for emscripten gamepads with "standard" mapping 2018-01-14 04:24:37 -06:00
Toad King b3900217da clamp axis values to -1.0 - 1.0, at least firefox can report values outside that range 2018-01-14 03:43:23 -06:00
Toad King 1f8a85615c don't always clear poll state 2018-01-14 02:34:38 -06:00
Toad King de3581de73 fix analog sticks 2018-01-14 01:35:28 -06:00
Toad King 15c3f56b37 fix phantom button presses 2018-01-14 01:00:46 -06:00
Toad King 21d928ba0e add joypad driver for emscripten 2018-01-14 00:15:30 -06:00
Toad King 38ec1acf8e add mouse support to emscripten 2018-01-13 20:51:30 -06:00
Toad King 0ce1fa7751 fix search box in menu 2018-01-13 20:47:15 -06:00
Toad King 1e212b4248 use emscripten HTML5 API for keyboard events instead of old JS library 2018-01-13 17:56:00 -06:00
Toad King a77f9c37c6 start on bringing the emscripten video code up to speed with latest emscripten
fix rwebinput
2018-01-13 00:05:07 -06:00
twinaphex 7cbe4ba9a8 Turn some variables static 2018-01-12 01:37:23 +01:00
radius 3b334b60d6 add display name and config name to autoconf 2018-01-11 17:06:14 -05:00
David Walters c76545bf6c Compile fix. 2018-01-11 17:03:18 +00:00
David Walters 3dc3534498 Merge branch 'master' of https://github.com/libretro/RetroArch into udev_lightgun_api 2018-01-08 14:37:05 +00:00
gblues 5894d0ef86 Remove all HID code from WiiU build via ifdef
== DETAILS
We're trying to track down the source of crashes when switching cores.
To rule out the HID code, this commit does the following:

- Wraps the library imports in an ifdef
- Wraps the object files in conditionals in Makefile.wiiu
- In wiiu_joypad, calls into the hidpad driver are wrapped in ifdef

== TESTING
This didn't solve the "System memory error" crash I've been experiencing.
But, maybe it will impact the other flavors of crashes others are seeing.
2018-01-07 20:26:24 -08:00
vgmoose 890de0e79b allow joycons to work while attached 2018-01-07 12:10:28 +01:00
radius 3ee75e86c5 ake the hack less specific 2018-01-06 13:47:54 -05:00
gblues 5b13f85967 Use the right value for BIT256_GET macro
== DETAILS

The BIT256_GET() macro expects a bit number (from 0-255), and we're giving it
a 32-bit mask (0x000080000).

Solution:

- Define VPAD_BUTTON_xxx_BIT macros using the bit number
- Use said macro in wiiu_input.c
- organizational cleanup:

  * put VPAD_BUTTON_TOUCH into the enum in stead of as a hokey define
  * put the touch bits in the right order
  * put in placeholder enums for (currently) unused bits
2018-01-05 20:03:10 -08:00
Gregor Richards c8ec048459 More netplay flip nonsense to tear out. 2018-01-05 14:27:02 -05:00
Gregor Richards 8d5a79fc69 Removing long-obsolete now-disfunctional "netplay flip players" feature 2018-01-05 14:27:02 -05:00
twinaphex cf8e7cd362 (wiiu) small style nits; declare variables at top; C comments 2018-01-05 13:09:05 +01:00
Ian House 5311544c65 Added overlay led driver, fixed a bug in the rpi led driver 2018-01-04 12:56:57 -05:00
twinaphex edb8ecdbf8 (xdk_joypad.c) Add C codepath for XGetDeviceChanges 2018-01-03 14:13:29 +01:00
twinaphex b57f0d95c2 Try to fix Apple iOS build - error: initializer element is not a compile-time constant 2018-01-01 15:27:52 +01:00
Alcaro 7fd4d5013d C89 2017-12-31 23:46:11 +01:00
twinaphex bd16fd49ab Fix ./configure --disable-rgui 2017-12-31 17:53:11 +01:00
twinaphex 5aa159431e Prevent potential crash 2017-12-31 07:15:18 +01:00
Twinaphex 768be8b9c8
Merge pull request #6011 from gblues/master
Fix a couple crash bugs
2017-12-31 07:08:03 +01:00
twinaphex 2884ad2d73 (360) Some buildfixes 2017-12-31 06:09:39 +01:00
Brad Parker 8a8687ec9c add missing ifdef for device change fix and include 2K in the version check 2017-12-30 23:07:59 -05:00
twinaphex b464014a51 C89_BUILD fixes 2017-12-31 03:27:55 +01:00
misson20000 7cc614263a (NSW) add default button bindings and fix right joystick 2017-12-31 03:04:11 +01:00
gblues 11fed40c79 Fix another crash bug in joypad_connect
== DETAILS

I fixed a similar bug in a past commit, with the same root cause: making
assumptions about the length of the array.

- Add validation to joypad_connection_init() so that if >MAX_USERS is
  requested, a warning is logged and only MAX_USERS is allocated.
- Rewrote the iteration routines so they strictly use the
  joypad_is_end_of_list() method to detect the end.
2017-12-30 16:36:54 -08:00
Twinaphex 0389bc64fe
Merge pull request #5997 from libretro/new_hid
New HID system (courtesy of gblues)
2017-12-30 15:30:03 +01:00
twinaphex 20bb653f1e (Xbox 360) Buildfixes 2017-12-30 12:36:00 +01:00
gblues 65c177a0ee Move HID driver into wiiu/ code
== DETAILS

RetroArch's general HID drivers are intended as a full-on substitute for
other input drivers such as XInput, DInput, SDL, etc. The Wii U port is,
to my knowledge, the first case of heterogenous input drivers working
concurrently.

As such, I've moved things around:

- The HID driver source is moved into the wiiu/input/ directory alongside
  the joypad subdrivers.
- We no longer use the input_hid_init_first() method to instantiate; instead
  we just init the wiiu HID driver directly.
- The HID pad driver and HID subsystem driver enjoy a tighter coupling,
  mainly having to do with the initialization of the joypad connections
  list, because there's no way to inform the HID driver's init() method
  how many slots to allocate.

== TESTING
Will test in a moment, but at  least it compiles cleanly. ;)
2017-12-30 04:43:38 +01:00
gblues 704cc61fd8 Fix bug in autodetect macro, gamepad now works properly
== DETAILS
The gamepad didn't work because I had tried to rename the pad from
'WIIU Gamepad' to 'WiiU Gamepad'.

I added some debug logging and (to cut out a lot of trial-and-error)
discovered that the reason it didn't work was because a bug in a macro
was  using the define literally instead of substituting it (so e.g.
the autodetect handler was trying to match 'WiiU Gamepad' against the
literal string 'PAD_NAME_WIIU_GAMEPAD').

- Fixed the macro bug
- Left a minimal amount of the debug logging in place; may come in
  handy for someone else.
- Updated wpad/kpad/hidpad to use the define constants

== TESTING
Did a test build and confirmed the gamepad responded.
2017-12-30 04:43:33 +01:00
gblues 0ae7ffe0d3 Clean up dumb compile warnings, fix crash bug
== DETAILS

- the free() method of the hid_driver_t interface needs its
  parameter defined as const in order for the compiler to stop
  complaining about losing const-ness.
- if a joypad list is created with <MAX_USERS slots in it, the
  destroy() function will crash because it assumes there are MAX_USERS
  entries.

  To do this, the allocate function creates n+1 slots, and gives the
  last slot a canary value that the destroy() method can then watch for
  when iterating through the list.
2017-12-30 04:43:27 +01:00
gblues 52c754cfa8 Split wiiu_gamepad into three sub-drivers
== DETAILS
Well, after a lot of code analysis, this seems like the
best way to handle things on the Wii U without also completely
re-architecting the I/O handling in RetroArch.

How it works:

- the top-level wiiu_joypad driver is now nothing more than a
  delegator.
- the wiiu-specific drivers live in `wiiu/input/`
- wpad_driver.c handles the WiiU gamepad
- kpad_driver.c handles the wiimotes
- hidpad_driver.c will handle HID devices like the GC adapter, DS3/DS4, etc.

  (I say "will" because this isn't implemented yet)

== TESTING
Haven't actually tried the build to see if it works, but it does
compile.
2017-12-30 04:43:18 +01:00
gblues 8f900de65e Clean up USB VID/PID declarations
== DETAILS

USB Vendor and Product IDs are in little-endian byte order, and they
need to be byteswapped on big-endian systems.

This approach allows us to use the standard hex notation for the VID/HID
values, and give them meaningful names, and only swap on the platforms
that need it. Also prevents having to abuse SWAP16() in the platform-
specific code.
2017-12-30 04:43:03 +01:00
gblues 0f66bc3297 Implement HID read loop, add debug logging
== DETAILS

I haven't figured out how I'm going to get the data read via HIDRead()
funneled back to the adapter--the handle_packet() method doesn't actually
get called anywhere.

I'm probably going to need to do more tweaking to the function pointer
list.

This commit also adds logging for the data read via HIDRead.

== TESTING

I used my "stress test" (which I used to reproduce the crash caused
by the old HID implementation), and it did not crash.
2017-12-30 04:41:30 +01:00
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