-added libwupc, this will make the wiiu pro controller usable in wiiflow

This commit is contained in:
fix94.1 2014-09-15 23:22:04 +00:00
parent e399a8cbc4
commit 549061586a
8 changed files with 94 additions and 21 deletions

View File

@ -57,7 +57,7 @@ ios := 249
#---------------------------------------------------------------------------------
CFLAGS = -g -ggdb -Os -Wall -Wextra $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g -ggdb $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80620000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
LDFLAGS = -g -ggdb $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80620000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,wiiuse_register
ifeq ($(BUILDMODE),channel)
CFLAGS += -DFULLCHANNEL
@ -67,7 +67,7 @@ endif
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lturbojpeg -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lturbojpeg -lm -lz -lwiiuse -lwupc -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View File

@ -0,0 +1,49 @@
/****************************************************************************
* Copyright (C) 2014 FIX94
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef _WUPC_H_
#define _WUPC_H_
#ifdef __cplusplus
extern "C" {
#endif
struct WUPCData {
s16 xAxisL;
s16 xAxisR;
s16 yAxisL;
s16 yAxisR;
u32 button;
};
void WUPC_Init();
void WUPC_Shutdown();
struct WUPCData *WUPC_Data(u8 chan);
void WUPC_Rumble(u8 chan, bool rumble);
u32 WUPC_UpdateButtonStats();
u32 WUPC_ButtonsUp(u8 chan);
u32 WUPC_ButtonsDown(u8 chan);
u32 WUPC_ButtonsHeld(u8 chan);
s16 WUPC_lStickX(u8 chan);
s16 WUPC_lStickY(u8 chan);
s16 WUPC_rStickX(u8 chan);
s16 WUPC_rStickY(u8 chan);
#ifdef __cplusplus
}
#endif
#endif

BIN
portlibs/lib/libwupc.a Normal file

Binary file not shown.

View File

@ -197,10 +197,11 @@ void CButtonsMgr::show(s16 id, bool instant)
}
}
void CButtonsMgr::setRumble(int chan, bool wii, bool gc)
void CButtonsMgr::setRumble(int chan, bool wii, bool gc, bool wupc)
{
wii_rumble[chan] = wii;
gc_rumble[chan] = gc;
wupc_rumble[chan] = wupc;
}
void CButtonsMgr::mouse(int chan, int x, int y)
@ -240,6 +241,7 @@ void CButtonsMgr::mouse(int chan, int x, int y)
if(m_rumbleEnabled)
{
m_rumble[chan] = 4;
if(wupc_rumble[chan]) WUPC_Rumble(chan, 1);
if(wii_rumble[chan]) WPAD_Rumble(chan, 1);
if(gc_rumble[chan]) PAD_ControlMotor(chan, 1);
}
@ -341,6 +343,7 @@ void CButtonsMgr::click(s16 id)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
WUPC_Rumble(chan, 0);
WPAD_Rumble(chan, 0);
PAD_ControlMotor(chan, 0);
@ -393,6 +396,7 @@ void CButtonsMgr::tick(void)
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
if (m_rumble[chan] > 0 && --m_rumble[chan] == 0)
{
WUPC_Rumble(chan, 0);
WPAD_Rumble(chan, 0);
PAD_ControlMotor(chan, 0);
}

View File

@ -6,6 +6,7 @@
#include <ogc/pad.h>
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
#include "video.hpp"
#include "FreeTypeGX.h"
@ -60,7 +61,7 @@ public:
void noHover(bool nohover = false);
void click(s16 id = -1);
bool selected(s16 button = -1);
void setRumble(int, bool wii = false, bool gc = false);
void setRumble(int, bool wii = false, bool gc = false, bool wupc = false);
void deselect(void){ for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) m_selected[chan] = -1; }
void stopSounds(void);
void setSoundVolume(int vol);
@ -144,6 +145,7 @@ private:
u8 m_rumble[WPAD_MAX_WIIMOTES];
bool wii_rumble[WPAD_MAX_WIIMOTES];
bool gc_rumble[WPAD_MAX_WIIMOTES];
bool wupc_rumble[WPAD_MAX_WIIMOTES];
GuiSound *m_sndHover;
GuiSound *m_sndClick;
u8 m_soundVolume;

View File

@ -16,6 +16,7 @@
#include "memory/mem2.hpp"
#include "memory/memory.h"
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
/* Variables */
bool reset = false;
@ -33,6 +34,7 @@ void Open_Inputs(void)
{
/* Initialize Wiimote subsystem */
PAD_Init();
WUPC_Init();
WPAD_Init();
/* Set POWER button callback */
@ -43,6 +45,8 @@ void Open_Inputs(void)
void Close_Inputs(void)
{
WUPC_Shutdown();
u32 cnt;
/* Disconnect Wiimotes */

View File

@ -28,6 +28,7 @@
#include "music/MusicPlayer.hpp"
#include "plugin/plugin.hpp"
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
using namespace std;
@ -624,6 +625,8 @@ private:
bool wBtn_HeldChan(int btn, u8 ext, int &chan);
u32 gc_btnsPressed;
u32 gc_btnsHeld;
u32 wupc_btnsPressed[WPAD_MAX_WIIMOTES];
u32 wupc_btnsHeld[WPAD_MAX_WIIMOTES];
bool m_show_pointer[WPAD_MAX_WIIMOTES];
float left_stick_angle[WPAD_MAX_WIIMOTES];

View File

@ -60,6 +60,7 @@ void CMenu::ScanInput()
m_show_zone_prev = false;
m_show_zone_next = false;
WUPC_UpdateButtonStats();
WPAD_ScanPads();
PAD_ScanPads();
@ -102,7 +103,8 @@ void CMenu::ScanInput()
}
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
m_btnMgr.setRumble(chan, WPadIR_Valid(chan), PAD_StickX(chan) < -20 || PAD_StickX(chan) > 20 || PAD_StickY(chan) < -20 || PAD_StickY(chan) > 20);
m_btnMgr.setRumble(chan, WPadIR_Valid(chan), PAD_StickX(chan) < -20 || PAD_StickX(chan) > 20 || PAD_StickY(chan) < -20 || PAD_StickY(chan) > 20,
WUPC_lStickX(chan) < -160 || WUPC_lStickX(chan) > 160 || WUPC_lStickY(chan) < -160 || WUPC_lStickY(chan) > 160);
m_btnMgr.setMouse(WPadIR_Valid(chan) || m_show_pointer[chan]);
if(WPadIR_Valid(chan))
{
@ -130,6 +132,7 @@ void CMenu::ButtonsPressed()
{
wii_btnsPressed[chan] = WPAD_ButtonsDown(chan);
gc_btnsPressed |= PAD_ButtonsDown(chan);
wupc_btnsPressed[chan] = WUPC_ButtonsDown(chan);
}
}
@ -140,12 +143,14 @@ void CMenu::ButtonsHeld()
{
wii_btnsHeld[chan] = WPAD_ButtonsHeld(chan);
gc_btnsHeld |= PAD_ButtonsHeld(chan);
wupc_btnsHeld[chan] = WUPC_ButtonsHeld(chan);
}
}
bool CMenu::wBtn_PressedChan(int btn, u8 ext, int &chan)
{
return ((wii_btnsPressed[chan] & btn) && (ext == WPAD_EXP_NONE || ext == wd[chan]->exp.type));
return ((wii_btnsPressed[chan] & btn) && (ext == WPAD_EXP_NONE || ext == wd[chan]->exp.type))
|| ((wupc_btnsPressed[chan] & btn) && (ext == WPAD_EXP_CLASSIC));
}
bool CMenu::wBtn_Pressed(int btn, u8 ext)
@ -160,7 +165,8 @@ bool CMenu::wBtn_Pressed(int btn, u8 ext)
bool CMenu::wBtn_HeldChan(int btn, u8 ext, int &chan)
{
return ((wii_btnsHeld[chan] & btn) && (ext == WPAD_EXP_NONE || ext == wd[chan]->exp.type));
return ((wii_btnsHeld[chan] & btn) && (ext == WPAD_EXP_NONE || ext == wd[chan]->exp.type))
|| ((wupc_btnsHeld[chan] & btn) && (ext == WPAD_EXP_CLASSIC));
}
bool CMenu::wBtn_Held(int btn, u8 ext)
@ -178,13 +184,14 @@ void CMenu::LeftStick()
u8 speed = 0, pSpeed = 0;
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if(left_stick_mag[chan] > 0.15 || abs(PAD_StickX(chan)) > 20 || abs(PAD_StickY(chan)) > 20)
if(left_stick_mag[chan] > 0.15 || abs(PAD_StickX(chan)) > 20 || abs(PAD_StickY(chan)) > 20
|| abs(WUPC_lStickX(chan)) > 160 || abs(WUPC_lStickY(chan)) > 160)
{
m_show_pointer[chan] = true;
if(LEFT_STICK_LEFT)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)abs(PAD_StickX(chan))/10;
pSpeed = (u8)(abs(PAD_StickX(chan))/10 | abs(WUPC_lStickX(chan))/80);
if(stickPointer_x[chan] > m_cursor[chan].width()/2)
stickPointer_x[chan] = stickPointer_x[chan]-speed-pSpeed;
pointerhidedelay[chan] = 150;
@ -192,7 +199,7 @@ void CMenu::LeftStick()
if(LEFT_STICK_DOWN)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)abs(PAD_StickY(chan))/10;
pSpeed = (u8)(abs(PAD_StickY(chan))/10 | abs(WUPC_lStickY(chan))/80);
if(stickPointer_y[chan] < (m_vid.height() + (m_cursor[chan].height()/2)))
stickPointer_y[chan] = stickPointer_y[chan]+speed+pSpeed;
pointerhidedelay[chan] = 150;
@ -200,7 +207,7 @@ void CMenu::LeftStick()
if(LEFT_STICK_RIGHT)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)abs(PAD_StickX(chan))/10;
pSpeed = (u8)(abs(PAD_StickX(chan))/10 | abs(WUPC_lStickX(chan))/80);
if(stickPointer_x[chan] < (m_vid.width() + (m_cursor[chan].width()/2)))
stickPointer_x[chan] = stickPointer_x[chan]+speed+pSpeed;
pointerhidedelay[chan] = 150;
@ -208,7 +215,7 @@ void CMenu::LeftStick()
if(LEFT_STICK_UP)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)abs(PAD_StickY(chan))/10;
pSpeed = (u8)(abs(PAD_StickY(chan))/10 | abs(WUPC_lStickY(chan))/80);
if(stickPointer_y[chan] > m_cursor[chan].height()/2)
stickPointer_y[chan] = stickPointer_y[chan]-speed-pSpeed;
pointerhidedelay[chan] = 150;
@ -393,7 +400,7 @@ bool CMenu::lStick_Up(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((LEFT_STICK_ANG_UP && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) > 20)
if((LEFT_STICK_ANG_UP && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) > 20 || WUPC_lStickY(chan) > 160)
return true;
}
return false;
@ -403,7 +410,7 @@ bool CMenu::lStick_Right(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((LEFT_STICK_ANG_RIGHT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) > 20)
if((LEFT_STICK_ANG_RIGHT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) > 20 || WUPC_lStickX(chan) > 160)
return true;
}
return false;
@ -413,7 +420,7 @@ bool CMenu::lStick_Down(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((LEFT_STICK_ANG_DOWN && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) < -20)
if((LEFT_STICK_ANG_DOWN && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) < -20 || WUPC_lStickY(chan) < -160)
return true;
}
return false;
@ -423,7 +430,7 @@ bool CMenu::lStick_Left(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((LEFT_STICK_ANG_LEFT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) < -20)
if((LEFT_STICK_ANG_LEFT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) < -20 || WUPC_lStickX(chan) < -160)
return true;
}
return false;
@ -433,7 +440,8 @@ bool CMenu::rStick_Up(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((RIGHT_STICK_ANG_UP && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0) || PAD_SubStickY(chan) > 20)
if((RIGHT_STICK_ANG_UP && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0)
|| PAD_SubStickY(chan) > 20 || WUPC_rStickY(chan) > 160)
return true;
}
return false;
@ -443,7 +451,8 @@ bool CMenu::rStick_Right(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((RIGHT_STICK_ANG_RIGHT && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0) || PAD_SubStickX(chan) > 20)
if((RIGHT_STICK_ANG_RIGHT && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0)
|| PAD_SubStickX(chan) > 20 || WUPC_rStickX(chan) > 160)
return true;
}
return false;
@ -453,7 +462,8 @@ bool CMenu::rStick_Down(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((RIGHT_STICK_ANG_DOWN && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0) || PAD_SubStickY(chan) < -20)
if((RIGHT_STICK_ANG_DOWN && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0)
|| PAD_SubStickY(chan) < -20 || WUPC_rStickY(chan) < -160)
return true;
}
return false;
@ -463,7 +473,8 @@ bool CMenu::rStick_Left(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if((RIGHT_STICK_ANG_LEFT && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0) || PAD_SubStickX(chan) < -20)
if((RIGHT_STICK_ANG_LEFT && right_stick_mag[chan] > 0.15 && right_stick_skip[chan] == 0)
|| PAD_SubStickX(chan) < -20 || WUPC_rStickX(chan) < -160)
return true;
}
return false;
@ -483,7 +494,7 @@ bool CMenu::wRoll_Right(void)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if(WBTN_B_HELD && (wmote_roll[chan] > 5) && wmote_roll_skip[chan] == 0)
if(WBTN_B_HELD && (wmote_roll[chan] > 5) && wmote_roll_skip[chan] == 0)
return true;
}
return false;