-
Notifications
You must be signed in to change notification settings - Fork 0
/
libex_key.c
executable file
·169 lines (121 loc) · 4.55 KB
/
libex_key.c
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* -------------------------------------------------------------------------- */
/* (c) ali@balarabe.com [libex_key.c] */
/* -------------------------------------------------------------------------- */
#include "libex_c_precompiled.h"
#include "libex_key_.h"
#if defined INCLUDED_LIBEX_KEY_H
#include "libex_config_.h"
#include "libex_call_.h"
#include "libex_.h"
#include "libex_type_.h"
#if defined __cplusplus_cli
#pragma unmanaged
#endif
/* -------------------------------------------------------------------------- */
NAMESPACE(c_)
/* -------------------------------------------------------------------------- */
/* Functions: Modifier Keys */
/* returns true if the 'alt' key is being held. */
PUBLIC bool key_alt( void ) { /*F*/
GO (UID(FC97D7));
bool ret = false;
#if PLATFORM_LINUX
IMPLEMENT_LINUX(); /* TODO: How to find out if ALT key is down? */
#endif
#if PLATFORM_WIN32
ret = (GetKeyState_win(VK_MENU_win) < 0);
#endif
RETURN(ret);
} /* key_alt */
/* returns true if the 'control' key is being held. */
PUBLIC bool key_control( void ) { /*F*/
GO (UID(FC209D));
bool ret = false;
#if PLATFORM_LINUX
IMPLEMENT_LINUX(); /* TODO: How to detect CONTROL key down on Linux? */
#endif
#if PLATFORM_WIN32
ret = (GetKeyState_win(VK_CONTROL_win) < 0);
#endif
RETURN(ret);
} /* key_control */
/* returns true if the 'shift' key is being held. */
PUBLIC bool key_shift( void ) { /*F*/
GO (UID(F2AAFC));
bool ret = false;
#if PLATFORM_LINUX
IMPLEMENT_LINUX(); /* TODO: How to detect SHIFT key down on Linux? */
#endif /* PLATFORM_LINUX */
#if PLATFORM_WIN32
ret = (GetKeyState_win(VK_SHIFT_win) < 0);
#endif
RETURN(ret);
} /* key_shift */
/* -------------------------------------------------------------------------- */
/* Functions: */
PUBLIC bool key_down( const key_code_enum key_ ) { /*F*/
GO (UID(FD0992));
bool ret = false;
#if PLATFORM_LINUX
UNUSED(key_);
IMPLEMENT_LINUX(); /* TODO: How to detect a specific key press Linux? */
#endif /* PLATFORM_LINUX */
#if PLATFORM_WIN32
ret = GetKeyState_win(key_to_code(key_)) < 0;
#endif
RETURN(ret);
} /* key_down */
PUBLIC key_code_enum key_from_code( const uint32_t char_ ) { /*F*/
GO (UID(F2A48B));
const key_code_enum ret = CAST(key_code_enum, char_);
RETURN(ret);
} /* key_from_code */
PUBLIC uint32_t key_to_code( const key_code_enum key_ ) { /*F*/
GO (UID(F0EFB6));
const uint32_t ret = CAST(uint32_t, key_);
RETURN(ret);
} /* key_to_code */
/*
UNUSED KEYS:
have you ever seen a keyboard with so many function keys?
VK_F13_win
VK_F14_win
VK_F15_win
VK_F16_win
VK_F17_win
VK_F18_win
VK_F19_win
VK_F20_win
VK_F21_win
VK_F22_win
VK_F23_win
VK_F24_win
these are special bells and whistles
VK_BROWSER_BACK_win
VK_BROWSER_FORWARD_win
VK_BROWSER_REFRESH_win
VK_BROWSER_STOP_win
VK_BROWSER_SEARCH_win
VK_BROWSER_FAVORITES_win
VK_BROWSER_HOME_win
VK_VOLUME_MUTE_win
VK_VOLUME_DOWN_win
VK_VOLUME_UP_win
VK_MEDIA_NEXT_TRACK_win
VK_MEDIA_PREV_TRACK_win
VK_MEDIA_STOP_win
VK_MEDIA_PLAY_PAUSE_win
VK_LAUNCH_MAIL_win
VK_LAUNCH_MEDIA_SELECT_win
VK_LAUNCH_APP1_win
VK_LAUNCH_APP2_win
mouse buttons (let mouse class handle that)
VK_LBUTTON_win
VK_RBUTTON_win
VK_MBUTTON_win
are these game console keys ?
VK_XBUTTON1_win
VK_XBUTTON2_win
*/
END_NAMESPACE /*c_*/
#endif /*eof*/