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-12-27 19:31:02 +00:00
|
|
|
#include "EmuDefinitions.h"
|
|
|
|
|
2009-07-10 06:16:22 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
|
|
|
#include "X11InputBase.h"
|
|
|
|
#endif
|
2009-12-09 14:52:30 +00:00
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
|
|
|
void WiimotePadConfigDialog::ToBlank(bool ToBlank, int Id)
|
2009-11-14 17:08:32 +00:00
|
|
|
{
|
2009-12-27 19:31:02 +00:00
|
|
|
if (!ControlsCreated)
|
2009-11-14 17:08:32 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
if(ToBlank)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-12-27 19:31:02 +00:00
|
|
|
if (GetButtonText(Id) == wxString(wxT("-1")))
|
|
|
|
SetButtonText(Id, wxString());
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-27 19:31:02 +00:00
|
|
|
if (GetButtonText(Id).IsEmpty())
|
|
|
|
SetButtonText(Id, wxString(wxT("-1")));
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
void WiimotePadConfigDialog::DoChangeDeadZone()
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2009-12-27 19:31:02 +00:00
|
|
|
float Rad;
|
|
|
|
|
|
|
|
Rad = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneL * ((float)BoxW / 100.0) * 0.5;
|
|
|
|
m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapClear());
|
|
|
|
m_bmpDeadZoneLeftIn[m_Page]->SetSize(0, 0);
|
|
|
|
m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
|
|
|
|
m_bmpDeadZoneLeftIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
|
|
|
|
m_bmpDeadZoneLeftIn[m_Page]->Refresh();
|
|
|
|
|
|
|
|
Rad = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneR * ((float)BoxW / 100.0) * 0.5;
|
|
|
|
m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapClear());
|
|
|
|
m_bmpDeadZoneRightIn[m_Page]->SetSize(0, 0);
|
|
|
|
m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad));
|
|
|
|
m_bmpDeadZoneRightIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad));
|
|
|
|
m_bmpDeadZoneRightIn[m_Page]->Refresh();
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set dialog items from saved values
|
|
|
|
|
|
|
|
|
|
|
|
// Update the textbox for the buttons
|
2009-12-27 19:31:02 +00:00
|
|
|
void WiimotePadConfigDialog::SetButtonText(int id, const wxString &str)
|
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-27 19:31:02 +00:00
|
|
|
m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->SetLabel(str);
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
|
2009-12-27 19:31:02 +00:00
|
|
|
m_Button_Wiimote[id - IDB_WM_A][m_Page]->SetLabel(str);
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
|
2009-12-27 19:31:02 +00:00
|
|
|
m_Button_NunChuck[id - IDB_NC_Z][m_Page]->SetLabel(str);
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
|
2009-12-27 19:31:02 +00:00
|
|
|
m_Button_Classic[id - IDB_CC_A][m_Page]->SetLabel(str);
|
2009-07-10 05:30:19 +00:00
|
|
|
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
|
2009-12-27 19:31:02 +00:00
|
|
|
m_Button_GH3[id - IDB_GH3_GREEN][m_Page]->SetLabel(str);
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the text in the textbox for the buttons
|
2009-12-27 19:31:02 +00:00
|
|
|
wxString WiimotePadConfigDialog::GetButtonText(int id)
|
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-27 19:31:02 +00:00
|
|
|
return m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->GetLabel();
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_WM_A <= id && id <= IDB_WM_SHAKE)
|
2009-12-27 19:31:02 +00:00
|
|
|
return m_Button_Wiimote[id - IDB_WM_A][m_Page]->GetLabel();
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_NC_Z <= id && id <= IDB_NC_SHAKE)
|
2009-12-27 19:31:02 +00:00
|
|
|
return m_Button_NunChuck[id - IDB_NC_Z][m_Page]->GetLabel();
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_CC_A <= id && id <= IDB_CC_RD)
|
2009-12-27 19:31:02 +00:00
|
|
|
return m_Button_Classic[id - IDB_CC_A][m_Page]->GetLabel();
|
2009-12-09 14:52:30 +00:00
|
|
|
else if (IDB_GH3_GREEN <= id && id <= IDB_GH3_STRUM_DOWN)
|
2009-12-27 19:31:02 +00:00
|
|
|
return m_Button_GH3[id - IDB_GH3_GREEN][m_Page]->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
|
2009-12-27 19:31:02 +00:00
|
|
|
int PadID = WiiMoteEmu::WiiMapping[m_Page].ID;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Get the controller and trigger type
|
2009-12-27 19:31:02 +00:00
|
|
|
int TriggerType = WiiMoteEmu::WiiMapping[m_Page].TriggerType;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
bool NoTriggerFilter = false;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Values used in this function
|
|
|
|
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-12-17 16:14:48 +00:00
|
|
|
int KeyPressed = 0;
|
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
|
|
|
|
|
|
|
// 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-12-27 19:31:02 +00:00
|
|
|
WiiMoteEmu::WiiMapping[m_Page].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-27 19:31:02 +00:00
|
|
|
else if (WiiMoteEmu::NumGoodPads > 0)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
InputCommon::GetButton(
|
2009-12-31 17:42:55 +00:00
|
|
|
WiiMoteEmu::WiiMapping[m_Page].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
|
2009-12-17 16:14:48 +00:00
|
|
|
KeyPressed, value, type, pressed, Succeed, Stop,
|
2009-02-23 06:15:48 +00:00
|
|
|
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process results
|
|
|
|
// Count each time
|
|
|
|
GetButtonWaitingTimer++;
|
|
|
|
|
|
|
|
// This is run every second
|
2009-12-27 19:31:02 +00:00
|
|
|
if (GetButtonWaitingTimer % TimesPerSecond == 0)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Current time
|
|
|
|
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
|
|
|
|
// Update text
|
2009-12-27 19:31:02 +00:00
|
|
|
SetButtonText(_GetId, wxString::Format(wxT("[ %d ]"), TmpTime));
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Time's up
|
2009-12-27 19:31:02 +00:00
|
|
|
if (GetButtonWaitingTimer / TimesPerSecond >= Seconds)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
Stop = true;
|
2009-11-29 17:58:52 +00:00
|
|
|
// Revert back to old label
|
2009-12-27 19:31:02 +00:00
|
|
|
SetButtonText(_GetId, OldLabel);
|
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;
|
|
|
|
}
|
2009-12-27 19:31:02 +00:00
|
|
|
if (IDB_WM_A <= _GetId && _GetId <= IDB_GH3_STRUM_DOWN)
|
2009-11-29 17:58:52 +00:00
|
|
|
{
|
|
|
|
// Better make the pad button code far from virtual key code
|
2009-12-27 19:31:02 +00:00
|
|
|
SaveButtonMapping(_GetId, 0x1000 + pressed);
|
|
|
|
SetButtonText(_GetId, wxString::Format(wxT("PAD: %d"), pressed));
|
2009-11-29 17:58:52 +00:00
|
|
|
}
|
2009-12-27 19:31:02 +00:00
|
|
|
else if (IDB_ANALOG_LEFT_X <= _GetId && _GetId <= IDB_TRIGGER_R)
|
2009-11-29 17:58:52 +00:00
|
|
|
{
|
2009-12-27 19:31:02 +00:00
|
|
|
SaveButtonMapping(_GetId, pressed);
|
|
|
|
SetButtonText(_GetId, wxString::Format(wxT("%d"), pressed));
|
2009-11-29 17:58:52 +00:00
|
|
|
}
|
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-12-28 23:28:35 +00:00
|
|
|
WiiMoteEmu::WiiMapping[m_Page].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
|
2009-12-17 16:14:48 +00:00
|
|
|
if(KeyPressed == -1)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
// Update text
|
2009-12-27 19:31:02 +00:00
|
|
|
SetButtonText(_GetId, wxString(wxT("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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-12-27 19:31:02 +00:00
|
|
|
void WiimotePadConfigDialog::UpdatePadInfo(wxTimerEvent& WXUNUSED(event))
|
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. */
|
2009-12-27 19:31:02 +00:00
|
|
|
if (WiiMoteEmu::WiiMapping[m_Page].ID < 0 || WiiMoteEmu::WiiMapping[m_Page].ID >= WiiMoteEmu::NumGoodPads)
|
|
|
|
{
|
|
|
|
m_tStatusLeftIn[m_Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusLeftOut[m_Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusRightIn[m_Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_tStatusRightOut[m_Page]->SetLabel(wxT("Not connected"));
|
|
|
|
m_TriggerStatusL[m_Page]->SetLabel(wxT("000"));
|
|
|
|
m_TriggerStatusR[m_Page]->SetLabel(wxT("000"));
|
2009-02-23 06:15:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that Dolphin is in focus, otherwise don't update the pad status
|
|
|
|
//if (IsFocus())
|
2009-12-27 19:31:02 +00:00
|
|
|
WiiMoteEmu::GetAxisState(WiiMoteEmu::WiiMapping[m_Page]);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Analog stick
|
|
|
|
// Get original values
|
2009-12-27 19:31:02 +00:00
|
|
|
int main_x = WiiMoteEmu::WiiMapping[m_Page].AxisState.Lx;
|
|
|
|
int main_y = WiiMoteEmu::WiiMapping[m_Page].AxisState.Ly;
|
|
|
|
int right_x = WiiMoteEmu::WiiMapping[m_Page].AxisState.Rx;
|
|
|
|
int right_y = WiiMoteEmu::WiiMapping[m_Page].AxisState.Ry;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// 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
|
2009-12-27 19:31:02 +00:00
|
|
|
if(WiiMoteEmu::WiiMapping[m_Page].bCircle2Square)
|
|
|
|
InputCommon::Square2Circle(main_x_after, main_y_after, 0, WiiMoteEmu::WiiMapping[m_Page].Diagonal, true);
|
2009-12-09 14:52:30 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
// Check dead zone
|
2009-12-27 19:31:02 +00:00
|
|
|
float DeadZoneLeft = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneL / 100.0;
|
|
|
|
float DeadZoneRight = (float)WiiMoteEmu::WiiMapping[m_Page].DeadZoneR / 100.0;
|
2009-02-23 06:15:48 +00:00
|
|
|
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-27 19:31:02 +00:00
|
|
|
m_tStatusLeftIn[m_Page]->SetLabel(wxString::Format(wxT("x:%1.2f y:%1.2f"), f_x, f_y ));
|
|
|
|
m_tStatusLeftOut[m_Page]->SetLabel(wxString::Format(wxT("x:%1.2f y:%1.2f"), f_x_aft, f_y_aft));
|
|
|
|
m_tStatusRightIn[m_Page]->SetLabel(wxString::Format(wxT("x:%1.2f y:%1.2f"), f_Rx, f_Ry));
|
|
|
|
m_tStatusRightOut[m_Page]->SetLabel(wxString::Format(wxT("x:%1.2f y:%1.2f"), f_Rx_aft, f_Ry_aft));
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// 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
|
2009-12-27 19:31:02 +00:00
|
|
|
m_bmpDotLeftIn[m_Page]->SetPosition(wxPoint(main_x, main_y));
|
|
|
|
m_bmpDotLeftOut[m_Page]->SetPosition(wxPoint(main_x_after, main_y_after));
|
|
|
|
m_bmpDotRightIn[m_Page]->SetPosition(wxPoint(right_x, right_y));
|
|
|
|
m_bmpDotRightOut[m_Page]->SetPosition(wxPoint(right_x_after, right_y_after));
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Get the trigger values
|
2009-12-27 19:31:02 +00:00
|
|
|
int TriggerLeft = WiiMoteEmu::WiiMapping[m_Page].AxisState.Tl;
|
|
|
|
int TriggerRight = WiiMoteEmu::WiiMapping[m_Page].AxisState.Tr;
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// Convert the triggers values
|
2009-12-27 19:31:02 +00:00
|
|
|
if (WiiMoteEmu::WiiMapping[m_Page].TriggerType == InputCommon::CTL_TRIGGER_SDL)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
|
|
|
TriggerLeft = InputCommon::Pad_Convert(TriggerLeft);
|
|
|
|
TriggerRight = InputCommon::Pad_Convert(TriggerRight);
|
|
|
|
}
|
|
|
|
|
2009-12-27 19:31:02 +00:00
|
|
|
m_TriggerStatusL[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerLeft));
|
|
|
|
m_TriggerStatusR[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerRight));
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|