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
|
#include "keypad.h"
/// @brief Define you keymaps here
int map[]={
KEY_X, // 0
KEY_ONE, // 1
KEY_TWO, // 2
KEY_THREE, // 3
KEY_Q, // 4
KEY_W, // 5
KEY_E, // 6
KEY_A, // 7
KEY_S, // 8
KEY_D, // 9
KEY_Z, // A
KEY_C, // B
KEY_FOUR, // C
KEY_R, // D
KEY_F, // E
KEY_V // F
};
/**
* @brief Get hex from keycode (used only in this file)
*
* @param keycode
* @return int
*/
int KeypadGetKey(int keycode){
for(int i=0;i<16;i++){
if(map[i]==keycode)
return i;
}
return -1;
}
int KeypadGetPressed(){
for(int i=0;i<16;i++){
if(IsKeyDown(map[i]))
return i;
}
return -1;
}
|