Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wiimote accelerometer data #1158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions kernel/BT.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ static s32 BTHandleData(void *arg,void *buffer,u16 len)

BTPad[chan].xAxisL = (*(((u8*)buffer)+16) - stat->xAxisLmid);
BTPad[chan].yAxisL = (*(((u8*)buffer)+17) - stat->yAxisLmid);
BTPad[chan].xAccel = (*(((u8*)buffer)+18) << 2) | ((*(((u8*)buffer)+21) & 0x0C) >> 2);
BTPad[chan].yAccel = (*(((u8*)buffer)+19) << 2) | ((*(((u8*)buffer)+21) & 0x30) >> 4);
BTPad[chan].zAccel = (*(((u8*)buffer)+20) << 2) | ((*(((u8*)buffer)+21) & 0xC0) >> 6);
BTPad[chan].xAccel[0] = (*(((u8*)buffer)+3) << 2) | ((*(((u8*)buffer)+2) & 0x60) >> 5);
BTPad[chan].yAccel[0] = (*(((u8*)buffer)+4) << 2) | ((*(((u8*)buffer)+1) & 0x20) >> 4);
BTPad[chan].zAccel[0] = (*(((u8*)buffer)+5) << 2) | ((*(((u8*)buffer)+1) & 0x40) >> 5);
BTPad[chan].xAccel[1] = (*(((u8*)buffer)+18) << 2) | ((*(((u8*)buffer)+21) & 0x0C) >> 2);
BTPad[chan].yAccel[1] = (*(((u8*)buffer)+19) << 2) | ((*(((u8*)buffer)+21) & 0x30) >> 4);
BTPad[chan].zAccel[1] = (*(((u8*)buffer)+20) << 2) | ((*(((u8*)buffer)+21) & 0xC0) >> 6);

struct IRdot {
bool has_data;
Expand Down
6 changes: 3 additions & 3 deletions kernel/BT.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ struct BTPadCont {
u32 button;
u8 triggerL;
u8 triggerR;
s16 xAccel;
s16 yAccel;
s16 zAccel;
s16 xAccel[2];
s16 yAccel[2];
s16 zAccel[2];
} ALIGNED(32);

#define BT_DPAD_UP 0x0001
Expand Down
6 changes: 3 additions & 3 deletions loader/include/FPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct BTPadCont {
u32 button;
u8 triggerL;
u8 triggerR;
s16 xAccel;
s16 yAccel;
s16 zAccel;
s16 xAccel[2];
s16 yAccel[2];
s16 zAccel[2];
} __attribute__((aligned(32)));

void FPAD_Init( void );
Expand Down
6 changes: 3 additions & 3 deletions loader/source/ppc/PADReadGC/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct BTPadCont {
u32 button;
u8 triggerL;
u8 triggerR;
s16 xAccel;
s16 yAccel;
s16 zAccel;
s16 xAccel[2];
s16 yAccel[2];
s16 zAccel[2];
} __attribute__((aligned(32)));

#define PAD_BUTTON_LEFT 0x0001
Expand Down
96 changes: 48 additions & 48 deletions loader/source/ppc/PADReadGC/source/PADReadGC.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,41 +876,41 @@ u32 PADRead(u32 calledByGame)
{
//tilt as cStick
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 350)
if(BTPad[chan].xAccel[1] < 350)
Pad[chan].substickX = -0x78;
else if(BTPad[chan].xAccel > 674)
else if(BTPad[chan].xAccel[1] > 674)
Pad[chan].substickX = 0x78;
else
Pad[chan].substickX = (BTPad[chan].xAccel - 512) * 0xF0 / (674 - 350);
Pad[chan].substickX = (BTPad[chan].xAccel[1] - 512) * 0xF0 / (674 - 350);

/* yAccel up=280 C=512 down=720 */
if(BTPad[chan].yAccel < 344)
if(BTPad[chan].yAccel[1] < 344)
Pad[chan].substickY = -0x78;
else if(BTPad[chan].yAccel > 680)
else if(BTPad[chan].yAccel[1] > 680)
Pad[chan].substickY = 0x78;
else
Pad[chan].substickY = (BTPad[chan].yAccel - 512) * 0xF0 / (680 - 344);
Pad[chan].substickY = (BTPad[chan].yAccel[1] - 512) * 0xF0 / (680 - 344);
}
else // use tilt as AnalogL and AnalogR
{
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 340)
if(BTPad[chan].xAccel[1] < 340)
{
button |= PAD_TRIGGER_L;
Pad[chan].triggerLeft = 0xFF;
}
else if(BTPad[chan].xAccel < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel) * 0xF0 / (475 - 340);
else if(BTPad[chan].xAccel[1] < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel[1]) * 0xF0 / (475 - 340);
else
Pad[chan].triggerLeft = 0;

