-added libwiidrc so now wiiflow lite can be injected in a wii u wiivc game and will run with the gamepad.

-other minor changes and notes added
This commit is contained in:
fledge68 2018-08-01 12:27:12 +00:00
parent e4d9b2e0d1
commit c13a061359
26 changed files with 450 additions and 347 deletions

View File

@ -67,7 +67,7 @@ endif
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lturbojpeg -lm -lz -lwiiuse -lwupc -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -lsicksaxis
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lturbojpeg -lm -lz -lwiiuse -lwupc -lwiidrc -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -lsicksaxis
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2017 FIX94
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef _WIIDRC_H_
#define _WIIDRC_H_
#ifdef __cplusplus
extern "C" {
#endif
struct WiiDRCData {
s16 xAxisL;
s16 xAxisR;
s16 yAxisL;
s16 yAxisR;
u16 button;
u8 battery;
u8 extra;
};
#define WIIDRC_BUTTON_A 0x8000
#define WIIDRC_BUTTON_B 0x4000
#define WIIDRC_BUTTON_X 0x2000
#define WIIDRC_BUTTON_Y 0x1000
#define WIIDRC_BUTTON_LEFT 0x0800
#define WIIDRC_BUTTON_RIGHT 0x0400
#define WIIDRC_BUTTON_UP 0x0200
#define WIIDRC_BUTTON_DOWN 0x0100
#define WIIDRC_BUTTON_ZL 0x0080
#define WIIDRC_BUTTON_ZR 0x0040
#define WIIDRC_BUTTON_L 0x0020
#define WIIDRC_BUTTON_R 0x0010
#define WIIDRC_BUTTON_PLUS 0x0008
#define WIIDRC_BUTTON_MINUS 0x0004
#define WIIDRC_BUTTON_HOME 0x0002
#define WIIDRC_BUTTON_SYNC 0x0001
#define WIIDRC_EXTRA_BUTTON_L3 0x80
#define WIIDRC_EXTRA_BUTTON_R3 0x40
#define WIIDRC_EXTRA_BUTTON_TV 0x20
#define WIIDRC_EXTRA_OVERLAY_TV 0x10
#define WIIDRC_EXTRA_OVERLAY_POWER 0x01
bool WiiDRC_Init();
bool WiiDRC_Inited();
bool WiiDRC_Recalibrate();
bool WiiDRC_ScanPads();
bool WiiDRC_Connected();
bool WiiDRC_ShutdownRequested();
const u8 *WiiDRC_GetRawI2CAddr();
const struct WiiDRCData *WiiDRC_Data();
u32 WiiDRC_ButtonsUp();
u32 WiiDRC_ButtonsDown();
u32 WiiDRC_ButtonsHeld();
s16 WiiDRC_lStickX();
s16 WiiDRC_lStickY();
s16 WiiDRC_rStickX();
s16 WiiDRC_rStickY();
#ifdef __cplusplus
}
#endif
#endif

BIN
portlibs/lib/libwiidrc.a Normal file

Binary file not shown.

View File

