Commit Graph

211 Commits

Author SHA1 Message Date
Alfredo Monclus bbd9a6566c WiiU: C89 style comments 2018-01-06 09:44:03 -03:00
twinaphex 8c20206afa Update 2018-01-06 12:35:00 +01:00
gblues 560a5f0a4f Fix the blocking call to HIDRead()
== DETAILS

TIL that the "max_packet_size_*" fields in the HIDDevice struct
are actually requirements, not maximums.

The reason HIDRead() was blocking was because the HIDWrite() that
sent the activation command was silently failing.

The reason HIDWrite() was silently failing was because I was using too
small of a buffer for the device.

In this case: the Wii U GC adapter, which has a "max" tx packet size of 5.

"max" is misleading. You actually have to write all 5 bytes.

Which means: copying the 1-byte buffer to the 5-byte buffer, and writing
the 5-byte buffer via HIDWrite().

So, in summary:

- Use correct semantics for HIDWrite() so that HIDRead() can work.
- Update the OSThread struct to reflect the current knowledge over at
  WUT. It's unlikely this was actually causing a problem, but never
  hurts to be more correct.

== TESTING
I temporarily enabled the call to log_buffer() and confirmed that the
GC adapter's state is successfully being read.
2018-01-05 23:12:42 -08: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
Andrés dedcd26495
Merge pull request #6053 from aliaspider/master
(WIIU) add preliminary multi-pass shader support.
2018-01-05 21:48:30 -05:00
aliaspider 55d262f5d8 (WIIU) add preliminary multi-pass shader support.
can load *.slangp and *.slang files. since there is no runtime compiler,
precompiled shaders (*.gsh) need to be present next to each *.slang
source file.
2018-01-06 03:39:53 +01:00
Twinaphex 3dff396ff4
Merge pull request #6050 from aliaspider/master
(WIIU) add a frame shader to match the shaders used by gl/vulkan
2018-01-05 13:49:10 +01:00
aliaspider 8e095164e0 (WIIU) add a frame shader to match the shaders used by the gl/vulkan
drivers.
2018-01-05 13:18:55 +01:00
twinaphex cf8e7cd362 (wiiu) small style nits; declare variables at top; C comments 2018-01-05 13:09:05 +01:00
Twinaphex af9911df8a
Merge pull request #6048 from gblues/master
Fix RETRO_DEVICE_ID_POINTER_PRESSED handling
2018-01-05 12:39:52 +01:00
gblues 34b120c269 Fix unfreed memory bug
== DETAILS
This should fix #6025.

After confirming that dummying out the init block of the HID subsystem
driver eliminated the crash, I narrowed it down to the event loop.

And that's when I noticed that, when the thread consumes the event,
it doesn't free it.

Oops.

Updated the event loop to free the event after it has been processed.

== TESTING
Local build, was able to load multiple ROMs in succession where prior
I was getting the system memory errors.

I've #if 0'd out a call to HIDRead that is still getting deadlocked,
because it slows down the startup/shutdown process.
2018-01-05 00:16:59 -08:00
gblues 3a0468523a Fix RETRO_DEVICE_ID_POINTER_PRESSED handling
== DETAILS

The joypad driver was only copying the first 16 bits when executing
get_buttons(). The touchpad button is bit 19, so as a result
RETRO_DEVICE_ID_POINTER_PRESSED would never fire.

We fix this for now by copying 32 bits.

== TESTING

Will need someone to verify. I don't  have a core handy that leverages
the pointer device state functionality.
2018-01-04 22:13:30 -08:00
aliaspider 3979d03cb3 (WIIU) add a gfd shader file reader. 2018-01-04 23:03:11 +01:00
aliaspider a7632620da (WIIU) add a sprite shader. 2018-01-04 17:38:04 +01:00
aliaspider e63697dca7 (WIIU) fix net logger. 2018-01-04 17:21:16 +01:00
gblues 80cdb92154 Re-re-fix wpad scaling. For real this time.
== DETAILS

@r-type got me the link to the fixed-fixed version.

Which was actually closer to where I was originally!

So:

- Revert the previous commit
- Apply the actual changes needed to fix the problem
- Bring in and fix the logging code from the previous implementation

== TESTING
- Verified that top-left is -0x7fff,-0x7fff and that bottom-right is
  0x7fff, 0x7fff.

== REVIEW
@QuarkTheAwesome @r-type @twinaphex
2018-01-03 21:32:00 -08:00
gblues c1ef5c5497 Revert "Fix wiiu touchpad scaling"
This reverts commit 1d933a6b52.
2018-01-03 19:57:38 -08:00
gblues 1d933a6b52 Fix wiiu touchpad scaling
== DETAILS

