Commit Graph

41668 Commits

Author SHA1 Message Date
Twinaphex
f63385de08
Merge pull request #5994 from orbea/bsd
qb: Include /usr/local/lib for *bsd too
2017-12-30 05:25:59 +01:00
Twinaphex
6c08ceacb9
Merge pull request #5995 from meepingsnesroms/master
Fix new 3ds xl not being detected, others
2017-12-30 05:25:46 +01:00
gblues
ec45df79f4 Dummy out calls into HID driver
== DETAILS

Got system memory error. Probably because the calls aren't properly
implemented. So  dummy them out for now.
2017-12-30 04:43:46 +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
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
d0368124e6 Add OSFastMutex WiiU calls to list of imports 2017-12-30 04:40:10 +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
a792112bd1 Update glslang support for MSVC 2017-12-30 04:36:35 +01:00
meepingsnesroms
d18ee7eaed Fix new 3ds xl not being detected, others
Also fixes whitespace in makefile and platform_ctr.c and compiles with debug libctru when DEBUG=1
2017-12-29 19:30:54 -08:00
orbea
1b404afc86 qb: Include /usr/local/lib for *bsd too 2017-12-29 16:06:04 -08: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
Alcaro
ad7dd75458 this name makes slightly more sense. 2017-12-29 21:16:28 +01:00
Alcaro
fc725e252e Maybe #5989 can accept this compromise 2017-12-29 21:15:25 +01:00
Twinaphex
22062fdf91
Merge pull request #5991 from orbea/gl
qb: Include /usr/local/include for bsd based systems.
2017-12-29 21:08:41 +01:00
Twinaphex
c4049946ea
Merge pull request #5990 from orbea/revert-5983-patch-1
Revert "config.libs.sh: reintroduce HAVE_X11 check"
2017-12-29 21:08:10 +01:00
orbea
6ab2244a43 qb: Do not check for x11 when using --disable-x11. 2017-12-29 11:25:35 -08:00
orbea
72e3d5c38c Makefile: Fix debug builds. (#5989)
RetroArch builds debug builds by default after commit ec4b0f9089
This is very bad and breaks ./configure && make.
2017-12-29 14:00:53 -05:00
orbea
a34555c9a9 qb: Include /usr/local/include for bsd based systems.
This resolves an issue where the default freebsd compiler does not
include /usr/local/include which contains important headers such as
GL/gl.h and results in the check_header function failing to find them.

Unfortunately pkg-config/pkgconf will not work here for two reasons.
1. It does not seem able to actually check for gl.h which RetroArch
explicitly needs.

2. Not all systems have a pkg-config implementation so we will still
have to fall back to checking for gl.h...

Fixes https://github.com/libretro/RetroArch/issues/5958
2017-12-29 10:23:14 -08:00
orbea
eaccab5237
Revert "config.libs.sh: reintroduce HAVE_X11 check" 2017-12-29 18:04:07 +00:00
Alcaro
ec4b0f9089 What kind of bug farm is this filestream thingy 2017-12-29 15:32:07 +01:00
twinaphex
8c2070947e Prevent some warnings 2017-12-29 13:00:24 +01:00
Twinaphex
c872edcc2b
Merge pull request #5986 from RobLoach/patch-25
xmb: Add a few icons to the menu
2017-12-29 09:23:55 +01:00
Rob Loach
0a65875956
xmb: Add a few icons to the menu 2017-12-29 02:18:40 -05:00
Twinaphex
96f5323723
Update CHANGES.md 2017-12-29 06:57:17 +01:00
Twinaphex
ba8b5749ac
Merge pull request #5985 from meepingsnesroms/master
Basic networking for 3DS, bug fixes
2017-12-29 06:56:45 +01:00
meepingsnesroms
7dbaa45172 Basic networking, bug fixes
Fix CPU count bug, make 3ds compile with networking
2017-12-28 21:49:21 -08:00
Twinaphex
688443b9a6
Merge pull request #5984 from RobLoach/slow-motion-granularity
settings: Add Slow Motion Ratio granularity
2017-12-29 06:00:09 +01:00
Rob Loach
10076706b5
settings: Add Slow Motion Ratio granularity
This makes it so that the Slow Motion setting can be set to something like 1.2, rather than 1 increments.

Fixes #5917
2017-12-28 23:51:41 -05:00