@ -47,6 +47,7 @@
#define WBTN_2_HELD (wBtn_Held(WPAD_BUTTON_2, WPAD_EXP_NONE) \
|| wBtn_Held(WPAD_CLASSIC_BUTTON_X, WPAD_EXP_CLASSIC))
/* gamecube controller */
#define GBTN_UP (PAD_BUTTON_UP)
#define GBTN_DOWN (PAD_BUTTON_DOWN)
#define GBTN_LEFT (PAD_BUTTON_LEFT)
@ -85,64 +86,29 @@
#define GBTN_1_HELD (gc_btnsHeld & GBTN_1)
#define GBTN_2_HELD (gc_btnsHeld & GBTN_2)
#define DBTN_PS (DS3_BUTTON_PS)
#define DBTN_START (DS3_BUTTON_START)
#define DBTN_SELECT (DS3_BUTTON_SELECT)
#define DBTN_Y (DS3_BUTTON_TRIANGLE)
#define DBTN_Z (DS3_BUTTON_CIRCLE)
#define DBTN_B (DS3_BUTTON_CROSS)
#define DBTN_A (DS3_BUTTON_SQUARE)
#define DBTN_UP (DS3_BUTTON_UP)
#define DBTN_RIGHT (DS3_BUTTON_RIGHT)
#define DBTN_DOWN (DS3_BUTTON_DOWN)
#define DBTN_LEFT (DS3_BUTTON_LEFT)
#define DBTN_L1 (DS3_BUTTON_L1)
#define DBTN_L2 (DS3_BUTTON_L2)
#define DBTN_L3 (DS3_BUTTON_L3)
#define DBTN_R1 (DS3_BUTTON_R1)
#define DBTN_R2 (DS3_BUTTON_R2)
#define DBTN_R3 (DS3_BUTTON_R3)
#define DBTN_PS_PRESSED (ds3_btnsPressed & DS3_BUTTON_PS)
#define DBTN_START_PRESSED (ds3_btnsPressed & DS3_BUTTON_START)
#define DBTN_SELECT_PRESSED (ds3_btnsPressed & DS3_BUTTON_SELECT)
#define DBTN_Y_PRESSED (ds3_btnsPressed & DS3_BUTTON_TRIANGLE)
#define DBTN_Z_PRESSED (ds3_btnsPressed & DS3_BUTTON_CIRCLE)
#define DBTN_B_PRESSED (ds3_btnsPressed & DS3_BUTTON_CROSS)
#define DBTN_A_PRESSED (ds3_btnsPressed & DS3_BUTTON_SQUARE)
#define DBTN_UP_PRESSED (ds3_btnsPressed & DS3_BUTTON_UP)
#define DBTN_RIGHT_PRESSED (ds3_btnsPressed & DS3_BUTTON_RIGHT)
#define DBTN_DOWN_PRESSED (ds3_btnsPressed & DS3_BUTTON_DOWN)
#define DBTN_LEFT_PRESSED (ds3_btnsPressed & DS3_BUTTON_LEFT)
#define DBTN_L1_PRESSED (ds3_btnsPressed & DS3_BUTTON_L1)
#define DBTN_L2_PRESSED (ds3_btnsPressed & DS3_BUTTON_L2)
#define DBTN_L3_PRESSED (ds3_btnsPressed & DS3_BUTTON_L3)
#define DBTN_R1_PRESSED (ds3_btnsPressed & DS3_BUTTON_R1)
#define DBTN_R2_PRESSED (ds3_btnsPressed & DS3_BUTTON_R2)
#define DBTN_R3_PRESSED (ds3_btnsPressed & DS3_BUTTON_R3)
#define BTN_UP_PRESSED (WBTN_UP_PRESSED || GBTN_UP_PRESSED || DBTN_UP_PRESSED)
#define BTN_DOWN_PRESSED (WBTN_DOWN_PRESSED || GBTN_DOWN_PRESSED || DBTN_DOWN_PRESSED)
#define BTN_LEFT_PRESSED (WBTN_LEFT_PRESSED || GBTN_LEFT_PRESSED || DBTN_LEFT_PRESSED)
#define BTN_RIGHT_PRESSED (WBTN_RIGHT_PRESSED || GBTN_RIGHT_PRESSED || DBTN_RIGHT_PRESSED)
#define BTN_HOME_PRESSED (WBTN_HOME_PRESSED || GBTN_START_PRESSED || DBTN_START_PRESSED)
#define BTN_MINUS_PRESSED (WBTN_MINUS_PRESSED || GBTN_L_PRESSED || DBTN_L2_PRESSED)
#define BTN_PLUS_PRESSED (WBTN_PLUS_PRESSED || GBTN_R_PRESSED || DBTN_R2_PRESSED)
#define BTN_A_PRESSED (WBTN_A_PRESSED || GBTN_A_PRESSED || DBTN_A_PRESSED || DBTN_Z_PRESSED)
#define BTN_B_PRESSED (WBTN_B_PRESSED || GBTN_B_PRESSED || DBTN_B_PRESSED)
#define BTN_1_PRESSED (WBTN_1_PRESSED || GBTN_1_PRESSED || DBTN_L1_PRESSED)
#define BTN_2_PRESSED (WBTN_2_PRESSED || GBTN_2_PRESSED || DBTN_R1_PRESSED)
/* All controllers */
#define BTN_UP_PRESSED (WBTN_UP_PRESSED || GBTN_UP_PRESSED)
#define BTN_DOWN_PRESSED (WBTN_DOWN_PRESSED || GBTN_DOWN_PRESSED)
#define BTN_LEFT_PRESSED (WBTN_LEFT_PRESSED || GBTN_LEFT_PRESSED)
#define BTN_RIGHT_PRESSED (WBTN_RIGHT_PRESSED || GBTN_RIGHT_PRESSED)
#define BTN_HOME_PRESSED (WBTN_HOME_PRESSED || GBTN_START_PRESSED)
#define BTN_MINUS_PRESSED (WBTN_MINUS_PRESSED || GBTN_L_PRESSED)
#define BTN_PLUS_PRESSED (WBTN_PLUS_PRESSED || GBTN_R_PRESSED)
#define BTN_A_PRESSED (WBTN_A_PRESSED || GBTN_A_PRESSED)
#define BTN_B_PRESSED (WBTN_B_PRESSED || GBTN_B_PRESSED)
#define BTN_1_PRESSED (WBTN_1_PRESSED || GBTN_1_PRESSED)
#define BTN_2_PRESSED (WBTN_2_PRESSED || GBTN_2_PRESSED)
#define BTN_UP_HELD (WBTN_UP_HELD || GBTN_UP_HELD)
#define BTN_DOWN_HELD (WBTN_DOWN_HELD || GBTN_DOWN_HELD)
#define BTN_LEFT_HELD (WBTN_LEFT_HELD || GBTN_LEFT_HELD )
#define BTN_LEFT_HELD (WBTN_LEFT_HELD || GBTN_LEFT_HELD)
#define BTN_RIGHT_HELD (WBTN_RIGHT_HELD || GBTN_RIGHT_HELD)
#define BTN_HOME_HELD (WBTN_HOME_HELD || GBTN_START_HELD)
#define BTN_MINUS_HELD (WBTN_MINUS_HELD || GBTN_L_HELD)
#define BTN_PLUS_HELD (WBTN_PLUS_HELD || GBTN_R_HELD)
#define BTN_A_HELD (WBTN_A_HELD || GBTN_A_HELD)
#define BTN_B_HELD (WBTN_B_HELD || GBTN_B_HELD || DBTN_B_PRESSED || DBTN_Y_PRESSED)
#define BTN_1_HELD (WBTN_1_HELD || GBTN_1_HELD)
#define BTN_B_HELD (WBTN_B_HELD || GBTN_B_HELD)
#define BTN_1_HELD (WBTN_1_HELD || GBTN_1_HELD)
#define BTN_2_HELD (WBTN_2_HELD || GBTN_2_HELD)
enum
@ -154,11 +120,11 @@ enum
WBTN_A,
};
#define BTN_UP_REPEAT (wii_btnRepeat(WBTN_UP) || gc_btnRepeat(GBTN_UP) || ds3_btnRepeat(DBTN_UP))
#define BTN_DOWN_REPEAT (wii_btnRepeat(WBTN_DOWN) || gc_btnRepeat(GBTN_DOWN) || ds3_btnRepeat(DBTN_DOWN))
#define BTN_LEFT_REPEAT (wii_btnRepeat(WBTN_LEFT) || gc_btnRepeat(GBTN_LEFT) || ds3_btnRepeat(DBTN_LEFT))
#define BTN_RIGHT_REPEAT (wii_btnRepeat(WBTN_RIGHT) || gc_btnRepeat(GBTN_RIGHT) || ds3_btnRepeat(DBTN_RIGHT))
#define BTN_A_REPEAT (wii_btnRepeat(WBTN_A) || gc_btnRepeat(GBTN_A) || ds3_btnRepeat(DBTN_A))
#define BTN_UP_REPEAT (wii_btnRepeat(WBTN_UP) || gc_btnRepeat(GBTN_UP))
#define BTN_DOWN_REPEAT (wii_btnRepeat(WBTN_DOWN) || gc_btnRepeat(GBTN_DOWN))
#define BTN_LEFT_REPEAT (wii_btnRepeat(WBTN_LEFT) || gc_btnRepeat(GBTN_LEFT))
#define BTN_RIGHT_REPEAT (wii_btnRepeat(WBTN_RIGHT) || gc_btnRepeat(GBTN_RIGHT))
#define BTN_A_REPEAT (wii_btnRepeat(WBTN_A) || gc_btnRepeat(GBTN_A))
#define LEFT_STICK_UP lStick_Up()
#define LEFT_STICK_DOWN lStick_Down()
@ -169,8 +135,8 @@ enum
#define RIGHT_STICK_DOWN rStick_Down()
#define RIGHT_STICK_LEFT rStick_Left()
#define RIGHT_STICK_RIGHT rStick_Right()
#define RIGHT_STICK_MOVE (RIGHT_STICK_UP || RIGHT_STICK_DOWN \
|| RIGHT_STICK_LEFT || RIGHT_STICK_RIGHT)
#define RIGHT_STICK_MOVE (RIGHT_STICK_UP || RIGHT_STICK_DOWN || RIGHT_STICK_LEFT || RIGHT_STICK_RIGHT)
#define WROLL_LEFT wRoll_Left()
#define WROLL_RIGHT wRoll_Right()

View File

