mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
just trying some stuff, please don't try to auto build it
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3375 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,356 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "EmuDefinitions.h" // for PadMapping
|
||||
#include "main.h"
|
||||
|
||||
// TODO: Figure out what to do for non-Win32
|
||||
#ifndef _WIN32
|
||||
#define VK_LEFT 0
|
||||
#define VK_RIGHT 0
|
||||
#define VK_UP 0
|
||||
#define VK_DOWN 0
|
||||
#define VK_NUMPAD4 0
|
||||
#define VK_NUMPAD6 0
|
||||
#define VK_NUMPAD8 0
|
||||
#define VK_NUMPAD5 0
|
||||
#endif
|
||||
|
||||
Config g_Config;
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
// Set all default values to zero
|
||||
memset(this, 0, sizeof(Config));
|
||||
}
|
||||
|
||||
void Config::Load(bool ChangePad)
|
||||
{
|
||||
std::string temp;
|
||||
IniFile iniFile;
|
||||
iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini");
|
||||
|
||||
// General
|
||||
iniFile.Get("Settings", "SidewaysDPad", &bSidewaysDPad, false);
|
||||
iniFile.Get("Settings", "NunchuckConnected", &bNunchuckConnected, false);
|
||||
iniFile.Get("Settings", "ClassicControllerConnected", &bClassicControllerConnected, false);
|
||||
|
||||
// Real Wiimote
|
||||
iniFile.Get("Real", "Connect", &bConnectRealWiimote, true);
|
||||
iniFile.Get("Real", "Use", &bUseRealWiimote, true);
|
||||
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
|
||||
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNeutralZ", &iAccNeutralZ, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralX", &iAccNunNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralY", &iAccNunNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralZ", &iAccNunNeutralZ, 0);
|
||||
|
||||
// Default controls
|
||||
int WmA = 65, WmB = 66,
|
||||
Wm1 = 49, Wm2 = 50,
|
||||
WmP = 80, WmM = 77, WmH = 72,
|
||||
WmL = VK_LEFT, WmR = VK_RIGHT, WmU = VK_UP, WmD = VK_DOWN, // Regular directional keys
|
||||
WmShake = 83, // S
|
||||
WmPitchL = 51, WmPitchR = 52, // 3 and 4
|
||||
|
||||
NcZ = 90, NcC = 67, // C, Z
|
||||
NcL = VK_NUMPAD4, NcR = VK_NUMPAD6, NcU = VK_NUMPAD8, NcD = VK_NUMPAD5, // Numpad
|
||||
NcShake = 68, // D
|
||||
|
||||
CcA = 90, CcB = 67, CcX = 0x58, CcY = 0x59, // C, Z, X, Y
|
||||
CcP = 0x4f, CcM = 0x4e, CcH = 0x55, // O instead of P, N instead of M, U instead of H
|
||||
CcTl = 0x37, CcZl = 0x38, CcZr = 0x39, CcTr = 0x30, // 7, 8, 9, 0
|
||||
CcDl = VK_NUMPAD4, CcDu = VK_NUMPAD8, CcDr = VK_NUMPAD6, CcDd = VK_NUMPAD5, // Numpad
|
||||
CcLl = 0x4a, CcLu = 0x49, CcLr = 0x4c, CcLd = 0x4b, // J, I, L, K
|
||||
CcRl = 0x44, CcRu = 0x52, CcRr = 0x47, CcRd = 0x46; // D, R, G, F
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
// ==================================================================
|
||||
// Slot specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
std::string SectionName = StringFromFormat("Wiimote%i", i + 1);
|
||||
iniFile.Get(SectionName.c_str(), "NoTriggerFilter", &bNoTriggerFilter, false);
|
||||
iniFile.Get(SectionName.c_str(), "TriggerType", &Trigger.Type, Trigger.TRIGGER_OFF);
|
||||
iniFile.Get(SectionName.c_str(), "TriggerRollRange", &Trigger.Range.Roll, 50);
|
||||
iniFile.Get(SectionName.c_str(), "TriggerPitchRange", &Trigger.Range.Pitch, false);
|
||||
|
||||
// Wiimote
|
||||
iniFile.Get(SectionName.c_str(), "WmA", &WiiMoteEmu::PadMapping[i].Wm.A, WmA);
|
||||
iniFile.Get(SectionName.c_str(), "WmB", &WiiMoteEmu::PadMapping[i].Wm.B, WmB);
|
||||
iniFile.Get(SectionName.c_str(), "Wm1", &WiiMoteEmu::PadMapping[i].Wm.One, Wm1);
|
||||
iniFile.Get(SectionName.c_str(), "Wm2", &WiiMoteEmu::PadMapping[i].Wm.Two, Wm2);
|
||||
iniFile.Get(SectionName.c_str(), "WmP", &WiiMoteEmu::PadMapping[i].Wm.P, WmP);
|
||||
iniFile.Get(SectionName.c_str(), "WmM", &WiiMoteEmu::PadMapping[i].Wm.M, WmM);
|
||||
iniFile.Get(SectionName.c_str(), "WmH", &WiiMoteEmu::PadMapping[i].Wm.H, WmH);
|
||||
iniFile.Get(SectionName.c_str(), "WmL", &WiiMoteEmu::PadMapping[i].Wm.L, WmL);
|
||||
iniFile.Get(SectionName.c_str(), "WmR", &WiiMoteEmu::PadMapping[i].Wm.R, WmR);
|
||||
iniFile.Get(SectionName.c_str(), "WmU", &WiiMoteEmu::PadMapping[i].Wm.U, WmU);
|
||||
iniFile.Get(SectionName.c_str(), "WmD", &WiiMoteEmu::PadMapping[i].Wm.D, WmD);
|
||||
iniFile.Get(SectionName.c_str(), "WmShake", &WiiMoteEmu::PadMapping[i].Wm.Shake, WmShake);
|
||||
iniFile.Get(SectionName.c_str(), "WmPitchL", &WiiMoteEmu::PadMapping[i].Wm.PitchL, WmPitchL);
|
||||
iniFile.Get(SectionName.c_str(), "WmPitchR", &WiiMoteEmu::PadMapping[i].Wm.PitchR, WmPitchR);
|
||||
|
||||
// Nunchuck
|
||||
iniFile.Get(SectionName.c_str(), "NunchuckStick", &Nunchuck.Type, Nunchuck.KEYBOARD);
|
||||
iniFile.Get(SectionName.c_str(), "NcZ", &WiiMoteEmu::PadMapping[i].Nc.Z, NcZ);
|
||||
iniFile.Get(SectionName.c_str(), "NcC", &WiiMoteEmu::PadMapping[i].Nc.C, NcC);
|
||||
iniFile.Get(SectionName.c_str(), "NcL", &WiiMoteEmu::PadMapping[i].Nc.L, NcL);
|
||||
iniFile.Get(SectionName.c_str(), "NcR", &WiiMoteEmu::PadMapping[i].Nc.R, NcR);
|
||||
iniFile.Get(SectionName.c_str(), "NcU", &WiiMoteEmu::PadMapping[i].Nc.U, NcU);
|
||||
iniFile.Get(SectionName.c_str(), "NcD", &WiiMoteEmu::PadMapping[i].Nc.D, NcD);
|
||||
iniFile.Get(SectionName.c_str(), "NcShake", &WiiMoteEmu::PadMapping[i].Nc.Shake, NcShake);
|
||||
|
||||
// Classic Controller
|
||||
iniFile.Get(SectionName.c_str(), "CcLeftStick", &ClassicController.LType, ClassicController.KEYBOARD);
|
||||
iniFile.Get(SectionName.c_str(), "CcRightStick", &ClassicController.RType, ClassicController.KEYBOARD);
|
||||
iniFile.Get(SectionName.c_str(), "CcTriggers", &ClassicController.TType, ClassicController.KEYBOARD);
|
||||
iniFile.Get(SectionName.c_str(), "CcA", &WiiMoteEmu::PadMapping[i].Cc.A, CcA);
|
||||
iniFile.Get(SectionName.c_str(), "CcB", &WiiMoteEmu::PadMapping[i].Cc.B, CcB);
|
||||
iniFile.Get(SectionName.c_str(), "CcX", &WiiMoteEmu::PadMapping[i].Cc.X, CcX);
|
||||
iniFile.Get(SectionName.c_str(), "CcY", &WiiMoteEmu::PadMapping[i].Cc.Y, CcY);
|
||||
iniFile.Get(SectionName.c_str(), "CcP", &WiiMoteEmu::PadMapping[i].Cc.P, CcP);
|
||||
iniFile.Get(SectionName.c_str(), "CcM", &WiiMoteEmu::PadMapping[i].Cc.M, CcM);
|
||||
iniFile.Get(SectionName.c_str(), "CcH", &WiiMoteEmu::PadMapping[i].Cc.H, CcH);
|
||||
iniFile.Get(SectionName.c_str(), "CcTl", &WiiMoteEmu::PadMapping[i].Cc.Tl, CcTl);
|
||||
iniFile.Get(SectionName.c_str(), "CcZl", &WiiMoteEmu::PadMapping[i].Cc.Zl, CcZl);
|
||||
iniFile.Get(SectionName.c_str(), "CcZr", &WiiMoteEmu::PadMapping[i].Cc.Zr, CcZr);
|
||||
iniFile.Get(SectionName.c_str(), "CcTr", &WiiMoteEmu::PadMapping[i].Cc.Tr, CcTr);
|
||||
iniFile.Get(SectionName.c_str(), "CcDl", &WiiMoteEmu::PadMapping[i].Cc.Dl, CcDl);
|
||||
iniFile.Get(SectionName.c_str(), "CcDu", &WiiMoteEmu::PadMapping[i].Cc.Du, CcDu);
|
||||
iniFile.Get(SectionName.c_str(), "CcDr", &WiiMoteEmu::PadMapping[i].Cc.Dr, CcDr);
|
||||
iniFile.Get(SectionName.c_str(), "CcDd", &WiiMoteEmu::PadMapping[i].Cc.Dd, CcDd);
|
||||
iniFile.Get(SectionName.c_str(), "CcLl", &WiiMoteEmu::PadMapping[i].Cc.Ll, CcLl);
|
||||
iniFile.Get(SectionName.c_str(), "CcLu", &WiiMoteEmu::PadMapping[i].Cc.Lu, CcLu);
|
||||
iniFile.Get(SectionName.c_str(), "CcLr", &WiiMoteEmu::PadMapping[i].Cc.Lr, CcLr);
|
||||
iniFile.Get(SectionName.c_str(), "CcLd", &WiiMoteEmu::PadMapping[i].Cc.Ld, CcLd);
|
||||
iniFile.Get(SectionName.c_str(), "CcRl", &WiiMoteEmu::PadMapping[i].Cc.Rl, CcRl);
|
||||
iniFile.Get(SectionName.c_str(), "CcRu", &WiiMoteEmu::PadMapping[i].Cc.Ru, CcRu);
|
||||
iniFile.Get(SectionName.c_str(), "CcRr", &WiiMoteEmu::PadMapping[i].Cc.Rr, CcRr);
|
||||
iniFile.Get(SectionName.c_str(), "CcRd", &WiiMoteEmu::PadMapping[i].Cc.Rd, CcRd);
|
||||
|
||||
// Don't update this when we are loading settings from the ConfigBox
|
||||
if(!ChangePad)
|
||||
{
|
||||
/* This pad Id could possibly be higher than the number of pads that are connected,
|
||||
but we check later, when needed, that that is not the case */
|
||||
iniFile.Get(SectionName.c_str(), "DeviceID", &WiiMoteEmu::PadMapping[i].ID, 0);
|
||||
iniFile.Get(SectionName.c_str(), "Enabled", &WiiMoteEmu::PadMapping[i].enabled, true);
|
||||
}
|
||||
// ===================
|
||||
|
||||
// ==================================================================
|
||||
// Joypad specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Current joypad device ID: PadMapping[i].ID
|
||||
// Current joypad name: joyinfo[PadMapping[i].ID].Name
|
||||
|
||||
/* Prevent a crash from illegal access to joyinfo that will only have values for
|
||||
the current amount of connected PadMapping */
|
||||
if((u32)WiiMoteEmu::PadMapping[i].ID >= WiiMoteEmu::joyinfo.size()) continue;
|
||||
|
||||
// Create a section name
|
||||
SectionName = WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name;
|
||||
|
||||
iniFile.Get(SectionName.c_str(), "left_x", &WiiMoteEmu::PadMapping[i].Axis.Lx, 0);
|
||||
iniFile.Get(SectionName.c_str(), "left_y", &WiiMoteEmu::PadMapping[i].Axis.Ly, 1);
|
||||
iniFile.Get(SectionName.c_str(), "right_x", &WiiMoteEmu::PadMapping[i].Axis.Rx, 2);
|
||||
iniFile.Get(SectionName.c_str(), "right_y", &WiiMoteEmu::PadMapping[i].Axis.Ry, 3);
|
||||
iniFile.Get(SectionName.c_str(), "l_trigger", &WiiMoteEmu::PadMapping[i].Axis.Tl, 1004);
|
||||
iniFile.Get(SectionName.c_str(), "r_trigger", &WiiMoteEmu::PadMapping[i].Axis.Tr, 1005);
|
||||
iniFile.Get(SectionName.c_str(), "DeadZoneL", &WiiMoteEmu::PadMapping[i].DeadZoneL, 0);
|
||||
iniFile.Get(SectionName.c_str(), "DeadZoneR", &WiiMoteEmu::PadMapping[i].DeadZoneR, 0);
|
||||
iniFile.Get(SectionName.c_str(), "TriggerType", &WiiMoteEmu::PadMapping[i].triggertype, 0);
|
||||
iniFile.Get(SectionName.c_str(), "Diagonal", &WiiMoteEmu::PadMapping[i].SDiagonal, "100%");
|
||||
iniFile.Get(SectionName.c_str(), "Circle2Square", &WiiMoteEmu::PadMapping[i].bCircle2Square, false);
|
||||
iniFile.Get(SectionName.c_str(), "RollInvert", &WiiMoteEmu::PadMapping[i].bRollInvert, false);
|
||||
iniFile.Get(SectionName.c_str(), "PitchInvert", &WiiMoteEmu::PadMapping[i].bPitchInvert, false);
|
||||
}
|
||||
// =============================
|
||||
|
||||
// ==================================================================
|
||||
// Load the IR cursor settings if it's avaliable, if not load the default settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
iniFile.Load(FULL_CONFIG_DIR "IR Pointer.ini");
|
||||
std::string TmpSection;
|
||||
if (g_ISOId) TmpSection = Hex2Ascii(g_ISOId); else TmpSection = "Default";
|
||||
iniFile.Get(TmpSection.c_str(), "IRLeft", &iIRLeft, LEFT);
|
||||
iniFile.Get(TmpSection.c_str(), "IRTop", &iIRTop, TOP);
|
||||
iniFile.Get(TmpSection.c_str(), "IRWidth", &iIRWidth, RIGHT - LEFT);
|
||||
iniFile.Get(TmpSection.c_str(), "IRHeight", &iIRHeight, BOTTOM - TOP);
|
||||
// =============================
|
||||
|
||||
// ==================================================================
|
||||
/* Load a few screen settings to. If these are added to the DirectX plugin it's probably
|
||||
better to place them in the main Dolphin.ini file */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
|
||||
iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false);
|
||||
iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false);
|
||||
iniFile.Get("Settings", "Crop", &bCrop, false);
|
||||
// =============================
|
||||
|
||||
// Logging
|
||||
INFO_LOG(CONSOLE, "Load()\n");
|
||||
}
|
||||
|
||||
void Config::Save(int Slot)
|
||||
{
|
||||
IniFile iniFile;
|
||||
iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini");
|
||||
iniFile.Set("Settings", "SidewaysDPad", bSidewaysDPad);
|
||||
iniFile.Set("Settings", "NunchuckConnected", bNunchuckConnected);
|
||||
iniFile.Set("Settings", "ClassicControllerConnected", bClassicControllerConnected);
|
||||
|
||||
iniFile.Set("Real", "Connect", bConnectRealWiimote);
|
||||
iniFile.Set("Real", "Use", bUseRealWiimote);
|
||||
iniFile.Set("Real", "UpdateStatus", bUpdateRealWiimote);
|
||||
iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
|
||||
iniFile.Set("Real", "AccNeutralY", iAccNeutralY);
|
||||
iniFile.Set("Real", "AccNeutralZ", iAccNeutralZ);
|
||||
iniFile.Set("Real", "AccNunNeutralX", iAccNunNeutralX);
|
||||
iniFile.Set("Real", "AccNunNeutralY", iAccNunNeutralY);
|
||||
iniFile.Set("Real", "AccNunNeutralZ", iAccNunNeutralZ);
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
// ==================================================================
|
||||
// Slot specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
std::string SectionName = StringFromFormat("Wiimote%i", i + 1);
|
||||
iniFile.Set(SectionName.c_str(), "Enabled", WiiMoteEmu::PadMapping[i].enabled);
|
||||
iniFile.Set(SectionName.c_str(), "NoTriggerFilter", bNoTriggerFilter);
|
||||
iniFile.Set(SectionName.c_str(), "TriggerType", Trigger.Type);
|
||||
iniFile.Set(SectionName.c_str(), "TriggerRollRange", Trigger.Range.Roll);
|
||||
iniFile.Set(SectionName.c_str(), "TriggerPitchRange", Trigger.Range.Pitch);
|
||||
|
||||
// Wiimote
|
||||
iniFile.Set(SectionName.c_str(), "WmA", WiiMoteEmu::PadMapping[i].Wm.A);
|
||||
iniFile.Set(SectionName.c_str(), "WmB", WiiMoteEmu::PadMapping[i].Wm.B);
|
||||
iniFile.Set(SectionName.c_str(), "Wm1", WiiMoteEmu::PadMapping[i].Wm.One);
|
||||
iniFile.Set(SectionName.c_str(), "Wm2", WiiMoteEmu::PadMapping[i].Wm.Two);
|
||||
iniFile.Set(SectionName.c_str(), "WmP", WiiMoteEmu::PadMapping[i].Wm.P);
|
||||
iniFile.Set(SectionName.c_str(), "WmM", WiiMoteEmu::PadMapping[i].Wm.M);
|
||||
iniFile.Set(SectionName.c_str(), "WmH", WiiMoteEmu::PadMapping[i].Wm.H);
|
||||
iniFile.Set(SectionName.c_str(), "WmL", WiiMoteEmu::PadMapping[i].Wm.L);
|
||||
iniFile.Set(SectionName.c_str(), "WmR", WiiMoteEmu::PadMapping[i].Wm.R);
|
||||
iniFile.Set(SectionName.c_str(), "WmU", WiiMoteEmu::PadMapping[i].Wm.U);
|
||||
iniFile.Set(SectionName.c_str(), "WmD", WiiMoteEmu::PadMapping[i].Wm.D);
|
||||
iniFile.Set(SectionName.c_str(), "WmShake", WiiMoteEmu::PadMapping[i].Wm.Shake);
|
||||
iniFile.Set(SectionName.c_str(), "WmPitchL", WiiMoteEmu::PadMapping[i].Wm.PitchL);
|
||||
iniFile.Set(SectionName.c_str(), "WmPitchR", WiiMoteEmu::PadMapping[i].Wm.PitchR);
|
||||
|
||||
// Nunchuck
|
||||
iniFile.Set(SectionName.c_str(), "NunchuckStick", Nunchuck.Type);
|
||||
iniFile.Set(SectionName.c_str(), "NcZ", WiiMoteEmu::PadMapping[i].Nc.Z);
|
||||
iniFile.Set(SectionName.c_str(), "NcC", WiiMoteEmu::PadMapping[i].Nc.C);
|
||||
iniFile.Set(SectionName.c_str(), "NcL", WiiMoteEmu::PadMapping[i].Nc.L);
|
||||
iniFile.Set(SectionName.c_str(), "NcR", WiiMoteEmu::PadMapping[i].Nc.R);
|
||||
iniFile.Set(SectionName.c_str(), "NcU", WiiMoteEmu::PadMapping[i].Nc.U);
|
||||
iniFile.Set(SectionName.c_str(), "NcD", WiiMoteEmu::PadMapping[i].Nc.D);
|
||||
iniFile.Set(SectionName.c_str(), "NcShake", WiiMoteEmu::PadMapping[i].Nc.Shake);
|
||||
|
||||
// Classic Controller
|
||||
iniFile.Set(SectionName.c_str(), "CcLeftStick", ClassicController.LType);
|
||||
iniFile.Set(SectionName.c_str(), "CcRightStick", ClassicController.RType);
|
||||
iniFile.Set(SectionName.c_str(), "CcTriggers", ClassicController.TType);
|
||||
iniFile.Set(SectionName.c_str(), "CcA", WiiMoteEmu::PadMapping[i].Cc.A);
|
||||
iniFile.Set(SectionName.c_str(), "CcB", WiiMoteEmu::PadMapping[i].Cc.B);
|
||||
iniFile.Set(SectionName.c_str(), "CcX", WiiMoteEmu::PadMapping[i].Cc.X);
|
||||
iniFile.Set(SectionName.c_str(), "CcY", WiiMoteEmu::PadMapping[i].Cc.Y);
|
||||
iniFile.Set(SectionName.c_str(), "CcP", WiiMoteEmu::PadMapping[i].Cc.P);
|
||||
iniFile.Set(SectionName.c_str(), "CcM", WiiMoteEmu::PadMapping[i].Cc.M);
|
||||
iniFile.Set(SectionName.c_str(), "CcH", WiiMoteEmu::PadMapping[i].Cc.H);
|
||||
iniFile.Set(SectionName.c_str(), "CcTl", WiiMoteEmu::PadMapping[i].Cc.Tl);
|
||||
iniFile.Set(SectionName.c_str(), "CcZl", WiiMoteEmu::PadMapping[i].Cc.Zl);
|
||||
iniFile.Set(SectionName.c_str(), "CcZr", WiiMoteEmu::PadMapping[i].Cc.Zr);
|
||||
iniFile.Set(SectionName.c_str(), "CcTr", WiiMoteEmu::PadMapping[i].Cc.Tr);
|
||||
iniFile.Set(SectionName.c_str(), "CcDl", WiiMoteEmu::PadMapping[i].Cc.Dl);
|
||||
iniFile.Set(SectionName.c_str(), "CcDu", WiiMoteEmu::PadMapping[i].Cc.Du);
|
||||
iniFile.Set(SectionName.c_str(), "CcDr", WiiMoteEmu::PadMapping[i].Cc.Dr);
|
||||
iniFile.Set(SectionName.c_str(), "CcDd", WiiMoteEmu::PadMapping[i].Cc.Dd);
|
||||
iniFile.Set(SectionName.c_str(), "CcLl", WiiMoteEmu::PadMapping[i].Cc.Ll);
|
||||
iniFile.Set(SectionName.c_str(), "CcLu", WiiMoteEmu::PadMapping[i].Cc.Lu);
|
||||
iniFile.Set(SectionName.c_str(), "CcLr", WiiMoteEmu::PadMapping[i].Cc.Lr);
|
||||
iniFile.Set(SectionName.c_str(), "CcLd", WiiMoteEmu::PadMapping[i].Cc.Ld);
|
||||
iniFile.Set(SectionName.c_str(), "CcRl", WiiMoteEmu::PadMapping[i].Cc.Rl);
|
||||
iniFile.Set(SectionName.c_str(), "CcRu", WiiMoteEmu::PadMapping[i].Cc.Ru);
|
||||
iniFile.Set(SectionName.c_str(), "CcRr", WiiMoteEmu::PadMapping[i].Cc.Rr);
|
||||
iniFile.Set(SectionName.c_str(), "CcRd", WiiMoteEmu::PadMapping[i].Cc.Rd);
|
||||
|
||||
// Save the physical device ID number
|
||||
iniFile.Set(SectionName.c_str(), "DeviceID", WiiMoteEmu::PadMapping[i].ID);
|
||||
// ===================
|
||||
|
||||
// ==================================================================
|
||||
// Joypad specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Current joypad device ID: PadMapping[i].ID
|
||||
// Current joypad name: joyinfo[PadMapping[i].ID].Name
|
||||
|
||||
/* Save joypad specific settings. Check for "PadMapping[i].ID < SDL_NumJoysticks()" to
|
||||
avoid reading a joyinfo that does't exist */
|
||||
if((u32)WiiMoteEmu::PadMapping[i].ID >= WiiMoteEmu::joyinfo.size()) continue;
|
||||
|
||||
// Create a new section name after the joypad name
|
||||
SectionName = WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name;
|
||||
|
||||
iniFile.Set(SectionName.c_str(), "left_x", WiiMoteEmu::PadMapping[i].Axis.Lx);
|
||||
iniFile.Set(SectionName.c_str(), "left_y", WiiMoteEmu::PadMapping[i].Axis.Ly);
|
||||
iniFile.Set(SectionName.c_str(), "right_x", WiiMoteEmu::PadMapping[i].Axis.Rx);
|
||||
iniFile.Set(SectionName.c_str(), "right_y", WiiMoteEmu::PadMapping[i].Axis.Ry);
|
||||
iniFile.Set(SectionName.c_str(), "l_trigger", WiiMoteEmu::PadMapping[i].Axis.Tl);
|
||||
iniFile.Set(SectionName.c_str(), "r_trigger", WiiMoteEmu::PadMapping[i].Axis.Tr);
|
||||
|
||||
iniFile.Set(SectionName.c_str(), "DeadZoneL", WiiMoteEmu::PadMapping[i].DeadZoneL);
|
||||
iniFile.Set(SectionName.c_str(), "DeadZoneR", WiiMoteEmu::PadMapping[i].DeadZoneR);
|
||||
//iniFile.Set(SectionName.c_str(), "controllertype", WiiMoteEmu::PadMapping[i].controllertype);
|
||||
iniFile.Set(SectionName.c_str(), "TriggerType", WiiMoteEmu::PadMapping[i].triggertype);
|
||||
iniFile.Set(SectionName.c_str(), "Diagonal", WiiMoteEmu::PadMapping[i].SDiagonal);
|
||||
iniFile.Set(SectionName.c_str(), "Circle2Square", WiiMoteEmu::PadMapping[i].bCircle2Square);
|
||||
iniFile.Set(SectionName.c_str(), "RollInvert", WiiMoteEmu::PadMapping[i].bRollInvert);
|
||||
iniFile.Set(SectionName.c_str(), "PitchInvert", WiiMoteEmu::PadMapping[i].bPitchInvert);
|
||||
// ======================================
|
||||
}
|
||||
|
||||
iniFile.Save(FULL_CONFIG_DIR "Wiimote.ini");
|
||||
|
||||
// ==================================================================
|
||||
// Save the IR cursor settings if it's avaliable, if not save the default settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
iniFile.Load(FULL_CONFIG_DIR "IR Pointer.ini");
|
||||
std::string TmpSection;
|
||||
if (g_ISOId) TmpSection = Hex2Ascii(g_ISOId); else TmpSection = "Default";
|
||||
iniFile.Set(TmpSection.c_str(), "IRLeft", iIRLeft);
|
||||
iniFile.Set(TmpSection.c_str(), "IRTop", iIRTop);
|
||||
iniFile.Set(TmpSection.c_str(), "IRWidth", iIRWidth);
|
||||
iniFile.Set(TmpSection.c_str(), "IRHeight", iIRHeight);
|
||||
iniFile.Save(FULL_CONFIG_DIR "IR Pointer.ini");
|
||||
// =============================
|
||||
|
||||
// Logging
|
||||
INFO_LOG(CONSOLE, "Save()\n");
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _PLUGIN_WIIMOTE_CONFIG_H
|
||||
#define _PLUGIN_WIIMOTE_CONFIG_H
|
||||
|
||||
|
||||
struct Config
|
||||
{
|
||||
Config();
|
||||
void Load(bool ChangePad = false);
|
||||
void Save(int Slot = -1);
|
||||
|
||||
struct PadRange
|
||||
{
|
||||
int Roll;
|
||||
int Pitch;
|
||||
};
|
||||
|
||||
struct PadTrigger
|
||||
{
|
||||
enum ETriggerType
|
||||
{
|
||||
TRIGGER_OFF = 0,
|
||||
KEYBOARD,
|
||||
ANALOG1,
|
||||
ANALOG2,
|
||||
TRIGGER
|
||||
};
|
||||
int Type;
|
||||
PadRange Range;
|
||||
};
|
||||
struct PadNunchuck
|
||||
{
|
||||
enum ENunchuckStick
|
||||
{
|
||||
KEYBOARD,
|
||||
ANALOG1,
|
||||
ANALOG2
|
||||
};
|
||||
int Type;
|
||||
};
|
||||
struct PadClassicController
|
||||
{
|
||||
enum ECcStick
|
||||
{
|
||||
KEYBOARD,
|
||||
ANALOG1,
|
||||
ANALOG2,
|
||||
TRIGGER
|
||||
};
|
||||
int LType;
|
||||
int RType;
|
||||
int TType;
|
||||
};
|
||||
|
||||
// Emulated Wiimote
|
||||
bool bSidewaysDPad;
|
||||
bool bWideScreen;
|
||||
bool bNunchuckConnected, bClassicControllerConnected;
|
||||
|
||||
// Real Wiimote
|
||||
bool bConnectRealWiimote, bUseRealWiimote, bUpdateRealWiimote;
|
||||
int iIRLeft, iIRTop, iIRWidth, iIRHeight;
|
||||
int iAccNeutralX, iAccNeutralY, iAccNeutralZ;
|
||||
int iAccNunNeutralX, iAccNunNeutralY, iAccNunNeutralZ;
|
||||
|
||||
// Gamepad
|
||||
bool bNoTriggerFilter;
|
||||
PadTrigger Trigger;
|
||||
PadNunchuck Nunchuck;
|
||||
PadClassicController ClassicController;
|
||||
|
||||
// Screen size settings
|
||||
bool bKeepAR43, bKeepAR169, bCrop;
|
||||
};
|
||||
|
||||
extern Config g_Config;
|
||||
|
||||
#endif // _PLUGIN_WIIMOTE_CONFIG_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,275 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef __CONFIGDIALOG_h__
|
||||
#define __CONFIGDIALOG_h__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/progdlg.h>
|
||||
|
||||
class ConfigDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ConfigDialog(wxWindow *parent, wxWindowID id = 1,
|
||||
const wxString &title = wxT("Wii Remote Plugin Configuration"),
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
|
||||
virtual ~ConfigDialog();
|
||||
|
||||
// General open, close and event functions
|
||||
void CloseClick(wxCommandEvent& event);
|
||||
void UpdateGUI(int Slot = 0); void UpdateGUIButtonMapping(int controller); void UpdateControls();
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void LoadFile(); void SaveFile();
|
||||
|
||||
// Timers
|
||||
wxTimer *m_TimeoutTimer, *m_ShutDownTimer, *m_TimeoutOnce, *m_ButtonMappingTimer, *m_UpdatePad;
|
||||
|
||||
// General status
|
||||
wxStaticText * m_TextUpdateRate;
|
||||
|
||||
// Wiimote status
|
||||
wxGauge *m_GaugeBattery, *m_GaugeRoll[2], *m_GaugeGForce[3], *m_GaugeAccel[3];
|
||||
wxStaticBitmap *m_bmpDotLeftIn[4], *m_bmpDotLeftOut[4], *m_bmpDotRightIn[4], *m_bmpDotRightOut[4],
|
||||
*m_bmpDeadZoneLeftIn[4], *m_bmpDeadZoneRightIn[4];
|
||||
wxStaticText *m_TextIR;
|
||||
bool m_bWaitForRecording, m_bRecording, m_bAllowA;
|
||||
int m_iRecordTo;
|
||||
void RecordMovement(wxCommandEvent& event);
|
||||
void DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int IRBytes);
|
||||
void DoRecordA(bool Pressed);
|
||||
void Convert2Box(int &x);
|
||||
void ConvertToString();
|
||||
void Update(wxTimerEvent& WXUNUSED(event));
|
||||
void ShutDown(wxTimerEvent& WXUNUSED(event));
|
||||
void UpdateOnce(wxTimerEvent& event);
|
||||
|
||||
// Gamepad configuration
|
||||
void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
|
||||
void UpdatePad(wxTimerEvent& WXUNUSED(event));
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
bool ControlsCreated, m_bEnableUseRealWiimote; int Page, BoxW, BoxH, g_Pressed;
|
||||
|
||||
wxNotebook *m_Notebook;
|
||||
wxPanel *m_Controller[4], *m_PageRecording;
|
||||
wxButton *m_About, *m_Close, *m_Apply;
|
||||
wxBoxSizer *m_MainSizer, *m_sMain[4], *m_SizeParent[4], *m_sRecordingMain;
|
||||
|
||||
// Emulated Wiimote key settings
|
||||
wxBoxSizer *m_SizerIRPointerWidth[4], *m_SizerIRPointerHeight[4], *m_SizerIRPointerScreen[4],
|
||||
*m_SizeBasicPadding[4], *m_SizeEmuPadding[4], *m_SizeRealPadding[4], *m_SizeExtensionsPadding[4],
|
||||
*m_SizeBasicGeneral[4], *m_SizeBasicGeneralLeft[4], *m_SizeBasicGeneralRight[4],
|
||||
*m_HorizControllers[4], *m_gC2SDeadZone[4], *m_gCircle2Square[4], *m_gCircle2SquareVert[4], *m_gDeadZone[4], *m_gDeadZoneHoriz[4], *m_HorizControllerTiltParent[4], *m_HorizControllerTilt[4], *m_TiltHoriz[4],
|
||||
*m_SizeAnalogLeft[4], *m_SizeAnalogLeftHorizX[4], *m_SizeAnalogLeftHorizY[4], *m_SizeAnalogRight[4], *m_SizeAnalogRightHorizX[4], *m_SizeAnalogRightHorizY[4],
|
||||
*m_SizeAnalogTriggerVertLeft[4], *m_SizeAnalogTriggerVertRight[4], *m_SizeAnalogTriggerHorizInput[4],
|
||||
// Nunchuck
|
||||
*m_SNcShake[4], *m_SNcZ[4], *m_SNcC[4], *m_SNcL[4], *m_SNcR[4], *m_SNcU[4], *m_SNcD[4],
|
||||
// Wiimote
|
||||
*m_SWmVertLeft[4], *m_SWmVertRight[4], *m_SWmShake[4], *m_SWmPitchL[4], *m_SWmPitchR[4], *m_SWmA[4], *m_SWmB[4], *m_SWm1[4], *m_SWm2[4], *m_SWmP[4], *m_SWmM[4], *m_SWmH[4], *m_SWmL[4], *m_SWmR[4], *m_SWmU[4], *m_SWmD[4],
|
||||
*m_HorizControllerMapping[4], *m_NunchuckStick[4],
|
||||
// Classic Controller
|
||||
*m_SCcVertLeft[4], *m_SCcVertMiddle[4], *m_SCcVertRight[4],
|
||||
*m_SCcLeftStick[4], *m_SCcRightStick[4], *m_SCcTriggers[4],
|
||||
*m_SCcA[4], *m_SCcB[4], *m_SCcX[4], *m_SCcY[4],
|
||||
*m_SCcP[4], *m_SCcM[4], *m_SCcH[4],
|
||||
*m_SCcTl[4], *m_SCcZl[4], *m_SCcZr[4], *m_SCcTr[4],
|
||||
*m_SCcDl[4], *m_SCcDu[4], *m_SCcDr[4], *m_SCcDd[4],
|
||||
*m_SCcLl[4], *m_SCcLu[4], *m_SCcLr[4], *m_SCcLd[4],
|
||||
*m_SCcRl[4], *m_SCcRu[4], *m_SCcRr[4], *m_SCcRd[4];
|
||||
wxGridBagSizer *m_SizeAnalogTriggerHorizConfig[4], *m_SizeAnalogTriggerStatusBox[4], *m_TiltGrid[4],
|
||||
*m_GridLeftStick[4], *m_GridRightStick[4];
|
||||
wxStaticBoxSizer *m_SizeBasic[4], *m_SizeEmu[4], *m_SizeReal[4], *m_SizeExtensions[4], *m_SizerIRPointer[4], *m_gTilt[4], *m_gJoyname[4];
|
||||
wxTextCtrl *m_AnalogLeftX[4], *m_AnalogLeftY[4], *m_AnalogRightX[4], *m_AnalogRightY[4],
|
||||
*m_AnalogTriggerL[4], *m_AnalogTriggerR[4];
|
||||
wxButton *m_bAnalogLeftX[4], *m_bAnalogLeftY[4], *m_bAnalogRightX[4], *m_bAnalogRightY[4],
|
||||
*m_bAnalogTriggerL[4], *m_bAnalogTriggerR[4],
|
||||
// Nunchuck
|
||||
*m_bNcShake[4], *m_bNcZ[4], *m_bNcC[4], *m_bNcL[4], *m_bNcR[4], *m_bNcU[4], *m_bNcD[4],
|
||||
// Wiimote
|
||||
*m_bWmShake[4], *m_bWmPitchL[4], *m_bWmPitchR[4], *m_bWmA[4], *m_bWmB[4], *m_bWm1[4], *m_bWm2[4], *m_bWmP[4], *m_bWmM[4], *m_bWmH[4], *m_bWmD[4], *m_bWmU[4], *m_bWmR[4], *m_bWmL[4],
|
||||
// Classic Controller
|
||||
*m_bCcA[4], *m_bCcB[4], *m_bCcX[4], *m_bCcY[4],
|
||||
*m_bCcP[4], *m_bCcM[4], *m_bCcH[4],
|
||||
*m_bCcTl[4], *m_bCcZl[4], *m_bCcZr[4], *m_bCcTr[4],
|
||||
*m_bCcDl[4], *m_bCcDu[4], *m_bCcDr[4], *m_bCcDd[4],
|
||||
*m_bCcLl[4], *m_bCcLu[4], *m_bCcLr[4], *m_bCcLd[4],
|
||||
*m_bCcRl[4], *m_bCcRu[4], *m_bCcRr[4], *m_bCcRd[4];
|
||||
wxStaticText *m_TextScreenWidth[4], *m_TextScreenHeight[4], *m_TextScreenLeft[4], *m_TextScreenTop[4], *m_TextAR[4],
|
||||
*m_tAnalogX[8], *m_tAnalogY[8], *m_TiltTextRoll[4], *m_TiltTextPitch[4],
|
||||
*m_CheckC2SLabel[4], *m_ComboDeadZoneLabel[4], *m_TStatusLeftIn[4], *m_TStatusLeftOut[4], *m_TStatusRightIn[4], *m_TStatusRightOut[4],
|
||||
*m_TriggerStatusL[4], *m_TriggerStatusR[4], *m_TriggerStatusLx[4], *m_TriggerStatusRx[4],
|
||||
*m_tAnalogTriggerInput[4], *m_tAnalogTriggerL[4], *m_tAnalogTriggerR[4],
|
||||
// Nunchuck
|
||||
*m_tNcShake[4], *m_tNcZ[4], *m_tNcC[4], *m_tNcL[4], *m_tNcR[4], *m_tNcU[4], *m_tNcD[4],
|
||||
// Wiimote
|
||||
*m_tWmShake[4], *m_tWmPitchL[4], *m_tWmPitchR[4], *m_tWmA[4], *m_tWmB[4], *m_tWm1[4], *m_tWm2[4], *m_tWmP[4], *m_tWmM[4], *m_tWmH[4], *m_tWmL[4], *m_tWmR[4], *m_tWmU[4],*m_tWmD[4],
|
||||
*m_NunchuckTextStick[5],
|
||||
// Classic Controller
|
||||
*m_tCcA[4], *m_tCcB[4], *m_tCcX[4], *m_tCcY[4],
|
||||
*m_tCcP[4], *m_tCcM[4], *m_tCcH[4],
|
||||
*m_tCcTl[4], *m_tCcZl[4], *m_tCcZr[4], *m_tCcTr[4],
|
||||
*m_tCcDl[4], *m_tCcDu[4], *m_tCcDr[4], *m_tCcDd[4],
|
||||
*m_tCcLl[4], *m_tCcLu[4], *m_tCcLr[4], *m_tCcLd[4],
|
||||
*m_tCcRl[4], *m_tCcRu[4], *m_tCcRr[4], *m_tCcRd[4],
|
||||
*m_CcTextLeftStick[4], *m_CcTextRightStick[4], *m_CcTextTriggers[4];
|
||||
wxButton *ClickedButton;
|
||||
wxString OldLabel;
|
||||
wxSlider *m_SliderWidth[4], *m_SliderHeight[4], *m_SliderLeft[4], *m_SliderTop[4];
|
||||
|
||||
// Emulated Wiimote settings
|
||||
wxCheckBox *m_SidewaysDPad[4], *m_WiimoteOnline[4],
|
||||
*m_CheckC2S[4], *m_TiltInvertRoll[4], *m_TiltInvertPitch[4],
|
||||
*m_WiiMotionPlusConnected[4], *m_NunchuckConnected[4], *m_ClassicControllerConnected[4], *m_BalanceBoardConnected[4], *m_GuitarHeroGuitarConnected[4], *m_GuitarHeroWorldTourDrumsConnected[4],
|
||||
*m_CheckAR43[4], *m_CheckAR169[4], *m_Crop[4];
|
||||
wxComboBox *m_TiltComboInput[4], *m_TiltComboRangeRoll[4], *m_TiltComboRangePitch[4], *m_Joyname[4], *m_ComboDiagonal[4], *m_ComboDeadZoneLeft[4], *m_ComboDeadZoneRight[4], *m_TriggerType[4],
|
||||
*m_NunchuckComboStick[4], *m_CcComboLeftStick[4], *m_CcComboRightStick[4], *m_CcComboTriggers[4];
|
||||
|
||||
// Real Wiimote settings
|
||||
wxCheckBox *m_ConnectRealWiimote[4], *m_UseRealWiimote[4], *m_UpdateMeters;
|
||||
|
||||
wxPanel *m_pLeftInStatus[4], *m_pLeftOutStatus[4], *m_pRightInStatus[4], *m_pRightOutStatus[4];
|
||||
wxStaticBitmap *m_bmpSquareLeftIn[4], *m_bmpSquareLeftOut[4], *m_bmpSquareRightIn[4], *m_bmpSquareRightOut[4];
|
||||
wxStaticBoxSizer *m_gAnalogLeft[4], *m_gAnalogRight[4], *m_gTrigger[4],
|
||||
*m_gWiimote[4], *m_gNunchuck[4], *m_gClassicController[4];
|
||||
wxBitmap CreateBitmapDot(), CreateBitmap(), CreateBitmapDeadZone(int Radius), CreateBitmapClear();
|
||||
|
||||
wxButton * m_RecordButton[RECORDING_ROWS + 1];
|
||||
wxChoice * m_RecordHotKeySwitch[RECORDING_ROWS + 1];
|
||||
wxChoice * m_RecordHotKeyWiimote[RECORDING_ROWS + 1];
|
||||
wxChoice * m_RecordHotKeyNunchuck[RECORDING_ROWS + 1];
|
||||
wxChoice * m_RecordHotKeyIR[RECORDING_ROWS + 1];
|
||||
wxTextCtrl * m_RecordText[RECORDING_ROWS + 1];
|
||||
wxTextCtrl * m_RecordGameText[RECORDING_ROWS + 1];
|
||||
wxTextCtrl * m_RecordIRBytesText[RECORDING_ROWS + 1];
|
||||
wxTextCtrl * m_RecordSpeed[RECORDING_ROWS + 1];
|
||||
wxChoice * m_RecordPlayBackSpeed[RECORDING_ROWS + 1];
|
||||
|
||||
/*
|
||||
struct m_sRecording
|
||||
{
|
||||
u8 x;
|
||||
u8 y;
|
||||
u8 z;
|
||||
double Time;
|
||||
};
|
||||
*/
|
||||
std::vector<SRecording> m_vRecording;
|
||||
int IRBytes;
|
||||
|
||||
enum
|
||||
{
|
||||
ID_CLOSE = 1000,
|
||||
ID_APPLY,
|
||||
ID_ABOUTOGL,
|
||||
IDTM_EXIT, IDTM_UPDATE, IDTM_SHUTDOWN, IDTM_UPDATE_ONCE, IDTM_BUTTON, IDTM_UPDATE_PAD, // Timer
|
||||
|
||||
ID_NOTEBOOK, ID_CONTROLLERPAGE1, ID_CONTROLLERPAGE2, ID_CONTROLLERPAGE3, ID_CONTROLLERPAGE4, ID_PAGE_RECORDING,
|
||||
|
||||
// Emulated Wiimote
|
||||
ID_SIDEWAYSDPAD,
|
||||
ID_NUNCHUCKCONNECTED, ID_CLASSICCONTROLLERCONNECTED,
|
||||
IDC_WIMOTE_ON,
|
||||
|
||||
// Gamepad <It's important that the internal ordering of these are unchanged>
|
||||
IDB_ANALOG_LEFT_X, IDB_ANALOG_LEFT_Y,
|
||||
IDB_ANALOG_RIGHT_X, IDB_ANALOG_RIGHT_Y,
|
||||
IDB_TRIGGER_L, IDB_TRIGGER_R,
|
||||
|
||||
ID_ANALOG_LEFT_X, ID_ANALOG_LEFT_Y,
|
||||
ID_ANALOG_RIGHT_X, ID_ANALOG_RIGHT_Y,
|
||||
ID_TRIGGER_L, ID_TRIGGER_R,
|
||||
|
||||
// Wiimote
|
||||
IDS_WIDTH, IDS_HEIGHT, IDS_LEFT, IDS_TOP,
|
||||
IDB_WM_A, IDB_WM_B,
|
||||
IDB_WM_1, IDB_WM_2,
|
||||
IDB_WM_P, IDB_WM_M, IDB_WM_H,
|
||||
IDB_WM_L, IDB_WM_R, IDB_WM_U, IDB_WM_D,
|
||||
IDB_WM_SHAKE, IDB_WM_PITCH_L, IDB_WM_PITCH_R,
|
||||
|
||||
// Nunchuck
|
||||
IDB_NC_Z, IDB_NC_C, IDB_NC_L, IDB_NC_R, IDB_NC_U, IDB_NC_D,
|
||||
IDB_NC_SHAKE,
|
||||
|
||||
// Classic Controller
|
||||
IDB_CC_A, IDB_CC_B,
|
||||
IDB_CC_X, IDB_CC_Y,
|
||||
IDB_CC_P, IDB_CC_M, IDB_CC_H,
|
||||
IDB_CC_TL, IDB_CC_ZL, IDB_CC_ZR, IDB_CC_TR,
|
||||
IDB_CC_DL, IDB_CC_DU, IDB_CC_DR, IDB_CC_DD, // Digital pad
|
||||
IDB_CC_LL, IDB_CC_LU, IDB_CC_LR, IDB_CC_LD, // Left analog stick
|
||||
IDB_CC_RL, IDB_CC_RU, IDB_CC_RR, IDB_CC_RD, // Right analog stick
|
||||
|
||||
// Gamepad settings
|
||||
IDC_JOYNAME, IDC_LEFT_C2S, IDCB_LEFT_DIAGONAL, IDCB_DEAD_ZONE_LEFT, IDCB_DEAD_ZONE_RIGHT,
|
||||
ID_TRIGGER_TYPE, ID_TILT_INPUT, ID_TILT_RANGE_ROLL, ID_TILT_RANGE_PITCH, ID_TILT_INVERT_ROLL, ID_TILT_INVERT_PITCH,
|
||||
IDCB_NUNCHUCK_STICK, IDCB_CC_LEFT_STICK, IDCB_CC_RIGHT_STICK, IDCB_CC_TRIGGERS,
|
||||
|
||||
// Real
|
||||
ID_CONNECT_REAL, ID_USE_REAL, ID_UPDATE_REAL, IDT_STATUS,
|
||||
IDB_RECORD = 2000,
|
||||
IDC_RECORD = 3000,
|
||||
IDC_PLAY_WIIMOTE, IDC_PLAY_NUNCHUCK, IDC_PLAY_IR, IDT_RECORD_TEXT, IDT_RECORD_GAMETEXT, IDT_RECORD_IRBYTESTEXT, IDT_RECORD_SPEED, IDT_RECORD_PLAYSPEED
|
||||
};
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls();
|
||||
void CreateGUIControlsRecording();
|
||||
void AboutClick(wxCommandEvent& event);
|
||||
void GeneralSettingsChanged(wxCommandEvent& event);
|
||||
void GeneralSettingsChangedScroll(wxScrollEvent& event);
|
||||
|
||||
void DoConnectReal(); // Real
|
||||
void DoUseReal();
|
||||
|
||||
void DoExtensionConnectedDisconnected(int Extension = -1); // Emulated
|
||||
|
||||
// Gamepad configuration
|
||||
void SetButtonText(int id, char text[128], int _Page = -1); void SetButtonTextAll(int id, char text[128]);
|
||||
wxString GetButtonText(int id, int Page = -1);
|
||||
void GetButtons(wxCommandEvent& event); void DoGetButtons(int);
|
||||
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1); void SaveButtonMappingAll(int Slot);
|
||||
void SaveKeyboardMapping(int Controller, int Id, int Key);
|
||||
void ToBlank(bool ToBlank = true);
|
||||
void PadGetStatus();
|
||||
void DoSave(bool ChangePad = false, int Slot = -1);
|
||||
void DoChangeJoystick(); void PadOpen(int Open); void PadClose(int Close); void DoChangeDeadZone(bool Left);
|
||||
void OnButtonClick(wxCommandEvent& event);
|
||||
|
||||
// Configure buttons
|
||||
int GetButtonWaitingID, GetButtonWaitingTimer;
|
||||
};
|
||||
|
||||
extern ConfigDialog *frame;
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,301 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Data reports guide. The different structures location in the Input reports. The ? in
|
||||
the IR coordinates is the High coordinates that are four in one byte.
|
||||
|
||||
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the end (represented)
|
||||
by "..." below, it seems like they can be set to either 0xff or 0x00 without affecting the
|
||||
IR emulation. */
|
||||
// ----------------
|
||||
|
||||
/* 0x33
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y ?
|
||||
|
||||
0x37
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2 ... ext.jx jy ax ay az bt
|
||||
|
||||
|
||||
The Data Report's path from here is
|
||||
WII_IPC_HLE_WiiMote.cpp:
|
||||
Callback_WiimoteInput()
|
||||
CWII_IPC_HLE_WiiMote::SendL2capData()
|
||||
WII_IPC_HLE_Device_usb.cpp:
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame()
|
||||
at that point the message is queued and will be sent by the next
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() */
|
||||
|
||||
// ================
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "StringUtil.h" // for ArrayToString
|
||||
|
||||
#include "wiimote_hid.h" // Local
|
||||
#include "main.h"
|
||||
#include "EmuMain.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
//******************************************************************************
|
||||
// Subroutines
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Update the data reporting mode */
|
||||
// ----------------
|
||||
void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Set Data reporting mode");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " All The Time: %x (not only on data change)", dr->all_the_time);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Mode: 0x%02x", dr->mode);
|
||||
INFO_LOG(CONSOLE, "Data reporting:\n");
|
||||
INFO_LOG(CONSOLE, " Continuous: %x\n", dr->continuous);
|
||||
INFO_LOG(CONSOLE, " All The Time: %x (not only on data change)\n", dr->all_the_time);
|
||||
INFO_LOG(CONSOLE, " Mode: 0x%02x\n", dr->mode);
|
||||
INFO_LOG(CONSOLE, " Channel: 0x%04x\n", _channelID);
|
||||
|
||||
g_ReportingMode = dr->mode;
|
||||
g_ReportingChannel = _channelID;
|
||||
switch(dr->mode) // See Wiimote_Update()
|
||||
{
|
||||
case WM_REPORT_CORE:
|
||||
case WM_REPORT_CORE_ACCEL:
|
||||
case WM_REPORT_CORE_ACCEL_IR12:
|
||||
case WM_REPORT_CORE_ACCEL_EXT16:
|
||||
case WM_REPORT_CORE_ACCEL_IR10_EXT6:
|
||||
break;
|
||||
default:
|
||||
PanicAlert("Wiimote: Unsupported reporting mode 0x%x", dr->mode);
|
||||
}
|
||||
|
||||
// WmSendAck(_channelID, WM_DATA_REPORTING);
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x30: Core Buttons */
|
||||
// ----------------
|
||||
void SendReportCore(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE);
|
||||
|
||||
wm_report_core* pReport = (wm_report_core*)(DataFrame + Offset);
|
||||
Offset += sizeof(wm_report_core);
|
||||
memset(pReport, 0, sizeof(wm_report_core));
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pReport->c);
|
||||
#endif
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendReportCore()");
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* 0x31: Core Buttons and Accelerometer */
|
||||
// ----------------
|
||||
void SendReportCoreAccel(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL);
|
||||
|
||||
wm_report_core_accel* pReport = (wm_report_core_accel*)(DataFrame + Offset);
|
||||
Offset += sizeof(wm_report_core_accel);
|
||||
memset(pReport, 0, sizeof(wm_report_core_accel));
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pReport->c);
|
||||
FillReportAcc(pReport->a);
|
||||
#endif
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendReportCoreAccel (0x31)");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Channel: %04x", _channelID);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Offset: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12);
|
||||
|
||||
wm_report_core_accel_ir12* pReport = (wm_report_core_accel_ir12*)(DataFrame + Offset);
|
||||
Offset += sizeof(wm_report_core_accel_ir12);
|
||||
memset(pReport, 0, sizeof(wm_report_core_accel_ir12));
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pReport->c);
|
||||
FillReportAcc(pReport->a);
|
||||
|
||||
// We settle with emulating two objects, not all four. We leave object 2 and 3 with 0xff.
|
||||
FillReportIR(pReport->ir[0], pReport->ir[1]);
|
||||
#endif
|
||||
memset(&pReport->ir[2], 0xff, sizeof(wm_ir_extended));
|
||||
memset(&pReport->ir[3], 0xff, sizeof(wm_ir_extended));
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendReportCoreAccelIr12()");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Offset: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelExt16(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_EXT16);
|
||||
|
||||
wm_report_core_accel_ext16* pReport = (wm_report_core_accel_ext16*)(DataFrame + Offset);
|
||||
Offset += sizeof(wm_report_core_accel_ext16);
|
||||
memset(pReport, 0, sizeof(wm_report_core_accel_ext16));
|
||||
|
||||
// Make a classic extension struct
|
||||
wm_classic_extension _ext;
|
||||
memset(&_ext, 0, sizeof(wm_classic_extension));
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pReport->c);
|
||||
FillReportAcc(pReport->a);
|
||||
#endif
|
||||
|
||||
if(g_Config.bNunchuckConnected)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportExtension(pReport->ext);
|
||||
#endif
|
||||
}
|
||||
else if(g_Config.bClassicControllerConnected)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportClassicExtension(_ext);
|
||||
#endif
|
||||
// Copy _ext to pReport->ext
|
||||
memcpy(&pReport->ext, &_ext, sizeof(_ext));
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendReportCoreAccelExt16 (0x35)");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Channel: %04x", _channelID);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Offset: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR10_EXT6);
|
||||
|
||||
wm_report_core_accel_ir10_ext6* pReport = (wm_report_core_accel_ir10_ext6*)(DataFrame + Offset);
|
||||
Offset += sizeof(wm_report_core_accel_ir10_ext6);
|
||||
memset(pReport, 0, sizeof(wm_report_core_accel_ir10_ext6));
|
||||
|
||||
// Make a classic extension struct
|
||||
wm_classic_extension _ext;
|
||||
memset(&_ext, 0, sizeof(wm_classic_extension));
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportInfo(pReport->c);
|
||||
FillReportAcc(pReport->a);
|
||||
FillReportIRBasic(pReport->ir[0], pReport->ir[1]);
|
||||
#endif
|
||||
|
||||
if(g_Config.bNunchuckConnected)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportExtension(pReport->ext);
|
||||
#endif
|
||||
}
|
||||
else if(g_Config.bClassicControllerConnected)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportClassicExtension(_ext);
|
||||
#endif
|
||||
// Copy _ext to pReport->ext
|
||||
memcpy(&pReport->ext, &_ext, sizeof(_ext));
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendReportCoreAccelIr10Ext()");
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _EMU_DEFINITIONS_
|
||||
#define _EMU_DEFINITIONS_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Common.h"
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
//////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
//******************************************************************************
|
||||
// Definitions and variable declarations
|
||||
//******************************************************************************
|
||||
|
||||
u8 g_Leds;
|
||||
u8 g_Speaker;
|
||||
u8 g_SpeakerVoice;
|
||||
u8 g_IR;
|
||||
|
||||
u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
u8 g_RegSpeaker[WIIMOTE_REG_SPEAKER_SIZE];
|
||||
u8 g_RegExt[WIIMOTE_REG_EXT_SIZE];
|
||||
u8 g_RegExtTmp[WIIMOTE_REG_EXT_SIZE];
|
||||
u8 g_RegIr[WIIMOTE_REG_IR_SIZE];
|
||||
|
||||
u8 g_ReportingMode; // The reporting mode and channel id
|
||||
u16 g_ReportingChannel;
|
||||
|
||||
std::vector<wm_ackdelay> AckDelay; // Ackk delay
|
||||
|
||||
wiimote_key g_ExtKey; // The extension encryption key
|
||||
bool g_Encryption; // Encryption on or off
|
||||
|
||||
// Gamepad input
|
||||
int NumPads = 0, NumGoodPads = 0; // Number of goods pads
|
||||
std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
|
||||
InputCommon::CONTROLLER_STATE_NEW PadState[4];
|
||||
InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4];
|
||||
|
||||
// Keyboard input
|
||||
KeyboardWiimote g_Wm;
|
||||
KeyboardNunchuck g_Nc;
|
||||
KeyboardClassicController g_Cc;
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _EMU_DECLARATIONS_
|
||||
#define _EMU_DECLARATIONS_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include "wiimote_hid.h" // Local
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
//******************************************************************************
|
||||
// Definitions and variable declarations
|
||||
//******************************************************************************
|
||||
|
||||
/* The Libogc bounding box in smoothed IR coordinates is 232,284 792,704. However, there is no
|
||||
universal standard that works with all games. They all use their own calibration. Also,
|
||||
there is no widescreen mode for the calibration, at least not in the games I tried, the
|
||||
game decides for example that a horizontal value of 500 is 50% from the left of the screen,
|
||||
and then that's the same regardless if we use the widescreen mode or not.*/
|
||||
#define LEFT 266
|
||||
#define TOP 215
|
||||
#define RIGHT 752
|
||||
#define BOTTOM 705
|
||||
/* Since the width of the entire virtual screen is 1024 a reasonable sensor bar width is perhaps 200,
|
||||
given how small most sensor bars are compared to the total TV width. When I tried the distance with
|
||||
my Wiimote from around three meters distance from the sensor bar (that has around 15 cm beteen the
|
||||
IR lights) I got a dot distance of around 110 (and a dot size of between 1 and 2). */
|
||||
#define SENSOR_BAR_RADIUS 100
|
||||
|
||||
// Movement recording
|
||||
extern int g_RecordingPlaying[3];
|
||||
extern int g_RecordingCounter[3];
|
||||
extern int g_RecordingPoint[3];
|
||||
extern double g_RecordingStart[3];
|
||||
extern double g_RecordingCurrentTime[3];
|
||||
|
||||
// Registry sizes
|
||||
#define WIIMOTE_EEPROM_SIZE (16*1024)
|
||||
#define WIIMOTE_EEPROM_FREE_SIZE 0x16ff
|
||||
#define WIIMOTE_REG_SPEAKER_SIZE 10
|
||||
#define WIIMOTE_REG_EXT_SIZE 0x100
|
||||
#define WIIMOTE_REG_IR_SIZE 0x34
|
||||
|
||||
extern u8 g_Leds;
|
||||
extern u8 g_Speaker;
|
||||
extern u8 g_SpeakerVoice;
|
||||
extern u8 g_IR;
|
||||
|
||||
extern u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
extern u8 g_RegSpeaker[WIIMOTE_REG_SPEAKER_SIZE];
|
||||
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 u8 g_ReportingMode;
|
||||
extern u16 g_ReportingChannel;
|
||||
|
||||
// Ack delay
|
||||
struct wm_ackdelay
|
||||
{
|
||||
u8 Delay;
|
||||
u8 ReportID;
|
||||
u16 ChannelID;
|
||||
bool Sent;
|
||||
};
|
||||
extern std::vector<wm_ackdelay> AckDelay;
|
||||
|
||||
extern wiimote_key g_ExtKey; // extension encryption key
|
||||
extern bool g_Encryption;
|
||||
|
||||
/* An example of a factory default first bytes of the Eeprom memory. There are differences between
|
||||
different Wiimotes, my Wiimote had different neutral values for the accelerometer. */
|
||||
static const u8 EepromData_0[] = {
|
||||
0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, 0x74, 0xD3,
|
||||
0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, 0x74, 0xD3,
|
||||
// Accelerometer neutral values
|
||||
0x82, 0x82, 0x82, 0x15, 0x9C, 0x9C, 0x9E, 0x38, 0x40, 0x3E,
|
||||
0x82, 0x82, 0x82, 0x15, 0x9C, 0x9C, 0x9E, 0x38, 0x40, 0x3E
|
||||
};
|
||||
|
||||
static const u8 EepromData_16D0[] = {
|
||||
0x00, 0x00, 0x00, 0xFF, 0x11, 0xEE, 0x00, 0x00,
|
||||
0x33, 0xCC, 0x44, 0xBB, 0x00, 0x00, 0x66, 0x99,
|
||||
0x77, 0x88, 0x00, 0x00, 0x2B, 0x01, 0xE8, 0x13
|
||||
};
|
||||
|
||||
|
||||
/* Default calibration for the nunchuck. It should be written to 0x20 - 0x3f of the
|
||||
extension register. 0x80 is the neutral x and y accelerators and 0xb3 is the
|
||||
neutral z accelerometer that is adjusted for gravity. */
|
||||
static const u8 nunchuck_calibration[] =
|
||||
{
|
||||
0x80,0x80,0x80,0x00, // accelerometer x, y, z neutral
|
||||
0xb3,0xb3,0xb3,0x00, // x, y, z g-force values
|
||||
|
||||
0xff, 0x00, 0x80, 0xff, // 0x80 = analog stick x and y axis center
|
||||
0x00, 0x80, 0xee, 0x43 // checksum on the last two bytes
|
||||
};
|
||||
static const u8 wireless_nunchuck_calibration[] =
|
||||
{
|
||||
128, 128, 128, 0x00,
|
||||
181, 181, 181, 0x00,
|
||||
255, 0, 125, 255,
|
||||
0, 126, 0xed, 0x43
|
||||
};
|
||||
|
||||
/* Classic Controller calibration */
|
||||
static const u8 classic_calibration[] =
|
||||
{
|
||||
0xff,0x00,0x80, 0xff,0x00,0x80, 0xff,0x00,0x80, 0xff,0x00,0x80,
|
||||
0x00,0x00, 0x51,0xa6
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* The Nunchuck id. It should be written to the last bytes of the
|
||||
extension register */
|
||||
static const u8 nunchuck_id[] =
|
||||
{
|
||||
0x00, 0x00, 0xa4, 0x20, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* The Classic Controller id. It should be written to the last bytes of the
|
||||
extension register */
|
||||
static const u8 classic_id[] =
|
||||
{
|
||||
0x00, 0x00, 0xa4, 0x20, 0x01, 0x01
|
||||
};
|
||||
|
||||
/* The id for nothing inserted */
|
||||
static const u8 nothing_id[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x2e, 0x2e
|
||||
};
|
||||
|
||||
/* The id for a partially inserted extension */
|
||||
static const u8 partially_id[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff
|
||||
};
|
||||
|
||||
// Gamepad input
|
||||
extern int NumPads, NumGoodPads; // Number of goods pads
|
||||
extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
|
||||
extern InputCommon::CONTROLLER_STATE_NEW PadState[4];
|
||||
extern InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4];
|
||||
|
||||
// Wiimote status
|
||||
struct SDot
|
||||
{
|
||||
int Rx, Ry, X, Y;
|
||||
bool Visible;
|
||||
int Size; // Size of the IR dot (0-15)
|
||||
int Order; // Increasing order from low to higher x-axis values
|
||||
};
|
||||
struct SIR
|
||||
{
|
||||
SDot Dot[4];
|
||||
int Distance;
|
||||
};
|
||||
|
||||
// Keyboard input
|
||||
struct KeyboardWiimote
|
||||
{
|
||||
enum EKeyboardWiimote
|
||||
{
|
||||
A = 0, MA, // Keyboard A and Mouse A
|
||||
B, MB,
|
||||
ONE, TWO,
|
||||
P, M, H,
|
||||
L, R, U, D,
|
||||
PITCH_L, PITCH_R,
|
||||
SHAKE,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
|
||||
// Raw X and Y coordinate and processed X and Y coordinates
|
||||
SIR IR;
|
||||
};
|
||||
extern KeyboardWiimote g_Wm;
|
||||
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,
|
||||
#else
|
||||
Z = 16,
|
||||
#endif
|
||||
C,
|
||||
L, R, U, D,
|
||||
SHAKE,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
};
|
||||
extern KeyboardNunchuck g_Nc;
|
||||
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,
|
||||
#else
|
||||
A = 23,
|
||||
#endif
|
||||
B, X, Y,
|
||||
P, M, H,
|
||||
Dl, Dr, Du, Dd,
|
||||
Tl, Tr, Zl, Zr,
|
||||
Ll, Lr, Lu, Ld,
|
||||
Rl, Rr, Ru, Rd,
|
||||
SHAKE
|
||||
};
|
||||
};
|
||||
extern KeyboardClassicController g_Cc;
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DEFINITIONS_
|
||||
@@ -0,0 +1,383 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "MathUtil.h"
|
||||
#include "StringUtil.h" // for ArrayToString()
|
||||
#include "IniFile.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include "EmuDefinitions.h" // Local
|
||||
#include "main.h"
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuMain.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Accelerometer functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Test the calculations
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void TiltTest(u8 x, u8 y, u8 z)
|
||||
{
|
||||
int Roll, Pitch, RollAdj, PitchAdj;
|
||||
PitchAccelerometerToDegree(x, y, z, Roll, Pitch, RollAdj, PitchAdj);
|
||||
std::string From = StringFromFormat("From: X:%i Y:%i Z:%i Roll:%s Pitch:%s", x, y, z,
|
||||
(Roll >= 0) ? StringFromFormat(" %03i", Roll).c_str() : StringFromFormat("%04i", Roll).c_str(),
|
||||
(Pitch >= 0) ? StringFromFormat(" %03i", Pitch).c_str() : StringFromFormat("%04i", Pitch).c_str());
|
||||
|
||||
float _Roll = (float)Roll, _Pitch = (float)Pitch;
|
||||
PitchDegreeToAccelerometer(_Roll, _Pitch, x, y, z);
|
||||
std::string To = StringFromFormat("%s\nTo: X:%i Y:%i Z:%i Roll:%s Pitch:%s", From.c_str(), x, y, z,
|
||||
(_Roll >= 0) ? StringFromFormat(" %03i", (int)_Roll).c_str() : StringFromFormat("%04i", (int)_Roll).c_str(),
|
||||
(_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str());
|
||||
INFO_LOG(CONSOLE, "%s\n", To.c_str());
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is used. When the absolute values
|
||||
of the angles go over 90° the Wiimote is upside down and these adjustments are needed. */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void AdjustAngles(float &Roll, float &Pitch)
|
||||
{
|
||||
float OldPitch = Pitch;
|
||||
|
||||
if (abs(Roll) > 90)
|
||||
{
|
||||
if (Pitch >= 0)
|
||||
Pitch = 180 - Pitch; // 15 to 165
|
||||
else if (Pitch < 0)
|
||||
Pitch = -180 - Pitch; // -15 to -165
|
||||
}
|
||||
|
||||
if (abs(OldPitch) > 90)
|
||||
{
|
||||
if (Roll >= 0)
|
||||
Roll = 180 - Roll; // 15 to 165
|
||||
else if (Roll < 0)
|
||||
Roll = -180 - Roll; // -15 to -165
|
||||
}
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Angles to accelerometer values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z)
|
||||
{
|
||||
// We need radiands for the math functions
|
||||
_Roll = InputCommon::Deg2Rad(_Roll);
|
||||
_Pitch = InputCommon::Deg2Rad(_Pitch);
|
||||
// We need decimal values
|
||||
float x = (float)_x, y = (float)_y, z = (float)_z;
|
||||
|
||||
// In these cases we can use the simple and accurate formula
|
||||
if(g_Config.Trigger.Range.Pitch == 0)
|
||||
{
|
||||
x = sin(_Roll);
|
||||
z = cos(_Roll);
|
||||
}
|
||||
else if (g_Config.Trigger.Range.Roll == 0)
|
||||
{
|
||||
|
||||
y = sin(_Pitch);
|
||||
z = cos(_Pitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ====================================================
|
||||
/* This seems to always produce the exact same combination of x, y, z and Roll and Pitch that the
|
||||
real Wiimote produce. There is an unlimited amount of x, y, z combinations for any combination of
|
||||
Roll and Pitch. But if we select a Z from the smallest of the absolute value of cos(Roll) and
|
||||
cos (Pitch) we get the right values. */
|
||||
// ---------
|
||||
if (abs(cos(_Roll)) < abs(cos(_Pitch))) z = cos(_Roll); else z = cos(_Pitch);
|
||||
/* I got these from reversing the calculation in PitchAccelerometerToDegree() in a math program
|
||||
I don't know if we can derive these from some kind of matrix or something */
|
||||
float x_num = 2 * tanf(0.5f * _Roll) * z;
|
||||
float x_den = pow2f(tanf(0.5f * _Roll)) - 1;
|
||||
x = - (x_num / x_den);
|
||||
float y_num = 2 * tanf(0.5f * _Pitch) * z;
|
||||
float y_den = pow2f(tanf(0.5f * _Pitch)) - 1;
|
||||
y = - (y_num / y_den);
|
||||
// =========================
|
||||
}
|
||||
|
||||
// Multiply with the neutral of z and its g
|
||||
float xg = g_wm.cal_g.x;
|
||||
float yg = g_wm.cal_g.y;
|
||||
float zg = g_wm.cal_g.z;
|
||||
float x_zero = g_wm.cal_zero.x;
|
||||
float y_zero = g_wm.cal_zero.y;
|
||||
float z_zero = g_wm.cal_zero.z;
|
||||
int ix = (int) (x_zero + xg * x);
|
||||
int iy = (int) (y_zero + yg * y);
|
||||
int iz = (int) (z_zero + zg * z);
|
||||
|
||||
// Boundaries
|
||||
if (ix < 0) ix = 0; if (ix > 255) ix = 255;
|
||||
if (iy < 0) iy = 0; if (iy > 255) iy = 255;
|
||||
if (iz < 0) iz = 0; if (iz > 255) iz = 255;
|
||||
if(g_Config.Trigger.Range.Roll != 0) _x = ix;
|
||||
if(g_Config.Trigger.Range.Pitch != 0) _y = iy;
|
||||
_z = iz;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Accelerometer to roll and pitch angles
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
float AccelerometerToG(float Current, float Neutral, float G)
|
||||
{
|
||||
float _G = (Current - Neutral) / G;
|
||||
return _G;
|
||||
}
|
||||
|
||||
void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int &_RollAdj, int &_PitchAdj)
|
||||
{
|
||||
// Definitions
|
||||
float Roll = 0, Pitch = 0;
|
||||
|
||||
// Calculate how many g we are from the neutral
|
||||
float x = AccelerometerToG((float)_x, (float)g_wm.cal_zero.x, (float)g_wm.cal_g.x);
|
||||
float y = AccelerometerToG((float)_y, (float)g_wm.cal_zero.y, (float)g_wm.cal_g.y);
|
||||
float z = AccelerometerToG((float)_z, (float)g_wm.cal_zero.z, (float)g_wm.cal_g.z);
|
||||
|
||||
// If it is over 1g then it is probably accelerating and may not reliable
|
||||
//if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x)
|
||||
{
|
||||
// Calculate the degree
|
||||
Roll = InputCommon::Rad2Deg(atan2(x, z));
|
||||
}
|
||||
|
||||
//if (abs(_y - g_wm.cal_zero.y) <= g_wm.cal_g.y)
|
||||
{
|
||||
// Calculate the degree
|
||||
Pitch = InputCommon::Rad2Deg(atan2(y, z));
|
||||
}
|
||||
|
||||
_Roll = (int)Roll;
|
||||
_Pitch = (int)Pitch;
|
||||
|
||||
/* Don't allow forces bigger than 1g */
|
||||
if (x < -1.0) x = -1.0; else if (x > 1.0) x = 1.0;
|
||||
if (y < -1.0) y = -1.0; else if (y > 1.0) y = 1.0;
|
||||
if (z < -1.0) z = -1.0; else if (z > 1.0) z = 1.0;
|
||||
Roll = InputCommon::Rad2Deg(atan2(x, z));
|
||||
Pitch = InputCommon::Rad2Deg(atan2(y, z));
|
||||
|
||||
_RollAdj = (int)Roll;
|
||||
_PitchAdj = (int)Pitch;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// IR data functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the basic 10 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2DotsBasic(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
||||
Dot[0].Rx = 1023 - (Data[0] | ((Data[2] & 0x30) << 4));
|
||||
Dot[0].Ry = Data[1] | ((Data[2] & 0xc0) << 2);
|
||||
|
||||
Dot[1].Rx = 1023 - (Data[3] | ((Data[2] & 0x03) << 8));
|
||||
Dot[1].Ry = Data[4] | ((Data[2] & 0x0c) << 6);
|
||||
|
||||
Dot[2].Rx = 1023 - (Data[5] | ((Data[7] & 0x30) << 4));
|
||||
Dot[2].Ry = Data[6] | ((Data[7] & 0xc0) << 2);
|
||||
|
||||
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 */
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (Dot[i].Ry == 1023)
|
||||
{
|
||||
Dot[i].Visible = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dot[i].Visible = 1;
|
||||
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
|
||||
Dot[i].X = Dot[i].Rx; Dot[i].Y = Dot[i].Ry;
|
||||
}
|
||||
|
||||
// Calculate the other values
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
//Console::Print("Rx: %i\n", Dot[i].Rx);
|
||||
|
||||
Dot[i].Rx = 1023 - (Data[3*i] | ((Data[(3*i)+2] & 0x30) << 4));
|
||||
Dot[i].Ry = Data[(3*i)+1] | ((Data[(3*i)+2] & 0xc0) << 2);
|
||||
|
||||
Dot[i].Size = Data[(3*i)+2] & 0x0f;
|
||||
|
||||
/* if in range set to visible */
|
||||
if (Dot[i].Ry == 1023)
|
||||
Dot[i].Visible = false;
|
||||
else
|
||||
Dot[i].Visible = true;
|
||||
|
||||
//Console::Print("Rx: %i\n", Dot[i].Rx);
|
||||
|
||||
// For now we let our virtual resolution be the same as the default one
|
||||
Dot[i].X = Dot[i].Rx; Dot[i].Y = Dot[i].Ry;
|
||||
}
|
||||
|
||||
// Calculate the other values
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ReorderIRDots()
|
||||
{
|
||||
// Create a shortcut
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
||||
// Variables
|
||||
int i, j, order;
|
||||
|
||||
// Reset the dot ordering to zero
|
||||
for (i = 0; i < 4; ++i)
|
||||
Dot[i].Order = 0;
|
||||
|
||||
for (order = 1; order < 5; ++order)
|
||||
{
|
||||
i = 0;
|
||||
|
||||
//
|
||||
for (; !Dot[i].Visible || Dot[i].Order; ++i)
|
||||
if (i > 4) return;
|
||||
|
||||
//
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
if (Dot[j].Visible && !Dot[j].Order && (Dot[j].X < Dot[i].X))
|
||||
i = j;
|
||||
}
|
||||
|
||||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Distance()
|
||||
{
|
||||
// Create a shortcut
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
||||
// Make these ones global
|
||||
int i1, i2;
|
||||
|
||||
for (i1 = 0; i1 < 4; ++i1)
|
||||
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; }
|
||||
|
||||
// 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; }
|
||||
|
||||
/* 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_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Classic Controller functions
|
||||
//******************************************************************************
|
||||
|
||||
std::string CCData2Values(u8 *Data)
|
||||
{
|
||||
return StringFromFormat(
|
||||
"Tl:%03i Tr:%03i Lx:%03i Ly:%03i Rx:%03i Ry:%03i",
|
||||
(((Data[2] & 0x60) >> 2) | ((Data[3] & 0xe0) >> 5)),
|
||||
(Data[3] & 0x1f),
|
||||
(Data[0] & 0x3f),
|
||||
(Data[1] & 0x3f),
|
||||
((Data[0] & 0xc0) >> 3) | ((Data[1] & 0xc0) >> 5) | ((Data[2] & 0x80) >> 7),
|
||||
(Data[2] & 0x1f));
|
||||
}
|
||||
|
||||
} // WiiMoteEmu
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef WIIMOTE_EMU_H
|
||||
#define WIIMOTE_EMU_H
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
||||
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuDefinitions.h"
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
u32 convert24bit(const u8* src);
|
||||
u16 convert16bit(const u8* src);
|
||||
void GetMousePos(float& x, float& y);
|
||||
|
||||
// General functions
|
||||
void Initialize();
|
||||
void DoState(void* ptr, int mode);
|
||||
void Shutdown(void);
|
||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) ;
|
||||
void Update();
|
||||
|
||||
// Recordings
|
||||
void LoadRecordedMovements();
|
||||
|
||||
// Registers and calibration values
|
||||
void ResetVariables();
|
||||
void UpdateEeprom();
|
||||
void SetDefaultExtensionRegistry();
|
||||
|
||||
// Gamepad
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads);
|
||||
void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons);
|
||||
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr);
|
||||
|
||||
// Accelerometer
|
||||
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z);
|
||||
void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int&, int&);
|
||||
float AccelerometerToG(float Current, float Neutral, float G);
|
||||
void TiltTest(u8 x, u8 y, u8 z);
|
||||
void Tilt(u8 &_x, u8 &_y, u8 &_z);
|
||||
void AdjustAngles(float &Roll, float &Pitch);
|
||||
|
||||
// IR data
|
||||
void IRData2Dots(u8 *Data);
|
||||
void IRData2DotsBasic(u8 *Data);
|
||||
void ReorderIRDots();
|
||||
void IRData2Distance();
|
||||
|
||||
// Classic Controller data
|
||||
std::string CCData2Values(u8 *Data);
|
||||
|
||||
}; // WiiMoteEmu
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,195 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "StringUtil.h" // for ArrayToString()
|
||||
#include "IniFile.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include "EmuDefinitions.h" // Local
|
||||
#include "main.h"
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuMain.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
////////////////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// ===================================================
|
||||
// Fill joyinfo with the current connected devices
|
||||
// ----------------
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
|
||||
|
||||
// Warn the user if no gamepads are detected
|
||||
if (_NumGoodPads == 0 && g_EmulatorRunning)
|
||||
{
|
||||
//PanicAlert("nJoy: No Gamepad Detected");
|
||||
//return false;
|
||||
}
|
||||
|
||||
// Load PadMapping[] etc
|
||||
g_Config.Load();
|
||||
|
||||
// Update the PadState[].joy handle
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID)
|
||||
if(joyinfo.at(PadMapping[i].ID).Good)
|
||||
PadState[i].joy = SDL_JoystickOpen(PadMapping[i].ID);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
// ===========================
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Return adjusted input values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
||||
{
|
||||
// This has to be changed if multiple Wiimotes are to be supported later
|
||||
const int Page = 0;
|
||||
|
||||
// Copy all states to a local variable
|
||||
Lx = PadState[Page].Axis.Lx;
|
||||
Ly = PadState[Page].Axis.Ly;
|
||||
Rx = PadState[Page].Axis.Rx;
|
||||
Ry = PadState[Page].Axis.Ry;
|
||||
Tl = PadState[Page].Axis.Tl;
|
||||
Tr = PadState[Page].Axis.Tr;
|
||||
|
||||
// Check the circle to square option
|
||||
if(PadMapping[Page].bCircle2Square)
|
||||
{
|
||||
std::vector<int> main_xy = InputCommon::Square2Circle(Lx, Ly, Page, PadMapping[Page].SDiagonal, true);
|
||||
|
||||
Lx = main_xy.at(0);
|
||||
Ly = main_xy.at(1);
|
||||
}
|
||||
|
||||
// Dead zone adjustment
|
||||
float DeadZoneLeft = (float)PadMapping[Page].DeadZoneL / 100.0f;
|
||||
float DeadZoneRight = (float)PadMapping[Page].DeadZoneR / 100.0f;
|
||||
if (InputCommon::IsDeadZone(DeadZoneLeft, Lx, Ly))
|
||||
{
|
||||
Lx = 0;
|
||||
Ly = 0;
|
||||
}
|
||||
if (InputCommon::IsDeadZone(DeadZoneRight, Rx, Ry))
|
||||
{
|
||||
Rx = 0;
|
||||
Ry = 0;
|
||||
}
|
||||
|
||||
// Downsize the values from 0x8000 to 0x80
|
||||
Lx = InputCommon::Pad_Convert(Lx);
|
||||
Ly = InputCommon::Pad_Convert(Ly);
|
||||
Rx = InputCommon::Pad_Convert(Rx);
|
||||
Ry = InputCommon::Pad_Convert(Ry);
|
||||
// The XInput range is already 0 to 0x80
|
||||
if (PadMapping[Page].triggertype == InputCommon::CTL_TRIGGER_SDL)
|
||||
{
|
||||
Tl = InputCommon::Pad_Convert(PadState[Page].Axis.Tl);
|
||||
Tr = InputCommon::Pad_Convert(PadState[Page].Axis.Tr);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Request joystick state
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Called from: PAD_GetStatus()
|
||||
Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input value "controller" is
|
||||
for a virtual controller 0 to 3. */
|
||||
|
||||
void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons)
|
||||
{
|
||||
// Return if we have no pads
|
||||
if (NumGoodPads == 0) return;
|
||||
|
||||
// Update the gamepad status
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
// Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here.
|
||||
_PadState.Axis.Lx = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Lx);
|
||||
_PadState.Axis.Ly = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Ly);
|
||||
_PadState.Axis.Rx = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Rx);
|
||||
_PadState.Axis.Ry = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Ry);
|
||||
|
||||
// Update the analog trigger axis values
|
||||
#ifdef _WIN32
|
||||
if (_PadMapping.triggertype == InputCommon::CTL_TRIGGER_SDL)
|
||||
{
|
||||
#endif
|
||||
// If we are using SDL analog triggers the buttons have to be mapped as 1000 or up, otherwise they are not used
|
||||
// We must also check that we are not asking for a negative axis number because SDL_JoystickGetAxis() has
|
||||
// no good way of handling that
|
||||
if ((_PadMapping.Axis.Tl - 1000) >= 0) _PadState.Axis.Tl = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Tl - 1000);
|
||||
if ((_PadMapping.Axis.Tr - 1000) >= 0) _PadState.Axis.Tr = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.Axis.Tr - 1000);
|
||||
#ifdef _WIN32
|
||||
}
|
||||
else
|
||||
{
|
||||
_PadState.Axis.Tl = XInput::GetXI(0, _PadMapping.Axis.Tl - 1000);
|
||||
_PadState.Axis.Tr = XInput::GetXI(0, _PadMapping.Axis.Tr - 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Debugging
|
||||
// Console::ClearScreen();
|
||||
DEBUG_LOG(CONSOLE,
|
||||
"Controller and handle: %i %i\n"
|
||||
|
||||
"Triggers:%i %i %i %i %i\n"
|
||||
|
||||
"Analog:%06i %06i \n",
|
||||
|
||||
controller, (int)_PadState.joy,
|
||||
|
||||
_PadMapping.triggertype,
|
||||
_PadMapping.Axis.Tl, _PadMapping.Axis.Tr,
|
||||
_PadState.Axis.Tl, _PadState.Axis.Tr,
|
||||
|
||||
_PadState.Axis.Lx, _PadState.Axis.Ly
|
||||
);*/
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
} // end of namespace WiiMoteEmu
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _EMU_SUBFUNCTIONS_
|
||||
#define _EMU_SUBFUNCTIONS_
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "main.h"
|
||||
#include "wiimote_hid.h" // Local
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
void HidOutputReport(u16 _channelID, wm_report* sr);
|
||||
|
||||
void WmLeds(u16 _channelID, wm_leds* leds);
|
||||
void WmReadData(u16 _channelID, wm_read_data* rd);
|
||||
void WmWriteData(u16 _channelID, wm_write_data* wd);
|
||||
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension = -1);
|
||||
void WmRequestStatus_(u16 _channelID, int a);
|
||||
void WmDataReporting(u16 _channelID, wm_data_reporting* dr);
|
||||
|
||||
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size);
|
||||
void SendReportCoreAccel(u16 _channelID);
|
||||
void SendReportCoreAccelIr12(u16 _channelID);
|
||||
void SendReportCore(u16 _channelID);
|
||||
void SendReportCoreAccelExt16(u16 _channelID);
|
||||
void SendReportCoreAccelIr10Ext(u16 _channelID);
|
||||
|
||||
int WriteWmReport(u8* dst, u8 channel);
|
||||
void WmSendAck(u16 _channelID, u8 _reportID, u32 address);
|
||||
|
||||
void FillReportAcc(wm_accel& _acc);
|
||||
void FillReportInfo(wm_core& _core);
|
||||
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1);
|
||||
void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1);
|
||||
void FillReportExtension(wm_extension& _ext);
|
||||
void FillReportClassicExtension(wm_classic_extension& _ext);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
@@ -0,0 +1,303 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
// Copyright (C) Hector Martin "marcan" (hector@marcansoft.com)
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Common.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Encryption.h"
|
||||
|
||||
|
||||
u8 ans_tbl[7][6] = {
|
||||
{0xA8,0x77,0xA6,0xE0,0xF7,0x43},
|
||||
{0x5A,0x35,0x85,0xE2,0x72,0x97},
|
||||
{0x8F,0xB7,0x1A,0x62,0x87,0x38},
|
||||
{ 0xD,0x67,0xC7,0xBE,0x4F,0x3E},
|
||||
{0x20,0x76,0x37,0x8F,0x68,0xB7},
|
||||
{0xA9,0x26,0x3F,0x2B,0x10,0xE3},
|
||||
{0x30,0x7E,0x90, 0xE,0x85, 0xA},
|
||||
};
|
||||
|
||||
u8 tsbox[256] = {
|
||||
0x70,0x51, 3,0x86,0x40, 0xD,0x4F,0xEB,0x3E,0xCC,0xD1,0x87,0x35,0xBD,0xF5, 0xB,
|
||||
0x5E,0xD0,0xF8,0xF2,0xD5,0xE2,0x6C,0x31, 0xC,0xAD,0xFC,0x21,0xC3,0x78,0xC1, 6,
|
||||
0xC2,0x4C,0x55,0xE6,0x4A,0x34,0x48,0x11,0x1E,0xDA,0xE7,0x1A,0x84,0xA0,0x96,0xA7,
|
||||
0xE3,0x7F,0xAF,0x63,0x9C,0xFA,0x23,0x5B,0x79,0xC8,0x9E,0xBA,0xB2,0xC9,0x22,0x12,
|
||||
0x4B,0xB3,0xA1,0xB6,0x32,0x49,0xA2,0xE1,0x89,0x39,0x10,0x66,0xC5, 7,0x8F,0x54,
|
||||
0xEA,0x91,0xCA,0x3F,0xF9,0x19,0xF0,0xD7,0x46,0xBC,0x28,0x1B,0x61,0xE8,0x2F,0x6A,
|
||||
0xAE,0x9D,0xF6,0x4E, 9,0x14,0x77,0x4D,0xDB,0x1F,0x2E,0x7B,0x7C,0xF1,0x43,0xA3,
|
||||
0,0xB8,0x13,0x8C,0x85,0xB9,0x29,0x75,0x88,0xFD,0xD2,0x56,0x1C,0x50,0x97,0x41,
|
||||
0xE5,0x3B,0x60,0xB5,0xC0,0x64,0xEE,0x98,0xD6,0x2D,0x25,0xA4,0xAA,0xCD,0x7D,0xA8,
|
||||
0x83,0xC6,0xAB,0xBE,0x44,0x99,0x26,0x3C,0xCE,0x9F,0xBF,0xD3,0xCB,0x76,0x7A,0x7E,
|
||||
0x82, 1,0x8A,0x9A,0x80,0x1D, 0xE,0xB0,0x5C,0xD4,0x38,0x62,0xF4,0x30,0xE0,0x8E,
|
||||
0x53,0xB7, 2,0x57,0xAC,0xA6,0x52, 0xA,0x6D,0x92,0x65,0x17,0x24,0x33,0x45,0x72,
|
||||
0x74,0xB1,0xB4,0xF7,0x5D,0xED,0x2C,0xFF,0x47,0x37,0x5A,0x90,0xBB,0xDF,0x2A,0x16,
|
||||
0x59,0x95,0xD9,0xC4,0x27,0x67,0x73,0xC7,0x68,0xFE,0xA5,0xDD,0x6B,0x5F,0x93,0xD8,
|
||||
0xEC, 5,0x3A,0x8D,0x6E,0xFB,0x3D,0xA9,0x69,0x36,0xF3,0x94,0xDE,0xEF,0x15,0x6F,
|
||||
0x8B,0x9B, 8, 0xF,0xDC,0x81,0x18,0x20, 4,0xE4,0x71,0xCF,0xE9,0x2B,0x42,0x58,
|
||||
};
|
||||
|
||||
u8 sboxes[8][256] = {
|
||||
{
|
||||
1,0xA0,0xA9,0x62,0xD6,0x3F,0x85,0xA7,0xB6,0xD4,0xFA,0x15,0x66,0x17, 9,0xBD,
|
||||
0x5D,0x14,0x34,0x26,0x59,0x72,0x91,0x54, 6,0x4F,0xF8,0xB0,0x5B,0x74,0x93,0x99,
|
||||
0x8C,0xF2,0x45,0xCD,0xEA,0x4E,0xAD,0x10,0x4A,0xE5,0xCA,0xEE,0xDF,0xC6,0x6F,0x9F,
|
||||
0x88,0x8E, 2,0xCC, 8,0xA8,0x77,0x94,0x6D,0x21,0xB1,0x28,0xE4,0x39,0x79,0x96,
|
||||
0x60,0x71,0x81,0x16,0x2E,0xE6,0x78,0xB9,0xC4,0x46,0x9A,0x42,0xAE,0xB7,0x7C,0x43,
|
||||
0xB3,0x22,0x1A,0x86,0xC2,0x32,0x3D,0x2D,0x9C,0xD2,0x29,0xE9,0x63,0x9B,0xD1,0x31,
|
||||
0x38,0x5E,0x1E,0x36,0x41,0xBB, 3,0x18,0x2B,0x3E,0xBF,0x68,0x61,0xFC,0x52,0xC0,
|
||||
0xDE,0xE0, 0xA,0x58,0x13,0x5A, 0,0xBE,0x1C,0x90, 0xE,0x53,0x12,0xFD,0xE2,0x6E,
|
||||
0xBA,0xCE,0x24,0x27,0x44,0x7F,0x87,0xA3,0xA1,0xD5,0x50,0x40,0xE3,0xF9,0x83,0xF7,
|
||||
0xC7,0xA2,0x35,0xC8,0xDB,0x19,0xAB,0x2F,0x11,0x25,0xED,0x33,0x9E,0x55,0xE1,0x48,
|
||||
0xAF,0x73,0x84,0xDA,0x2A,0xAA,0x51,0xEB,0x9D,0x95,0xB2,0xCB,0xE7,0x70,0x80,0xFE,
|
||||
0x4C,0x65, 4,0xEF,0xC5,0xF1,0xC3,0x3A,0xB4,0xF5,0x5F,0x23,0x89,0xDD,0x30,0xA5,
|
||||
0x8B,0xD3,0xF6,0xDC,0x4D,0x64,0xD7,0xF0,0x8F,0xEC,0x56,0x37,0x5C,0xA4, 0xD, 7,
|
||||
0x76,0x8A,0x2C, 0xB,0xB5,0xD8,0xC1,0x1F,0xE8,0x3B,0xF4,0x4B,0x1B,0x47,0x6C,0x49,
|
||||
0x67,0x7B,0x92,0xCF,0x75,0x7E,0x20,0xD9,0x7D,0x3C,0x97,0x7A,0xD0, 5,0x6B, 0xF,
|
||||
0x1D,0xFB,0x82,0x98,0x57,0x8D,0xF3,0x6A,0xBC,0xAC,0xC9,0xA6,0xFF,0xB8,0x69, 0xC,
|
||||
},
|
||||
{
|
||||
0x4C,0x4D,0x72, 7,0x5A,0x49,0x33,0x8D,0xA2,0xAB,0x46,0x3D,0x63, 0xD,0xA0,0x97,
|
||||
0xFF,0xF0,0xF5,0xFA,0xC0,0xE9,0xDB,0x62,0xE4,0xE1,0x74,0x43,0xDC,0x86,0x18,0x29,
|
||||
0x37,0xF4, 6,0xE2,0xED,0x6F,0x90,0x48,0x1E,0x2D,0x1D,0xEA,0x73,0x94,0x54,0xDF,
|
||||
0x25,0xF6,0x47,0x27,0xD9,0x11,0x77,0xC9,0x84,0x1C,0x5B,0x5C,0x51,0x81,0xA6,0x22,
|
||||
0x3E,0x24,0x96,0xC8,0x8A,0xEC,0x82,0x7C, 9,0xB8,0x45,0x4A,0x57,0xBB,0x2F,0x50,
|
||||
0x75,0x8E,0x61,0x70,0x8C,0x6C,0xAF,0xD0,0xFD,0xB4,0x1B,0xAE,0xDE,0xFE,0x3B,0xB5,
|
||||
0x36,0xBD,0x55, 1, 0xE,0x9C,0x41,0x56,0x5F,0xB3,0x26, 3,0x83,0xBA,0x13,0x4B,
|
||||
0xCA,0xC5, 0xA,0xF8,0x60,0xA5,0xB9,0xC7,0xC3,0x98,0x32,0xFB,0x12,0xF9,0xA7,0x92,
|
||||
0xAA,0x68,0xF3,0x78,0x7E, 5,0x20,0x21, 2,0xE8,0xBF,0xF2,0xB0,0x59,0x8F,0xD2,
|
||||
0xCB,0x87,0x65,0x15,0xF1,0x1A,0xB2,0x30,0xAD,0xEE,0x58,0xA3,0x8B,0x66,0x1F,0x2C,
|
||||
0xD7,0x5D,0x19,0x85,0xA8,0xE6,0xD3,0x6B,0xA1, 0xC,0x91,0x93,0x6A,0x5E, 0xB,0x79,
|
||||
0xE3,0xDD, 0,0x4F,0x3C,0x89,0x6E,0x71,0x69,0xA9,0xAC,0x40,0xE5,0x99,0x28,0xC6,
|
||||
0x31,0x4E,0x7A,0xCD, 8,0x9E,0x7D,0xEF,0x17,0xFC,0x88,0xD8,0xA4,0x6D,0x44,0x95,
|
||||
0xD1,0xB7,0xD4,0x9B,0xBE,0x2A,0x34,0x64,0x2B,0xCF,0x2E,0xEB,0x38,0xCE,0x23,0xE0,
|
||||
0x3A,0x3F,0xF7,0x7B,0x9F,0x10,0x53,0xBC,0x52,0x67,0x16,0xE7,0x80,0x76, 4,0xC4,
|
||||
0xB6,0xC1,0xC2,0x7F,0x9A,0xDA,0xD5,0x39,0x42,0x14,0x9D,0xB1, 0xF,0x35,0xD6,0xCC,
|
||||
},
|
||||
{
|
||||
0xB9,0xDA,0x38, 0xC,0xA2,0x9C, 9,0x1F, 6,0xB1,0xB6,0xFD,0x1A,0x69,0x23,0x30,
|
||||
0xC4,0xDE, 1,0xD1,0xF4,0x58,0x29,0x37,0x1C,0x7D,0xD5,0xBF,0xFF,0xBD,0xC8,0xC9,
|
||||
0xCF,0x65,0xBE,0x7B,0x78,0x97,0x98,0x67, 8,0xB3,0x26,0x57,0xF7,0xFA,0x40,0xAD,
|
||||
0x8E,0x75,0xA6,0x7C,0xDB,0x91,0x8B,0x51,0x99,0xD4,0x17,0x7A,0x90,0x8D,0xCE,0x63,
|
||||
0xCB,0x4E,0xA0,0xAB,0x18,0x3A,0x5B,0x50,0x7F,0x21,0x74,0xC1,0xBB,0xB8,0xB7,0xBA,
|
||||
0xB,0x35,0x95,0x31,0x59,0x9A,0x4D, 4, 7,0x1E,0x5A,0x76,0x13,0xF3,0x71,0x83,
|
||||
0xD0,0x86, 3,0xA8,0x39,0x42,0xAA,0x28,0xE6,0xE4,0xD8,0x5D,0xD3,0xD0,0x6E,0x6F,
|
||||
0x96,0xFB,0x5E,0xBC,0x56,0xC2,0x5F,0x85,0x9B,0xE7,0xAF,0xD2,0x3B,0x84,0x6A,0xA7,
|
||||
0x53,0xC5,0x44,0x49,0xA5,0xF9,0x36,0x72,0x3D,0x2C,0xD9,0x1B,0xA1,0xF5,0x4F,0x93,
|
||||
0x9D,0x68,0x47,0x41,0x16,0xCA,0x2A,0x4C,0xA3,0x87,0xD6,0xE5,0x19,0x2E,0x77,0x15,
|
||||
0x6D,0x70,0xC0,0xDF,0xB2, 0,0x46,0xED,0xC6,0x6C,0x43,0x60,0x92,0x2D,0xA9,0x22,
|
||||
0x45,0x8F,0x34,0x55,0xAE,0xA4, 0xA,0x66,0x32,0xE0,0xDC, 2,0xAC,0xE8,0x20,0x8C,
|
||||
0x89,0x62,0x4A,0xFE,0xEE,0xC3,0xE3,0x3C,0xF1,0x79, 5,0xE9,0xF6,0x27,0x33,0xCC,
|
||||
0xF2,0x9E,0x11,0x81,0x7E,0x80,0x10,0x8A,0x82,0x9F,0x48, 0xD,0xD7,0xB4,0xFC,0x2F,
|
||||
0xB5,0xC7,0xDD,0x88,0x14,0x6B,0x2B,0x54,0xEA,0x1D,0x94,0x5C,0xB0,0xEF,0x12,0x24,
|
||||
0xCD,0xEB,0xE1,0xE2,0x64,0x73,0x3F, 0xE,0x52,0x61,0x25,0x3E,0xF8, 0xF,0x4B,0xEC,
|
||||
},
|
||||
{
|
||||
0xC0, 0,0x30,0xF6, 2,0x49,0x3D,0x10,0x6E,0x20,0xC9,0xA6,0x2F,0xFE,0x2C,0x2B,
|
||||
0x75,0x2E,0x45,0x26,0xAB,0x48,0xA9,0x80,0xFC, 4,0xCC,0xD3,0xB5,0xBA,0xA3,0x38,
|
||||
0x31,0x7D, 1,0xD9,0xA7,0x7B,0x96,0xB6,0x63,0x69,0x4E,0xF7,0xDE,0xE0,0x78,0xCA,
|
||||
0x50,0xAA,0x41,0x91,0x65,0x88,0xE4,0x21,0x85,0xDA,0x3A,0x27,0xBE,0x1C,0x3E,0x42,
|
||||
0x5E,0x17,0x52,0x7F,0x1F,0x89,0x24,0x6F,0x8F,0x5C,0x67,0x74, 0xE,0x12,0x87,0x8D,
|
||||
0xE9,0x34,0xED,0x73,0xC4,0xF8,0x61,0x5B, 5,0xDF,0x59,0x4C,0x97,0x79,0x83,0x18,
|
||||
0xA4,0x55,0x95,0xEB,0xBD,0x53,0xF5,0xF1,0x57,0x66,0x46,0x9F,0xB2,0x81, 9,0x51,
|
||||
0x86,0x22,0x16,0xDD,0x23,0x93,0x76,0x29,0xC2,0xD7,0x1D,0xD4,0xBF,0x36,0x3F,0xEA,
|
||||
0x4B,0x11,0x32,0xB9,0x62,0x54,0x60,0xD6,0x6D,0x43,0x9A, 0xD,0x92,0x9C,0xB0,0xEF,
|
||||
0x58,0x6C,0x9D,0x77,0x2D,0x70,0xFA,0xF3,0xB3, 0xB,0xE2,0x40,0x7E,0xF4,0x8A,0xE5,
|
||||
0x8C,0x3C,0x56,0x71,0xD1,0x64,0xE1,0x82, 0xA,0xCB,0x13,0x15,0x90,0xEC, 3,0x99,
|
||||
0xAF,0x14,0x5D, 0xF,0x33,0x4A,0x94,0xA5,0xA8,0x35,0x1B,0xE3,0x6A,0xC6,0x28,0xFF,
|
||||
0x4D,0xE7,0x25,0x84,0xAC, 8,0xAE,0xC5,0xA2,0x2A,0xB8,0x37, 0xC,0x7A,0xA0,0xC3,
|
||||
0xCE,0xAD, 6,0x1A,0x9E,0x8B,0xFB,0xD5,0xD0,0xC1,0x1E,0xD0,0xB4,0x9B,0xB1,0x44,
|
||||
0xF2,0x47,0xC7,0x68,0xCF,0x72,0xBB,0x4F,0x5A,0xF9,0xDC,0x6B,0xDB,0xD2,0xE8,0x7C,
|
||||
0xC8,0xEE,0x98,0xA1,0xE6,0xD8,0x39, 7,0x5F,0xFD,0x8E,0x19,0xB7,0x3B,0xBC,0xCD,
|
||||
},
|
||||
{
|
||||
0x7C,0xE3,0x81,0x73,0xB2,0x11,0xBF,0x6F,0x20,0x98,0xFE,0x75,0x96,0xEF,0x6C,0xDA,
|
||||
0x50,0xE1, 9,0x72,0x54,0x45,0xBA,0x34,0x80,0x5B,0xED,0x3E,0x53,0x2C,0x87,0xA4,
|
||||
0x57,0xF3,0x33,0x3F,0x3C,0xB7,0x67,0xB4,0xA3,0x25,0x60,0x4F, 7,0x6B,0x1B,0x47,
|
||||
0x15, 0xF,0xE4, 0xA,0xEA,0xD1,0x32,0x78,0x36,0x49,0x8D,0x4B,0xD2,0xBC,0xA5,0xDC,
|
||||
0x1D, 0xD,0x4D,0xCD,0x9A,0x82,0x5F,0xFC,0x94,0x65,0xBE,0xE2,0xF4,0xC9,0x1E,0x44,
|
||||
0xCB,0x9E, 0xC,0x64,0x71,0x26,0x63,0xB3,0x14,0xE8,0x40,0x70,0x8A, 0xE,0x19,0x42,
|
||||
0x6D,0xAC,0x88,0x10,0x5C,0xDF,0x41,0xA9,0xAD,0xE5,0xFB,0x74,0xCC,0xD5, 6,0x8E,
|
||||
0x59,0x86,0xCE,0x1F,0x3D,0x76,0xE0,0x8F,0xB9,0x77,0x27,0x7B,0xA6,0xD8,0x29,0xD3,
|
||||
0xEC,0xB8,0x13,0xF7,0xFA,0xC3,0x51,0x6A,0xDE,0x4A,0x5A,0xEB,0xC2,0x8B,0x23,0x48,
|
||||
0x92,0xCF,0x62,0xA8,0x99,0xF8,0xD0,0x2E,0x85,0x61,0x43,0xC8,0xBD,0xF0, 5,0x93,
|
||||
0xCA,0x4E,0xF1,0x7D,0x30,0xFD,0xC4,0x69,0x66,0x2F, 8,0xB1,0x52,0xF9,0x21,0xE6,
|
||||
0x7A,0x2B,0xDD,0x39,0x84,0xFF,0xC0,0x91,0xD6,0x37,0xD4,0x7F,0x2D,0x9B,0x5D,0xA1,
|
||||
0x3B,0x6E,0xB5,0xC5,0x46, 4,0xF5,0x90,0xEE,0x7E,0x83,0x1C, 3,0x56,0xB6,0xAA,
|
||||
0,0x17, 1,0x35,0x55,0x79, 0xB,0x12,0xBB,0x1A,0x31,0xE7, 2,0x28,0x16,0xC1,
|
||||
0xF6,0xA2,0xDB,0x18,0x9C,0x89,0x68,0x38,0x97,0xAB,0xC7,0x2A,0xD7,0x3A,0xF2,0xC6,
|
||||
0x24,0x4C,0xB0,0x58,0xA0,0x22,0x5E,0x9D,0xD9,0xA7,0xE9,0xAE,0xAF,0x8C,0x95,0x9F,
|
||||
},
|
||||
{
|
||||
0x28,0xB7,0x20,0xD7,0xB0,0x30,0xC3, 9,0x19,0xC0,0x67,0xD6, 0,0x3C,0x7E,0xE7,
|
||||
0xE9,0xF4, 8,0x5A,0xF8,0xB8,0x2E, 5,0xA6,0x25,0x9E,0x5C,0xD8,0x15, 0xD,0xE1,
|
||||
0xF6,0x11,0x54,0x6B,0xCD,0x21,0x46,0x66,0x5E,0x84,0xAD, 6,0x38,0x29,0x44,0xC5,
|
||||
0xA2,0xCE,0xF1,0xAA,0xC1,0x40,0x71,0x86,0xB5,0xEF,0xFC,0x36,0xA8,0xCB, 0xA,0x48,
|
||||
0x27,0x45,0x64,0xA3,0xAF,0x8C,0xB2,0xC6,0x9F, 7,0x89,0xDC,0x17,0xD3,0x49,0x79,
|
||||
0xFB,0xFE,0x1D,0xD0,0xB9,0x88,0x43,0x52,0xBC, 1,0x78,0x2B,0x7D,0x94,0xC7, 0xE,
|
||||
0xDE,0xA5,0xD5,0x9B,0xCC,0xF7,0x61,0x7A,0xC2,0x74,0x81,0x39, 3,0xAB,0x96,0xA0,
|
||||
0x37,0xBD,0x2D,0x72,0x75,0x3F,0xC9,0xD4,0x8E,0x6F,0xF9,0x8D,0xED,0x62,0xDB,0x1C,
|
||||
0xDF, 4,0xAC,0x1B,0x6C,0x14,0x4B,0x63,0xD0,0xBF,0xB4,0x82,0xEC,0x7B,0x1A,0x59,
|
||||
0x92,0xD2,0x10,0x60,0xB6,0x3D,0x5F,0xE6,0x80,0x6E,0x70,0xC4,0xF2,0x35,0xD9,0x7C,
|
||||
0xEE,0xE5,0x41,0xA4,0x5B,0x50,0xDD,0xBB,0x4C,0xF3,0x1F,0x9D,0x5D,0x57,0x55,0x51,
|
||||
0x97,0xE3,0x58,0x42,0x4D,0x9C,0x73,0xBA,0xC8,0x77,0x31,0x69,0x26,0xAE,0xEA,0x8A,
|
||||
0xDA,0x22,0xB3,0x87,0x56,0xFA,0x93, 0xB,0x34,0x16,0x33,0xE8,0xE4,0x53,0xBE,0xA9,
|
||||
0xB1,0x3A,0x3E,0xF5,0x90,0x6A,0xCF,0x3B,0x12,0xFD,0x8F,0x9A,0xA7,0x47,0x91,0x99,
|
||||
0xEB, 0xF,0x24,0xFF,0x23,0x18,0x85,0x4E,0x7F, 0xC,0xE0,0xA1,0xD2,0xD1,0x2C,0x2A,
|
||||
0x4A, 2,0x4F,0x1E,0x95,0x68,0x8B,0x98,0x83,0x6D,0x76,0xCA,0x65,0x32,0x13,0x2F,
|
||||
},
|
||||
{
|
||||
0xC3,0x82,0x9A,0xA4,0xBA,0x81,0x60,0x37,0x34,0x35,0xFC,0x80,0xA8,0x51,0x65,0x67,
|
||||
0xED,0x30,0x5F,0x10,0xD3,0x4A,0x27,0x2F,0x13,0xB9,0x2A,0xD2,0xCC,0xE1,0xEF,0xAE,
|
||||
0xEB,0xBE,0xF4,0xBD,0xCF,0x43,0xB3,0xC5,0x88,0x84,0xB7,0xDD,0x39,0x40,0xCE,0x48,
|
||||
0x6D,0x9B,0x72,0x61,0x7E,0xE7,0xA1,0x4E,0x53,0x2E,0x77,0x3B,0xE2,0xC9,0x36,0x22,
|
||||
0x1B,0x6E,0x73,0xB1, 3,0xB2,0x4C,0x87,0xA9,0xD4,0x4D, 0xF,0xD8,0x15,0x6C,0xAA,
|
||||
0x18,0xF6,0x49,0x57,0x5D,0xFB,0x7A,0x14,0x94,0x63,0xA0,0x11,0xB0,0x9E,0xDE, 5,
|
||||
0x46,0xC8,0xEE,0x47,0xDB,0xDC,0x24,0x89,0x9C,0x91,0x97,0x29,0xE9,0x7B,0xC1, 7,
|
||||
0x1E,0xB8,0xFD,0xFE,0xAC,0xC6,0x62,0x98,0x4F,0xF1,0x79,0xE0,0xE8,0x6B,0x78,0x56,
|
||||
0xB6,0x8D, 4,0x50,0x86,0xCA,0x6F,0x20,0xE6,0xEA,0xE5,0x76,0x17,0x1C,0x74,0x7F,
|
||||
0xBC, 0xD,0x2C,0x85,0xF7,0x66,0x96,0xE4,0x8B,0x75,0x3F,0x4B,0xD9,0x38,0xAF,0x7C,
|
||||
0xDA, 0xB,0x83,0x2D,0x31,0x32,0xA2,0xF5,0x1D,0x59,0x41,0x45,0xBF,0x3C,0x1F,0xF8,
|
||||
0xF9,0x8A,0xD0,0x16,0x25,0x69,0x12,0x99,0x9D,0x21,0x95,0xAB, 1,0xA6,0xD7,0xB5,
|
||||
0xC0,0x7D,0xFF,0x58, 0xE,0x3A,0x92,0xD1,0x55,0xE3, 8,0x9F,0xD6,0x3E,0x52,0x8E,
|
||||
0xFA,0xA3,0xC7, 2,0xCD,0xDF,0x8F,0x64,0x19,0x8C,0xF3,0xA7, 0xC,0x5E, 0xA,0x6A,
|
||||
9,0xF0,0x93,0x5B,0x42,0xC2, 6,0x23,0xEC,0x71,0xAD,0xB4,0xCB,0xBB,0x70,0x28,
|
||||
0xD5,0x1A,0x5C,0x33,0x68,0x5A, 0,0x44,0x90,0xA5,0xC4,0x26,0x3D,0x2B,0xF2,0x54,
|
||||
},
|
||||
{
|
||||
0x96,0xAD,0xDA,0x1F,0xED,0x33,0xE1,0x81,0x69, 8, 0xD, 0xA,0xDB,0x35,0x77,0x9A,
|
||||
0x64,0xD1,0xFC,0x78,0xAA,0x1B,0xD0,0x67,0xA0,0xDD,0xFA,0x6C,0x63,0x71, 5,0x84,
|
||||
0x17,0x6A,0x89,0x4F,0x66,0x7F,0xC6,0x50,0x55,0x92,0x6F,0xBD,0xE7,0xD2,0x40,0x72,
|
||||
0x8D,0xBB,0xEC, 6,0x42,0x8A,0xE4,0x88,0x9D,0x7E,0x7A,0x82,0x27,0x13,0x41,0x1A,
|
||||
0xAF,0xC8,0xA4,0x76,0xB4,0xC2,0xFE,0x6D,0x1C,0xD9,0x61,0x30,0xB3,0x7C,0xEA,0xF7,
|
||||
0x29, 0xF,0xF2,0x3B,0x51,0xC1,0xDE,0x5F,0xE5,0x2A,0x2F,0x99, 0xB,0x5D,0xA3,0x2B,
|
||||
0x4A,0xAB,0x95,0xA5,0xD3,0x58,0x56,0xEE,0x28,0x31, 0,0xCC,0x15,0x46,0xCA,0xE6,
|
||||
0x86,0x38,0x3C,0x65,0xF5,0xE3,0x9F,0xD6,0x5B, 9,0x49,0x83,0x70,0x2D,0x53,0xA9,
|
||||
0x7D,0xE2,0xC4,0xAC,0x8E,0x5E,0xB8,0x25,0xF4,0xB9,0x57,0xF3,0xF1,0x68,0x47,0xB2,
|
||||
0xA2,0x59,0x20,0xCE,0x34,0x79,0x5C,0x90, 0xE,0x1E,0xBE,0xD5,0x22,0x23,0xB1,0xC9,
|
||||
0x18,0x62,0x16,0x2E,0x91,0x3E, 7,0x8F,0xD8,0x3F,0x93,0x3D,0xD4,0x9B,0xDF,0x85,
|
||||
0x21,0xFB,0x11,0x74,0x97,0xC7,0xD7,0xDC,0x4C,0x19,0x45,0x98,0xE9,0x43, 2,0x4B,
|
||||
0xBC,0xC3, 4,0x9C,0x6B,0xF0,0x75,0x52,0xA7,0x26,0xF6,0xC5,0xBA,0xCF,0xB0,0xB7,
|
||||
0xAE,0x5A,0xA1,0xBF, 3,0x8B,0x80,0x12,0x6E, 0xC,0xEB,0xF9,0xC0,0x44,0x24,0xEF,
|
||||
0x10,0xF8,0xA8,0x8C,0xE8,0x7B,0xFF,0x9E,0x2C,0xCD,0x60,0x36,0x87,0xB5,0x94,0xA6,
|
||||
0x54,0x73,0x3A,0x14,0x4E, 1,0x1D,0xB6,0xFD,0x37,0x48,0x4D,0x39,0xCB,0xE0,0x32,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static inline u8 ror8(u8 a, u8 b) {
|
||||
return (a>>b) | ((a<<(8-b))&0xff);
|
||||
}
|
||||
|
||||
|
||||
void genkey(u8 *rand, u8 idx, u8 *key)
|
||||
{
|
||||
u8 *ans = ans_tbl[idx];
|
||||
u8 t0[10];
|
||||
int i;
|
||||
|
||||
for(i=0;i<10;i++)
|
||||
t0[i] = tsbox[rand[i]];
|
||||
|
||||
key[0] = ((ror8((ans[0]^t0[5]),(t0[2]%8)) - t0[9]) ^ t0[4]);
|
||||
key[1] = ((ror8((ans[1]^t0[1]),(t0[0]%8)) - t0[5]) ^ t0[7]);
|
||||
key[2] = ((ror8((ans[2]^t0[6]),(t0[8]%8)) - t0[2]) ^ t0[0]);
|
||||
key[3] = ((ror8((ans[3]^t0[4]),(t0[7]%8)) - t0[3]) ^ t0[2]);
|
||||
key[4] = ((ror8((ans[4]^t0[1]),(t0[6]%8)) - t0[3]) ^ t0[4]);
|
||||
key[5] = ((ror8((ans[5]^t0[7]),(t0[8]%8)) - t0[5]) ^ t0[9]);
|
||||
}
|
||||
|
||||
|
||||
void gentabs(u8 *rand, u8 *key, u8 idx, u8 *ft, u8 *sb)
|
||||
{
|
||||
ft[0] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[3]];
|
||||
ft[1] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[5]];
|
||||
ft[2] = sboxes[idx][key[5]] ^ sboxes[(idx+1)%8][rand[7]];
|
||||
ft[3] = sboxes[idx][key[0]] ^ sboxes[(idx+1)%8][rand[2]];
|
||||
ft[4] = sboxes[idx][key[1]] ^ sboxes[(idx+1)%8][rand[4]];
|
||||
ft[5] = sboxes[idx][key[3]] ^ sboxes[(idx+1)%8][rand[9]];
|
||||
ft[6] = sboxes[idx][rand[0]] ^ sboxes[(idx+1)%8][rand[6]];
|
||||
ft[7] = sboxes[idx][rand[1]] ^ sboxes[(idx+1)%8][rand[8]];
|
||||
|
||||
sb[0] = sboxes[idx][key[0]] ^ sboxes[(idx+1)%8][rand[1]];
|
||||
sb[1] = sboxes[idx][key[5]] ^ sboxes[(idx+1)%8][rand[4]];
|
||||
sb[2] = sboxes[idx][key[3]] ^ sboxes[(idx+1)%8][rand[0]];
|
||||
sb[3] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[9]];
|
||||
sb[4] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[7]];
|
||||
sb[5] = sboxes[idx][key[1]] ^ sboxes[(idx+1)%8][rand[8]];
|
||||
sb[6] = sboxes[idx][rand[3]] ^ sboxes[(idx+1)%8][rand[5]];
|
||||
sb[7] = sboxes[idx][rand[2]] ^ sboxes[(idx+1)%8][rand[6]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate key from the 0x40-0x4c data in g_RegExt */
|
||||
// ----------------
|
||||
void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
{
|
||||
u8 rand[10];
|
||||
u8 skey[6];
|
||||
u8 testkey[6];
|
||||
int idx;
|
||||
|
||||
for(int i=0;i<10;i++)
|
||||
rand[9-i] = keydata[i];
|
||||
for(int i=0;i<6;i++)
|
||||
skey[5-i] = keydata[i+10];
|
||||
|
||||
INFO_LOG(CONSOLE, "rand: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", rand[0], rand[1], rand[2], rand[3], rand[4], rand[5], rand[6], rand[7], rand[8], rand[9]);
|
||||
INFO_LOG(CONSOLE, "key: %02x %02x %02x %02x %02x %02x\n", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]);
|
||||
|
||||
for(idx = 0; idx < 7; idx++)
|
||||
{
|
||||
genkey(rand, idx, testkey);
|
||||
if(!memcmp(testkey, skey, 6))
|
||||
break;
|
||||
}
|
||||
// default case is idx = 7 which is valid (homebrew uses it for the 0x17 case)
|
||||
INFO_LOG(CONSOLE, "idx: %d\n", idx);
|
||||
|
||||
gentabs(rand, skey, idx, key->ft, key->sb);
|
||||
|
||||
INFO_LOG(CONSOLE, "ft: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->ft[0], key->ft[1], key->ft[2], key->ft[3], key->ft[4], key->ft[5], key->ft[6], key->ft[7]);
|
||||
INFO_LOG(CONSOLE, "sb: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->sb[0], key->sb[1], key->sb[2], key->sb[3], key->sb[4], key->sb[5], key->sb[6], key->sb[7]);
|
||||
|
||||
// for homebrew, ft and sb are all 0x97 which is equivalent to 0x17
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Encrypt data */
|
||||
// ----------------
|
||||
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
data[i] = (data[i] - key->ft[addr%8]) ^ key->sb[addr%8];
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* 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];
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
// Copyright (C) Hector Martin "marcan" (hector@marcansoft.com)
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#ifndef WIIMOTE_EXTENSION_ENCRYPTION_H
|
||||
#define WIIMOTE_EXTENSION_ENCRYPTION_H
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* They key structure to use with wiimote_gen_key() */
|
||||
// ----------------
|
||||
typedef struct {
|
||||
u8 ft[8];
|
||||
u8 sb[8];
|
||||
} wiimote_key;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,119 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// -------------
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "StringUtil.h"
|
||||
|
||||
#define HAVE_WX 1
|
||||
#if defined(HAVE_WX) && HAVE_WX // wxWidgets
|
||||
#include <wx/datetime.h> // for the timestamps
|
||||
#endif
|
||||
///////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Settings
|
||||
// -------------
|
||||
|
||||
// On and off
|
||||
bool g_consoleEnable = true;
|
||||
bool gSaveFile = true;
|
||||
#define DEBUG_WIIMOTE // On or off
|
||||
const int nFiles = 1;
|
||||
|
||||
// Create handles
|
||||
#ifdef DEBUG_WIIMOTE
|
||||
FILE* __fStdOut[nFiles];
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HANDLE __hStdOut = NULL;
|
||||
#endif
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
/* Get Timestamp */
|
||||
// -------------
|
||||
std::string Tm(bool Ms)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
std::string Tmp;
|
||||
if(Ms)
|
||||
{
|
||||
wxDateTime datetime = wxDateTime::UNow(); // Get timestamp
|
||||
Tmp = StringFromFormat("%02i:%02i:%03i",
|
||||
datetime.GetMinute(), datetime.GetSecond(), datetime.GetMillisecond());
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDateTime datetime = wxDateTime::Now(); // Get timestamp
|
||||
Tmp = StringFromFormat("%02i:%02i",
|
||||
datetime.GetMinute(), datetime.GetSecond());
|
||||
}
|
||||
return Tmp;
|
||||
#else
|
||||
std::string Tmp = "";
|
||||
return Tmp;
|
||||
#endif
|
||||
}
|
||||
// ===========================
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// File printf function
|
||||
// ---------------
|
||||
int PrintFile(int a, char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUG_WIIMOTE) && defined(_WIN32)
|
||||
if(gSaveFile)
|
||||
{
|
||||
char s[500]; // WARNING: mind this value
|
||||
va_list argptr;
|
||||
int cnt;
|
||||
|
||||
va_start(argptr, fmt);
|
||||
cnt = vsnprintf(s, 500, fmt, argptr); // remember to update this value to
|
||||
va_end(argptr);
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
|
||||
//to make it work
|
||||
fprintf(__fStdOut[a], s);
|
||||
fflush(__fStdOut[0]); // Write file now, don't wait
|
||||
// -------------
|
||||
|
||||
return(cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user