nJoy: Enabled keyboard input (only for buttons so far) through wxWidgets in the main application. It only works when you render to the main window.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1706 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2008-12-28 18:50:24 +00:00
parent de7abc6bd0
commit 5e5e507121
20 changed files with 460 additions and 153 deletions

View File

@ -31,6 +31,7 @@
#include "Config.h" // Core
#include "Core.h"
#include "HW/DVDInterface.h"
#include "Plugins/Plugin_PAD.h"
#include "State.h"
#include "VolumeHandler.h"
@ -172,6 +173,10 @@ CFrame::CFrame(wxFrame* parent,
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(CFrame::OnKeyUp),
(wxObject*)0, this);
UpdateGUI();
}
@ -506,7 +511,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
{
// Ask for confirmation in case the user accidently clicked Stop
int answer;
bool answer;
if(SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
{
answer = AskYesNo("Are you sure you want to stop the current emulation?",
@ -514,10 +519,10 @@ void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
}
else
{
answer = wxYES;
answer = true;
}
if (answer == wxYES && Core::GetState() != Core::CORE_UNINITIALIZED)
if (answer && Core::GetState() != Core::CORE_UNINITIALIZED)
{
Core::Stop();
UpdateGUI();
@ -690,8 +695,18 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
#endif
else
{
if(Core::GetState() != Core::CORE_UNINITIALIZED)
PluginPAD::PAD_Input(event.GetKeyCode(), 1); // 1 = Down
event.Skip();
}
//if(event.GetKeyCode() == 80) PanicAlert("Core 80");
}
void CFrame::OnKeyUp(wxKeyEvent& event)
{
if(Core::GetState() != Core::CORE_UNINITIALIZED)
PluginPAD::PAD_Input(event.GetKeyCode(), 0); // 0 = Up
event.Skip();
}

View File

@ -117,7 +117,7 @@ class CFrame : public wxFrame
void OnResize(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event);
void OnToggleStatusbar(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event);
void OnHostMessage(wxCommandEvent& event);
void OnMemcard(wxCommandEvent& event); // Misc

View File

@ -46,7 +46,7 @@
IMPLEMENT_APP(DolphinApp)
#if defined(HAVE_WX) && HAVE_WX
bool wxMsgAlert(const char*, const char*, bool);
bool wxMsgAlert(const char*, const char*, bool, int);
#endif
CFrame* main_frame = NULL;
@ -278,18 +278,27 @@ void DolphinApp::OnEndSession()
SConfig::GetInstance().SaveSettings();
}
/////////////////////////////////////////////////////////////
/* We declare this here instead of in Common/MsgHandler.cpp because we want to keep Common
free of wxWidget functions */
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int Style)
{
#ifdef _WIN32
/* In Windows we use a MessageBox isntead of a wxMessageBox to don't block
the debug window */
int STYLE = MB_ICONINFORMATION;
if(Style == QUESTION) STYLE = MB_ICONQUESTION;
if(Style == WARNING) STYLE = MB_ICONWARNING;
bool wxMsgAlert(const char* caption, const char* text,
bool yes_no) {
#ifdef _WIN32
// I like parentless messageboxes - don't block the debug window.
return IDYES == MessageBox(0, text, caption, yes_no?MB_YESNO:MB_OK);
#else
return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption),
(yes_no)?wxYES_NO:wxOK);
#endif
return IDYES == MessageBox(0, text, caption, STYLE | (yes_no ? MB_YESNO : MB_OK));
#else
return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption),
(yes_no)?wxYES_NO:wxOK);
#endif
}
//////////////////////////////////
// OK, this thread boundary is DANGEROUS on linux