1. Fixed a silly bug that prevented IR rotation in last rev from working, now IR rotation works fine, verified.
2. Added Roll Left/Right key mappings for keyboard. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4659 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
4df6dc24f8
commit
48896c7de2
|
@ -55,16 +55,13 @@ namespace InputCommon
|
|||
// -------------
|
||||
float Deg2Rad(float Deg)
|
||||
{
|
||||
return Deg * ((float)M_PI / 180.0f);
|
||||
return Deg * (float)M_PI / 180.0f;
|
||||
}
|
||||
float Rad2Deg(float Rad)
|
||||
{
|
||||
return (Rad * 180.0f) / (float)M_PI;
|
||||
return Rad * 180.0f / (float)M_PI;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Check if the pad is within the dead zone, we assume the range is 0x8000
|
||||
// ----------------
|
||||
float CoordinatesToRadius(int x, int y)
|
||||
|
@ -107,7 +104,7 @@ int Pad_Convert(int _val)
|
|||
// Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
|
||||
_val = 0x8000 +_val;
|
||||
|
||||
// Convert the range (-32768 to 32767) to (-128 to 127)
|
||||
// Convert the range (0 to 0xffff) to (0 to 0xff)
|
||||
_val = _val >> 8;
|
||||
|
||||
//Console::Print("0x%04x %06i\n\n", _val, _val);
|
||||
|
@ -196,7 +193,7 @@ void Square2Circle(int &_x, int &_y, int _pad, std::string SDiagonal, bool Circl
|
|||
|
||||
/* Calculate the actual distance between the maxium diagonal values, and the outer edges of the
|
||||
square. A diagonal of 85% means a maximum distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
|
||||
float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45)) );
|
||||
float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45.0f)) );
|
||||
float SquareDist = Square2CircleDistance(deg);
|
||||
// The original-to-square distance adjustment
|
||||
float adj_ratio1;
|
||||
|
|
|
@ -180,9 +180,9 @@ struct PadAxis
|
|||
};
|
||||
struct PadWiimote
|
||||
{
|
||||
int keyForControls[14];
|
||||
int keyForControls[16];
|
||||
// Order is A, B, 1, 2, +, -, Home
|
||||
// L, R, U, D, Shake, PitchL, PitchR
|
||||
// L, R, U, D, RollL, RollR, PitchU, PitchD, Shake
|
||||
};
|
||||
|
||||
struct PadNunchuck
|
||||
|
@ -194,8 +194,8 @@ struct PadClassicController
|
|||
{
|
||||
int keyForControls[23];
|
||||
// Order is A, B, X, Y, +, -, Home
|
||||
// Tl, Zl, Zr, Tr, Dl, Du, Dr, Dd
|
||||
// Ll, Lu, Lr, Ld, Rl, Ru, Rr, Rd
|
||||
// Tl, Zl, Zr, Tr, Dl, Dr, Du, Dd
|
||||
// Ll, Lr, Lu, Ld, Rl, Rr, Ru, Rd
|
||||
};
|
||||
struct PadGH3Controller
|
||||
{
|
||||
|
|
|
@ -44,37 +44,50 @@ static const char* wmControlNames[] =
|
|||
"WmR",
|
||||
"WmU",
|
||||
"WmD",
|
||||
"WmPitchL",
|
||||
"WmPitchR",
|
||||
"WmRollL",
|
||||
"WmRollR",
|
||||
"WmPitchU",
|
||||
"WmPitchD",
|
||||
"WmShake",
|
||||
};
|
||||
static int wmDefaultControls[] =
|
||||
{
|
||||
#ifdef _WIN32
|
||||
'Z',
|
||||
'X',
|
||||
'C',
|
||||
'V',
|
||||
'M',
|
||||
'B',
|
||||
'N',
|
||||
#ifdef _WIN32
|
||||
VK_OEM_PLUS,
|
||||
VK_OEM_MINUS,
|
||||
VK_BACK,
|
||||
VK_LEFT,
|
||||
VK_RIGHT,
|
||||
VK_UP,
|
||||
VK_DOWN,
|
||||
'N',
|
||||
'M',
|
||||
VK_OEM_COMMA,
|
||||
VK_OEM_PERIOD,
|
||||
VK_OEM_2 // /
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
'Z',
|
||||
'X',
|
||||
'C',
|
||||
'V',
|
||||
XK_Equal,
|
||||
XK_Minus,
|
||||
XK_BackSpace,
|
||||
XK_Left,
|
||||
XK_Right,
|
||||
XK_Up,
|
||||
XK_Down,
|
||||
'N',
|
||||
'M',
|
||||
XK_comma,
|
||||
XK_period,
|
||||
XK_slash
|
||||
#else
|
||||
0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -143,51 +156,51 @@ static int ccDefaultControls[] =
|
|||
{
|
||||
// A, B, X, Y
|
||||
#ifdef _WIN32
|
||||
VK_OEM_6, // ]
|
||||
VK_OEM_7, // '
|
||||
VK_OEM_4, // [
|
||||
VK_OEM_6, // ]
|
||||
VK_OEM_1, // ;
|
||||
VK_OEM_7, // '
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
XK_bracketright,
|
||||
XK_quoteright,
|
||||
XK_bracketleft,
|
||||
XK_bracketright,
|
||||
XK_semicolon,
|
||||
XK_quoteright,
|
||||
#else
|
||||
0,0,0,0,
|
||||
#endif
|
||||
// +, -, Home
|
||||
'L',
|
||||
'J',
|
||||
'K',
|
||||
'H',
|
||||
'F',
|
||||
'G',
|
||||
// Triggers, Zs
|
||||
'E',
|
||||
'U',
|
||||
'R',
|
||||
'Y',
|
||||
// Digital pad
|
||||
'A',
|
||||
'D',
|
||||
'W',
|
||||
'S',
|
||||
// Left analog
|
||||
'F',
|
||||
'H',
|
||||
'R',
|
||||
'T',
|
||||
'G',
|
||||
// Right analog
|
||||
// Digital pad
|
||||
#ifdef _WIN32
|
||||
VK_NUMPAD4,
|
||||
VK_NUMPAD6,
|
||||
VK_NUMPAD8,
|
||||
VK_NUMPAD5
|
||||
VK_NUMPAD5,
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
XK_KP_4,
|
||||
XK_KP_6,
|
||||
XK_KP_8,
|
||||
XK_KP_5
|
||||
XK_KP_5,
|
||||
#else
|
||||
0,0,0,0
|
||||
0,0,0,0,
|
||||
#endif
|
||||
// Left analog
|
||||
'A',
|
||||
'D',
|
||||
'W',
|
||||
'S',
|
||||
// Right analog
|
||||
'J',
|
||||
'L',
|
||||
'I',
|
||||
'K'
|
||||
};
|
||||
|
||||
// GH3 Default controls
|
||||
|
@ -257,7 +270,7 @@ void Config::Load(bool ChangePad)
|
|||
|
||||
// Real Wiimote
|
||||
iniFile.Get("Real", "Connect", &bConnectRealWiimote, true);
|
||||
iniFile.Get("Real", "Use", &bUseRealWiimote, true);
|
||||
iniFile.Get("Real", "Use", &bUseRealWiimote, false);
|
||||
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
|
||||
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <X11/keysym.h>
|
||||
#endif
|
||||
|
||||
#define WM_CONTROLS 14
|
||||
#define WM_CONTROLS 16
|
||||
#define NC_CONTROLS 7
|
||||
#define CC_CONTROLS 23
|
||||
#define GH3_CONTROLS 14
|
||||
|
|
|
@ -256,7 +256,7 @@ void WiimotePadConfigDialog::SaveButtonMapping(int controller, bool DontChangeId
|
|||
// Save keyboard key mapping
|
||||
void WiimotePadConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key)
|
||||
{
|
||||
if (IDB_WM_A <= Id && Id <= IDB_WM_PITCH_R)
|
||||
if (IDB_WM_A <= Id && Id <= IDB_WM_SHAKE)
|
||||
{
|
||||
WiiMoteEmu::PadMapping[Controller].Wm.keyForControls[Id - IDB_WM_A] = Key;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void WiimotePadConfigDialog::SetButtonText(int id, const char text[128], int _Pa
|
|||
int controller;
|
||||
if (_Page == -1) controller = Page; else controller = _Page;
|
||||
|
||||
if (IDB_WM_A <= id && id <= IDB_WM_PITCH_R)
|
||||
if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
|
||||
m_Button_Wiimote[id - IDB_WM_A][controller]->SetLabel(wxString::FromAscii(text));
|
||||
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
|
||||
m_Button_NunChuck[id - IDB_NC_Z][controller]->SetLabel(wxString::FromAscii(text));
|
||||
|
|
|
@ -55,11 +55,13 @@ BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog)
|
|||
// Wiimote
|
||||
EVT_BUTTON(IDB_WM_A, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_B, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_1, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_2, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_P, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_M, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_H, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_P, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_M, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_H, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_L, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_R, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_U, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_D, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_ROLL_L, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_ROLL_R, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_PITCH_U, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_PITCH_D, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_SHAKE, WiimotePadConfigDialog::OnButtonClick)
|
||||
EVT_BUTTON(IDB_WM_PITCH_L, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_PITCH_R, WiimotePadConfigDialog::OnButtonClick)
|
||||
|
||||
// Nunchuck
|
||||
EVT_BUTTON(IDB_NC_Z, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_C, WiimotePadConfigDialog::OnButtonClick)
|
||||
|
@ -415,7 +417,7 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
|
|||
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
|
||||
// Configuration controls sizes
|
||||
static const int TxtW = 50, TxtH = 19, BtW = 75, BtH = 20;
|
||||
static const int TxtW = 50, TxtH = 20, BtW = 70, BtH = 20;
|
||||
|
||||
// Controller
|
||||
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(200, -1), StrJoyname, wxCB_READONLY);
|
||||
|
@ -705,8 +707,10 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
|
|||
wxT("Right"),
|
||||
wxT("Up"),
|
||||
wxT("Down"),
|
||||
wxT("Pitch Left"),
|
||||
wxT("Pitch Right"),
|
||||
wxT("Roll Left"),
|
||||
wxT("Roll Right"),
|
||||
wxT("Pitch Up"),
|
||||
wxT("Pitch Down"),
|
||||
wxT("Shake"),
|
||||
};
|
||||
|
||||
|
@ -722,7 +726,7 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
|
|||
m_Sizer_Wiimote[x][i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_Sizer_Wiimote[x][i]->Add(m_statictext_Wiimote[x][i], 0, (wxUP), 4);
|
||||
m_Sizer_Wiimote[x][i]->Add(m_Button_Wiimote[x][i], 0, (wxLEFT), 2);
|
||||
if (x < 7)
|
||||
if (x < 7 || x == WM_CONTROLS -1) // Make some balance
|
||||
m_SWmVertLeft[i]->Add(m_Sizer_Wiimote[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
else
|
||||
m_SWmVertRight[i]->Add(m_Sizer_Wiimote[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
|
@ -776,11 +780,11 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
|
|||
{
|
||||
// Stick controls
|
||||
m_CcTextLeftStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left stick"));
|
||||
m_CcComboLeftStick[i] = new wxComboBox(m_Controller[i], IDCB_CC_LEFT_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(100, -1), StrNunchuck, wxCB_READONLY);
|
||||
m_CcComboLeftStick[i] = new wxComboBox(m_Controller[i], IDCB_CC_LEFT_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(70, -1), StrNunchuck, wxCB_READONLY);
|
||||
m_CcTextRightStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Right stick"));
|
||||
m_CcComboRightStick[i] = new wxComboBox(m_Controller[i], IDCB_CC_RIGHT_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(100, -1), StrNunchuck, wxCB_READONLY);
|
||||
m_CcComboRightStick[i] = new wxComboBox(m_Controller[i], IDCB_CC_RIGHT_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(70, -1), StrNunchuck, wxCB_READONLY);
|
||||
m_CcTextTriggers[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Triggers"));
|
||||
m_CcComboTriggers[i] = new wxComboBox(m_Controller[i], IDCB_CC_TRIGGERS, StrCcTriggers[0], wxDefaultPosition, wxSize(100, -1), StrCcTriggers, wxCB_READONLY);
|
||||
m_CcComboTriggers[i] = new wxComboBox(m_Controller[i], IDCB_CC_TRIGGERS, StrCcTriggers[0], wxDefaultPosition, wxSize(70, -1), StrCcTriggers, wxCB_READONLY);
|
||||
|
||||
static const wxChar* classicText[] =
|
||||
{
|
||||
|
@ -834,30 +838,33 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
|
|||
// The left parent
|
||||
m_SCcVertLeft[i] = new wxBoxSizer(wxVERTICAL);
|
||||
m_SCcVertLeft[i]->Add(m_SCcLeftStick[i], 0, wxALIGN_RIGHT | (wxALL), 2);
|
||||
m_SCcVertLeft[i]->Add(m_SCcRightStick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 2);
|
||||
m_SCcVertLeft[i]->AddSpacer(2);
|
||||
// Left and right stick
|
||||
for ( int x = IDB_CC_LL; x <= IDB_CC_RD; x++)
|
||||
// Left stick
|
||||
for ( int x = IDB_CC_LL; x <= IDB_CC_LD; x++)
|
||||
m_SCcVertLeft[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
// Digital l,r,u,d
|
||||
for ( int x = IDB_CC_DL; x <= IDB_CC_DD; x++)
|
||||
m_SCcVertLeft[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
|
||||
// The middle parent
|
||||
m_SCcVertMiddle[i] = new wxBoxSizer(wxVERTICAL);
|
||||
m_SCcVertMiddle[i]->Add(m_SCcTriggers[i], 0, wxALIGN_RIGHT | (wxALL), 1);
|
||||
m_SCcVertMiddle[i]->Add(m_SCcRightStick[i], 0, wxALIGN_RIGHT | (wxALL), 2);
|
||||
m_SCcVertMiddle[i]->AddSpacer(2);
|
||||
// Shoulder buttons
|
||||
for ( int x = IDB_CC_TL; x <= IDB_CC_ZR; x++)
|
||||
// Right stick
|
||||
for ( int x = IDB_CC_RL; x <= IDB_CC_RD; x++)
|
||||
m_SCcVertMiddle[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
// Digital l,r,u,d
|
||||
for ( int x = IDB_CC_DL; x <= IDB_CC_DD; x++)
|
||||
for ( int x = IDB_CC_A; x <= IDB_CC_Y; x++)
|
||||
m_SCcVertMiddle[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
|
||||
// The right parent
|
||||
m_SCcVertRight[i] = new wxBoxSizer(wxVERTICAL);
|
||||
for ( int x = 0; x <= IDB_CC_ZR - IDB_CC_A; x++)
|
||||
{
|
||||
if (x != IDB_CC_TL - IDB_CC_A)
|
||||
m_SCcVertRight[i]->Add(m_Sizer_Classic[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
}
|
||||
m_SCcVertRight[i]->Add(m_SCcTriggers[i], 0, wxALIGN_RIGHT | (wxALL), 2);
|
||||
m_SCcVertRight[i]->AddSpacer(2);
|
||||
// Shoulder buttons
|
||||
for ( int x = IDB_CC_TL; x <= IDB_CC_ZR; x++)
|
||||
m_SCcVertRight[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
for ( int x = IDB_CC_P; x <= IDB_CC_H; x++)
|
||||
m_SCcVertRight[i]->Add(m_Sizer_Classic[x - IDB_CC_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
|
||||
|
||||
// The parent sizer
|
||||
m_gClassicController[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Classic Controller"));
|
||||
|
|
|
@ -207,7 +207,9 @@ class WiimotePadConfigDialog : public wxDialog
|
|||
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,
|
||||
IDB_WM_ROLL_L, IDB_WM_ROLL_R,
|
||||
IDB_WM_PITCH_U, IDB_WM_PITCH_D,
|
||||
IDB_WM_SHAKE,
|
||||
|
||||
// Nunchuck
|
||||
IDB_NC_Z,
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace WiiMoteEmu
|
|||
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
|
||||
#define SENSOR_BAR_WIDTH 200
|
||||
|
||||
// Movement recording
|
||||
extern int g_RecordingPlaying[3];
|
||||
|
@ -181,7 +181,8 @@ struct KeyboardWiimote
|
|||
ONE, TWO,
|
||||
P, M, H,
|
||||
L, R, U, D,
|
||||
PITCH_L, PITCH_R,
|
||||
ROLL_L, ROLL_R,
|
||||
PITCH_U, PITCH_D,
|
||||
SHAKE,
|
||||
MA, MB,
|
||||
LAST_CONSTANT
|
||||
|
@ -199,7 +200,7 @@ struct KeyboardNunchuck
|
|||
#ifdef _WIN32
|
||||
Z = g_Wiimote_kbd.LAST_CONSTANT,
|
||||
#else
|
||||
Z = 16,
|
||||
Z = 18,
|
||||
#endif
|
||||
C,
|
||||
L, R, U, D,
|
||||
|
@ -216,7 +217,7 @@ struct KeyboardClassicController
|
|||
#ifdef _WIN32
|
||||
A = g_NunchuckExt.LAST_CONSTANT,
|
||||
#else
|
||||
A = 23,
|
||||
A = 25,
|
||||
#endif
|
||||
B, X, Y,
|
||||
P, M, H,
|
||||
|
@ -224,7 +225,6 @@ struct KeyboardClassicController
|
|||
Dl, Dr, Du, Dd,
|
||||
Ll, Lr, Lu, Ld,
|
||||
Rl, Rr, Ru, Rd,
|
||||
SHAKE,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
};
|
||||
|
@ -238,14 +238,13 @@ struct KeyboardGH3GLP
|
|||
#ifdef _WIN32
|
||||
Green = g_ClassicContExt.LAST_CONSTANT,
|
||||
#else
|
||||
Green = 47,
|
||||
Green = 48,
|
||||
#endif
|
||||
Red, Yellow, Blue,
|
||||
Orange,Plus, Minus,
|
||||
Whammy,
|
||||
Al, Ar, Au, Ad,
|
||||
StrumUp, StrumDown,
|
||||
SHAKE,
|
||||
LAST_CONSTANT
|
||||
};
|
||||
};
|
||||
|
|
|
@ -94,12 +94,6 @@ void PitchDegreeToAccelerometer(int Roll, int Pitch, int &_x, int &_y, int &_z)
|
|||
// Direct mapping for swing, from analog stick to accelerometer
|
||||
if (g_Config.Trigger.Range.Roll == 0 && g_Config.Trigger.Range.Pitch == 0)
|
||||
{
|
||||
// Make a deadzone to avoid trouble
|
||||
if (abs(Roll) <= abs(g_wm.cal_g.x))
|
||||
Roll = 0;
|
||||
if (abs(Pitch) <= abs(g_wm.cal_g.z))
|
||||
Pitch = 0;
|
||||
|
||||
if (!g_Config.Trigger.Upright)
|
||||
{
|
||||
_x -= Roll;
|
||||
|
@ -117,16 +111,18 @@ void PitchDegreeToAccelerometer(int Roll, int Pitch, int &_x, int &_y, int &_z)
|
|||
float _Roll = InputCommon::Deg2Rad((float)Roll);
|
||||
float _Pitch = InputCommon::Deg2Rad((float)Pitch);
|
||||
// We need decimal values
|
||||
float x = (float)_x, y = (float)_y, z = (float)_z;
|
||||
float x, y, z;
|
||||
|
||||
// In these cases we can use the simple and accurate formula
|
||||
if(g_Config.Trigger.Range.Pitch == 0)
|
||||
{
|
||||
x = sin(_Roll);
|
||||
y = 0.0f;
|
||||
z = cos(_Roll);
|
||||
}
|
||||
else if (g_Config.Trigger.Range.Roll == 0)
|
||||
{
|
||||
x = 0.0f;
|
||||
y = sin(_Pitch);
|
||||
z = cos(_Pitch);
|
||||
}
|
||||
|
|
|
@ -99,8 +99,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr)
|
|||
break;
|
||||
|
||||
case WM_REQUEST_STATUS: // 0x15
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
||||
WmRequestStatus(_channelID, (wm_request_status*)sr->data);
|
||||
WmRequestStatus(_channelID, (wm_request_status*)sr->data);
|
||||
break;
|
||||
|
||||
case WM_WRITE_DATA: // 0x16
|
||||
|
@ -108,8 +107,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr)
|
|||
break;
|
||||
|
||||
case WM_READ_DATA: // 0x17
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
||||
WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||
WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||
break;
|
||||
|
||||
case WM_WRITE_SPEAKER_DATA: // 0x18
|
||||
|
|
|
@ -324,11 +324,6 @@ int GetMapKeyState(int _MapKey, int Key)
|
|||
// Multi System Input Status Check
|
||||
int IsKey(int Key)
|
||||
{
|
||||
|
||||
if (g_Wiimote_kbd.A <= Key && Key <= g_Wiimote_kbd.PITCH_R)
|
||||
{
|
||||
return GetMapKeyState(PadMapping[0].Wm.keyForControls[Key - g_Wiimote_kbd.A], Key);
|
||||
}
|
||||
if (Key == g_Wiimote_kbd.SHAKE)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -337,6 +332,10 @@ int IsKey(int Key)
|
|||
return GetMapKeyState(PadMapping[0].Wm.keyForControls[Key - g_Wiimote_kbd.A], Key);
|
||||
#endif
|
||||
}
|
||||
if (g_Wiimote_kbd.A <= Key && Key <= g_Wiimote_kbd.PITCH_D)
|
||||
{
|
||||
return GetMapKeyState(PadMapping[0].Wm.keyForControls[Key - g_Wiimote_kbd.A], Key);
|
||||
}
|
||||
if (g_NunchuckExt.Z <= Key && Key <= g_NunchuckExt.SHAKE)
|
||||
{
|
||||
return GetMapKeyState(PadMapping[0].Nc.keyForControls[Key - g_NunchuckExt.Z], Key);
|
||||
|
@ -431,18 +430,10 @@ Y |. .|| Z
|
|||
|
||||
*/
|
||||
|
||||
// Global declarations for FillReportAcc: These variables are global so they
|
||||
//can be changed during debugging int A = 0, B = 128, C = 64; // for debugging
|
||||
//int a = 1, b = 1, c = 2, d = -2; // for debugging int consoleDisplay = 0;
|
||||
|
||||
// Global declarations for FillReportAcc: These variables are global
|
||||
// For the shake function, Wiimote: wm = 0, Nunchuck: wm = 1
|
||||
int Shake[] = {0, 0};
|
||||
|
||||
// For the tilt function, the size of this list determines how fast Y returns to its neutral value
|
||||
std::vector<u8> yhist(15, 0);
|
||||
int KbDegree;
|
||||
|
||||
int Roll, Pitch;
|
||||
int Roll = 0, Pitch = 0;
|
||||
|
||||
// Single shake of all three directions
|
||||
void SingleShake(int &_x, int &_y, int &_z, int wm)
|
||||
|
@ -525,7 +516,7 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
|
|||
// Invert
|
||||
if (PadMapping[Page].bPitchInvert) { Tl = -Tl; Tr = -Tr; }
|
||||
// The final value
|
||||
Pitch = PitchRange * ((float)(Tl - Tr) / 128.0);
|
||||
Pitch = (float)PitchRange * ((float)(Tl - Tr) / 128.0f);
|
||||
}
|
||||
|
||||
/* For the analog stick roll is by default set to the X-axis, pitch is by
|
||||
|
@ -540,8 +531,8 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
|
|||
if (PadMapping[Page].bRollInvert) Lx = -Lx; // else Tr = -Tr;
|
||||
if (PadMapping[Page].bPitchInvert) Ly = -Ly; // else Tr = -Tr;
|
||||
// Produce the final value
|
||||
Roll = (RollRange) ? RollRange * ((float)Lx / 128.0) : Lx;
|
||||
Pitch = (PitchRange) ? PitchRange * ((float)Ly / 128.0) : Ly;
|
||||
Roll = (RollRange) ? (float)RollRange * ((float)Lx / 128.0f) : Lx;
|
||||
Pitch = (PitchRange) ? (float)PitchRange * ((float)Ly / 128.0f) : Ly;
|
||||
}
|
||||
// Otherwise we are using ANALOG2
|
||||
else
|
||||
|
@ -553,8 +544,8 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
|
|||
if (PadMapping[Page].bRollInvert) Rx = -Rx; // else Tr = -Tr;
|
||||
if (PadMapping[Page].bPitchInvert) Ry = -Ry; // else Tr = -Tr;
|
||||
// Produce the final value
|
||||
Roll = (RollRange) ? RollRange * ((float)Rx / 128.0) : Rx;
|
||||
Pitch = (PitchRange) ? PitchRange * ((float)Ry / 128.0) : Ry;
|
||||
Roll = (RollRange) ? (float)RollRange * ((float)Rx / 128.0f) : Rx;
|
||||
Pitch = (PitchRange) ? (float)PitchRange * ((float)Ry / 128.0f) : Ry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,55 +553,57 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
|
|||
// Tilting Wiimote with keyboard
|
||||
void TiltWiimoteKeyboard(int &Roll, int &Pitch)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Direct map keyboard pitch left/right to swing left/right
|
||||
// Direct map roll/pitch to swing
|
||||
if (g_Config.Trigger.Range.Roll == 0 && g_Config.Trigger.Range.Pitch == 0)
|
||||
{
|
||||
if (IsKey(g_Wiimote_kbd.PITCH_L))
|
||||
if (IsKey(g_Wiimote_kbd.ROLL_L))
|
||||
Roll = -0x80 / 2;
|
||||
else if (IsKey(g_Wiimote_kbd.PITCH_R))
|
||||
else if (IsKey(g_Wiimote_kbd.ROLL_R))
|
||||
Roll = 0x80 / 2;
|
||||
else
|
||||
Roll = 0;
|
||||
if (IsKey(g_Wiimote_kbd.PITCH_U))
|
||||
Pitch = -0x80 / 2;
|
||||
else if (IsKey(g_Wiimote_kbd.PITCH_D))
|
||||
Pitch = 0x80 / 2;
|
||||
else
|
||||
Pitch = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsKey(g_Wiimote_kbd.PITCH_L))
|
||||
// Otherwise do roll/pitch
|
||||
if (IsKey(g_Wiimote_kbd.ROLL_L))
|
||||
{
|
||||
// Stop at the upper end of the range
|
||||
if (KbDegree < g_Config.Trigger.Range.Pitch)
|
||||
KbDegree += 3; // aim left
|
||||
if (Roll < g_Config.Trigger.Range.Roll)
|
||||
Roll += 3; // aim left
|
||||
}
|
||||
else if (IsKey(g_Wiimote_kbd.PITCH_R))
|
||||
else if (IsKey(g_Wiimote_kbd.ROLL_R))
|
||||
{
|
||||
// Stop at the lower end of the range
|
||||
if (KbDegree > -g_Config.Trigger.Range.Pitch)
|
||||
KbDegree -= 3; // aim right
|
||||
}
|
||||
|
||||
// Check for inactivity in the tilting, the Y value will be reset after ten inactive updates
|
||||
// Check for activity
|
||||
yhist[yhist.size() - 1] = (
|
||||
IsKey(g_Wiimote_kbd.PITCH_L)
|
||||
||IsKey(g_Wiimote_kbd.PITCH_R)
|
||||
);
|
||||
|
||||
// Move all items back, and check if any of them are true
|
||||
bool ypressed = false;
|
||||
for (int i = 1; i < (int)yhist.size(); i++)
|
||||
{
|
||||
yhist[i-1] = yhist[i];
|
||||
if(yhist[i]) ypressed = true;
|
||||
}
|
||||
// Tilting was not used a single time, reset the angle to zero
|
||||
if(!ypressed)
|
||||
{
|
||||
KbDegree = 0;
|
||||
if (Roll > -g_Config.Trigger.Range.Roll)
|
||||
Roll -= 3; // aim right
|
||||
}
|
||||
else
|
||||
{
|
||||
Pitch = KbDegree;
|
||||
//DEBUG_LOG(WIIMOTE, "Degree: %i", KbDegree);
|
||||
Roll = 0;
|
||||
}
|
||||
if (IsKey(g_Wiimote_kbd.PITCH_U))
|
||||
{
|
||||
// Stop at the upper end of the range
|
||||
if (Pitch < g_Config.Trigger.Range.Pitch)
|
||||
Pitch += 3; // aim up
|
||||
}
|
||||
else if (IsKey(g_Wiimote_kbd.PITCH_D))
|
||||
{
|
||||
// Stop at the lower end of the range
|
||||
if (Pitch > -g_Config.Trigger.Range.Pitch)
|
||||
Pitch -= 3; // aim down
|
||||
}
|
||||
else
|
||||
{
|
||||
Pitch = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things)
|
||||
|
@ -619,10 +612,6 @@ void Tilt(int &_x, int &_y, int &_z)
|
|||
// Check if it's on
|
||||
if (g_Config.Trigger.Type == g_Config.Trigger.TRIGGER_OFF) return;
|
||||
|
||||
// Set to zero
|
||||
Roll = 0;
|
||||
Pitch = 0;
|
||||
|
||||
// Select input method and return the x, y, x values
|
||||
if (g_Config.Trigger.Type == g_Config.Trigger.KEYBOARD)
|
||||
TiltWiimoteKeyboard(Roll, Pitch);
|
||||
|
@ -763,27 +752,26 @@ void FillReportAcc(wm_accel& _acc)
|
|||
}
|
||||
|
||||
// Rotate IR dot when rolling Wiimote
|
||||
void RotateIR(int _Roll, int& _x, int& _y)
|
||||
void RotateIRDot(int _Roll, int& _x, int& _y)
|
||||
{
|
||||
if (_Roll == 0)
|
||||
if (g_Config.Trigger.Range.Roll == 0 || _Roll == 0)
|
||||
return;
|
||||
|
||||
// The IR camera resolution is 1024x768
|
||||
float dot_x = _x - 1024 / 2;
|
||||
float dot_y = _y - 768 / 2;
|
||||
// The IR camera resolution is 1023x767
|
||||
float dot_x = _x - 1023.0f / 2;
|
||||
float dot_y = _y - 767.0f / 2;
|
||||
|
||||
float radius = sqrt(pow(dot_x, 2)+pow(dot_y, 2));
|
||||
float radian = atan(dot_y / dot_x);
|
||||
float radius = sqrt(pow(dot_x, 2) + pow(dot_y, 2));
|
||||
float radian = atan2(dot_y, dot_x);
|
||||
|
||||
_x = radius * cos(radian + InputCommon::Deg2Rad(float(_Roll))) + 1024 / 2;
|
||||
_y = radius * sin(radian + InputCommon::Deg2Rad(float(_Roll))) + 768 / 2;
|
||||
_x = radius * cos(radian + InputCommon::Deg2Rad((float)_Roll)) + 1023.0f / 2;
|
||||
_y = radius * sin(radian + InputCommon::Deg2Rad((float)_Roll)) + 767.0f / 2;
|
||||
|
||||
// Out of sight check
|
||||
if (_x < 0 || _x > 1023) _x = 0xFFFF;
|
||||
if (_y < 0 || _y > 767) _y = 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int Top = TOP, Left = LEFT, Right = RIGHT,
|
||||
Bottom = BOTTOM, SensorBarRadius = SENSOR_BAR_RADIUS;
|
||||
|
@ -817,11 +805,27 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
|||
if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
|
||||
|
||||
// Position calculation
|
||||
int y0 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight);
|
||||
int y0 = g_Config.iIRTop + g_Config.iIRHeight * MouseY;
|
||||
int y1 = y0;
|
||||
|
||||
// The distance between the x positions are two sensor bar radii
|
||||
int x0 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS;
|
||||
int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS;
|
||||
int x0 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
|
||||
int x1 = x0 + SENSOR_BAR_WIDTH;
|
||||
|
||||
RotateIRDot(Roll, x0, y0);
|
||||
RotateIRDot(Roll, x1, y1);
|
||||
|
||||
// Converted to IR data
|
||||
_ir0.x = x0 & 0xff; _ir0.xHi = x0 >> 8;
|
||||
_ir0.y = y0 & 0xff; _ir0.yHi = y0 >> 8;
|
||||
|
||||
_ir1.x = x1 & 0xff; _ir1.xHi = x1 >> 8;
|
||||
_ir1.y = y1 & 0xff; _ir1.yHi = y1 >> 8;
|
||||
|
||||
// The size can be between 0 and 15 and is probably not important
|
||||
_ir0.size = 10;
|
||||
_ir1.size = 10;
|
||||
|
||||
// Debugging for calibration
|
||||
/*
|
||||
if(!GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_RIGHT))
|
||||
|
@ -850,25 +854,6 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
|||
DEBUG_LOG(WIIMOTE, "x0:%03i x1:%03i y0:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i",
|
||||
x0, x1, y0, y1, Top, Left, Right, Bottom, SensorBarRadius
|
||||
);*/
|
||||
|
||||
// Converted to IR data
|
||||
// The width is 0 to 1023
|
||||
// The height is 0 to 767
|
||||
x0 = 1023 - x0;
|
||||
x1 = 1023 - x1;
|
||||
|
||||
RotateIR(Roll, x0, y0);
|
||||
RotateIR(Roll, x1, y1);
|
||||
|
||||
_ir0.x = x0 & 0xff; _ir0.xHi = x0 >> 8;
|
||||
_ir0.y = y0 & 0xff; _ir0.yHi = y0 >> 8;
|
||||
|
||||
_ir1.x = x1 & 0xff; _ir1.xHi = x1 >> 8;
|
||||
_ir1.y = y1 & 0xff; _ir1.yHi = y1 >> 8;
|
||||
|
||||
// The size can be between 0 and 15 and is probably not important
|
||||
_ir0.size = 10;
|
||||
_ir1.size = 10;
|
||||
}
|
||||
|
||||
// The 10 byte reporting used when an extension is connected
|
||||
|
@ -898,29 +883,25 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
|
|||
// If we are outside the screen leave the values at 0xff
|
||||
if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
|
||||
|
||||
int y1 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight);
|
||||
int y2 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight);
|
||||
int y1 = g_Config.iIRTop + g_Config.iIRHeight * MouseY;
|
||||
int y2 = y1;
|
||||
|
||||
int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS;
|
||||
int x2 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS;
|
||||
int x1 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
|
||||
int x2 = x1 + SENSOR_BAR_WIDTH;
|
||||
|
||||
RotateIRDot(Roll, x1, y1);
|
||||
RotateIRDot(Roll, x2, y2);
|
||||
|
||||
/* As with the extented report we settle with emulating two out of four
|
||||
possible objects the only difference is that we don't report any size of
|
||||
the tracked object here */
|
||||
x1 = 1023 - x1;
|
||||
x2 = 1023 - x2;
|
||||
|
||||
RotateIR(Roll, x1, y1);
|
||||
RotateIR(Roll, x2, y2);
|
||||
|
||||
_ir0.x1 = x1 & 0xff; _ir0.x1Hi = (x1 >> 8); // we are dealing with 2 bit values here
|
||||
_ir0.y1 = y1 & 0xff; _ir0.y1Hi = (y1 >> 8);
|
||||
|
||||
|
||||
_ir0.x2 = x2 & 0xff; _ir0.x2Hi = (x2 >> 8);
|
||||
_ir0.y2 = y2 & 0xff; _ir0.y2Hi = (y2 >> 8);
|
||||
|
||||
|
||||
// Debugging for calibration
|
||||
/*
|
||||
if(GetAsyncKeyState(VK_NUMPAD1))
|
||||
|
|
Loading…
Reference in New Issue