mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
fix touchscreen input. proper cleanup of threads. meaningless codeblocks crap.
This commit is contained in:
parent
a65b45a334
commit
8e5f175f5e
121
melonDS.cbp
121
melonDS.cbp
@ -6,7 +6,7 @@
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Target title="Debug Windows">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="bin/Debug/melonDS" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
@ -15,13 +15,94 @@
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<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>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option platforms="Windows;" />
|
||||
<Target title="Release Linux">
|
||||
<Option platforms="Unix;" />
|
||||
<Option output="bin/Release/melonDS" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
@ -38,38 +119,13 @@
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fexceptions" />
|
||||
<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>
|
||||
<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">
|
||||
<Option compilerVar="WINDRES" />
|
||||
<Option target="Debug Windows" />
|
||||
<Option target="Release Windows" />
|
||||
</Unit>
|
||||
<Unit filename="src/ARM.cpp" />
|
||||
<Unit filename="src/ARM.h" />
|
||||
@ -115,7 +171,10 @@
|
||||
<Unit filename="src/wx/main.cpp" />
|
||||
<Unit filename="src/wx/main.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>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
|
@ -86,13 +86,34 @@ bool wxApp_melonDS::OnInit()
|
||||
printf("melonDS " MELONDS_VERSION "\n" MELONDS_URL "\n");
|
||||
|
||||
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();
|
||||
melon->Show(true);
|
||||
|
||||
melon->emuthread = emuthread;
|
||||
emuthread->parent = melon;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int wxApp_melonDS::OnExit()
|
||||
{
|
||||
emuthread->EmuPause();
|
||||
emuthread->EmuExit();
|
||||
emuthread->Wait();
|
||||
delete emuthread;
|
||||
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
|
||||
|
||||
wxBEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
||||
EVT_CLOSE(MainFrame::OnClose)
|
||||
@ -137,14 +158,6 @@ MainFrame::MainFrame()
|
||||
SetClientSize(256, 256);
|
||||
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();
|
||||
rompath = wxEmptyString;
|
||||
GetMenuBar()->Enable(ID_PAUSE, false);
|
||||
@ -154,24 +167,8 @@ MainFrame::MainFrame()
|
||||
joyid = -1;
|
||||
}
|
||||
|
||||
void MainFrame::CloseFromOutside()
|
||||
{
|
||||
emuthread = NULL;
|
||||
Close();
|
||||
}
|
||||
|
||||
void MainFrame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if (emuthread)
|
||||
{
|
||||
emuthread->EmuPause();
|
||||
emuthread->EmuExit();
|
||||
|
||||
emuthread->Wait();
|
||||
delete emuthread;
|
||||
emuthread = NULL;
|
||||
}
|
||||
|
||||
NDS::DeInit();
|
||||
|
||||
if (joy)
|
||||
@ -181,9 +178,8 @@ void MainFrame::OnClose(wxCloseEvent& event)
|
||||
joyid = -1;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
Destroy();
|
||||
emuthread->parent = NULL;
|
||||
|
||||
Config::Save();
|
||||
}
|
||||
@ -307,10 +303,9 @@ void MainFrame::OnInputConfig(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
|
||||
EmuThread::EmuThread(MainFrame* parent)
|
||||
EmuThread::EmuThread()
|
||||
: wxThread(wxTHREAD_JOINABLE)
|
||||
{
|
||||
this->parent = parent;
|
||||
}
|
||||
|
||||
EmuThread::~EmuThread()
|
||||
@ -434,6 +429,8 @@ wxThread::ExitCode EmuThread::Entry()
|
||||
emupaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
emupaused = true;
|
||||
|
||||
SDL_DestroyTexture(sdltex);
|
||||
SDL_DestroyRenderer(sdlrend);
|
||||
@ -454,10 +451,8 @@ void EmuThread::ProcessEvents()
|
||||
case SDL_WINDOWEVENT:
|
||||
if (evt.window.event == SDL_WINDOWEVENT_CLOSE)
|
||||
{
|
||||
wxThread* thread = parent->emuthread;
|
||||
parent->CloseFromOutside();
|
||||
if (parent) parent->Close();
|
||||
EmuExit();
|
||||
//delete thread;
|
||||
return;
|
||||
}
|
||||
if (evt.window.event != SDL_WINDOWEVENT_EXPOSED)
|
||||
@ -466,6 +461,14 @@ void EmuThread::ProcessEvents()
|
||||
{
|
||||
int w = evt.window.data1;
|
||||
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;
|
||||
if (ratio > 256)
|
||||
@ -498,8 +501,6 @@ void EmuThread::ProcessEvents()
|
||||
Config::WindowWidth = w;
|
||||
Config::WindowHeight = h;
|
||||
}
|
||||
|
||||
SDL_GetWindowPosition(sdlwin, &WindowX, &WindowY);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -512,6 +513,11 @@ void EmuThread::ProcessEvents()
|
||||
{
|
||||
Touching = true;
|
||||
NDS::PressKey(16+6);
|
||||
|
||||
int mx, my;
|
||||
SDL_GetGlobalMouseState(&mx, &my);
|
||||
txoffset = mx - evt.button.x;
|
||||
tyoffset = my - evt.button.y;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -601,8 +607,8 @@ void EmuThread::ProcessEvents()
|
||||
}
|
||||
else
|
||||
{
|
||||
mx -= (WindowX + botdst.x);
|
||||
my -= (WindowY + botdst.y);
|
||||
mx -= (txoffset + botdst.x);
|
||||
my -= (tyoffset + botdst.y);
|
||||
|
||||
if (botdst.w != 256) mx = (mx * 256) / botdst.w;
|
||||
if (botdst.h != 192) my = (my * 192) / botdst.h;
|
||||
|
@ -45,6 +45,9 @@ class wxApp_melonDS : public wxApp
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual int OnExit();
|
||||
|
||||
EmuThread* emuthread;
|
||||
};
|
||||
|
||||
class MainFrame : public wxFrame
|
||||
@ -59,8 +62,6 @@ public:
|
||||
|
||||
wxString rompath;
|
||||
|
||||
void CloseFromOutside();
|
||||
|
||||
private:
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
@ -81,7 +82,7 @@ private:
|
||||
class EmuThread : public wxThread
|
||||
{
|
||||
public:
|
||||
EmuThread(MainFrame* parent);
|
||||
EmuThread();
|
||||
~EmuThread();
|
||||
|
||||
void EmuRun() { emustatus = 1; emupaused = false; SDL_RaiseWindow(sdlwin); }
|
||||
@ -90,13 +91,13 @@ public:
|
||||
|
||||
bool EmuIsRunning() { return (emustatus == 1) || (emustatus == 2); }
|
||||
bool EmuIsPaused() { return (emustatus == 2) && emupaused; }
|
||||
|
||||
MainFrame* parent;
|
||||
|
||||
protected:
|
||||
virtual ExitCode Entry();
|
||||
void ProcessEvents();
|
||||
|
||||
MainFrame* parent;
|
||||
|
||||
SDL_Window* sdlwin;
|
||||
SDL_Renderer* sdlrend;
|
||||
SDL_Texture* sdltex;
|
||||
@ -105,8 +106,7 @@ protected:
|
||||
SDL_Rect botsrc, botdst;
|
||||
|
||||
bool Touching;
|
||||
|
||||
int WindowX, WindowY;
|
||||
int txoffset, tyoffset;
|
||||
|
||||
void* texpixels;
|
||||
int texstride;
|
||||
|
Loading…
Reference in New Issue
Block a user