-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathkeyboard.h
86 lines (67 loc) · 1.41 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
#pragma once
/*
зачем я это высрал?
*/
#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;
char code[2];
char name[2][4];
int type;
int id;
};
typedef void keyboard_callback(const char* result);
class CKeyBoard
{
friend class CGUI;
public:
CKeyBoard();
~CKeyBoard();
void Open(keyboard_callback* handler, bool hiden = false);
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 addTextToBuffer(std::string msg);
bool m_bEnable;
bool m_bHidenInput;
bool m_bInited;
ImVec2 m_Size;
ImVec2 m_Pos;
float m_fKeySizeY;
float m_fFontSize;
int m_iLayout;
int m_iCase;
int m_iPushedKey;
std::vector<std::string> m_szLastItems;
int m_iCurrentPosItem;
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;
};