Compare commits

...

1 Commits

Author SHA1 Message Date
  Alessandro Mauri 6691a616e3 basic xkbcommon support 10 months ago
4 changed files with 102 additions and 540 deletions
Split View
  1. +4
    -4
      config.template
  2. +96
    -31
      hkd.c
  3. +0
    -504
      keys.h
  4. +2
    -1
      makefile

+ 4
- 4
config.template View File

@ -40,7 +40,7 @@
# Aliases have to be declared before using them, they can also be concatenated.
# Examples:
# @ term : alacritty
# @ volumeup: amixer -q sset Master 3%+
# - leftmeta, p < term
# - VOLUMEUP < volumeup
@ term : alacritty
@ volumeup: amixer -q sset Master 3%+
# - meta, p < term
- XF86AudioRaiseVolume < volumeup

+ 96
- 31
hkd.c View File

@ -31,6 +31,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <locale.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/epoll.h>
@ -39,11 +40,12 @@
#include <ctype.h>
#include <sys/stat.h>
#include <stdarg.h>
#include "keys.h"
#include <xkbcommon/xkbcommon.h>
#include <linux/input.h>
/* Value defines */
#define FILE_NAME_MAX_LENGTH 255
#define KEY_BUFFER_SIZE 16
#define KEY_BUFFER_SIZE 10
#define BLOCK_SIZE 512
/* ANSI colors escape codes */
@ -75,7 +77,7 @@ const char *config_paths[] = {
};
struct key_buffer {
unsigned short buf[KEY_BUFFER_SIZE];
xkb_keysym_t buf[KEY_BUFFER_SIZE];
unsigned int size;
};
@ -94,6 +96,14 @@ struct hotkey_list_e {
struct hotkey_list_e *next;
};
struct {
struct xkb_context *context;
struct xkb_rule_names names;
struct xkb_keymap *keymap;
struct xkb_state *state;
// struct xkb_compose_state *comp_state;
} keyboard;
struct hotkey_list_e *hotkey_list = NULL;
unsigned long hotkey_size_mask = 0;
char *ext_config_file = NULL;
@ -101,8 +111,8 @@ char *ext_config_file = NULL;
int vflag = 0;
int dead = 0; /* Exit flag */
/* key buffer operations */
int key_buffer_add (struct key_buffer*, unsigned short);
int key_buffer_remove (struct key_buffer*, unsigned short);
int key_buffer_add (struct key_buffer*, xkb_keysym_t);
int key_buffer_remove (struct key_buffer*, xkb_keysym_t);
int key_buffer_compare_fuzzy (struct key_buffer *, struct key_buffer *);
int key_buffer_compare (struct key_buffer *, struct key_buffer *);
void key_buffer_reset (struct key_buffer *);
@ -136,6 +146,8 @@ int main (int argc, char *argv[])
struct sigaction action;
struct input_event event;
struct key_buffer pb = {{0}, 0}; /* Pressed keys buffer */
// struct xkb_compose_table_t *comp_table = NULL;
// const char *locale = NULL;
/* Parse command line arguments */
while ((opc = getopt(argc, argv, "vc:dh")) != -1) {
@ -167,6 +179,34 @@ int main (int argc, char *argv[])
sigaction(SIGUSR1, &action, NULL);
sigaction(SIGCHLD, &action, NULL);
/* Initialize xkbcommon */
if (!(keyboard.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS)))
die("Error initializing xkbcommon context: ");
keyboard.names = (struct xkb_rule_names){
.rules = NULL,
.model = NULL,
.layout = "gb",
.variant = NULL,
.options = NULL,
};
if (!(keyboard.keymap = xkb_keymap_new_from_names(keyboard.context,
&keyboard.names, XKB_KEYMAP_COMPILE_NO_FLAGS)))
die("Error compiling keymap: ");
if (!(keyboard.state = xkb_state_new(keyboard.keymap)))
die("Error creating keyboard state: ");
/*
locale = setlocale(LC_CTYPE, NULL);
if (!(comp_table = xkb_compose_table_new_from_locale(keyboard.context,
locale, XKB_COMPOSE_COMPILE_NO_FLAGS)))
die("Error compiling compose table: ");
if (!(keyboard.comp_state = xkb_compose_state_new(comp_table,
XKB_COMPOSE_TABLE_NO_FLAGS)))
die("Error creating compose state: ");
*/
/* Parse config file */
parse_config_file();
@ -184,12 +224,15 @@ int main (int argc, char *argv[])
/* If a dump is requested print the hotkey list then exit */
if (dump) {
char key_name[64];
printf("DUMPING HOTKEY LIST\n\n");
for (struct hotkey_list_e *tmp = hotkey_list; tmp; tmp = tmp->next) {
printf("Hotkey\n");
printf("\tKeys: ");
for (unsigned int i = 0; i < tmp->data.kb.size; i++)
printf("%s ", code_to_name(tmp->data.kb.buf[i]));
for (unsigned int i = 0; i < tmp->data.kb.size; i++) {
xkb_keysym_get_name(tmp->data.kb.buf[i], key_name, 64);
printf("%s ", key_name);
}
printf("\n\tMatching: %s\n", tmp->fuzzy ? "fuzzy" : "ordered");
printf("\tCommand: %s\n\n", tmp->command);
}
@ -214,8 +257,13 @@ int main (int argc, char *argv[])
int t = 0;
static unsigned int prev_size;
static struct epoll_event ev_type;
static xkb_keycode_t keycode;
static xkb_keysym_t keysym;
// enum xkb_state_component changed;
struct hotkey_list_e *tmp;
char buf[EVENT_BUF_LEN];
static char key_name[64];
// enum xkb_compose_status status;
/* On linux use epoll(2) as it gives better performance */
if (epoll_wait(ev_fd, &ev_type, fd_num, -1) < 0 || dead) {
@ -241,24 +289,32 @@ int main (int argc, char *argv[])
read_b = read(fds[i], &event, sizeof(struct input_event));
if (read_b != sizeof(struct input_event)) continue;
/* Ignore touchpad events */
if (
event.type == EV_KEY &&
event.code != BTN_TOUCH &&
event.code != BTN_TOOL_FINGER &&
event.code != BTN_TOOL_DOUBLETAP &&
event.code != BTN_TOOL_TRIPLETAP
) {
switch (event.value) {
/* Key released */
case 0:
key_buffer_remove(&pb, event.code);
break;
/* Key pressed */
case 1:
key_buffer_add(&pb, event.code);
break;
}
if (event.type != EV_KEY)
continue;
// evdev offset
keycode = event.code + 8;
if (event.value == 2 && !xkb_keymap_key_repeats(
keyboard.keymap, keycode))
continue;
if (event.value) {
keysym = xkb_state_key_get_one_sym(keyboard.state, keycode);
// kbd_compose_state_feed(keyboard.comp_state, keysym);
}
/* status = xkb_compose_state_get_status(keyboard.comp_state);
if (status == XKB_COMPOSE_CANCELLED || status == XKB_COMPOSE_COMPOSED)
xkb_compose_state_reset(kbd->compose_state);
*/
if (event.value) { /* Key pressed */
xkb_state_update_key(keyboard.state,
keycode, XKB_KEY_UP);
key_buffer_add(&pb, keysym);
} else {/* Key released */
xkb_state_update_key(keyboard.state,
keycode, XKB_KEY_DOWN);
key_buffer_remove(&pb, keysym);
}
}
@ -268,7 +324,8 @@ int main (int argc, char *argv[])
if (vflag) {
printf("Pressed keys: ");
for (unsigned int i = 0; i < pb.size; i++)
printf("%s ", code_to_name(pb.buf[i]));
xkb_keysym_get_name(pb.buf[i], key_name, 64);
printf("%s ", key_name);
putchar('\n');
}
@ -290,6 +347,10 @@ int main (int argc, char *argv[])
wait(NULL);
if (!dead)
fprintf(stderr, red("An error occured: %s\n"), errno ? strerror(errno): "idk");
xkb_state_unref(keyboard.state);
xkb_keymap_unref(keyboard.keymap);
// xkb_compose_state_unref(keyboard.comp_state);
xkb_context_unref(keyboard.context);
close(ev_fd);
close(event_watcher);
for (int i = 0; i < fd_num; i++)
@ -300,7 +361,7 @@ int main (int argc, char *argv[])
/* Adds a keycode to the pressed buffer if it is not already present
* Returns non zero if the key was not added. */
int key_buffer_add (struct key_buffer *pb, unsigned short key)
int key_buffer_add (struct key_buffer *pb, xkb_keysym_t key)
{
if (!pb) return 1;
/* Linear search if the key is already buffered */
@ -317,7 +378,7 @@ int key_buffer_add (struct key_buffer *pb, unsigned short key)
/* Removes a keycode from a pressed buffer if it is present returns
* non zero in case of failure (key not present or buffer empty). */
int key_buffer_remove (struct key_buffer *pb, unsigned short key)
int key_buffer_remove (struct key_buffer *pb, xkb_keysym_t key)
{
if (!pb) return 1;
@ -574,7 +635,7 @@ void parse_config_file (void)
char *cmd = NULL;
char *cp_tmp = NULL;
union hotkey_main_data dt = {0};
unsigned short us_tmp = 0;
xkb_keysym_t ks_tmp = 0;
if (ext_config_file) {
switch (wordexp(ext_config_file, &result, 0)) {
@ -779,12 +840,12 @@ void parse_config_file (void)
if (type != ALIAS) {
do {
if (!(us_tmp = key_to_code(cp_tmp))) {
if ((ks_tmp = xkb_keysym_from_name(cp_tmp, XKB_KEYSYM_NO_FLAGS)) == XKB_KEY_NoSymbol) {
die("Error at line %d: "
"%s is not a valid key",
linenum - 1, cp_tmp);
}
if (key_buffer_add(&dt.kb, us_tmp))
if (key_buffer_add(&dt.kb, ks_tmp))
die("Too many keys");
} while ((cp_tmp = strtok(NULL, ",")));
} else {
@ -845,6 +906,7 @@ void parse_config_file (void)
}
}
/*
unsigned short key_to_code (char *key)
{
for (char *tmp = key; *tmp; tmp++) {
@ -857,6 +919,7 @@ unsigned short key_to_code (char *key)
}
return 0;
}
*/
void remove_lock (void)
{
@ -883,6 +946,7 @@ void die(const char *fmt, ...)
exit(errno ? errno : 1);
}
/*
const char * code_to_name (unsigned int code)
{
for (int i = 0; i < array_size_const(key_conversion_table); i++) {
@ -891,6 +955,7 @@ const char * code_to_name (unsigned int code)
}
return "Key not recognized";
}
*/
void usage (void)
{


+ 0
- 504
keys.h View File

@ -1,504 +0,0 @@
#ifndef _H_KEYS
#define _H_KEYS
#include <linux/input.h>
struct {
const char *const name;
const unsigned short value;
} key_conversion_table[] =
{{"ESC", KEY_ESC},
{"1", KEY_1},
{"2", KEY_2},
{"3", KEY_3},
{"4", KEY_4},
{"5", KEY_5},
{"6", KEY_6},
{"7", KEY_7},
{"8", KEY_8},
{"9", KEY_9},
{"0", KEY_0},
{"MINUS", KEY_MINUS},
{"EQUAL", KEY_EQUAL},
{"BACKSPACE", KEY_BACKSPACE},
{"TAB", KEY_TAB},
{"Q", KEY_Q},
{"W", KEY_W},
{"E", KEY_E},
{"R", KEY_R},
{"T", KEY_T},
{"Y", KEY_Y},
{"U", KEY_U},
{"I", KEY_I},
{"O", KEY_O},
{"P", KEY_P},
{"LEFTBRACE", KEY_LEFTBRACE},
{"RIGHTBRACE", KEY_RIGHTBRACE},
{"ENTER", KEY_ENTER},
{"LEFTCTRL", KEY_LEFTCTRL},
{"A", KEY_A},
{"S", KEY_S},
{"D", KEY_D},
{"F", KEY_F},
{"G", KEY_G},
{"H", KEY_H},
{"J", KEY_J},
{"K", KEY_K},
{"L", KEY_L},
{"SEMICOLON", KEY_SEMICOLON},
{"APOSTROPHE", KEY_APOSTROPHE},
{"GRAVE", KEY_GRAVE},
{"LEFTSHIFT", KEY_LEFTSHIFT},
{"BACKSLASH", KEY_BACKSLASH},
{"Z", KEY_Z},
{"X", KEY_X},
{"C", KEY_C},
{"V", KEY_V},
{"B", KEY_B},
{"N", KEY_N},
{"M", KEY_M},
{"COMMA", KEY_COMMA},
{"DOT", KEY_DOT},
{"SLASH", KEY_SLASH},
{"RIGHTSHIFT", KEY_RIGHTSHIFT},
{"KPASTERISK", KEY_KPASTERISK},
{"LEFTALT", KEY_LEFTALT},
{"SPACE", KEY_SPACE},
{"CAPSLOCK", KEY_CAPSLOCK},
{"F1", KEY_F1},
{"F2", KEY_F2},
{"F3", KEY_F3},
{"F4", KEY_F4},
{"F5", KEY_F5},
{"F6", KEY_F6},
{"F7", KEY_F7},
{"F8", KEY_F8},
{"F9", KEY_F9},
{"F10", KEY_F10},
{"NUMLOCK", KEY_NUMLOCK},
{"SCROLLLOCK", KEY_SCROLLLOCK},
{"KP7", KEY_KP7},
{"KP8", KEY_KP8},
{"KP9", KEY_KP9},
{"KPMINUS", KEY_KPMINUS},
{"KP4", KEY_KP4},
{"KP5", KEY_KP5},
{"KP6", KEY_KP6},
{"KPPLUS", KEY_KPPLUS},
{"KP1", KEY_KP1},
{"KP2", KEY_KP2},
{"KP3", KEY_KP3},
{"KP0", KEY_KP0},
{"KPDOT", KEY_KP0},
{"ZENKAKUHANKAKU", KEY_ZENKAKUHANKAKU},
{"102ND", KEY_102ND},
{"F11", KEY_F11},
{"F12", KEY_F12},
{"RO", KEY_RO},
{"KATAKANA", KEY_KATAKANA},
{"HIRAGANA", KEY_HIRAGANA},
{"HENKAN", KEY_HENKAN},
{"KATAKANAHIRAGANA", KEY_KATAKANAHIRAGANA},
{"MUHENKAN", KEY_MUHENKAN},
{"KPJPCOMMA", KEY_KPJPCOMMA},
{"KPENTER", KEY_KPENTER},
{"RIGHTCTRL", KEY_RIGHTCTRL},
{"KPSLASH", KEY_KPSLASH},
{"SYSRQ", KEY_SYSRQ},
{"RIGHTALT", KEY_RIGHTALT},
{"LINEFEED", KEY_LINEFEED},
{"HOME", KEY_HOME},
{"UP", KEY_UP},
{"PAGEUP", KEY_PAGEUP},
{"LEFT", KEY_LEFT},
{"RIGHT", KEY_RIGHT},
{"END", KEY_END},
{"DOWN", KEY_DOWN},
{"PAGEDOWN", KEY_PAGEDOWN},
{"INSERT", KEY_INSERT},
{"DELETE", KEY_DELETE},
{"MACRO", KEY_MACRO},
{"MUTE", KEY_MUTE},
{"VOLUMEDOWN", KEY_VOLUMEDOWN},
{"VOLUMEUP", KEY_VOLUMEUP},
{"POWER", KEY_POWER},
{"KPEQUAL", KEY_KPEQUAL},
{"KPPLUSMINUS", KEY_KPPLUSMINUS},
{"PAUSE", KEY_PAUSE},
{"SCALE", KEY_SCALE},
{"KPCOMMA", KEY_KPCOMMA},
{"HANGEUL", KEY_HANGEUL},
{"HANGUEL", KEY_HANGEUL},
{"HANJA", KEY_HANJA},
{"YEN", KEY_YEN},
{"LEFTMETA", KEY_LEFTMETA},
{"RIGHTMETA", KEY_LEFTMETA},
{"COMPOSE", KEY_COMPOSE},
{"STOP", KEY_STOP},
{"AGAIN", KEY_AGAIN},
{"PROPS", KEY_PROPS},
{"UNDO", KEY_UNDO},
{"FRONT", KEY_FRONT},
{"COPY", KEY_COPY},
{"OPEN", KEY_OPEN},
{"PASTE", KEY_PASTE},
{"FIND", KEY_FIND},
{"CUT", KEY_CUT},
{"HELP", KEY_HELP},
{"MENU", KEY_MENU},
{"CALC", KEY_CALC},
{"SETUP", KEY_SETUP},
{"SLEEP", KEY_SLEEP},
{"WAKEUP", KEY_WAKEUP},
{"FILE", KEY_FILE},
{"SENDFILE", KEY_SENDFILE},
{"DELETEFILE", KEY_DELETEFILE},
{"XFER", KEY_XFER},
{"PROG1", KEY_PROG1},
{"PROG2", KEY_PROG2},
{"WWW", KEY_WWW},
{"MSDOS", KEY_MSDOS},
{"COFFEE", KEY_COFFEE},
{"SCREENLOCK", KEY_COFFEE},
{"DIRECTION", KEY_DIRECTION},
{"CYCLEWINDOWS", KEY_CYCLEWINDOWS},
{"MAIL", KEY_MAIL},
{"BOOKMARKS", KEY_BOOKMARKS},
{"COMPUTER", KEY_COMPUTER},
{"BACK", KEY_BACK},
{"FORWARD", KEY_FORWARD},
{"CLOSECD", KEY_CLOSECD},
{"EJECTCD", KEY_EJECTCD},
{"EJECTCLOSECD", KEY_EJECTCLOSECD},
{"NEXTSONG", KEY_NEXTSONG},
{"PLAYPAUSE", KEY_PLAYPAUSE},
{"PREVIOUSSONG", KEY_PREVIOUSSONG},
{"STOPCD", KEY_STOPCD},
{"RECORD", KEY_RECORD},
{"REWIND", KEY_REWIND},
{"PHONE", KEY_PHONE},
{"ISO", KEY_ISO},
{"CONFIG", KEY_CONFIG},
{"HOMEPAGE", KEY_HOMEPAGE},
{"REFRESH", KEY_REFRESH},
{"EXIT", KEY_EXIT},
{"MOVE", KEY_MOVE},
{"EDIT", KEY_EDIT},
{"SCROLLUP", KEY_SCROLLUP},
{"SCROLLDOWN", KEY_SCROLLDOWN},
{"KPLEFTPAREN", KEY_KPLEFTPAREN},
{"KPRIGHTPAREN", KEY_KPRIGHTPAREN},
{"NEW", KEY_NEW},{"REDO", KEY_REDO},
{"F13", KEY_F13},{"F14", KEY_F14},
{"F15", KEY_F15},{"F16", KEY_F16},
{"F17", KEY_F17},{"F18", KEY_F18},
{"F19", KEY_F19},{"F20", KEY_F20},
{"F21", KEY_F21},{"F22", KEY_F22},
{"F23", KEY_F23},{"F24", KEY_F24},
{"PLAYCD", KEY_PLAYCD},
{"PAUSECD", KEY_PAUSECD},
{"PROG3", KEY_PROG3},
{"PROG4", KEY_PROG4},
{"DASHBOARD", KEY_DASHBOARD},
{"SUSPEND", KEY_SUSPEND},
{"CLOSE", KEY_CLOSE},
{"PLAY", KEY_PLAY},
{"FASTFORWARD", KEY_FASTFORWARD},
{"BASSBOOST", KEY_BASSBOOST},
{"PRINT", KEY_PRINT},
{"HP", KEY_HP},
{"CAMERA", KEY_CAMERA},
{"SOUND", KEY_SOUND},
{"QUESTION", KEY_QUESTION},
{"EMAIL", KEY_EMAIL},
{"CHAT", KEY_CHAT},
{"SEARCH", KEY_SEARCH},
{"CONNECT", KEY_CONNECT},
{"FINANCE", KEY_FINANCE},
{"SPORT", KEY_SPORT},
{"SHOP", KEY_SHOP},
{"ALTERASE", KEY_ALTERASE},
{"CANCEL", KEY_CANCEL},
{"BRIGHTNESSDOWN", KEY_BRIGHTNESSDOWN},
{"BRIGHTNESSUP", KEY_BRIGHTNESSUP},
{"MEDIA", KEY_MEDIA},
{"SWITCHVIDEOMODE", KEY_SWITCHVIDEOMODE},
{"KBDILLUMTOGGLE", KEY_KBDILLUMTOGGLE},
{"KBDILLUMDOWN", KEY_KBDILLUMDOWN},
{"KBDILLUMUP", KEY_KBDILLUMUP},
{"SEND", KEY_SEND},
{"REPLY", KEY_REPLY},
{"FORWARDMAIL", KEY_FORWARDMAIL},
{"SAVE", KEY_SAVE},
{"DOCUMENTS", KEY_DOCUMENTS},
{"BATTERY", KEY_BATTERY},
{"BLUETOOTH", KEY_BLUETOOTH},
{"WLAN", KEY_WLAN},
{"UWB", KEY_UWB},
{"UNKNOWN", KEY_UNKNOWN},
{"VIDEO_NEXT", KEY_VIDEO_NEXT},
{"VIDEO_PREV", KEY_VIDEO_PREV},
{"BRIGHTNESS_CYCLE", KEY_BRIGHTNESS_CYCLE},
{"BRIGHTNESS_ZERO", KEY_BRIGHTNESS_ZERO},
{"DISPLAY_OFF", KEY_DISPLAY_OFF},
{"WIMAX", KEY_WIMAX},
{"RFKILL", KEY_RFKILL},
{"BTN_MISC", BTN_MISC},
{"BTN_0", BTN_0},
{"BTN_1", BTN_1},
{"BTN_2", BTN_2},
{"BTN_3", BTN_3},
{"BTN_4", BTN_4},
{"BTN_5", BTN_5},
{"BTN_6", BTN_6},
{"BTN_7", BTN_7},
{"BTN_8", BTN_8},
{"BTN_9", BTN_9},
{"BTN_MOUSE", BTN_MOUSE},
{"BTN_LEFT", BTN_LEFT},
{"BTN_RIGHT", BTN_RIGHT},
{"BTN_MIDDLE", BTN_MIDDLE},
{"BTN_SIDE", BTN_SIDE},
{"BTN_EXTRA", BTN_EXTRA},
{"BTN_FORWARD", BTN_FORWARD},
{"BTN_BACK", BTN_BACK},
{"BTN_TASK", BTN_TASK},
{"BTN_JOYSTICK", BTN_JOYSTICK},
{"BTN_TRIGGER", BTN_TRIGGER},
{"BTN_THUMB", BTN_THUMB},
{"BTN_THUMB2", BTN_THUMB2},
{"BTN_TOP", BTN_TOP},
{"BTN_TOP2", BTN_TOP2},
{"BTN_PINKIE", BTN_PINKIE},
{"BTN_BASE", BTN_BASE},
{"BTN_BASE2", BTN_BASE2},
{"BTN_BASE3", BTN_BASE3},
{"BTN_BASE4", BTN_BASE4},
{"BTN_BASE5", BTN_BASE5},
{"BTN_BASE6", BTN_BASE6},
{"BTN_DEAD", BTN_DEAD},
{"BTN_GAMEPAD", BTN_GAMEPAD},
{"BTN_A", BTN_A},
{"BTN_B", BTN_B},
{"BTN_C", BTN_C},
{"BTN_X", BTN_X},
{"BTN_Y", BTN_Y},
{"BTN_Z", BTN_Z},
{"BTN_TL", BTN_TL},
{"BTN_TR", BTN_TR},
{"BTN_TL2", BTN_TL2},
{"BTN_TR2", BTN_TR2},
{"BTN_SELECT", BTN_SELECT},
{"BTN_START", BTN_START},
{"BTN_MODE", BTN_MODE},
{"BTN_THUMBL", BTN_THUMBL},
{"BTN_THUMBR", BTN_THUMBR},
{"BTN_DIGI", BTN_DIGI},
{"BTN_TOOL_PEN", BTN_TOOL_PEN},
{"BTN_TOOL_RUBBER", BTN_TOOL_RUBBER},
{"BTN_TOOL_BRUSH", BTN_TOOL_RUBBER},
{"BTN_TOOL_PENCIL", BTN_TOOL_PENCIL},
{"BTN_TOOL_AIRBRUSH", BTN_TOOL_AIRBRUSH},
{"BTN_TOOL_FINGER", BTN_TOOL_FINGER},
{"BTN_TOOL_MOUSE", BTN_TOOL_MOUSE},
{"BTN_TOOL_LENS", BTN_TOOL_LENS},
{"BTN_TOUCH", BTN_TOUCH},
{"BTN_STYLUS", BTN_STYLUS},
{"BTN_STYLUS2", BTN_STYLUS2},
{"BTN_TOOL_DOUBLETAP", BTN_TOOL_DOUBLETAP},
{"BTN_TOOL_TRIPLETAP", BTN_TOOL_TRIPLETAP},
{"BTN_TOOL_QUADTAP", BTN_TOOL_QUADTAP},
{"BTN_WHEEL", BTN_WHEEL},
{"BTN_GEAR_DOWN", BTN_GEAR_DOWN},
{"BTN_GEAR_UP", BTN_GEAR_UP},
{"OK", KEY_OK},
{"SELECT", KEY_SELECT},
{"GOTO", KEY_GOTO},
{"CLEAR", KEY_CLEAR},
{"POWER2", KEY_POWER2},
{"OPTION", KEY_OPTION},
{"INFO", KEY_INFO},
{"TIME", KEY_TIME},
{"VENDOR", KEY_VENDOR},
{"ARCHIVE", KEY_ARCHIVE},
{"PROGRAM", KEY_PROGRAM},
{"CHANNEL", KEY_CHANNEL},
{"FAVORITES", KEY_FAVORITES},
{"EPG", KEY_EPG},
{"PVR", KEY_PVR},
{"MHP", KEY_MHP},
{"LANGUAGE", KEY_LANGUAGE},
{"TITLE", KEY_TITLE},
{"SUBTITLE", KEY_SUBTITLE},
{"ANGLE", KEY_ANGLE},
{"ZOOM", KEY_ZOOM},
{"MODE", KEY_MODE},
{"KEYBOARD", KEY_KEYBOARD},
{"SCREEN", KEY_SCREEN},
{"PC", KEY_PC},
{"TV", KEY_TV},
{"TV2", KEY_TV2},
{"VCR", KEY_VCR},
{"VCR2", KEY_VCR2},
{"SAT", KEY_SAT},
{"SAT2", KEY_SAT2},
{"CD", KEY_CD},
{"TAPE", KEY_TAPE},
{"RADIO", KEY_RADIO},
{"TUNER", KEY_TUNER},
{"PLAYER", KEY_PLAYER},
{"TEXT", KEY_TEXT},
{"DVD", KEY_DVD},
{"AUX", KEY_AUX},
{"MP3", KEY_MP3},
{"AUDIO", KEY_AUDIO},
{"VIDEO", KEY_VIDEO},
{"DIRECTORY", KEY_DIRECTORY},
{"LIST", KEY_LIST},
{"MEMO", KEY_MEMO},
{"CALENDAR", KEY_CALENDAR},
{"RED", KEY_RED},
{"GREEN", KEY_GREEN},
{"YELLOW", KEY_YELLOW},
{"BLUE", KEY_BLUE},
{"CHANNELUP", KEY_CHANNELUP},
{"CHANNELDOWN", KEY_CHANNELDOWN},
{"FIRST", KEY_FIRST},{"LAST", KEY_LAST},
{"AB", KEY_AB},
{"NEXT", KEY_NEXT},
{"RESTART", KEY_RESTART},
{"SLOW", KEY_SLOW},
{"SHUFFLE", KEY_SHUFFLE},
{"BREAK", KEY_BREAK},
{"PREVIOUS", KEY_PREVIOUS},
{"DIGITS", KEY_DIGITS},
{"TEEN", KEY_TEEN},
{"TWEN", KEY_TWEN},
{"VIDEOPHONE", KEY_VIDEOPHONE},
{"GAMES", KEY_GAMES},
{"ZOOMIN", KEY_ZOOMIN},
{"ZOOMOUT", KEY_ZOOMOUT},
{"ZOOMRESET", KEY_ZOOMRESET},
{"WORDPROCESSOR", KEY_WORDPROCESSOR},
{"EDITOR", KEY_EDITOR},
{"SPREADSHEET", KEY_SPREADSHEET},
{"GRAPHICSEDITOR", KEY_GRAPHICSEDITOR},
{"PRESENTATION", KEY_PRESENTATION},
{"DATABASE", KEY_DATABASE},
{"NEWS", KEY_NEWS},
{"VOICEMAIL", KEY_VOICEMAIL},
{"ADDRESSBOOK", KEY_ADDRESSBOOK},
{"MESSENGER", KEY_MESSENGER},
{"DISPLAYTOGGLE", KEY_DISPLAYTOGGLE},
{"SPELLCHECK", KEY_SPELLCHECK},
{"LOGOFF", KEY_LOGOFF},
{"DOLLAR", KEY_DOLLAR},
{"EURO", KEY_EURO},
{"FRAMEBACK", KEY_FRAMEBACK},
{"FRAMEFORWARD", KEY_FRAMEFORWARD},
{"CONTEXT_MENU", KEY_CONTEXT_MENU},
{"MEDIA_REPEAT", KEY_MEDIA_REPEAT},
{"10CHANNELSUP", KEY_10CHANNELSUP},
{"10CHANNELSDOWN", KEY_10CHANNELSDOWN},
{"DEL_EOL", KEY_DEL_EOL},
{"DEL_EOS", KEY_DEL_EOS},
{"INS_LINE", KEY_INS_LINE},
{"DEL_LINE", KEY_DEL_LINE},
{"FN", KEY_FN},
{"FN_ESC", KEY_FN_ESC},
{"FN_F1", KEY_FN_F1},
{"FN_F2", KEY_FN_F2},
{"FN_F3", KEY_FN_F3},
{"FN_F4", KEY_FN_F4},
{"FN_F5", KEY_FN_F5},
{"FN_F6", KEY_FN_F6},
{"FN_F7", KEY_FN_F7},
{"FN_F8", KEY_FN_F8},
{"FN_F9", KEY_FN_F9},
{"FN_F10", KEY_FN_F10},
{"FN_F11", KEY_FN_F11},
{"FN_F12", KEY_FN_F12},
{"FN_1", KEY_FN_1},
{"FN_2", KEY_FN_2},
{"FN_D", KEY_FN_D},
{"FN_E", KEY_FN_E},
{"FN_F", KEY_FN_F},
{"FN_S", KEY_FN_S},
{"FN_B", KEY_FN_B},
{"BRL_DOT1", KEY_BRL_DOT1},
{"BRL_DOT2", KEY_BRL_DOT2},
{"BRL_DOT3", KEY_BRL_DOT3},
{"BRL_DOT4", KEY_BRL_DOT4},
{"BRL_DOT5", KEY_BRL_DOT5},
{"BRL_DOT6", KEY_BRL_DOT6},
{"BRL_DOT7", KEY_BRL_DOT7},
{"BRL_DOT8", KEY_BRL_DOT8},
{"BRL_DOT9", KEY_BRL_DOT9},
{"BRL_DOT10", KEY_BRL_DOT10},
{"NUMERIC_0", KEY_NUMERIC_0},
{"NUMERIC_1", KEY_NUMERIC_1},
{"NUMERIC_2", KEY_NUMERIC_2},
{"NUMERIC_3", KEY_NUMERIC_3},
{"NUMERIC_4", KEY_NUMERIC_4},
{"NUMERIC_5", KEY_NUMERIC_5},
{"NUMERIC_6", KEY_NUMERIC_6},
{"NUMERIC_7", KEY_NUMERIC_7},
{"NUMERIC_8", KEY_NUMERIC_8},
{"NUMERIC_9", KEY_NUMERIC_9},
{"NUMERIC_STAR", KEY_NUMERIC_STAR},
{"NUMERIC_POUND", KEY_NUMERIC_POUND},
{"CAMERA_FOCUS", KEY_CAMERA_FOCUS},
{"WPS_BUTTON", KEY_WPS_BUTTON},
{"TOUCHPAD_TOGGLE", KEY_TOUCHPAD_TOGGLE},
{"TOUCHPAD_ON", KEY_TOUCHPAD_ON},
{"TOUCHPAD_OFF", KEY_TOUCHPAD_OFF},
{"BTN_TRIGGER_HAPPY", BTN_TRIGGER_HAPPY},
{"BTN_TRIGGER_HAPPY1", BTN_TRIGGER_HAPPY1},
{"BTN_TRIGGER_HAPPY2", BTN_TRIGGER_HAPPY2},
{"BTN_TRIGGER_HAPPY3", BTN_TRIGGER_HAPPY3},
{"BTN_TRIGGER_HAPPY4", BTN_TRIGGER_HAPPY4},
{"BTN_TRIGGER_HAPPY5", BTN_TRIGGER_HAPPY5},
{"BTN_TRIGGER_HAPPY6", BTN_TRIGGER_HAPPY6},
{"BTN_TRIGGER_HAPPY7", BTN_TRIGGER_HAPPY7},
{"BTN_TRIGGER_HAPPY8", BTN_TRIGGER_HAPPY8},
{"BTN_TRIGGER_HAPPY9", BTN_TRIGGER_HAPPY9},
{"BTN_TRIGGER_HAPPY10", BTN_TRIGGER_HAPPY10},
{"BTN_TRIGGER_HAPPY11", BTN_TRIGGER_HAPPY11},
{"BTN_TRIGGER_HAPPY12", BTN_TRIGGER_HAPPY12},
{"BTN_TRIGGER_HAPPY13", BTN_TRIGGER_HAPPY13},
{"BTN_TRIGGER_HAPPY14", BTN_TRIGGER_HAPPY14},
{"BTN_TRIGGER_HAPPY15", BTN_TRIGGER_HAPPY15},
{"BTN_TRIGGER_HAPPY16", BTN_TRIGGER_HAPPY16},
{"BTN_TRIGGER_HAPPY17", BTN_TRIGGER_HAPPY17},
{"BTN_TRIGGER_HAPPY18", BTN_TRIGGER_HAPPY18},
{"BTN_TRIGGER_HAPPY19", BTN_TRIGGER_HAPPY19},
{"BTN_TRIGGER_HAPPY20", BTN_TRIGGER_HAPPY20},
{"BTN_TRIGGER_HAPPY21", BTN_TRIGGER_HAPPY21},
{"BTN_TRIGGER_HAPPY22", BTN_TRIGGER_HAPPY22},
{"BTN_TRIGGER_HAPPY23", BTN_TRIGGER_HAPPY23},
{"BTN_TRIGGER_HAPPY24", BTN_TRIGGER_HAPPY24},
{"BTN_TRIGGER_HAPPY25", BTN_TRIGGER_HAPPY25},
{"BTN_TRIGGER_HAPPY26", BTN_TRIGGER_HAPPY26},
{"BTN_TRIGGER_HAPPY27", BTN_TRIGGER_HAPPY27},
{"BTN_TRIGGER_HAPPY28", BTN_TRIGGER_HAPPY28},
{"BTN_TRIGGER_HAPPY29", BTN_TRIGGER_HAPPY29},
{"BTN_TRIGGER_HAPPY30", BTN_TRIGGER_HAPPY30},
{"BTN_TRIGGER_HAPPY31", BTN_TRIGGER_HAPPY31},
{"BTN_TRIGGER_HAPPY32", BTN_TRIGGER_HAPPY32},
{"BTN_TRIGGER_HAPPY33", BTN_TRIGGER_HAPPY33},
{"BTN_TRIGGER_HAPPY34", BTN_TRIGGER_HAPPY34},
{"BTN_TRIGGER_HAPPY35", BTN_TRIGGER_HAPPY35},
{"BTN_TRIGGER_HAPPY36", BTN_TRIGGER_HAPPY36},
{"BTN_TRIGGER_HAPPY37", BTN_TRIGGER_HAPPY37},
{"BTN_TRIGGER_HAPPY38", BTN_TRIGGER_HAPPY38},
{"BTN_TRIGGER_HAPPY39", BTN_TRIGGER_HAPPY39},
{"BTN_TRIGGER_HAPPY40", BTN_TRIGGER_HAPPY40},
/* Aliases */
{"CTRL", KEY_LEFTCTRL},
{"META", KEY_LEFTMETA},
{"ALT", KEY_LEFTALT},
{"SHIFT", KEY_LEFTSHIFT},
{"PRINTSCR", KEY_SYSRQ},
{"MIC_MUTE", KEY_F20}};
#endif

+ 2
- 1
makefile View File

@ -1,5 +1,6 @@
CC ?= gcc
CFLAGS = -Wall -Werror -pedantic --std=c99 -O2
LDFLAGS = -lxkbcommon
VERSION = 0.4
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
@ -7,7 +8,7 @@ MANPREFIX = ${PREFIX}/share/man
hkd: hkd.c
debug:
gcc -Wall -O0 -g hkd.c -o hkd_debug
gcc -Wall -O0 -g hkd.c -lxkbcommon -o hkd_debug
install: hkd
mkdir -p ${DESTDIR}${PREFIX}/bin


Loading…
Cancel
Save