*added nunchuck to control of virtual screen pointer and removed it from control of list up/down scrolling and carousel

*fixed crash with 3D cover grabbing (old pointer method was still used)
*some clean up
This commit is contained in:
strtoul 2011-12-29 08:26:49 +00:00
parent d9be1719be
commit fffd644e67
8 changed files with 54 additions and 123 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>2.3 r1139</version> <version>2.3 r1141</version>
<release_date>201112281612</release_date> <release_date>201112290822</release_date>
<!-- // remove this line to enable arguments <!-- // remove this line to enable arguments
<arguments> <arguments>
<arg>--ios=250</arg> <arg>--ios=250</arg>

View File

@ -25,8 +25,7 @@
#include "BoxMesh.hpp" #include "BoxMesh.hpp"
#include "settings/CSettings.h" #include "settings/CSettings.h"
#include "themes/CTheme.h" #include "themes/CTheme.h"
#include "menu.h"
extern GuiImageData * pointer[4];
BoxCover::BoxCover(GuiImageData * img, bool flat) BoxCover::BoxCover(GuiImageData * img, bool flat)
: GuiImage(img), : GuiImage(img),
@ -56,15 +55,6 @@ BoxCover::BoxCover(GuiImageData * img, bool flat)
guLookAt(view, &camera, &up, &look); guLookAt(view, &camera, &up, &look);
guPerspective(projection, 8, 640.f/480.f, 1.0f, 300.0F); guPerspective(projection, 8, 640.f/480.f, 1.0f, 300.0F);
//! Remove me later
for(int i = 0; i < 4; ++i)
{
char name[50];
snprintf(name, sizeof(name), "player%i_grab.png", i+1);
GrabPointers[i] = Resources::GetImageData(name);
NormalPointers[i] = pointer[i];
}
if(flatCover || !image) if(flatCover || !image)
{ {
defaultBox = Resources::GetImageData("nocoverFull.png"); defaultBox = Resources::GetImageData("nocoverFull.png");
@ -85,10 +75,12 @@ BoxCover::BoxCover(GuiImageData * img, bool flat)
BoxCover::~BoxCover() BoxCover::~BoxCover()
{ {
delete defaultBox; delete defaultBox;
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
{ {
pointer[i] = NormalPointers[i]; char name[50];
delete GrabPointers[i]; snprintf(name, sizeof(name), "player%i_point.png", i+1);
pointer[i]->SetImage(name);
} }
} }
@ -106,8 +98,13 @@ void BoxCover::WiiPADControl(GuiTrigger *t)
PosY += movePosY; PosY += movePosY;
movePosX = 0.0f; movePosX = 0.0f;
movePosY = 0.0f; movePosY = 0.0f;
for(int i = 0; i < 4; ++i)
pointer[i] = GrabPointers[i]; if(moveChan >= 0 && moveChan < 3)
{
char name[50];
snprintf(name, sizeof(name), "player%i_grab.png", moveChan+1);
pointer[moveChan]->SetImage(name);
}
} }
else else
moveChan = -1; moveChan = -1;
@ -120,8 +117,12 @@ void BoxCover::WiiPADControl(GuiTrigger *t)
} }
else if(!(t->wpad.btns_h & WPAD_BUTTON_A) && moveChan == t->chan) else if(!(t->wpad.btns_h & WPAD_BUTTON_A) && moveChan == t->chan)
{ {
for(int i = 0; i < 4; ++i) if(moveChan >= 0 && moveChan < 3)
pointer[i] = NormalPointers[i]; {
char name[50];
snprintf(name, sizeof(name), "player%i_point.png", moveChan+1);
pointer[moveChan]->SetImage(name);
}
} }
if(t->wpad.btns_h & WPAD_BUTTON_UP) if(t->wpad.btns_h & WPAD_BUTTON_UP)

View File

@ -72,8 +72,6 @@ class BoxCover : public GuiImage
Mtx44 projection; Mtx44 projection;
GuiImageData boxBorder; GuiImageData boxBorder;
GuiImageData *defaultBox; GuiImageData *defaultBox;
GuiImageData *NormalPointers[4];
GuiImageData *GrabPointers[4];
Mtx view; Mtx view;
GXTexObj coverTex; GXTexObj coverTex;
GXTexObj boxBorderTex; GXTexObj boxBorderTex;

