persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
keyboard.cpp
Go to the documentation of this file.
1#include "keyboard.hpp"
2#include <string>
3
4int OnScreenKeyboard::evaluateInput(touchPosition* touch)
5{
6 if (touch == nullptr)
7 {
8 return 0;
9 }
10
11 for (KeyRow& row : keyboardRows)
12 {
13 if (touch->py >= row.topY && touch->py <= row.bottomY)
14 {
15 char c = row.checkRow(touch->px);
16 if (c == static_cast<char>(KEYCODES::CAPSLOCK))
17 {
19 return static_cast<char>(
20 KEYCODES::CAPSLOCK); // currently returning this so the screen image can be changed
21 }
22 else if (c == static_cast<char>(KEYCODES::SHIFT))
23 {
25 return static_cast<int>(KEYCODES::SHIFT);
26 }
27 if (isShift)
28 {
29 c = toupper(c);
30 isShift = false;
31 }
32 else if (isCapsLock)
33 {
34 c = toupper(c);
35 }
36 return c;
37 }
38 }
39 return 0;
40}
41
43{
44 isShift = false;
45 isCapsLock = false;
46}
int evaluateInput(touchPosition *touch)
Checks a touch input against the keyboard positions and returns pressed charcater.
Definition keyboard.cpp:4
KeyRow keyboardRows[6]
Definition keyboard.hpp:101
void reset()
Resets all internal variables to their defaults.
Definition keyboard.cpp:42
Acts as an onscreen keyboard and converts touch inputs into characters.
@ CAPSLOCK
Zero is reserved for not touching the keyboard.
Definition keyboard.hpp:18
Stores a row of keys on a keyboard and their associated y boundaries.
Definition keyboard.hpp:51