Project

General

Profile

Revision 271

files forgotten

View differences:

proj/include/makecode_map.h
1
#ifndef MAKE_CODE_MAP_H_
2
#define MAKE_CODE_MAP_H_
3

  
4
#define BASE_CODE    0x02
5
#define ERROR_CODE      0
6

  
7
#include <stdint.h>
8

  
9
/**
10
 * @brief Maps make code into char
11
 * @param code      Make code to map.
12
 * @return 0 if the char isn't valid, otherwise the character.
13
 */
14
char (map_makecode)(uint8_t code);
15

  
16
#endif /* end of include guard: MAKE_CODE_MAP_H_ */
0 17

  
proj/src/makecode_map.c
1
#include "makecode_map.h"
2

  
3
const char makecode_map[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\'', ERROR_CODE /*«*/, ERROR_CODE /*escape*/,
4
                            ERROR_CODE /*tab*/, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '+', ERROR_CODE /* ´ */, ERROR_CODE /*enter*/,
5
                            ERROR_CODE /*ctrl*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ERROR_CODE /* Ç */, ERROR_CODE /* º */, '\\', ERROR_CODE /*lshift*/, '~',
6
                            'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '-', ERROR_CODE /*rshift*/, ERROR_CODE /*unkown*/, ERROR_CODE /*alt*/, ' ' /*space*/};
7

  
8
const int size = sizeof(makecode_map);
9

  
10

  
11
char (map_makecode)(uint8_t code) {
12
    int key = code - BASE_CODE;
13
    if (key < 0 || key >= size) return ERROR_CODE;
14
    return makecode_map[key];
15
}
0 16

  

Also available in: Unified diff