Wiimote: Added decryption function, it could be useful for debugging real Wiimote extensions
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2099 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
c10d69fe07
commit
ec39c45dd5
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -289,9 +289,15 @@ 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]);
|
||||
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];
|
||||
}
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,14 +18,23 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <iostream> // 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
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <iostream> // 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);
|
||||
|
|
Loading…
Reference in New Issue