(windows)padsimple now shows human-readable names after you set a new key

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@692 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-09-25 17:57:57 +00:00
parent c1b340feb5
commit 3055091932
1 changed files with 11 additions and 12 deletions

View File

@ -71,10 +71,11 @@ ConfigDialog::~ConfigDialog()
{ {
} }
inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
const char *name, int ctl, int controller) { const char *name, int ctl, int controller)
{
wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL);
char keyStr[6] = {0}; char keyStr[10] = {0};
hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name),
wxDefaultPosition, wxDefaultSize), 0, wxDefaultPosition, wxDefaultSize), 0,
@ -82,14 +83,12 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
#ifdef _WIN32 #ifdef _WIN32
DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr);
#else #else
XKeyToString(pad[controller].keyForControl[ctl], keyStr); XKeyToString(pad[controller].keyForControl[ctl], keyStr);
#endif #endif
*button = new wxButton(pan, ctl, wxString::FromAscii(keyStr), *button = new wxButton(pan, ctl, wxString::FromAscii(keyStr),
wxDefaultPosition, wxDefaultSize, 0); wxDefaultPosition, wxDefaultSize, 0);
hButton->Add(*button, 0, wxEXPAND|wxALL);
sizer->Add(hButton); sizer->Add(hButton);
} }
@ -226,14 +225,17 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
{ {
if(m_dinput.diks[i]) if(m_dinput.diks[i])
{ {
char keyStr[10] = {0};
pad[page].keyForControl[clickedButton->GetId()] = i; pad[page].keyForControl[clickedButton->GetId()] = i;
DInput::DIKToString(i, keyStr);
clickedButton->SetLabel(wxString::FromAscii(keyStr));
} }
} }
#else #else
pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode());
#endif
clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode()));
clickedButton->Disconnect(); #endif
clickedButton->Disconnect();
} }
clickedButton = NULL; clickedButton = NULL;
@ -271,11 +273,8 @@ void ConfigDialog::OnButtonClick(wxCommandEvent& event)
clickedButton = (wxButton *)event.GetEventObject(); clickedButton = (wxButton *)event.GetEventObject();
oldLabel = clickedButton->GetLabel(); oldLabel = clickedButton->GetLabel();
clickedButton->SetLabel(_("Press Key")); clickedButton->SetLabel(_("Press Key"));
clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(ConfigDialog::OnKeyDown), wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)NULL, this); (wxObject*)NULL, this);
//clickedButton->SetLabel(wxString::Format(wxT("%i"), keyPress));
//clickedButton->SetLabel(wxString::Format(wxT("%s %i"), oldLabel, keyPress));
} }