From 480e15a545764c60748e087dca49c4bf1c93b8b5 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Wed, 10 Nov 2021 12:37:44 -0500 Subject: [PATCH 01/16] Add DRC (Wii U GamePad) support for Wii U Based on some code from @emukidid. --- gc_input/controller-DRC.c | 233 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 gc_input/controller-DRC.c diff --git a/gc_input/controller-DRC.c b/gc_input/controller-DRC.c new file mode 100644 index 0000000..6dcb7d4 --- /dev/null +++ b/gc_input/controller-DRC.c @@ -0,0 +1,233 @@ +/* + * Not64 - controller-DRC.c (based in controller-Classic.c) + * Original from emu_kidid (imported by saulfabreg) + * Copyright (c) 2013 Extrems + * + * This file is part of Not64. + * + * Not64 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Not64 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with Not64; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include "controller.h" +#include + +#define DRC_DEADZONE 6 +#define _DRC_BUILD_TMPSTICK(inval) \ + tmp_stick16 = (inval*1.08f); \ + if(tmp_stick16 > DRC_DEADZONE) tmp_stick16 = (tmp_stick16-DRC_DEADZONE)*1.08f; \ + else if(tmp_stick16 < -DRC_DEADZONE) tmp_stick16 = (tmp_stick16+DRC_DEADZONE)*1.08f; \ + else tmp_stick16 = 0; \ + if(tmp_stick16 > 80) tmp_stick8 = 80; \ + else if(tmp_stick16 < -80) tmp_stick8 = -80; \ + else tmp_stick8 = (s8)tmp_stick16; + +static int getDRCValue(int in) +{ + //do scale, deadzone and clamp + s8 tmp_stick8; s16 tmp_stick16; + _DRC_BUILD_TMPSTICK(in); + return tmp_stick8; +} + +enum { + L_STICK_AS_ANALOG = 1, R_STICK_AS_ANALOG = 2, +}; + +enum { + L_STICK_L = 0x01 << 16, + L_STICK_R = 0x02 << 16, + L_STICK_U = 0x04 << 16, + L_STICK_D = 0x08 << 16, + R_STICK_L = 0x10 << 16, + R_STICK_R = 0x20 << 16, + R_STICK_U = 0x40 << 16, + R_STICK_D = 0x80 << 16, +}; + +static button_t buttons[] = { + { 0, ~0, "None" }, + { 1, WIIDRC_BUTTON_UP, "D-Up" }, + { 2, WIIDRC_BUTTON_LEFT, "D-Left" }, + { 3, WIIDRC_BUTTON_RIGHT, "D-Right" }, + { 4, WIIDRC_BUTTON_DOWN, "D-Down" }, + { 5, WIIDRC_BUTTON_L, "L" }, + { 6, WIIDRC_BUTTON_R, "R" }, + { 7, WIIDRC_BUTTON_ZL, "Left Z" }, + { 8, WIIDRC_BUTTON_ZR, "Right Z" }, + { 9, WIIDRC_BUTTON_A, "A" }, + { 10, WIIDRC_BUTTON_B, "B" }, + { 11, WIIDRC_BUTTON_X, "X" }, + { 12, WIIDRC_BUTTON_Y, "Y" }, + { 13, WIIDRC_BUTTON_PLUS, "+" }, + { 14, WIIDRC_BUTTON_MINUS, "-" }, + { 15, WIIDRC_BUTTON_HOME, "Home" }, + { 16, R_STICK_U, "RS-Up" }, + { 17, R_STICK_L, "RS-Left" }, + { 18, R_STICK_R, "RS-Right" }, + { 19, R_STICK_D, "RS-Down" }, + { 20, L_STICK_U, "LS-Up" }, + { 21, L_STICK_L, "LS-Left" }, + { 22, L_STICK_R, "LS-Right" }, + { 23, L_STICK_D, "LS-Down" }, +}; + +static button_t analog_sources[] = { + { 0, L_STICK_AS_ANALOG, "Left Stick" }, + { 1, R_STICK_AS_ANALOG, "Right Stick" }, +}; + +static button_t menu_combos[] = { + { 0, WIIDRC_BUTTON_X|WIIDRC_BUTTON_Y, "X+Y" }, + { 1, WIIDRC_BUTTON_ZL|WIIDRC_BUTTON_ZR, "ZL+ZR" }, +}; + +static unsigned int getButtons() +{ + const struct WiiDRCData *data = WiiDRC_Data(); + + unsigned int b = data->button; + + if(data->xAxisL < -20) b |= L_STICK_L; + if(data->xAxisL > 20) b |= L_STICK_R; + if(data->yAxisL > 20) b |= L_STICK_U; + if(data->yAxisL < -20) b |= L_STICK_D; + + if(data->xAxisR < -20) b |= R_STICK_L; + if(data->xAxisR > 20) b |= R_STICK_R; + if(data->yAxisR > 20) b |= R_STICK_U; + if(data->yAxisR < -20) b |= R_STICK_D; + + return b; +} + +static int available(int Control) { + if(Control == 0 && WiiDRC_Inited() && WiiDRC_Connected()) + { + controller_DRC.available[Control] = 1; + return 1; + } + else + { + controller_DRC.available[Control] = 0; + return 0; + } +} + +static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config) +{ + if(drcNeedScan){ WiiDRC_ScanPads(); drcNeedScan = 0; } + BUTTONS* c = Keys; + memset(c, 0, sizeof(BUTTONS)); + + // Only use a connected classic controller + if(!available(Control)) + return 0; + + unsigned int b = getButtons(); + inline int isHeld(button_tp button){ + return (b & button->mask) == button->mask; + } + + c->R_DPAD = isHeld(config->DR); + c->L_DPAD = isHeld(config->DL); + c->D_DPAD = isHeld(config->DD); + c->U_DPAD = isHeld(config->DU); + + c->START_BUTTON = isHeld(config->START); + c->B_BUTTON = isHeld(config->B); + c->A_BUTTON = isHeld(config->A); + + c->Z_TRIG = isHeld(config->Z); + c->R_TRIG = isHeld(config->R); + c->L_TRIG = isHeld(config->L); + + c->R_CBUTTON = isHeld(config->CR); + c->L_CBUTTON = isHeld(config->CL); + c->D_CBUTTON = isHeld(config->CD); + c->U_CBUTTON = isHeld(config->CU); + + if(config->analog->mask == L_STICK_AS_ANALOG){ + c->X_AXIS = getDRCValue(WiiDRC_lStickX()); + c->Y_AXIS = getDRCValue(WiiDRC_lStickY()); + } else if(config->analog->mask == R_STICK_AS_ANALOG){ + c->X_AXIS = getDRCValue(WiiDRC_rStickX()); + c->Y_AXIS = getDRCValue(WiiDRC_rStickY()); + } + if(config->invertedY) c->Y_AXIS = -c->Y_AXIS; + + // Return whether the exit button(s) are pressed + return isHeld(config->exit); +} + +static void pause(int Control){ } + +static void resume(int Control){ } + +static void rumble(int Control, int rumble){ } + +static void configure(int Control, controller_config_t* config){ + // Don't know how this should be integrated +} + +static void assign(int p, int v){ + // TODO: Light up the LEDs appropriately +} + +static void refreshAvailable(void); + +controller_t controller_DRC = + { 'D', + _GetKeys, + configure, + assign, + pause, + resume, + rumble, + refreshAvailable, + {0, 0, 0, 0}, + sizeof(buttons)/sizeof(buttons[0]), + buttons, + sizeof(analog_sources)/sizeof(analog_sources[0]), + analog_sources, + sizeof(menu_combos)/sizeof(menu_combos[0]), + menu_combos, + { .DU = &buttons[1], // D-Pad Up + .DL = &buttons[2], // D-Pad Left + .DR = &buttons[3], // D-Pad Right + .DD = &buttons[4], // D-Pad Down + .Z = &buttons[7], // Left Z + .L = &buttons[5], // Left Trigger + .R = &buttons[6], // Right Trigger + .A = &buttons[9], // A + .B = &buttons[10], // B + .START = &buttons[13], // + + .CU = &buttons[16], // Right Stick Up + .CL = &buttons[17], // Right Stick Left + .CR = &buttons[18], // Right Stick Right + .CD = &buttons[19], // Right Stick Down + .analog = &analog_sources[0], + .exit = &menu_combos[0], + .invertedY = 0, + } + }; + +static void refreshAvailable(void){ + int i; + for(i=0; i<4; ++i){ + available(i); + } +} From 8a5410b1908505d0bd30fafce9ba479bf54f8734 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 11:53:25 -0500 Subject: [PATCH 02/16] Add DRC (Wii U GamePad) support (FIX94, emukidid) --- libgui/FocusManager.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libgui/FocusManager.cpp b/libgui/FocusManager.cpp index fcce8a9..a2faee0 100644 --- a/libgui/FocusManager.cpp +++ b/libgui/FocusManager.cpp @@ -38,6 +38,7 @@ Focus::Focus() { for (int i=0; i<4; i++) { previousButtonsWii[i] = 0; + previousButtonsDRC[i] = 0; previousButtonsGC[i] = 0; } } @@ -71,6 +72,7 @@ void Focus::updateFocus() previousButtonsGC[i] = PAD_ButtonsHeld(i); #ifdef HW_RVL previousButtonsWii[i] = WPAD_ButtonsHeld(i); + previousButtonsDRC[i] = (i == 0 ? WiiDRC_ButtonsHeld() : 0); #endif } clearInput = false; @@ -213,6 +215,38 @@ void Focus::updateFocus() else primaryFocusOwner = currentFrame->updateFocus(focusDirection,buttonsDown); break; } + + else if (i == 0 && WiiDRC_Inited() && WiiDRC_Connected() && (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i])) + { + u32 currentButtonsDownDRC = (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i]) & WiiDRC_ButtonsHeld(); + previousButtonsDRC[i] = WiiDRC_ButtonsHeld(); + switch (currentButtonsDownDRC) { + case WIIDRC_BUTTON_LEFT: + focusDirection = DIRECTION_LEFT; + break; + case WIIDRC_BUTTON_RIGHT: + focusDirection = DIRECTION_RIGHT; + break; + case WIIDRC_BUTTON_DOWN: + focusDirection = DIRECTION_DOWN; + break; + case WIIDRC_BUTTON_UP: + focusDirection = DIRECTION_UP; + break; + default: + focusDirection = DIRECTION_NONE; + } + if (currentButtonsDownDRC & (WIIDRC_BUTTON_A)) buttonsDown |= ACTION_SELECT; + if (currentButtonsDownDRC & (WIIDRC_BUTTON_B)) buttonsDown |= ACTION_BACK; + if (freezeAction) + { + focusDirection = DIRECTION_NONE; + buttonsDown = 0; + } + if (primaryFocusOwner) primaryFocusOwner = primaryFocusOwner->updateFocus(focusDirection,buttonsDown); + else primaryFocusOwner = currentFrame->updateFocus(focusDirection,buttonsDown); + break; + } #endif } } From 61395ebc44e5a2d424aa15cbfbdcd3ea85c7dd74 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 11:56:43 -0500 Subject: [PATCH 03/16] Add DRC (Wii U GamePad) support --- libgui/FocusManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libgui/FocusManager.h b/libgui/FocusManager.h index 40c6972..58008b1 100644 --- a/libgui/FocusManager.h +++ b/libgui/FocusManager.h @@ -64,6 +64,7 @@ class Focus int buttonsPressed, previousButtonsPressed; u32 previousButtonsWii[4]; u16 previousButtonsGC[4]; + u32 previousButtonsDRC[4]; ComponentList focusList; Component *primaryFocusOwner, *secondaryFocusOwner; Frame *currentFrame; From 9428dcfa131afd81f52dca0e1acb92b7eeaab036 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 12:01:58 -0500 Subject: [PATCH 04/16] Add DRC (Wii U GamePad) support (FIX94) --- libgui/InputManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libgui/InputManager.cpp b/libgui/InputManager.cpp index 4a0324f..d324ba6 100644 --- a/libgui/InputManager.cpp +++ b/libgui/InputManager.cpp @@ -22,6 +22,7 @@ #include "FocusManager.h" #include "CursorManager.h" #include "../main/wii64config.h" +#include extern char shutdown; extern int stop; @@ -35,13 +36,14 @@ Input::Input() { PAD_SetSamplingRate(pollRate); PAD_Init(); -#ifdef HW_RVL - WPAD_Init(); +#ifdef HW_RVL + WPAD_Init(); WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); - WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); + WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); SYS_SetPowerCallback(PowerCallback); + WiiDRC_Init(); #endif - SYS_SetResetCallback(ResetCallback); + SYS_SetResetCallback(ResetCallback); } Input::~Input() @@ -53,6 +55,7 @@ void Input::refreshInput() PAD_ScanPads(); #ifdef HW_RVL WPAD_ScanPads(); + if(drcNeedScan){ WiiDRC_ScanPads(); drcNeedScan = 0; } #endif } From 61e863ad34fdac52ffa054b35f3d64d7e64196a9 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 12:02:50 -0500 Subject: [PATCH 05/16] Add DRC (Wii U GamePad) support (FIX94) --- libgui/InputManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libgui/InputManager.h b/libgui/InputManager.h index f248d66..5a55163 100644 --- a/libgui/InputManager.h +++ b/libgui/InputManager.h @@ -22,6 +22,7 @@ #define INPUTMANAGER_H #include "GuiTypes.h" +#include namespace menu { From 37e0567c2ceb03333cbffb68c70244c934cf41ad Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 12:06:16 -0500 Subject: [PATCH 06/16] Add DRC (Wii U GamePad) support (FIX94, emukidid) --- libgui/InputStatusBar.cpp | 96 ++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/libgui/InputStatusBar.cpp b/libgui/InputStatusBar.cpp index dba535a..ee1b88e 100644 --- a/libgui/InputStatusBar.cpp +++ b/libgui/InputStatusBar.cpp @@ -26,6 +26,7 @@ #include "FocusManager.h" #include #include +#include #include "../main/wii64config.h" extern "C" { @@ -36,25 +37,25 @@ extern "C" { namespace menu { InputStatusBar::InputStatusBar(float x, float y) - : x(x), - y(y) + : x(x), + y(y) /* : active(false), selected(false), - normalImage(0), - focusImage(0), - selectedImage(0), - selectedFocusImage(0), - buttonText(label), - buttonStyle(style), - labelMode(LABEL_CENTER), - labelScissor(0), - StartTime(0), - x(x), - y(y), - width(width), - height(height), - clickedFunc(0), - returnFunc(0)*/ + normalImage(0), + focusImage(0), + selectedImage(0), + selectedFocusImage(0), + buttonText(label), + buttonStyle(style), + labelMode(LABEL_CENTER), + labelScissor(0), + StartTime(0), + x(x), + y(y), + width(width), + height(height), + clickedFunc(0), + returnFunc(0)*/ { //Focus color Inactive color Active color Selected color Label color // GXColor colors[5] = {{255, 100, 100, 255}, {255, 255, 255, 70}, {255, 255, 255, 130}, {255, 255, 255, 255}, {255, 255, 255, 255}}; @@ -132,8 +133,8 @@ void InputStatusBar::drawComponent(Graphics& gfx) u32 type; type = SI_Probe((int)padAssign[i]); controller_GC.available[(int)padAssign[i]] = (type == SI_GC_CONTROLLER || type == SI_GC_WAVEBIRD || type == SI_GC_STEERING) ? 1 : 0; - if (controller_GC.available[(int)padAssign[i]]) - { + if (controller_GC.available[(int)padAssign[i]]) + { assign_controller(i, &controller_GC, (int)padAssign[i]); // gfx.setColor(activeColor); // IplFont::getInstance().drawInit(activeColor); @@ -149,18 +150,19 @@ void InputStatusBar::drawComponent(Graphics& gfx) statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_GAMECUBE); // sprintf (statusText, "Pad%d: None", i+1); } - break; + break; #ifdef HW_RVL case PADTYPE_WII: - s32 err; + s32 err; err = WPAD_Probe((int)padAssign[i], &type); controller_ExtenmoteGC.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_GC) ? 1 : 0; controller_ExtenmoteN64.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_N64) ? 1 : 0; controller_ExtenmoteSNES.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_SNES) ? 1 : 0; controller_ExtenmoteNES.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_NES) ? 1 : 0; - controller_WiiUPro.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_WIIUPRO) ? 1 : 0; - controller_Classic.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_CLASSIC) ? 1 : 0; - controller_WiimoteNunchuk.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_NUNCHUK) ? 1 : 0; + controller_WiiUPro.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_WIIUPRO) ? 1 : 0; + controller_Classic.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_CLASSIC) ? 1 : 0; + controller_DRC.available[(int)padAssign[i]] = (i == 0 && WiiDRC_Inited() && WiiDRC_Connected()) ? 1 : 0; + controller_WiimoteNunchuk.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_NUNCHUK) ? 1 : 0; controller_Wiimote.available[(int)padAssign[i]] = (err == WPAD_ERR_NONE && type == WPAD_EXP_NONE) ? 1 : 0; if (controller_ExtenmoteGC.available[(int)padAssign[i]]) { @@ -211,9 +213,9 @@ void InputStatusBar::drawComponent(Graphics& gfx) IplFont::getInstance().drawInit(controllerColors[i]); statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_WIIUPRO); // sprintf (statusText, "Pad%d: WUP%d", i+1, padAssign[i]+1); - } - else if (controller_Classic.available[(int)padAssign[i]]) - { + } + else if (controller_Classic.available[(int)padAssign[i]]) + { assign_controller(i, &controller_Classic, (int)padAssign[i]); // gfx.setColor(activeColor); // IplFont::getInstance().drawInit(activeColor); @@ -221,9 +223,19 @@ void InputStatusBar::drawComponent(Graphics& gfx) IplFont::getInstance().drawInit(controllerColors[i]); statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_CLASSIC); // sprintf (statusText, "Pad%d: CC%d", i+1, padAssign[i]+1); + } + else if (controller_DRC.available[(int)padAssign[i]]) + { + assign_controller(i, &controller_DRC, (int)padAssign[i]); +// gfx.setColor(activeColor); +// IplFont::getInstance().drawInit(activeColor); + gfx.setColor(controllerColors[i]); + IplFont::getInstance().drawInit(controllerColors[i]); + statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_CLASSIC); +// sprintf (statusText, "Pad%d: DRC%d", i+1, padAssign[i]+1); } else if (controller_WiimoteNunchuk.available[(int)padAssign[i]]) - { + { assign_controller(i, &controller_WiimoteNunchuk, (int)padAssign[i]); // gfx.setColor(activeColor); // IplFont::getInstance().drawInit(activeColor); @@ -233,7 +245,7 @@ void InputStatusBar::drawComponent(Graphics& gfx) // sprintf (statusText, "Pad%d: WM+N%d", i+1, padAssign[i]+1); } else if (controller_Wiimote.available[(int)padAssign[i]]) - { + { assign_controller(i, &controller_Wiimote, (int)padAssign[i]); // gfx.setColor(activeColor); // IplFont::getInstance().drawInit(activeColor); @@ -249,14 +261,14 @@ void InputStatusBar::drawComponent(Graphics& gfx) statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_WIIMOTE); // sprintf (statusText, "Pad%d: None", i+1); } - break; -#endif - default: + break; +#endif + default: gfx.setColor(inactiveColor); IplFont::getInstance().drawInit(inactiveColor); statusIcon = Resources::getInstance().getImage(Resources::IMAGE_CONTROLLER_EMPTY); // sprintf (statusText, "Pad%d: None", i+1); - break; + break; } // IplFont::getInstance().drawString((int) 540, (int) 150+30*i, statusText, 1.0, true); // IplFont::getInstance().drawString((int) box_x+width/2, (int) 215+30*i, statusText, 1.0, true); @@ -272,11 +284,11 @@ void InputStatusBar::drawComponent(Graphics& gfx) } //draw icon statusIcon->activateImage(GX_TEXMAP0); - GX_SetTevColorIn(GX_TEVSTAGE0,GX_CC_ZERO,GX_CC_ZERO,GX_CC_ZERO,GX_CC_RASC); - GX_SetTevColorOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); - GX_SetTevAlphaIn(GX_TEVSTAGE0,GX_CA_ZERO,GX_CA_RASA,GX_CA_TEXA,GX_CA_ZERO); - GX_SetTevAlphaOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); - gfx.enableBlending(true); + GX_SetTevColorIn(GX_TEVSTAGE0,GX_CC_ZERO,GX_CC_ZERO,GX_CC_ZERO,GX_CC_RASC); + GX_SetTevColorOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE0,GX_CA_ZERO,GX_CA_RASA,GX_CA_TEXA,GX_CA_ZERO); + GX_SetTevAlphaOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); + gfx.enableBlending(true); gfx.drawImage(0, base_x, base_y, 48, 64, 0, 1, 0, 1); } @@ -300,10 +312,10 @@ void InputStatusBar::drawComponent(Graphics& gfx) } //draw buttonLabel? - gfx.enableBlending(true); -// gfx.setTEV(GX_PASSCLR); - gfx.setTEV(GX_MODULATE); - + gfx.enableBlending(true); +// gfx.setTEV(GX_PASSCLR); + gfx.setTEV(GX_MODULATE); + // gfx.setColor(focusColor); gfx.setDepth(-10.0f); gfx.newModelView(); From 6dddec70730433301ac14e1edf7a3119274d9cec Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 12:10:03 -0500 Subject: [PATCH 07/16] Add DRC (WiiU GamePad) support from Wii64 (FIX94, emukidid) --- main/main_gc-menu.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/main/main_gc-menu.c b/main/main_gc-menu.c index 66b6be2..4a2d076 100644 --- a/main/main_gc-menu.c +++ b/main/main_gc-menu.c @@ -95,6 +95,7 @@ extern timers Timers; char creditsScrolling; char padNeedScan; char wpadNeedScan; + char drcNeedScan; char shutdown; char saveStateDevice; char pakMode[4]; @@ -214,6 +215,20 @@ u16 readWPAD(void){ b |= (w & CLASSIC_CTRL_BUTTON_A) ? PAD_BUTTON_A : 0; b |= (w & CLASSIC_CTRL_BUTTON_B) ? PAD_BUTTON_B : 0; } + + if(drcNeedScan){ WiiDRC_ScanPads(); drcNeedScan = 0; } + const WiiDRCData* drc = WiiDRC_Data(); + + if(WiiDRC_Inited() && WiiDRC_Connected()) + { + u16 w = drc->button; + b |= (w & WIIDRC_BUTTON_UP) ? PAD_BUTTON_UP : 0; + b |= (w & WIIDRC_BUTTON_DOWN) ? PAD_BUTTON_DOWN : 0; + b |= (w & WIIDRC_BUTTON_LEFT) ? PAD_BUTTON_LEFT : 0; + b |= (w & WIIDRC_BUTTON_RIGHT) ? PAD_BUTTON_RIGHT : 0; + b |= (w & WIIDRC_BUTTON_A) ? PAD_BUTTON_A : 0; + b |= (w & WIIDRC_BUTTON_B) ? PAD_BUTTON_B : 0; + } return b; } @@ -382,7 +397,7 @@ static void rsp_info_init(void){ } void ScanPADSandReset() { - padNeedScan = wpadNeedScan = 1; + drcNeedScan = padNeedScan = wpadNeedScan = 1; if(!((*(u32*)0xCC003000)>>16)) stop = 1; } From 0fefb94b211503349aeb06b5d38fc8a40e21b068 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 12:13:40 -0500 Subject: [PATCH 08/16] Add DRC (Wii U GamePad) support (emukidid, FIX94) --- gc_input/input.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gc_input/input.c b/gc_input/input.c index 9fc924c..5907754 100644 --- a/gc_input/input.c +++ b/gc_input/input.c @@ -38,7 +38,7 @@ static CONTROL_INFO control_info; static BOOL lastData[4]; -virtualControllers_t virtualControllers[4]; +virtualControllers_t virtualControllers[5]; controller_t* controller_ts[num_controller_t] = #if defined(WII) && !defined(NO_BT) @@ -49,6 +49,7 @@ controller_t* controller_ts[num_controller_t] = &controller_ExtenmoteNES, &controller_WiiUPro, &controller_Classic, + &controller_DRC, &controller_WiimoteNunchuk, &controller_Wiimote, }; @@ -335,7 +336,8 @@ EXPORT void CALL WM_KeyDown( WPARAM wParam, LPARAM lParam ) EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam ) { } - void pauseInput(void){ + +void pauseInput(void){ int i; for(i=0; i<4; ++i){ if(virtualControllers[i].inUse){ From 38a1823986cd843ef99407fe5f6ae46c2eda5eae Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:03:04 -0500 Subject: [PATCH 09/16] Add DRC (Wii U GamePad) support (FIX94) --- menu/ConfigureButtonsFrame.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/menu/ConfigureButtonsFrame.cpp b/menu/ConfigureButtonsFrame.cpp index 5e32868..096cad3 100644 --- a/menu/ConfigureButtonsFrame.cpp +++ b/menu/ConfigureButtonsFrame.cpp @@ -269,6 +269,8 @@ void ConfigureButtonsFrame::activateSubmenu(int submenu) activePadType = ACTIVEPADTYPE_WIIUPRO; else if (virtualControllers[activePad].control == &controller_Classic) activePadType = ACTIVEPADTYPE_CLASSIC; + else if (virtualControllers[activePad].control == &controller_DRC) + activePadType = ACTIVEPADTYPE_CLASSIC; else if (virtualControllers[activePad].control == &controller_WiimoteNunchuk) activePadType = ACTIVEPADTYPE_WIIMOTENUNCHUCK; else if (virtualControllers[activePad].control == &controller_Wiimote) @@ -373,11 +375,11 @@ void ConfigureButtonsFrame::drawChildren(menu::Graphics &gfx) gfx.setColor(controllerColors[activePad]); controllerIcon = menu::Resources::getInstance().getImage(menu::Resources::IMAGE_N64_CONTROLLER); controllerIcon->activateImage(GX_TEXMAP0); - GX_SetTevColorIn(GX_TEVSTAGE0,GX_CC_ZERO,GX_CC_ZERO,GX_CC_ZERO,GX_CC_RASC); - GX_SetTevColorOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); - GX_SetTevAlphaIn(GX_TEVSTAGE0,GX_CA_ZERO,GX_CA_RASA,GX_CA_TEXA,GX_CA_ZERO); - GX_SetTevAlphaOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); - gfx.enableBlending(true); + GX_SetTevColorIn(GX_TEVSTAGE0,GX_CC_ZERO,GX_CC_ZERO,GX_CC_ZERO,GX_CC_RASC); + GX_SetTevColorOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE0,GX_CA_ZERO,GX_CA_RASA,GX_CA_TEXA,GX_CA_ZERO); + GX_SetTevAlphaOp(GX_TEVSTAGE0,GX_TEV_ADD,GX_TB_ZERO,GX_CS_SCALE_1,GX_TRUE,GX_TEVPREV); + gfx.enableBlending(true); gfx.drawImage(0, base_x, base_y, 208, 200, 0, 1, 0, 1); gfx.setTEV(GX_PASSCLR); From a1cf7042b0928e0764204a1688152592ff6824a7 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:06:37 -0500 Subject: [PATCH 10/16] Add DRC (WiiU GamePad) support (FIX94) --- menu/FileBrowserFrame.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/menu/FileBrowserFrame.cpp b/menu/FileBrowserFrame.cpp index e5a7d17..5df6098 100644 --- a/menu/FileBrowserFrame.cpp +++ b/menu/FileBrowserFrame.cpp @@ -260,6 +260,33 @@ void FileBrowserFrame::drawChildren(menu::Graphics &gfx) } break; } + else if (i == 0 && WiiDRC_Inited() && WiiDRC_Connected() && (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i])) + { + u32 currentButtonsDownDRC = (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i]) & WiiDRC_ButtonsHeld(); + previousButtonsDRC[i] = WiiDRC_ButtonsHeld(); + if (currentButtonsDownDRC & WIIDRC_BUTTON_R) + { + //move to next set & return + if(current_page+1 < max_page) + { + current_page +=1; + fileBrowserFrame_FillPage(); + menu::Focus::getInstance().clearPrimaryFocus(); + } + break; + } + else if (currentButtonsDownDRC & WIIDRC_BUTTON_L) + { + //move to the previous set & return + if(current_page > 0) + { + current_page -= 1; + fileBrowserFrame_FillPage(); + menu::Focus::getInstance().clearPrimaryFocus(); + } + break; + } + } #endif //HW_RVL } From aa7f8e2e13575b10637ea679dbca5af422a8ce5c Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:07:35 -0500 Subject: [PATCH 11/16] Add DRC (WiiU GamePad) support (FIX94) --- menu/FileBrowserFrame.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/FileBrowserFrame.h b/menu/FileBrowserFrame.h index c2b49ea..a906858 100644 --- a/menu/FileBrowserFrame.h +++ b/menu/FileBrowserFrame.h @@ -34,7 +34,7 @@ class FileBrowserFrame : public menu::Frame private: u16 previousButtonsGC[4]; u32 previousButtonsWii[4]; - + u32 previousButtonsDRC[4]; }; #endif From a801f112823a25d2c1ef776403a8504333b352e1 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:09:27 -0500 Subject: [PATCH 12/16] Add DRC (Wii U GamePad) support from Wii64 (FIX94) --- menu/SettingsFrame.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/menu/SettingsFrame.cpp b/menu/SettingsFrame.cpp index 7906369..f357dab 100644 --- a/menu/SettingsFrame.cpp +++ b/menu/SettingsFrame.cpp @@ -582,6 +582,31 @@ void SettingsFrame::drawChildren(menu::Graphics &gfx) } break; } + else if (i == 0 && WiiDRC_Inited() && WiiDRC_Connected() && (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i])) + { + u32 currentButtonsDownDRC = (WiiDRC_ButtonsHeld() ^ previousButtonsDRC[i]) & WiiDRC_ButtonsHeld(); + previousButtonsDRC[i] = WiiDRC_ButtonsHeld(); + if (currentButtonsDownDRC & WIIDRC_BUTTON_R) + { + //move to next tab + if(activeSubmenu < SUBMENU_SAVES) + { + activateSubmenu(activeSubmenu+1); + menu::Focus::getInstance().clearPrimaryFocus(); + } + break; + } + else if (currentButtonsDownDRC & WIIDRC_BUTTON_L) + { + //move to the previous tab + if(activeSubmenu > SUBMENU_GENERAL) + { + activateSubmenu(activeSubmenu-1); + menu::Focus::getInstance().clearPrimaryFocus(); + } + break; + } + } #endif //HW_RVL } From fdefec266092f98733823ffa05e94a04da19b504 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:10:30 -0500 Subject: [PATCH 13/16] Add DRC (Wii U GamePad) support (FIX94) --- menu/SettingsFrame.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/SettingsFrame.h b/menu/SettingsFrame.h index 74ad816..2879778 100644 --- a/menu/SettingsFrame.h +++ b/menu/SettingsFrame.h @@ -45,7 +45,7 @@ class SettingsFrame : public menu::Frame int activeSubmenu; u16 previousButtonsGC[4]; u32 previousButtonsWii[4]; - + u32 previousButtonsDRC[4]; }; #endif From 57d4dbea57c941462fd314b135ff2b29e342d751 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:14:14 -0500 Subject: [PATCH 14/16] Add DRC (Wii U GamePad) support using libwiidrc (FIX94) --- Makefile.menu2_wii | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.menu2_wii b/Makefile.menu2_wii index b80817f..9cf21ce 100644 --- a/Makefile.menu2_wii +++ b/Makefile.menu2_wii @@ -96,6 +96,7 @@ OBJ_INPUT =gc_input/main.o \ gc_input/controller-GC.o \ gc_input/controller-Extenmote.o \ gc_input/controller-Classic.o \ + gc_input/controller-DRC.o \ gc_input/controller-WiimoteNunchuk.o OBJ_RSPHLE =rsp_hle/alist.o \ @@ -163,7 +164,7 @@ HEADER =main/rom.h \ r4300/recomp.h \ gc_memory/pif.h -LIB = -laesnd -lwiiuse -lbte -ltinysmb -lfat -lz -static +LIB = -laesnd -lwiiuse -lbte -ltinysmb -lfat -lwiidrc -lz -static ifeq ($(strip mupen64_GX_gfx/main.cpp),) export LD := $(CC) From 395e2c4e867c39534e27b300c1def222c6572722 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:17:54 -0500 Subject: [PATCH 15/16] Added a thing for "fix" the build based in mupen64gc-fix94 --- Makefile.menu2_wii | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.menu2_wii b/Makefile.menu2_wii index 9cf21ce..1263ca3 100644 --- a/Makefile.menu2_wii +++ b/Makefile.menu2_wii @@ -5,7 +5,7 @@ CXX =powerpc-eabi-g++ AS =powerpc-eabi-as CFLAGS = -pipe -Ofast -Wall -Wno-multichar -mrvl -fgnu89-inline -flto=jobserver \ - -DWII -DRELEASE -DMENU_V2 -DGLN64_GX -DUSE_EXPANSION \ + -DWII -DRELEASE -DMENU_V2 -D__wii__ -DGLN64_GX -DUSE_EXPANSION \ -DPPC_DYNAREC -DUSE_RECOMP_CACHE -DFASTMEM -DNDEBUG LDFLAGS =$(CFLAGS) -Wl,-Map,$(notdir $@).map -Wl,--cref From 74facba94e0ad95b8d10499a89e859d105ee8581 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Fri, 17 Dec 2021 13:26:24 -0500 Subject: [PATCH 16/16] Missed added the -DRVL_LIBWIIDRC fir finish adding DRC support (i think?) --- Makefile.menu2_wii | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.menu2_wii b/Makefile.menu2_wii index 1263ca3..d5d931d 100644 --- a/Makefile.menu2_wii +++ b/Makefile.menu2_wii @@ -5,7 +5,7 @@ CXX =powerpc-eabi-g++ AS =powerpc-eabi-as CFLAGS = -pipe -Ofast -Wall -Wno-multichar -mrvl -fgnu89-inline -flto=jobserver \ - -DWII -DRELEASE -DMENU_V2 -D__wii__ -DGLN64_GX -DUSE_EXPANSION \ + -DWII -DRELEASE -DMENU_V2 -D__wii__ -DRVL_LIBWIIDRC -DGLN64_GX -DUSE_EXPANSION \ -DPPC_DYNAREC -DUSE_RECOMP_CACHE -DFASTMEM -DNDEBUG LDFLAGS =$(CFLAGS) -Wl,-Map,$(notdir $@).map -Wl,--cref