View File

@ -83,15 +83,8 @@ void WiiPointer::Draw(GuiTrigger *t)
lastActivity = 0; lastActivity = 0;
} }
int wpadX = 0; int wpadX = t->WPAD_Stick(0, 0);
int wpadY = 0; int wpadY = t->WPAD_Stick(0, 1);
// don't use it, if it's a nunchuck
if(t->wpad.exp.type != WPAD_EXP_NUNCHUK)
{
wpadX = t->WPAD_Stick(0, 0);
wpadY = t->WPAD_Stick(0, 1);
}
// Wii Extensions // Wii Extensions
// x-axis // x-axis

View File

@ -80,6 +80,7 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
switch ( wpad.exp.type ) switch ( wpad.exp.type )
{ {
default:
case WPAD_EXP_NUNCHUK: case WPAD_EXP_NUNCHUK:
case WPAD_EXP_GUITARHERO3: case WPAD_EXP_GUITARHERO3:
{ {
@ -104,8 +105,6 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
} }
break; break;
} }
default:
break;
} }
/* calculate x/y value (angle need to be converted into radian) */ /* calculate x/y value (angle need to be converted into radian) */
@ -131,8 +130,7 @@ bool GuiTrigger::Left()
wiibtn = WPAD_CLASSIC_BUTTON_LEFT; wiibtn = WPAD_CLASSIC_BUTTON_LEFT;
if ( ((wpad.btns_d | wpad.btns_h) & wiibtn) if ( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT))
|| (wpad.exp.type == WPAD_EXP_NUNCHUK && WPAD_Stick(0, 0) < -PADCAL))
{ {
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_LEFT)) if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_LEFT))
{ {
@ -155,8 +153,7 @@ bool GuiTrigger::Right()
wiibtn = WPAD_CLASSIC_BUTTON_RIGHT; wiibtn = WPAD_CLASSIC_BUTTON_RIGHT;
if ( ((wpad.btns_d | wpad.btns_h) & wiibtn) if ( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT))
|| (wpad.exp.type == WPAD_EXP_NUNCHUK && WPAD_Stick(0, 0) > PADCAL))
{ {
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_RIGHT)) if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_RIGHT))
{ {
@ -179,8 +176,7 @@ bool GuiTrigger::Up()
wiibtn = WPAD_CLASSIC_BUTTON_UP; wiibtn = WPAD_CLASSIC_BUTTON_UP;
if ( ((wpad.btns_d | wpad.btns_h) & wiibtn) if ( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP))
|| (wpad.exp.type == WPAD_EXP_NUNCHUK && WPAD_Stick(0, 1) > PADCAL))
{ {
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_UP)) if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_UP))
{ {
@ -203,8 +199,7 @@ bool GuiTrigger::Down()
wiibtn = WPAD_CLASSIC_BUTTON_DOWN; wiibtn = WPAD_CLASSIC_BUTTON_DOWN;
if ( ((wpad.btns_d | wpad.btns_h) & wiibtn) if ( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN))
|| (wpad.exp.type == WPAD_EXP_NUNCHUK && WPAD_Stick(0, 1) < -PADCAL))
{ {
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_DOWN)) if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_DOWN))
{ {

View File

@ -133,7 +133,6 @@ void SetupPads()
/**************************************************************************** /****************************************************************************
* ShutoffRumble * ShutoffRumble
***************************************************************************/ ***************************************************************************/
void ShutoffRumble() void ShutoffRumble()
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -146,7 +145,6 @@ void ShutoffRumble()
/**************************************************************************** /****************************************************************************
* DoRumble * DoRumble
***************************************************************************/ ***************************************************************************/
void DoRumble(int i) void DoRumble(int i)
{ {
if (rumbleRequest[i] && rumbleCount[i] < 3) if (rumbleRequest[i] && rumbleCount[i] < 3)
@ -166,56 +164,3 @@ void DoRumble(int i)
} }
} }
/****************************************************************************
* WPAD_Stick
*
* Get X/Y value from Wii Joystick (classic, nunchuk) input
***************************************************************************/
s8 WPAD_Stick(u8 chan, u8 right, int axis)
{
float mag = 0.0;
float ang = 0.0;
WPADData *data = WPAD_Data(chan);
switch (data->exp.type)
{
case WPAD_EXP_NUNCHUK:
case WPAD_EXP_GUITARHERO3:
if (right == 0)
{
mag = data->exp.nunchuk.js.mag;
ang = data->exp.nunchuk.js.ang;
}
break;
case WPAD_EXP_CLASSIC:
if (right == 0)
{
mag = data->exp.classic.ljs.mag;
ang = data->exp.classic.ljs.ang;
}
else
{
mag = data->exp.classic.rjs.mag;
ang = data->exp.classic.rjs.ang;
}
break;
default:
break;
}
/* calculate x/y value (angle need to be converted into radian) */
if (mag > 1.0)
mag = 1.0;
else if (mag < -1.0) mag = -1.0;
double val;
if (axis == 0) // x-axis
val = mag * sin((PI * ang) / 180.0f);
else // y-axis
val = mag * cos((PI * ang) / 180.0f);
return (s8) (val * 128.0f);
}