@ -32,6 +32,10 @@ static inline bool apply_patch(char *name, const u8 *old, const u8 *patch, u32 s
return (found > 0);
}
/* ISFS_permission for WiiU WiiVC patches made by fix94 */
static const u8 isfs_perm_wiivc_old[] = { 0x42, 0x9F, 0xD1, 0x03, 0x20, 0x00, 0xBD, 0xF0, 0x09, 0x8B, 0xE7, 0xF8, 0x20, 0x66 };
static const u8 isfs_perm_wiivc_patch[] = { 0x42, 0x9F, 0x46, 0xC0, 0x20, 0x00, 0xBD, 0xF0, 0x09, 0x8B, 0xE7, 0xF8, 0x20, 0x66 };
static const u8 isfs_perm_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
static const u8 isfs_perm_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
static const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
@ -43,8 +47,16 @@ static const u8 hash_patch[] = { 0x20, 0x00, 0x23, 0xA2 };
static const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
static const u8 new_hash_patch[] = { 0x20, 0x00, 0x4B, 0x0B };
void PatchIOS(bool patch_all)
void PatchIOS(bool patch_all, bool WiiVC)
{
if(WiiVC)
{
write32(MEM_PROT, read32(MEM_PROT) & 0x0000FFFF);
apply_patch("isfs_permissions", isfs_perm_wiivc_old, isfs_perm_wiivc_patch, sizeof(isfs_perm_wiivc_patch));
apply_patch("es_setuid", setuid_old, setuid_patch, sizeof(setuid_patch));
apply_patch("es_identify", es_identify_old, es_identify_patch, sizeof(es_identify_patch));
return;
}
__ES_Close();
write16(MEM_PROT, 0);
/* Do Patching */

View File

@ -6,7 +6,7 @@ extern "C"
#ifndef _PATCHER_H_
#define _PATCHER_H_
void PatchIOS(bool patch_all);
void PatchIOS(bool patch_all, bool WiiVC);
#endif

View File

@ -79,9 +79,9 @@ void Nand::Init()
bool Nand::LoadDefaultIOS(void)
{
Patch_AHB();
s32 ret = IOS_ReloadIOS(IOS_GetPreferredVersion());
loadIOS(IOS_GetVersion(), false);
Patch_AHB();//apply a patch so the new IOS will also have AHBPROT disabled
s32 ret = IOS_ReloadIOS(IOS_GetPreferredVersion());// reload to preferred IOS. not sure what wiiflows preferred IOS is.
loadIOS(IOS_GetVersion(), false);// this basically does nothing (well very little). definetly doesn't load a IOS or shutdown anything.
Init_ISFS();
return (ret == 0);
}
@ -1128,7 +1128,7 @@ void Nand::Init_ISFS()
{
if(isfs_inited)
return;
PatchIOS(IOS_GetVersion() < 222);
PatchIOS(IOS_GetVersion() < 222, isWiiVC);
usleep(1000);
gprintf("Init ISFS\n");
ISFS_Initialize();

View File

@ -163,7 +163,7 @@ void NandSave::LoadSettings()
ios_settings_t *file = (ios_settings_t*)ISFS_GetFile(ISFS_Path, &size, -1);
if(file != NULL && size == sizeof(ios_settings_t))
{
gprintf("Loading IOS Settings from NAND\n");
gprintf("Loading IOS Settings from wiiflow save\n");
cur_ios = file->cios;
if(cur_ios > 0)
mainIOS = cur_ios;
@ -177,7 +177,7 @@ void NandSave::LoadSettings()
u8 *port = ISFS_GetFile(ISFS_Path, &size, -1);
if(port != NULL && size == sizeof(u8))
{
gprintf("Using Port Settings from NAND\n");
gprintf("Using Port Settings from wiiflow save\n");
currentPort = port[0] & 1;
}
if(port != NULL)
@ -191,7 +191,7 @@ void NandSave::SaveIOS()
memset(&ios_settings, 0, sizeof(ios_settings_t));
ios_settings.cios = cur_ios;
ios_settings.use_cios = cur_load;
gprintf("Saving IOS Settings to NAND\n");
gprintf("Saving IOS Settings to wiiflow save\n");
WriteFile(IOS_SAVE_PATH, (u8*)&ios_settings, sizeof(ios_settings_t));
}
@ -199,7 +199,7 @@ void NandSave::SavePort(u8 port)
{
if(loaded == false)
return;
gprintf("Saving Port Settings to NAND\n");
gprintf("Saving Port Settings to wiiflow save\n");
WriteFile(PORT_SAVE_PATH, &port, sizeof(port));
}

View File

@ -8,8 +8,6 @@
#include <string>
#include "wiiuse/wpad.h"
#include <ogc/pad.h>
#include "video.hpp"
#include "FreeTypeGX.h"
#include "text.hpp"

View File

@ -7,7 +7,6 @@
#include <ogc/pad.h>
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
#include "video.hpp"
#include "FreeTypeGX.h"

View File

@ -57,23 +57,22 @@ bool loadIOS(int ios, bool MountDevices)
if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
{
WDVD_Close();
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
ShutdownBeforeExit();
NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
ret = IOS_ReloadIOS(ios) == 0;
gprintf("AHBPROT after IOS Reload: %u\n", AHBPROT_Patched());
NandHandle.Init_ISFS();
WDVD_Init();
ShutdownBeforeExit();// unmount all, close inputs and dvd drive, deinit ISFS, and close network
NandHandle.Patch_AHB(); //apply a patch so the new IOS will also have AHBPROT disabled
ret = IOS_ReloadIOS(ios) == 0;// convert ret value to true or false
gprintf("AHBPROT disabled after IOS Reload: %s\n", AHBPROT_Patched() ? "yes" : "no");
NandHandle.Init_ISFS();// re init ISFS
WDVD_Init();// re open dvd drive
}
/* Init_ISFS() before calling IOS_GetCurrentIOSInfo() */
IOS_GetCurrentIOSInfo();
if(CurrentIOS.Type == IOS_TYPE_HERMES)
load_ehc_module_ex();
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
load_dip_249();
DeviceHandle.SetModes();
if(MountDevices && ios != CurIOS)
if(MountDevices && ios != CurIOS)// remount sd and USB if desired
DeviceHandle.MountAll();
return ret;

View File

@ -120,6 +120,8 @@ bool IOS_D2X(u8 ios, u8 *base)
u8 IOS_GetType(u8 slot)
{
if(isWiiVC)
return IOS_TYPE_NORMAL_IOS;
u32 TMD_Length;
signed_blob *TMD_Buffer = GetTMD(slot, &TMD_Length);
if(TMD_Buffer == NULL)

View File

@ -1,9 +1,7 @@
#include <ogc/machine/processor.h>
#include <ogc/lwp_threads.h>
#include <ogc/lwp_watchdog.h>
#include <ogc/pad.h>
#include <stdio.h>
#include <ogcsys.h>
#include <stdlib.h>
#include <string.h>
@ -15,9 +13,9 @@
#include "gecko/gecko.hpp"
#include "memory/mem2.hpp"
#include "memory/memory.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
/* Variables */
bool reset = false;
@ -34,14 +32,13 @@ void __Wpad_PowerCallback()
void Open_Inputs(void)
{
/* Initialize Wiimote subsystem */
/* Initialize controllers - wiiu drc is inited only once in main.cpp */
PAD_Init();
WUPC_Init();
WPAD_Init();
DS3_Init();
//drc
/* Set POWER button callback */
/* Set wiimote power button callback */
WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetIdleTimeout(60 * 2); // idle after 2 minutes
@ -51,14 +48,13 @@ void Close_Inputs(void)
{
WUPC_Shutdown();
u32 cnt;
/* Disconnect Wiimotes */
for(cnt = 0; cnt < 4; cnt++)
for(u32 cnt = 0; cnt < 4; cnt++)
WPAD_Disconnect(cnt);
/* Shutdown Wiimote subsystem */
WPAD_Shutdown();
DS3_Cleanup();
}

View File

@ -50,6 +50,7 @@ bool IsOnWiiU(void);
extern void __exception_setreload(int t);
extern int mainIOS;
extern bool useMainIOS;
extern bool isWiiVC;
extern volatile bool NANDemuView;
extern volatile bool networkInit;
extern u8 currentPartition;

View File

@ -22,6 +22,7 @@
#include "menu/menu.hpp"
#include "memory/memory.h"
bool isWiiVC = false;
bool useMainIOS = false;
volatile bool NANDemuView = false;
volatile bool networkInit = false;
@ -30,6 +31,8 @@ volatile bool networkInit = false;
/* if not then we can skip the 20 second cycle trying to connect a USB device. */
/* this is nice for SD only users */
bool isUsingUSB() {
if(isWiiVC)
return false;
/* First check if the app path exists on the SD card, if not then we're using USB */
struct stat dummy;
string appPath = fmt("%s:/%s", DeviceName[SD], APPS_DIR);
@ -120,37 +123,61 @@ int main(int argc, char **argv)
}
}
if(IsOnWiiU())
gprintf("vWii Mode\n");
else
gprintf("Real Wii\n");
/* Init video */
m_vid.init();
if(showFlashImg)
m_vid.startImage();
/* check if WiiVC */
WiiDRC_Init();
isWiiVC = WiiDRC_Inited();
if(IsOnWiiU())
{
gprintf("WiiU\n");
if(isWiiVC)
gprintf("WiiVC\n");
else
gprintf("vWii Mode\n");
}
else
gprintf("Real Wii\n");
gprintf("AHBPROT disabled = %s\n", AHBPROT_Patched() ? "yes" : "no");
/* Init device partition handlers */
DeviceHandle.Init();
/* Init NAND handlers */
NandHandle.Init();
NandHandle.LoadDefaultIOS(); /* safe reload to preferred IOS */
/* load and check wiiflow save for possible new IOS and Port settings */
if(InternalSave.CheckSave())
InternalSave.LoadSettings();
if(isWiiVC)
{
NandHandle.Init_ISFS();
IOS_GetCurrentIOSInfo();
DeviceHandle.SetModes();
}
else
{
NandHandle.LoadDefaultIOS(); /* safe reload to preferred IOS */
/* Handle (c)IOS Loading */
if(useMainIOS && CustomIOS(IOS_GetType(mainIOS))) /* Requested */
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
/* load and check wiiflow save for possible new IOS and Port settings */
if(InternalSave.CheckSave())
InternalSave.LoadSettings();
/* Handle (c)IOS Loading */
if(useMainIOS && CustomIOS(IOS_GetType(mainIOS))) /* Requested */
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
}
/* sys inits */
Sys_Init();// set reset and power button callbacks
Sys_ExitTo(EXIT_TO_HBC);// set exit to in case of failed launch
/* mount Devices */
/* mount SD */
DeviceHandle.MountSD();// mount SD before calling isUsingUSB() duh!
/* mount USB if needed */
DeviceHandle.SetMountUSB(isUsingUSB());
DeviceHandle.MountAllUSB();// only mounts any USB if isUsingUSB()
@ -159,7 +186,7 @@ int main(int argc, char **argv)
m_vid.waitMessage(0.15f);
/* init controllers for input */
Open_Inputs();
Open_Inputs();// WPAD_SetVRes() is called later in mainMenu.init() during cursor init which gets the theme pointer images
/* init configs, folders, coverflow, gui and more */
if(mainMenu.init())
@ -183,7 +210,8 @@ int main(int argc, char **argv)
mainMenu.terror("errboot3", L"Could not initialize the DIP module!");
else // alls good lets start wiiflow
{
writeStub();// copy return stub to memory
if(!isWiiVC)
writeStub();// copy return stub to memory
if(gameid != NULL && strlen(gameid) == 6)// if argv game ID then launch it
mainMenu.directlaunch(gameid);
else

View File

@ -25,7 +25,7 @@
#include "music/SoundHandler.hpp"
#include "network/gcard.h"
#include "unzip/U8Archive.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
// Sounds
extern const u8 click_wav[];
extern const u32 click_wav_size;
@ -409,7 +409,7 @@ bool CMenu::init()
float pShadowY = m_theme.getFloat("GENERAL", "pointer_shadow_y", 3.f);
bool pShadowBlur = m_theme.getBool("GENERAL", "pointer_shadow_blur", false);
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
m_cursor[chan].init(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("GENERAL", fmt("pointer%i", chan+1)).c_str()),
m_vid.wide(), pShadowColor, pShadowX, pShadowY, pShadowBlur, chan);
@ -2447,6 +2447,8 @@ bool CMenu::_loadFile(u8 * &buffer, u32 &size, const char *path, const char *fil
void CMenu::_load_installed_cioses()
{
if(isWiiVC)
return;
gprintf("Loading cIOS map\n");
_installed_cios[0] = 1;
@ -2613,7 +2615,7 @@ void CMenu::TempLoadIOS(int IOS)
loadIOS(IOS, true);
Sys_Init();
Open_Inputs();
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
_netInit();
}

View File

@ -26,9 +26,10 @@
#include "music/gui_sound.h"
#include "music/MusicPlayer.hpp"
#include "plugin/plugin.hpp"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
#include "wiiuse/wpad.h"
#include "wupc/wupc.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
#include "wiidrc/wiidrc.h"
using namespace std;
@ -634,60 +635,54 @@ private:
SZone m_gameButtonsZone;
WPADData *wd[WPAD_MAX_WIIMOTES];
void LeftStick();
u8 pointerhidedelay[WPAD_MAX_WIIMOTES];
u16 stickPointer_x[WPAD_MAX_WIIMOTES];
u16 stickPointer_y[WPAD_MAX_WIIMOTES];
u32 wii_btnsPressed[WPAD_MAX_WIIMOTES];
u32 wii_btnsHeld[WPAD_MAX_WIIMOTES];
u32 wupc_btnsPressed[WPAD_MAX_WIIMOTES];
u32 wupc_btnsHeld[WPAD_MAX_WIIMOTES];
u32 gc_btnsPressed;
u32 gc_btnsHeld;
u32 ds3_btnsPressed;
bool wBtn_Pressed(int btn, u8 ext);
bool wBtn_PressedChan(int btn, u8 ext, int &chan);
bool wBtn_Held(int btn, u8 ext);
bool wBtn_HeldChan(int btn, u8 ext, int &chan);
u32 wiidrc_to_pad(u32 btns);
u32 ds3_to_pad(u32 btns);
bool wii_btnRepeat(u8 btn);
u8 m_wpadLeftDelay;
u8 m_wpadDownDelay;
u8 m_wpadRightDelay;
u8 m_wpadUpDelay;
u8 m_wpadADelay;
//u8 m_wpadBDelay;
u8 m_dpadLeftDelay;
u8 m_dpadDownDelay;
u8 m_dpadRightDelay;
u8 m_dpadUpDelay;
u8 m_dpadADelay;
u8 m_dpadHDelay;
bool gc_btnRepeat(s64 btn);
u8 m_padLeftDelay;
u8 m_padDownDelay;
u8 m_padRightDelay;
u8 m_padUpDelay;
u8 m_padADelay;
//u8 m_padBDelay;
u32 ds3_btnsPressed;
u32 wii_btnsPressed[WPAD_MAX_WIIMOTES];
u32 wii_btnsHeld[WPAD_MAX_WIIMOTES];
bool wBtn_Pressed(int btn, u8 ext);
bool wBtn_PressedChan(int btn, u8 ext, int &chan);
bool wBtn_Held(int btn, u8 ext);
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 ds3_btnRepeat(s64 btn);
bool m_show_pointer[WPAD_MAX_WIIMOTES];
float left_stick_angle[WPAD_MAX_WIIMOTES];
float left_stick_mag[WPAD_MAX_WIIMOTES];
float right_stick_angle[WPAD_MAX_WIIMOTES];
float right_stick_mag[WPAD_MAX_WIIMOTES];
float wmote_roll[WPAD_MAX_WIIMOTES];
s32 right_stick_skip[WPAD_MAX_WIIMOTES];
float wmote_roll[WPAD_MAX_WIIMOTES];
s32 wmote_roll_skip[WPAD_MAX_WIIMOTES];
bool enable_wmote_roll;
time_t no_input_time;
void SetupInput(bool reset_pos = false);
void ScanInput(void);
u32 NoInputTime(void);
void ButtonsPressed(void);
void ButtonsHeld(void);
void LeftStick();
bool lStick_Up(void);
bool lStick_Right(void);
bool lStick_Down(void);
@ -701,12 +696,15 @@ private:
bool wRoll_Left(void);
bool wRoll_Right(void);
bool wii_btnRepeat(u8 btn);
bool gc_btnRepeat(s64 btn);
bool WPadIR_Valid(int chan);
bool WPadIR_ANY(void);
u8 pointerhidedelay[WPAD_MAX_WIIMOTES];
u16 stickPointer_x[WPAD_MAX_WIIMOTES];
u16 stickPointer_y[WPAD_MAX_WIIMOTES];
bool m_show_pointer[WPAD_MAX_WIIMOTES];
bool ShowPointer(void);
void ShowZone(SZone zone, bool &showZone);
void ShowMainZone(void);
void ShowMainZone2(void);
@ -714,7 +712,6 @@ private:
void ShowPrevZone(void);
void ShowNextZone(void);
void ShowGameZone(void);
bool ShowPointer(void);
bool m_show_zone_main;
bool m_show_zone_main2;
bool m_show_zone_main3;
@ -722,6 +719,9 @@ private:
bool m_show_zone_next;
bool m_show_zone_game;
time_t no_input_time;
u32 NoInputTime(void);
volatile bool m_exit;
volatile bool m_thrdStop;
volatile bool m_thrdWorking;
@ -1195,7 +1195,9 @@ private:
void _stopGameSoundThread(void);
static void * _gameSoundThread(void *obj);
static void _load_installed_cioses();
void _load_installed_cioses();
map<u8, u8> _installed_cios;
typedef map<u8, u8>::iterator CIOSItr;
struct SOption { const char id[10]; const wchar_t text[16]; };
@ -1221,8 +1223,6 @@ private:
static const SOption _hooktype[8];
static const SOption _exitTo[3];
static map<u8, u8> _installed_cios;
typedef map<u8, u8>::iterator CIOSItr;
static int _version[9];
static const SCFParamDesc _cfParams[];
static const int _nbCfgPages;

View File

@ -197,7 +197,7 @@ const CMenu::SOption CMenu::_debugger[3] = {
{ "dbgfwrite", L"OSReport" },
};
map<u8, u8> CMenu::_installed_cios;
//map<u8, u8> CMenu::_installed_cios;
static inline int loopNum(int i, int s)
{
@ -663,69 +663,78 @@ void CMenu::_game(bool launch)
(!ShowPointer() && !m_video_playing && !coverFlipped))
{
_hideGame();
MusicPlayer.Stop();
_cleanupBanner();
m_cfg.setInt("GENERAL", "cat_startpage", m_catStartPage);
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
/* change to current game's partition */
switch(hdr->type)
if(isWiiVC && (hdr->type == TYPE_WII_GAME || hdr->type == TYPE_EMUCHANNEL))
{
case TYPE_CHANNEL:
case TYPE_EMUCHANNEL:
currentPartition = m_cfg.getInt(CHANNEL_DOMAIN, "partition", 1);
break;
case TYPE_HOMEBREW:
currentPartition = m_cfg.getInt(HOMEBREW_DOMAIN, "partition", 1);
break;
case TYPE_GC_GAME:
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", 1);
break;
case TYPE_WII_GAME:
currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", 1);
break;
default:
int romsPartition = m_plugin.GetRomPartition(m_plugin.GetPluginPosition(hdr->settings[0]));
if(romsPartition < 0)
romsPartition = m_cfg.getInt(PLUGIN_DOMAIN, "partition", 0);
currentPartition = romsPartition;
break;
error(_t("errgame19", L"Can't launch in Wii virtual console mode!"));
launch = false;
_showGame();
}
/* Get Banner Title for Playlog */
if(hdr->type == TYPE_WII_GAME || hdr->type == TYPE_CHANNEL || hdr->type == TYPE_EMUCHANNEL)
else
{
NANDemuView = hdr->type == TYPE_EMUCHANNEL;
CurrentBanner.ClearBanner();
if(hdr->type == TYPE_CHANNEL || hdr->type == TYPE_EMUCHANNEL)
MusicPlayer.Stop();
_cleanupBanner();
m_cfg.setInt("GENERAL", "cat_startpage", m_catStartPage);
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
/* change to current game's partition */
switch(hdr->type)
{
u64 chantitle = CoverFlow.getChanTitle();
ChannelHandle.GetBanner(chantitle);
case TYPE_CHANNEL:
case TYPE_EMUCHANNEL:
currentPartition = m_cfg.getInt(CHANNEL_DOMAIN, "partition", 1);
break;
case TYPE_HOMEBREW:
currentPartition = m_cfg.getInt(HOMEBREW_DOMAIN, "partition", 1);
break;
case TYPE_GC_GAME:
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", 1);
break;
case TYPE_WII_GAME:
currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", 1);
break;
default:
int romsPartition = m_plugin.GetRomPartition(m_plugin.GetPluginPosition(hdr->settings[0]));
if(romsPartition < 0)
romsPartition = m_cfg.getInt(PLUGIN_DOMAIN, "partition", 0);
currentPartition = romsPartition;
break;
}
else if(hdr->type == TYPE_WII_GAME)
_extractBnr(hdr);
u8 banner_title[84];
memset(banner_title, 0, 84);
if(CurrentBanner.IsValid())
CurrentBanner.GetName(banner_title, GetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()));
if(Playlog_Update(hdr->id, banner_title) < 0)
Playlog_Delete();
CurrentBanner.ClearBanner();
/* Get Banner Title for Playlog */
if(hdr->type == TYPE_WII_GAME || hdr->type == TYPE_CHANNEL || hdr->type == TYPE_EMUCHANNEL)
{
NANDemuView = hdr->type == TYPE_EMUCHANNEL;
CurrentBanner.ClearBanner();
if(hdr->type == TYPE_CHANNEL || hdr->type == TYPE_EMUCHANNEL)
{
u64 chantitle = CoverFlow.getChanTitle();
ChannelHandle.GetBanner(chantitle);
}
else if(hdr->type == TYPE_WII_GAME)
_extractBnr(hdr);
u8 banner_title[84];
memset(banner_title, 0, 84);
if(CurrentBanner.IsValid())
CurrentBanner.GetName(banner_title, GetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()));
if(Playlog_Update(hdr->id, banner_title) < 0)
Playlog_Delete();
CurrentBanner.ClearBanner();
}
/* Finally boot it */
gprintf("Launching game %s\n", hdr->id);
_launch(hdr);
if(m_exit)
break;
_hideWaitMessage();
launch = false;
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
m_gcfg2.unload();
_showGame();
}
/* Finally boot it */
gprintf("Launching game %s\n", hdr->id);
_launch(hdr);
if(m_exit)
break;
_hideWaitMessage();
launch = false;
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
m_gcfg2.unload();
_showGame();
}
else if(!coverFlipped)
{
@ -1055,6 +1064,7 @@ void CMenu::_launch(const dir_discHdr *hdr)
}
}
/* launch plugin with args */
gprintf("launching plugin app\n");
_launchHomebrew(plugin_file, arguments);
}
else if(launchHdr.type == TYPE_HOMEBREW)
@ -1066,6 +1076,7 @@ void CMenu::_launch(const dir_discHdr *hdr)
{
m_cfg.setString(HOMEBREW_DOMAIN, "current_item", strrchr(launchHdr.path, '/') + 1);
vector<string> arguments = _getMetaXML(bootpath);
gprintf("launching homebrew app\n");
_launchHomebrew(bootpath, arguments);
}
}
@ -1084,6 +1095,7 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
Playlog_Delete();
/* load boot.dol into memory and load app_booter.bin into memory */
bool ret = (LoadHomebrew(filepath) && LoadAppBooter(fmt("%s/app_booter.bin", m_binsDir.c_str())));
if(ret == false)
{
@ -1096,7 +1108,7 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
AddBootArgument(filepath);
for(u32 i = 0; i < arguments.size(); ++i)
{
gprintf("Argument: %s\n", arguments[i].c_str());
gprintf("app argument: %s\n", arguments[i].c_str());
AddBootArgument(arguments[i].c_str());
}
@ -1455,7 +1467,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
/* dont confuse loadIOS with _loadIOS */
int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channels)
{
gprintf("Game ID# %s requested IOS %d. User selected %d\n", id.c_str(), gameIOS, userIOS);
gprintf("Game ID %s requested IOS %d.\nUser selected %d\n", id.c_str(), gameIOS, userIOS);
if(RealNAND_Channels && IOS_GetType(mainIOS) == IOS_TYPE_STUB)
{
/* doesn't use cIOS so we don't check userIOS */
@ -1560,12 +1572,10 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
u8 patchVidMode = min(m_gcfg2.getUInt(id, "patch_video_modes", 0), ARRAY_SIZE(CMenu::_vidModePatch) - 1u);
int aspectRatio = min(m_gcfg2.getUInt(id, "aspect_ratio", 0), ARRAY_SIZE(CMenu::_AspectRatio) - 1) - 1;// -1,0,1
//u32 returnTo = 0;
//const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str();
//if(strlen(rtrn) == 4)
// returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
u32 returnTo = 0;
const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str();
u32 returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
if(strlen(rtrn) == 4)
returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
u8 *cheatFile = NULL;
u32 cheatSize = 0;
@ -1683,7 +1693,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
setLanguage(language);
ocarina_load_code(cheatFile, cheatSize);
NandHandle.Patch_AHB(); /* Identify maybe uses it so keep AHBPROT disabled */
PatchIOS(true); /* Patch for everything */
PatchIOS(true, isWiiVC); /* Patch for everything */
Identify(gameTitle);
ExternalBooter_ChannelSetup(gameTitle, use_dol);
@ -1768,8 +1778,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd, bool disc_cfg)
int language = min(m_gcfg2.getUInt(id, "language", 0), ARRAY_SIZE(CMenu::_languages) - 1u);
language = (language == 0) ? min(m_cfg.getUInt("GENERAL", "game_language", 0), ARRAY_SIZE(CMenu::_languages) - 1u) : language;
u32 returnTo = 0;
const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str();
u32 returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
if(strlen(rtrn) == 4)
returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3];
int aspectRatio = min(m_gcfg2.getUInt(id, "aspect_ratio", 0), ARRAY_SIZE(CMenu::_AspectRatio) - 1u) - 1;
u8 patchVidMode = min(m_gcfg2.getUInt(id, "patch_video_modes", 0), ARRAY_SIZE(CMenu::_vidModePatch) - 1u);