if(BTPad[chan].xAccel > 670)
if(BTPad[chan].xAccel[1] > 670)
{
button |= PAD_TRIGGER_R;
Pad[chan].triggerRight = 0xFF;
}
else if(BTPad[chan].xAccel > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel - 550) * 0xF0 / (670 - 550);
else if(BTPad[chan].xAccel[1] > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel[1] - 550) * 0xF0 / (670 - 550);
else
Pad[chan].triggerRight = 0;

Expand Down Expand Up @@ -1023,20 +1023,20 @@ u32 PADRead(u32 calledByGame)
{
//tilt as cStick
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 350)
if(BTPad[chan].xAccel[1] < 350)
Pad[chan].substickX = -0x78;
else if(BTPad[chan].xAccel > 674)
else if(BTPad[chan].xAccel[1] > 674)
Pad[chan].substickX = 0x78;
else
Pad[chan].substickX = (BTPad[chan].xAccel - 512) * 0xF0 / (674 - 350);
Pad[chan].substickX = (BTPad[chan].xAccel[1] - 512) * 0xF0 / (674 - 350);

/* yAccel up=280 C=512 down=720 */
if(BTPad[chan].yAccel < 344)
if(BTPad[chan].yAccel[1] < 344)
Pad[chan].substickY = -0x78;
else if(BTPad[chan].yAccel > 680)
else if(BTPad[chan].yAccel[1] > 680)
Pad[chan].substickY = 0x78;
else
Pad[chan].substickY = (BTPad[chan].yAccel - 512) * 0xF0 / (680 - 344);
Pad[chan].substickY = (BTPad[chan].yAccel[1] - 512) * 0xF0 / (680 - 344);
}

if(BTPad[chan].button & WM_BUTTON_LEFT)
Expand Down Expand Up @@ -1076,43 +1076,43 @@ u32 PADRead(u32 calledByGame)
{
//tilt as cStick
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 350)
if(BTPad[chan].xAccel[1] < 350)
Pad[chan].substickX = -0x78;
else if(BTPad[chan].xAccel > 674)
else if(BTPad[chan].xAccel[1] > 674)
Pad[chan].substickX = 0x78;
else
Pad[chan].substickX = (BTPad[chan].xAccel - 512) * 0xF0 / (674 - 350);
Pad[chan].substickX = (BTPad[chan].xAccel[1] - 512) * 0xF0 / (674 - 350);

