2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// 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 "wiimote_hid.h"
|
|
|
|
#include "main.h"
|
2009-07-05 04:29:00 +00:00
|
|
|
#include "ConfigPadDlg.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
#include "Config.h"
|
2009-07-08 07:16:26 +00:00
|
|
|
#include "EmuMain.h" // for WiiMoteEmu class
|
2009-07-10 06:16:22 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
|
|
|
#include "X11InputBase.h"
|
|
|
|
#endif
|
2009-02-23 06:15:48 +00:00
|
|
|
// Change Joystick
|
2009-07-05 05:59:03 +00:00
|
|
|
/* Function: When changing the joystick we save and load the settings and
|
|
|
|
update the PadMapping and PadState array. PadState[].joy is the gamepad
|
|
|
|
handle that is used to access the pad throughout the plugin. Joyinfo[].joy
|
|
|
|
is only used the first time the pads are checked. */
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::DoChangeJoystick()
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-14 17:08:32 +00:00
|
|
|
// Close the current pad, unless it's used by another slot
|
2009-12-13 04:31:38 +00:00
|
|
|
//if (PadMapping[Page].enabled) PadClose(Page);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Before changing the pad we save potential changes to the current pad
|
|
|
|
DoSave(true);
|
|
|
|
|
|
|
|
// Load the settings for the new Id
|
|
|
|
g_Config.Load(true);
|
2009-12-09 14:52:30 +00:00
|
|
|
|
2009-11-14 17:08:32 +00:00
|
|
|
UpdateGUI(Page); // Update the GUI
|
|
|
|
|
|
|
|
// Open the new pad
|
2009-12-13 04:31:38 +00:00
|
|
|
//if (WiiMoteEmu::PadMapping[Page].enabled) PadOpen(Page);
|
2009-11-14 17:08:32 +00:00
|
|
|
}
|
|
|
|
void WiimotePadConfigDialog::PadOpen(int Open) // Open for slot 1, 2, 3 or 4
|
|
|
|
{
|
|
|
|
// Check that we got a good pad
|
|
|
|
if (!WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Open].ID).Good)
|
|
|
|
{
|
|
|
|
DEBUG_LOG(WIIMOTE, "A bad pad was selected");
|
|
|
|
WiiMoteEmu::PadState[Open].joy = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_LOG(WIIMOTE, "Update the Slot %i handle to Id %i", Page, WiiMoteEmu::PadMapping[Open].ID);
|
|
|
|
WiiMoteEmu::PadState[Open].joy = SDL_JoystickOpen(WiiMoteEmu::PadMapping[Open].ID);
|
|
|
|
}
|
|
|
|
void WiimotePadConfigDialog::PadClose(int _Close) // Close for slot 1, 2, 3 or 4
|
|
|
|
{
|
|
|
|
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[_Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[_Close].joy);
|
|
|
|
WiiMoteEmu::PadState[_Close].joy = NULL;
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::DoChangeDeadZone(bool Left)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
if(Left)
|
|
|
|
{
|
|
|
|
float Rad = (float)WiiMoteEmu::PadMapping[Page].DeadZoneL * ((float)BoxW / 100.0) * 0.5;
|
|
|
|
m_bmpDeadZoneLeftIn[Page]->SetBitmap(CreateBitmapClear());
|
|
|
|
m_bmpDeadZoneLeftIn[Page]->SetSize(0, 0);
|
|
|
|
m_bmpDeadZoneLeftIn[Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
|
|
|
|
m_bmpDeadZoneLeftIn[Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
|
|
|
|
m_bmpDeadZoneLeftIn[Page]->Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float Rad = (float)WiiMoteEmu::PadMapping[Page].DeadZoneR * ((float)BoxW / 100.0) * 0.5;
|
|
|
|
m_bmpDeadZoneRightIn[Page]->SetBitmap(CreateBitmapClear());
|
|
|
|
m_bmpDeadZoneRightIn[Page]->SetSize(0, 0);
|
|
|
|
m_bmpDeadZoneRightIn[Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
|
|
|
|
m_bmpDeadZoneRightIn[Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
|
|
|
|
m_bmpDeadZoneRightIn[Page]->Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Change settings
|
|
|
|
|
|
|
|
// Set the button text for all four Wiimotes
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::SetButtonTextAll(int id, char text[128])
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-29 17:58:52 +00:00
|
|
|
for (int i = 0; i < 1; i++) // We've got only 1 currently
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-14 17:08:32 +00:00
|
|
|
// Safety check to avoid crash
|
|
|
|
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
|
|
|
|
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Page].ID].Name)
|
|
|
|
SetButtonText(id, text, i);
|
2009-02-23 06:15:48 +00:00
|
|
|
};
|
|
|
|
}
|
2009-11-14 17:08:32 +00:00
|
|
|
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::SaveButtonMappingAll(int Slot)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-14 17:08:32 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
2009-11-13 09:11:24 +00:00
|
|
|
{
|
2009-11-14 17:08:32 +00:00
|
|
|
// This can occur when no gamepad is detected
|
|
|
|
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID && WiiMoteEmu::PadMapping[i].ID >= 0)
|
|
|
|
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Slot].ID].Name)
|
|
|
|
SaveButtonMapping(i, false, Slot);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set dialog items from saved values
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
|
2009-11-29 17:58:52 +00:00
|
|
|
{
|
2009-02-23 06:15:48 +00:00
|
|
|
// Temporary storage
|
|
|
|
wxString tmp;
|
|
|
|
|
|
|
|
// Update selected gamepad
|
|
|
|
m_Joyname[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].ID);
|
|
|
|
|
|
|
|
// Update the enabled checkbox
|
|
|
|
//m_Joyattach[controller]->SetValue(PadMapping[controller].enabled == 1 ? true : false);
|
|
|
|
|
|
|
|
// Update the deadzone and controller type controls
|
|
|
|
m_ComboDeadZoneLeft[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].DeadZoneL);
|
|
|
|
m_ComboDeadZoneRight[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].DeadZoneR);
|
|
|
|
m_ComboDiagonal[controller]->SetValue(wxString::FromAscii(WiiMoteEmu::PadMapping[controller].SDiagonal.c_str()));
|
|
|
|
m_CheckC2S[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bCircle2Square);
|
2009-12-06 01:15:13 +00:00
|
|
|
m_CheckRumble[controller]->SetValue(WiiMoteEmu::PadMapping[controller].Rumble);
|
|
|
|
m_RumbleStrength[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].RumbleStrength);
|
2009-12-09 14:52:30 +00:00
|
|
|
m_TriggerType[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].triggertype);
|
|
|
|
|
2009-12-17 14:15:56 +00:00
|
|
|
m_TiltTypeWM[controller]->SetSelection(g_Config.Tilt.TypeWM);
|
|
|
|
m_TiltTypeNC[controller]->SetSelection(g_Config.Tilt.TypeNC);
|
2009-12-14 03:30:21 +00:00
|
|
|
m_TiltComboRangeRoll[controller]->SetSelection(g_Config.Tilt.Range.RollDegree / 5 - 1); // 5 to 180, step 5
|
|
|
|
m_TiltComboRangePitch[controller]->SetSelection(g_Config.Tilt.Range.PitchDegree / 5 - 1); // 5 to 180, step 5
|
|
|
|
m_TiltRollSwing[controller]->SetValue(g_Config.Tilt.Range.RollSwing);
|
|
|
|
m_TiltPitchSwing[controller]->SetValue(g_Config.Tilt.Range.PitchSwing);
|
|
|
|
m_TiltRollInvert[controller]->SetValue(g_Config.Tilt.RollInvert);
|
|
|
|
m_TiltPitchInvert[controller]->SetValue(g_Config.Tilt.PitchInvert);
|
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
for (int i = 0; i < AN_CONTROLS; i++)
|
|
|
|
{
|
|
|
|
tmp << WiiMoteEmu::PadMapping[controller].Axis.keyForControls[i];
|
|
|
|
m_Button_Analog[i][controller]->SetLabel(tmp);
|
|
|
|
tmp.clear();
|
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Wiimote
|
2009-02-28 01:26:56 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-10 05:30:19 +00:00
|
|
|
for (int x = 0; x < WM_CONTROLS; x++)
|
2009-12-09 14:52:30 +00:00
|
|
|
{
|
2009-07-10 05:30:19 +00:00
|
|
|
m_Button_Wiimote[x][controller]->SetLabel(wxString::FromAscii(
|
|
|
|
InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.keyForControls[x]).c_str()));
|
2009-12-09 14:52:30 +00:00
|
|
|
}
|
2009-07-09 04:19:49 +00:00
|
|
|
if(g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
|
|
|
{
|
2009-07-10 05:30:19 +00:00
|
|
|
for (int x = 0; x < NC_CONTROLS; x++)
|
|
|
|
m_Button_NunChuck[x][controller]->SetLabel(wxString::FromAscii(
|
|
|
|
InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.keyForControls[x]).c_str()));
|
2009-07-09 04:19:49 +00:00
|
|
|
}
|
|
|
|
else if(g_Config.iExtensionConnected == EXT_CLASSIC_CONTROLLER)
|
|
|
|
{
|
2009-07-10 05:30:19 +00:00
|
|
|
for (int x = 0; x < CC_CONTROLS; x++)
|
|
|
|
m_Button_Classic[x][controller]->SetLabel(wxString::FromAscii(
|
|
|
|
InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Cc.keyForControls[x]).c_str()));
|
2009-07-09 04:19:49 +00:00
|
|
|
}
|
|
|
|
else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < GH3_CONTROLS; x++)
|
|
|
|
m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii(
|
|
|
|
InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].GH3c.keyForControls[x]).c_str()));
|
|
|
|
}
|
2009-07-10 06:16:22 +00:00
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
|
|
|
char keyStr[10] = {0};
|
|
|
|
for (int x = 0; x < WM_CONTROLS; x++)
|
|
|
|
{
|
|
|
|
InputCommon::XKeyToString(WiiMoteEmu::PadMapping[controller].Wm.keyForControls[x], keyStr);
|
|
|
|
m_Button_Wiimote[x][controller]->SetLabel(wxString::FromAscii(keyStr));
|
|
|
|
}
|
|
|
|
if(g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < NC_CONTROLS; x++)
|
|
|
|
{
|
|
|
|
InputCommon::XKeyToString(WiiMoteEmu::PadMapping[controller].Nc.keyForControls[x], keyStr);
|
|
|
|
m_Button_NunChuck[x][controller]->SetLabel(wxString::FromAscii(keyStr));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(g_Config.iExtensionConnected == EXT_CLASSIC_CONTROLLER)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < CC_CONTROLS; x++)
|
|
|
|
{
|
|
|
|
InputCommon::XKeyToString(WiiMoteEmu::PadMapping[controller].Cc.keyForControls[x], keyStr);
|
|
|
|
m_Button_Classic[x][controller]->SetLabel(wxString::FromAscii(keyStr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER)
|
2009-07-09 06:50:22 +00:00
|
|
|
{
|
|
|
|
for (int x = 0; x < GH3_CONTROLS; x++)
|
|
|
|
{
|
2009-07-10 06:16:22 +00:00
|
|
|
InputCommon::XKeyToString(WiiMoteEmu::PadMapping[controller].GH3c.keyForControls[x], keyStr);
|
2009-07-09 06:50:22 +00:00
|
|
|
m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii(keyStr));
|
|
|
|
}
|
|
|
|
}
|
2009-02-28 01:26:56 +00:00
|
|
|
#endif
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "m_bWmA[%i] = %i = %s", controller, WiiMoteEmu::PadMapping[controller].Wm.keyForControls[0], InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.keyForControls[0]).c_str());
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Populate the PadMapping array with the dialog items settings (for example
|
|
|
|
selected joystick, enabled or disabled status and so on) */
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int FromSlot)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Temporary storage
|
|
|
|
long value;
|
|
|
|
|
|
|
|
// Save from or to the same or different slots
|
|
|
|
if (FromSlot == -1) FromSlot = controller;
|
|
|
|
|
|
|
|
// Replace "" with "-1" in the GUI controls
|
|
|
|
ToBlank(false);
|
|
|
|
|
|
|
|
/* Set physical device Id. GetSelection() should never be -1 here so we don't check that it's zero or higher. If it's possible that it can be
|
|
|
|
-1 that's a bug that should be fixed. Because the m_Joyname[] combo box should always show <No Gamepad Detected>, or a gamepad name, not a
|
|
|
|
a blank selection. */
|
2009-02-28 01:26:56 +00:00
|
|
|
if (!DontChangeId)
|
2009-11-14 17:08:32 +00:00
|
|
|
WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
2009-02-23 06:15:48 +00:00
|
|
|
// Set enabled or disable status
|
2009-02-28 01:26:56 +00:00
|
|
|
if (FromSlot == controller)
|
2009-12-09 14:52:30 +00:00
|
|
|
WiiMoteEmu::PadMapping[controller].enabled = true; // Only enable one
|
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Set other settings
|
|
|
|
WiiMoteEmu::PadMapping[controller].DeadZoneL = m_ComboDeadZoneLeft[FromSlot]->GetSelection();
|
|
|
|
WiiMoteEmu::PadMapping[controller].DeadZoneR = m_ComboDeadZoneRight[FromSlot]->GetSelection();
|
|
|
|
WiiMoteEmu::PadMapping[controller].SDiagonal = m_ComboDiagonal[FromSlot]->GetLabel().mb_str();
|
2009-12-09 14:52:30 +00:00
|
|
|
WiiMoteEmu::PadMapping[controller].bCircle2Square = m_CheckC2S[FromSlot]->IsChecked();
|
|
|
|
WiiMoteEmu::PadMapping[controller].Rumble = m_CheckRumble[FromSlot]->IsChecked();
|
|
|
|
WiiMoteEmu::PadMapping[controller].RumbleStrength = m_RumbleStrength[FromSlot]->GetSelection();
|
|
|
|
WiiMoteEmu::PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
for (int i = 0; i < AN_CONTROLS; i++)
|
|
|
|
{
|
|
|
|
m_Button_Analog[i][FromSlot]->GetLabel().ToLong(&value);
|
|
|
|
WiiMoteEmu::PadMapping[controller].Axis.keyForControls[i] = value;
|
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "WiiMoteEmu::PadMapping[%i].ID = %i, m_Joyname[%i]->GetSelection() = %i",
|
2009-02-23 06:15:48 +00:00
|
|
|
// controller, WiiMoteEmu::PadMapping[controller].ID, FromSlot, m_Joyname[FromSlot]->GetSelection());
|
|
|
|
|
|
|
|
// Replace "-1" with ""
|
|
|
|
ToBlank();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save keyboard key mapping
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-12-08 19:58:19 +00:00
|
|
|
if (IDB_WM_A <= Id && Id <= IDB_WM_SHAKE)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-07-08 07:16:26 +00:00
|
|
|
WiiMoteEmu::PadMapping[Controller].Wm.keyForControls[Id - IDB_WM_A] = Key;
|
|
|
|
}
|
|
|
|
else if (IDB_NC_Z <= Id && Id <= IDB_NC_SHAKE)
|
|
|
|
{
|
|
|
|
WiiMoteEmu::PadMapping[Controller].Nc.keyForControls[Id - IDB_NC_Z] = Key;
|
|
|
|
}
|
|
|
|
else if (IDB_CC_A <= Id && Id <= IDB_CC_RD)
|
|
|
|
{
|
|
|
|
WiiMoteEmu::PadMapping[Controller].Cc.keyForControls[Id - IDB_CC_A] = Key;
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
2009-07-09 03:58:53 +00:00
|
|
|
else if (IDB_GH3_GREEN <= Id && Id <= IDB_GH3_STRUM_DOWN)
|
|
|
|
{
|
|
|
|
WiiMoteEmu::PadMapping[Controller].GH3c.keyForControls[Id - IDB_GH3_GREEN] = Key;
|
|
|
|
}
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "WiiMoteEmu::PadMapping[%i].Wm.A = %i", Controller, WiiMoteEmu::PadMapping[Controller].Wm.A);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
2009-07-05 05:59:03 +00:00
|
|
|
void WiimotePadConfigDialog::ToBlank(bool _ToBlank)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
if (!ControlsCreated) return;
|
|
|
|
|
2009-06-03 20:09:48 +00:00
|
|
|
for (int j = 0; j < 1; j++)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-07-05 05:59:03 +00:00
|
|
|
if(_ToBlank)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
2009-12-09 14:52:30 +00:00
|
|
|
#if !defined _WIN32 && !wxCHECK_VERSION(2, 9, 0)
|
2009-10-05 07:31:38 +00:00
|
|
|
if(GetButtonText(i, j).ToAscii() == "-1")
|
|
|
|
SetButtonText(i, (char *)"", j);
|
|
|
|
#else
|
|
|
|
if(GetButtonText(i, j) == wxT("-1")) SetButtonText(i, "", j);
|
|
|
|
#endif
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
2009-07-05 05:59:03 +00:00
|
|
|
if(GetButtonText(i, j).IsEmpty())
|
|
|
|
SetButtonText(i, (char *)"-1", j);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update the textbox for the buttons
|
2009-11-29 17:58:52 +00:00
|
|
|
void WiimotePadConfigDialog::SetButtonText(int id, const char text[128], int _Page)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Set controller value
|
|
|
|
int controller;
|
2009-12-09 14:52:30 +00:00
|
|
|
if (_Page == -1) controller = Page;
|
|
|
|
else controller = _Page;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R)
|
2009-12-13 04:31:38 +00:00
|
|
|
m_Button_Analog[id - IDB_ANALOG_LEFT_X][controller]->SetLabel(wxString::FromAscii(text));
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
|
2009-12-13 04:31:38 +00:00
|
|
|
m_Button_Wiimote[id - IDB_WM_A][controller]->SetLabel(wxString::FromAscii(text));
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
|
2009-12-13 04:31:38 +00:00
|
|
|
m_Button_NunChuck[id - IDB_NC_Z][controller]->SetLabel(wxString::FromAscii(text));
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
|
2009-12-13 04:31:38 +00:00
|
|
|
m_Button_Classic[id - IDB_CC_A][controller]->SetLabel(wxString::FromAscii(text));
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
|
2009-12-13 04:31:38 +00:00
|
|
|
m_Button_GH3[id - IDB_GH3_GREEN][controller]->SetLabel(wxString::FromAscii(text));
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "SetButtonText: %s", text);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the text in the textbox for the buttons
|
2009-07-05 04:29:00 +00:00
|
|
|
wxString WiimotePadConfigDialog::GetButtonText(int id, int _Page)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "GetButtonText: %i", id);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Set controller value
|
|
|
|
int controller;
|
2009-12-09 14:52:30 +00:00
|
|
|
if (_Page == -1) controller = Page;
|
|
|
|
else controller = _Page;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R)
|
|
|
|
return m_Button_Analog[id - IDB_ANALOG_LEFT_X][controller]->GetLabel();
|
|
|
|
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
|
|
|
|
return m_Button_Wiimote[id - IDB_WM_A][controller]->GetLabel();
|
|
|
|
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
|
|
|
|
return m_Button_NunChuck[id - IDB_NC_Z][controller]->GetLabel();
|
|
|
|
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
|
|
|
|
return m_Button_Classic[id - IDB_CC_A][controller]->GetLabel();
|
|
|
|
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
|
|
|
|
return m_Button_GH3[id - IDB_GH3_GREEN][controller]->GetLabel();
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
return wxString();
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Configure button mapping
|
|
|
|
|
|
|
|
// Wait for button press
|
2009-07-05 05:59:03 +00:00
|
|
|
|
|
|
|
/* Loop or timer: There are basically two ways to do this. With a while() or
|
|
|
|
for() loop, or with a timer. The downside with the while() or for() loop is
|
|
|
|
that there is no way to stop it if the user should select to configure
|
|
|
|
another button while we are still in an old loop. What will happen then is
|
|
|
|
that we start another parallel loop (at least in Windows) that blocks the
|
|
|
|
old loop. And our only option to wait for the old loop to finish is with a
|
|
|
|
new loop, and that will block the old loop for as long as it's going
|
|
|
|
on. Therefore a timer is easier to control. */
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::GetButtons(wxCommandEvent& event)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-29 17:58:52 +00:00
|
|
|
if (event.GetEventType() != wxEVT_COMMAND_BUTTON_CLICKED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_ButtonMappingTimer->IsRunning())
|
|
|
|
return;
|
|
|
|
|
2009-12-13 04:31:38 +00:00
|
|
|
wxButton* pButton = (wxButton *)event.GetEventObject();
|
|
|
|
OldLabel = pButton->GetLabel();
|
|
|
|
pButton->SetLabel(wxT("<Move Axis>"));
|
|
|
|
DoGetButtons(pButton->GetId());
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 05:59:03 +00:00
|
|
|
void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Collect the starting values
|
|
|
|
|
|
|
|
// Get the current controller
|
|
|
|
int Controller = Page;
|
|
|
|
int PadID = WiiMoteEmu::PadMapping[Controller].ID;
|
|
|
|
|
|
|
|
// Get the controller and trigger type
|
|
|
|
int TriggerType = WiiMoteEmu::PadMapping[Controller].triggertype;
|
|
|
|
|
|
|
|
// Collect the accepted buttons for this slot
|
2009-07-05 05:59:03 +00:00
|
|
|
bool LeftRight = (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-07-05 05:59:03 +00:00
|
|
|
bool Axis = (_GetId >= IDB_ANALOG_LEFT_X && _GetId <= IDB_TRIGGER_R)
|
2009-02-23 06:15:48 +00:00
|
|
|
// Don't allow SDL axis input for the shoulder buttons if XInput is selected
|
2009-07-05 05:59:03 +00:00
|
|
|
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R) );
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
|
|
|
|
|
2009-11-29 17:58:52 +00:00
|
|
|
bool Button = (_GetId >= IDB_WM_A && _GetId <= IDB_GH3_STRUM_DOWN);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-11-29 17:58:52 +00:00
|
|
|
bool Hat = (_GetId >= IDB_WM_A && _GetId <= IDB_GH3_STRUM_DOWN);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
bool NoTriggerFilter = g_Config.bNoTriggerFilter;
|
|
|
|
|
|
|
|
// Values used in this function
|
|
|
|
char format[128];
|
|
|
|
int Seconds = 4; // Seconds to wait for
|
2009-11-14 17:08:32 +00:00
|
|
|
int TimesPerSecond = 40; // How often to run the check
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Values returned from InputCommon::GetButton()
|
2009-11-29 17:58:52 +00:00
|
|
|
int value; // Axis value or Hat value
|
2009-02-23 06:15:48 +00:00
|
|
|
int type; // Button type
|
2009-11-29 17:58:52 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
int pressed = 0;
|
|
|
|
bool Succeed = false;
|
|
|
|
bool Stop = false; // Stop the timer
|
|
|
|
|
2009-09-15 02:12:55 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "Before (%i) Id:%i %i IsRunning:%i",
|
2009-07-05 05:59:03 +00:00
|
|
|
// GetButtonWaitingTimer, GetButtonWaitingID, _GetId, m_ButtonMappingTimer->IsRunning());
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// If the Id has changed or the timer is not running we should start one
|
2009-07-05 05:59:03 +00:00
|
|
|
if( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() )
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
if(m_ButtonMappingTimer->IsRunning())
|
|
|
|
m_ButtonMappingTimer->Stop();
|
|
|
|
|
|
|
|
// Save the button Id
|
2009-07-05 05:59:03 +00:00
|
|
|
GetButtonWaitingID = _GetId;
|
2009-11-29 17:58:52 +00:00
|
|
|
GetButtonWaitingTimer = 0;
|
2009-02-23 06:15:48 +00:00
|
|
|
// Reset the key in case we happen to have an old one
|
|
|
|
g_Pressed = 0;
|
|
|
|
|
|
|
|
// Start the timer
|
|
|
|
#if wxUSE_TIMER
|
2009-12-13 04:31:38 +00:00
|
|
|
m_ButtonMappingTimer->Start(1000 / TimesPerSecond);
|
2009-02-23 06:15:48 +00:00
|
|
|
#endif
|
2009-12-13 04:31:38 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Timer Started: Pad:%i _GetId:%i "
|
|
|
|
"Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i",
|
2009-07-05 05:59:03 +00:00
|
|
|
WiiMoteEmu::PadMapping[Controller].ID, _GetId,
|
2009-02-23 06:15:48 +00:00
|
|
|
Axis, LeftRight, XInput, Button, Hat);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for buttons
|
|
|
|
|
2009-12-13 04:31:38 +00:00
|
|
|
// If there is a timer we should not create a new one
|
2009-12-04 12:22:36 +00:00
|
|
|
else if (WiiMoteEmu::NumGoodPads >0)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
InputCommon::GetButton(
|
2009-11-14 17:08:32 +00:00
|
|
|
WiiMoteEmu::joyinfo[PadID].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
|
2009-02-23 06:15:48 +00:00
|
|
|
g_Pressed, value, type, pressed, Succeed, Stop,
|
|
|
|
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process results
|
|
|
|
|
|
|
|
// Count each time
|
|
|
|
GetButtonWaitingTimer++;
|
|
|
|
|
|
|
|
// This is run every second
|
|
|
|
if(GetButtonWaitingTimer % TimesPerSecond == 0)
|
|
|
|
{
|
|
|
|
// Current time
|
|
|
|
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
|
|
|
|
|
|
|
|
// Update text
|
2009-11-29 17:58:52 +00:00
|
|
|
sprintf(format, "[ %d ]", TmpTime);
|
2009-07-05 05:59:03 +00:00
|
|
|
SetButtonText(_GetId, format);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 17:58:52 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Time's up
|
|
|
|
if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
|
|
|
|
{
|
|
|
|
Stop = true;
|
2009-11-29 17:58:52 +00:00
|
|
|
// Revert back to old label
|
|
|
|
SetButtonText(_GetId, OldLabel.ToAscii());
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we got a button
|
2009-11-14 17:08:32 +00:00
|
|
|
if(Succeed)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-07-08 07:16:26 +00:00
|
|
|
Stop = true;
|
2009-11-29 17:58:52 +00:00
|
|
|
// We need to assign hat special code
|
|
|
|
if (type == InputCommon::CTL_HAT)
|
|
|
|
{
|
|
|
|
// Index of pressed starts from 0
|
|
|
|
if (value & SDL_HAT_UP) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_UP;
|
|
|
|
else if (value & SDL_HAT_DOWN) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_DOWN;
|
|
|
|
else if (value & SDL_HAT_LEFT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_LEFT;
|
|
|
|
else if (value & SDL_HAT_RIGHT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_RIGHT;
|
|
|
|
else pressed = -1;
|
|
|
|
}
|
|
|
|
if (_GetId >= IDB_WM_A && _GetId <= IDB_GH3_STRUM_DOWN)
|
|
|
|
{
|
|
|
|
// Better make the pad button code far from virtual key code
|
|
|
|
SaveKeyboardMapping(Page, ClickedButton->GetId(), 0x1000 + pressed);
|
|
|
|
sprintf(format, "PAD: %d", pressed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Update the button mapping for all slots that use this device. (It
|
|
|
|
doesn't make sense to have several slots controlled by the same
|
|
|
|
device, but several DirectInput instances of different but identical
|
|
|
|
devices may possible have the same id, I don't know. So we have to
|
|
|
|
do this. The user may also have selected the same device for several
|
|
|
|
disabled slots. */
|
|
|
|
SaveButtonMappingAll(Controller);
|
|
|
|
// Write the number of the pressed button to the text box
|
|
|
|
sprintf(format, "%d", pressed);
|
|
|
|
}
|
2009-07-05 05:59:03 +00:00
|
|
|
SetButtonTextAll(_GetId, format);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop the timer
|
2009-11-14 17:08:32 +00:00
|
|
|
if(Stop)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Timer Stopped for Pad:%i _GetId:%i",
|
2009-07-05 05:59:03 +00:00
|
|
|
WiiMoteEmu::PadMapping[Controller].ID, _GetId);
|
2009-11-29 17:58:52 +00:00
|
|
|
|
|
|
|
m_ButtonMappingTimer->Stop();
|
|
|
|
GetButtonWaitingTimer = 0;
|
|
|
|
GetButtonWaitingID = 0;
|
|
|
|
ClickedButton = NULL;
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we got a bad button
|
|
|
|
if(g_Pressed == -1)
|
|
|
|
{
|
|
|
|
// Update text
|
2009-11-29 17:58:52 +00:00
|
|
|
SetButtonTextAll(_GetId, (char *)"PAD: -1");
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Notify the user
|
2009-07-30 07:08:31 +00:00
|
|
|
wxMessageBox(wxString::Format(
|
|
|
|
wxT("You selected a key with a to low key code (%i), please")
|
|
|
|
wxT(" select another key with a higher key code."), pressed)
|
2009-02-23 06:15:48 +00:00
|
|
|
, wxT("Notice"), wxICON_INFORMATION);
|
|
|
|
}
|
2009-07-08 07:16:26 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Debugging
|
|
|
|
/*
|
2009-09-15 02:12:55 +00:00
|
|
|
DEBUG_LOG(WIIMOTE, "Change: %i %i %i %i '%s' '%s' '%s' '%s'",
|
2009-02-23 06:15:48 +00:00
|
|
|
WiiMoteEmu::PadMapping[0].halfpress, WiiMoteEmu::PadMapping[1].halfpress, WiiMoteEmu::PadMapping[2].halfpress, WiiMoteEmu::PadMapping[3].halfpress,
|
|
|
|
m_JoyButtonHalfpress[0]->GetValue().c_str(), m_JoyButtonHalfpress[1]->GetValue().c_str(), m_JoyButtonHalfpress[2]->GetValue().c_str(), m_JoyButtonHalfpress[3]->GetValue().c_str()
|
|
|
|
);*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Show current input status
|
|
|
|
// Convert the 0x8000 range values to BoxW and BoxH for the plot
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::Convert2Box(int &x)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Border adjustment
|
|
|
|
int BoxW_ = BoxW - 2; int BoxH_ = BoxH - 2;
|
|
|
|
|
|
|
|
// Convert values
|
|
|
|
x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the input status boxes
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::PadGetStatus()
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-11-14 17:08:32 +00:00
|
|
|
//DEBUG_LOG(WIIMOTE, "SDL_WasInit: %i", SDL_WasInit(0));
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
/* Return if it's not enabled or not detected. The ID should never be less than zero here,
|
|
|
|
it can only be that because of a manual ini file change, but we make that check anway. */
|
|
|
|
if(!WiiMoteEmu::PadMapping[Page].enabled
|
|
|
|
|| WiiMoteEmu::PadMapping[Page].ID < 0
|
|
|
|
|| WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_tStatusLeftIn[Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusLeftOut[Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusRightIn[Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusRightOut[Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_TriggerStatusL[Page]->SetLabel(wxT("000"));
|
|
|
|
m_TriggerStatusR[Page]->SetLabel(wxT("000"));
|
2009-02-23 06:15:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get physical device status
|
2009-11-14 17:08:32 +00:00
|
|
|
int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID;
|
2009-02-23 06:15:48 +00:00
|
|
|
int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype;
|
|
|
|
|
|
|
|
// Check that Dolphin is in focus, otherwise don't update the pad status
|
|
|
|
//if (IsFocus())
|
2009-11-14 17:08:32 +00:00
|
|
|
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Analog stick
|
|
|
|
|
|
|
|
// Get original values
|
|
|
|
int main_x = WiiMoteEmu::PadState[Page].Axis.Lx;
|
|
|
|
int main_y = WiiMoteEmu::PadState[Page].Axis.Ly;
|
|
|
|
int right_x = WiiMoteEmu::PadState[Page].Axis.Rx;
|
|
|
|
int right_y = WiiMoteEmu::PadState[Page].Axis.Ry;
|
|
|
|
|
|
|
|
// Get adjusted values
|
|
|
|
int main_x_after = main_x, main_y_after = main_y;
|
|
|
|
int right_x_after = right_x, right_y_after = right_y;
|
2009-12-09 14:52:30 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Produce square
|
|
|
|
if(WiiMoteEmu::PadMapping[Page].bCircle2Square)
|
|
|
|
{
|
2009-07-09 02:23:40 +00:00
|
|
|
InputCommon::Square2Circle(main_x_after, main_y_after, Page, WiiMoteEmu::PadMapping[Page].SDiagonal, true);
|
2009-12-09 14:52:30 +00:00
|
|
|
}
|
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Check dead zone
|
|
|
|
float DeadZoneLeft = (float)WiiMoteEmu::PadMapping[Page].DeadZoneL / 100.0;
|
|
|
|
float DeadZoneRight = (float)WiiMoteEmu::PadMapping[Page].DeadZoneR / 100.0;
|
|
|
|
if (InputCommon::IsDeadZone(DeadZoneLeft, main_x_after, main_y_after))
|
|
|
|
{
|
|
|
|
main_x_after = 0;
|
|
|
|
main_y_after = 0;
|
|
|
|
}
|
|
|
|
if (InputCommon::IsDeadZone(DeadZoneRight, right_x_after, right_y_after))
|
|
|
|
{
|
|
|
|
right_x_after = 0;
|
|
|
|
right_y_after = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the adjusted angles in the status box
|
|
|
|
// Change 0x8000 to 180
|
|
|
|
/*
|
|
|
|
float x8000 = 0x8000;
|
|
|
|
main_x_after = main_x_after * (180 / x8000);
|
|
|
|
main_y_after = main_y_after * (180 / x8000);
|
|
|
|
float f_main_x_after = (float)main_x_after;
|
|
|
|
float f_main_y_after = (float)main_y_after;
|
|
|
|
WiiMoteEmu::AdjustAngles(f_main_x_after, f_main_y_after);
|
|
|
|
//WiiMoteEmu::AdjustAngles(f_main_x_after, f_main_y_after, true);
|
|
|
|
main_x_after = (int)f_main_x_after;
|
|
|
|
main_y_after = (int)f_main_y_after;
|
|
|
|
// Change back 180 to 0x8000
|
|
|
|
main_x_after = main_x_after * (x8000 / 180);
|
|
|
|
main_y_after = main_y_after * (x8000 / 180);
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Convert the values to fractions
|
|
|
|
float f_x = main_x / 32767.0;
|
|
|
|
float f_y = main_y / 32767.0;
|
|
|
|
float f_x_aft = main_x_after / 32767.0;
|
|
|
|
float f_y_aft = main_y_after / 32767.0;
|
|
|
|
|
|
|
|
float f_Rx = right_x / 32767.0;
|
|
|
|
float f_Ry = right_y / 32767.0;
|
|
|
|
float f_Rx_aft = right_x_after / 32767.0;
|
|
|
|
float f_Ry_aft = right_y_after / 32767.0;
|
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
m_tStatusLeftIn[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("x:%1.2f y:%1.2f"), f_x, f_y
|
|
|
|
));
|
2009-12-09 14:52:30 +00:00
|
|
|
m_tStatusLeftOut[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("x:%1.2f y:%1.2f"), f_x_aft, f_y_aft
|
|
|
|
));
|
2009-12-09 14:52:30 +00:00
|
|
|
m_tStatusRightIn[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("x:%1.2f y:%1.2f"), f_Rx, f_Ry
|
|
|
|
));
|
2009-12-09 14:52:30 +00:00
|
|
|
m_tStatusRightOut[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("x:%1.2f y:%1.2f"), f_Rx_aft, f_Ry_aft
|
|
|
|
));
|
|
|
|
|
|
|
|
// Adjust the values for the plot
|
|
|
|
Convert2Box(main_x); Convert2Box(main_y);
|
|
|
|
Convert2Box(right_x); Convert2Box(right_y);
|
|
|
|
|
|
|
|
Convert2Box(main_x_after); Convert2Box(main_y_after);
|
|
|
|
Convert2Box(right_x_after); Convert2Box(right_y_after);
|
|
|
|
|
|
|
|
// Adjust the dot
|
|
|
|
m_bmpDotLeftIn[Page]->SetPosition(wxPoint(main_x, main_y));
|
|
|
|
m_bmpDotLeftOut[Page]->SetPosition(wxPoint(main_x_after, main_y_after));
|
|
|
|
m_bmpDotRightIn[Page]->SetPosition(wxPoint(right_x, right_y));
|
|
|
|
m_bmpDotRightOut[Page]->SetPosition(wxPoint(right_x_after, right_y_after));
|
|
|
|
|
|
|
|
|
|
|
|
// Get the trigger values
|
|
|
|
int TriggerLeft = WiiMoteEmu::PadState[Page].Axis.Tl;
|
|
|
|
int TriggerRight = WiiMoteEmu::PadState[Page].Axis.Tr;
|
|
|
|
|
|
|
|
// Convert the triggers values
|
|
|
|
if (WiiMoteEmu::PadMapping[Page].triggertype == InputCommon::CTL_TRIGGER_SDL)
|
|
|
|
{
|
|
|
|
TriggerLeft = InputCommon::Pad_Convert(TriggerLeft);
|
|
|
|
TriggerRight = InputCommon::Pad_Convert(TriggerRight);
|
|
|
|
}
|
|
|
|
|
2009-12-09 14:52:30 +00:00
|
|
|
m_TriggerStatusL[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("%03i"), TriggerLeft));
|
2009-12-09 14:52:30 +00:00
|
|
|
m_TriggerStatusR[Page]->SetLabel(wxString::Format(
|
2009-02-23 06:15:48 +00:00
|
|
|
wxT("%03i"), TriggerRight));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populate the advanced tab
|
2009-07-05 04:29:00 +00:00
|
|
|
void WiimotePadConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Show the current status
|
2009-11-14 17:08:32 +00:00
|
|
|
/*
|
2009-02-23 06:15:48 +00:00
|
|
|
#ifdef SHOW_PAD_STATUS
|
2009-11-14 17:08:32 +00:00
|
|
|
m_pStatusBar->SetLabel(wxString::Format(
|
|
|
|
"%s", ShowStatus(notebookpage).c_str()
|
|
|
|
));
|
|
|
|
#endif*/
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
//LogMsg("Abc%s\n", ShowStatus(notebookpage).c_str());
|
|
|
|
|
|
|
|
PadGetStatus();
|
|
|
|
}
|
2009-07-05 04:29:00 +00:00
|
|
|
|