Add Wiimote + Classic Controller support
askot askot.altair@gmail.com
Fri, 21 Aug 2015 23:09:16 -0700
1 files changed,
47 insertions(+),
17 deletions(-)
jump to
M
src/platform/wii/main.c
→
src/platform/wii/main.c
@@ -8,6 +8,7 @@
#include <fat.h> #include <gccore.h> #include <malloc.h> +#include <wiiuse/wpad.h> #include "util/common.h"@@ -52,6 +53,7 @@
int main() { VIDEO_Init(); PAD_Init(); + WPAD_Init(); AUDIO_Init(0); AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_RegisterDMACallback(_audioDMA);@@ -195,35 +197,50 @@ }
#endif PAD_ScanPads(); u16 padkeys = PAD_ButtonsHeld(0); + WPAD_ScanPads(); + u32 wiiPad = WPAD_ButtonsHeld(0); + u32 ext = 0; uint16_t keys = 0; - if (padkeys & PAD_BUTTON_A) { + WPAD_Probe(0, &ext); + + if ((padkeys & PAD_BUTTON_A) || (wiiPad & WPAD_BUTTON_2) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & (WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y)))) { keys |= 1 << GBA_KEY_A; } - if (padkeys & PAD_BUTTON_B) { + if ((padkeys & PAD_BUTTON_B) || (wiiPad & WPAD_BUTTON_1) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & (WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_X)))) { keys |= 1 << GBA_KEY_B; } - if (padkeys & PAD_TRIGGER_L) { + if ((padkeys & PAD_TRIGGER_L) || (wiiPad & WPAD_BUTTON_B) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_FULL_L))) { keys |= 1 << GBA_KEY_L; } - if (padkeys & PAD_TRIGGER_R) { + if ((padkeys & PAD_TRIGGER_R) || (wiiPad & WPAD_BUTTON_A) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_FULL_R))) { keys |= 1 << GBA_KEY_R; } - if (padkeys & PAD_BUTTON_START) { + if ((padkeys & PAD_BUTTON_START) || (wiiPad & WPAD_BUTTON_PLUS) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_PLUS))) { keys |= 1 << GBA_KEY_START; } - if (padkeys & (PAD_BUTTON_X | PAD_BUTTON_Y)) { + if ((padkeys & (PAD_BUTTON_X | PAD_BUTTON_Y))|| (wiiPad & WPAD_BUTTON_MINUS) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_MINUS))) { keys |= 1 << GBA_KEY_SELECT; } - if (padkeys & PAD_BUTTON_LEFT) { + if ((padkeys & PAD_BUTTON_LEFT)|| (wiiPad & WPAD_BUTTON_UP) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_LEFT))) { keys |= 1 << GBA_KEY_LEFT; } - if (padkeys & PAD_BUTTON_RIGHT) { + if ((padkeys & PAD_BUTTON_RIGHT) || (wiiPad & WPAD_BUTTON_DOWN) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_RIGHT))) { keys |= 1 << GBA_KEY_RIGHT; } - if (padkeys & PAD_BUTTON_UP) { + if ((padkeys & PAD_BUTTON_UP) || (wiiPad & WPAD_BUTTON_RIGHT) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_UP))) { keys |= 1 << GBA_KEY_UP; } - if (padkeys & PAD_BUTTON_DOWN) { + if ((padkeys & PAD_BUTTON_DOWN) || (wiiPad & WPAD_BUTTON_LEFT) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_DOWN))) { keys |= 1 << GBA_KEY_DOWN; } int x = PAD_StickX(0);@@ -240,7 +257,7 @@ }
if (y > 0x40) { keys |= 1 << GBA_KEY_UP; } - if (padkeys & PAD_TRIGGER_Z) { + if ((padkeys & PAD_TRIGGER_Z) || (wiiPad & WPAD_BUTTON_HOME) || (wiiPad & WPAD_CLASSIC_BUTTON_HOME)) { break; } GBAContextFrame(&context, keys);@@ -350,23 +367,36 @@
static int _pollInput(void) { PAD_ScanPads(); u16 padkeys = PAD_ButtonsHeld(0); + + WPAD_ScanPads(); + u32 wiiPad = WPAD_ButtonsHeld(0); + u32 ext = 0; + int keys = 0; - if (padkeys & PAD_BUTTON_A) { + + WPAD_Probe(0, &ext); + if ((padkeys & PAD_BUTTON_A) || (wiiPad & WPAD_BUTTON_2) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & (WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y)))) { keys |= 1 << GUI_INPUT_SELECT; } - if (padkeys & PAD_BUTTON_B) { + if ((padkeys & PAD_BUTTON_B) || (wiiPad & WPAD_BUTTON_1) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & (WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_X)))) { keys |= 1 << GUI_INPUT_BACK; } - if (padkeys & PAD_BUTTON_LEFT) { + if ((padkeys & PAD_BUTTON_LEFT)|| (wiiPad & WPAD_BUTTON_UP) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_LEFT))) { keys |= 1 << GUI_INPUT_LEFT; } - if (padkeys & PAD_BUTTON_RIGHT) { + if ((padkeys & PAD_BUTTON_RIGHT) || (wiiPad & WPAD_BUTTON_DOWN) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_RIGHT))) { keys |= 1 << GUI_INPUT_RIGHT; } - if (padkeys & PAD_BUTTON_UP) { + if ((padkeys & PAD_BUTTON_UP) || (wiiPad & WPAD_BUTTON_RIGHT) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_UP))) { keys |= 1 << GUI_INPUT_UP; } - if (padkeys & PAD_BUTTON_DOWN) { + if ((padkeys & PAD_BUTTON_DOWN) || (wiiPad & WPAD_BUTTON_LEFT) || + ((ext == WPAD_EXP_CLASSIC) && (wiiPad & WPAD_CLASSIC_BUTTON_DOWN))) { keys |= 1 << GUI_INPUT_DOWN; } return keys;