Conversation
| bool WPAD_IsBatteryCritical(int chan); | ||
|
|
||
| s32 WPAD_HasMotionPlus(s32 chan); | ||
| #define WPAD_EXP_MOTION_PLUS 5 |
There was a problem hiding this comment.
The #define WPAD_EXP_MOTION_PLUS 5 is important because it exposes Motion Plus as an official public API constant. Now that Motion Plus actually works, external code needs to know what the value 5 represents. Without it in the header, 5 stays an undocumented magic number. The constant makes Motion Plus a discoverable, documented part of the API.
There was a problem hiding this comment.
Please don't add this: we already have EXP_MOTION_PLUS defined in a public header, and there's a way of checking if the motion plus is available, using the currently public API: just check the exp.type field of the WPADData structure.
If you really want to make it even more convenient, you could add this to the wpad.h header:
static inline bool WPAD_HasMotionPlus(s32 chan) {
return WPAD_Data(chan)->exp.type == EXP_MOTION_PLUS;
}There was a problem hiding this comment.
Hi mardy,
Just to clarify what my new code actually does: it ensures that the Wii MotionPlus can be reliably detected as physically present using libogc. Before these changes, detection wasn’t consistent, and the gyroscope values from MotionPlus were all zeros, so motion data wasn’t accessible at all. With my fixes, the MotionPlus now responds correctly to motion, and developers can safely detect and use it.
That’s why I added the new header — it’s directly tied to these fixes and makes the feature work reliably in practice.
Thanks for taking a look.
| bool WPAD_IsBatteryCritical(int chan); | ||
|
|
||
| s32 WPAD_HasMotionPlus(s32 chan); | ||
| #define WPAD_EXP_MOTION_PLUS 5 |
There was a problem hiding this comment.
Please don't add this: we already have EXP_MOTION_PLUS defined in a public header, and there's a way of checking if the motion plus is available, using the currently public API: just check the exp.type field of the WPADData structure.
If you really want to make it even more convenient, you could add this to the wpad.h header:
static inline bool WPAD_HasMotionPlus(s32 chan) {
return WPAD_Data(chan)->exp.type == EXP_MOTION_PLUS;
}
Hey,
I was messing around with Motion Plus on my Wii and noticed it never worked in any homebrew app. Looked into the libogc source and found some bugs in motion_plus.c that explain why.
The probe function was reading from WM_EXP_MOTION_PLUS_MODE (0x04A600FE) instead of WM_EXP_ID (0x04A400FA) which are completely different memory banks on the Wiimote. On top of that it was only reading 2 bytes when the identifier is 6 bytes long, which meant data[5] was always an out of bounds read. And then it was checking data[1] != 0x05 when the correct byte to check is data[5] since 0x05 is the last byte of the Motion Plus identifier (00 00 A6 20 00 05).
Fixed all three in motion_plus.c. Also added WPAD_HasMotionPlus() in wpad.c since there was no public way to check if Motion Plus is present, and added WPAD_EXP_MOTION_PLUS as a constant to match the existing WPAD_EXP_NUNCHUK and WPAD_EXP_CLASSIC.
Tested on real Wii hardware with both the original Motion Plus accessory and a built-in Wiimote Plus. Gyro data works and detection works correctly.