Apparently when I refactored this code, I missed out on the fix for
touchpad coordinates that @QuarkTheAwesome had committed.

Oops.

- Fix the touchpad coordinates
- Remove unneeded references to video driver in wpad_driver.c
- Remove unneeded video driver include in pad_driver.h
- Add logging in wpad_driver to verify the fix (#ifdef'd out by default)

== TESTING

Verified fix manually.
2018-01-02 23:25:03 -08:00
aliaspider 0a32642f17 (WIIU) shader: use a single attribute stream. 2017-12-31 14:06:49 +01:00
gblues c2d2fe971e Add timeout for HID thread shutdown
== DETAILS
If a call to HIDRead() ends up blocking indefinitely, it will
cause the shutdown process to wait forever.

To avoid a deadlock, I've put in a retry counter so that it will
give up after 5s and print a warning to the log.
2017-12-30 20:59:07 -08:00
Twinaphex d9c0f769c7
Merge pull request #6006 from aliaspider/master
(WIIU) update shader and add alpha blending to menu + overlays.
2017-12-31 00:21:53 +01:00
aliaspider b371f4bb32 (WIIU) add a color attribute to tex_shader.
+ some fixes to overlay and menu display code.
2017-12-30 23:21:32 +01:00
aliaspider f6fdd421c6 (WIIU) shaders: use bitfields for GPU register values. 2017-12-30 16:39:23 +01:00
twinaphex 136fb6e3c9 (WIIU) Cleanup 2017-12-30 15:35:32 +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 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 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 d0368124e6 Add OSFastMutex WiiU calls to list of imports 2017-12-30 04:40:10 +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
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
Ash 52fb8276d7
[WiiU] Exception handler: minor comment tweak 2017-12-01 11:03:09 +11:00
Ash 469662345f
[WiiU] Exception handler: remove opcodes; fix strcmp misuse
Thanks for @gblues for finding the strcmp bug.
I've removed the opcode display since it's a bit unsafe - if the
exception handler causes a DSI; Cafe OS will take over and freeze up the
console. This is obviously not a good thing. There are possible
situations where memory is executable and not readable; so this is just
about covering all bases until a better solution can be implemented.
Maybe we can experiment a bit more once this handler isn't being used so
often ;)
2017-12-01 10:56:54 +11:00
Ash a79d3aa8aa
[WiiU] Exception handler: fix coreinit handles, add opcode to DSIs
Coreinit seems to get special handles, so adding a special case should
make its relative addresses actually become helpful again. Let's just
hope __PPCExit stays at 0x180!
Also added the violating opcode to the DSI message; may have to move it
in case it pushes stuff off the end of the screen.

Untested at time of commit. Hopefully this should make debugging #5357 a
bit easier...
2017-12-01 10:54:21 +11:00
Ash 5f00e2f6bb
[WiiU] Reformat fs_utils.c
Was getting warnings around misleading indentation when there
was none, so just redid the whole file.
2017-11-04 20:37:30 +11:00
Ash 0d38612f4a
[WiiU] Various warning/format string fixes
All things from unsigned comparisons to missing initializers; we got it
here.
2017-11-04 20:37:30 +11:00
Ash b49268a9e9
[WiiU] Redo exception handler format strings
Deals with the infamous devkitPPC "int32_t = long int" thing, and
future-proofs in case they ever change it back.
2017-11-04 20:37:30 +11:00
Maschell 6fa80376e0 [Wii U]Added some more checks while parsing the configuration files for the HID controller
This hopefully fixes the crashes when starting retroarch with (faulty)
.ini files
2017-10-25 21:16:31 +02:00
Brad Parker 19af87214a wiiu: only one dash for gcc -std 2017-10-20 23:43:33 -04:00
Maschell 05ef63fd08 [WII U] Fix for Issue #5556
This hopefully fixes the issues when you try to use 2 Controllers with
the same vid/pid at the same time.

Tested with 2 DS4 controller via the Hid to VPAD Network Client.
Adapters with multiple ports (like the official GC-Adapter) are still
working
2017-10-17 21:38:42 +02:00
Ash 6b5aef09a1
[WiiU] DRC touch support as pointer device
Allow using the Gamepad's touch screen as a RETRO_DEVICE_POINTER.
Methodology could use some work, had to add an extra axis to
joypad in order to get the data transferred into the input driver.
Feel free to change this.
Needs to emulate RETRO_DEVICE_LIGHTGUN to really be useful.
Potential for Wiimote IR in future.

