Skip to content

Commit

Permalink
darken pressed down key
Browse files Browse the repository at this point in the history
  • Loading branch information
DPS2004 committed Oct 19, 2023
1 parent 24d912e commit d80e034
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
42 changes: 39 additions & 3 deletions platform/3ds/source/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,48 @@ void Keyboard::GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& t
}


void Keyboard::DarkenRect(int x, int y, int w){
int rectx = x*KEY_WIDTH+KEY_XOFFSET;
int recty = y*KEY_HEIGHT+KEY_YOFFSET;
int rectw = w*KEY_WIDTH;

if(x == 0){
rectx = 0;
rectw += KEY_XOFFSET;
}

if(x + w == KEY_COLUMNS){
rectw += KEY_XOFFSET;
}

C2D_DrawRectSolid(rectx, recty, 1, rectw, KEY_HEIGHT,darkenColor);
}

void Keyboard::Draw(){
//Logger_Write("Drawing keyboard\n");
if(enabled){
C2D_DrawSprite(&kbSprite);
if(!enabled){
return;

}

C2D_DrawSprite(&kbSprite);

if(touchDown){
DarkenRect(keyX,keyY,1);
}

if(shift){
DarkenRect(0,4,3);
}
if(ctrl){
DarkenRect(8,4,2);
}
if(alt){
DarkenRect(10,4,2);
}
if(symbol){
DarkenRect(2,5,2);
}

}

void Keyboard::Cleanup(){
Expand Down
3 changes: 3 additions & 0 deletions platform/3ds/source/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const std::string layout[KEY_ROWS][KEY_COLUMNS][2] = {
{{"\t","\t"},{"\t","\t"},{"!E","!E"},{"!E","!E"},{"..",".."},{"..",".."},{"..",".."},{"..",".."},{"`" ,"~" },{"\b","\b"},{"\b","\b"},{"\b","\b"}}
};

const u32 darkenColor = C2D_Color32(0x00, 0x00, 0x00, 0x80);

class Keyboard {

bool enabled = false;
Expand Down Expand Up @@ -59,6 +61,7 @@ class Keyboard {
void UpdateTickSpeed(int fps);
bool AllowMouse();
void GetKey(bool& currKBDown, std::string& currKBKey, touchPosition& touch);
void DarkenRect(int x, int y, int w);
void Draw();
void Cleanup();
};

0 comments on commit d80e034

Please sign in to comment.