// initialize the keymap void init_keymap(void) { set_keymap(1, hd.buttons[1]); set_keymap(2, hd.buttons[2]); set_keymap(3, hd.buttons[3]); set_keymap(4, hd.buttons[4]); set_keymap(5, hd.buttons[5]); set_keymap(6, hd.buttons[6]); }
static int upload_keymap(USBKeyboard *kb, const KBHwinfo *info, const char *infilename, int mapindex) { if(check_mapindex(info,1,mapindex) != 0) return -1; uint8_t keymap[KEYMAP_NAME_LENGTH+info->num_of_keys]; if(read_keymap_from_file(infilename, keymap,KEYMAP_NAME_LENGTH+info->num_of_keys) == -1) return -1; if(keymap[0] == '\0' || keymap[0] == 0xff) { fprintf(stderr,"Key map data invalid.\n"); return -1; } return set_keymap(kb,mapindex,keymap,sizeof(keymap),0); }
static int delete_keymap(USBKeyboard *kb, const KBHwinfo *info, int mapindex) { if(check_mapindex(info,1,mapindex) != 0) return -1; return set_keymap(kb,mapindex,NULL,0,1); }