View File

@ -567,7 +567,9 @@ int PatchNewReturnTo(int es_fd, u64 title)
//! this is here for test purpose only and needs be moved later //! this is here for test purpose only and needs be moved later
static u64 sm_title_id ATTRIBUTE_ALIGN(32); static u64 sm_title_id ATTRIBUTE_ALIGN(32);
STACK_ALIGN(ioctlv, vector, 1, 32); ioctlv *vector = (ioctlv *) memalign(32, sizeof(ioctlv));
if(!vector)
return -1;
sm_title_id = title; sm_title_id = title;
vector[0].data = &sm_title_id; vector[0].data = &sm_title_id;
@ -581,29 +583,29 @@ int PatchNewReturnTo(int es_fd, u64 title)
if(result >= 0) if(result >= 0)
gprintf("Return to %08X patched with d2x method.\n", (u32) title); gprintf("Return to %08X patched with d2x method.\n", (u32) title);
free(vector);
return result; return result;
} }
int BlockIOSReload(int es_fd, u8 gameIOS) int BlockIOSReload(int es_fd, u8 gameIOS)
{ {
if(es_fd < 0) if(es_fd < 0)
return 0; return -1;
static int mode ATTRIBUTE_ALIGN(32); static int mode ATTRIBUTE_ALIGN(32);
static int ios ATTRIBUTE_ALIGN(32); static int ios ATTRIBUTE_ALIGN(32);
STACK_ALIGN(ioctlv, vector, 2, 32); ioctlv *vector = (ioctlv *) memalign(32, sizeof(ioctlv) * 2);
if(!vector)
return -1;
int inlen = 2;
mode = 2; mode = 2;
ios = gameIOS; // ios to be reloaded in place of the requested one
vector[0].data = &mode; vector[0].data = &mode;
vector[0].len = 4; vector[0].len = 4;
vector[1].data = &ios;
int inlen = 1; vector[1].len = 4;
if (mode == 2) {
inlen = 2;
ios = gameIOS; // ios to be reloaded in place of the requested one
vector[1].data = &ios;
vector[1].len = 4;
}
int result = -1; int result = -1;
@ -611,9 +613,11 @@ int BlockIOSReload(int es_fd, u8 gameIOS)
result = IOS_Ioctlv(es_fd, 0xA0, inlen, 0, vector); result = IOS_Ioctlv(es_fd, 0xA0, inlen, 0, vector);
if(result >= 0) if(result >= 0)
gprintf("Block IOS Reload patched with d2x method.\n"); gprintf("Block IOS Reload patched with d2x method to IOS%i; result: %i\n", gameIOS, result);
return (result >= 0); free(vector);
return result;
} }

View File

