mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-29 17:19:54 -06:00
fix touchscreen input. proper cleanup of threads. meaningless codeblocks crap.
This commit is contained in:
121
melonDS.cbp
121
melonDS.cbp
@ -6,7 +6,7 @@
|
|||||||
<Option pch_mode="2" />
|
<Option pch_mode="2" />
|
||||||
<Option compiler="gcc" />
|
<Option compiler="gcc" />
|
||||||
<Build>
|
<Build>
|
||||||
<Target title="Debug">
|
<Target title="Debug Windows">
|
||||||
<Option platforms="Windows;" />
|
<Option platforms="Windows;" />
|
||||||
<Option output="bin/Debug/melonDS" prefix_auto="1" extension_auto="1" />
|
<Option output="bin/Debug/melonDS" prefix_auto="1" extension_auto="1" />
|
||||||
<Option object_output="obj/Debug/" />
|
<Option object_output="obj/Debug/" />
|
||||||
@ -15,13 +15,94 @@
|
|||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-m64" />
|
<Add option="-m64" />
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
|
<Add option="-D_FILE_OFFSET_BITS=64" />
|
||||||
|
<Add option="-D__WXMSW__" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/lib/wx/include/msw-unicode-static-3.0" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/include/wx-3.0" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-m64" />
|
||||||
|
<Add library=":libwx_mswu_core-3.0.a" />
|
||||||
|
<Add library=":libwx_baseu-3.0.a" />
|
||||||
|
<Add library="SDL2" />
|
||||||
|
<Add library=":libpng.a" />
|
||||||
|
<Add library=":libjpeg.a" />
|
||||||
|
<Add library=":libtiff.a" />
|
||||||
|
<Add library=":libz.a" />
|
||||||
|
<Add library="rpcrt4" />
|
||||||
|
<Add library="oleaut32" />
|
||||||
|
<Add library="ole32" />
|
||||||
|
<Add library="uuid" />
|
||||||
|
<Add library="winspool" />
|
||||||
|
<Add library="winmm" />
|
||||||
|
<Add library="shell32" />
|
||||||
|
<Add library="comctl32" />
|
||||||
|
<Add library="comdlg32" />
|
||||||
|
<Add library="advapi32" />
|
||||||
|
<Add library="wsock32" />
|
||||||
|
<Add library="oleacc" />
|
||||||
|
<Add library="gdi32" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release Windows">
|
||||||
|
<Option platforms="Windows;" />
|
||||||
|
<Option output="bin/Release/melonDS" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O2" />
|
||||||
|
<Add option="-m64" />
|
||||||
|
<Add option="-D_FILE_OFFSET_BITS=64" />
|
||||||
|
<Add option="-D__WXMSW__" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/lib/wx/include/msw-unicode-static-3.0" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/include/wx-3.0" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-s" />
|
||||||
|
<Add option="-m64" />
|
||||||
|
<Add library=":libwx_mswu_core-3.0.a" />
|
||||||
|
<Add library=":libwx_baseu-3.0.a" />
|
||||||
|
<Add library="SDL2" />
|
||||||
|
<Add library=":libpng.a" />
|
||||||
|
<Add library=":libjpeg.a" />
|
||||||
|
<Add library=":libtiff.a" />
|
||||||
|
<Add library=":libz.a" />
|
||||||
|
<Add library="rpcrt4" />
|
||||||
|
<Add library="oleaut32" />
|
||||||
|
<Add library="ole32" />
|
||||||
|
<Add library="uuid" />
|
||||||
|
<Add library="winspool" />
|
||||||
|
<Add library="winmm" />
|
||||||
|
<Add library="shell32" />
|
||||||
|
<Add library="comctl32" />
|
||||||
|
<Add library="comdlg32" />
|
||||||
|
<Add library="advapi32" />
|
||||||
|
<Add library="wsock32" />
|
||||||
|
<Add library="oleacc" />
|
||||||
|
<Add library="gdi32" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
<Target title="Debug Linux">
|
||||||
|
<Option platforms="Unix;" />
|
||||||
|
<Option output="bin/Debug/melonDS" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
<Add option="-m64" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/lib/wx/include/gtk2-unicode-static-3.0" />
|
||||||
|
<Add option="-I$(TARGET_COMPILER_DIR)/include/wx-3.0" />
|
||||||
|
<Add option="-D_FILE_OFFSET_BITS=64" />
|
||||||
|
<Add option="-D__WXGTK__" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
<Add option="-m64" />
|
<Add option="-m64" />
|
||||||
</Linker>
|
</Linker>
|
||||||
</Target>
|
</Target>
|
||||||
<Target title="Release">
|
<Target title="Release Linux">
|
||||||
<Option platforms="Windows;" />
|
<Option platforms="Unix;" />
|
||||||
<Option output="bin/Release/melonDS" prefix_auto="1" extension_auto="1" />
|
<Option output="bin/Release/melonDS" prefix_auto="1" extension_auto="1" />
|
||||||
<Option object_output="obj/Release/" />
|
<Option object_output="obj/Release/" />
|
||||||
<Option type="1" />
|
<Option type="1" />
|
||||||
@ -38,38 +119,13 @@
|
|||||||
</Build>
|
</Build>
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
<Add option="-m64" />
|
|
||||||
<Add option="-fexceptions" />
|
<Add option="-fexceptions" />
|
||||||
<Add option="-pipe" />
|
<Add option="-pipe" />
|
||||||
<Add option="-I$(TARGET_COMPILER_DIR)/lib/wx/include/msw-unicode-static-3.0 -I$(TARGET_COMPILER_DIR)/include/wx-3.0" />
|
|
||||||
<Add option="-D_FILE_OFFSET_BITS=64" />
|
|
||||||
<Add option="-D__WXMSW__" />
|
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
|
||||||
<Add option="-m64" />
|
|
||||||
<Add library=":libwx_mswu_core-3.0.a" />
|
|
||||||
<Add library=":libwx_baseu-3.0.a" />
|
|
||||||
<Add library="SDL2" />
|
|
||||||
<Add library=":libpng.a" />
|
|
||||||
<Add library=":libjpeg.a" />
|
|
||||||
<Add library=":libtiff.a" />
|
|
||||||
<Add library=":libz.a" />
|
|
||||||
<Add library="rpcrt4" />
|
|
||||||
<Add library="oleaut32" />
|
|
||||||
<Add library="ole32" />
|
|
||||||
<Add library="uuid" />
|
|
||||||
<Add library="winspool" />
|
|
||||||
<Add library="winmm" />
|
|
||||||
<Add library="shell32" />
|
|
||||||
<Add library="comctl32" />
|
|
||||||
<Add library="comdlg32" />
|
|
||||||
<Add library="advapi32" />
|
|
||||||
<Add library="wsock32" />
|
|
||||||
<Add library="oleacc" />
|
|
||||||
<Add library="gdi32" />
|
|
||||||
</Linker>
|
|
||||||
<Unit filename="melon.rc">
|
<Unit filename="melon.rc">
|
||||||
<Option compilerVar="WINDRES" />
|
<Option compilerVar="WINDRES" />
|
||||||
|
<Option target="Debug Windows" />
|
||||||
|
<Option target="Release Windows" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="src/ARM.cpp" />
|
<Unit filename="src/ARM.cpp" />
|
||||||
<Unit filename="src/ARM.h" />
|
<Unit filename="src/ARM.h" />
|
||||||
@ -115,7 +171,10 @@
|
|||||||
<Unit filename="src/wx/main.cpp" />
|
<Unit filename="src/wx/main.cpp" />
|
||||||
<Unit filename="src/wx/main.h" />
|
<Unit filename="src/wx/main.h" />
|
||||||
<Unit filename="src/wx/scancode_wx2sdl.h" />
|
<Unit filename="src/wx/scancode_wx2sdl.h" />
|
||||||
<Unit filename="xp.manifest" />
|
<Unit filename="xp.manifest">
|
||||||
|
<Option target="Debug Windows" />
|
||||||
|
<Option target="Release Windows" />
|
||||||
|
</Unit>
|
||||||
<Extensions>
|
<Extensions>
|
||||||
<code_completion />
|
<code_completion />
|
||||||
<envvars />
|
<envvars />
|
||||||
|
@ -86,13 +86,34 @@ bool wxApp_melonDS::OnInit()
|
|||||||
printf("melonDS " MELONDS_VERSION "\n" MELONDS_URL "\n");
|
printf("melonDS " MELONDS_VERSION "\n" MELONDS_URL "\n");
|
||||||
|
|
||||||
Config::Load();
|
Config::Load();
|
||||||
|
|
||||||
|
emuthread = new EmuThread();
|
||||||
|
if (emuthread->Run() != wxTHREAD_NO_ERROR)
|
||||||
|
{
|
||||||
|
printf("thread shat itself :( giving up now\n");
|
||||||
|
delete emuthread;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MainFrame* melon = new MainFrame();
|
MainFrame* melon = new MainFrame();
|
||||||
melon->Show(true);
|
melon->Show(true);
|
||||||
|
|
||||||
|
melon->emuthread = emuthread;
|
||||||
|
emuthread->parent = melon;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxApp_melonDS::OnExit()
|
||||||
|
{
|
||||||
|
emuthread->EmuPause();
|
||||||
|
emuthread->EmuExit();
|
||||||
|
emuthread->Wait();
|
||||||
|
delete emuthread;
|
||||||
|
|
||||||
|
return wxApp::OnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
wxBEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
||||||
EVT_CLOSE(MainFrame::OnClose)
|
EVT_CLOSE(MainFrame::OnClose)
|
||||||
@ -137,14 +158,6 @@ MainFrame::MainFrame()
|
|||||||
SetClientSize(256, 256);
|
SetClientSize(256, 256);
|
||||||
SetMinSize(GetSize());
|
SetMinSize(GetSize());
|
||||||
|
|
||||||
emuthread = new EmuThread(this);
|
|
||||||
if (emuthread->Run() != wxTHREAD_NO_ERROR)
|
|
||||||
{
|
|
||||||
printf("thread shat itself :( giving up now\n");
|
|
||||||
delete emuthread;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NDS::Init();
|
NDS::Init();
|
||||||
rompath = wxEmptyString;
|
rompath = wxEmptyString;
|
||||||
GetMenuBar()->Enable(ID_PAUSE, false);
|
GetMenuBar()->Enable(ID_PAUSE, false);
|
||||||
@ -154,24 +167,8 @@ MainFrame::MainFrame()
|
|||||||
joyid = -1;
|
joyid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::CloseFromOutside()
|
|
||||||
{
|
|
||||||
emuthread = NULL;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainFrame::OnClose(wxCloseEvent& event)
|
void MainFrame::OnClose(wxCloseEvent& event)
|
||||||
{
|
{
|
||||||
if (emuthread)
|
|
||||||
{
|
|
||||||
emuthread->EmuPause();
|
|
||||||
emuthread->EmuExit();
|
|
||||||
|
|
||||||
emuthread->Wait();
|
|
||||||
delete emuthread;
|
|
||||||
emuthread = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
NDS::DeInit();
|
NDS::DeInit();
|
||||||
|
|
||||||
if (joy)
|
if (joy)
|
||||||
@ -181,9 +178,8 @@ void MainFrame::OnClose(wxCloseEvent& event)
|
|||||||
joyid = -1;
|
joyid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Quit();
|
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
|
emuthread->parent = NULL;
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
}
|
}
|
||||||
@ -307,10 +303,9 @@ void MainFrame::OnInputConfig(wxCommandEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EmuThread::EmuThread(MainFrame* parent)
|
EmuThread::EmuThread()
|
||||||
: wxThread(wxTHREAD_JOINABLE)
|
: wxThread(wxTHREAD_JOINABLE)
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuThread::~EmuThread()
|
EmuThread::~EmuThread()
|
||||||
@ -434,6 +429,8 @@ wxThread::ExitCode EmuThread::Entry()
|
|||||||
emupaused = true;
|
emupaused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emupaused = true;
|
||||||
|
|
||||||
SDL_DestroyTexture(sdltex);
|
SDL_DestroyTexture(sdltex);
|
||||||
SDL_DestroyRenderer(sdlrend);
|
SDL_DestroyRenderer(sdlrend);
|
||||||
@ -454,10 +451,8 @@ void EmuThread::ProcessEvents()
|
|||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if (evt.window.event == SDL_WINDOWEVENT_CLOSE)
|
if (evt.window.event == SDL_WINDOWEVENT_CLOSE)
|
||||||
{
|
{
|
||||||
wxThread* thread = parent->emuthread;
|
if (parent) parent->Close();
|
||||||
parent->CloseFromOutside();
|
|
||||||
EmuExit();
|
EmuExit();
|
||||||
//delete thread;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (evt.window.event != SDL_WINDOWEVENT_EXPOSED)
|
if (evt.window.event != SDL_WINDOWEVENT_EXPOSED)
|
||||||
@ -466,6 +461,14 @@ void EmuThread::ProcessEvents()
|
|||||||
{
|
{
|
||||||
int w = evt.window.data1;
|
int w = evt.window.data1;
|
||||||
int h = evt.window.data2;
|
int h = evt.window.data2;
|
||||||
|
|
||||||
|
// SDL_SetWindowMinimumSize() doesn't seem to work on Linux. oh well
|
||||||
|
if ((w < 256) || (h < 384))
|
||||||
|
{
|
||||||
|
if (w < 256) w = 256;
|
||||||
|
if (h < 384) h = 384;
|
||||||
|
SDL_SetWindowSize(sdlwin, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
int ratio = (w * 384) / h;
|
int ratio = (w * 384) / h;
|
||||||
if (ratio > 256)
|
if (ratio > 256)
|
||||||
@ -498,8 +501,6 @@ void EmuThread::ProcessEvents()
|
|||||||
Config::WindowWidth = w;
|
Config::WindowWidth = w;
|
||||||
Config::WindowHeight = h;
|
Config::WindowHeight = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GetWindowPosition(sdlwin, &WindowX, &WindowY);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -512,6 +513,11 @@ void EmuThread::ProcessEvents()
|
|||||||
{
|
{
|
||||||
Touching = true;
|
Touching = true;
|
||||||
NDS::PressKey(16+6);
|
NDS::PressKey(16+6);
|
||||||
|
|
||||||
|
int mx, my;
|
||||||
|
SDL_GetGlobalMouseState(&mx, &my);
|
||||||
|
txoffset = mx - evt.button.x;
|
||||||
|
tyoffset = my - evt.button.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -601,8 +607,8 @@ void EmuThread::ProcessEvents()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mx -= (WindowX + botdst.x);
|
mx -= (txoffset + botdst.x);
|
||||||
my -= (WindowY + botdst.y);
|
my -= (tyoffset + botdst.y);
|
||||||
|
|
||||||
if (botdst.w != 256) mx = (mx * 256) / botdst.w;
|
if (botdst.w != 256) mx = (mx * 256) / botdst.w;
|
||||||
if (botdst.h != 192) my = (my * 192) / botdst.h;
|
if (botdst.h != 192) my = (my * 192) / botdst.h;
|
||||||
|
@ -45,6 +45,9 @@ class wxApp_melonDS : public wxApp
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
|
virtual int OnExit();
|
||||||
|
|
||||||
|
EmuThread* emuthread;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MainFrame : public wxFrame
|
class MainFrame : public wxFrame
|
||||||
@ -59,8 +62,6 @@ public:
|
|||||||
|
|
||||||
wxString rompath;
|
wxString rompath;
|
||||||
|
|
||||||
void CloseFromOutside();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ private:
|
|||||||
class EmuThread : public wxThread
|
class EmuThread : public wxThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EmuThread(MainFrame* parent);
|
EmuThread();
|
||||||
~EmuThread();
|
~EmuThread();
|
||||||
|
|
||||||
void EmuRun() { emustatus = 1; emupaused = false; SDL_RaiseWindow(sdlwin); }
|
void EmuRun() { emustatus = 1; emupaused = false; SDL_RaiseWindow(sdlwin); }
|
||||||
@ -90,13 +91,13 @@ public:
|
|||||||
|
|
||||||
bool EmuIsRunning() { return (emustatus == 1) || (emustatus == 2); }
|
bool EmuIsRunning() { return (emustatus == 1) || (emustatus == 2); }
|
||||||
bool EmuIsPaused() { return (emustatus == 2) && emupaused; }
|
bool EmuIsPaused() { return (emustatus == 2) && emupaused; }
|
||||||
|
|
||||||
|
MainFrame* parent;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ExitCode Entry();
|
virtual ExitCode Entry();
|
||||||
void ProcessEvents();
|
void ProcessEvents();
|
||||||
|
|
||||||
MainFrame* parent;
|
|
||||||
|
|
||||||
SDL_Window* sdlwin;
|
SDL_Window* sdlwin;
|
||||||
SDL_Renderer* sdlrend;
|
SDL_Renderer* sdlrend;
|
||||||
SDL_Texture* sdltex;
|
SDL_Texture* sdltex;
|
||||||
@ -105,8 +106,7 @@ protected:
|
|||||||
SDL_Rect botsrc, botdst;
|
SDL_Rect botsrc, botdst;
|
||||||
|
|
||||||
bool Touching;
|
bool Touching;
|
||||||
|
int txoffset, tyoffset;
|
||||||
int WindowX, WindowY;
|
|
||||||
|
|
||||||
void* texpixels;
|
void* texpixels;
|
||||||
int texstride;
|
int texstride;
|
||||||
|
Reference in New Issue
Block a user