mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Wiimote: More work, don't ask, no answer
nJoy: Maybe this could reactivate multi-pad? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4729 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
#include "wiimote_hid.h"
|
||||
#include "Config.h"
|
||||
#include "EmuDefinitions.h" // for PadMapping
|
||||
#include "main.h"
|
||||
@ -293,7 +293,7 @@ void Config::Load(bool ChangePad)
|
||||
iniFile.Get("Real", "AccNunNeutralY", &iAccNunNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralZ", &iAccNunNeutralZ, 0);
|
||||
|
||||
for (int i = 0; i < 1; i++) // Only got 1 wiimote yet
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
// Slot specific settings
|
||||
char SectionName[32];
|
||||
@ -404,7 +404,7 @@ void Config::Save(int Slot)
|
||||
iniFile.Set("Real", "AccNunNeutralY", iAccNunNeutralY);
|
||||
iniFile.Set("Real", "AccNunNeutralZ", iAccNunNeutralZ);
|
||||
|
||||
for (int i = 0; i < 1; i++) // Only got 1 wiimote yet
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
// Slot specific settings
|
||||
char SectionName[32];
|
||||
|
@ -261,7 +261,7 @@ void WiimotePadConfigDialog::DoSave(bool ChangePad, int Slot)
|
||||
if(ChangePad)
|
||||
{
|
||||
// Since we are selecting the pad to save to by the Id we can't update it when we change the pad
|
||||
for(int i = 0; i < 1; i++) // Only got 1 wiimote yet
|
||||
for(int i = 0; i < MAX_WIIMOTES; i++)
|
||||
SaveButtonMapping(i, true);
|
||||
// Save the settings for the current pad
|
||||
// g_Config.Save(Slot);
|
||||
@ -271,7 +271,7 @@ void WiimotePadConfigDialog::DoSave(bool ChangePad, int Slot)
|
||||
else
|
||||
{
|
||||
// Update PadMapping[] from the GUI controls
|
||||
for(int i = 0; i < 1; i++) // Only got 1 wiimote yet
|
||||
for(int i = 0; i < MAX_WIIMOTES; i++)
|
||||
SaveButtonMapping(i);
|
||||
// g_Config.Save(Slot);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void WmReportMode(u16 _channelID, wm_report_mode* dr)
|
||||
DEBUG_LOG(WIIMOTE, " All The Time: %x (not only on data change)", dr->all_the_time);
|
||||
DEBUG_LOG(WIIMOTE, " Mode: 0x%02x", dr->mode);
|
||||
|
||||
g_ReportingAuto = dr->all_the_time;
|
||||
g_ReportingAuto[g_RefreshWiimote] = dr->all_the_time;
|
||||
g_ReportingMode = dr->mode;
|
||||
g_ReportingChannel = _channelID;
|
||||
|
||||
@ -114,8 +114,7 @@ void SendReportCore(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
@ -140,7 +139,7 @@ void SendReportCoreAccel(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -170,7 +169,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -215,7 +214,7 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -269,7 +268,7 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
|
@ -36,7 +36,7 @@ namespace WiiMoteEmu
|
||||
// Definitions and variable declarations
|
||||
//******************************************************************************
|
||||
|
||||
u8 g_Leds;
|
||||
u8 g_Leds[4];
|
||||
u8 g_Speaker;
|
||||
u8 g_SpeakerVoice;
|
||||
u8 g_IR;
|
||||
@ -48,7 +48,8 @@ u8 g_RegExt[WIIMOTE_REG_EXT_SIZE];
|
||||
u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
|
||||
u8 g_RegIr[WIIMOTE_REG_IR_SIZE];
|
||||
|
||||
bool g_ReportingAuto; // Auto report or passive report
|
||||
int g_RefreshWiimote; // Current refreshing Wiimote
|
||||
bool g_ReportingAuto[4]; // Auto report or passive report
|
||||
u8 g_ReportingMode; // The reporting mode and channel id
|
||||
u16 g_ReportingChannel;
|
||||
|
||||
@ -69,6 +70,7 @@ KeyboardNunchuck g_NunchuckExt;
|
||||
KeyboardClassicController g_ClassicContExt;
|
||||
KeyboardGH3GLP g_GH3Ext;
|
||||
bool KeyStatus[64];
|
||||
SWiimoteData g_WiimoteData[4];
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
|
@ -68,7 +68,7 @@ extern double g_RecordingCurrentTime[3];
|
||||
#define WIIMOTE_REG_EXT_SIZE 0x100
|
||||
#define WIIMOTE_REG_IR_SIZE 0x34
|
||||
|
||||
extern u8 g_Leds;
|
||||
extern u8 g_Leds[4];
|
||||
extern u8 g_Speaker;
|
||||
extern u8 g_SpeakerVoice;
|
||||
extern u8 g_IR;
|
||||
@ -80,7 +80,8 @@ extern u8 g_RegExt[WIIMOTE_REG_EXT_SIZE];
|
||||
extern u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
|
||||
extern u8 g_RegIr[WIIMOTE_REG_IR_SIZE];
|
||||
|
||||
extern bool g_ReportingAuto;
|
||||
extern int g_RefreshWiimote;
|
||||
extern bool g_ReportingAuto[4];
|
||||
extern u8 g_ReportingMode;
|
||||
extern u16 g_ReportingChannel;
|
||||
|
||||
@ -187,6 +188,14 @@ struct STiltData
|
||||
}
|
||||
};
|
||||
|
||||
struct SWiimoteData
|
||||
{
|
||||
// Raw X and Y coordinate and processed X and Y coordinates
|
||||
SIR IR;
|
||||
STiltData TiltWM;
|
||||
STiltData TiltNC;
|
||||
};
|
||||
extern SWiimoteData g_WiimoteData[4];
|
||||
|
||||
// Keyboard input
|
||||
struct KeyboardWiimote
|
||||
@ -204,10 +213,6 @@ struct KeyboardWiimote
|
||||
MA, MB,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
|
||||
// Raw X and Y coordinate and processed X and Y coordinates
|
||||
SIR IR;
|
||||
STiltData TiltData;
|
||||
};
|
||||
extern KeyboardWiimote g_Wiimote_kbd;
|
||||
|
||||
@ -215,12 +220,7 @@ struct KeyboardNunchuck
|
||||
{
|
||||
enum EKeyboardNunchuck
|
||||
{
|
||||
// This is not allowed in Linux so we have to set the starting value manually
|
||||
#ifdef _WIN32
|
||||
Z = g_Wiimote_kbd.LAST_CONSTANT,
|
||||
#else
|
||||
Z = 18,
|
||||
#endif
|
||||
Z = 18,
|
||||
C,
|
||||
L, R, U, D,
|
||||
ROLL_L, ROLL_R,
|
||||
@ -228,8 +228,6 @@ struct KeyboardNunchuck
|
||||
SHAKE,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
|
||||
STiltData TiltData;
|
||||
};
|
||||
extern KeyboardNunchuck g_NunchuckExt;
|
||||
|
||||
@ -237,12 +235,7 @@ struct KeyboardClassicController
|
||||
{
|
||||
enum EKeyboardClassicController
|
||||
{
|
||||
// This is not allowed in Linux so we have to set the starting value manually
|
||||
#ifdef _WIN32
|
||||
A = g_NunchuckExt.LAST_CONSTANT,
|
||||
#else
|
||||
A = 29,
|
||||
#endif
|
||||
A = 29,
|
||||
B, X, Y,
|
||||
P, M, H,
|
||||
Tl, Tr, Zl, Zr,
|
||||
@ -258,12 +251,7 @@ struct KeyboardGH3GLP
|
||||
{
|
||||
enum EKeyboardGH3GLP
|
||||
{
|
||||
// This is not allowed in Linux so we have to set the starting value manually
|
||||
#ifdef _WIN32
|
||||
Green = g_ClassicContExt.LAST_CONSTANT,
|
||||
#else
|
||||
Green = 52,
|
||||
#endif
|
||||
Green = 52,
|
||||
Red, Yellow, Blue, Orange,
|
||||
Plus, Minus, Whammy,
|
||||
Al, Ar, Au, Ad,
|
||||
|
@ -243,6 +243,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
|
||||
// IR data functions
|
||||
//******************************************************************************
|
||||
|
||||
/*
|
||||
// Calculate dot positions from the basic 10 byte IR data
|
||||
void IRData2DotsBasic(u8 *Data)
|
||||
{
|
||||
@ -260,7 +261,7 @@ void IRData2DotsBasic(u8 *Data)
|
||||
Dot[3].Rx = 1023 - (Data[8] | ((Data[7] & 0x03) << 8));
|
||||
Dot[3].Ry = Data[9] | ((Data[7] & 0x0c) << 6);
|
||||
|
||||
/* set each IR spot to visible if spot is in range */
|
||||
// set each IR spot to visible if spot is in range
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (Dot[i].Ry == 1023)
|
||||
@ -270,7 +271,7 @@ void IRData2DotsBasic(u8 *Data)
|
||||
else
|
||||
{
|
||||
Dot[i].Visible = 1;
|
||||
Dot[i].Size = 0; /* since we don't know the size, set it as 0 */
|
||||
Dot[i].Size = 0; // since we don't know the size, set it as 0
|
||||
}
|
||||
|
||||
// For now we let our virtual resolution be the same as the default one
|
||||
@ -281,8 +282,9 @@ void IRData2DotsBasic(u8 *Data)
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
@ -297,7 +299,7 @@ void IRData2Dots(u8 *Data)
|
||||
|
||||
Dot[i].Size = Data[(3*i)+2] & 0x0f;
|
||||
|
||||
/* if in range set to visible */
|
||||
// if in range set to visible
|
||||
if (Dot[i].Ry == 1023)
|
||||
Dot[i].Visible = false;
|
||||
else
|
||||
@ -313,8 +315,9 @@ void IRData2Dots(u8 *Data)
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
void ReorderIRDots()
|
||||
{
|
||||
@ -347,8 +350,9 @@ void ReorderIRDots()
|
||||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
void IRData2Distance()
|
||||
{
|
||||
@ -371,15 +375,15 @@ void IRData2Distance()
|
||||
// Only one dot was visible, we can not calculate the distance
|
||||
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 */
|
||||
// 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
|
||||
int xd = Dot[i2].X - Dot[i1].X;
|
||||
int yd = Dot[i2].Y - Dot[i1].Y;
|
||||
|
||||
// Save the distance
|
||||
g_Wiimote_kbd.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//******************************************************************************
|
||||
// Classic Controller functions
|
||||
|
@ -374,11 +374,17 @@ void ExtensionChecksum(u8 * Calibration)
|
||||
// Set initial valuesm this done both in Init and Shutdown
|
||||
void ResetVariables()
|
||||
{
|
||||
g_ReportingAuto = false;
|
||||
g_RefreshWiimote = 0;
|
||||
g_ReportingMode = 0;
|
||||
g_ReportingChannel = 0;
|
||||
g_Encryption = false;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
g_ReportingAuto[i] = false;
|
||||
memset(&g_WiimoteData[i], 0, sizeof(g_WiimoteData));
|
||||
}
|
||||
|
||||
// Set default recording values
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
for (int i = 0; i < 3; i++)
|
||||
@ -469,7 +475,6 @@ void Initialize()
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
// TODO: Shorten the list
|
||||
p.Do(g_Leds);
|
||||
p.Do(g_Speaker);
|
||||
p.Do(g_SpeakerVoice);
|
||||
p.Do(g_IR);
|
||||
@ -480,7 +485,6 @@ void DoState(PointerWrap &p)
|
||||
p.DoArray(g_RegExtTmp, WIIMOTE_REG_EXT_SIZE);
|
||||
p.DoArray(g_RegIr, WIIMOTE_REG_IR_SIZE);
|
||||
|
||||
p.Do(g_ReportingAuto);
|
||||
p.Do(g_ReportingMode);
|
||||
p.Do(g_ReportingChannel);
|
||||
|
||||
@ -492,10 +496,16 @@ void DoState(PointerWrap &p)
|
||||
//p.Do(joyinfo);
|
||||
//p.DoArray(PadState, 4);
|
||||
//p.DoArray(PadMapping, 4);
|
||||
|
||||
//p.Do(g_Wiimote_kbd);
|
||||
//p.Do(g_NunchuckExt);
|
||||
//p.Do(g_ClassicContExt);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
p.Do(g_ReportingAuto[i]);
|
||||
p.Do(g_Leds[i]);
|
||||
p.Do(g_WiimoteData[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -515,8 +525,9 @@ void Shutdown()
|
||||
|
||||
/* This function produce Wiimote Input, i.e. reports from the Wiimote in
|
||||
response to Output from the Wii. */
|
||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
g_RefreshWiimote = _number;
|
||||
/* Debugging. We have not yet decided how much of 'data' we will use, it's
|
||||
not determined by sizeof(data). We have to determine it by looking at
|
||||
the data cases. */
|
||||
@ -524,7 +535,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
|
||||
hid_packet* hidp = (hid_packet*)_pData;
|
||||
|
||||
INFO_LOG(WIIMOTE, "Emu InterruptChannel (type: 0x%02x, param: 0x%02x)", hidp->type, hidp->param);
|
||||
INFO_LOG(WIIMOTE, "Emu InterruptChannel (page: %i, type: 0x%02x, param: 0x%02x)", _number, hidp->type, hidp->param);
|
||||
|
||||
switch(hidp->type)
|
||||
{
|
||||
@ -562,11 +573,13 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
}
|
||||
|
||||
|
||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
g_RefreshWiimote = _number;
|
||||
|
||||
hid_packet* hidp = (hid_packet*)_pData;
|
||||
|
||||
INFO_LOG(WIIMOTE, "Emu ControlChannel (type: 0x%02x, param: 0x%02x)", hidp->type, hidp->param);
|
||||
INFO_LOG(WIIMOTE, "Emu ControlChannel (page: %i, type: 0x%02x, param: 0x%02x)", _number, hidp->type, hidp->param);
|
||||
|
||||
switch(hidp->type)
|
||||
{
|
||||
@ -586,7 +599,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
// (TO_BE_VERIFIED)
|
||||
//
|
||||
u8 handshake = 0;
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, &handshake, 1);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, &handshake, 1);
|
||||
|
||||
PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!");
|
||||
}
|
||||
@ -608,13 +621,14 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
documentation. I'm not sure exactly how often this function is called but I
|
||||
think it's tied to the frame rate of the game rather than a certain amount
|
||||
of times per second. */
|
||||
void Update()
|
||||
void Update(int _number)
|
||||
{
|
||||
if(g_ReportingAuto == false)
|
||||
if (g_ReportingAuto[_number] == false)
|
||||
return;
|
||||
|
||||
// Read input or not
|
||||
g_RefreshWiimote = _number;
|
||||
|
||||
// Read input or not
|
||||
if (g_Config.bInputActive)
|
||||
{
|
||||
ReadLinuxKeyboard();
|
||||
@ -626,9 +640,8 @@ void Update()
|
||||
&& NumGoodPads > 0 && joyinfo.size() > (u32)PadMapping[0].ID)
|
||||
*/
|
||||
// Check if the pad state should be updated
|
||||
const int Page = 0;
|
||||
if (NumGoodPads > 0 && joyinfo.size() > (u32)PadMapping[Page].ID)
|
||||
WiiMoteEmu::GetJoyState(PadState[Page], PadMapping[Page], Page, joyinfo[PadMapping[Page].ID].NumButtons);
|
||||
if (NumGoodPads > 0 && joyinfo.size() > (u32)PadMapping[g_RefreshWiimote].ID)
|
||||
WiiMoteEmu::GetJoyState(PadState[g_RefreshWiimote], PadMapping[g_RefreshWiimote], g_RefreshWiimote, joyinfo[PadMapping[g_RefreshWiimote].ID].NumButtons);
|
||||
}
|
||||
|
||||
switch(g_ReportingMode)
|
||||
|
@ -38,9 +38,9 @@ void GetMousePos(float& x, float& y);
|
||||
void Initialize();
|
||||
void DoState(PointerWrap &p);
|
||||
void Shutdown();
|
||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) ;
|
||||
void Update();
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) ;
|
||||
void Update(int _number);
|
||||
void ReadLinuxKeyboard();
|
||||
|
||||
// Recordings
|
||||
@ -68,8 +68,8 @@ void AdjustAngles(int &Roll, int &Pitch);
|
||||
void RotateIRDots(int &_x, int &_y, STiltData &_TiltData);
|
||||
void IRData2Dots(u8 *Data);
|
||||
void IRData2DotsBasic(u8 *Data);
|
||||
void ReorderIRDots();
|
||||
void IRData2Distance();
|
||||
//void ReorderIRDots();
|
||||
//void IRData2Distance();
|
||||
|
||||
// Classic Controller data
|
||||
std::string CCData2Values(u8 *Data);
|
||||
|
@ -164,7 +164,7 @@ void WmLeds(u16 _channelID, wm_leds* leds)
|
||||
{
|
||||
INFO_LOG(WIIMOTE, "Set LEDs: %x, Rumble: %x", leds->leds, leds->rumble);
|
||||
|
||||
g_Leds = leds->leds;
|
||||
g_Leds[g_RefreshWiimote] = leds->leds;
|
||||
}
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ void WmSendAck(u16 _channelID, u8 _reportID)
|
||||
DEBUG_LOG(WIIMOTE, "WMSendAck");
|
||||
DEBUG_LOG(WIIMOTE, " Report ID: %02x", _reportID);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -360,11 +360,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, int _Size)
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
std::string Temp = ArrayToString(DataFrame, Offset);
|
||||
ERROR_LOG(WIIMOTE, "Data: %s", Temp.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "Data: %s", Temp.c_str());
|
||||
#endif
|
||||
|
||||
// Send a piece
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Update the size that is left
|
||||
_Size -= copySize;
|
||||
@ -482,7 +482,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pStatus->buttons);
|
||||
#endif
|
||||
pStatus->leds = g_Leds; // leds are 4 bit
|
||||
pStatus->leds = g_Leds[g_RefreshWiimote]; // leds are 4 bit
|
||||
pStatus->ir = g_IR; // 1 bit
|
||||
pStatus->speaker = g_Speaker; // 1 bit
|
||||
pStatus->battery_low = 0; // battery is okay
|
||||
@ -514,7 +514,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
DEBUG_LOG(WIIMOTE, " Extension: %x", pStatus->extension);
|
||||
DEBUG_LOG(WIIMOTE, " Buttons: 0x%04x", pStatus->buttons);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(g_RefreshWiimote, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
|
@ -686,16 +686,16 @@ void TiltWiimote(int &_x, int &_y, int &_z)
|
||||
return;
|
||||
// Select input method and return the x, y, x values
|
||||
else if (g_Config.Tilt.TypeWM == g_Config.Tilt.KEYBOARD)
|
||||
TiltByKeyboardWM(g_Wiimote_kbd.TiltData);
|
||||
TiltByKeyboardWM(g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
else
|
||||
TiltByGamepad(g_Wiimote_kbd.TiltData, g_Config.Tilt.TypeWM);
|
||||
TiltByGamepad(g_WiimoteData[g_RefreshWiimote].TiltWM, g_Config.Tilt.TypeWM);
|
||||
|
||||
// Adjust angles, it's only needed if both roll and pitch is used together
|
||||
if (g_Config.Tilt.Range.Roll != 0 && g_Config.Tilt.Range.Pitch != 0)
|
||||
AdjustAngles(g_Wiimote_kbd.TiltData.Roll, g_Wiimote_kbd.TiltData.Pitch);
|
||||
AdjustAngles(g_WiimoteData[g_RefreshWiimote].TiltWM.Roll, g_WiimoteData[g_RefreshWiimote].TiltWM.Pitch);
|
||||
|
||||
// Calculate the accelerometer value from this tilt angle
|
||||
TiltToAccelerometer(_x, _y, _z, g_Wiimote_kbd.TiltData);
|
||||
TiltToAccelerometer(_x, _y, _z, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
|
||||
//DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_Wiimote_kbd.TiltData.Roll, g_Wiimote_kbd.TiltData.Pitch, _x, _y, _z);
|
||||
}
|
||||
@ -708,16 +708,16 @@ void TiltNunchuck(int &_x, int &_y, int &_z)
|
||||
return;
|
||||
// Select input method and return the x, y, x values
|
||||
else if (g_Config.Tilt.TypeNC == g_Config.Tilt.KEYBOARD)
|
||||
TiltByKeyboardNC(g_NunchuckExt.TiltData);
|
||||
TiltByKeyboardNC(g_WiimoteData[g_RefreshWiimote].TiltNC);
|
||||
else
|
||||
TiltByGamepad(g_NunchuckExt.TiltData, g_Config.Tilt.TypeNC);
|
||||
TiltByGamepad(g_WiimoteData[g_RefreshWiimote].TiltNC, g_Config.Tilt.TypeNC);
|
||||
|
||||
// Adjust angles, it's only needed if both roll and pitch is used together
|
||||
if (g_Config.Tilt.Range.Roll != 0 && g_Config.Tilt.Range.Pitch != 0)
|
||||
AdjustAngles(g_NunchuckExt.TiltData.Roll, g_NunchuckExt.TiltData.Pitch);
|
||||
AdjustAngles(g_WiimoteData[g_RefreshWiimote].TiltNC.Roll, g_WiimoteData[g_RefreshWiimote].TiltNC.Pitch);
|
||||
|
||||
// Calculate the accelerometer value from this tilt angle
|
||||
TiltToAccelerometer(_x, _y, _z, g_NunchuckExt.TiltData);
|
||||
TiltToAccelerometer(_x, _y, _z, g_WiimoteData[g_RefreshWiimote].TiltNC);
|
||||
|
||||
//DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_NunchuckExt.TiltData.Roll, g_NunchuckExt.TiltData.Pitch, _x, _y, _z);
|
||||
}
|
||||
@ -745,11 +745,11 @@ void FillReportAcc(wm_accel& _acc)
|
||||
|
||||
// Adjust position, also add some noise to prevent disconnection
|
||||
if (!g_Config.bUpright)
|
||||
_acc.z += g_wm.cal_g.z + g_Wiimote_kbd.TiltData.FakeNoise;
|
||||
_acc.z += g_wm.cal_g.z + g_WiimoteData[g_RefreshWiimote].TiltWM.FakeNoise;
|
||||
else // Upright wiimote
|
||||
_acc.y -= g_wm.cal_g.y + g_Wiimote_kbd.TiltData.FakeNoise;
|
||||
_acc.y -= g_wm.cal_g.y + g_WiimoteData[g_RefreshWiimote].TiltWM.FakeNoise;
|
||||
|
||||
g_Wiimote_kbd.TiltData.FakeNoise = -g_Wiimote_kbd.TiltData.FakeNoise;
|
||||
g_WiimoteData[g_RefreshWiimote].TiltWM.FakeNoise = -g_WiimoteData[g_RefreshWiimote].TiltWM.FakeNoise;
|
||||
|
||||
if (IsFocus())
|
||||
{
|
||||
@ -757,14 +757,14 @@ void FillReportAcc(wm_accel& _acc)
|
||||
int acc_y = _acc.y;
|
||||
int acc_z = _acc.z;
|
||||
|
||||
if (IsKey(g_Wiimote_kbd.SHAKE) && g_Wiimote_kbd.TiltData.Shake == 0)
|
||||
g_Wiimote_kbd.TiltData.Shake = 1;
|
||||
if (IsKey(g_Wiimote_kbd.SHAKE) && g_WiimoteData[g_RefreshWiimote].TiltWM.Shake == 0)
|
||||
g_WiimoteData[g_RefreshWiimote].TiltWM.Shake = 1;
|
||||
|
||||
// Step the shake simulation one step
|
||||
ShakeToAccelerometer(acc_x, acc_y, acc_z, g_Wiimote_kbd.TiltData);
|
||||
ShakeToAccelerometer(acc_x, acc_y, acc_z, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
|
||||
// Tilt Wiimote, allow the shake function to interrupt it
|
||||
if (g_Wiimote_kbd.TiltData.Shake == 0)
|
||||
if (g_WiimoteData[g_RefreshWiimote].TiltWM.Shake == 0)
|
||||
TiltWiimote(acc_x, acc_y, acc_z);
|
||||
|
||||
// Boundary check
|
||||
@ -916,8 +916,8 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
||||
int x0 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
|
||||
int x1 = x0 + SENSOR_BAR_WIDTH;
|
||||
|
||||
RotateIRDot(x0, y0, g_Wiimote_kbd.TiltData);
|
||||
RotateIRDot(x1, y1, g_Wiimote_kbd.TiltData);
|
||||
RotateIRDot(x0, y0, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
RotateIRDot(x1, y1, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
|
||||
// Converted to IR data
|
||||
_ir0.x = x0 & 0xff; _ir0.xHi = x0 >> 8;
|
||||
@ -993,8 +993,8 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
|
||||
int x1 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
|
||||
int x2 = x1 + SENSOR_BAR_WIDTH;
|
||||
|
||||
RotateIRDot(x1, y1, g_Wiimote_kbd.TiltData);
|
||||
RotateIRDot(x2, y2, g_Wiimote_kbd.TiltData);
|
||||
RotateIRDot(x1, y1, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
RotateIRDot(x2, y2, g_WiimoteData[g_RefreshWiimote].TiltWM);
|
||||
|
||||
/* As with the extented report we settle with emulating two out of four
|
||||
possible objects the only difference is that we don't report any size of
|
||||
@ -1082,14 +1082,14 @@ if (IsFocus())
|
||||
int acc_y = _ext.ay;
|
||||
int acc_z = _ext.az;
|
||||
|
||||
if (IsKey(g_NunchuckExt.SHAKE) && g_NunchuckExt.TiltData.Shake == 0)
|
||||
g_NunchuckExt.TiltData.Shake = 1;
|
||||
if (IsKey(g_NunchuckExt.SHAKE) && g_WiimoteData[g_RefreshWiimote].TiltNC.Shake == 0)
|
||||
g_WiimoteData[g_RefreshWiimote].TiltNC.Shake = 1;
|
||||
|
||||
// Step the shake simulation one step
|
||||
ShakeToAccelerometer(acc_x, acc_y, acc_z, g_NunchuckExt.TiltData);
|
||||
ShakeToAccelerometer(acc_x, acc_y, acc_z, g_WiimoteData[g_RefreshWiimote].TiltNC);
|
||||
|
||||
// Tilt Nunchuck, allow the shake function to interrupt it
|
||||
if (g_NunchuckExt.TiltData.Shake == 0)
|
||||
if (g_WiimoteData[g_RefreshWiimote].TiltNC.Shake == 0)
|
||||
TiltNunchuck(acc_x, acc_y, acc_z);
|
||||
|
||||
// Boundary check
|
||||
|
@ -305,7 +305,7 @@ void DoState(unsigned char **ptr, int mode)
|
||||
Switch between real and emulated wiimote: We send all this Input to WiiMoteEmu::InterruptChannel()
|
||||
so that it knows the channel ID and the data reporting mode at all times.
|
||||
*/
|
||||
void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
void Wiimote_InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
@ -319,17 +319,17 @@ void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
|
||||
// Decice where to send the message
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
||||
WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size);
|
||||
WiiMoteEmu::InterruptChannel(_number, _channelID, _pData, _Size);
|
||||
#if HAVE_WIIUSE
|
||||
else if (g_RealWiiMotePresent)
|
||||
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size);
|
||||
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size); // TODO: Multi-Wiimote
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Function: Used for the initial Bluetooth HID handshake.
|
||||
|
||||
void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
@ -354,17 +354,17 @@ void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
}
|
||||
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
||||
WiiMoteEmu::ControlChannel(_channelID, _pData, _Size);
|
||||
WiiMoteEmu::ControlChannel(_number, _channelID, _pData, _Size);
|
||||
#if HAVE_WIIUSE
|
||||
else if (g_RealWiiMotePresent)
|
||||
WiiMoteReal::ControlChannel(_channelID, _pData, _Size);
|
||||
WiiMoteReal::ControlChannel(_channelID, _pData, _Size); // TODO: Multi-Wiimote
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* This sends a Data Report from the Wiimote. See SystemTimers.cpp for the documentation of this
|
||||
update. */
|
||||
void Wiimote_Update()
|
||||
void Wiimote_Update(int _number)
|
||||
{
|
||||
// Tell us about the update rate, but only about once every second to avoid a major slowdown
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
@ -384,10 +384,10 @@ void Wiimote_Update()
|
||||
// Emulated Wiimote: Only data reports 0x30-0x37
|
||||
// Real Wiimote: Both data reports 0x30-0x37 and all other read reports
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
||||
WiiMoteEmu::Update();
|
||||
WiiMoteEmu::Update(_number);
|
||||
#if HAVE_WIIUSE
|
||||
else if (g_RealWiiMotePresent)
|
||||
WiiMoteReal::Update();
|
||||
WiiMoteReal::Update(); // TODO: Multi-Wiimote
|
||||
#endif
|
||||
|
||||
// Debugging
|
||||
@ -445,7 +445,7 @@ void DisableExtensions()
|
||||
g_Config.iExtensionConnected = EXT_NONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
{
|
||||
//
|
||||
@ -484,8 +484,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
//(pStatus->leds >> 3),
|
||||
pStatus->battery_low
|
||||
);
|
||||
/* Update the global (for both the real and emulated) extension settings from whatever
|
||||
the real Wiimote use. We will enable the extension from the 0x21 report. */
|
||||
// Update the global (for both the real and emulated) extension settings from whatever
|
||||
// the real Wiimote use. We will enable the extension from the 0x21 report.
|
||||
if(!Emu && !pStatus->extension)
|
||||
{
|
||||
DisableExtensions();
|
||||
@ -518,8 +518,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x02, (data[4] >> 0x04) + 1);
|
||||
}
|
||||
|
||||
/* Update the global extension settings. Enable the emulated extension from reading
|
||||
what the real Wiimote has connected. To keep the emulated and real Wiimote in sync. */
|
||||
// Update the global extension settings. Enable the emulated extension from reading
|
||||
// what the real Wiimote has connected. To keep the emulated and real Wiimote in sync.
|
||||
if(data[4] == 0x10)
|
||||
{
|
||||
if (!Emu) DisableExtensions();
|
||||
@ -553,9 +553,9 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
}
|
||||
|
||||
// Show the Wiimote neutral values
|
||||
/* The only difference between the Nunchuck and Wiimote that we go
|
||||
after is calibration here is the offset in memory. If needed we can
|
||||
check the preceding 0x17 request to. */
|
||||
// The only difference between the Nunchuck and Wiimote that we go
|
||||
// after is calibration here is the offset in memory. If needed we can
|
||||
// check the preceding 0x17 request to.
|
||||
if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
|
||||
{
|
||||
if(data[6] == 0x10)
|
||||
@ -763,7 +763,6 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
// ---------------------------------------------
|
||||
// Test the angles to x, y, z values formula by calculating the values back and forth
|
||||
// -----------
|
||||
/*
|
||||
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
|
||||
Console->ClearScreen();
|
||||
// Show a test of our calculations
|
||||
@ -771,7 +770,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
u8 x, y, z;
|
||||
//WiiMoteEmu::Tilt(x, y, z);
|
||||
//WiiMoteEmu::TiltTest(x, y, z);
|
||||
*/
|
||||
|
||||
// -------------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
@ -825,7 +824,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
DEBUG_LOG(WIIMOTE, "Accel x, y, z: %03u %03u %03u", data[4], data[5], data[6]);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void InterruptDebugging(bool Emu, const void* _pData)
|
||||
{
|
||||
|
@ -25,6 +25,8 @@
|
||||
#endif
|
||||
#pragma pack(push, 1)
|
||||
|
||||
#define MAX_WIIMOTES 2
|
||||
|
||||
// Source: HID_010_SPC_PFL/1.0 (official HID specification)
|
||||
|
||||
struct hid_packet {
|
||||
|
@ -235,7 +235,7 @@ void SendEvent(SEvent& _rEvent)
|
||||
Offset += sizeof(_rEvent.m_PayLoad);
|
||||
|
||||
// Send it
|
||||
g_WiimoteInitialize.pWiimoteInput(m_channelID, Buffer, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInput(0, m_channelID, Buffer, Offset); // TODO: Multi-Wiimote
|
||||
|
||||
// Debugging
|
||||
// ReadDebugging(false, Buffer, Offset);
|
||||
|
@ -26,8 +26,6 @@
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
|
||||
#define MAX_WIIMOTES 1
|
||||
|
||||
int Initialize();
|
||||
void DoState(PointerWrap &p);
|
||||
void Shutdown(void);
|
||||
|
@ -119,6 +119,7 @@ void PADConfigDialognJoy::SaveButtonMapping(int controller, bool DontChangeId, i
|
||||
|
||||
// Set other settings
|
||||
if(!DontChangeId) PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
||||
PadMapping[controller].enable = m_Enable[FromSlot]->IsChecked();
|
||||
PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
|
||||
PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
|
||||
PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection();
|
||||
|
@ -259,6 +259,9 @@ void PAD_Input(u16 _Key, u8 _UpDown)
|
||||
// Check if the keys are interesting, and then update it
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
if (!PadMapping[i].enable)
|
||||
continue;
|
||||
|
||||
for(int j = InputCommon::CTL_L_SHOULDER; j <= InputCommon::CTL_START; j++)
|
||||
{
|
||||
if (PadMapping[i].buttons[j] == _Key)
|
||||
@ -292,7 +295,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
{
|
||||
// Check if the pad is avaliable, currently we don't disable pads just because they are
|
||||
// disconnected
|
||||
if (!PadState[_numPAD].joy || !PadMapping[_numPAD].enable)
|
||||
if (!PadState[_numPAD].joy)
|
||||
return;
|
||||
|
||||
// Clear pad status
|
||||
|
Reference in New Issue
Block a user