Skip to content

Wii Motion Plus Fixed#260

Open
gitman123323 wants to merge 3 commits intodevkitPro:masterfrom
gitman123323:master
Open

Wii Motion Plus Fixed#260
gitman123323 wants to merge 3 commits intodevkitPro:masterfrom
gitman123323:master

Conversation

@gitman123323
Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Member

@DacoTaco DacoTaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a glance from far away. im not that educated on wpad stuff. i think @Zarithya or @mardy have more functional knowledge of how the stuff works :)

Comment thread wiiuse/wpad.c
Comment thread gc/wiiuse/wpad.h
bool WPAD_IsBatteryCritical(int chan);

s32 WPAD_HasMotionPlus(s32 chan);
#define WPAD_EXP_MOTION_PLUS 5
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused define?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Copy Markdown
Author

@gitman123323 gitman123323 Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gitman123323 gitman123323 requested a review from DacoTaco March 23, 2026 13:33
Comment thread gc/wiiuse/wpad.h
bool WPAD_IsBatteryCritical(int chan);

s32 WPAD_HasMotionPlus(s32 chan);
#define WPAD_EXP_MOTION_PLUS 5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Comment thread wiiuse/motion_plus.c
Comment thread wiiuse/wpad.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants