commit db692c4b6df52fe14c9b3974a155043f975c0422
Author: DPS2004 <dpsophinos@gmail.com>
AuthorDate: Mon Feb 28 13:38:10 2022 -0500
Commit: DPS2004 <dpsophinos@gmail.com>
CommitDate: Mon Apr 11 11:28:35 2022 -0400
working emoji input 웃♥🐱
---
platform/windows/source/WindowsHost.cpp | 6 ++--
source/emojiconversion.cpp | 53 +++++++++++++++++++++++++++++++++
source/emojiconversion.h | 3 ++
3 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/platform/windows/source/WindowsHost.cpp b/platform/windows/source/WindowsHost.cpp
index 3e58c9e..2e153e2 100644
--- a/platform/windows/source/WindowsHost.cpp
+++ b/platform/windows/source/WindowsHost.cpp
@@ -17,6 +17,8 @@ using namespace std;
#include "../../../source/filehelpers.h"
#include "../../../source/logger.h"
+#include "../../../source/emojiconversion.h"
+
// sdl
#include <SDL2/SDL.h>
@@ -99,9 +101,9 @@ InputState_t Host::scanInput(){
#if KB_ENABLED
case SDL_TEXTINPUT:
- //Logger_Write(event.text.text);
+ //Logger_Write( charset::upper_to_emoji(event.text.text).c_str() );
//Logger_Write("\n");
- currKBKey = event.text.text;
+ currKBKey = charset::upper_to_emoji(event.text.text);
currKBDown = true;
break;
diff --git a/source/emojiconversion.cpp b/source/emojiconversion.cpp
index b3229b1..2db1635 100644
--- a/source/emojiconversion.cpp
+++ b/source/emojiconversion.cpp
@@ -112,3 +112,56 @@ std::string charset::pico8_to_utf8(std::string const &str)
return ret;
}
+
+
+std::string charset::upper_to_emoji(std::string str)
+{
+
+ std::map<std::string,std::string> uemap = {
+ {"A","█"},
+ {"B","▒"},
+ {"C","🐱"},
+ {"D","⬇️"},
+ {"E","░"},
+ {"F","✽"},
+ {"G","●"},
+ {"H","♥"},
+ {"I","☉"},
+ {"J","웃"},
+ {"K","⌂"},
+ {"L","⬅️"},
+ {"M","😐"},
+ {"N","♪"},
+ {"O","🅾️"},
+ {"P","◆"},
+ {"Q","…"},
+ {"R","➡️"},
+ {"S","★"},
+ {"T","⧗"},
+ {"U","⬆️"},
+ {"V","ˇ"},
+ {"W","∧"},
+ {"X","❎"},
+ {"Y","▤"},
+ {"Z","▥"}
+ };
+
+
+ std::string newstring = "";
+
+ for(unsigned i = 0; i < str.length(); i++){
+
+ std::string c = "";
+ c += str.at(i);
+ auto loc = uemap.find(c);
+
+ if(loc == uemap.end()){
+ newstring += c;
+
+ }else{
+ newstring += uemap.at(c);
+ }
+ }
+
+ return charset::utf8_to_pico8(newstring);
+}
\ No newline at end of file
diff --git a/source/emojiconversion.h b/source/emojiconversion.h
index a701b2b..4ad3049 100644
--- a/source/emojiconversion.h
+++ b/source/emojiconversion.h
@@ -12,6 +12,9 @@ struct charset
// Map 8-bit PICO-8 characters to UTF-8 string views
static std::string_view to_utf8[256];
+
+ // Map uppercase letters to PICO-8 glyphs
+ static std::string upper_to_emoji(std::string str);
private:
static std::regex static_init();