131 Commits

Author SHA1 Message Date
twinaphex
4f7f237644 (Wiiu) uniquely name global variable 'pos' to prevent collissions with
variables in other cores (like freeintv)
2018-02-03 15:40:54 +01:00
Ash
af37d3780a
[WiiU] Fix indentation, for real this time
-_-
2018-01-30 17:43:45 +11:00
Ash
68f7aeadb2
[WiiU] Reformat line indents
Not sure what happened there. Do we need a squash merge now?
2018-01-30 17:38:16 +11:00
Ash
3a442af6be
[WiiU] Add missing time/clock libc functions
Add some timing functions so that we can know the time (woo-hoo?)
I use errno here, which worries me a bit. I wouldn't put it past
devkitPPC to have it as a null pointer or something.

Can confirm this makes XMB's clock work, much to @cucholix's delight;
I'm sure ;D
2018-01-30 17:14:58 +11: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
Twinaphex
a3757cea70
Merge pull request #6165 from gblues/master
Fix wiimote detection
2018-01-24 06:38:19 +01:00
gblues
9e2d53dc99 Fix wiimote detection
== DETAILS
When I split out wiiu_gamepad into multiple sub-drivers, I missed a spot.

The code expects the device type to be initialized to a magic number
(0xfd), and instead it was getting initalized to zero, which meant it
never triggered the detection process.

I re-added the initialization, and now it works.

== TESTING

Tested with nestopia core to confirm autodetect and game response works.
2018-01-23 19:57:51 -08:00
aliaspider
c8027ebe1d (tools) add the tool used to generate the d3d headers. 2018-01-21 04:28:06 +01:00
gblues
86ac651edf Fix disabled HID code, add defensive programming
== DETAILS

1. Noticed that the HID driver wasn't loading after setting WIIU_HID=1. Found
   that the HID driver init was ifdef'd out. Removed that.

2. Current theory around "System Memory Error 160-2203" is in-memory
   corruption. So, to try to identify it:

   - Created a routine that does a hex dump of the RPX over the logger. (I
     have a python3 script that can extract the hex dump back into a binary
     file). If a SME occurs with this routine enabled, we can see if the
     corruption is happening at read-time, or somewhere between when we send
     the RPX to the loader and try to execute it.

   - I noticed that we allocate slightly more memory than the RPX actually
     needs, and we don't zero the memory, which means there's a handful of
     bytes at the end that could be anything. I added a call to memset() to
     zero out the memory prior to loading the RPX off the SD card.

And, of course, after adding those, I haven't been able to reproduce the
System Memory Error, so maybe the uninitialized memory was the problem?

Here's hoping.
2018-01-18 19:57:19 -08:00
gblues
1515bd8c1b Minor cleanups
== DETAILS
- Add *.swp to gitignore so editor swap files don't get committed
- Remove unneeded commented-out defines from WiiU build
- Start on fix for DSI when switching cores on WiiU

== TESTING
Sigh. I'm back at "System Memory error", which makes me think the problem
might be the SD card. (On the plus side, I manually verified the hash so
at least the copy process is working).

So, that's to say that I can't actually test to see if the DSI error is
fixed.
2018-01-13 12:16:37 -08:00
aliaspider
24cb240079 (WIIU) add remaining menu shaders.
- move some files around.
2018-01-12 02:54:45 +01:00
aliaspider
eac088696a (WIIU) add ribbon shader. fix menu bg gradient. 2018-01-11 02:09:03 +01:00
Twinaphex
ae9e13324d
Merge pull request #6073 from aliaspider/master
(WIIU) improve support for custom shaders.
2018-01-09 03:22:49 +01:00
aliaspider
dc7c0a570f (WIIU) revert changes to net_listen.sh 2018-01-09 03:07:41 +01:00
aliaspider
42905d9bbb (WIIU) add a better converter for slang shaders. 2018-01-09 03:05:29 +01: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
aliaspider
6b24663dd9 (WIIU) add more NULL check to *_free functions. 2018-01-07 03:45:41 +01:00
aliaspider
7cc34302f4 (WIIU) check for NULL in gfd_free 2018-01-07 03:40:03 +01:00
aliaspider
517a3f801f (WIIU) add a tool to convert slang shaders. 2018-01-07 03:26:14 +01:00
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 1d933a6b52e15ec281deb2aff5151292b8ebe655.
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