mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Wiimote plugin cleanup & linux build fix
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3677 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -38,9 +38,7 @@ extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// ===================================================
|
||||
/* Bit shift conversions */
|
||||
// -------------
|
||||
u32 convert24bit(const u8* src) {
|
||||
return (src[0] << 16) | (src[1] << 8) | src[2];
|
||||
}
|
||||
@ -48,12 +46,9 @@ u32 convert24bit(const u8* src) {
|
||||
u16 convert16bit(const u8* src) {
|
||||
return (src[0] << 8) | src[1];
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
|
||||
// ----------------
|
||||
void GetMousePos(float& x, float& y)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -72,10 +67,8 @@ void GetMousePos(float& x, float& y)
|
||||
float XOffset = 0, YOffset = 0;
|
||||
float PictureWidth = WinWidth, PictureHeight = WinHeight;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
/* Calculate the actual picture size and location */
|
||||
// Output: PictureWidth, PictureHeight, XOffset, YOffset
|
||||
// ------------------
|
||||
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
|
||||
{
|
||||
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
||||
@ -84,55 +77,38 @@ void GetMousePos(float& x, float& y)
|
||||
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
|
||||
if (Ratio > 1)
|
||||
{
|
||||
// ------------------------------------------------
|
||||
// Calculate the new width and height for glViewport, this is not the actual size of either the picture or the screen
|
||||
// ----------------
|
||||
PictureWidth = WinWidth / Ratio;
|
||||
// --------------------
|
||||
|
||||
// ------------------------------------------------
|
||||
// Calculate the new X offset
|
||||
// ----------------
|
||||
|
||||
// Move the left of the picture to the middle of the screen
|
||||
XOffset = XOffset + WinWidth / 2.0f;
|
||||
// Then remove half the picture height to move it to the horizontal center
|
||||
XOffset = XOffset - PictureWidth / 2.0f;
|
||||
// --------------------
|
||||
}
|
||||
// The window is to high, we have to limit the height
|
||||
else
|
||||
{
|
||||
// ------------------------------------------------
|
||||
// Calculate the new width and height for glViewport, this is not the actual size of either the picture or the screen
|
||||
// ----------------
|
||||
// Invert the ratio to make it > 1
|
||||
Ratio = 1.0f / Ratio;
|
||||
PictureHeight = WinHeight / Ratio;
|
||||
// --------------------
|
||||
|
||||
// ------------------------------------------------
|
||||
|
||||
// Calculate the new Y offset
|
||||
// ----------------
|
||||
// Move the top of the picture to the middle of the screen
|
||||
YOffset = YOffset + WinHeight / 2.0f;
|
||||
// Then remove half the picture height to move it to the vertical center
|
||||
YOffset = YOffset - PictureHeight / 2.0f;
|
||||
// --------------------
|
||||
}
|
||||
// Logging
|
||||
/*
|
||||
// Console::ClearScreen();
|
||||
INFO_LOG(CONSOLE, "Screen Width:%4.0f Height:%4.0f Ratio:%1.2f\n", WinWidth, WinHeight, Ratio);
|
||||
INFO_LOG(CONSOLE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset);
|
||||
INFO_LOG(CONSOLE, "----------------------------------------------------------------\n");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Screen Width:%4.0f Height:%4.0f Ratio:%1.2f\n", WinWidth, WinHeight, Ratio);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset);
|
||||
*/
|
||||
}
|
||||
// -------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
/* Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10. */
|
||||
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
|
||||
// Output: PictureWidth, PictureHeight, XOffset, YOffset
|
||||
// ------------------
|
||||
if ((g_Config.bKeepAR43 || g_Config.bKeepAR169) && g_Config.bCrop)
|
||||
{
|
||||
float Ratio = g_Config.bKeepAR43 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
|
||||
@ -149,41 +125,31 @@ void GetMousePos(float& x, float& y)
|
||||
XOffset = float(XOffset - (IncreasedWidth / 2.0));
|
||||
YOffset = float(YOffset - (IncreasedHeight / 2.0));
|
||||
|
||||
// Logging
|
||||
/*
|
||||
INFO_LOG(CONSOLE, "Crop Ratio:%1.2f IncrWidth:%3.0f IncrHeight:%3.0f\n", Ratio, IncreasedWidth, IncreasedHeight);
|
||||
INFO_LOG(CONSOLE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset);
|
||||
INFO_LOG(CONSOLE, "----------------------------------------------------------------\n");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Crop Ratio:%1.2f IncrWidth:%3.0f IncrHeight:%3.0f\n", Ratio, IncreasedWidth, IncreasedHeight);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset);
|
||||
*/
|
||||
}
|
||||
// -------------------------------------
|
||||
|
||||
|
||||
// Return the mouse position as a fraction of one, inside the picture, with (0.0, 0.0) being the upper left corner of the picture
|
||||
x = ((float)point.x - XOffset) / PictureWidth;
|
||||
y = ((float)point.y - YOffset) / PictureHeight;
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// Logging
|
||||
// -------------
|
||||
/*
|
||||
INFO_LOG(CONSOLE, "GetCursorPos: %i %i\n", point.x, point.y);
|
||||
INFO_LOG(CONSOLE, "GetClientRect: %i %i %i %i\n", Rect.left, Rect.right, Rect.top, Rect.bottom);
|
||||
INFO_LOG(CONSOLE, "Position X:%1.2f Y:%1.2f\n", x, y);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "GetCursorPos: %i %i\n", point.x, point.y);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "GetClientRect: %i %i %i %i\n", Rect.left, Rect.right, Rect.top, Rect.bottom);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Position X:%1.2f Y:%1.2f\n", x, y);
|
||||
*/
|
||||
// ---------------------------
|
||||
|
||||
|
||||
#else
|
||||
// TODO fix on linux
|
||||
x = 0.5f;
|
||||
y = 0.5f;
|
||||
#endif
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Homebrew encryption for 16 byte zero keys. */
|
||||
// ----------------
|
||||
void CryptBuffer(u8* _buffer, u8 _size)
|
||||
{
|
||||
for (int i=0; i<_size; i++)
|
||||
@ -198,41 +164,33 @@ void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value)
|
||||
CryptBuffer((u8*)&cryptedValue, sizeof(u16));
|
||||
|
||||
*(u16*)(_baseBlock + _address) = cryptedValue;
|
||||
//PanicAlert("Converted %04x to %04x", _value, cryptedValue);
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Calculate Extenstion Regisister Calibration Checksum */
|
||||
// This function is not currently used, it's just here to show how the values in EmuDefinitions.h are calculated.
|
||||
// ----------------
|
||||
// This function is not currently used, it's just here to show how the values
|
||||
// in EmuDefinitions.h are calculated.
|
||||
void GetCalibrationChecksum()
|
||||
{
|
||||
u8 sum = 0;
|
||||
for (int i = 0; i < sizeof(nunchuck_calibration) - 2; i++)
|
||||
for (u32 i = 0; i < sizeof(nunchuck_calibration) - 2; i++)
|
||||
sum += nunchuck_calibration[i];
|
||||
u8 Check1 = sum + 0x55;
|
||||
u8 Check2 = sum + 0xaa;
|
||||
INFO_LOG(CONSOLE, "0x%02x 0x%02x", Check1, Check2);
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "0x%02x 0x%02x", (sum + 0x55), (sum + 0xaa));
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Load pre-recorded movements */
|
||||
// ----------------
|
||||
void LoadRecordedMovements()
|
||||
{
|
||||
INFO_LOG(CONSOLE, "LoadRecordedMovements()\n");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "LoadRecordedMovements()\n");
|
||||
|
||||
IniFile file;
|
||||
file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini");
|
||||
|
||||
for(int i = 0; i < RECORDING_ROWS; i++)
|
||||
{
|
||||
// Logging
|
||||
//INFO_LOG(CONSOLE, "Recording%i ", i + 1);
|
||||
//INFO_LOG(WII_IPC_WIIMOTE, "Recording%i ", i + 1);
|
||||
|
||||
// Temporary storage
|
||||
int iTmp;
|
||||
@ -276,12 +234,11 @@ void LoadRecordedMovements()
|
||||
Tmp.y = atoi(StrY.c_str());
|
||||
Tmp.z = atoi(StrZ.c_str());
|
||||
|
||||
// ---------------------------------
|
||||
// Go to next set of IR values
|
||||
// ---------
|
||||
// If there is no IR data saving we fill the array with zeroes. This should only be able to occur from manual ini editing
|
||||
// but we check for it anyway
|
||||
if (TmpIRBytes == 0) for(int i = 0; i < 12; i++) Tmp.IR[i] = 0;
|
||||
|
||||
// If there is no IR data saving we fill the array with
|
||||
// zeroes. This should only be able to occur from manual ini
|
||||
// editing but we check for it anyway
|
||||
for(int ii = 0; ii < TmpIRBytes; ii++)
|
||||
{
|
||||
if(TmpIR.length() < (u32)(k + i + TmpIRBytes)) continue; // Safety check
|
||||
@ -291,7 +248,6 @@ void LoadRecordedMovements()
|
||||
Tmp.IR[ii] = (u8)TmpU32;
|
||||
}
|
||||
if (TmpIRBytes == 10) k += (10*2 + 1); else k += (12*2 + 1);
|
||||
// ---------------------
|
||||
|
||||
// Go to next set of time values
|
||||
double Time = (double)atoi(TmpTime.substr(l, 5).c_str());
|
||||
@ -301,13 +257,11 @@ void LoadRecordedMovements()
|
||||
// Save the values
|
||||
VRecording.at(i).Recording.push_back(Tmp);
|
||||
|
||||
// ---------------------------------
|
||||
// Log results
|
||||
// ---------
|
||||
/*INFO_LOG(CONSOLE, "Time:%f\n", Tmp.Time);
|
||||
/*INFO_LOG(WII_IPC_WIIMOTE, "Time:%f\n", Tmp.Time);
|
||||
std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30);
|
||||
INFO_LOG(CONSOLE, "IR: %s\n", TmpIRLog.c_str());
|
||||
INFO_LOG(CONSOLE, "\n");*/
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "IR: %s\n", TmpIRLog.c_str());
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "\n");*/
|
||||
}
|
||||
|
||||
// Get HotKey
|
||||
@ -320,24 +274,20 @@ void LoadRecordedMovements()
|
||||
int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1);
|
||||
VRecording.at(i).PlaybackSpeed = TmpPlaybackSpeed;
|
||||
|
||||
// ---------------------------------
|
||||
// Logging
|
||||
// ---------
|
||||
/*std::string TmpIRLog;
|
||||
if(TmpIRBytes > 0 && VRecording.size() > i)
|
||||
TmpIRLog = ArrayToString(VRecording.at(i).Recording.at(0).IR, TmpIRBytes, 0, 30);
|
||||
else
|
||||
TmpIRLog = "";
|
||||
|
||||
INFO_LOG(CONSOLE, "Size:%i HotKey:%i PlSpeed:%i IR:%s X:%i Y:%i Z:%i\n",
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Size:%i HotKey:%i PlSpeed:%i IR:%s X:%i Y:%i Z:%i\n",
|
||||
VRecording.at(i).Recording.size(), VRecording.at(i).HotKeyWiimote, VRecording.at(i).PlaybackSpeed,
|
||||
TmpIRLog.c_str(),
|
||||
VRecording.at(i).Recording.at(0).x, VRecording.at(i).Recording.at(0).y, VRecording.at(i).Recording.at(0).z
|
||||
);*/
|
||||
// ---------------------
|
||||
}
|
||||
}
|
||||
// ================
|
||||
|
||||
// Update the accelerometer neutral values
|
||||
void UpdateEeprom()
|
||||
@ -349,7 +299,7 @@ void UpdateEeprom()
|
||||
g_wm.cal_g.y = g_Eeprom[27] - g_Eeprom[24];
|
||||
g_wm.cal_g.z = g_Eeprom[28] - g_Eeprom[24];
|
||||
|
||||
INFO_LOG(CONSOLE, "\nUpdateEeprom: %i %i %i\n",
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "\nUpdateEeprom: %i %i %i\n",
|
||||
WiiMoteEmu::g_Eeprom[22], WiiMoteEmu::g_Eeprom[23], WiiMoteEmu::g_Eeprom[28]);
|
||||
|
||||
if(g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
||||
@ -367,7 +317,7 @@ void UpdateEeprom()
|
||||
g_nu.jy.min = g_RegExt[0x2c];
|
||||
g_nu.jy.center = g_RegExt[0x2d];
|
||||
|
||||
INFO_LOG(CONSOLE, "UpdateNunchuck: %i %i %i %i %i\n\n",
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "UpdateNunchuck: %i %i %i %i %i\n\n",
|
||||
WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d],
|
||||
WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]);
|
||||
}
|
||||
@ -390,7 +340,7 @@ void UpdateEeprom()
|
||||
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",
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "UpdateCC: %i %i %i %i %i\n\n",
|
||||
WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d],
|
||||
WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]);
|
||||
}
|
||||
@ -401,14 +351,14 @@ void UpdateEeprom()
|
||||
// Calculate checksum for the nunchuck calibration. The last two bytes.
|
||||
void ExtensionChecksum(u8 * Calibration)
|
||||
{
|
||||
u8 sum = 0; u8 Byte15, Byte16;
|
||||
for (int i = 0; i < sizeof(Calibration) - 2; i++)
|
||||
u8 sum = 0; //u8 Byte15, Byte16;
|
||||
for (u32 i = 0; i < sizeof(Calibration) - 2; i++)
|
||||
{
|
||||
sum += Calibration[i];
|
||||
printf("Plus 0x%02x\n", Calibration[i]);
|
||||
}
|
||||
Byte15 = sum + 0x55; // Byte 15
|
||||
Byte16 = sum + 0xaa; // Byte 16
|
||||
// Byte15 = sum + 0x55; // Byte 15
|
||||
// Byte16 = sum + 0xaa; // Byte 16
|
||||
}
|
||||
|
||||
// Set initial valuesm this done both in Init and Shutdown
|
||||
@ -460,15 +410,13 @@ void SetDefaultExtensionRegistry()
|
||||
memcpy(g_RegExt + 0xfa, gh3glp_id, sizeof(gh3glp_id));
|
||||
}
|
||||
|
||||
INFO_LOG(CONSOLE, "\nSetDefaultExtensionRegistry()\n\n");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "\nSetDefaultExtensionRegistry()\n\n");
|
||||
|
||||
UpdateEeprom();
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Write initial values to Eeprom and registers. */
|
||||
// ----------------
|
||||
void Initialize()
|
||||
{
|
||||
if (g_EmulatedWiiMoteInitialized) return;
|
||||
@ -476,14 +424,15 @@ void Initialize()
|
||||
// Reset variables
|
||||
ResetVariables();
|
||||
|
||||
// Write default Eeprom data to g_Eeprom[], this may be overwritten by WiiMoteReal::Initialize()
|
||||
// after this function.
|
||||
// Write default Eeprom data to g_Eeprom[], this may be overwritten by
|
||||
// WiiMoteReal::Initialize() after this function.
|
||||
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
|
||||
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
|
||||
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
|
||||
|
||||
/* Populate joyinfo for all attached devices and do g_Config.Load() if the configuration window is
|
||||
not already open, if it's already open we continue with the settings we have */
|
||||
/* Populate joyinfo for all attached devices and do g_Config.Load() if the
|
||||
configuration window is not already open, if it's already open we
|
||||
continue with the settings we have */
|
||||
if(!g_FrameOpen)
|
||||
{
|
||||
Search_Devices(joyinfo, NumPads, NumGoodPads);
|
||||
@ -498,15 +447,15 @@ void Initialize()
|
||||
// Load pre-recorded movements
|
||||
LoadRecordedMovements();
|
||||
|
||||
/* The Nuncheck extension ID for homebrew applications that use the zero key. This writes 0x0000
|
||||
in encrypted form (0xfefe) to 0xfe in the extension register. */
|
||||
/* The Nuncheck extension ID for homebrew applications that use the zero
|
||||
key. This writes 0x0000 in encrypted form (0xfefe) to 0xfe in the
|
||||
extension register. */
|
||||
//WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk
|
||||
|
||||
// I forgot what these were for? Is this the zero key encrypted 0xa420?
|
||||
// g_RegExt[0xfd] = 0x1e;
|
||||
// g_RegExt[0xfc] = 0x9a;
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
@ -542,24 +491,24 @@ void DoState(PointerWrap &p)
|
||||
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
|
||||
these variables. */
|
||||
/* This is not needed if we call FreeLibrary() when we stop a game, but if it's
|
||||
not called we need to reset these variables. */
|
||||
void Shutdown(void)
|
||||
{
|
||||
INFO_LOG(CONSOLE, "ShutDown\n");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "ShutDown\n");
|
||||
|
||||
ResetVariables();
|
||||
|
||||
/* Close all devices carefully. We must check that we are not accessing any undefined
|
||||
vector elements or any bad devices */
|
||||
/* Close all devices carefully. We must check that we are not accessing any
|
||||
undefined vector elements or any bad devices */
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID)
|
||||
if (joyinfo.at(PadMapping[i].ID).Good)
|
||||
{
|
||||
INFO_LOG(CONSOLE, "ShutDown: %i\n", PadState[i].joy);
|
||||
/* SDL_JoystickClose() crashes for some reason so I avoid this for now, SDL_Quit() should
|
||||
close the pads to I think */
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "ShutDown: %i\n", PadState[i].joy);
|
||||
/* SDL_JoystickClose() crashes for some reason so I avoid this
|
||||
for now, SDL_Quit() should close the pads to I think */
|
||||
//if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy);
|
||||
//PadState[i].joy = NULL;
|
||||
}
|
||||
@ -575,12 +524,11 @@ void Shutdown(void)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* An ack delay of 1 was not small enough, but 2 seemed to work, that was about between 20 ms and
|
||||
100 ms in my case in Zelda - TP. You may have to increase this value for other things to work, for
|
||||
example in the wpad demo I had to set it to at least 3 for the Sound to be able to turned on (I have
|
||||
an update rate of around 150 fps in the wpad demo) */
|
||||
// ----------------
|
||||
/* An ack delay of 1 was not small enough, but 2 seemed to work, that was about
|
||||
between 20 ms and 100 ms in my case in Zelda - TP. You may have to increase
|
||||
this value for other things to work, for example in the wpad demo I had to
|
||||
set it to at least 3 for the Sound to be able to turned on (I have an update
|
||||
rate of around 150 fps in the wpad demo) */
|
||||
void CreateAckDelay(u8 _ChannelID, u16 _ReportID)
|
||||
{
|
||||
// Settings
|
||||
@ -610,27 +558,24 @@ void CheckAckDelay()
|
||||
}
|
||||
AckDelay.at(i).Delay--;
|
||||
|
||||
//INFO_LOG(CONSOLE, "%i 0x%04x 0x%02x", i, AckDelay.at(i).ChannelID, AckDelay.at(i).ReportID);
|
||||
//INFO_LOG(WII_IPC_WIIMOTE, "%i 0x%04x 0x%02x", i, AckDelay.at(i).ChannelID, AckDelay.at(i).ReportID);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This function produce Wiimote Input, i.e. reports from the Wiimote in response
|
||||
to Output from the Wii. */
|
||||
// ----------------
|
||||
/* 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)
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Emu InterruptChannel\n");
|
||||
//INFO_LOG(WII_IPC_WIIMOTE, "Emu InterruptChannel\n");
|
||||
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
/* 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. */
|
||||
/* 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. */
|
||||
InterruptDebugging(true, data);
|
||||
|
||||
hid_packet* hidp = (hid_packet*) data;
|
||||
@ -645,19 +590,23 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
wm_report* sr = (wm_report*)hidp->data;
|
||||
HidOutputReport(_channelID, sr);
|
||||
|
||||
/* This is the 0x22 answer to all Inputs. In most games it didn't matter
|
||||
if it was written before or after HidOutputReport(), but Wii Sports
|
||||
and Mario Galaxy would stop working if it was placed before
|
||||
HidOutputReport(). Zelda - TP is even more sensitive and require
|
||||
a delay after the Input for the Nunchuck to work. It seemed to be
|
||||
enough to delay only the Nunchuck registry reads and writes but
|
||||
for now I'm delaying all inputs. Both for status changes and Eeprom
|
||||
and registry reads and writes. */
|
||||
/* This is the 0x22 answer to all Inputs. In most games it
|
||||
didn't matter if it was written before or after
|
||||
HidOutputReport(), but Wii Sports and Mario Galaxy would
|
||||
stop working if it was placed before
|
||||
HidOutputReport(). Zelda - TP is even more sensitive and
|
||||
require a delay after the Input for the Nunchuck to
|
||||
work. It seemed to be enough to delay only the Nunchuck
|
||||
registry reads and writes but for now I'm delaying all
|
||||
inputs. Both for status changes and Eeprom and registry
|
||||
reads and writes. */
|
||||
|
||||
// There are no 0x22 replys to these report from the real wiimote from what I could see
|
||||
// Report 0x10 that seems to be only used for rumble, and we don't need to answer that,
|
||||
// also if we do *we should update the 0x22 to have the core keys* otherwise the game will
|
||||
// think we release the key every time it rumbles
|
||||
// There are no 0x22 replys to these report from the real
|
||||
// wiimote from what I could see Report 0x10 that seems to
|
||||
// be only used for rumble, and we don't need to answer
|
||||
// that, also if we do *we should update the 0x22 to have
|
||||
// the core keys* otherwise the game will think we release
|
||||
// the key every time it rumbles
|
||||
if(!(data[1] == WM_READ_DATA && data[2] == 0x00)
|
||||
&& !(data[1] == WM_REQUEST_STATUS)
|
||||
&& !(data[1] == WM_WRITE_SPEAKER_DATA)
|
||||
@ -667,7 +616,6 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param);
|
||||
PanicAlert("HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param);
|
||||
break;
|
||||
}
|
||||
@ -675,26 +623,21 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE,"HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
|
||||
PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
}
|
||||
|
||||
|
||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Emu ControlChannel\n");
|
||||
//INFO_LOG(WII_IPC_WIIMOTE, "Emu ControlChannel\n");
|
||||
|
||||
const u8* data = (const u8*)_pData;
|
||||
// Dump raw data
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel");
|
||||
std::string Temp = ArrayToString(data, 0, _Size);
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
INFO_LOG(CONSOLE, "\n%s: ControlChannel: %s\n", Tm().c_str(), Temp.c_str());
|
||||
#endif
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Data: %s", Temp.c_str());
|
||||
}
|
||||
|
||||
@ -704,12 +647,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
case HID_TYPE_HANDSHAKE:
|
||||
if (hidp->param == HID_PARAM_INPUT)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
|
||||
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
|
||||
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
|
||||
}
|
||||
break;
|
||||
@ -717,7 +658,6 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
case HID_TYPE_SET_REPORT:
|
||||
if (hidp->param == HID_PARAM_INPUT)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_SET_REPORT input");
|
||||
PanicAlert("HID_TYPE_SET_REPORT input");
|
||||
}
|
||||
else
|
||||
@ -731,12 +671,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
break;
|
||||
|
||||
case HID_TYPE_DATA:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_DATA %s", hidp->type, hidp->param == HID_PARAM_INPUT ? "input" : "output");
|
||||
PanicAlert("HID_TYPE_DATA %s", hidp->type, hidp->param == HID_PARAM_INPUT ? "input" : "output");
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param);
|
||||
PanicAlert("HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param);
|
||||
break;
|
||||
}
|
||||
@ -744,15 +682,14 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This is called from Wiimote_Update(). See SystemTimers.cpp for a 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. */
|
||||
// ----------------
|
||||
/* This is called from Wiimote_Update(). See SystemTimers.cpp for a
|
||||
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()
|
||||
{
|
||||
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update");
|
||||
//INFO_LOG(CONSOLE, "Emu Update: %i\n", g_ReportingMode);
|
||||
//INFO_LOG(WII_IPC_WIIMOTE, "Emu Update: %i\n", g_ReportingMode);
|
||||
|
||||
// Check if the pad state should be updated
|
||||
if ((g_Config.Trigger.Type == g_Config.Trigger.TRIGGER || g_Config.Trigger.Type == g_Config.Trigger.ANALOG1 || g_Config.Trigger.Type == g_Config.Trigger.ANALOG2
|
||||
@ -781,4 +718,4 @@ void Update()
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace
|
||||
} // end of namespace
|
||||
|
Reference in New Issue
Block a user