Commit Graph

141 Commits

Author SHA1 Message Date
gblues
6eebbe4213 Build fix for PC
== DETAILS
Hooray for conditional compile directives.

Moving things around broke things in unexpected ways on non-WiiU builds.

Well, not *completely* unexpected. But still.

Changes:

- Move some typedefs around to avoid circular include dependencies
- Include the file where the HID driver definition got moved to

== TESTING
- verified build for Wii U still runs successfully
- did a local build without any errors (some weird warnings, but since they
  happen in code I didn't change, I'm assuming they're pre-existing?)
2018-04-15 00:04:49 -07:00
gblues
fb5b31faf3 Merge branch 'master' into gblues/hid 2018-04-14 14:18:03 -07:00
twinaphex
a82bb0ec94 Create special type input_bits_t 2018-04-08 20:21:12 +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
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
twinaphex
cf8e7cd362 (wiiu) small style nits; declare variables at top; C comments 2018-01-05 13:09:05 +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
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
b464014a51 C89_BUILD fixes 2017-12-31 03:27:55 +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
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
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
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
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
Twinaphex
26f483b22d
Merge pull request #5882 from hiddenasbestos/dolphinbar
Mayflash DolphinBar
2017-12-17 16:48:26 +01: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
David Walters
124ddcd27a Add dolphin bar VID/PID - treat like a wii over bluetooth connection 2017-12-07 23:44:29 +00:00
twinaphex
f0c143766e Change to 256bit macros 2017-12-05 12:07:35 +01:00
twinaphex
6c09661a64 Move defines to retro_miscellaneous.h 2017-12-05 10:42:37 +01:00
twinaphex
e94300a581 Get rid of a lot of RARCH_INPUT_STATE_BIT_ macros - replace them
with BIT128_ equivalents instead
2017-12-05 09:22:56 +01:00
David Walters
f09477d46a additional compile fixes 2017-11-28 10:36:16 +00:00
David Walters
c5bdc02d6f replace uint64_t with retro_bits_t* for pad buttons state 2017-11-28 10:04:34 +00:00
daniel jimenez
e91bae38cf Introduce button mappings for generic usb controller 2017-11-13 22:08:24 -08:00
twinaphex
e16371b8a5 Merge input_config.c and input_driver.c 2017-08-31 02:25:04 +02:00
twinaphex
b11620e1eb Add retro_timers.h/retro_math.h 2017-06-28 04:41:38 +02:00
twinaphex
5d1cfc47cc C89_BUILD fixes 2017-06-25 04:05:34 +02:00
twinaphex
5c973b6649 Add another entry to debug logging 2017-06-18 15:52:17 +02:00
twinaphex
2d76e98c22 Add debug logging 2017-06-18 15:48:44 +02:00
Daniel Jimenez
5267b630f8 Added code for single port psx to ps3 adapter
On branch master
 Changes to be committed:
	modified:   ../griffin/griffin.c
	modified:   ../input/connect/connect_ps2adapter.c
	new file:   ../input/connect/connect_psxadapter.c
	modified:   ../input/connect/joypad_connection.c
	modified:   ../input/connect/joypad_connection.h
2017-06-17 14:19:09 -07:00
twinaphex
96c8ca5a09 Header update #1 2017-01-22 13:40:32 +01:00
Brad Parker
1d3e1a6962 DOS/DJGPP buildfix 2017-01-20 18:23:45 -05:00
twinaphex
a5e4ea2f33 C89_BUILD fix 2016-12-24 01:47:01 +01:00
Dave Leaver
f7c6574b37 Correctly handle adding controllers if we fail to match them to the known pad_map. 2016-12-16 20:16:55 +13:00
twinaphex
afe67ca254 C89/C90 don't support bitfields on uint8_t - work around this 2016-06-07 14:47:54 +02:00
twinaphex
974d3245d2 Fix logically dead code warnings 2016-05-23 22:04:00 +02:00
twinaphex
4a7ab8366b Move libretro.h headers to libretro-common/include 2016-05-10 19:03:53 +02:00
twinaphex
4f2d1d7c93 Silence warning 'val may be unused uninitialized in this function' 2016-04-21 07:22:26 +02:00
twinaphex
97d5a971a4 Change header includes 2016-04-17 07:34:01 +02:00
Ernesto Ramirez
c4f2de321a (GX) Added PS2/PSX Controller Adapter for HID driver. 2016-04-16 19:33:17 -05:00
twinaphex
24f5275001 Use wiiugca for non-Wii too 2016-02-04 23:49:04 +01:00
twinaphex
407d85f604 Use nesusb/snesusb for non-Wii too 2016-02-04 23:43:33 +01:00
netux79
bca4ccb155 (GX) Refactor of the Wii USB HID support. Now it's working!
In order to have a controller working you need:
1) Have a matching HID autoconfig file in autoconfig/hid for your controller.
2) Create a "connect" driver for the pad in "input/connect" folder (source code of RA).
3) Once you are in RA, change the joystick driver to HID and restart.
4) You may be now able to use you USB HID compatible pad in RA.

I included some "connect" drivers as an example. It also need to include them for compilation.
2016-02-04 17:01:03 -05:00
twinaphex
2e8f015de3 Cleanups 2016-02-04 21:07:02 +01:00