Partially addresses libretro/RetroArch#5294
2017-08-19 17:40:56 +10:00
not6 10492c1ee7 Update imports.h
add additional imports  (semaphore)
2017-08-07 23:25:05 +02:00
Ash 40a4a5a733
[WiiU] Rewrite exception handler 2017-08-04 21:30:49 +10:00
Ash 2492f3d6b3 Add missing_libc_functions.c (for DOSBox) 2017-06-15 15:21:38 +10:00
Ash 7f5986e1d5 Rename Wii U log functions (conflict in DOSBox) 2017-06-15 15:20:58 +10:00
aliaspider f589c50043 (WiiU) misc. 2017-05-28 12:42:19 +01:00
aliaspider 5a92ec15cf (WiiU) fix netplay. 2017-05-26 12:32:45 +01:00
aliaspider 934f7c58ba (WiiU) enable networking. 2017-05-23 10:24:23 +01:00
aliaspider b17e76d8b7 (WiiU) add freetype and stb font support.
freetype disabled by default due to requiring an external library.
2017-05-21 04:22:32 +01:00
aliaspider 8dee95651f (WiiU) add a font driver. 2017-05-21 03:05:41 +01:00
Maschell bd8d3d66d7 [Wii U] Using the controller_patcher lib files directly instead of including it as a submodule 2017-05-20 20:23:01 +02:00
Maschell 7a2c09e9ce [Wii U ] Proper order of the HID devices.
Added individual names for the HID devices.
2017-05-20 19:26:12 +02:00
Maschell fa0d82b188 [Wii U] Fixing the .rpx build 2017-05-20 13:13:52 +02:00
Maschell 4393e17ea7 [Wii U] Using the HID Controller as a own controller. Currently the stick only work when it's bind manually. Mapping from controller to retroarch input port may change when you attach a new device. 2017-05-08 21:46:34 +02:00
Maschell 11a0610d13 [Wii U] Updating to new controller patcher. Removing debug stuff. 2017-05-08 12:32:02 +02:00
Maschell e695d4e8ad [WiiU] Initial controller patcher support (HID via USB and network)
- Reading config from sd cards currently broken
- Not implemeted as a driver, currently all devices will be mapped to the WiiU Gamepad driver
2017-05-08 12:24:06 +02:00
Maschell da0f3620bc [Wii U] Adding missing includes and defines 2017-05-08 12:18:28 +02:00
xhp-creations 4915f452f5 WiiU Initial Keyboard Support
WiiU Initial Keyboard Support
2017-02-09 12:34:12 -05:00
aliaspider 8f88d8fb4d (WiiU) implement the missing requirement for core loading: exec,
exitspawn, set_fork and salamander.
2017-01-25 19:52:31 +01:00
aliaspider 021b510452 (WiiU) refactors/cleanups. 2017-01-23 16:14:05 +01:00
aliaspider 272f7c0a85 (WiiU) cleanups. 2017-01-23 16:01:53 +01:00
aliaspider 1601febabc (WiiU) buildfix for devkitPPC r29.
- add wut headers and elf2rpl to source tree.
2017-01-23 16:01:53 +01:00
aliaspider 8cb692622a (WiiU) add support for bluetooth controllers (Wiimote, nunchuk, classic
controller, wiiu pro controller).
2017-01-16 18:52:39 +01:00
FIX94 c0b023a1cf (WiiU) added basic libiosuhax support 2016-12-17 18:42:04 +01:00
FIX94 df956efd43 (WiiU) properly set audio offset before starting playback 2016-11-30 02:37:42 +01:00
FIX94 53042b58b0 (WiiU) changed linker script to now properly generate a small rpx elf file instead of a 243mb one every time 2016-11-24 09:09:23 +01:00
aliaspider f43c7254ee (WiiU) add a helper macro for DisassemblePPCRange. 2016-11-24 00:34:03 +01:00
FIX94 19ab43ae90 (WiiU) added additional imports 2016-11-23 23:53:22 +01:00
aliaspider 2b4e4d56cd (WiiU) no need to specify library name for IMPORT_END() anymore. 2016-11-23 08:47:02 +01:00
aliaspider ea248559e0 (WiiU) rpx update:
- c++ static constructors/destructors fix for rpx builds.
- building both rpx and hbl elf formats doesn't require a clean step
inbetween anymore, both can be now built in a single make call.
2016-11-23 03:21:01 +01:00
aliaspider eedbea4527 (WiiU) build RPX imports from imports.h. 2016-11-23 00:06:35 +01:00
aliaspider 3acdf3d1cb (WiiU) import only the needed symbols. 2016-11-22 22:48:44 +01:00
FIX94 b3eb8ec3be (WiiU) use some more direct callback for audio updates and added safety into it 2016-11-22 02:39:12 +01:00
FIX94 0c314d0159 (WiiU) more audio driver cleanup 2016-11-22 00:37:22 +01:00
FIX94 b29cdef8ec (WiiU) continuation of the audio driver changes from yesterday 2016-11-21 22:47:29 +01:00
aliaspider 3cb5ab32f5 (WiiU) add missing file. 2016-11-16 20:12:45 +01:00
aliaspider 3cc1ddbdd1 (WiiU) simplify memory.c 2016-11-16 18:25:23 +01:00
aliaspider 418787e6ca (WiiU) can't use start files with rpx buidls yet (this also means, no C+
+ static constructors support).
2016-11-16 17:44:54 +01:00
aliaspider 4089f9ec63 (WiiU) use the already defined __init and __fini symbols. 2016-11-16 17:43:04 +01:00
aliaspider 286a1887a9 (WiiU) change linker script, add calls to _init() and _fini().
fixes cores relying on C++ static constructors/destructors. (only for
elf builds)
2016-11-15 19:37:30 +01:00
aliaspider 6f7f6a363b (WiiU) only wait for vsync when not missed. 2016-11-10 14:24:20 +01:00
aliaspider 225edffce1 (WiiU) fix wiiload script. 2016-11-10 08:32:45 +01:00
aliaspider deb9ea4453 (WiiU) netlog scripts. 2016-11-09 14:28:39 +01:00
aliaspider dbd8a87ebb (WiiU) can compile as rpx. (doesn't exit properly) 2016-11-09 14:26:38 +01:00
aliaspider 8b07cf5fd6 (WIIU) calling FSFlushFile each write doesn't seem to be necessary
anymore.
2016-11-08 09:51:05 +01:00
aliaspider 5a17f0ba3c add missing copyright notice. 2016-11-06 19:03:08 +01:00
aliaspider a0383e6b6a (WIIU) keep the dynlib handles. 2016-11-06 18:59:39 +01:00
aliaspider 31edafde03 (WIIU) add timers, fix retro_sleep. 2016-11-06 11:55:56 +01:00
aliaspider 2aa555fb95 (WIIU) forgot to add this file too. 2016-11-05 15:09:37 +01:00
aliaspider d3b3c18a6f (WIIU) GX2 rendering. 2016-11-05 15:05:46 +01:00
aliaspider 0433cae3c9 (WIIU) misc. 2016-11-05 15:01:43 +01:00
aliaspider 176dd79f33 (WIIU) misc. 2016-11-02 22:06:15 +01:00
aliaspider e055b7cbc1 (WIIU) cleanup. adapt dynamic symbol loading to be able to use headers
from WUT.
2016-10-29 02:56:40 +01:00
aliaspider ac915abb5d (WIIU) edit netloader script. 2016-10-28 00:28:44 +01:00
aliaspider cf1e9f38ce (WIIU) flush to file after each write, this is a temporary fix as it
seems to hang in FSWriteFile after writing 0x8000 bytes otherwise.
2016-10-28 00:25:47 +01:00
aliaspider 30d31538b1 (WIIU) add an alternative exception handler (source: https://github.com/
QuarkTheAwesome/URetro)
2016-10-27 23:19:54 +01:00
aliaspider 8bdc40d5f8 (WIIU) exception handler: use net_print directly 2016-10-27 23:03:56 +01:00
aliaspider 2a7f5d8ba3 (WIIU) alternative memory allocation functions (from wut) 2016-10-27 23:03:21 +01:00
aliaspider 844c6ed582 (WIIU) misc. 2016-10-27 19:53:56 +01:00
aliaspider 02c38d23c1 (WIIU) enable the exception handler. 2016-10-27 19:53:27 +01:00
aliaspider 0c3dc1e6b2 (WIIU) edit the .ld script to keep the debug symbols. 2016-10-27 19:37:53 +01:00
aliaspider 962baabe5d (WIIU) add missing files in dynamic_libs, add exception_handler 2016-10-27 18:58:19 +01:00
aliaspider cb7e880df6 (WIIU) update dynamic_libs (https://github.com/Maschell/dynamic_libs) 2016-10-27 18:17:20 +01:00
aliaspider 094b725ad6 (WIIU) disable mem2/frontend driver 2016-10-27 15:49:21 +01:00
aliaspider 185849d5ff (WIIU) add frontend driver, allocate mem2 2016-10-27 15:33:40 +01:00
aliaspider a4d745a471 preliminary port to the wiiu platform 2016-10-27 01:34:10 +01:00