diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 513b2332f4..149f2bd2d5 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -933,7 +933,7 @@ void ConfigDialog::UpdateGUI() has been initialized. Functions for that are basically already in place so these two options could possibly be simplified to one option. */ m_ConnectRealWiimote->Enable(!g_EmulatorRunning); - m_UseRealWiimote->Enable(g_RealWiiMotePresent && g_Config.bConnectRealWiimote); + m_UseRealWiimote->Enable(!(g_EmulatorRunning && g_RealWiiMotePresent && g_Config.bConnectRealWiimote)); // Linux has no FindItem() #ifdef _WIN32 diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index 5fa1087adc..0409225b4c 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -503,11 +503,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size) LOG(WII_IPC_WIIMOTE, " Error: 0x%x", pReply->error); LOG(WII_IPC_WIIMOTE, " Size: 0x%x", pReply->size); LOG(WII_IPC_WIIMOTE, " Address: 0x%04x", pReply->address); - /**/Console::Print(" SendReadDataReply()\n"); + /*Console::Print(" SendReadDataReply()\n"); Console::Print(" dataOffset: 0x%x\n", dataOffset); Console::Print(" copySize: 0x%x\n", copySize); Console::Print(" Size: 0x%x\n", pReply->size); - Console::Print(" Address: 0x%04x\n", Common::swap16(pReply->address)); + Console::Print(" Address: 0x%04x\n", Common::swap16(pReply->address));*/ //std::string Temp = ArrayToString(data, 0x40); //Console::Print("Eeprom: %s\n", Temp.c_str()); diff --git a/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp b/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp index 97fee94974..c96030af73 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp @@ -288,10 +288,16 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata) // ---------------- void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len) { - for(int i = 0; i < len; i++, addr++) - { - //Console::Print("data[%i] from %02x ", i, data[i]); + for(int i = 0; i < len; i++, addr++) data[i] = (data[i] - key->ft[addr%8]) ^ key->sb[addr%8]; - //Console::Print("to %02x\n", data[i]); - } } + + +// =================================================== +/* Decrypt data */ +// ---------------- +void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len) +{ + for(int i = 0; i < len; i++, addr++) + data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8]; +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_Wiimote/Src/Encryption.h b/Source/Plugins/Plugin_Wiimote/Src/Encryption.h index d94e90385e..c68ec87827 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Encryption.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Encryption.h @@ -31,6 +31,7 @@ typedef struct { void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len); +void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len); void wiimote_gen_key(wiimote_key *key, u8 *keydata); diff --git a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp index 07a0dde88a..c1bff77145 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp @@ -147,8 +147,17 @@ void handle_event(struct wiimote_t* wm) Tmp += StringFromFormat("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y); } + Tmp += "\n"; Tmp += StringFromFormat("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y); Tmp += StringFromFormat("IR z distance: %f\n", wm->ir.z); + + if(wm->exp.type == EXP_NUNCHUK) + { + Tmp += "\n"; + Tmp += StringFromFormat("Nunchuck accel x, y, z: %03i %03i %03i\n", nc->accel.x, nc->accel.y, nc->accel.z); + } + + //Tmp += "\n"; //std::string TmpData = ArrayToString(g_EventBuffer, ReportSize, 0, 30); //Tmp += "Data: " + TmpData; @@ -157,7 +166,7 @@ void handle_event(struct wiimote_t* wm) if(frame) { - // Produce adjussted accelerometer values + // Produce adjusted accelerometer values u8 AccelX = 0, AccelY = 0, AccelZ = 0; if((wm->accel.x + g_Config.iAccNunNeutralX) <= 255) AccelX = wm->accel.x + g_Config.iAccNeutralX; if((wm->accel.y + g_Config.iAccNunNeutralY) <= 255) AccelY = wm->accel.y + g_Config.iAccNeutralY; diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 9116a6140d..9299746e37 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -16,7 +16,9 @@ // http://code.google.com/p/dolphin-emu/ +////////////////////////////////////////////////////////////////////////////////////////// // Includes +// ŻŻŻŻŻŻŻŻŻŻŻŻŻ #include "Common.h" // Common #include "StringUtil.h" #include "ConsoleWindow.h" // For Start, Print, GetHwnd diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index bce50756bb..315cda82c1 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -18,14 +18,23 @@ #ifndef MAIN_H #define MAIN_H +////////////////////////////////////////////////////////////////////////////////////////// +// Includes +// ŻŻŻŻŻŻŻŻŻŻŻŻŻ #include // System +//////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////////// +// Definitions and declarations +// ŻŻŻŻŻŻŻŻŻ #ifdef _WIN32 #define sleep(x) Sleep(x) #else #define sleep(x) usleep(x*1000) #endif -// Declarations + + void DoInitialize(); double GetDoubleTime(); int GetUpdateRate(); @@ -33,6 +42,7 @@ void InterruptDebugging(bool Emu, const void* _pData); void ReadDebugging(bool Emu, const void* _pData); bool IsFocus(); + // Movement recording #define RECORDING_ROWS 15 #define WM_RECORDING_WIIMOTE 0 diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 5297b7cb5f..f6b431f316 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -16,7 +16,9 @@ // http://code.google.com/p/dolphin-emu/ +////////////////////////////////////////////////////////////////////////////////////////// // Includes +// ŻŻŻŻŻŻŻŻŻŻŻŻŻ #include // System #include "pluginspecs_wiimote.h" @@ -437,16 +439,17 @@ int Initialize() // Remove the wiiuse_poll() threshold wiiuse_set_accel_threshold(g_WiiMotesFromWiiUse[0], 0); - // Set the sensor bar position, this only affects the internal wiiuse api functions + // Set the sensor bar position, this should only affect the internal wiiuse api functions wiiuse_set_ir_position(g_WiiMotesFromWiiUse[0], WIIUSE_IR_ABOVE); - // I don't seem to need wiiuse_connect() - // Linux needs it - int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); - Console::Print("Connected: %i\n", Connect); + // I don't seem to need wiiuse_connect() in Windows. But Linux needs it. + #ifndef _WIN32 + int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); + Console::Print("Connected: %i\n", Connect); + #endif // If we are connecting from the config window without a game running we flash the lights - if (!g_EmulatorRunning) FlashLights(true); + if (!g_EmulatorRunning && g_RealWiiMotePresent) FlashLights(true); // Create Wiimote classes for (int i = 0; i < g_NumberOfWiiMotes; i++) @@ -499,7 +502,7 @@ void Shutdown(void) } // Flash flights - if (!g_EmulatorRunning) FlashLights(false); + if (!g_EmulatorRunning && g_RealWiiMotePresent) FlashLights(false); // Clean up wiiuse wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes);