Emulated Wiimote: Added customizable controls for the Wiimote and the Nunchuck

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2259 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-15 18:23:42 +00:00
parent c49f969563
commit a8e35e976a
16 changed files with 525 additions and 204 deletions

View File

@ -153,7 +153,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
@ -287,7 +287,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
@ -415,6 +415,14 @@
RelativePath=".\Src\Configuration.cpp"
>
</File>
<File
RelativePath=".\Src\DirectInputBase.cpp"
>
</File>
<File
RelativePath=".\Src\DirectInputBase.h"
>
</File>
<File
RelativePath=".\Src\Event.hpp"
>

View File

@ -33,6 +33,10 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#if defined HAVE_WX && HAVE_WX
#include <wx/wx.h>
#endif
#include "SDL.h" // Local
////////////////////////////////////
@ -197,11 +201,47 @@ std::vector<int> Square2Circle(int _x, int _y, int _pad, std::string SDiagonal,
vec.push_back(int_y);
// Debugging
//m_frame->m_pStatusBar2->SetLabel(wxString::Format("%f %f %i", corner_circle_dist, Diagonal, Tmp));
//Console::Print("%f %f %i", corner_circle_dist, Diagonal, Tmp));
return vec;
}
/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Windows Virtual Key Codes Names
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#ifdef _WIN32
std::string VKToString(int keycode)
{
// Default value
char KeyStr[64] = {0};
GetKeyNameText(MapVirtualKey(keycode, MAPVK_VK_TO_VSC) << 16, KeyStr, 64);
std::string KeyString = KeyStr;
switch(keycode)
{
// Give it some help with a few keys
case VK_END: return "END";
case VK_INSERT: return "INS";
case VK_DELETE: return "DEL";
case VK_PRIOR: return "PGUP";
case VK_NEXT: return "PGDN";
case VK_UP: return "UP";
case VK_DOWN: return "DOWN";
case VK_LEFT: return "LEFT";
case VK_RIGHT: return "RIGHT";
case VK_LSHIFT: return "LEFT SHIFT";
case VK_LCONTROL: return "LEFT CTRL";
case VK_RCONTROL: return "RIGHT CTRL";
case VK_LMENU: return "LEFT ALT";
default: return KeyString;
}
}
#endif
/////////////////////////////////////////////////////////////////////
}

View File

@ -15,8 +15,13 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#include "DirectInputBase.h"
////////////////////////////////////
DInput::DInput()
: g_pDI(NULL),
@ -163,7 +168,7 @@ HRESULT DInput::Read()
hr = g_pKeyboard->GetDeviceState(sizeof(diks), diks);
//for (int i=0; i<256; i++)
// if (diks[i])MessageBox(0,"DSFJDKSF|",0,0);
// if (diks[i]) MessageBox(0,"DSFJDKSF|",0,0);
if (FAILED(hr))
{
// DirectInput may be telling us that the input stream has been

View File

@ -18,6 +18,20 @@
#ifndef _DIRECTINPUTBASE_H
#define _DIRECTINPUTBASE_H
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <windows.h> // System
#include <stdio.h>
#define DIRECTINPUT_VERSION 0x0800 // DirectInput
#include <dinput.h>
//#include "ConsoleWindow.h" // Common
///////////////////////////////
class DInput
{
public:

View File

@ -38,10 +38,10 @@
#include <vector>
#include <cmath>
#ifdef _WIN32 // UGLY HACK FIXME PLEAAAAAAASE
#ifdef _WIN32
#include <SDL.h> // Externals
#else
#include <SDL/SDL.h> // Externals
#include <SDL/SDL.h>
#endif
#include "Common.h" // Common
@ -171,15 +171,35 @@ struct PadAxis
int Tl; // Triggers
int Tr;
};
struct PadWiimote
{
int A;
int B;
int One;
int Two;
int P;
int M;
int H;
int L, R, U, D;
int Shake;
};
struct PadNunchuck
{
int Z;
int C;
int L, R, U, D;
int Shake;
};
struct CONTROLLER_STATE_NEW // GC PAD INFO/STATE
{
PadAxis Axis; // 6 Axes (Main, Sub, Triggers)
SDL_Joystick *joy; // SDL joystick device
};
struct CONTROLLER_MAPPING_NEW // GC PAD MAPPING
{
PadAxis Axis; // (See above)
PadWiimote Wm;
PadNunchuck Nc;
bool enabled; // Pad attached?
int DeadZoneL; // Analog 1 Deadzone
int DeadZoneR; // Analog 2 Deadzone
@ -212,6 +232,11 @@ float SquareDistance(float deg);
bool IsDeadZone(float DeadZone, int x, int y);
std::vector<int> Square2Circle(int _x, int _y, int _pad, std::string SDiagonal, bool Circle2Square = false);
// Input configuration
#ifdef _WIN32
std::string VKToString(int keycode);
#endif
#ifndef _SDL_MAIN_
extern int g_LastPad;
#endif

View File

@ -22,6 +22,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_PadSimple", "Plugins\Plugin_PadSimple\Plugin_PadSimple.vcproj", "{9A183B48-ECC2-4121-876A-9B3793686073}"
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="Plugin_PadSimple"
ProjectGUID="{9A183B48-ECC2-4121-876A-9B3793686073}"
RootNamespace="Plugin_PadSimple"
@ -635,68 +635,6 @@
>
</File>
</Filter>
<Filter
Name="DirectInputBase"
>
<File
RelativePath=".\Src\DirectInputBase.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Src\DirectInputBase.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\PadSimple.cpp"
>

View File

@ -21,7 +21,7 @@
#ifdef _WIN32
#include "XInput.h"
#include "../DirectInputBase.h"
#include "../../../../Core/InputCommon/Src/DirectInputBase.h" // Core
DInput m_dinput;
#endif
@ -70,7 +70,7 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl
#ifdef _WIN32
m_dinput.Init((HWND)parent);
#endif
clickedButton = NULL;
ClickedButton = NULL;
CreateGUIControls();
Fit();
}
@ -79,28 +79,36 @@ ConfigDialog::~ConfigDialog()
{
}
//////////////////////////////////////////////////////////////////////////////////////////
// Create input button controls
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
const char *name, int ctl, int controller)
{
wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL);
char keyStr[10] = {0};
// Add the label
hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name),
wxDefaultPosition, wxDefaultSize), 0,
wxALIGN_CENTER_VERTICAL|wxALL);
// Give it the mapped key name
#ifdef _WIN32
DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr);
#elif defined(HAVE_X11) && HAVE_X11
XKeyToString(pad[controller].keyForControl[ctl], keyStr);
#endif
// Add the button to its sizer
*button = new wxButton(pan, ctl, wxString::FromAscii(keyStr),
wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
hButton->Add(*button, 0, wxALIGN_RIGHT|wxALL);
sizer->Add(hButton, 0, wxALIGN_RIGHT|wxALL);
}
////////////////////////////////////
void ConfigDialog::CreateGUIControls()
{
@ -307,8 +315,9 @@ void ConfigDialog::OnClose(wxCloseEvent& event)
void ConfigDialog::OnKeyDown(wxKeyEvent& event)
{
if(clickedButton != NULL)
if(ClickedButton != NULL)
{
// Get the selected notebook page
int page = m_Notebook->GetSelection();
#ifdef _WIN32
@ -318,23 +327,45 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
if(m_dinput.diks[i])
{
char keyStr[10] = {0};
pad[page].keyForControl[clickedButton->GetId()] = i;
// Save the mapped key, the wxButtons have the Id 0 to 21
pad[page].keyForControl[ClickedButton->GetId()] = i;
// Get the key name
DInput::DIKToString(i, keyStr);
clickedButton->SetLabel(wxString::FromAscii(keyStr));
ClickedButton->SetLabel(wxString::FromAscii(keyStr));
break;
}
}
#elif defined(HAVE_X11) && HAVE_X11
pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode());
clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode()));
pad[page].keyForControl[ClickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode());
ClickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode()));
#endif
clickedButton->Disconnect();
ClickedButton->Disconnect();
}
clickedButton = NULL;
// Reset
ClickedButton = NULL;
event.Skip();
}
// We have clicked a button
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{
// Check if the Space key was set to solve the Space key problem
if (m_dinput.diks[DIK_SPACE]) { m_dinput.diks[DIK_SPACE] = 0; return; }
// If we come here again before any key was set
if(ClickedButton) ClickedButton->SetLabel(oldLabel);
// Save the old button label so we can reapply it if necessary
ClickedButton = (wxButton *)event.GetEventObject();
oldLabel = ClickedButton->GetLabel();
ClickedButton->SetLabel(_("Press Key"));
// Connect EVT_KEY_DOWN to OnKeyDown()
ClickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)NULL, this);
}
void ConfigDialog::OnCloseClick(wxCommandEvent& event)
{
Close();
@ -385,20 +416,6 @@ void ConfigDialog::ControllerSettingsChanged(wxCommandEvent& event)
}
}
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{
if(clickedButton)
{
clickedButton->SetLabel(oldLabel);
}
clickedButton = (wxButton *)event.GetEventObject();
oldLabel = clickedButton->GetLabel();
clickedButton->SetLabel(_("Press Key"));
clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)NULL, this);
}
void ConfigDialog::DllAbout(wxCommandEvent& event)
{
wxString message;

View File

@ -129,7 +129,7 @@ class ConfigDialog : public wxDialog
void DllAbout(wxCommandEvent& event);
int keyPress;
wxButton *clickedButton;
wxButton *ClickedButton;
wxString oldLabel;
};

