mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Added analog sticks to emulated Classic Controller, the left analog stick is JKLI, the right stick is FGHT, the home button is U, the + and - buttons are O and N
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1322 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -223,11 +223,11 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
|||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/**/if(GetAsyncKeyState('V'))
|
/*if(GetAsyncKeyState('V'))
|
||||||
{
|
{
|
||||||
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
|
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
|
||||||
wprintf("DataFrame: %s\n", Temp.c_str());
|
wprintf("DataFrame: %s\n", Temp.c_str());
|
||||||
}
|
}*/
|
||||||
#endif
|
#endif
|
||||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||||
}
|
}
|
||||||
@ -268,11 +268,11 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
|
|||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/**/if(GetAsyncKeyState('V'))
|
/*if(GetAsyncKeyState('V'))
|
||||||
{
|
{
|
||||||
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
|
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
|
||||||
wprintf("DataFrame: %s\n", Temp.c_str());
|
wprintf("DataFrame: %s\n", Temp.c_str());
|
||||||
}
|
}*/
|
||||||
#endif
|
#endif
|
||||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||||
}
|
}
|
||||||
|
@ -239,10 +239,10 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
|
|||||||
wprintf("\n\nWmReadData Address: %08x Offset: %08x Size: %i byte\n",
|
wprintf("\n\nWmReadData Address: %08x Offset: %08x Size: %i byte\n",
|
||||||
address, address & 0xffff, (u8)size);
|
address, address & 0xffff, (u8)size);
|
||||||
|
|
||||||
// Debugging
|
/* Debugging
|
||||||
// u32 offset = address & 0xffff;
|
u32 offset = address & 0xffff;
|
||||||
//std::string Temp = WiiMoteEmu::ArrayToString(g_RegExt, size, offset);
|
std::string Temp = WiiMoteEmu::ArrayToString(g_RegExt, size, offset);
|
||||||
//wprintf("Unencrypted data:\n%s\n", Temp.c_str());
|
wprintf("Unencrypted data:\n%s\n", Temp.c_str());*/
|
||||||
|
|
||||||
// Check if encrypted reads is on
|
// Check if encrypted reads is on
|
||||||
if(g_RegExt[0xf0] == 0xaa)
|
if(g_RegExt[0xf0] == 0xaa)
|
||||||
|
@ -134,13 +134,14 @@ void Initialize()
|
|||||||
|
|
||||||
|
|
||||||
// Copy extension id and calibration to its register
|
// Copy extension id and calibration to its register
|
||||||
memcpy(g_RegExt + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration));
|
|
||||||
if(g_Config.bNunchuckConnected)
|
if(g_Config.bNunchuckConnected)
|
||||||
{
|
{
|
||||||
|
memcpy(g_RegExt + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration));
|
||||||
memcpy(g_RegExt + 0xfa, nunchuck_id, sizeof(nunchuck_id));
|
memcpy(g_RegExt + 0xfa, nunchuck_id, sizeof(nunchuck_id));
|
||||||
}
|
}
|
||||||
else if(g_Config.bClassicControllerConnected)
|
else if(g_Config.bClassicControllerConnected)
|
||||||
{
|
{
|
||||||
|
memcpy(g_RegExt + 0x20, classic_calibration, sizeof(classic_calibration));
|
||||||
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
|
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,9 @@ static const u8 nunchuck_calibration[] =
|
|||||||
0xe0,0x20,0x80,0xe0, 0x20,0x80,0xee,0x43
|
0xe0,0x20,0x80,0xe0, 0x20,0x80,0xee,0x43
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Classic Controller calibration */
|
/* Classic Controller calibration. 0x80 is the neutral for the analog triggers and
|
||||||
|
sticks. The left analog range is 0x1c - 0xe4 and the right is 0x28 - 0xd8.
|
||||||
|
We use this range because it's closest to the GC controller range. */
|
||||||
static const u8 classic_calibration[] =
|
static const u8 classic_calibration[] =
|
||||||
{
|
{
|
||||||
0xe4,0x1c,0x80,0xe4, 0x1c,0x80,0xd8,0x28,
|
0xe4,0x1c,0x80,0xe4, 0x1c,0x80,0xd8,0x28,
|
||||||
@ -94,7 +96,6 @@ static const u8 classic_calibration[] =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The Nunchuck id. It should be written to the last bytes of the
|
/* The Nunchuck id. It should be written to the last bytes of the
|
||||||
extension register */
|
extension register */
|
||||||
static const u8 nunchuck_id[] =
|
static const u8 nunchuck_id[] =
|
||||||
|
@ -488,20 +488,21 @@ void FillReportExtension(wm_extension& _ext)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if(GetAsyncKeyState(VK_NUMPAD4))
|
/* We use a 192 range (32 to 224) that match our calibration values in
|
||||||
|
nunchuck_calibration */
|
||||||
|
if(GetAsyncKeyState(VK_NUMPAD4)) // left
|
||||||
_ext.jx = 0x20;
|
_ext.jx = 0x20;
|
||||||
|
|
||||||
if(GetAsyncKeyState(VK_NUMPAD8))
|
if(GetAsyncKeyState(VK_NUMPAD8))
|
||||||
_ext.jy = 0xe0;
|
_ext.jy = 0xe0;
|
||||||
|
|
||||||
if(GetAsyncKeyState(VK_NUMPAD6))
|
if(GetAsyncKeyState(VK_NUMPAD6)) // right
|
||||||
_ext.jx = 0xe0;
|
_ext.jx = 0xe0;
|
||||||
|
|
||||||
if(GetAsyncKeyState(VK_NUMPAD5))
|
if(GetAsyncKeyState(VK_NUMPAD5))
|
||||||
_ext.jy = 0x20;
|
_ext.jy = 0x20;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(GetAsyncKeyState('C'))
|
if(GetAsyncKeyState('C'))
|
||||||
_ext.bt = 0x01;
|
_ext.bt = 0x01;
|
||||||
|
|
||||||
@ -519,26 +520,13 @@ void FillReportExtension(wm_extension& _ext)
|
|||||||
|
|
||||||
/* Write the nunchuck inputs to it. We begin writing at 0x08, but it could also be
|
/* Write the nunchuck inputs to it. We begin writing at 0x08, but it could also be
|
||||||
0x00, the important thing is that we begin at an address evenly divisible
|
0x00, the important thing is that we begin at an address evenly divisible
|
||||||
by 0x08
|
by 0x08 */
|
||||||
g_RegExtTmp[0x08] = _ext.jx;
|
|
||||||
g_RegExtTmp[0x09] = _ext.jy;
|
|
||||||
g_RegExtTmp[0x0a] = _ext.ax;
|
|
||||||
g_RegExtTmp[0x0b] = _ext.ay;
|
|
||||||
g_RegExtTmp[0x0c] = _ext.az;
|
|
||||||
g_RegExtTmp[0x0d] = _ext.bt; */
|
|
||||||
memcpy(g_RegExtTmp + 0x08, &_ext, sizeof(_ext));
|
memcpy(g_RegExtTmp + 0x08, &_ext, sizeof(_ext));
|
||||||
|
|
||||||
// Encrypt it
|
// Encrypt it
|
||||||
wiimote_encrypt(&g_ExtKey, &g_RegExtTmp[0x08], 0x08, sizeof(_ext));
|
wiimote_encrypt(&g_ExtKey, &g_RegExtTmp[0x08], 0x08, sizeof(_ext));
|
||||||
|
|
||||||
// Write it back
|
// Write it back
|
||||||
/*
|
|
||||||
_ext.jx = g_RegExtTmp[0x08];
|
|
||||||
_ext.jy = g_RegExtTmp[0x09];
|
|
||||||
_ext.ax = g_RegExtTmp[0x0a];
|
|
||||||
_ext.ay = g_RegExtTmp[0x0b];
|
|
||||||
_ext.az = g_RegExtTmp[0x0c];
|
|
||||||
_ext.bt = g_RegExtTmp[0x0d];*/
|
|
||||||
memcpy(&_ext, &g_RegExtTmp[0x08], sizeof(_ext));
|
memcpy(&_ext, &g_RegExtTmp[0x08], sizeof(_ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,13 +538,10 @@ void FillReportExtension(wm_extension& _ext)
|
|||||||
void FillReportClassicExtension(wm_classic_extension& _ext)
|
void FillReportClassicExtension(wm_classic_extension& _ext)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* These are the default neutral values for the nunchuck accelerometer according
|
/* These are the default neutral values for the analog triggers and sticks */
|
||||||
to a source.
|
u8 Rx = 0x80, Ry = 0x80, Lx = 0x80, Ly = 0x80, lT = 0x80, rT = 0x80;
|
||||||
_ext.ax = 0x80;
|
|
||||||
_ext.ay = 0x80;
|
|
||||||
_ext.az = 0xb3; */
|
|
||||||
|
|
||||||
_ext.b1.padding = 0x01; // these are the default values unless we use them
|
_ext.b1.padding = 0x01; // 0x01 means not pressed
|
||||||
_ext.b1.bRT = 0x01;
|
_ext.b1.bRT = 0x01;
|
||||||
_ext.b1.bP = 0x01;
|
_ext.b1.bP = 0x01;
|
||||||
_ext.b1.bH = 0x01;
|
_ext.b1.bH = 0x01;
|
||||||
@ -574,15 +559,53 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||||||
_ext.b2.bB = 0x01;
|
_ext.b2.bB = 0x01;
|
||||||
_ext.b2.bZL = 0x01;
|
_ext.b2.bZL = 0x01;
|
||||||
|
|
||||||
//_ext.bt = 0x03; // 0x03 means no button pressed, the button is zero active
|
// --------------------------------------
|
||||||
|
/* Left and right analog sticks
|
||||||
|
|
||||||
/*
|
u8 Lx : 6; // byte 0
|
||||||
_ir0.y2 = y2 & 0xff;
|
u8 Rx : 2;
|
||||||
_ir0.x2Hi = (x2 >> 8);
|
u8 Ly : 6; // byte 1
|
||||||
_ir0.y2Hi = (y2 >> 8);
|
u8 Rx2 : 2;
|
||||||
|
u8 Ry : 5; // byte 2
|
||||||
|
u8 lT : 2;
|
||||||
|
u8 Rx3 : 1;
|
||||||
|
u8 rT : 5; // byte 3
|
||||||
|
u8 lT2 : 3;
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* We use a 200 range (28 to 228) for the left analog stick and a 176 range
|
||||||
|
(40 to 216) for the right analog stick to match our calibration values
|
||||||
|
in classic_calibration */
|
||||||
|
if(GetAsyncKeyState('J')) // left analog left
|
||||||
|
Lx = 0x1c;
|
||||||
|
if(GetAsyncKeyState('I')) // up
|
||||||
|
Ly = 0xe4;
|
||||||
|
if(GetAsyncKeyState('L')) // right
|
||||||
|
Lx = 0xe4;
|
||||||
|
if(GetAsyncKeyState('K')) // down
|
||||||
|
Ly = 0x1c;
|
||||||
|
|
||||||
|
if(GetAsyncKeyState('F')) // right analog left
|
||||||
|
Rx = 0x28;
|
||||||
|
if(GetAsyncKeyState('T')) // up
|
||||||
|
Ry = 0xd8;
|
||||||
|
if(GetAsyncKeyState('H')) // right
|
||||||
|
Rx = 0xd8;
|
||||||
|
if(GetAsyncKeyState('G')) // down
|
||||||
|
Ry = 0x28;
|
||||||
|
|
||||||
|
_ext.Lx = (Lx >> 2);
|
||||||
|
_ext.Ly = (Ly >> 2);
|
||||||
|
_ext.Rx = (Rx >> 3); // this may be wrong
|
||||||
|
_ext.Rx2 = (Rx >> 5);
|
||||||
|
_ext.Rx3 = (Rx >> 7);
|
||||||
|
_ext.Ry = (Ry >> 2);
|
||||||
|
|
||||||
|
_ext.lT = (Ry >> 2);
|
||||||
|
_ext.lT2 = (Ry >> 3);
|
||||||
|
_ext.rT = (Ry >> 4);
|
||||||
|
// --------------
|
||||||
|
|
||||||
// I don't understand't the & 0x03, should we do that?
|
|
||||||
//_ir1.x1Hi = (x1 >> 8) & 0x3;*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -598,7 +621,6 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||||||
0: bdU
|
0: bdU
|
||||||
1: bdL
|
1: bdL
|
||||||
*/
|
*/
|
||||||
#ifdef _WIN32
|
|
||||||
if(GetAsyncKeyState(VK_NUMPAD4)) // left
|
if(GetAsyncKeyState(VK_NUMPAD4)) // left
|
||||||
_ext.b2.bdL = 0x00;
|
_ext.b2.bdL = 0x00;
|
||||||
|
|
||||||
@ -642,6 +664,15 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||||||
if(GetAsyncKeyState('X'))
|
if(GetAsyncKeyState('X'))
|
||||||
_ext.b2.bX = 0x00;
|
_ext.b2.bX = 0x00;
|
||||||
|
|
||||||
|
if(GetAsyncKeyState('O')) // O instead of P
|
||||||
|
_ext.b1.bP = 0x00;
|
||||||
|
|
||||||
|
if(GetAsyncKeyState('N')) // N instead of M
|
||||||
|
_ext.b1.bM = 0x00;
|
||||||
|
|
||||||
|
if(GetAsyncKeyState('U')) // Home button
|
||||||
|
_ext.b1.bH = 0x00;
|
||||||
|
|
||||||
if(GetAsyncKeyState('7')) // digital left trigger
|
if(GetAsyncKeyState('7')) // digital left trigger
|
||||||
_ext.b1.bLT = 0x00;
|
_ext.b1.bLT = 0x00;
|
||||||
|
|
||||||
@ -655,8 +686,8 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||||||
_ext.b1.bRT = 0x00;
|
_ext.b1.bRT = 0x00;
|
||||||
|
|
||||||
// All buttons pressed
|
// All buttons pressed
|
||||||
if(GetAsyncKeyState('C') && GetAsyncKeyState('Z'))
|
//if(GetAsyncKeyState('C') && GetAsyncKeyState('Z'))
|
||||||
{ _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; }
|
// { _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; }
|
||||||
// --------------
|
// --------------
|
||||||
#else
|
#else
|
||||||
// TODO linux port
|
// TODO linux port
|
||||||
|
@ -130,10 +130,10 @@ extern "C" void Wiimote_Initialize(SWiimoteInitialize _WiimoteInitialize)
|
|||||||
for it in that case */
|
for it in that case */
|
||||||
g_UseRealWiiMote = WiiMoteReal::Initialize() > 0;
|
g_UseRealWiiMote = WiiMoteReal::Initialize() > 0;
|
||||||
|
|
||||||
WiiMoteEmu::Initialize();
|
|
||||||
|
|
||||||
g_Config.Load(); // load config settings
|
g_Config.Load(); // load config settings
|
||||||
|
|
||||||
|
WiiMoteEmu::Initialize();
|
||||||
|
|
||||||
// Debugging window
|
// Debugging window
|
||||||
/*startConsoleWin(100, 750, "Wiimote"); // give room for 20 rows
|
/*startConsoleWin(100, 750, "Wiimote"); // give room for 20 rows
|
||||||
wprintf("Wiimote console opened\n");
|
wprintf("Wiimote console opened\n");
|
||||||
|
Reference in New Issue
Block a user