commit 78799cd79f664fb211940530ee3b88ad867ef1fb
Author: DPS2004 <dpsophinos@gmail.com>
AuthorDate: Wed Mar 2 11:18:59 2022 -0500
Commit: DPS2004 <dpsophinos@gmail.com>
CommitDate: Mon May 2 09:34:18 2022 -0400
"stretch" no longer looks like a real word to me...
---
platform/3ds/source/3dsHost.cpp | 4 ++++
platform/SDL2Common/source/sdl2basehost.cpp | 9 +++++++++
platform/bittboy/source/BittBoyHost.cpp | 9 +++++++++
platform/miyoomini/source/MiyooMiniHost.cpp | 8 ++++++++
platform/wiiu/source/WiiUHost.cpp | 9 +++++++++
source/FakoSettings.h | 1 +
source/host.h | 2 ++
source/hostCommonFunctions.cpp | 24 ++++++++++++++++++++++++
source/picoluaapi.cpp | 12 +++++++++++-
source/vm.cpp | 6 ++++++
source/vm.h | 1 +
test/stubhost.cpp | 9 +++++++++
12 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/platform/3ds/source/3dsHost.cpp b/platform/3ds/source/3dsHost.cpp
index 92770ee..4e452d5 100644
--- a/platform/3ds/source/3dsHost.cpp
+++ b/platform/3ds/source/3dsHost.cpp
@@ -454,6 +454,10 @@ void Host::changeStretch(){
}
}
+void Host::forceStretch(StretchOption newStretch) {
+ setRenderParamsFromStretch(stretch);
+}
+
InputState_t Host::scanInput(){
hidScanInput();
diff --git a/platform/SDL2Common/source/sdl2basehost.cpp b/platform/SDL2Common/source/sdl2basehost.cpp
index 14e1546..28db663 100644
--- a/platform/SDL2Common/source/sdl2basehost.cpp
+++ b/platform/SDL2Common/source/sdl2basehost.cpp
@@ -293,6 +293,15 @@ void Host::changeStretch(){
}
}
+void Host::forceStretch(StretchOption newStretch) {
+ _changeStretch(newStretch);
+ stretch = newStretch;
+ scaleX = _screenWidth / (float)PicoScreenWidth;
+ scaleY = _screenHeight / (float)PicoScreenHeight;
+ mouseOffsetX = DestR.x;
+ mouseOffsetY = DestR.y;
+}
+
bool Host::shouldQuit() {
return quit == 1;
}
diff --git a/platform/bittboy/source/BittBoyHost.cpp b/platform/bittboy/source/BittBoyHost.cpp
index f253048..c097e83 100644
--- a/platform/bittboy/source/BittBoyHost.cpp
+++ b/platform/bittboy/source/BittBoyHost.cpp
@@ -280,6 +280,15 @@ void Host::changeStretch(){
}
}
+void Host::forceStretch(StretchOption newStretch) {
+ _changeStretch(newStretch);
+ stretch = newStretch;
+ scaleX = _screenWidth / (float)PicoScreenWidth;
+ scaleY = _screenHeight / (float)PicoScreenHeight;
+ mouseOffsetX = DestR.x;
+ mouseOffsetY = DestR.y;
+}
+
InputState_t Host::scanInput(){
currKDown = 0;
currKHeld = 0;
diff --git a/platform/miyoomini/source/MiyooMiniHost.cpp b/platform/miyoomini/source/MiyooMiniHost.cpp
index 38bcd07..d6bfce2 100644
--- a/platform/miyoomini/source/MiyooMiniHost.cpp
+++ b/platform/miyoomini/source/MiyooMiniHost.cpp
@@ -318,6 +318,14 @@ void Host::changeStretch(){
mouseOffsetY = DestR.y;
}
}
+void Host::forceStretch(StretchOption newStretch) {
+ _changeStretch(newStretch);
+ stretch = newStretch;
+ scaleX = _screenWidth / (float)PicoScreenWidth;
+ scaleY = _screenHeight / (float)PicoScreenHeight;
+ mouseOffsetX = DestR.x;
+ mouseOffsetY = DestR.y;
+}
InputState_t Host::scanInput(){
currKDown = 0;
diff --git a/platform/wiiu/source/WiiUHost.cpp b/platform/wiiu/source/WiiUHost.cpp
index 1fd71dd..17fad53 100644
--- a/platform/wiiu/source/WiiUHost.cpp
+++ b/platform/wiiu/source/WiiUHost.cpp
@@ -314,6 +314,15 @@ void Host::changeStretch(){
}
}
+void Host::forceStretch(StretchOption newStretch) {
+ _changeStretch(newStretch);
+ stretch = newStretch;
+ scaleX = _screenWidth / (float)PicoScreenWidth;
+ scaleY = _screenHeight / (float)PicoScreenHeight;
+ mouseOffsetX = DestR.x;
+ mouseOffsetY = DestR.y;
+}
+
InputState_t Host::scanInput(){
currKDown = 0;
uint8_t kUp = 0;
diff --git a/source/FakoSettings.h b/source/FakoSettings.h
index 6a5efcd..d405ee0 100644
--- a/source/FakoSettings.h
+++ b/source/FakoSettings.h
@@ -118,6 +118,7 @@ function updatecursor()
cursorpos = (cursorpos % numitems) + 1
if btnp( ❎ ) or btnp ( 🅾️ ) then
+ printh('cursorpos - 1: ' .. cursorpos-1)
if cursorpos == numitems then -- back
cursorpos = deli(path)
if not cursorpos then
diff --git a/source/host.h b/source/host.h
index bffa937..3fceb68 100644
--- a/source/host.h
+++ b/source/host.h
@@ -82,6 +82,7 @@ class Host {
bool shouldQuit();
void changeStretch();
+ void forceStretch(StretchOption newStretch);
void waitForTargetFps();
@@ -110,6 +111,7 @@ class Host {
//settings
int getSetting(std::string sname);
+ void setSetting(std::string sname, int sdata);
Color* GetPaletteColors();
diff --git a/source/hostCommonFunctions.cpp b/source/hostCommonFunctions.cpp
index a677d40..52c55f1 100644
--- a/source/hostCommonFunctions.cpp
+++ b/source/hostCommonFunctions.cpp
@@ -213,4 +213,28 @@ int Host::getSetting(std::string sname) {
return 0;
}
+}
+
+void Host::setSetting(std::string sname, int sval) {
+ if(sname == "kbmode"){ //why cant you use strings in switch statements in c++ :(
+ Logger_Write("setting KB mode\n");
+ kbmode = (KeyboardOption) sval;
+ }else if(sname == "stretch"){
+ Logger_Write("setting Stretch to");
+ std::string stringval = std::to_string(sval);
+ Logger_Write(stringval.c_str());
+ Logger_Write("\n");
+
+
+ stretch = (StretchOption) sval;
+
+ //force change stretch
+ forceStretch(stretch);
+
+ }else{
+ Logger_Write("Setting ");
+ Logger_Write(sname.c_str());
+ Logger_Write(" not found!");
+ }
+
}
\ No newline at end of file
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index fcbffa3..432e6f9 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -1331,7 +1331,17 @@ int getsetting(lua_State *L) {
int setsetting(lua_State *L) {
//get setting from host
+ const char * str = "";
+ if (lua_isstring(L, 1)){
+ str = lua_tolstring(L, 1, nullptr);
+ }
+ Logger_Write("setting setting ");
+ Logger_Write(str);
+ Logger_Write("\n");
+
+ int sval = lua_tonumber(L,2);
+
+ _vmForLuaApi->setSetting(str,sval);
-
return 1;
}
\ No newline at end of file
diff --git a/source/vm.cpp b/source/vm.cpp
index ebb7b42..fe5c67e 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -1045,4 +1045,10 @@ int Vm::getSetting(std::string sname) {
return _host->getSetting(sname);
+}
+
+void Vm::setSetting(std::string sname, int sval) {
+
+ _host->setSetting(sname,sval);
+
}
\ No newline at end of file
diff --git a/source/vm.h b/source/vm.h
index d4ed2e4..9d6e5ce 100644
--- a/source/vm.h
+++ b/source/vm.h
@@ -148,6 +148,7 @@ class Vm {
//settings
int getSetting(string sname);
+ void setSetting(string sname, int sval);
string getCartBreadcrumb();
string getCartParam();
diff --git a/test/stubhost.cpp b/test/stubhost.cpp
index d1fc3fa..5150816 100644
--- a/test/stubhost.cpp
+++ b/test/stubhost.cpp
@@ -41,6 +41,10 @@ void Host::changeStretch(){
}
+void Host::forceStretch(StretchOption newStretch) {
+
+}
+
void StubHost::stubInput(uint8_t kdown, uint8_t kheld) {
stubCurrKDown = kdown;
stubCurrKHeld = kheld;
@@ -109,6 +113,11 @@ void Host::saveCartData(std::string cartDataKey, std::string contents) {
}
int Host::getSetting(std::string sname) {
+ return 0;
+}
+
+void Host::setSetting(std::string sname, int sval) {
+
}
std::string Host::getCartDirectory() {