Skip to content

Commit

Permalink
-improved wiiu gamepad stick range a bit
Browse files Browse the repository at this point in the history
-when in device/game selection in the loader, allow console shutdown
  • Loading branch information
FIX94 committed Sep 29, 2017
1 parent 2d83769 commit 6653c99
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/include/NintendontVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __NINTENDONT_VERSION_H__

#define NIN_MAJOR_VERSION 5
#define NIN_MINOR_VERSION 465
#define NIN_MINOR_VERSION 466

#define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION)

Expand Down
7 changes: 7 additions & 0 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ int _main( int argc, char *argv[] )
BootStatus(1, 0, 0);
mdelay(10);

//give power button to loader
set32(HW_GPIO_ENABLE, GPIO_POWER);
clear32(HW_GPIO_DIR, GPIO_POWER);
set32(HW_GPIO_OWNER, GPIO_POWER);

//Loader running, selects games
while(1)
{
Expand Down Expand Up @@ -283,6 +288,8 @@ int _main( int argc, char *argv[] )
clear32(HW_GPIO_OWNER, GPIO_SENSOR_BAR);
set32(HW_GPIO_OUT, GPIO_SENSOR_BAR); //turn on sensor bar

clear32(HW_GPIO_OWNER, GPIO_POWER); //take back power button

write32( HW_PPCIRQMASK, (1<<30) ); //only allow IPC IRQ
write32( HW_PPCIRQFLAG, read32(HW_PPCIRQFLAG) );

Expand Down
11 changes: 8 additions & 3 deletions loader/extlibs/include/wiidrc/wiidrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct WiiDRCData {
s16 yAxisL;
s16 yAxisR;
u16 button;
u8 battery;
u8 extra;
};

Expand All @@ -35,16 +36,20 @@ struct WiiDRCData {
#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 0x30
#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();
Expand Down
Binary file modified loader/extlibs/lib/libwiidrc.a
Binary file not shown.
1 change: 1 addition & 0 deletions loader/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ int CreateNewFile(const char *Path, unsigned int size);
* @param ret Exit code.
*/
void ExitToLoader(int ret) NORETURN;
void LoaderShutdown() NORETURN;

void ClearScreen();
void CloseDevices();
Expand Down
1 change: 1 addition & 0 deletions loader/include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct GameInfo
// Disc format colors.
extern const u32 DiscFormatColors[8];

void SetShutdown(void);
void HandleSTMEvent(u32 event);
void HandleWiiMoteEvent(s32 chan);

Expand Down
Binary file modified loader/loader.dol
Binary file not shown.
10 changes: 9 additions & 1 deletion loader/source/FPad.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <unistd.h>
#include <wiidrc/wiidrc.h>
#include <wupc/wupc.h>
#include "menu.h"
#include "PADReadGC_bin.h"
#include "HID.h"

Expand Down Expand Up @@ -68,6 +69,7 @@ void FPAD_Init( void )
PAD_Init();
WUPC_Init();
WPAD_Init();
WPAD_SetPowerButtonCallback(HandleWiiMoteEvent);

WPAD_Pressed = 0;
WiiDRC_Pressed = 0;
Expand Down Expand Up @@ -109,10 +111,13 @@ void FPAD_Update( void )
}

/* DRC */
if(WiiDRC_ScanPads())
if(WiiDRC_Inited() && WiiDRC_Connected())
{
WiiDRC_ScanPads();
const struct WiiDRCData *drcstat = WiiDRC_Data();
WiiDRC_Pressed |= drcstat->button;
if(WiiDRC_ShutdownRequested())
SetShutdown();
}

/* HID */
Expand Down Expand Up @@ -150,6 +155,9 @@ void FPAD_Update( void )
SLock = false;
}
}
//Power Button
if((*(vu32*)0xCD8000C8) & 1)
SetShutdown();
}
bool FPAD_Up( bool ILock )
{
Expand Down
15 changes: 15 additions & 0 deletions loader/source/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ void ExitToLoader(int ret)
while(1) usleep(20000);
}

void LoaderShutdown()
{
GRRLIB_FreeTexture(background);
GRRLIB_FreeTexture(screen_buffer);
GRRLIB_FreeTTF(myFont);
GRRLIB_Exit();
CloseDevices();
gprintf("Loader Shutdown\n");
VIDEO_SetBlack(TRUE);
VIDEO_Flush();
VIDEO_WaitVSync();
SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0);
while(1) usleep(20000);
}

/**
* Load the configuration file from the root device.
* @return True if loaded successfully; false if not.
Expand Down
12 changes: 10 additions & 2 deletions loader/source/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ inline u32 SettingY(u32 row)
{
return 127 + 16 * row;
}
void HandleWiiMoteEvent(s32 chan)
void SetShutdown(void)
{
Shutdown = 1;
}
void HandleWiiMoteEvent(s32 chan)
{
SetShutdown();
}
void HandleSTMEvent(u32 event)
{
*(vu32*)(0xCC003024) = 1;
Expand All @@ -97,7 +101,7 @@ void HandleSTMEvent(u32 event)
case STM_EVENT_RESET:
break;
case STM_EVENT_POWER:
Shutdown = 1;
SetShutdown();
break;
}
}
Expand Down Expand Up @@ -1630,6 +1634,8 @@ static int SelectGame(void)
{
VIDEO_WaitVSync();
FPAD_Update();
if(Shutdown)
LoaderShutdown();

if( FPAD_Start(0) )
{
Expand Down Expand Up @@ -1746,6 +1752,8 @@ bool SelectDevAndGame(void)
{
VIDEO_WaitVSync();
FPAD_Update();
if(Shutdown)
LoaderShutdown();

if (redraw)
{
Expand Down
2 changes: 1 addition & 1 deletion loader/source/ppc/PADReadGC.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const s8 DEADZONE = 0x1A;

#define DRC_DEADZONE 10
#define _DRC_BUILD_TMPSTICK(inval) \
tmp_stick16 = (((s8)(inval-0x80))*13)>>3; \
tmp_stick16 = (((s8)(inval-0x80))*14)>>3; \
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; \
Expand Down

0 comments on commit 6653c99

Please sign in to comment.