mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Some clean up
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3377 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -16,9 +16,6 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -37,9 +34,7 @@
|
||||
#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
|
||||
@ -51,9 +46,7 @@ namespace WiiMoteEmu
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Test the calculations
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void TiltTest(u8 x, u8 y, u8 z)
|
||||
{
|
||||
int Roll, Pitch, RollAdj, PitchAdj;
|
||||
@ -69,13 +62,11 @@ void TiltTest(u8 x, u8 y, u8 z)
|
||||
(_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<39> the Wiimote is upside down and these adjustments are needed. */
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is
|
||||
used. When the absolute values of the angles go over 90<39> the Wiimote is
|
||||
upside down and these adjustments are needed. */
|
||||
void AdjustAngles(float &Roll, float &Pitch)
|
||||
{
|
||||
float OldPitch = Pitch;
|
||||
@ -96,12 +87,9 @@ void AdjustAngles(float &Roll, float &Pitch)
|
||||
Roll = -180 - Roll; // -15 to -165
|
||||
}
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Angles to accelerometer values
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z)
|
||||
{
|
||||
// We need radiands for the math functions
|
||||
@ -125,21 +113,22 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
||||
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. */
|
||||
/* 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 */
|
||||
/* 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
|
||||
@ -162,9 +151,7 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
||||
_z = iz;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Accelerometer to roll and pitch angles
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float AccelerometerToG(float Current, float Neutral, float G)
|
||||
{
|
||||
float _G = (Current - Neutral) / G;
|
||||
@ -214,11 +201,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
|
||||
// IR data functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the basic 10 byte IR data
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void IRData2DotsBasic(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
@ -258,9 +241,7 @@ void IRData2DotsBasic(u8 *Data)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
@ -290,12 +271,9 @@ void IRData2Dots(u8 *Data)
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void ReorderIRDots()
|
||||
{
|
||||
// Create a shortcut
|
||||
@ -326,12 +304,9 @@ void ReorderIRDots()
|
||||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void IRData2Distance()
|
||||
{
|
||||
// Create a shortcut
|
||||
@ -361,7 +336,6 @@ void IRData2Distance()
|
||||
// Save the distance
|
||||
g_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
@ -380,4 +354,4 @@ std::string CCData2Values(u8 *Data)
|
||||
(Data[2] & 0x1f));
|
||||
}
|
||||
|
||||
} // WiiMoteEmu
|
||||
} // WiiMoteEmu
|
||||
|
Reference in New Issue
Block a user