commit c0f94e00027d2b99a6f131ee897458c4f82f4c36
Author: DPS2004 <dpsophinos@gmail.com>
AuthorDate: Mon Feb 28 11:37:48 2022 -0500
Commit: DPS2004 <dpsophinos@gmail.com>
CommitDate: Mon Apr 11 11:28:35 2022 -0400
stat(31) works (mostly!)
---
platform/windows/source/WindowsHost.cpp | 6 ++++--
source/Input.cpp | 9 +++++++--
source/Input.h | 4 +++-
source/host.h | 1 +
source/hostVmShared.h | 1 +
source/picoluaapi.cpp | 4 ++--
source/vm.cpp | 4 ++--
7 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/platform/windows/source/WindowsHost.cpp b/platform/windows/source/WindowsHost.cpp
index 2b50a27..3e58c9e 100644
--- a/platform/windows/source/WindowsHost.cpp
+++ b/platform/windows/source/WindowsHost.cpp
@@ -92,6 +92,7 @@ InputState_t Host::scanInput(){
stretchKeyPressed = false;
currKBDown = false;
+ currKBKey = "";
while (SDL_PollEvent(&event)) {
switch (event.type) {
@@ -100,7 +101,7 @@ InputState_t Host::scanInput(){
case SDL_TEXTINPUT:
//Logger_Write(event.text.text);
//Logger_Write("\n");
-
+ currKBKey = event.text.text;
currKBDown = true;
break;
@@ -182,7 +183,8 @@ InputState_t Host::scanInput(){
(int16_t)mouseX,
(int16_t)mouseY,
picoMouseState,
- currKBDown
+ currKBDown,
+ currKBKey
};
}
diff --git a/source/Input.cpp b/source/Input.cpp
index 8549b81..58546c5 100644
--- a/source/Input.cpp
+++ b/source/Input.cpp
@@ -56,9 +56,9 @@ void Input::SetMouse(int16_t mouseX, int16_t mouseY, uint8_t mouseBtnState){
_mouseBtnState = mouseBtnState;
}
-void Input::SetKeyboard(bool kbDown){
+void Input::SetKeyboard(bool kbDown, std::string kbKey){
_kbDown = kbDown;
-
+ _kbKey = kbKey;
}
uint8_t Input::btn(){
@@ -105,3 +105,8 @@ uint8_t Input::getMouseBtnState() {
bool Input::getKeyDown() {
return _kbDown;
}
+
+const char* Input::getKey() {
+ return _kbKey.c_str();
+}
+
diff --git a/source/Input.h b/source/Input.h
index b708d64..29d158e 100644
--- a/source/Input.h
+++ b/source/Input.h
@@ -13,13 +13,14 @@ class Input{
int16_t _mouseY;
uint8_t _mouseBtnState;
bool _kbDown;
+ std::string _kbKey;
public:
Input(PicoRam* memory);
void SetState(uint8_t kdown, uint8_t kheld);
void SetMouse(int16_t mouseX, int16_t mouseY, uint8_t mouseBtnState);
- void SetKeyboard(bool kbdown);
+ void SetKeyboard(bool kbdown, std::string kbkey);
uint8_t btn();
uint8_t btnp();
@@ -35,4 +36,5 @@ class Input{
uint8_t getMouseBtnState();
bool getKeyDown();
+ const char* getKey();
};
\ No newline at end of file
diff --git a/source/host.h b/source/host.h
index 9888e29..f9b3225 100644
--- a/source/host.h
+++ b/source/host.h
@@ -30,6 +30,7 @@ class Host {
uint8_t currKHeld;
bool currKBDown = false;
+ std::string currKBKey = "";
bool lDown = false;
bool rDown = false;
diff --git a/source/hostVmShared.h b/source/hostVmShared.h
index 6c9107e..2222ece 100644
--- a/source/hostVmShared.h
+++ b/source/hostVmShared.h
@@ -73,6 +73,7 @@ struct InputState_t {
int16_t mouseY;
uint8_t mouseBtnState;
bool KBdown;
+ std::string KBkey;
};
enum PrintMode_t
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index a1307ca..eaadbb3 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -866,9 +866,9 @@ int stat(lua_State *L) {
lua_pushboolean(L, _inputForLuaApi->getKeyDown());
return 1;
break;
- //string of key pressed (blank for now)
+ //string of key pressed
case 31:
- lua_pushstring(L, "");
+ lua_pushstring(L, _inputForLuaApi->getKey());
return 1;
break;
//mouse x
diff --git a/source/vm.cpp b/source/vm.cpp
index 80b8b8f..269f279 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -862,11 +862,11 @@ void Vm::update_buttons() {
_input->SetState(inputState.KDown, inputState.KHeld);
if (_memory->drawState.devkitMode) {
_input->SetMouse(inputState.mouseX, inputState.mouseY, inputState.mouseBtnState);
- _input->SetKeyboard(inputState.KBdown);
+ _input->SetKeyboard(inputState.KBdown,inputState.KBkey);
}
else {
_input->SetMouse(0, 0, 0);
- _input->SetKeyboard(false);
+ _input->SetKeyboard(false,"");
}
}