View File

@ -2,13 +2,8 @@
#include <ogc/lwp_watchdog.h>
#include "menu.hpp"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
static const u32 g_repeatDelay = 25;
u64 button_time = 0;
#define CheckTime() (ticks_to_millisecs(diff_ticks((button_time), gettick())) > 200)
#define UpdateTime() button_time = gettick()
void CMenu::SetupInput(bool reset_pos)
{
@ -59,6 +54,18 @@ static int CalculateRepeatSpeed(float magnitude, int current_value)
void CMenu::ScanInput()
{
/*for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
wd[chan] = WPAD_Data(chan);
if(wd[chan]->err < 0)
{
Close_Inputs();
Open_Inputs();
for(int chn = WPAD_MAX_WIIMOTES-1; chn >= 0; chn--)
WPAD_SetVRes(chn, m_vid.width() + m_cursor[chn].width(), m_vid.height() + m_cursor[chn].height());
break;
}
}*/
m_show_zone_main = false;
m_show_zone_main2 = false;
m_show_zone_main3 = false;
@ -69,7 +76,8 @@ void CMenu::ScanInput()
WPAD_ScanPads();
PAD_ScanPads();
DS3_ScanPads();
//drc
if(WiiDRC_Inited() && WiiDRC_Connected())
WiiDRC_ScanPads();
ButtonsPressed();
ButtonsHeld();
@ -82,7 +90,7 @@ void CMenu::ScanInput()
left_stick_mag[chan] = 0;
right_stick_angle[chan] = 0;
right_stick_mag[chan] = 0;
switch(wd[chan]->exp.type)
switch(wd[chan]->exp.type)// exp = expansion
{
case WPAD_EXP_NUNCHUK:
right_stick_mag[chan] = wd[chan]->exp.nunchuk.js.mag;
@ -108,22 +116,24 @@ void CMenu::ScanInput()
}
right_stick_skip[chan] = CalculateRepeatSpeed(right_stick_mag[chan], right_stick_skip[chan]);
}
/* handles wii/gc rumble and mouse/cursor position and drawing */
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,
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))
if(WPadIR_Valid(chan))// wiimote IR
{
m_cursor[chan].draw(wd[chan]->ir.x, wd[chan]->ir.y, wd[chan]->ir.angle);
m_btnMgr.mouse(chan, wd[chan]->ir.x - m_cursor[chan].width() / 2, wd[chan]->ir.y - m_cursor[chan].height() / 2);
}
else if(m_show_pointer[chan])
else if(m_show_pointer[chan])// left stick
{
m_cursor[chan].draw(stickPointer_x[chan], stickPointer_y[chan], 0);
m_btnMgr.mouse(chan, stickPointer_x[chan] - m_cursor[chan].width() / 2, stickPointer_y[chan] - m_cursor[chan].height() / 2);
}
}
/* handles display zones */
ShowMainZone();
ShowMainZone2();
ShowMainZone3();
@ -133,11 +143,16 @@ void CMenu::ScanInput()
}
extern "C" { extern bool shutdown; };
u64 button_time = 0;
#define CheckTime() (ticks_to_millisecs(diff_ticks((button_time), gettick())) > 200)
#define UpdateTime() button_time = gettick()
void CMenu::ButtonsPressed()
{
gc_btnsPressed = 0;
if (CheckTime())
/* ds3 controller */
if(CheckTime())
{
ds3_btnsPressed = DS3_ButtonsDown();
UpdateTime();
@ -145,30 +160,94 @@ void CMenu::ButtonsPressed()
else
ds3_btnsPressed = 0;
if(ds3_btnsPressed & DBTN_SELECT) shutdown = 1;
if(ds3_btnsPressed & DS3_BUTTON_SELECT)
shutdown = 1;
else
gc_btnsPressed |= ds3_to_pad(ds3_btnsPressed);
/* wii, gc, drc, and wupc */
gc_btnsPressed |= wiidrc_to_pad(WiiDRC_ButtonsDown());
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
wii_btnsPressed[chan] = WPAD_ButtonsDown(chan);
gc_btnsPressed |= PAD_ButtonsDown(chan);
wupc_btnsPressed[chan] = WUPC_ButtonsDown(chan);
//drc
}
wii_btnsPressed[chan] = WPAD_ButtonsDown(chan);
gc_btnsPressed |= PAD_ButtonsDown(chan);
wupc_btnsPressed[chan] = WUPC_ButtonsDown(chan);
}
}
void CMenu::ButtonsHeld()
{
/* wii, gc, drc, and wupc controllers = no ds3 not sure why */
gc_btnsHeld = 0;
gc_btnsHeld |= wiidrc_to_pad(WiiDRC_ButtonsHeld());
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
wii_btnsHeld[chan] = WPAD_ButtonsHeld(chan);
gc_btnsHeld |= PAD_ButtonsHeld(chan);
wupc_btnsHeld[chan] = WUPC_ButtonsHeld(chan);
//drc
}
}
/* convert wiidrc buttons to gc pad buttons */
u32 CMenu::wiidrc_to_pad(u32 btns) {
u32 ret = 0;
if(btns & WIIDRC_BUTTON_LEFT)
ret |= PAD_BUTTON_LEFT;
if(btns & WIIDRC_BUTTON_RIGHT)
ret |= PAD_BUTTON_RIGHT;
if(btns & WIIDRC_BUTTON_UP)
ret |= PAD_BUTTON_UP;
if(btns & WIIDRC_BUTTON_DOWN)
ret |= PAD_BUTTON_DOWN;
if(btns & WIIDRC_BUTTON_A)
ret |= PAD_BUTTON_A;
if(btns & WIIDRC_BUTTON_B)
ret |= PAD_BUTTON_B;
if(btns & WIIDRC_BUTTON_X)
ret |= PAD_BUTTON_X;
if(btns & WIIDRC_BUTTON_Y)
ret |= PAD_BUTTON_Y;
if((btns & WIIDRC_BUTTON_L) || (btns & WIIDRC_BUTTON_ZL) || (btns & WIIDRC_BUTTON_MINUS))
ret |= PAD_TRIGGER_L;
if((btns & WIIDRC_BUTTON_R) || (btns & WIIDRC_BUTTON_ZR) || (btns & WIIDRC_BUTTON_PLUS))
ret |= PAD_TRIGGER_R;
if(btns & WIIDRC_BUTTON_HOME)
ret |= PAD_BUTTON_START;
return (ret&0xffff) ;
}
/* convert ds3 buttons to gc pad buttons */
u32 CMenu::ds3_to_pad(u32 btns) {
u32 ret = 0;
if(btns & DS3_BUTTON_LEFT)
ret |= PAD_BUTTON_LEFT;
if(btns & DS3_BUTTON_RIGHT)
ret |= PAD_BUTTON_RIGHT;
if(btns & DS3_BUTTON_UP)
ret |= PAD_BUTTON_UP;
if(btns & DS3_BUTTON_DOWN)
ret |= PAD_BUTTON_DOWN;
if((btns & DS3_BUTTON_SQUARE) || (btns & DS3_BUTTON_CIRCLE))
ret |= PAD_BUTTON_A;
if(btns & DS3_BUTTON_CROSS)
ret |= PAD_BUTTON_B;
if(btns & DS3_BUTTON_R1)
ret |= PAD_BUTTON_X;
if(btns & DS3_BUTTON_L1)
ret |= PAD_BUTTON_Y;
if(btns & DS3_BUTTON_L2)
ret |= PAD_TRIGGER_L;
if(btns & DS3_BUTTON_R2)
ret |= PAD_TRIGGER_R;
if(btns & DS3_BUTTON_START)
ret |= PAD_BUTTON_START;
return (ret&0xffff) ;
}
bool CMenu::wBtn_PressedChan(int btn, u8 ext, int &chan)
{
return ((wii_btnsPressed[chan] & btn) && (ext == WPAD_EXP_NONE || ext == wd[chan]->exp.type)) || ((wupc_btnsPressed[chan] & btn) && (ext == WPAD_EXP_CLASSIC));
@ -199,18 +278,22 @@ bool CMenu::wBtn_Held(int btn, u8 ext)
return false;
}
/* Left Stick is used to show/hide the pointer and move it */
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 || (chan == 0 && (abs(DS3_StickX()) > 20 || abs(DS3_StickY()) > 20)) || abs(WUPC_lStickX(chan)) > 160 || abs(WUPC_lStickY(chan)) > 160)
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
|| (chan == 0 && (abs(DS3_StickX()) > 20 || abs(DS3_StickY()) > 20)) || (chan == 0 && (abs(WiiDRC_lStickX()) > 20 || abs(WiiDRC_lStickY()) > 20)))
{
m_show_pointer[chan] = true;
if(LEFT_STICK_LEFT)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(DS3_StickX()/10))|((int)abs(WUPC_lStickX(chan))/80));
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(WUPC_lStickX(chan))/80)|((int)abs(WiiDRC_lStickX())/8));
if(chan == 0)
pSpeed |= (int)abs(DS3_StickX()/10);
if(stickPointer_x[chan] > m_cursor[chan].width()/2)
stickPointer_x[chan] = stickPointer_x[chan]-speed-pSpeed;
pointerhidedelay[chan] = 150;
@ -218,7 +301,9 @@ void CMenu::LeftStick()
if(LEFT_STICK_DOWN)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(DS3_StickY()/10))|((int)abs(WUPC_lStickY(chan))/80));
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(WUPC_lStickY(chan))/80)|((int)abs(WiiDRC_lStickY())/8));
if(chan == 0)
pSpeed |= (int)abs(DS3_StickY()/10);
if(stickPointer_y[chan] < (m_vid.height() + (m_cursor[chan].height()/2)))
stickPointer_y[chan] = stickPointer_y[chan]+speed+pSpeed;
pointerhidedelay[chan] = 150;
@ -226,7 +311,9 @@ void CMenu::LeftStick()
if(LEFT_STICK_RIGHT)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(DS3_StickX()/10))|((int)abs(WUPC_lStickX(chan))/80));
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(WUPC_lStickX(chan))/80)|((int)abs(WiiDRC_lStickX())/8));
if(chan == 0)
pSpeed |= (int)abs(DS3_StickX()/10);
if(stickPointer_x[chan] < (m_vid.width() + (m_cursor[chan].width()/2)))
stickPointer_x[chan] = stickPointer_x[chan]+speed+pSpeed;
pointerhidedelay[chan] = 150;
@ -234,7 +321,9 @@ void CMenu::LeftStick()
if(LEFT_STICK_UP)
{
speed = (u8)(left_stick_mag[chan] * 10.00);
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(DS3_StickY()/10))|((int)abs(WUPC_lStickY(chan))/80));
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(WUPC_lStickY(chan))/80)|((int)abs(WiiDRC_lStickY())/8));
if(chan == 0)
pSpeed |= (int)abs(DS3_StickY()/10);
if(stickPointer_y[chan] > m_cursor[chan].height()/2)
stickPointer_y[chan] = stickPointer_y[chan]-speed-pSpeed;
pointerhidedelay[chan] = 150;
@ -273,6 +362,9 @@ bool CMenu::WPadIR_ANY(void)
return (wd[0]->ir.valid || wd[1]->ir.valid || wd[2]->ir.valid || wd[3]->ir.valid);
}
/* all _btnRepeat's are used the same as right stick below */
/* only called from menu_main and menu_game to move the coverflow up, down, left, right */
/* btn A repeat is used in config screen, sound, and adjust coverflow */
bool CMenu::wii_btnRepeat(u8 btn)
{
bool b = false;
@ -414,109 +506,13 @@ bool CMenu::gc_btnRepeat(s64 btn)
return b;
}
bool CMenu::ds3_btnRepeat(s64 btn)
{
bool b = false;
if(btn == DBTN_UP)
{
if(ds3_btnsPressed & DBTN_UP)
{
if(m_dpadUpDelay == 0 || m_dpadUpDelay >= g_repeatDelay)
b = true;
if(m_dpadUpDelay < g_repeatDelay)
++m_dpadUpDelay;
}
else
{
m_dpadUpDelay = 0;
m_btnMgr.noClick();
}
}
else if(btn == DBTN_RIGHT)
{
if(ds3_btnsPressed & DBTN_RIGHT)
{
if(m_dpadRightDelay == 0 || m_dpadRightDelay >= g_repeatDelay)
b = true;
if(m_dpadRightDelay < g_repeatDelay)
++m_dpadRightDelay;
}
else
{
m_dpadRightDelay = 0;
m_btnMgr.noClick();
}
}
else if(btn == DBTN_DOWN)
{
if(ds3_btnsPressed & DBTN_DOWN)
{
if(m_dpadDownDelay == 0 || m_dpadDownDelay >= g_repeatDelay)
b = true;
if(m_dpadDownDelay < g_repeatDelay)
++m_dpadDownDelay;
}
else
{
m_dpadDownDelay = 0;
m_btnMgr.noClick();
}
}
else if(btn == DBTN_LEFT)
{
if(ds3_btnsPressed & DBTN_LEFT)
{
if(m_dpadLeftDelay == 0 || m_dpadLeftDelay >= g_repeatDelay)
b = true;
if(m_dpadLeftDelay < g_repeatDelay)
++m_dpadLeftDelay;
}
else
{
m_dpadLeftDelay = 0;
m_btnMgr.noClick();
}
}
else if(btn == DBTN_A)
{
if(ds3_btnsPressed & DBTN_A)
{
m_btnMgr.noClick(true);
if(m_dpadADelay == 1 || m_dpadADelay >= g_repeatDelay)
b = true;
if(m_dpadADelay < g_repeatDelay)
++m_dpadADelay;
}
else
{
m_dpadADelay = 1;
m_btnMgr.noClick();
}
}
else if(btn == DBTN_START)
{
if(ds3_btnsPressed & DBTN_START)
{
m_btnMgr.noClick(true);
if(m_dpadHDelay == 0.5 || m_dpadHDelay >= g_repeatDelay)
b = true;
if(m_dpadHDelay < g_repeatDelay)
++m_dpadHDelay;
}
else
{
m_dpadHDelay = 0.5;
m_btnMgr.noClick();
}
}
return b;
}
bool CMenu::lStick_Up(void)
{
if(WiiDRC_lStickY() > 20 || DS3_StickY() < -20)
return true;
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 || DS3_StickY() < -20 || WUPC_lStickY(chan) > 160)
if((LEFT_STICK_ANG_UP && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) > 20 || WUPC_lStickY(chan) > 160)
return true;
}
return false;
@ -524,9 +520,11 @@ bool CMenu::lStick_Up(void)
bool CMenu::lStick_Right(void)
{
if(WiiDRC_lStickX() > 20 || DS3_StickX() > 20)
return true;
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 || DS3_StickX() > 20 || WUPC_lStickX(chan) > 160)
if((LEFT_STICK_ANG_RIGHT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) > 20 || WUPC_lStickX(chan) > 160)
return true;
}
return false;
@ -534,9 +532,11 @@ bool CMenu::lStick_Right(void)
bool CMenu::lStick_Down(void)
{
if(WiiDRC_lStickY() < -20 || DS3_StickY() > 20)
return true;
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 || DS3_StickY() > 20 || WUPC_lStickY(chan) < -160)
if((LEFT_STICK_ANG_DOWN && left_stick_mag[chan] > 0.15) || PAD_StickY(chan) < -20 || WUPC_lStickY(chan) < -160)
return true;
}
return false;
@ -544,16 +544,21 @@ bool CMenu::lStick_Down(void)
bool CMenu::lStick_Left(void)
{
if(WiiDRC_lStickX() < -20 || DS3_StickX() < -20)
return true;
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 || DS3_StickX() < -20 || WUPC_lStickX(chan) < -160)
if((LEFT_STICK_ANG_LEFT && left_stick_mag[chan] > 0.15) || PAD_StickX(chan) < -20 || WUPC_lStickX(chan) < -160)
return true;
}
return false;
}
/* right stick movements are only used in menu_main and menu_game to move the coverflow up, down, left, right just like the d-pad */
bool CMenu::rStick_Up(void)
{
if(WiiDRC_rStickY() > 30)
return true;
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 || WUPC_rStickY(chan) > 160)
@ -564,6 +569,8 @@ bool CMenu::rStick_Up(void)
bool CMenu::rStick_Right(void)
{
if(WiiDRC_rStickX() > 30)
return true;
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 || WUPC_rStickX(chan) > 160)
@ -574,6 +581,8 @@ bool CMenu::rStick_Right(void)
bool CMenu::rStick_Down(void)
{
if(WiiDRC_rStickY() < -30)
return true;
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 || WUPC_rStickY(chan) < -160)
@ -584,6 +593,8 @@ bool CMenu::rStick_Down(void)
bool CMenu::rStick_Left(void)
{
if(WiiDRC_rStickX() < -30)
return true;
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 || WUPC_rStickX(chan) < -160)
@ -658,13 +669,16 @@ void CMenu::ShowGameZone()
ShowZone(m_gameButtonsZone, m_show_zone_game);
}
/* returns the elapsed time of no controller input */
u32 CMenu::NoInputTime()
{
bool input_found = false;
/* showpointer() = true if any wiimote IR at screen or any controller left stick is moving pointer */
if(ShowPointer() == true || RIGHT_STICK_MOVE == true || gc_btnsPressed != 0)
input_found = true;
else
{
/* check if any wiimote buttons are pressed or held */
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
{
if(wii_btnsPressed[chan] != 0 || wii_btnsHeld[chan] != 0)

View File

@ -253,9 +253,10 @@ int CMenu::main(void)
m_btnMgr.show(m_mem1FreeSize);
m_btnMgr.show(m_mem2FreeSize);
}
SetupInput(true);
gprintf("start wiiflow main screen\n");
gprintf("wiiflow main screen ready!\n");
while(!m_exit)
{
/* IMPORTANT check if a disc is inserted */

View File

@ -103,6 +103,8 @@ void CMenu::_listEmuNands(const char *path, vector<string> &emuNands)
void CMenu::_checkEmuNandSettings(void)
{
if(isWiiVC)
return;
u8 i;
string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand", "default");
int emuPart = m_cfg.getInt(CHANNEL_DOMAIN, "partition", 0);
@ -191,6 +193,8 @@ void CMenu::_checkEmuNandSettings(void)
void CMenu::_FullNandCheck(void)
{
if(isWiiVC)
return;
for(u8 i = 0; i < 2; i++)
{
int emulate_mode;

View File

@ -345,6 +345,7 @@ int getTID(const char *path, u64 *tid)
void * CMenu::_pThread(void *obj)
{
CMenu *m = (CMenu*)obj;
m->SetupInput();
while(m->m_thrdInstalling)
{
m->_mainLoopCommon();

View File

@ -47,12 +47,12 @@ void SoundHandler::Init()
DecoderList[i] = NULL;
LWP_CreateThread(&SoundThread, UpdateThread, this, SoundStack, SoundStackSize, LWP_PRIO_HIGHEST);
gprintf("SHND: Running sound thread\n");
gprintf("Running sound thread\n");
}
void SoundHandler::Cleanup()
{
gprintf("SHND: Stopping sound thread\n");
gprintf("Stopping sound thread\n");
ExitRequested = true;
ThreadSignal();
@ -60,7 +60,7 @@ void SoundHandler::Cleanup()
SoundThread = LWP_THREAD_NULL;
ClearDecoderList();
gprintf("SHND: Stopped sound thread\n");
gprintf("Stopped sound thread\n");
}
void SoundHandler::AddDecoder(int voice, const char * filepath)

View File

@ -4,7 +4,7 @@
#ifndef _DS3WRAPPER_H_
#define _DS3WRAPPER_H_
#include <gctypes.h>
//#include <gctypes.h>
struct ss_device;

View File

@ -292,6 +292,7 @@ errgame15=WiiFlow locked! Unlock WiiFlow to use this feature.
errgame16=Not available for plugin games!
errgame17=Can not delete real NAND Channels!
errgame18=No game info!
errgame19=Can't launch in Wii virtual console mode!
errneek1=Cannot launch neek2o. Verify your neek2o setup
errsource1=Homebrew locked!
errsource2=Homebrew and multisource not allowed!