/* yAccel up=280 C=512 down=720 */
if(BTPad[chan].yAccel < 344)
if(BTPad[chan].yAccel[1] < 344)
Pad[chan].substickY = -0x78;
else if(BTPad[chan].yAccel > 680)
else if(BTPad[chan].yAccel[1] > 680)
Pad[chan].substickY = 0x78;
else
Pad[chan].substickY = (BTPad[chan].yAccel - 512) * 0xF0 / (680 - 344);
Pad[chan].substickY = (BTPad[chan].yAccel[1] - 512) * 0xF0 / (680 - 344);
}
else // gas use forward and back ward tilt as AnalogL and AnalogR
{
/* yAccel up=280 C=512 down=720 */
//break pedal
if(BTPad[chan].yAccel < 357)
if(BTPad[chan].yAccel[1] < 357)
{
button |= PAD_TRIGGER_L;
Pad[chan].triggerLeft = 0xFF;
}
else if(BTPad[chan].yAccel < 485)
Pad[chan].triggerLeft = (485 - BTPad[chan].yAccel) * 0xF0 / (485 - 357);
else if(BTPad[chan].yAccel[1] < 485)
Pad[chan].triggerLeft = (485 - BTPad[chan].yAccel[1]) * 0xF0 / (485 - 357);
else
Pad[chan].triggerLeft = 0;

//gas pedal
if(BTPad[chan].yAccel > 668)
if(BTPad[chan].yAccel[1] > 668)
{
button |= PAD_TRIGGER_R;
Pad[chan].triggerRight = 0xFF;
}
else if(BTPad[chan].yAccel > 540)
Pad[chan].triggerRight = (BTPad[chan].yAccel - 540) * 0xF0 / (668 - 540);
else if(BTPad[chan].yAccel[1] > 540)
Pad[chan].triggerRight = (BTPad[chan].yAccel[1] - 540) * 0xF0 / (668 - 540);
else
Pad[chan].triggerRight = 0;

Expand Down Expand Up @@ -1153,41 +1153,41 @@ u32 PADRead(u32 calledByGame)
{
//tilt as cStick
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 350)
if(BTPad[chan].xAccel[1] < 350)
Pad[chan].substickX = -0x78;
else if(BTPad[chan].xAccel > 674)
else if(BTPad[chan].xAccel[1] > 674)
Pad[chan].substickX = 0x78;
else
Pad[chan].substickX = (BTPad[chan].xAccel - 512) * 0xF0 / (674 - 350);
Pad[chan].substickX = (BTPad[chan].xAccel[1] - 512) * 0xF0 / (674 - 350);

/* yAccel up=280 C=512 down=720 */
if(BTPad[chan].yAccel < 344)
if(BTPad[chan].yAccel[1] < 344)
Pad[chan].substickY = -0x78;
else if(BTPad[chan].yAccel > 680)
else if(BTPad[chan].yAccel[1] > 680)
Pad[chan].substickY = 0x78;
else
Pad[chan].substickY = (BTPad[chan].yAccel - 512) * 0xF0 / (680 - 344);
Pad[chan].substickY = (BTPad[chan].yAccel[1] - 512) * 0xF0 / (680 - 344);
}
else // use tilt as AnalogL and AnalogR
{
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 340)
if(BTPad[chan].xAccel[1] < 340)
{
button |= PAD_TRIGGER_L;
Pad[chan].triggerLeft = 0xFF;
}
else if(BTPad[chan].xAccel < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel) * 0xF0 / (475 - 340);
else if(BTPad[chan].xAccel[1] < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel[1]) * 0xF0 / (475 - 340);
else
Pad[chan].triggerLeft = 0;

if(BTPad[chan].xAccel > 670)
if(BTPad[chan].xAccel[1] > 670)
{
button |= PAD_TRIGGER_R;
Pad[chan].triggerRight = 0xFF;
}
else if(BTPad[chan].xAccel > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel - 550) * 0xF0 / (670 - 550);
else if(BTPad[chan].xAccel[1] > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel[1] - 550) * 0xF0 / (670 - 550);
else
Pad[chan].triggerRight = 0;

Expand Down Expand Up @@ -1315,13 +1315,13 @@ u32 PADRead(u32 calledByGame)
{
// use tilt as AnalogL
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel < 340)
if(BTPad[chan].xAccel[1] < 340)
{
button |= PAD_TRIGGER_L;
Pad[chan].triggerLeft = 0xFF;
}
else if(BTPad[chan].xAccel < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel) * 0xF0 / (475 - 340);
else if(BTPad[chan].xAccel[1] < 475)
Pad[chan].triggerLeft = (475 - BTPad[chan].xAccel[1]) * 0xF0 / (475 - 340);
else
Pad[chan].triggerLeft = 0;
}
Expand All @@ -1339,13 +1339,13 @@ u32 PADRead(u32 calledByGame)
{
// use tilt as AnalogR
/* xAccel L=300 C=512 R=740 */
if(BTPad[chan].xAccel > 670)
if(BTPad[chan].xAccel[1] > 670)
{
button |= PAD_TRIGGER_R;
Pad[chan].triggerRight = 0xFF;
}
else if(BTPad[chan].xAccel > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel - 550) * 0xF0 / (670 - 550);
else if(BTPad[chan].xAccel[1] > 550)
Pad[chan].triggerRight = (BTPad[chan].xAccel[1] - 550) * 0xF0 / (670 - 550);
else
Pad[chan].triggerRight = 0;
}
Expand Down