Skip to content

Commit

Permalink
Next Attempt (2024)!
Browse files Browse the repository at this point in the history
-Still lots todo! but I have a (mostly) working version up and running!
  • Loading branch information
NPO-197 committed Sep 25, 2024
1 parent 2eb6d44 commit 2f19ab8
Show file tree
Hide file tree
Showing 13 changed files with 956 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build*/
debug*/
bin
obj
*.depend
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/qt_sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set(SOURCES_QT_SDL

LANDialog.cpp
NetplayDialog.cpp

LuaMain.cpp
)

if (APPLE)
Expand Down Expand Up @@ -84,6 +86,7 @@ endif()
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive)
pkg_check_modules(Zstd REQUIRED IMPORTED_TARGET libzstd)
pkg_search_module(Lua REQUIRED IMPORTED_TARGET lua-5.4 lua-5.3 lua>=5.3)

fix_interface_includes(PkgConfig::SDL2 PkgConfig::LibArchive)

Expand Down Expand Up @@ -178,7 +181,7 @@ else()
target_include_directories(melonDS PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
target_link_libraries(melonDS PRIVATE core)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::LibArchive PkgConfig::Zstd)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::LibArchive PkgConfig::Zstd PkgConfig::Lua)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})

if (WIN32)
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/qt_sdl/EmuInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class EmuInstance
int getJoystickID() { return joystickID; }
SDL_Joystick* getJoystick() { return joystick; }

std::vector<int> keyStrokes;
private:
static int lastSep(const std::string& path);
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);
Expand Down Expand Up @@ -205,6 +206,7 @@ class EmuInstance
static void audioCallback(void* data, Uint8* stream, int len);
static void micCallback(void* data, Uint8* stream, int len);


void onKeyPress(QKeyEvent* event);
void onKeyRelease(QKeyEvent* event);
void keyReleaseAll();
Expand Down Expand Up @@ -254,6 +256,8 @@ class EmuInstance
bool doLimitFPS;
int maxFPS;
bool doAudioSync;

melonDS::u32 getInputMask(){return inputMask;}
private:

std::unique_ptr<melonDS::Savestate> backupState;
Expand Down
1 change: 1 addition & 0 deletions src/frontend/qt_sdl/EmuInstanceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ void EmuInstance::onKeyPress(QKeyEvent* event)
{
int keyHK = getEventKeyVal(event);
int keyKP = keyHK;
keyStrokes.push_back(keyHK);
if (event->modifiers() != Qt::KeypadModifier)
keyKP &= ~event->modifiers();

Expand Down
7 changes: 7 additions & 0 deletions src/frontend/qt_sdl/EmuThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

#include "EmuInstance.h"

#include "LuaMain.h"

using namespace melonDS;


Expand Down Expand Up @@ -439,6 +441,11 @@ void EmuThread::run()
}

handleMessages();

//Lua Script Stuff (-for now happens at the end of each frame regardless of emuStatus)
LuaScript::createLuaState();//Create LuaState if needed
LuaScript::luaUpdate(); //"_Update()" gets called in current lua script

}

file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Write);
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/qt_sdl/EmuThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class EmuThread : public QThread
void deinitContext();
void updateVideoSettings() { videoSettingsDirty = true; }

void onLuaPrint(const QString&);
void onLuaClearConsole();
void onLuaLoadState(const QString&);
void onLuaSaveState(const QString&);
void onLuaLayoutChange();

int FrontBuffer = 0;
QMutex FrontBufferLock;

Expand All @@ -130,6 +136,11 @@ class EmuThread : public QThread

void syncVolumeLevel();

void signalLuaPrint(const QString&);
void signalLuaClearConsole();
void signalLuaSaveState(const QString&);
void signalLuaLoadState(const QString&);

private:
void handleMessages();

Expand Down
Loading

0 comments on commit 2f19ab8

Please sign in to comment.