View File

@ -36,7 +36,7 @@
#ifdef _WIN32
#include "XInput.h"
#include "DirectInputBase.h"
#include "../../../Core/InputCommon/Src/DirectInputBase.h" // Core
DInput dinput;
//#elif defined(USE_SDL) && USE_SDL
@ -615,6 +615,8 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {}
void DllConfig(HWND _hParent)
{
//Console::Open(70, 5000);
LoadConfig();
#ifdef _WIN32
wxWindow win;

View File

@ -64,7 +64,30 @@ void Config::Load(bool ChangePad)
iniFile.Get(SectionName.c_str(), "TriggerType", &Trigger.Type, Trigger.TRIGGER_OFF);
iniFile.Get(SectionName.c_str(), "TriggerRollRange", &Trigger.Range.Roll, 50);
iniFile.Get(SectionName.c_str(), "TriggerPitchRange", &Trigger.Range.Pitch, false);
// Wiimote
iniFile.Get(SectionName.c_str(), "WmA", &WiiMoteEmu::PadMapping[i].Wm.A, 0);
iniFile.Get(SectionName.c_str(), "WmB", &WiiMoteEmu::PadMapping[i].Wm.B, 0);
iniFile.Get(SectionName.c_str(), "Wm1", &WiiMoteEmu::PadMapping[i].Wm.One, 0);
iniFile.Get(SectionName.c_str(), "Wm2", &WiiMoteEmu::PadMapping[i].Wm.Two, 0);
iniFile.Get(SectionName.c_str(), "WmP", &WiiMoteEmu::PadMapping[i].Wm.P, 0);
iniFile.Get(SectionName.c_str(), "WmM", &WiiMoteEmu::PadMapping[i].Wm.M, 0);
iniFile.Get(SectionName.c_str(), "WmH", &WiiMoteEmu::PadMapping[i].Wm.H, 0);
iniFile.Get(SectionName.c_str(), "WmL", &WiiMoteEmu::PadMapping[i].Wm.L, 0);
iniFile.Get(SectionName.c_str(), "WmR", &WiiMoteEmu::PadMapping[i].Wm.R, 0);
iniFile.Get(SectionName.c_str(), "WmU", &WiiMoteEmu::PadMapping[i].Wm.U, 0);
iniFile.Get(SectionName.c_str(), "WmD", &WiiMoteEmu::PadMapping[i].Wm.D, 0);
iniFile.Get(SectionName.c_str(), "WmShake", &WiiMoteEmu::PadMapping[i].Wm.Shake, 0);
// Nunchuck
iniFile.Get(SectionName.c_str(), "NunchuckStick", &Nunchuck.Type, Nunchuck.KEYBOARD);
iniFile.Get(SectionName.c_str(), "NcZ", &WiiMoteEmu::PadMapping[i].Nc.Z, 0);
iniFile.Get(SectionName.c_str(), "NcC", &WiiMoteEmu::PadMapping[i].Nc.C, 0);
iniFile.Get(SectionName.c_str(), "NcL", &WiiMoteEmu::PadMapping[i].Nc.L, 0);
iniFile.Get(SectionName.c_str(), "NcR", &WiiMoteEmu::PadMapping[i].Nc.R, 0);
iniFile.Get(SectionName.c_str(), "NcU", &WiiMoteEmu::PadMapping[i].Nc.U, 0);
iniFile.Get(SectionName.c_str(), "NcD", &WiiMoteEmu::PadMapping[i].Nc.D, 0);
iniFile.Get(SectionName.c_str(), "NcShake", &WiiMoteEmu::PadMapping[i].Nc.Shake, 0);
// Don't update this when we are loading settings from the ConfigBox
if(!ChangePad)
@ -139,7 +162,29 @@ void Config::Save(int Slot)
iniFile.Set(SectionName.c_str(), "TriggerType", Trigger.Type);
iniFile.Set(SectionName.c_str(), "TriggerRollRange", Trigger.Range.Roll);
iniFile.Set(SectionName.c_str(), "TriggerPitchRange", Trigger.Range.Pitch);
// Wiimote
iniFile.Set(SectionName.c_str(), "WmA", WiiMoteEmu::PadMapping[i].Wm.A);
iniFile.Set(SectionName.c_str(), "WmB", WiiMoteEmu::PadMapping[i].Wm.B);
iniFile.Set(SectionName.c_str(), "Wm1", WiiMoteEmu::PadMapping[i].Wm.One);
iniFile.Set(SectionName.c_str(), "Wm2", WiiMoteEmu::PadMapping[i].Wm.Two);
iniFile.Set(SectionName.c_str(), "WmP", WiiMoteEmu::PadMapping[i].Wm.P);
iniFile.Set(SectionName.c_str(), "WmM", WiiMoteEmu::PadMapping[i].Wm.M);
iniFile.Set(SectionName.c_str(), "WmH", WiiMoteEmu::PadMapping[i].Wm.H);
iniFile.Set(SectionName.c_str(), "WmL", WiiMoteEmu::PadMapping[i].Wm.L);
iniFile.Set(SectionName.c_str(), "WmR", WiiMoteEmu::PadMapping[i].Wm.R);
iniFile.Set(SectionName.c_str(), "WmU", WiiMoteEmu::PadMapping[i].Wm.U);
iniFile.Set(SectionName.c_str(), "WmD", WiiMoteEmu::PadMapping[i].Wm.D);
iniFile.Set(SectionName.c_str(), "WmShake", WiiMoteEmu::PadMapping[i].Wm.Shake);
// Nunchuck
iniFile.Set(SectionName.c_str(), "NunchuckStick", Nunchuck.Type);
iniFile.Set(SectionName.c_str(), "NcZ", WiiMoteEmu::PadMapping[i].Nc.Z);
iniFile.Set(SectionName.c_str(), "NcC", WiiMoteEmu::PadMapping[i].Nc.C);
iniFile.Set(SectionName.c_str(), "NcL", WiiMoteEmu::PadMapping[i].Nc.L);
iniFile.Set(SectionName.c_str(), "NcR", WiiMoteEmu::PadMapping[i].Nc.R);
iniFile.Set(SectionName.c_str(), "NcU", WiiMoteEmu::PadMapping[i].Nc.U);
iniFile.Set(SectionName.c_str(), "NcShake", WiiMoteEmu::PadMapping[i].Nc.Shake);
// Save the physical device ID number
iniFile.Set(SectionName.c_str(), "DeviceID", WiiMoteEmu::PadMapping[i].ID);

View File

@ -23,6 +23,7 @@
#include "CommonTypes.h" // for u16
#include "IniFile.h"
#include "Timer.h"
#include "StringUtil.h"
#include "wiimote_real.h" // Local
#include "wiimote_hid.h"
@ -113,6 +114,20 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CHECKBOX(ID_TILT_INVERT_PITCH, ConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(IDCB_NUNCHUCK_STICK, ConfigDialog::GeneralSettingsChanged)
// Wiimote
EVT_BUTTON(IDB_WM_A, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_B, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_WM_1, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_2, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_WM_P, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_M, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_H, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_WM_L, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_R, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_WM_U, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_WM_D, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_WM_SHAKE, ConfigDialog::OnButtonClick)
// Nunchuck
EVT_BUTTON(IDB_NC_Z, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_C, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_L, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_R, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_U, ConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_D, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_SHAKE, ConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_ANALOG_LEFT_X, ConfigDialog::GetButtons)
EVT_BUTTON(IDB_ANALOG_LEFT_Y, ConfigDialog::GetButtons)
EVT_BUTTON(IDB_ANALOG_RIGHT_X, ConfigDialog::GetButtons)
@ -157,6 +172,7 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl
m_bEnableUseRealWiimote = true;
Page = 0;
m_vRecording.resize(RECORDING_ROWS + 1);
ClickedButton = NULL;
g_Config.Load();
CreateGUIControls();
@ -167,9 +183,6 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)0, this);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)0, this);
}
ConfigDialog::~ConfigDialog()
@ -190,8 +203,69 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
m_bRecording = false;
UpdateGUI();
}
// ----------------------------------------------------
// Handle the keyboard key mapping
// ------------------
std::string StrKey;
if(ClickedButton != NULL)
{
// Allow the escape key to set a blank key
if (g_Pressed == WXK_ESCAPE)
{
SaveKeyboardMapping(Page, ClickedButton->GetId(), -1);
SetButtonText(ClickedButton->GetId(), "");
ClickedButton = NULL;
return;
}
#ifdef _WIN32
BYTE keyState[256];
GetKeyboardState(keyState);
for (int i = 1; i < 256; ++i)
{
if ((keyState[i] & 0x80) != 0)
{
// Use the left and right specific keys instead of the common ones
if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU) continue;
// Update the button label
char KeyStr[64] = {0}; strcpy(KeyStr, InputCommon::VKToString(i).c_str());
SetButtonText(ClickedButton->GetId(), KeyStr);
// Save the setting
SaveKeyboardMapping(Page, ClickedButton->GetId(), i);
}
}
#elif defined(HAVE_X11) && HAVE_X11
//pad[page].keyForControl[ClickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode());
//ClickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode()));
#endif
}
// Remove the button control pointer
ClickedButton = NULL;
// ---------------------------
}
// Input button clicked
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{
//Console::Print("OnButtonClick: %i\n", g_Pressed);
// Don't allow space to start a new Press Key option, that will interfer with setting a key to space
if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; }
// Reset the old label
if(ClickedButton) ClickedButton->SetLabel(OldLabel);
// Create the button object
ClickedButton = (wxButton *)event.GetEventObject();
OldLabel = ClickedButton->GetLabel();
ClickedButton->SetLabel(wxT("<Press Key>"));
// Allow Tab and directional keys to
ClickedButton->SetWindowStyle(wxWANTS_CHARS);
}
void ConfigDialog::OnClose(wxCloseEvent& event)
{
g_FrameOpen = false;
@ -441,6 +515,9 @@ void ConfigDialog::CreateGUIControls()
StrNunchuck.Add(wxString::FromAscii("Keyboard"));
StrNunchuck.Add(wxString::FromAscii("Analog 1"));
StrNunchuck.Add(wxString::FromAscii("Analog 2"));
// A small type font
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
///////////////////////////////////////
@ -453,7 +530,7 @@ void ConfigDialog::CreateGUIControls()
// ----------------
// Configuration controls
static const int TxtW = 50, TxtH = 19, ChW = 261;
static const int TxtW = 50, TxtH = 19, ChW = 261, BtW = 75, BtH = 20;
// Basic Settings
m_WiimoteOnline[i] = new wxCheckBox(m_Controller[i], IDC_WIMOTE_ON, wxT("Wiimote On"), wxDefaultPosition, wxSize(ChW, -1));
@ -540,7 +617,7 @@ void ConfigDialog::CreateGUIControls()
// --------------------------------------------------------------------
// Controller
// -----------------------------
/**/
// Controller
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(200, -1), StrJoyname, wxCB_READONLY);
@ -834,20 +911,6 @@ void ConfigDialog::CreateGUIControls()
// Wiimote
// -----------------------------
m_gWiimote[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Wiimote"));
/*
m_WmA[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmB[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_Wm1[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_Wm2[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmP[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmM[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmH[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmL[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmR[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmU[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_WmD[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_tWmA[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("A"));
m_tWmB[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("B"));
m_tWm1[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("1"));
@ -859,30 +922,64 @@ void ConfigDialog::CreateGUIControls()
m_tWmR[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Right"));
m_tWmU[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Up"));
m_tWmD[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Down"));
m_tWmShake[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Shake"));
m_bWmA[i] = new wxButton(m_Controller[i], IDB_WM_A);
m_bWmB[i] = new wxButton(m_Controller[i], IDB_WM_B);
m_bWm1[i] = new wxButton(m_Controller[i], IDB_WM_1);
m_bWm2[i] = new wxButton(m_Controller[i], IDB_WM_2);
m_bWmP[i] = new wxButton(m_Controller[i], IDB_WM_P);
m_bWmM[i] = new wxButton(m_Controller[i], IDB_WM_M);
m_bWmL[i] = new wxButton(m_Controller[i], IDB_WM_L);
m_bWmR[i] = new wxButton(m_Controller[i], IDB_WM_R);
m_bWmU[i] = new wxButton(m_Controller[i], IDB_WM_U);
m_bWmD[i] = new wxButton(m_Controller[i], IDB_WM_D);
m_bWmA[i] = new wxButton(m_Controller[i], IDB_WM_A, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmB[i] = new wxButton(m_Controller[i], IDB_WM_B, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWm1[i] = new wxButton(m_Controller[i], IDB_WM_1, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWm2[i] = new wxButton(m_Controller[i], IDB_WM_2, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmP[i] = new wxButton(m_Controller[i], IDB_WM_P, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmM[i] = new wxButton(m_Controller[i], IDB_WM_M, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmH[i] = new wxButton(m_Controller[i], IDB_WM_H, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmL[i] = new wxButton(m_Controller[i], IDB_WM_L, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmR[i] = new wxButton(m_Controller[i], IDB_WM_R, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmU[i] = new wxButton(m_Controller[i], IDB_WM_U, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmD[i] = new wxButton(m_Controller[i], IDB_WM_D, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bWmShake[i] = new wxButton(m_Controller[i], IDB_WM_SHAKE, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
// Disable
m_WmA[i]->Enable(false);
m_WmB[i]->Enable(false);
m_Wm1[i]->Enable(false);
m_Wm2[i]->Enable(false);
m_WmP[i]->Enable(false);
m_WmM[i]->Enable(false);
m_WmL[i]->Enable(false);
m_WmR[i]->Enable(false);
m_WmU[i]->Enable(false);
m_WmD[i]->Enable(false);
*/
// Set small font
m_bWmA[i]->SetFont(m_SmallFont); m_bWmB[i]->SetFont(m_SmallFont);
m_bWm1[i]->SetFont(m_SmallFont); m_bWm2[i]->SetFont(m_SmallFont);
m_bWmP[i]->SetFont(m_SmallFont); m_bWmM[i]->SetFont(m_SmallFont); m_bWmH[i]->SetFont(m_SmallFont);
m_bWmL[i]->SetFont(m_SmallFont); m_bWmR[i]->SetFont(m_SmallFont);
m_bWmU[i]->SetFont(m_SmallFont); m_bWmD[i]->SetFont(m_SmallFont);
m_bWmShake[i]->SetFont(m_SmallFont);
// Sizers
m_SWmA[i] = new wxBoxSizer(wxHORIZONTAL); m_SWmB[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWm1[i] = new wxBoxSizer(wxHORIZONTAL); m_SWm2[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWmP[i] = new wxBoxSizer(wxHORIZONTAL); m_SWmM[i] = new wxBoxSizer(wxHORIZONTAL); m_SWmH[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWmL[i] = new wxBoxSizer(wxHORIZONTAL); m_SWmR[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWmU[i] = new wxBoxSizer(wxHORIZONTAL); m_SWmD[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWmShake[i] = new wxBoxSizer(wxHORIZONTAL);
m_SWmA[i]->Add(m_tWmA[i], 0, (wxUP), 4); m_SWmA[i]->Add(m_bWmA[i], 0, (wxLEFT), 2);
m_SWmB[i]->Add(m_tWmB[i], 0, (wxUP), 4); m_SWmB[i]->Add(m_bWmB[i], 0, (wxLEFT), 2);
m_SWm1[i]->Add(m_tWm1[i], 0, (wxUP), 4); m_SWm1[i]->Add(m_bWm1[i], 0, (wxLEFT), 2);
m_SWm2[i]->Add(m_tWm2[i], 0, (wxUP), 4); m_SWm2[i]->Add(m_bWm2[i], 0, (wxLEFT), 2);
m_SWmP[i]->Add(m_tWmP[i], 0, (wxUP), 4); m_SWmP[i]->Add(m_bWmP[i], 0, (wxLEFT), 2);
m_SWmM[i]->Add(m_tWmM[i], 0, (wxUP), 4); m_SWmM[i]->Add(m_bWmM[i], 0, (wxLEFT), 2);
m_SWmH[i]->Add(m_tWmH[i], 0, (wxUP), 4); m_SWmH[i]->Add(m_bWmH[i], 0, (wxLEFT), 2);
m_SWmL[i]->Add(m_tWmL[i], 0, (wxUP), 4); m_SWmL[i]->Add(m_bWmL[i], 0, (wxLEFT), 2);
m_SWmR[i]->Add(m_tWmR[i], 0, (wxUP), 4); m_SWmR[i]->Add(m_bWmR[i], 0, (wxLEFT), 2);
m_SWmU[i]->Add(m_tWmU[i], 0, (wxUP), 4); m_SWmU[i]->Add(m_bWmU[i], 0, (wxLEFT), 2);
m_SWmD[i]->Add(m_tWmD[i], 0, (wxUP), 4); m_SWmD[i]->Add(m_bWmD[i], 0, (wxLEFT), 2);
m_SWmShake[i]->Add(m_tWmShake[i], 0, (wxUP), 4); m_SWmShake[i]->Add(m_bWmShake[i], 0, (wxLEFT), 2);
m_gWiimote[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Wiimote"));
m_gWiimote[i]->Add(m_SWmShake[i], 0, wxALIGN_RIGHT | (wxALL), 1);
m_gWiimote[i]->Add(m_SWmL[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmR[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmU[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmD[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmA[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmB[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWm1[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWm2[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmP[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmM[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->Add(m_SWmH[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gWiimote[i]->AddSpacer(1);
// --------------------------------------------------------------------
// Nunchuck
@ -892,44 +989,59 @@ void ConfigDialog::CreateGUIControls()
m_NunchuckTextStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick controls"));
m_NunchuckComboStick[i] = new wxComboBox(m_Controller[i], IDCB_NUNCHUCK_STICK, StrNunchuck[0], wxDefaultPosition, wxDefaultSize, StrNunchuck, wxCB_READONLY);
/*
m_NuZ[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_NuC[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_NuL[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_NuR[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_NuU[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_NuD[i] = new wxTextCtrl(m_Controller[i], ID_WM_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
m_tNcZ[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Z"));
m_tNcC[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("C"));
m_tNcL[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left"));
m_tNcR[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Right"));
m_tNcU[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Up"));
m_tNcD[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Down"));
m_tNcShake[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Shake"));
m_tNuZ[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Z"));
m_tNuC[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("C"));
m_tNuL[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left"));
m_tNuR[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Right"));
m_tNuU[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Up"));
m_tNuD[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Down"));
m_bNcZ[i] = new wxButton(m_Controller[i], IDB_NC_Z, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcC[i] = new wxButton(m_Controller[i], IDB_NC_C, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcL[i] = new wxButton(m_Controller[i], IDB_NC_L, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcR[i] = new wxButton(m_Controller[i], IDB_NC_R, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcU[i] = new wxButton(m_Controller[i], IDB_NC_U, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcD[i] = new wxButton(m_Controller[i], IDB_NC_D, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNcShake[i] = new wxButton(m_Controller[i], IDB_NC_SHAKE, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_bNuZ[i] = new wxButton(m_Controller[i], IDB_WM_Z);
m_bNuC[i] = new wxButton(m_Controller[i], IDB_WM_C);
m_bNuL[i] = new wxButton(m_Controller[i], IDB_WM_L);
m_bNuR[i] = new wxButton(m_Controller[i], IDB_WM_R);
m_bNuU[i] = new wxButton(m_Controller[i], IDB_WM_U);
m_bNuD[i] = new wxButton(m_Controller[i], IDB_WM_D);
// Disable
m_NuZ[i]->Enable(false);
m_NuC[i]->Enable(false);
m_NuL[i]->Enable(false);
m_NuR[i]->Enable(false);
m_NuU[i]->Enable(false);
m_NuD[i]->Enable(false);
*/
// Set small font
m_bNcShake[i]->SetFont(m_SmallFont);
m_bNcZ[i]->SetFont(m_SmallFont);
m_bNcC[i]->SetFont(m_SmallFont);
m_bNcL[i]->SetFont(m_SmallFont); m_bNcR[i]->SetFont(m_SmallFont);
m_bNcU[i]->SetFont(m_SmallFont); m_bNcD[i]->SetFont(m_SmallFont);
m_bNcShake[i]->SetFont(m_SmallFont);
// Sizers
m_NunchuckStick[i] = new wxBoxSizer(wxHORIZONTAL);
m_NunchuckStick[i]->Add(m_NunchuckTextStick[i], 0, (wxUP), 4);
m_NunchuckStick[i]->Add(m_NunchuckComboStick[i], 0, (wxLEFT), 2);
m_gNunchuck[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Nunchuck"));
m_gNunchuck[i]->Add(m_NunchuckStick[i], 0, (wxALL), 2);
m_SNcZ[i] = new wxBoxSizer(wxHORIZONTAL); m_SNcC[i] = new wxBoxSizer(wxHORIZONTAL);
m_SNcL[i] = new wxBoxSizer(wxHORIZONTAL); m_SNcR[i] = new wxBoxSizer(wxHORIZONTAL);
m_SNcU[i] = new wxBoxSizer(wxHORIZONTAL); m_SNcD[i] = new wxBoxSizer(wxHORIZONTAL);
m_SNcShake[i] = new wxBoxSizer(wxHORIZONTAL);
m_SNcZ[i]->Add(m_tNcZ[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcZ[i]->Add(m_bNcZ[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcC[i]->Add(m_tNcC[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcC[i]->Add(m_bNcC[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcL[i]->Add(m_tNcL[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcL[i]->Add(m_bNcL[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcR[i]->Add(m_tNcR[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcR[i]->Add(m_bNcR[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcU[i]->Add(m_tNcU[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcU[i]->Add(m_bNcU[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcD[i]->Add(m_tNcD[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcD[i]->Add(m_bNcD[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
m_SNcShake[i]->Add(m_tNcShake[i], 0, wxALIGN_RIGHT | (wxUP), 4); m_SNcShake[i]->Add(m_bNcShake[i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
// The parent sizer
m_gNunchuck[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Nunchuck"));
m_gNunchuck[i]->Add(m_NunchuckStick[i], 0, wxALIGN_CENTER | (wxALL), 2);
m_gNunchuck[i]->AddSpacer(2);
m_gNunchuck[i]->Add(m_SNcShake[i], 0, wxALIGN_RIGHT | (wxALL), 1);
m_gNunchuck[i]->Add(m_SNcZ[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gNunchuck[i]->Add(m_SNcC[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gNunchuck[i]->Add(m_SNcL[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gNunchuck[i]->Add(m_SNcR[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gNunchuck[i]->Add(m_SNcU[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_gNunchuck[i]->Add(m_SNcD[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
//Set values
m_NunchuckComboStick[i]->SetSelection(g_Config.Nunchuck.Type);

View File

@ -39,7 +39,7 @@ class ConfigDialog : public wxDialog
ConfigDialog(wxWindow *parent, wxWindowID id = 1,
const wxString &title = wxT("Wii Remote Plugin Configuration"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE);
long style = wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
virtual ~ConfigDialog();
// General open, close and event functions
@ -90,6 +90,10 @@ class ConfigDialog : public wxDialog
*m_HorizControllers[4], *m_gC2SDeadZone[4], *m_gCircle2Square[4], *m_gCircle2SquareVert[4], *m_gDeadZone[4], *m_gDeadZoneHoriz[4], *m_HorizControllerTiltParent[4], *m_HorizControllerTilt[4], *m_TiltHoriz[4],
*m_SizeAnalogLeft[4], *m_SizeAnalogLeftHorizX[4], *m_SizeAnalogLeftHorizY[4], *m_SizeAnalogRight[4], *m_SizeAnalogRightHorizX[4], *m_SizeAnalogRightHorizY[4],
*m_SizeAnalogTriggerVertLeft[4], *m_SizeAnalogTriggerVertRight[4], *m_SizeAnalogTriggerHorizInput[4],
// Nunchuck
*m_SNcShake[4], *m_SNcZ[4], *m_SNcC[4], *m_SNcL[4], *m_SNcR[4], *m_SNcU[4], *m_SNcD[4],
// Wiimote
*m_SWmShake[4], *m_SWmA[4], *m_SWmB[4], *m_SWm1[4], *m_SWm2[4], *m_SWmP[4], *m_SWmM[4], *m_SWmH[4], *m_SWmL[4], *m_SWmR[4], *m_SWmU[4], *m_SWmD[4],
*m_HorizControllerMapping[4], *m_NunchuckStick[4];
wxGridBagSizer *m_SizeAnalogTriggerHorizConfig[4], *m_SizeAnalogTriggerStatusBox[4], *m_TiltGrid[4],
*m_GridLeftStick[4], *m_GridRightStick[4];
@ -97,12 +101,22 @@ class ConfigDialog : public wxDialog
wxTextCtrl *m_AnalogLeftX[4], *m_AnalogLeftY[4], *m_AnalogRightX[4], *m_AnalogRightY[4],
*m_AnalogTriggerL[4], *m_AnalogTriggerR[4];
wxButton *m_bAnalogLeftX[4], *m_bAnalogLeftY[4], *m_bAnalogRightX[4], *m_bAnalogRightY[4],
*m_bAnalogTriggerL[4], *m_bAnalogTriggerR[4];
*m_bAnalogTriggerL[4], *m_bAnalogTriggerR[4],
// Nunchuck
*m_bNcShake[4], *m_bNcZ[4], *m_bNcC[4], *m_bNcL[4], *m_bNcR[4], *m_bNcU[4], *m_bNcD[4],
// Wiimote
*m_bWmShake[4], *m_bWmA[4], *m_bWmB[4], *m_bWm1[4], *m_bWm2[4], *m_bWmP[4], *m_bWmM[4], *m_bWmH[4], *m_bWmD[4], *m_bWmU[4], *m_bWmR[4], *m_bWmL[4];
wxStaticText *m_tAnalogX[8], *m_tAnalogY[8], *m_TiltTextRoll[4], *m_TiltTextPitch[4],
*m_CheckC2SLabel[4], *m_ComboDeadZoneLabel[4], *m_TStatusLeftIn[4], *m_TStatusLeftOut[4], *m_TStatusRightIn[4], *m_TStatusRightOut[4],
*m_TriggerStatusL[4], *m_TriggerStatusR[4], *m_TriggerStatusLx[4], *m_TriggerStatusRx[4],
*m_tAnalogTriggerInput[4], *m_tAnalogTriggerL[4], *m_tAnalogTriggerR[4],
// Nunchuck
*m_tNcShake[4], *m_tNcZ[4], *m_tNcC[4], *m_tNcL[4], *m_tNcR[4], *m_tNcU[4], *m_tNcD[4],
// Wiimote
*m_tWmShake[4], *m_tWmA[4], *m_tWmB[4], *m_tWm1[4], *m_tWm2[4], *m_tWmP[4], *m_tWmM[4], *m_tWmH[4], *m_tWmL[4], *m_tWmR[4], *m_tWmU[4],*m_tWmD[4],
*m_NunchuckTextStick[5];
wxButton *ClickedButton;
wxString OldLabel;
// Emulated Wiimote settings
wxCheckBox *m_SidewaysDPad[4], *m_WiimoteOnline[4], *m_WideScreen[4];
@ -168,6 +182,21 @@ class ConfigDialog : public wxDialog
ID_ANALOG_RIGHT_X, ID_ANALOG_RIGHT_Y,
ID_TRIGGER_L, ID_TRIGGER_R,
// Wiimote
IDB_WM_A, IDB_WM_B,
IDB_WM_1, IDB_WM_2,
IDB_WM_P, IDB_WM_M, IDB_WM_H,
IDB_WM_L, IDB_WM_R, IDB_WM_U, IDB_WM_D,
IDB_WM_SHAKE,
// Nunchuck
IDB_NC_Z, IDB_NC_C, IDB_NC_L, IDB_NC_R, IDB_NC_U, IDB_NC_D,
IDB_NC_SHAKE,
// Classic Controller
IDB_CC_A, IDB_CC_B,
IDB_CC_X, IDB_CC_Y,
// Gamepad settings
IDC_JOYNAME, IDC_LEFT_C2S, IDCB_LEFT_DIAGONAL, IDCB_DEAD_ZONE_LEFT, IDCB_DEAD_ZONE_RIGHT,
ID_TRIGGER_TYPE, ID_TILT_INPUT, ID_TILT_RANGE_ROLL, ID_TILT_RANGE_PITCH, ID_TILT_INVERT_ROLL, ID_TILT_INVERT_PITCH,
@ -196,10 +225,12 @@ class ConfigDialog : public wxDialog
wxString GetButtonText(int id, int Page = -1);
void GetButtons(wxCommandEvent& event); void DoGetButtons(int);
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1); void SaveButtonMappingAll(int Slot);
void SaveKeyboardMapping(int Controller, int Id, int Key);
void ToBlank(bool ToBlank = true);
void PadGetStatus();
void DoSave(bool ChangePad = false, int Slot = -1);
void DoChangeJoystick(); void PadOpen(int Open); void PadClose(int Close); void DoChangeDeadZone(bool Left);
void OnButtonClick(wxCommandEvent& event);
// Configure buttons
int GetButtonWaitingID, GetButtonWaitingTimer;

View File

@ -102,6 +102,8 @@ void ConfigDialog::DoChangeDeadZone(bool Left)
///////////////////////////////////////////////////////////////////////////////////
// Change settings
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Set the button text for all four Wiimotes
void ConfigDialog::SetButtonTextAll(int id, char text[128])
{
for (int i = 0; i < 1; i++)
@ -157,7 +159,30 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller)
m_TiltInvertRoll[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bRollInvert);
m_TiltInvertPitch[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bPitchInvert);
//Console::Print("m_ComboDeadZone[%i] = %i\n", controller, WiiMoteEmu::PadMapping[controller].deadzone);
// Wiimote
m_bWmA[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A));
m_bWmB[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.B));
m_bWm1[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.One));
m_bWm2[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.Two));
m_bWmP[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.P));
m_bWmM[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.M));
m_bWmH[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.H));
m_bWmL[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.L));
m_bWmR[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.R));
m_bWmU[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.U));
m_bWmD[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.D));
m_bWmShake[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.Shake));
// Nunchuck
m_bNcZ[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.Z));
m_bNcC[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.C));
m_bNcL[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.L));
m_bNcR[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.R));
m_bNcU[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.U));
m_bNcD[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.D));
m_bNcShake[controller]->SetLabel(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Nc.Shake));
//Console::Print("m_bWmA[%i] = %i = %s\n", controller, WiiMoteEmu::PadMapping[controller].Wm.A, InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str());
}
/* Populate the PadMapping array with the dialog items settings (for example
@ -206,6 +231,38 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From
ToBlank();
}
// Save keyboard key mapping
void ConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key)
{
switch(Id)
{
// Wiimote
case IDB_WM_A: WiiMoteEmu::PadMapping[Controller].Wm.A = Key; break;
case IDB_WM_B: WiiMoteEmu::PadMapping[Controller].Wm.B = Key; break;
case IDB_WM_1: WiiMoteEmu::PadMapping[Controller].Wm.One = Key; break;
case IDB_WM_2: WiiMoteEmu::PadMapping[Controller].Wm.Two = Key; break;
case IDB_WM_P: WiiMoteEmu::PadMapping[Controller].Wm.P = Key; break;
case IDB_WM_M: WiiMoteEmu::PadMapping[Controller].Wm.M = Key; break;
case IDB_WM_H: WiiMoteEmu::PadMapping[Controller].Wm.H = Key; break;
case IDB_WM_L: WiiMoteEmu::PadMapping[Controller].Wm.L = Key; break;
case IDB_WM_R: WiiMoteEmu::PadMapping[Controller].Wm.R = Key; break;
case IDB_WM_U: WiiMoteEmu::PadMapping[Controller].Wm.U = Key; break;
case IDB_WM_D: WiiMoteEmu::PadMapping[Controller].Wm.D = Key; break;
case IDB_WM_SHAKE: WiiMoteEmu::PadMapping[Controller].Wm.Shake = Key; break;
// Nunchuck
case IDB_NC_Z: WiiMoteEmu::PadMapping[Controller].Nc.Z = Key; break;
case IDB_NC_C: WiiMoteEmu::PadMapping[Controller].Nc.C = Key; break;
case IDB_NC_L: WiiMoteEmu::PadMapping[Controller].Nc.L = Key; break;
case IDB_NC_R: WiiMoteEmu::PadMapping[Controller].Nc.R = Key; break;
case IDB_NC_U: WiiMoteEmu::PadMapping[Controller].Nc.U = Key; break;
case IDB_NC_D: WiiMoteEmu::PadMapping[Controller].Nc.D = Key; break;
case IDB_NC_SHAKE: WiiMoteEmu::PadMapping[Controller].Nc.Shake = Key; break;
}
//Console::Print("WiiMoteEmu::PadMapping[%i].Wm.A = %i", Controller, WiiMoteEmu::PadMapping[Controller].Wm.A);
}
// Replace the harder to understand -1 with "" for the sake of user friendliness
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigDialog::ToBlank(bool ToBlank)
@ -252,6 +309,30 @@ void ConfigDialog::SetButtonText(int id, char text[128], int _Page)
case IDB_TRIGGER_L: m_AnalogTriggerL[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_TRIGGER_R: m_AnalogTriggerR[controller]->SetValue(wxString::FromAscii(text)); break;
// Wiimote
case IDB_WM_A: m_bWmA[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_B: m_bWmB[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_1: m_bWm1[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_2: m_bWm2[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_P: m_bWmP[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_M: m_bWmM[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_H: m_bWmH[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_L: m_bWmL[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_R: m_bWmR[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_U: m_bWmU[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_D: m_bWmD[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_WM_SHAKE: m_bWmShake[controller]->SetLabel(wxString::FromAscii(text)); break;
// Nunchuck
case IDB_NC_Z: m_bNcZ[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_C: m_bNcC[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_L: m_bNcL[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_R: m_bNcR[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_U: m_bNcU[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_D: m_bNcD[controller]->SetLabel(wxString::FromAscii(text)); break;
case IDB_NC_SHAKE: m_bNcShake[controller]->SetLabel(wxString::FromAscii(text)); break;
default: break;
}
//Console::Print("SetButtonText: %s\n", text);
@ -471,6 +552,7 @@ void ConfigDialog::DoGetButtons(int GetId)
/////////////////////////////////////////////////////////// Configure button mapping
//////////////////////////////////////////////////////////////////////////////////////////
// Show current input status
// ¯¯¯¯¯¯¯¯¯¯

View File

@ -268,32 +268,31 @@ void FillReportInfo(wm_core& _core)
bool InsideScreen = !(x < 0 || x > 1 || y < 0 || y > 1);
// Allow both mouse buttons and keyboard to press a and b
if((GetAsyncKeyState(VK_LBUTTON) && InsideScreen) || GetAsyncKeyState('A') ? 1 : 0)
if((GetAsyncKeyState(VK_LBUTTON) && InsideScreen) || GetAsyncKeyState(PadMapping[0].Wm.A))
_core.a = 1;
if((GetAsyncKeyState(VK_RBUTTON) && InsideScreen) || GetAsyncKeyState('B') ? 1 : 0)
if((GetAsyncKeyState(VK_RBUTTON) && InsideScreen) || GetAsyncKeyState(PadMapping[0].Wm.B))
_core.b = 1;
_core.one = GetAsyncKeyState('1') ? 1 : 0;
_core.two = GetAsyncKeyState('2') ? 1 : 0;
_core.plus = GetAsyncKeyState('P') ? 1 : 0;
_core.minus = GetAsyncKeyState('M') ? 1 : 0;
_core.home = GetAsyncKeyState('H') ? 1 : 0;
_core.one = GetAsyncKeyState(PadMapping[0].Wm.One) ? 1 : 0;
_core.two = GetAsyncKeyState(PadMapping[0].Wm.Two) ? 1 : 0;
_core.plus = GetAsyncKeyState(PadMapping[0].Wm.P) ? 1 : 0;
_core.minus = GetAsyncKeyState(PadMapping[0].Wm.M) ? 1 : 0;
_core.home = GetAsyncKeyState(PadMapping[0].Wm.H) ? 1 : 0;
/* Sideways controls (for example for Wario Land) if the Wiimote is intended to be held sideways */
if(g_Config.bSidewaysDPad)
{
_core.left = GetAsyncKeyState(VK_DOWN) ? 1 : 0;
_core.up = GetAsyncKeyState(VK_LEFT) ? 1 : 0;
_core.right = GetAsyncKeyState(VK_UP) ? 1 : 0;
_core.down = GetAsyncKeyState(VK_RIGHT) ? 1 : 0;
_core.left = GetAsyncKeyState(PadMapping[0].Wm.D) ? 1 : 0;
_core.up = GetAsyncKeyState(PadMapping[0].Wm.L) ? 1 : 0;
_core.right = GetAsyncKeyState(PadMapping[0].Wm.U) ? 1 : 0;
_core.down = GetAsyncKeyState(PadMapping[0].Wm.R) ? 1 : 0;
}
else
{
_core.left = GetAsyncKeyState(VK_LEFT) ? 1 : 0;
_core.up = GetAsyncKeyState(VK_UP) ? 1 : 0;
_core.right = GetAsyncKeyState(VK_RIGHT) ? 1 : 0;
_core.down = GetAsyncKeyState(VK_DOWN) ? 1 : 0;
_core.left = GetAsyncKeyState(PadMapping[0].Wm.L) ? 1 : 0;
_core.up = GetAsyncKeyState(PadMapping[0].Wm.U) ? 1 : 0;
_core.right = GetAsyncKeyState(PadMapping[0].Wm.R) ? 1 : 0;
_core.down = GetAsyncKeyState(PadMapping[0].Wm.D) ? 1 : 0;
}
#else
// TODO: fill in
@ -334,7 +333,7 @@ void SingleShake(u8 &_y, u8 &_z, int i)
{
#ifdef _WIN32
// Shake Wiimote with S, Nunchuck with D
if((i == 0 && GetAsyncKeyState('S')) || (i == 1 && GetAsyncKeyState('D')))
if((i == 0 && GetAsyncKeyState(PadMapping[0].Wm.Shake)) || (i == 1 && GetAsyncKeyState(PadMapping[0].Nc.Shake)))
{
_z = 0;
_y = 0;
@ -918,14 +917,14 @@ void FillReportExtension(wm_extension& _ext)
if (g_Config.Nunchuck.Type == g_Config.Nunchuck.KEYBOARD)
{
// Set the max values to the current calibration values
if(GetAsyncKeyState(VK_NUMPAD4)) // x
if(GetAsyncKeyState(PadMapping[0].Nc.L)) // x
_ext.jx = g_nu.jx.min;
if(GetAsyncKeyState(VK_NUMPAD6))
if(GetAsyncKeyState(PadMapping[0].Nc.R))
_ext.jx = g_nu.jx.max;
if(GetAsyncKeyState(VK_NUMPAD5)) // y
if(GetAsyncKeyState(PadMapping[0].Nc.D)) // y
_ext.jy = g_nu.jy.min;
if(GetAsyncKeyState(VK_NUMPAD8))
if(GetAsyncKeyState(PadMapping[0].Nc.U))
_ext.jy = g_nu.jy.max;
}
else
@ -984,11 +983,11 @@ void FillReportExtension(wm_extension& _ext)
}
}
if(GetAsyncKeyState('C'))
if(GetAsyncKeyState(PadMapping[0].Nc.C))
_ext.bt = 0x01;
if(GetAsyncKeyState('Z'))
if(GetAsyncKeyState(PadMapping[0].Nc.Z))
_ext.bt = 0x02;
if(GetAsyncKeyState('C') && GetAsyncKeyState('Z'))
if(GetAsyncKeyState(PadMapping[0].Nc.C) && GetAsyncKeyState(PadMapping[0].Nc.Z))
_ext.bt = 0x00;
#else
// TODO linux port

View File

@ -381,11 +381,15 @@ extern "C" unsigned int Wiimote_GetAttachedControllers()
// ================
//******************************************************************************
// Supporting functions
//******************************************************************************
// ----------------------------------------
// Debugging window
// ----------
@ -662,14 +666,15 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
"%02x %02x %02x %02x "
"%03i %03i %03i "
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x "
"%03i %03i %03i %03i %03i "
"%02x %02x ",
"%03i %03i "
"%03i %03i %03i "
"%02x ",
data[0], data[1], data[2], data[3], // Header and core buttons
data[4], data[5], data[6], // Wiimote accelerometer
data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16],
data[17], data[18], // Nunchuck stick
data[19], data[20], data[21], // Nunchuck Accelerometer
data[22], data[23] // Nunchuck buttons
data[22] // Nunchuck buttons
);
// Calculate the Wiimote roll and pitch in degrees
@ -936,9 +941,6 @@ void DoInitialize()
// Open console
//OpenConsole(true);
// Load config settings, will be done after the SDL functions in EmuMain.cpp
//g_Config.Load();
// Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom
WiiMoteEmu::Initialize();