diff --git a/platform/3ds/source/3dsHost.cpp b/platform/3ds/source/3dsHost.cpp index f5675934..9e2bc660 100644 --- a/platform/3ds/source/3dsHost.cpp +++ b/platform/3ds/source/3dsHost.cpp @@ -417,6 +417,7 @@ void Host::oneTimeCleanup(){ void Host::setTargetFps(int targetFps){ targetFrameTimeMs = 1000.0 / (float)targetFps; + kb.UpdateTickSpeed(targetFps); } void Host::changeStretch(){ diff --git a/platform/3ds/source/Keyboard.cpp b/platform/3ds/source/Keyboard.cpp index 3903bc02..d322ffe0 100644 --- a/platform/3ds/source/Keyboard.cpp +++ b/platform/3ds/source/Keyboard.cpp @@ -31,6 +31,11 @@ void Keyboard::Toggle(){ } } +void Keyboard::UpdateTickSpeed(int fps){ + + tickSpeed = 60 / fps; //1 at 60, 2 at 30 +} + void Keyboard::UpdateStretch(StretchOption& stretch) { if(enabled){ if(!useEnableStretch){ @@ -81,8 +86,32 @@ void Keyboard::GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& t return; } if (touch.py < KEY_YOFFSET){ + touchDown = false; + repeatTimer = 0; + repeatingKey = false; return; } + if(touchDown){ + repeatTimer += tickSpeed; + if(!repeatingKey){ + if(repeatTimer < REPEAT_WAIT1){ + return; + } + else { + repeatTimer -= REPEAT_WAIT1; + repeatingKey = true; + } + } + else { + if(repeatTimer < REPEAT_WAIT2){ + return; + } + else { + repeatTimer -= REPEAT_WAIT2; + } + } + } + touchDown = true; currKBDown = true; currKBKey = "A"; diff --git a/platform/3ds/source/Keyboard.h b/platform/3ds/source/Keyboard.h index be836d05..7ca9e584 100644 --- a/platform/3ds/source/Keyboard.h +++ b/platform/3ds/source/Keyboard.h @@ -13,6 +13,9 @@ #define KEY_ROWS 6 #define KEY_COLUMNS 12 +#define REPEAT_WAIT1 30 +#define REPEAT_WAIT2 5 + 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" },{"[", "{" },{"]", "}" }}, @@ -28,10 +31,18 @@ class Keyboard { C2D_SpriteSheet spritesheet; C2D_Sprite kbSprite; bool useEnableStretch = false; + bool shift = false; bool ctrl = false; bool alt = false; bool symbol = false; + + bool touchDown = false; + bool repeatingKey = false; + int repeatTimer = 0; + + int tickSpeed = 1; + StretchOption disableStretch; StretchOption enableStretch = AltScreenStretch; @@ -40,6 +51,7 @@ class Keyboard { void Init(); void Toggle(); void UpdateStretch(StretchOption& stretch); + void UpdateTickSpeed(int fps); bool AllowMouse(); void GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& touch); void Draw();