summaryrefslogtreecommitdiff
path: root/src/keypad.c
blob: f26c5e2876427f316746526da26037f1561d32a9 (plain)
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
#include "keypad.h"

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
};

int KeypadKeycodeValid(int keycode){
  for(int i=0;i<16;i++){
    if(map[i]==keycode)
      return i;
  }
  return -1;
}


int KeypadGetPressed(){
  int keycode=GetKeyPressed();
  if(keycode){
    return KeypadKeycodeValid(keycode);
  }
  return -1;
}