ricardoquesada / bluepad32

Bluetooth gamepad, mouse and keyboard support for ESP32 and PicoW
https://bluepad32.readthedocs.io/
Other
503 stars 53 forks source link

wii: support native WiiMote button mapping #99

Closed mdvorak closed 2 months ago

mdvorak commented 2 months ago

When library is used as controller host, and not translation layer for consoles, it is impossible to use WiiMote in predefined configuration. Additionally, buttons from Nunchuck are merged with WiiMote buttons, without ability to read them separately.

This PR adds public wii_force_flags function, which can be called during init. It forces wii controller to enter desired mode, regardless of buttons pressed during pairing. Additionally, it adds WII_FLAGS_NATIVE mode, which maps all buttons to the closest possible value. Additional remapping can be done via standard API.

While I understand wii_force_flags is not ideal solution, WiiMote is already very specific in many ways, and if you want to support it, this gives you easy way to do so. This does not affect other controllers at all.

Replaces #98

ricardoquesada commented 2 months ago

yes, I've been thinking about improving the Wii code.

I don't like that everything is hardcoded the way it is... the driver should provide primitives, and the clients should put Wii in the desired mode.

In any case, let's merge this pull-request... but I'll make some changes to in the coming days/weeks.

Invictaz commented 2 months ago

@mdvorak great add. Are you aware that the Wiimote functions different in horizontal mode than in vertical position? I have seen some github issues over the years that users request this.

ricardoquesada commented 2 months ago

a did a follow-up fix.

basically I merged "native" with "vertical". Removed the old behavior, the "native" is the current one. with some minor changes

https://github.com/ricardoquesada/bluepad32/commit/c810b8eb45a355299d35850a9445dd4ffa1a39be

mdvorak commented 2 months ago

Thats fantastic, thanks!