@ -290,12 +290,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
usleep(500000); // wait to see if progress flag changes soon usleep(500000); // wait to see if progress flag changes soon
if (!showProgress) return; if (!showProgress) return;
int PosY; const int ProgressPosY = 20;
//if(msg2 != 0)
// PosY = 40;
//else
PosY = 20;
GuiWindow promptWindow(472, 320); GuiWindow promptWindow(472, 320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
@ -321,18 +316,18 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
progressbarOutlineImg.SetWidescreen(Settings.widescreen); progressbarOutlineImg.SetWidescreen(Settings.widescreen);
} }
progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarOutlineImg.SetPosition(35, PosY); progressbarOutlineImg.SetPosition(35, ProgressPosY);
GuiImageData progressbarEmpty(Resources::GetFile("progressbar_empty.png"), Resources::GetFileSize("button_dialogue_box.png")); GuiImageData progressbarEmpty(Resources::GetFile("progressbar_empty.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImage progressbarEmptyImg(&progressbarEmpty); GuiImage progressbarEmptyImg(&progressbarEmpty);
progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarEmptyImg.SetPosition(35, PosY); progressbarEmptyImg.SetPosition(35, ProgressPosY);
progressbarEmptyImg.SetTileHorizontal(100); progressbarEmptyImg.SetTileHorizontal(100);
GuiImageData progressbar(Resources::GetFile("progressbar.png"), Resources::GetFileSize("progressbar.png")); GuiImageData progressbar(Resources::GetFile("progressbar.png"), Resources::GetFileSize("progressbar.png"));
GuiImage progressbarImg(&progressbar); GuiImage progressbarImg(&progressbar);
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarImg.SetPosition(35, PosY); progressbarImg.SetPosition(35, ProgressPosY);
GuiText titleTxt(title, 26, thColor("r=0 g=0 b=0 a=255 - prompt windows text color")); GuiText titleTxt(title, 26, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -350,7 +345,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
GuiText prsTxt("%", 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color")); GuiText prsTxt("%", 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
prsTxt.SetPosition(-178, PosY); prsTxt.SetPosition(-178, ProgressPosY);
GuiText timeTxt((char*) NULL, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color")); GuiText timeTxt((char*) NULL, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
timeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); timeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
@ -366,15 +361,15 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
GuiText prTxt((char*) NULL, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color")); GuiText prTxt((char*) NULL, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
prTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); prTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
prTxt.SetPosition(210, PosY); prTxt.SetPosition(210, ProgressPosY);
if ((Settings.wsprompt) && (Settings.widescreen)) /////////////adjust for widescreen if ((Settings.wsprompt) && (Settings.widescreen)) /////////////adjust for widescreen
{ {
progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
progressbarOutlineImg.SetPosition(0, PosY); progressbarOutlineImg.SetPosition(0, ProgressPosY);
progressbarEmptyImg.SetPosition(80, PosY); progressbarEmptyImg.SetPosition(80, ProgressPosY);
progressbarEmptyImg.SetTileHorizontal(78); progressbarEmptyImg.SetTileHorizontal(78);
progressbarImg.SetPosition(80, PosY); progressbarImg.SetPosition(80, ProgressPosY);
msg1Txt.SetMaxWidth(380, DOTTED); msg1Txt.SetMaxWidth(380, DOTTED);
msg2Txt.SetMaxWidth(380, DOTTED); msg2Txt.SetMaxWidth(380, DOTTED);
@ -401,7 +396,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
GuiButton cancelBtn(&cancelImg, &cancelImg, ALIGN_LEFT, ALIGN_MIDDLE, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1); GuiButton cancelBtn(&cancelImg, &cancelImg, ALIGN_LEFT, ALIGN_MIDDLE, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetLabel(&cancelTxt); cancelBtn.SetLabel(&cancelTxt);
cancelBtn.SetState(STATE_SELECTED); cancelBtn.SetState(STATE_SELECTED);
cancelBtn.SetPosition(dialogBoxImg.GetWidth()/2-cancelImg.GetWidth()/2*cancelScale, PosY + 45); cancelBtn.SetPosition(dialogBoxImg.GetWidth()/2-cancelImg.GetWidth()/2*cancelScale, ProgressPosY + 45);
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&progressbarEmptyImg); promptWindow.Append(&progressbarEmptyImg);