diff --git a/melonDS.cbp b/melonDS.cbp index 46bf54b3..cc31c335 100644 --- a/melonDS.cbp +++ b/melonDS.cbp @@ -107,10 +107,13 @@ + + + diff --git a/src/wx/EmuConfig.cpp b/src/wx/EmuConfig.cpp new file mode 100644 index 00000000..90c5e4b7 --- /dev/null +++ b/src/wx/EmuConfig.cpp @@ -0,0 +1,74 @@ +/* + Copyright 2016-2017 StapleButter + + This file is part of melonDS. + + melonDS 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, either version 3 of the License, or (at your option) + any later version. + + melonDS 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 for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#include "../types.h" +#include "EmuConfig.h" +#include "../Config.h" + + +wxBEGIN_EVENT_TABLE(EmuConfigDialog, wxDialog) + EVT_COMMAND(1001, wxEVT_BUTTON, EmuConfigDialog::OnOk) + EVT_COMMAND(1002, wxEVT_BUTTON, EmuConfigDialog::OnCancel) +wxEND_EVENT_TABLE() + + +EmuConfigDialog::EmuConfigDialog(wxWindow* parent) + : wxDialog(parent, -1, "Emulation settings - melonDS") +{ + wxBoxSizer* vboxmain = new wxBoxSizer(wxVERTICAL); + + cbDirectBoot = new wxCheckBox(this, wxID_ANY, "Boot game directly"); + vboxmain->Add(cbDirectBoot, 0, wxALL&(~wxBOTTOM), 15); + cbDirectBoot->SetValue(Config::DirectBoot != 0); + + { + wxPanel* p = new wxPanel(this); + wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton* ok = new wxButton(p, 1001, "OK"); + sizer->Add(ok); + + wxButton* cancel = new wxButton(p, 1002, "Cancel"); + sizer->Add(3, 0); + sizer->Add(cancel); + + p->SetSizer(sizer); + vboxmain->Add(p, 0, wxALL|wxALIGN_RIGHT, 15); + } + + SetSizer(vboxmain); + Fit(); +} + +EmuConfigDialog::~EmuConfigDialog() +{ +} + +void EmuConfigDialog::OnOk(wxCommandEvent& event) +{ + Config::DirectBoot = cbDirectBoot->GetValue() ? 1:0; + Config::Save(); + + Close(); +} + +void EmuConfigDialog::OnCancel(wxCommandEvent& event) +{ + Close(); +} + diff --git a/src/wx/EmuConfig.h b/src/wx/EmuConfig.h new file mode 100644 index 00000000..744239a8 --- /dev/null +++ b/src/wx/EmuConfig.h @@ -0,0 +1,43 @@ +/* + Copyright 2016-2017 StapleButter + + This file is part of melonDS. + + melonDS 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, either version 3 of the License, or (at your option) + any later version. + + melonDS 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 for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#ifndef WX_EMUCONFIG_H +#define WX_EMUCONFIG_H + +#include +#ifndef WX_PRECOMP +#include +#endif + +class EmuConfigDialog : public wxDialog +{ +public: + EmuConfigDialog(wxWindow* parent); + ~EmuConfigDialog(); + +private: + wxDECLARE_EVENT_TABLE(); + + void OnOk(wxCommandEvent& event); + void OnCancel(wxCommandEvent& event); + + wxCheckBox* cbDirectBoot; +}; + +#endif // WX_EMUCONFIG_H + diff --git a/src/wx/InputConfig.cpp b/src/wx/InputConfig.cpp index 693ddbd5..3120bf05 100644 --- a/src/wx/InputConfig.cpp +++ b/src/wx/InputConfig.cpp @@ -165,8 +165,6 @@ InputConfigDialog::InputConfigDialog(wxWindow* parent) polltimer = new wxTimer(this); pollid = 0; - keystate = SDL_GetKeyboardState(&nkeys); - njoys = SDL_NumJoysticks(); if (njoys) joy = SDL_JoystickOpen(0); } @@ -210,8 +208,27 @@ void InputConfigDialog::OnKeyDown(wxKeyEvent& event) pollbtn->Refresh(); return; } + else if ((code == SDL_SCANCODE_BACKSPACE) && (pollid >= 200)) + { + id = pollid - 200; + if (id >= 12) return; - if (pollid >= 200) return; + joymapping[id] = -1; + + char keyname[16]; + JoyMappingName(joymapping[id], keyname); + pollbtn->SetLabel(keyname); + + polltimer->Stop(); + pollid = 0; + + pollbtn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); + pollbtn->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); + pollbtn->Refresh(); + return; + } + + if (pollid >= 12) return; keymapping[id] = code; @@ -272,23 +289,6 @@ void InputConfigDialog::OnPoll(wxTimerEvent& event) int id = pollid - 200; if (id >= 12) return; - if (keystate[SDL_SCANCODE_BACKSPACE]) - { - joymapping[id] = -1; - - char keyname[16]; - JoyMappingName(joymapping[id], keyname); - pollbtn->SetLabel(keyname); - - polltimer->Stop(); - pollid = 0; - - pollbtn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - pollbtn->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); - pollbtn->Refresh(); - return; - } - int nbuttons = SDL_JoystickNumButtons(joy); for (int i = 0; i < nbuttons; i++) { diff --git a/src/wx/InputConfig.h b/src/wx/InputConfig.h index e64a0d97..0ca3bcaf 100644 --- a/src/wx/InputConfig.h +++ b/src/wx/InputConfig.h @@ -48,8 +48,6 @@ private: void JoyMappingName(int id, char* str); - const u8* keystate; - int nkeys; int njoys; SDL_Joystick* joy; diff --git a/src/wx/main.cpp b/src/wx/main.cpp index c761d0e4..f2d48242 100644 --- a/src/wx/main.cpp +++ b/src/wx/main.cpp @@ -24,6 +24,7 @@ #include "../GPU.h" #include "InputConfig.h" +#include "EmuConfig.h" wxIMPLEMENT_APP_NO_MAIN(wxApp_melonDS); @@ -103,6 +104,7 @@ wxBEGIN_EVENT_TABLE(MainFrame, wxFrame) EVT_MENU(ID_PAUSE, MainFrame::OnPause) EVT_MENU(ID_RESET, MainFrame::OnReset) + EVT_MENU(ID_EMUCONFIG, MainFrame::OnEmuConfig) EVT_MENU(ID_INPUTCONFIG, MainFrame::OnInputConfig) wxEND_EVENT_TABLE() @@ -122,6 +124,7 @@ MainFrame::MainFrame() systemmenu->Append(ID_RESET, "Reset"); wxMenu* settingsmenu = new wxMenu(); + settingsmenu->Append(ID_EMUCONFIG, "Emulation"); settingsmenu->Append(ID_INPUTCONFIG, "Input"); wxMenuBar* melonbar = new wxMenuBar(); @@ -199,7 +202,7 @@ void MainFrame::OnOpenROM(wxCommandEvent& event) emuthread->EmuPause(); rompath = opener.GetPath(); - NDS::LoadROM(rompath.mb_str(), true); + NDS::LoadROM(rompath.mb_str(), Config::DirectBoot); emuthread->EmuRun(); GetMenuBar()->Enable(ID_PAUSE, true); @@ -259,7 +262,7 @@ void MainFrame::OnReset(wxCommandEvent& event) emuthread->EmuPause(); if (!rompath.IsEmpty()) - NDS::LoadROM(rompath.mb_str(), true); + NDS::LoadROM(rompath.mb_str(), Config::DirectBoot); else NDS::LoadBIOS(); @@ -278,6 +281,12 @@ void MainFrame::OnReset(wxCommandEvent& event) } } +void MainFrame::OnEmuConfig(wxCommandEvent& event) +{ + EmuConfigDialog dlg(this); + dlg.ShowModal(); +} + void MainFrame::OnInputConfig(wxCommandEvent& event) { if (joy) diff --git a/src/wx/main.h b/src/wx/main.h index d61442db..8a46fa0c 100644 --- a/src/wx/main.h +++ b/src/wx/main.h @@ -35,6 +35,7 @@ enum ID_PAUSE, ID_RESET, + ID_EMUCONFIG, ID_INPUTCONFIG, }; @@ -71,6 +72,7 @@ private: void OnPause(wxCommandEvent& event); void OnReset(wxCommandEvent& event); + void OnEmuConfig(wxCommandEvent& event); void OnInputConfig(wxCommandEvent& event); void ProcessSDLEvents();