Skip to content

Commit

Permalink
send kb input on touch (just A for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
DPS2004 committed Oct 19, 2023
1 parent 5f1667b commit 2e566bb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
Binary file modified platform/3ds/gfx/kb_draft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions platform/3ds/source/3dsHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ void Host::oneTimeSetup(Audio* audio){
Logger_Write("Citra detected, disabling wide mode!\n");
consoleModel = 3;
}
frdExit();
}

gfxInitDefault();
Expand Down Expand Up @@ -474,8 +475,10 @@ InputState_t Host::scanInput(){
kb.Toggle();
forceStretch(stretch);
}

kb.GetKey(currKBDown, currKBKey, touch);

if (touch.px > 0 && touch.py > 0) {
if (touch.px > 0 && touch.py > 0 && kb.AllowMouse()) {
touchLocationX = (touch.px - mouseOffsetX) * scaleX;
touchLocationY = (touch.py - mouseOffsetY) * scaleY;
mouseBtnState = 1;
Expand All @@ -489,7 +492,10 @@ InputState_t Host::scanInput(){
ConvertInputToP8(currKHeld32),
(int16_t)touchLocationX,
(int16_t)touchLocationY,
mouseBtnState
mouseBtnState,
currKBDown,
currKBKey

};
}

Expand Down
19 changes: 18 additions & 1 deletion platform/3ds/source/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "../../source/logger.h"
#include "../../source/host.h"


Keyboard::Keyboard(){

};
Expand Down Expand Up @@ -71,6 +70,24 @@ void Keyboard::UpdateStretch(StretchOption& stretch) {
}
}

bool Keyboard::AllowMouse(){
return !enabled;
}

void Keyboard::GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& touch){
currKBDown = false;
currKBKey = "";
if(!enabled){
return;
}
if (touch.py < KEY_YOFFSET){
return;
}

currKBDown = true;
currKBKey = "A";
}


void Keyboard::Draw(){
//Logger_Write("Drawing keyboard\n");
Expand Down
25 changes: 24 additions & 1 deletion platform/3ds/source/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,34 @@

#include "../../source/host.h"


#define KEY_WIDTH 30
#define KEY_HEIGHT 36
#define KEY_XOFFSET 0
#define KEY_YOFFSET 24

#define KEY_ROWS 6
#define KEY_COLUMNS 12

const std::string layout[KEY_ROWS][KEY_COLUMNS][2] = {
{{"1", "!" },{"2", "@" },{"3", "#" },{"4", "$" },{"5", "%" },{"6", "^" },{"7", "&" },{"8", "*" },{"9", "(" },{"0", ")" },{"-", "_" },{"=", "=" }},
{{"Q", "q" },{"W", "w" },{"E", "e" },{"R", "r" },{"T", "t" },{"Y", "y" },{"U", "u" },{"I", "i" },{"O", "o" },{"P", "p" },{"[", "{" },{"]", "}" }},
{{"A", "a" },{"S", "s" },{"D", "d" },{"F", "f" },{"G", "g" },{"H", "h" },{"J", "j" },{"K", "k" },{"L", "l" },{";", ":" },{"'", "\""},{"\r","\r"}},
{{"Z", "z" },{"X", "x" },{"C", "c" },{"V", "v" },{"B", "b" },{"N", "n "},{"M", "m" },{",", "<" },{".", ">" },{"/", "?" },{"\\","|" },{"\r","\r"}},
{{"!S","!S"},{"!S","!S"},{"!S","!S"},{" ", " " },{" ", " " },{" ", " " },{" ", " " },{" ", " " },{"!C","!C"},{"!C","!C"},{"!A","!A"},{"!A","!A"}},
{{"\t","\t"},{"\t","\t"},{"!E","!E"},{"!E","!E"},{"..",".."},{"..",".."},{"..",".."},{"..",".."},{"`" ,"~" },{"\b","\b"},{"\b","\b"},{"\b","\b"}}
};

class Keyboard {

bool enabled = false;
C2D_SpriteSheet spritesheet;
C2D_Sprite kbSprite;

bool useEnableStretch = false;
bool shift = false;
bool ctrl = false;
bool alt = false;
bool symbol = false;
StretchOption disableStretch;
StretchOption enableStretch = AltScreenStretch;

Expand All @@ -19,6 +40,8 @@ class Keyboard {
void Init();
void Toggle();
void UpdateStretch(StretchOption& stretch);
bool AllowMouse();
void GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& touch);
void Draw();
void Cleanup();
};

0 comments on commit 2e566bb

Please sign in to comment.