From WiiUBrew
Revision as of 07:21, 22 April 2016 by Tueidj (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Reading Remote Values (solved)

Does anybody know how to correctly read data from the Wii Remote? Calling WPADRead and reading the button presses works perfectly, as long as the controllers are actually connected. If the controllers aren't connected, (mostly with controllers 3 and 4) I get a garbled mess of fake button presses. Does anybody know why? (see Wii Remote Button Tester for an example) You will see that some buttons are reported as being pressed, even though the controller isn't connected. CreeperMario (talk) 10:28, 20 April 2016 (CEST)

Just a guess but try actually checking the return value of WPADRead? Tueidj (talk) 11:46, 20 April 2016 (CEST)
Just tested that theory, and it appears that WPADRead always returns with 0, regardless of the input. The value of WPADStatus.err is randomized when remotes are disconnected, sometimes being zero, sometimes not. CreeperMario (talk) 12:45, 20 April 2016 (CEST)
In that case check if there's a function called WPADProbe which is what the wii's WPAD library uses for controller detection. Tueidj (talk) 01:44, 21 April 2016 (CEST)
Thanks! This does indeed work. As long as I call WPADProbe before WPADRead, I can safely avoid detecting fake button presses if the controller is not connected. CreeperMario (talk) 10:45, 21 April 2016 (CEST)

There should also be a WPADSetDataFormat function to specify what type of status should be filled... you would think whoever added the WPAD*Status struct definitions would have known they're useless without it. Tueidj (talk) 12:32, 21 April 2016 (CEST)

Interesting... I'll try that tomorrow morning, but I think I'm okay with the default settings. I haven't done any thorough testing yet, though. One thing that I find a little weird, though, is that the Wii U's WPADStatus structure only contains a 'buttons' field, despite the original Wii's implementation containing trigger, hold and release fields. On the Wii U, the GamePad has 'btn_trigger', 'btn_hold' and 'btn_release', but the Wii Remotes don't. Why? CreeperMario (talk) 14:05, 21 April 2016 (CEST)
Okay, we found another undocumented function. I can confirm that WPADSetDataFormat exists on the Wii U (because it doesn't crash when I try to use it), but I don't think it does anything. If I am correct (which I probably won't be, as this is the first I've heard of this function), performing WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS) on the Wii should block rotation/IR data from being accessed, or something similar to that. Calling WPADSetDataFormat(0, 0) on the Wii U still gives me access to the rotation/IR data. CreeperMario (talk) 00:12, 22 April 2016 (CEST)
You probably shouldn't expect anything from libogc's WPAD library to match up, it's one of the few parts that wasn't ripped directly from the official SDK. Tueidj (talk) 07:21, 22 April 2016 (CEST)