mirror of
https://github.com/FunKey-Project/fkgpiod.git
synced 2025-12-12 16:08:51 +01:00
change RESET command to CLEAR, add default fkgpiod.conf
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
parent
b482c729bd
commit
16b7a7b167
@ -28,6 +28,7 @@ $ echo "LOAD /etc/fkgpiod.conf" > /tmp/fkgpiod.fifo
|
|||||||
## Available script commands (commands are not case sensitive):
|
## Available script commands (commands are not case sensitive):
|
||||||
|
|
||||||
```
|
```
|
||||||
|
CLEAR Clear the button mapping
|
||||||
DUMP Dump the button mapping
|
DUMP Dump the button mapping
|
||||||
KEYDOWN <key_code> Send a key down event with the given keycode
|
KEYDOWN <key_code> Send a key down event with the given keycode
|
||||||
KEYPRESS <key_code> Send key press event with the given keycode
|
KEYPRESS <key_code> Send key press event with the given keycode
|
||||||
@ -35,7 +36,6 @@ KEYUP <key_code> Send a key up event with the
|
|||||||
LOAD <configuration_file> Load a configuration file
|
LOAD <configuration_file> Load a configuration file
|
||||||
MAP <button_combination> TO KEY <key_code> Map a button combination to a keycode
|
MAP <button_combination> TO KEY <key_code> Map a button combination to a keycode
|
||||||
MAP <button_combination> TO COMMAND <shell_command> Map a button combination to a Shell command
|
MAP <button_combination> TO COMMAND <shell_command> Map a button combination to a Shell command
|
||||||
RESET Reset the button mapping
|
|
||||||
SLEEP <delays_ms> Sleep for the given delay in ms
|
SLEEP <delays_ms> Sleep for the given delay in ms
|
||||||
TYPE <character_string> Type in a character string
|
TYPE <character_string> Type in a character string
|
||||||
UNMAP <button_combination> Unmap a button combination
|
UNMAP <button_combination> Unmap a button combination
|
||||||
@ -48,13 +48,15 @@ where:
|
|||||||
- <configuration_file> is the full path to a configurtion file
|
- <configuration_file> is the full path to a configurtion file
|
||||||
- <delay_ms> is a delay in ms
|
- <delay_ms> is a delay in ms
|
||||||
- <character_string> is a character string
|
- <character_string> is a character string
|
||||||
- <key_code> is among:
|
- <key_code> is taken from the Linux key and button codes
|
||||||
|
(https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h),
|
||||||
|
which in turn is modeled after USB HUT 1.12 (see http://www.usb.org/developers/hidpage):
|
||||||
- KEY_0 to KEY_9, KEY_A to KEY_Z
|
- KEY_0 to KEY_9, KEY_A to KEY_Z
|
||||||
- KEY_F1 to KEY_F24, KEY_KP0 to KEY_KP9, KEY_PROG1 to KEY_PROG4
|
- KEY_F1 to KEY_F24, KEY_KP0 to KEY_KP9, KEY_PROG1 to KEY_PROG4
|
||||||
- BTN_0 to BTN_9, BTN_A to BTN_C, BTN_X to BTN_Z, BTN_BASE2 to BTN_BASE6
|
- BTN_0 to BTN_9, BTN_A to BTN_C, BTN_X to BTN_Z, BTN_BASE2 to BTN_BASE6
|
||||||
- BTN_BACK, BTN_BASE, BTN_DEAD, BTN_EXTRA, BTN_FORWARD, BTN_GAMEPAD, BTN_JOYSTICK, BTN_LEFT,
|
- BTN_BACK, BTN_BASE, BTN_DEAD, BTN_EXTRA, BTN_FORWARD, BTN_GAMEPAD, BTN_JOYSTICK, BTN_LEFT,
|
||||||
BTN_MIDDLE, BTN_MISC, BTN_MODE, BTN_MOUSE, BTN_PINKIE, BTN_RIGHT, BTN_SELECT, BTN_SIDE,
|
BTN_MIDDLE, BTN_MISC, BTN_MODE, BTN_MOUSE, BTN_PINKIE, BTN_RIGHT, BTN_SELECT, BTN_SIDE,
|
||||||
BTN_START, BTN_TASK, BTN_THUMB, BTN_THUMB2, BTN_THUMBL, BTN_THUMBR, BTN_TL, BTN_TL2,
|
BTN_START, BTN_TASK, BTN_THUMB, BTN_THUMB2, BTN_THUMBL, BTN_THUMBR, BTN_TL, BTN_TL2,
|
||||||
BTN_TOP, BTN_TOP2, BTN_TR, BTN_TR2, BTN_TRIGGER,
|
BTN_TOP, BTN_TOP2, BTN_TR, BTN_TR2, BTN_TRIGGER,
|
||||||
- KEY_102ND, KEY_AGAIN, KEY_ALTERASE, KEY_APOSTROPHE, KEY_BACK, KEY_BACKSLASH, KEY_BACKSPACE,
|
- KEY_102ND, KEY_AGAIN, KEY_ALTERASE, KEY_APOSTROPHE, KEY_BACK, KEY_BACKSLASH, KEY_BACKSPACE,
|
||||||
KEY_BASSBOOST, KEY_BATTERY, KEY_BLUETOOTH, KEY_BOOKMARKS, KEY_BRIGHTNESSDOWN,
|
KEY_BASSBOOST, KEY_BATTERY, KEY_BLUETOOTH, KEY_BOOKMARKS, KEY_BRIGHTNESSDOWN,
|
||||||
|
|||||||
25
fkgpiod.conf
Normal file
25
fkgpiod.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
CLEAR
|
||||||
|
MAP FN TO KEY KEY_K
|
||||||
|
MAP START TO KEY KEY_S
|
||||||
|
MAP UP TO KEY KEY_U
|
||||||
|
MAP LEFT TO KEY KEY_L
|
||||||
|
MAP FN+LEFT TO KEY KEY_J
|
||||||
|
MAP DOWN TO KEY KEY_D
|
||||||
|
MAP FN+DOWN TO KEY KEY_H
|
||||||
|
MAP RIGHT TO KEY KEY_R
|
||||||
|
MAP FN+RIGHT TO KEY KEY_I
|
||||||
|
MAP R TO KEY KEY_N
|
||||||
|
MAP FN+R TO KEY KEY_O
|
||||||
|
MAP L TO KEY KEY_M
|
||||||
|
MAP FN+L TO KEY KEY_V
|
||||||
|
MAP A TO KEY KEY_A
|
||||||
|
MAP B TO KEY KEY_B
|
||||||
|
MAP X TO KEY KEY_X
|
||||||
|
MAP Y TO KEY KEY_Y
|
||||||
|
MAP MENU TO KEY KEY_Q
|
||||||
|
MAP FN+UP TO COMMAND snap
|
||||||
|
MAP FN+A TO COMMAND quick_action_volume_up
|
||||||
|
MAP FN+Y TO COMMAND quick_action_volume_down
|
||||||
|
MAP FN+X TO COMMAND quick_action_bright_up
|
||||||
|
MAP FN+B TO COMMAND quick_action_bright_down
|
||||||
|
MAP FN+L+R TO COMMAND display_notif_system_stats
|
||||||
6
main.c
6
main.c
@ -61,6 +61,7 @@ static void print_usage(void)
|
|||||||
"\n"
|
"\n"
|
||||||
"Available script commands (commands are not case sensitive):\n"
|
"Available script commands (commands are not case sensitive):\n"
|
||||||
"-----------------------------------------------------------\n"
|
"-----------------------------------------------------------\n"
|
||||||
|
"CLEAR Clear the button mapping\n"
|
||||||
"DUMP Dump the button mapping\n"
|
"DUMP Dump the button mapping\n"
|
||||||
"KEYDOWN <keycode> Send a key down event with the given keycode\n"
|
"KEYDOWN <keycode> Send a key down event with the given keycode\n"
|
||||||
"KEYPRESS <keycode> Send key press event with the given keycode\n"
|
"KEYPRESS <keycode> Send key press event with the given keycode\n"
|
||||||
@ -68,7 +69,6 @@ static void print_usage(void)
|
|||||||
"LOAD <configuration_file> Load a configuration file\n"
|
"LOAD <configuration_file> Load a configuration file\n"
|
||||||
"MAP <button_combination> TO KEY <keycode> Map a button combination to a keycode\n"
|
"MAP <button_combination> TO KEY <keycode> Map a button combination to a keycode\n"
|
||||||
"MAP <button_combination> TO COMMAND <shell_command> Map a button combination to a Shell command\n"
|
"MAP <button_combination> TO COMMAND <shell_command> Map a button combination to a Shell command\n"
|
||||||
"RESET Reset the button mapping\n"
|
|
||||||
"SLEEP <delays_ms> Sleep for the given delay in ms\n"
|
"SLEEP <delays_ms> Sleep for the given delay in ms\n"
|
||||||
"TYPE <string> Type in a string\n"
|
"TYPE <string> Type in a string\n"
|
||||||
"UNMAP <button_combination> Unmap a button combination\n"
|
"UNMAP <button_combination> Unmap a button combination\n"
|
||||||
@ -80,7 +80,9 @@ static void print_usage(void)
|
|||||||
" - <configuration_file> is the full path to a configurtion file\n"
|
" - <configuration_file> is the full path to a configurtion file\n"
|
||||||
" - <delay_ms> is a delay in ms\n"
|
" - <delay_ms> is a delay in ms\n"
|
||||||
" - <string> is a character string\n"
|
" - <string> is a character string\n"
|
||||||
" - <keycode> is among:\n"
|
" - <keycode> is taken from the Linux key and button codes\n"
|
||||||
|
" (https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h),\n"
|
||||||
|
" which in turn is modeled after USB HUT 1.12 (see http://www.usb.org/developers/hidpage):\n"
|
||||||
" - KEY_0 to KEY_9, KEY_A to KEY_Z\n"
|
" - KEY_0 to KEY_9, KEY_A to KEY_Z\n"
|
||||||
" - KEY_F1 to KEY_F24, KEY_KP0 to KEY_KP9, KEY_PROG1 to KEY_PROG4\n"
|
" - KEY_F1 to KEY_F24, KEY_KP0 to KEY_KP9, KEY_PROG1 to KEY_PROG4\n"
|
||||||
" - BTN_0 to BTN_9, BTN_A to BTN_C, BTN_X to BTN_Z, BTN_BASE2 to BTN_BASE6\n"
|
" - BTN_0 to BTN_9, BTN_A to BTN_C, BTN_X to BTN_Z, BTN_BASE2 to BTN_BASE6\n"
|
||||||
|
|||||||
@ -119,8 +119,8 @@ void init_mapping_list(mapping_list_t *list)
|
|||||||
list->prev = list;
|
list->prev = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Empty a mpping list */
|
/* Clear a mapping list */
|
||||||
void reset_mapping_list(mapping_list_t *list)
|
void clear_mapping_list(mapping_list_t *list)
|
||||||
{
|
{
|
||||||
struct mapping_list_t *p, *n;
|
struct mapping_list_t *p, *n;
|
||||||
mapping_t *tmp;
|
mapping_t *tmp;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ typedef struct mapping_t {
|
|||||||
} mapping_t;
|
} mapping_t;
|
||||||
|
|
||||||
void init_mapping_list(mapping_list_t *list);
|
void init_mapping_list(mapping_list_t *list);
|
||||||
void reset_mapping_list(mapping_list_t *list);
|
void clear_mapping_list(mapping_list_t *list);
|
||||||
mapping_t *first_mapping(mapping_list_t *list);
|
mapping_t *first_mapping(mapping_list_t *list);
|
||||||
mapping_t *next_mapping(mapping_t *mapping);
|
mapping_t *next_mapping(mapping_t *mapping);
|
||||||
bool last_mapping(const mapping_list_t *list, const mapping_t *mapping);
|
bool last_mapping(const mapping_list_t *list, const mapping_t *mapping);
|
||||||
|
|||||||
@ -72,7 +72,7 @@ static const char *gpio_names[] = {GPIOS};
|
|||||||
static const keyword_t valid_commands[] = {
|
static const keyword_t valid_commands[] = {
|
||||||
{"MAP", STATE_MAP},
|
{"MAP", STATE_MAP},
|
||||||
{"UNMAP", STATE_UNMAP},
|
{"UNMAP", STATE_UNMAP},
|
||||||
{"RESET", STATE_RESET},
|
{"CLEAR", STATE_CLEAR},
|
||||||
{"LOAD", STATE_LOAD},
|
{"LOAD", STATE_LOAD},
|
||||||
{"SLEEP", STATE_SLEEP},
|
{"SLEEP", STATE_SLEEP},
|
||||||
{"KEYUP", STATE_KEYUP},
|
{"KEYUP", STATE_KEYUP},
|
||||||
@ -274,7 +274,7 @@ bool parse_config_line(char *line, mapping_list_t *list,
|
|||||||
} while (token_end != NULL);
|
} while (token_end != NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_RESET:
|
case STATE_CLEAR:
|
||||||
case STATE_DUMP:
|
case STATE_DUMP:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -348,9 +348,9 @@ bool parse_config_line(char *line, mapping_list_t *list,
|
|||||||
*monitored_gpio_mask &= ~gpio_mask;
|
*monitored_gpio_mask &= ~gpio_mask;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_RESET:
|
case STATE_CLEAR:
|
||||||
LOG_DEBUG("RESET\n");
|
LOG_DEBUG("CLEAR\n");
|
||||||
reset_mapping_list(list);
|
clear_mapping_list(list);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_LOAD:
|
case STATE_LOAD:
|
||||||
|
|||||||
@ -61,7 +61,7 @@ typedef enum {GPIOS} button_t;
|
|||||||
X(STATE_INIT, "INIT") \
|
X(STATE_INIT, "INIT") \
|
||||||
X(STATE_MAP, "MAP") \
|
X(STATE_MAP, "MAP") \
|
||||||
X(STATE_UNMAP, "UNMAP") \
|
X(STATE_UNMAP, "UNMAP") \
|
||||||
X(STATE_RESET, "RESET") \
|
X(STATE_CLEAR, "CLEAR") \
|
||||||
X(STATE_LOAD, "LOAD") \
|
X(STATE_LOAD, "LOAD") \
|
||||||
X(STATE_SLEEP, "SLEEP") \
|
X(STATE_SLEEP, "SLEEP") \
|
||||||
X(STATE_KEYUP, "KEYUP") \
|
X(STATE_KEYUP, "KEYUP") \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user