Some Work on the Guitar extension for Wiimote, untested, no gui yet

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3674 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99
2009-07-04 07:28:48 +00:00
parent 76b5bd49f8
commit 86a51e0c57
9 changed files with 404 additions and 148 deletions
+18 -3
View File
@@ -68,10 +68,25 @@ struct Config
int TType;
};
struct PadGH3
{
enum EGH3Stick
{
KEYBOARD,
ANALOG1,
ANALOG2
};
int LType; // Analog Stick
int RType;
int TType; // Whammy bar
};
// Emulated Wiimote
bool bSidewaysDPad;
bool bWideScreen;
bool bNunchuckConnected, bClassicControllerConnected;
bool bNunchuckConnected;
bool bClassicControllerConnected;
bool bGuitarConnected;
// Real Wiimote
bool bConnectRealWiimote, bUseRealWiimote, bUpdateRealWiimote;
@@ -84,11 +99,11 @@ struct Config
PadTrigger Trigger;
PadNunchuck Nunchuck;
PadClassicController ClassicController;
PadGH3 GH3Controller;
// Screen size settings
bool bKeepAR43, bKeepAR169, bCrop;
};
extern Config g_Config;
#endif // _PLUGIN_WIIMOTE_CONFIG_H
#endif // _PLUGIN_WIIMOTE_CONFIG_H
@@ -67,9 +67,10 @@ InputCommon::CONTROLLER_STATE_NEW PadState[4];
InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4];
// Keyboard input
KeyboardWiimote g_Wm;
KeyboardNunchuck g_Nc;
KeyboardClassicController g_Cc;
KeyboardWiimote g_Wiimote_kbd;
KeyboardNunchuck g_NunchuckExt;
KeyboardClassicController g_ClassicContExt;
KeyboardGH3GLP g_GH3Ext;
} // namespace
@@ -155,6 +155,20 @@ static const u8 classic_id[] =
0x00, 0x00, 0xa4, 0x20, 0x01, 0x01
};
/* The GH3 guitar id. It should be written to the last bytes of the
extension register */
static const u8 gh3glp_id[] =
{
0x00, 0x00, 0xa4, 0x20, 0x01, 0x03
};
/* The GHWT drums id. It should be written to the last bytes of the
extension register */
static const u8 ghwtdrums_id[] =
{
0x01, 0x00, 0xa4, 0x20, 0x01, 0x03
};
/* The id for nothing inserted */
static const u8 nothing_id[] =
{
@@ -205,14 +219,14 @@ struct KeyboardWiimote
// Raw X and Y coordinate and processed X and Y coordinates
SIR IR;
};
extern KeyboardWiimote g_Wm;
extern KeyboardWiimote g_Wiimote_kbd;
struct KeyboardNunchuck
{
enum EKeyboardNunchuck
{
// This is not allowed in Linux so we have to set the starting value manually
#ifdef _WIN32
Z = g_Wm.LAST_CONSTANT,
Z = g_Wiimote_kbd.LAST_CONSTANT,
#else
Z = 16,
#endif
@@ -222,14 +236,14 @@ struct KeyboardNunchuck
LAST_CONSTANT
};
};
extern KeyboardNunchuck g_Nc;
extern KeyboardNunchuck g_NunchuckExt;
struct KeyboardClassicController
{
enum EKeyboardClassicController
{
// This is not allowed in Linux so we have to set the starting value manually
#ifdef _WIN32
A = g_Nc.LAST_CONSTANT,
A = g_NunchuckExt.LAST_CONSTANT,
#else
A = 23,
#endif
@@ -239,10 +253,31 @@ struct KeyboardClassicController
Tl, Tr, Zl, Zr,
Ll, Lr, Lu, Ld,
Rl, Rr, Ru, Rd,
SHAKE,
LAST_CONSTANT
};
};
extern KeyboardClassicController g_ClassicContExt;
struct KeyboardGH3GLP
{
enum EKeyboardGH3GLP
{
// This is not allowed in Linux so we have to set the starting value manually
#ifdef _WIN32
BG = g_ClassicContExt.LAST_CONSTANT,
#else
BG = 47,
#endif
BR, BY, BB,
BO, BP, BM,
WB,
Ll, Lr, Lu, Ld,
Bu, Bd,
SHAKE
};
};
extern KeyboardClassicController g_Cc;
extern KeyboardGH3GLP g_GH3Ext;
} // namespace
@@ -221,7 +221,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void IRData2DotsBasic(u8 *Data)
{
struct SDot* Dot = g_Wm.IR.Dot;
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
Dot[0].Rx = 1023 - (Data[0] | ((Data[2] & 0x30) << 4));
Dot[0].Ry = Data[1] | ((Data[2] & 0xc0) << 2);
@@ -263,7 +263,7 @@ void IRData2DotsBasic(u8 *Data)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void IRData2Dots(u8 *Data)
{
struct SDot* Dot = g_Wm.IR.Dot;
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
for (int i = 0; i < 4; ++i)
{
@@ -299,7 +299,7 @@ void IRData2Dots(u8 *Data)
void ReorderIRDots()
{
// Create a shortcut
struct SDot* Dot = g_Wm.IR.Dot;
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
// Variables
int i, j, order;
@@ -335,7 +335,7 @@ void ReorderIRDots()
void IRData2Distance()
{
// Create a shortcut
struct SDot* Dot = g_Wm.IR.Dot;
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
// Make these ones global
int i1, i2;
@@ -344,14 +344,14 @@ void IRData2Distance()
if (Dot[i1].Visible) break;
// Only one dot was visible, we can not calculate the distance
if (i1 == 4) { g_Wm.IR.Distance = 0; return; }
if (i1 == 4) { g_Wiimote_kbd.IR.Distance = 0; return; }
// Look at the next dot
for (i2 = i1 + 1; i2 < 4; ++i2)
if (Dot[i2].Visible) break;
// Only one dot was visible, we can not calculate the distance
if (i2 == 4) { g_Wm.IR.Distance = 0; return; }
if (i2 == 4) { g_Wiimote_kbd.IR.Distance = 0; return; }
/* For the emulated Wiimote the y distance is always zero so then the distance is the
simple distance between the x dots, i.e. the sensor bar width */
@@ -359,7 +359,7 @@ void IRData2Distance()
int yd = Dot[i2].Y - Dot[i1].Y;
// Save the distance
g_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
g_Wiimote_kbd.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
}
////////////////////////////////
+23 -18
View File
@@ -379,22 +379,22 @@ void UpdateEeprom()
}
else if(g_Config.bClassicControllerConnected)
{
g_cc.Lx.max = g_RegExt[0x20];
g_cc.Lx.min = g_RegExt[0x21];
g_cc.Lx.center = g_RegExt[0x22];
g_cc.Ly.max = g_RegExt[0x23];
g_cc.Ly.min = g_RegExt[0x24];
g_cc.Ly.center = g_RegExt[0x25];
g_ClassicContCalibration.Lx.max = g_RegExt[0x20];
g_ClassicContCalibration.Lx.min = g_RegExt[0x21];
g_ClassicContCalibration.Lx.center = g_RegExt[0x22];
g_ClassicContCalibration.Ly.max = g_RegExt[0x23];
g_ClassicContCalibration.Ly.min = g_RegExt[0x24];
g_ClassicContCalibration.Ly.center = g_RegExt[0x25];
g_cc.Rx.max = g_RegExt[0x26];
g_cc.Rx.min = g_RegExt[0x27];
g_cc.Rx.center = g_RegExt[0x28];
g_cc.Ry.max = g_RegExt[0x29];
g_cc.Ry.min = g_RegExt[0x2a];
g_cc.Ry.center = g_RegExt[0x2b];
g_ClassicContCalibration.Rx.max = g_RegExt[0x26];
g_ClassicContCalibration.Rx.min = g_RegExt[0x27];
g_ClassicContCalibration.Rx.center = g_RegExt[0x28];
g_ClassicContCalibration.Ry.max = g_RegExt[0x29];
g_ClassicContCalibration.Ry.min = g_RegExt[0x2a];
g_ClassicContCalibration.Ry.center = g_RegExt[0x2b];
g_cc.Tl.neutral = g_RegExt[0x2c];
g_cc.Tr.neutral = g_RegExt[0x2d];
g_ClassicContCalibration.Tl.neutral = g_RegExt[0x2c];
g_ClassicContCalibration.Tr.neutral = g_RegExt[0x2d];
INFO_LOG(CONSOLE, "UpdateCC: %i %i %i %i %i\n\n",
WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d],
@@ -459,6 +459,12 @@ void SetDefaultExtensionRegistry()
memcpy(g_RegExt + 0x30, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
}
else if(g_Config.bGuitarConnected)
{
// memcpy(g_RegExt + 0x20, classic_calibration, sizeof(classic_calibration));
// memcpy(g_RegExt + 0x30, classic_calibration, sizeof(classic_calibration));
memcpy(g_RegExt + 0xfa, gh3glp_id, sizeof(gh3glp_id));
}
INFO_LOG(CONSOLE, "\nSetDefaultExtensionRegistry()\n\n");
@@ -537,9 +543,9 @@ void DoState(PointerWrap &p)
p.DoArray(PadState, 4);
p.DoArray(PadMapping, 4);
p.Do(g_Wm);
p.Do(g_Nc);
p.Do(g_Cc);
p.Do(g_Wiimote_kbd);
p.Do(g_NunchuckExt);
p.Do(g_ClassicContExt);
}
/* This is not needed if we call FreeLibrary() when we stop a game, but if it's not called we need to reset
@@ -782,4 +788,3 @@ void Update()
} // end of namespace
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -75,7 +75,8 @@ bool g_WiimoteUnexpectedDisconnect = false;
// Settings
accel_cal g_wm;
nu_cal g_nu;
cc_cal g_cc;
cc_cal g_ClassicContCalibration;
gh3_cal g_GH3Calibration;
// Debugging
bool g_DebugAccelerometer = false;
@@ -489,7 +490,7 @@ void DisableExtensions()
g_Config.bNunchuckConnected = false;
g_Config.bClassicControllerConnected = false;
//g_Config.bBalanceBoard = false;
//g_Config.bGuitar = false;
g_Config.bGuitarConnected = false;
//g_Config.bDrums = false;
}
@@ -841,7 +842,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
if (data[1] == WM_REPORT_CORE_ACCEL_IR10_EXT6) WiiMoteEmu::IRData2DotsBasic(&data[7]); else WiiMoteEmu::IRData2Dots(&data[7]);
std::string IRData;
// Create a shortcut
struct WiiMoteEmu::SDot* Dot = WiiMoteEmu::g_Wm.IR.Dot;
struct WiiMoteEmu::SDot* Dot = WiiMoteEmu::g_Wiimote_kbd.IR.Dot;
for (int i = 0; i < 4; ++i)
{
if(Dot[i].Visible)
@@ -850,7 +851,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
IRData += StringFromFormat("[%i]", Dot[i].Order);
}
// Dot distance
IRData += StringFromFormat(" | Distance:%i", WiiMoteEmu::g_Wm.IR.Distance);
IRData += StringFromFormat(" | Distance:%i", WiiMoteEmu::g_Wiimote_kbd.IR.Distance);
// -------------------------
// Classic Controller data
+2 -1
View File
@@ -63,7 +63,8 @@ struct SRecordingAll
// Settings
extern accel_cal g_wm;
extern nu_cal g_nu;
extern cc_cal g_cc;
extern cc_cal g_ClassicContCalibration;
extern gh3_cal g_GH3Calibration;
// Debugging
extern bool g_DebugAccelerometer;
@@ -226,6 +226,39 @@ struct wm_classic_extension
wm_cc_5 b2; // byte 5
};
struct wm_GH3_extension
{
u8 SX : 6;
u8 pad1 : 2; // 1 on GH3, 0 on GHWT
u8 SY : 6;
u8 pad2 : 2; // 1 on GH3, 0 on GHWT
u8 TB : 5; // not used in GH3
u8 pad3 : 3; // Always 0
u8 WB : 5;
u8 pad4 : 3; // Always 0
u8 pad5 : 2; // Always 1
u8 BP : 1;
u8 pad6 : 1; // Always 1
u8 BM : 1;
u8 pad7 : 1; // Always 1
u8 BD : 1;
u8 pad8 : 1; // Always 1
u8 BU : 1;
u8 pad9 : 2; // Always 1
u8 BY : 1;
u8 BG : 1;
u8 BB : 1;
u8 BR : 1;
u8 BO : 1;
};
//******************************************************************************
// Data reports
//******************************************************************************
@@ -324,6 +357,13 @@ struct cc_cal
cc_trigger Tl; //
cc_trigger Tr; //
};
struct gh3_cal
{
nu_js Lx
nu_js Ly;
nu_js Rx;
nu_js Ry;
};
#pragma pack(pop)