forked from jtothebell/fake-08
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draw toggleable keyboard to bottom screen
- Loading branch information
Showing
7 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--atlas -f rgba8888 -z none | ||
kb_draft.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include "Keyboard.h" | ||
|
||
#include <citro2d.h> | ||
|
||
#include "../../source/logger.h" | ||
#include "../../source/host.h" | ||
|
||
|
||
Keyboard::Keyboard(){ | ||
|
||
}; | ||
|
||
void Keyboard::Init(){ | ||
Logger_Write("Initializing keyboard\n"); | ||
|
||
romfsInit(); | ||
spritesheet = C2D_SpriteSheetLoad("romfs:/gfx/keyboard.t3x"); | ||
C2D_SpriteFromSheet(&kbSprite, spritesheet, 0); | ||
C2D_SpriteSetPos(&kbSprite,0,0); | ||
|
||
enabled = false; | ||
} | ||
|
||
void Keyboard::Toggle(){ | ||
enabled = !enabled; | ||
if(enabled){ | ||
|
||
Logger_Write("KB Enabled\n"); | ||
} | ||
else { | ||
Logger_Write("KB Disabled\n"); | ||
} | ||
} | ||
|
||
void Keyboard::UpdateStretch(StretchOption& stretch) { | ||
if(enabled){ | ||
if(!useEnableStretch){ | ||
useEnableStretch = true; | ||
if(enableStretch == AltScreenStretch){ //first time keyboard has changed the stretch, match current stretch | ||
if(stretch == AltScreenPixelPerfect){ | ||
enableStretch = PixelPerfect; | ||
} | ||
else if(stretch == AltScreenStretch){ | ||
enableStretch = StretchToFit; | ||
} | ||
else { | ||
enableStretch = stretch; | ||
} | ||
} | ||
disableStretch = stretch; | ||
stretch = enableStretch; | ||
|
||
} | ||
else { | ||
if(stretch == AltScreenPixelPerfect){ | ||
stretch = PixelPerfect; | ||
} | ||
if(stretch == AltScreenStretch){ | ||
stretch = StretchToFit; | ||
} | ||
} | ||
} | ||
else { | ||
if(useEnableStretch){ | ||
useEnableStretch = false; | ||
if(enableStretch != AltScreenStretch){ | ||
enableStretch = stretch; | ||
stretch = disableStretch; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
void Keyboard::Draw(){ | ||
//Logger_Write("Drawing keyboard\n"); | ||
if(enabled){ | ||
C2D_DrawSprite(&kbSprite); | ||
} | ||
|
||
} | ||
|
||
void Keyboard::Cleanup(){ | ||
C2D_SpriteSheetFree(spritesheet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <citro2d.h> | ||
|
||
#include "../../source/host.h" | ||
|
||
class Keyboard { | ||
|
||
bool enabled = false; | ||
C2D_SpriteSheet spritesheet; | ||
C2D_Sprite kbSprite; | ||
|
||
bool useEnableStretch = false; | ||
StretchOption disableStretch; | ||
StretchOption enableStretch = AltScreenStretch; | ||
|
||
public: | ||
Keyboard(); | ||
void Init(); | ||
void Toggle(); | ||
void UpdateStretch(StretchOption& stretch); | ||
void Draw(); | ||
void Cleanup(); | ||
}; |