forked from 0xcds4r/build69-gtasa2.0
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkeyboard.h
96 lines (76 loc) · 1.7 KB
/
keyboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
//
// Powered by tapy.me/weikton
//
#define LAYOUT_ENG 0
#define LAYOUT_RUS 1
#define LAYOUT_NUM 2
#define LOWER_CASE 0
#define UPPER_CASE 1
#define KEY_DEFAULT 0
#define KEY_SHIFT 1
#define KEY_BACKSPACE 2
#define KEY_SWITCH 3
#define KEY_SPACE 4
#define KEY_SEND 5
#define MAX_INPUT_LEN 0xBF
struct kbKey
{
// Ïîçèöèÿ êíîïêè
ImVec2 pos;
// Ïîçèöèÿ ñèìâîëà
ImVec2 symPos;
// Øèðèíà êíîïêè
float width;
// Êîä ñèìâîëà (cp1251 lower/upper case)
char code[2];
// utf8-code (äëÿ ðåíäåðà)
char name[2][4];
// Òèï êíîïêè
int type;
// id êíîïêè
int id;
};
typedef void keyboard_callback(const char* result);
class CKeyBoard
{
friend class CGUI;
public:
CKeyBoard();
~CKeyBoard();
void Open(keyboard_callback* handler);
void Close();
bool IsOpen() { return m_bEnable; }
protected:
void Render();
bool OnTouchEvent(int type, bool multi, int x, int y);
private:
void InitENG();
void InitRU();
void InitNUM();
kbKey* GetKeyFromPos(int x, int y);
void HandleInput(kbKey &key);
void AddCharToInput(char sym);
void DeleteCharFromInput();
void Send();
void setInput(std::string msg);
void clearInput();
void WriteHistory(std::string msg);
bool m_bEnable;
bool m_bInited;
ImVec2 m_Size;
ImVec2 m_Pos;
float m_fKeySizeY;
float m_fFontSize;
int m_iLayout;
int m_iCase;
int m_iPushedKey;
int m_iCurrentPosItem;
bool m_bKeyHistoryPressed[2];
std::vector<std::string> m_szKeyBoardHistory;
std::vector<kbKey> m_Rows[3][4]; // eng, rus, num
std::string m_sInput;
char m_utf8Input[MAX_INPUT_LEN*3 + 0xF];
int m_iInputOffset;
keyboard_callback *m_pHandler;
};