Parser rewritten to simplify config files + bugfixes
This commit is contained in:
parent
c838c55af2
commit
3846a358c1
9 changed files with 224 additions and 136 deletions
|
@ -1,14 +1,13 @@
|
||||||
#SAMPLE CONFIG FILE FOR A GENERIC KEYBOARD
|
#SAMPLE CONFIG FILE FOR A GENERIC KEYBOARD
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#KEYS MOUSE/KEYBOARD BINDINGS
|
#Examples of Key => Key(s)
|
||||||
KEY_CAPSLOCK = ["KEY_LEFTCTRL"]
|
KEY_CAPSLOCK = ["KEY_LEFTCTRL"]
|
||||||
KEY_LEFTCTRL = ["KEY_CAPSLOCK"]
|
KEY_LEFTCTRL = ["KEY_CAPSLOCK"]
|
||||||
|
#Examples of Modifier(s) + Key => Key(s)
|
||||||
[combinations.keys]
|
|
||||||
KEY_LEFTCTRL-KEY_LEFTSHIFT.KEY_Q = ["KEY_ESC"]
|
KEY_LEFTCTRL-KEY_LEFTSHIFT.KEY_Q = ["KEY_ESC"]
|
||||||
KEY_LEFTSHIFT.KEY_UP = ["KEY_LEFTSHIFT", "KEY_PAGEUP"]
|
KEY_LEFTSHIFT.KEY_UP = ["KEY_LEFTSHIFT", "KEY_PAGEUP"]
|
||||||
KEY_LEFTSHIFT.KEY_DOWN = ["KEY_LEFTSHIFT", "KEY_PAGEDOWN"]
|
KEY_LEFTSHIFT.KEY_DOWN = ["KEY_LEFTSHIFT", "KEY_PAGEDOWN"]
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
#SAMPLE CONFIG FILE FOR A GENERIC MOUSE
|
#SAMPLE CONFIG FILE FOR A GENERIC MOUSE
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
#Axis values are hard coded instead, use SCROLL_WHEEL_UP and SCROLL_WHEEL_DOWN to rebind wheel movements.
|
#Relative and absolute axis events are hard coded, for example use SCROLL_WHEEL_UP and SCROLL_WHEEL_DOWN to rebind wheel movements.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#MOUSE BUTTONS MOUSE/KEYBOARD BINDINGS
|
#Example of Key => Key(s)
|
||||||
BTN_RIGHT = ["KEY_LEFTCTRL", "KEY_C"]
|
BTN_RIGHT = ["KEY_LEFTCTRL", "KEY_C"]
|
||||||
|
#Example of Axis event => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
SCROLL_WHEEL_UP = ["KEY_LEFTCTRL", "KEY_F"]
|
SCROLL_WHEEL_UP = ["KEY_LEFTCTRL", "KEY_F"]
|
||||||
SCROLL_WHEEL_DOWN = ["KEY_LEFTCTRL", "KEY_Q"]
|
SCROLL_WHEEL_DOWN = ["KEY_LEFTCTRL", "KEY_Q"]
|
||||||
|
#Examples of Modifier(s) + Key => Key(s)
|
||||||
[combinations.keys]
|
|
||||||
KEY_LEFTCTRL.BTN_RIGHT = ["KEY_SYSRQ"]
|
KEY_LEFTCTRL.BTN_RIGHT = ["KEY_SYSRQ"]
|
||||||
KEY_LEFTCTRL-KEY_LEFTSHIFT.BTN_LEFT = ["KEY_LEFTSHIFT", "KEY_DELETE"]
|
KEY_LEFTCTRL-KEY_LEFTSHIFT.BTN_LEFT = ["KEY_LEFTSHIFT", "KEY_DELETE"]
|
||||||
|
#Examples of Modifier(s) + Axis event => Key(s)
|
||||||
[combinations.axis]
|
|
||||||
KEY_LEFTCTRL-KEY_LEFTSHIFT.SCROLL_WHEEL_UP = ["KEY_HOME"]
|
KEY_LEFTCTRL-KEY_LEFTSHIFT.SCROLL_WHEEL_UP = ["KEY_HOME"]
|
||||||
KEY_LEFTCTRL-KEY_LEFTSHIFT.SCROLL_WHEEL_DOWN = ["KEY_END"]
|
KEY_LEFTCTRL-KEY_LEFTSHIFT.SCROLL_WHEEL_DOWN = ["KEY_END"]
|
||||||
KEY_LEFTCTRL-KEY_LEFTSHIFT-KEY_LEFTALT.SCROLL_WHEEL_DOWN = ["KEY_LEFTALT", "KEY_F4"]
|
KEY_LEFTCTRL-KEY_LEFTSHIFT-KEY_LEFTALT.SCROLL_WHEEL_DOWN = ["KEY_LEFTALT", "KEY_F4"]
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#SAMPLE CONFIG FILE FOR PLAYSTATION CONTROLLERS
|
#SAMPLE CONFIG FILE FOR PLAYSTATION CONTROLLERS
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
#Relative and absolute axis events are hard coded, for example use RSTICK_UP, RSTICK_DOWN etc to rebind your analog stick.
|
||||||
#This config file is tested for DualShock 3, DualShock 4 and DualSense controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
#This config file is tested for DualShock 3, DualShock 4 and DualSense controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#CONTROLLER MOUSE/KEYBOARD BINDINGS
|
#Examples of Button => Key(s)
|
||||||
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #triangle
|
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #triangle
|
||||||
BTN_EAST = ["KEY_ENTER"] #circle
|
BTN_EAST = ["KEY_ENTER"] #circle
|
||||||
BTN_SOUTH = ["KEY_LEFTSHIFT"] #X
|
BTN_SOUTH = ["KEY_LEFTSHIFT"] #X
|
||||||
|
@ -17,19 +18,23 @@ BTN_SELECT = ["KEY_ESC"] #select
|
||||||
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
||||||
BTN_THUMBL = ["BTN_MIDDLE"] #L3
|
BTN_THUMBL = ["BTN_MIDDLE"] #L3
|
||||||
BTN_MODE = ["KEY_SPACE"] #PS button
|
BTN_MODE = ["KEY_SPACE"] #PS button
|
||||||
|
#Examples of Axis events => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #L2
|
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #L2
|
||||||
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #R2
|
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #R2
|
||||||
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
||||||
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
||||||
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
||||||
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
||||||
|
RSTICK_UP = ["KEY_UP"] #right analog stick up
|
||||||
|
RSTICK_DOWN = ["KEY_DOWN"] #right analog stick down
|
||||||
|
RSTICK_LEFT = ["KEY_LEFT"] #right analog stick left
|
||||||
|
RSTICK_RIGHT = ["KEY_RIGHT"] #right analog stick right
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
CURSOR_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
LSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
SCROLL_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
RSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
CURSOR_STICK = "left" #left, right or none
|
LSTICK = "cursor" #cursor, scroll, bind or disabled
|
||||||
SCROLL_STICK = "right" #left, right or none
|
RSTICK = "bind" #cursor, scroll, bind or disabled
|
||||||
DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
LSTICK_DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
|
RSTICK_DEADZONE = "64" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
GRAB_DEVICE = "false" #gain exclusivity on the device
|
GRAB_DEVICE = "false" #gain exclusivity on the device
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#SAMPLE CONFIG FILE FOR PLAYSTATION 2 CONTROLLERS
|
#SAMPLE CONFIG FILE FOR PLAYSTATION 2 CONTROLLERS
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
#Relative and absolute axis events are hard coded, for example use RSTICK_UP, RSTICK_DOWN etc to rebind your analog stick.
|
||||||
#This config file is tested for DualShock 2 controllers. The "analog" LED on your controller has to be turned on or this daemon won't work properly. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again).
|
#This config file is tested for DualShock 2 controllers. The "analog" LED on your controller has to be turned on or this daemon won't work properly. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again).
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#CONTROLLER MOUSE/KEYBOARD BINDINGS
|
#Examples of Button => Key(s)
|
||||||
BTN_TRIGGER = ["KEY_LEFTMETA", "KEY_J"] #triangle
|
BTN_TRIGGER = ["KEY_LEFTMETA", "KEY_J"] #triangle
|
||||||
BTN_THUMB = ["KEY_ENTER"] #circle
|
BTN_THUMB = ["KEY_ENTER"] #circle
|
||||||
BTN_THUMB2 = ["KEY_LEFTSHIFT"] #X
|
BTN_THUMB2 = ["KEY_LEFTSHIFT"] #X
|
||||||
|
@ -18,17 +19,21 @@ BTN_BASE4 = ["KEY_LEFTMETA", "KEY_D"] #start
|
||||||
BTN_BASE3 = ["KEY_ESC"] #select
|
BTN_BASE3 = ["KEY_ESC"] #select
|
||||||
BTN_BASE6 = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
BTN_BASE6 = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
||||||
BTN_BASE5 = ["BTN_MIDDLE"] #L3
|
BTN_BASE5 = ["BTN_MIDDLE"] #L3
|
||||||
|
#Examples of Axis events => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
||||||
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
||||||
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
||||||
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
||||||
|
RSTICK_UP = ["KEY_UP"] #right analog stick up
|
||||||
|
RSTICK_DOWN = ["KEY_DOWN"] #right analog stick down
|
||||||
|
RSTICK_LEFT = ["KEY_LEFT"] #right analog stick left
|
||||||
|
RSTICK_RIGHT = ["KEY_RIGHT"] #right analog stick right
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
CURSOR_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
LSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
SCROLL_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
RSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
CURSOR_STICK = "left" #left, right or none
|
LSTICK = "cursor" #cursor, scroll, bind or disabled
|
||||||
SCROLL_STICK = "right" #left, right or none
|
RSTICK = "bind" #cursor, scroll, bind or disabled
|
||||||
DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
LSTICK_DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
|
RSTICK_DEADZONE = "64" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
GRAB_DEVICE = "false" #gain exclusivity on the device
|
GRAB_DEVICE = "false" #gain exclusivity on the device
|
|
@ -1,11 +1,12 @@
|
||||||
#SAMPLE CONFIG FILE FOR GOOGLE STADIA CONTROLLERS
|
#SAMPLE CONFIG FILE FOR GOOGLE STADIA CONTROLLERS
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
#Relative and absolute axis events are hard coded, for example use RSTICK_UP, RSTICK_DOWN etc to rebind your analog stick.
|
||||||
#This config file is tested for Stadia controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
#This config file is tested for Stadia controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#CONTROLLER MOUSE/KEYBOARD BINDINGS
|
#Examples of Button => Key(s)
|
||||||
BTN_WEST = ["KEY_LEFTMETA", "KEY_J"] #Y
|
BTN_WEST = ["KEY_LEFTMETA", "KEY_J"] #Y
|
||||||
BTN_EAST = ["KEY_ENTER"] #X
|
BTN_EAST = ["KEY_ENTER"] #X
|
||||||
BTN_SOUTH = ["KEY_LEFTSHIFT"] #A
|
BTN_SOUTH = ["KEY_LEFTSHIFT"] #A
|
||||||
|
@ -21,17 +22,21 @@ BTN_TRIGGER_HAPPY2 = ["BTN_LEFT"] #share/bubbles?
|
||||||
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #R3
|
||||||
BTN_THUMBL = ["BTN_MIDDLE"] #L3
|
BTN_THUMBL = ["BTN_MIDDLE"] #L3
|
||||||
BTN_MODE = ["KEY_SPACE"] #Stadia button
|
BTN_MODE = ["KEY_SPACE"] #Stadia button
|
||||||
|
#Examples of Axis events => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
||||||
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
||||||
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
||||||
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
||||||
|
RSTICK_UP = ["KEY_UP"] #right analog stick up
|
||||||
|
RSTICK_DOWN = ["KEY_DOWN"] #right analog stick down
|
||||||
|
RSTICK_LEFT = ["KEY_LEFT"] #right analog stick left
|
||||||
|
RSTICK_RIGHT = ["KEY_RIGHT"] #right analog stick right
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
CURSOR_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
LSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
SCROLL_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
RSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
CURSOR_STICK = "left" #left, right or none
|
LSTICK = "cursor" #cursor, scroll, bind or disabled
|
||||||
SCROLL_STICK = "right" #left, right or none
|
RSTICK = "bind" #cursor, scroll, bind or disabled
|
||||||
DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
LSTICK_DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
|
RSTICK_DEADZONE = "64" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
GRAB_DEVICE = "false" #gain exclusivity on the device
|
GRAB_DEVICE = "false" #gain exclusivity on the device
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#SAMPLE CONFIG FILE FOR SWITCH JOYCONS
|
#SAMPLE CONFIG FILE FOR SWITCH JOYCONS
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
#Relative and absolute axis events are hard coded, for example use RSTICK_UP, RSTICK_DOWN etc to rebind your analog stick.
|
||||||
#This config file is tested for Switch Joycons (Left and Right). When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
#This config file is tested for Switch Joycons (Left and Right). When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#CONTROLLER MOUSE/KEYBOARD BINDINGS
|
#Examples of Button => Key(s)
|
||||||
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #X
|
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #X
|
||||||
BTN_EAST = ["KEY_ENTER"] #A
|
BTN_EAST = ["KEY_ENTER"] #A
|
||||||
BTN_SOUTH = ["KEY_LEFTSHIFT"] #B
|
BTN_SOUTH = ["KEY_LEFTSHIFT"] #B
|
||||||
|
@ -18,20 +19,24 @@ BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #right stick press
|
||||||
BTN_THUMBL = ["BTN_MIDDLE"] #left stick press
|
BTN_THUMBL = ["BTN_MIDDLE"] #left stick press
|
||||||
BTN_MODE = ["KEY_SPACE"] #home
|
BTN_MODE = ["KEY_SPACE"] #home
|
||||||
BTN_Z = ["BTN_LEFT"] #capture
|
BTN_Z = ["BTN_LEFT"] #capture
|
||||||
|
#Examples of Axis events => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #ZL (and SR on right joycon)
|
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #ZL (and SR on right joycon)
|
||||||
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #ZR (and SR on left joycon)
|
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #ZR (and SR on left joycon)
|
||||||
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
||||||
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
||||||
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
||||||
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
||||||
|
RSTICK_UP = ["KEY_UP"] #right analog stick up
|
||||||
|
RSTICK_DOWN = ["KEY_DOWN"] #right analog stick down
|
||||||
|
RSTICK_LEFT = ["KEY_LEFT"] #right analog stick left
|
||||||
|
RSTICK_RIGHT = ["KEY_RIGHT"] #right analog stick right
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
CURSOR_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
LSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
SCROLL_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
RSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
CURSOR_STICK = "left" #left, right or none
|
LSTICK = "cursor" #cursor, scroll, bind or disabled
|
||||||
SCROLL_STICK = "right" #left, right or none
|
RSTICK = "bind" #cursor, scroll, bind or disabled
|
||||||
DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
LSTICK_DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
SIGNED_AXIS_VALUE = "true" #necessary for Xbox controllers and Switch joycons, use false for other controllers
|
RSTICK_DEADZONE = "64" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
|
16_BIT_AXIS = "true" #necessary for Xbox controllers and Switch joycons, use false for other controllers
|
||||||
GRAB_DEVICE = "false" #gain exclusivity on the device
|
GRAB_DEVICE = "false" #gain exclusivity on the device
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#SAMPLE CONFIG FILE FOR XBOX CONTROLLERS
|
#SAMPLE CONFIG FILE FOR XBOX CONTROLLERS
|
||||||
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization.
|
#Put this in ~/.config/makima and rename it to the exact name of the device as shown by the 'evtest' command, including spaces and capitalization. Omit "/" if present.
|
||||||
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
#You can find all the available keycodes in /usr/include/linux/input-event-codes.h
|
||||||
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
#If you're not sure which keycode corresponds to which key, you can run 'evtest', select your device and press the corresponding key/button.
|
||||||
|
#Relative and absolute axis events are hard coded, for example use RSTICK_UP, RSTICK_DOWN etc to rebind your analog stick.
|
||||||
#This config file is tested for Xbox 360, Xbox One and Xbox Elite 2 controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
#This config file is tested for Xbox 360, Xbox One and Xbox Elite 2 controllers. When using a different controller, if no specific config file for your device is available, change the keycodes on the left according to those of your controller (evtest is your friend again). If your controller has a button to enable/disable analog sticks, make sure they're enabled.
|
||||||
|
|
||||||
[bindings.keys]
|
[remap]
|
||||||
#CONTROLLER MOUSE/KEYBOARD BINDINGS
|
#Examples of Button => Key(s)
|
||||||
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #X
|
BTN_NORTH = ["KEY_LEFTMETA", "KEY_J"] #X
|
||||||
BTN_EAST = ["KEY_ENTER"] #Y
|
BTN_EAST = ["KEY_ENTER"] #Y
|
||||||
BTN_SOUTH = ["KEY_LEFTSHIFT"] #A
|
BTN_SOUTH = ["KEY_LEFTSHIFT"] #A
|
||||||
|
@ -17,20 +18,24 @@ BTN_SELECT = ["KEY_ESC"] #back
|
||||||
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #RS
|
BTN_THUMBR = ["KEY_LEFTMETA", "KEY_Q"] #RS
|
||||||
BTN_THUMBL = ["BTN_MIDDLE"] #LS
|
BTN_THUMBL = ["BTN_MIDDLE"] #LS
|
||||||
BTN_MODE = ["KEY_SPACE"] #Xbox button
|
BTN_MODE = ["KEY_SPACE"] #Xbox button
|
||||||
|
#Examples of Axis events => Key(s)
|
||||||
[bindings.axis]
|
|
||||||
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #RT
|
BTN_TR2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_L"] #RT
|
||||||
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #LT
|
BTN_TL2 = ["KEY_LEFTMETA", "KEY_LEFTSHIFT", "KEY_K"] #LT
|
||||||
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
BTN_DPAD_UP = ["KEY_UP"] #directional pad up
|
||||||
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
BTN_DPAD_RIGHT = ["KEY_RIGHT"] #directional pad right
|
||||||
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
BTN_DPAD_DOWN = ["KEY_DOWN"] #directional pad down
|
||||||
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
BTN_DPAD_LEFT = ["KEY_LEFT"] #directional pad left
|
||||||
|
RSTICK_UP = ["KEY_UP"] #right analog stick up
|
||||||
|
RSTICK_DOWN = ["KEY_DOWN"] #right analog stick down
|
||||||
|
RSTICK_LEFT = ["KEY_LEFT"] #right analog stick left
|
||||||
|
RSTICK_RIGHT = ["KEY_RIGHT"] #right analog stick right
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
CURSOR_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
LSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
SCROLL_SENSITIVITY = "6" #lower value is higher sensitivity, minimum 1
|
RSTICK_SENSITIVITY = "6" #sensitivity when scrolling or moving cursor, lower value is higher sensitivity, minimum 1
|
||||||
CURSOR_STICK = "left" #left, right or none
|
LSTICK = "cursor" #cursor, scroll, bind or disabled
|
||||||
SCROLL_STICK = "right" #left, right or none
|
RSTICK = "bind" #cursor, scroll, bind or disabled
|
||||||
DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
LSTICK_DEADZONE = "5" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
SIGNED_AXIS_VALUE = "true" #necessary for Xbox controllers and Switch joycons, use false for other controllers
|
RSTICK_DEADZONE = "64" #integer between 0 and 128, bigger number is wider deadzone, default 5
|
||||||
|
16_BIT_AXIS = "true" #necessary for Xbox controllers and Switch joycons, use false for other controllers
|
||||||
GRAB_DEVICE = "false" #gain exclusivity on the device
|
GRAB_DEVICE = "false" #gain exclusivity on the device
|
||||||
|
|
|
@ -4,46 +4,33 @@ use evdev::Key;
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, Default)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Bindings {
|
pub struct Bindings {
|
||||||
#[serde(default)]
|
|
||||||
pub keys: HashMap<Key, Vec<Key>>,
|
pub keys: HashMap<Key, Vec<Key>>,
|
||||||
#[serde(default)]
|
|
||||||
pub axis: HashMap<String, Vec<Key>>,
|
pub axis: HashMap<String, Vec<Key>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, Default)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Combinations {
|
pub struct Combinations {
|
||||||
#[serde(default)]
|
|
||||||
pub keys: HashMap<String, HashMap<Key, Vec<Key>>>,
|
pub keys: HashMap<String, HashMap<Key, Vec<Key>>>,
|
||||||
#[serde(default)]
|
|
||||||
pub axis: HashMap<String, HashMap<String, Vec<Key>>>,
|
pub axis: HashMap<String, HashMap<String, Vec<Key>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, Default)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Modifiers {
|
pub struct Modifiers {
|
||||||
pub keys: HashMap<BTreeMap<Key, i32>, HashMap<Key, Vec<Key>>>,
|
pub keys: HashMap<BTreeMap<Key, i32>, HashMap<Key, Vec<Key>>>,
|
||||||
pub axis: HashMap<BTreeMap<Key, i32>, HashMap<String, Vec<Key>>>,
|
pub axis: HashMap<BTreeMap<Key, i32>, HashMap<String, Vec<Key>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Modifiers {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
let keys: HashMap<BTreeMap<Key, i32>, HashMap<Key, Vec<Key>>> = HashMap::new();
|
|
||||||
let axis: HashMap<BTreeMap<Key, i32>, HashMap<String, Vec<Key>>> = HashMap::new();
|
|
||||||
Self {
|
|
||||||
keys: keys,
|
|
||||||
axis: axis
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone)]
|
#[derive(serde::Deserialize, Debug, Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub remap: HashMap<String, Vec<Key>>,
|
||||||
|
#[serde(skip)]
|
||||||
pub bindings: Bindings,
|
pub bindings: Bindings,
|
||||||
#[serde(default)]
|
#[serde(skip)]
|
||||||
pub combinations: Combinations,
|
pub combinations: Combinations,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub modifiers: Modifiers,
|
pub modifiers: Modifiers,
|
||||||
|
@ -56,9 +43,53 @@ impl Config {
|
||||||
let file_content: String = std::fs::read_to_string(file).unwrap();
|
let file_content: String = std::fs::read_to_string(file).unwrap();
|
||||||
let config: Config = toml::from_str(&file_content)
|
let config: Config = toml::from_str(&file_content)
|
||||||
.expect("Couldn't parse config file.");
|
.expect("Couldn't parse config file.");
|
||||||
let mut bindings: Bindings = config.bindings;
|
|
||||||
let combinations: Combinations = config.combinations;
|
|
||||||
let settings: HashMap<String, String> = config.settings;
|
let settings: HashMap<String, String> = config.settings;
|
||||||
|
let remap: HashMap<String, Vec<Key>> = config.remap;
|
||||||
|
let mut bindings: Bindings = Default::default();
|
||||||
|
let mut combinations: Combinations = Default::default();
|
||||||
|
|
||||||
|
let abs = [
|
||||||
|
"DPAD_UP",
|
||||||
|
"DPAD_DOWN",
|
||||||
|
"DPAD_LEFT",
|
||||||
|
"DPAD_RIGHT",
|
||||||
|
"LSTICK_UP",
|
||||||
|
"LSTICK_DOWN",
|
||||||
|
"LSTICK_LEFT",
|
||||||
|
"LSTICK_RIGHT",
|
||||||
|
"RSTICK_UP",
|
||||||
|
"RSTICK_DOWN",
|
||||||
|
"RSTICK_LEFT",
|
||||||
|
"RSTICK_RIGHT",
|
||||||
|
"SCROLLWHEEL_UP",
|
||||||
|
"SCROLLWHEEL_DOWN",
|
||||||
|
"BTN_TL2",
|
||||||
|
"BTN_TR2",
|
||||||
|
];
|
||||||
|
for (input, output) in remap.clone().into_iter() {
|
||||||
|
if input.contains(".") {
|
||||||
|
let (mods, key) = input.split_once(".").unwrap();
|
||||||
|
if abs.contains(&key) {
|
||||||
|
if !combinations.axis.contains_key(&mods.to_string()) {
|
||||||
|
combinations.axis.insert(mods.to_string(), HashMap::from([(key.to_string(), output)]));
|
||||||
|
} else {
|
||||||
|
combinations.axis.get_mut(mods).unwrap().insert(key.to_string(), output);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !combinations.keys.contains_key(&mods.to_string()) {
|
||||||
|
combinations.keys.insert(mods.to_string(), HashMap::from([(Key::from_str(key).expect("Invalid KEY value."), output)]));
|
||||||
|
} else {
|
||||||
|
combinations.keys.get_mut(mods).unwrap().insert(Key::from_str(key).expect("Invalid KEY value."), output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if abs.contains(&input.as_str()) {
|
||||||
|
bindings.axis.insert(input, output);
|
||||||
|
} else {
|
||||||
|
bindings.keys.insert(Key::from_str(input.as_str()).expect("Invalid KEY value."), output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let empty_modmap = BTreeMap::from ([
|
let empty_modmap = BTreeMap::from ([
|
||||||
(Key::KEY_LEFTSHIFT, 0),
|
(Key::KEY_LEFTSHIFT, 0),
|
||||||
|
@ -69,23 +100,24 @@ impl Config {
|
||||||
(Key::KEY_RIGHTALT, 0),
|
(Key::KEY_RIGHTALT, 0),
|
||||||
(Key::KEY_LEFTMETA, 0)
|
(Key::KEY_LEFTMETA, 0)
|
||||||
]);
|
]);
|
||||||
let mut modifiers = Modifiers::new();
|
let mut modifiers: Modifiers = Default::default();
|
||||||
for (mods, map) in combinations.keys.iter() {
|
|
||||||
let mods_vector = mods.split("-").map(str::to_string).collect::<Vec<String>>();
|
for (mods, key) in combinations.keys.iter() {
|
||||||
|
let mods_vector = mods.split("+").map(str::to_string).collect::<Vec<String>>();
|
||||||
let mut modmap = empty_modmap.clone();
|
let mut modmap = empty_modmap.clone();
|
||||||
for modifier in mods_vector {
|
for modifier in mods_vector {
|
||||||
modmap.insert(Key::from_str(&modifier).unwrap(), 1);
|
modmap.insert(Key::from_str(&modifier).unwrap(), 1);
|
||||||
}
|
}
|
||||||
modifiers.keys.insert(modmap, map.clone());
|
modifiers.keys.insert(modmap, key.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (mods, map) in combinations.axis.iter() {
|
for (mods, key) in combinations.axis.iter() {
|
||||||
let mods_vector = mods.split("-").map(str::to_string).collect::<Vec<String>>();
|
let mods_vector = mods.split("+").map(str::to_string).collect::<Vec<String>>();
|
||||||
let mut modmap = empty_modmap.clone();
|
let mut modmap = empty_modmap.clone();
|
||||||
for modifier in mods_vector {
|
for modifier in mods_vector {
|
||||||
modmap.insert(Key::from_str(&modifier).unwrap(), 1);
|
modmap.insert(Key::from_str(&modifier).unwrap(), 1);
|
||||||
}
|
}
|
||||||
modifiers.axis.insert(modmap, map.clone());
|
modifiers.axis.insert(modmap, key.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut pad_x: Vec<Key> = bindings.axis.get("BTN_DPAD_LEFT")
|
let mut pad_x: Vec<Key> = bindings.axis.get("BTN_DPAD_LEFT")
|
||||||
|
@ -123,6 +155,7 @@ impl Config {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
name: file_name,
|
name: file_name,
|
||||||
|
remap,
|
||||||
bindings,
|
bindings,
|
||||||
combinations,
|
combinations,
|
||||||
modifiers,
|
modifiers,
|
||||||
|
|
|
@ -44,7 +44,6 @@ impl EventReader {
|
||||||
let rstick_position = Arc::new(Mutex::new(position_vector.clone()));
|
let rstick_position = Arc::new(Mutex::new(position_vector.clone()));
|
||||||
let device_is_connected: Arc<Mutex<bool>> = Arc::new(Mutex::new(true));
|
let device_is_connected: Arc<Mutex<bool>> = Arc::new(Mutex::new(true));
|
||||||
let virt_dev = Arc::new(Mutex::new(VirtualDevices::new()));
|
let virt_dev = Arc::new(Mutex::new(VirtualDevices::new()));
|
||||||
|
|
||||||
let lstick_function = config.get(&"default".to_string()).unwrap()
|
let lstick_function = config.get(&"default".to_string()).unwrap()
|
||||||
.settings.get("LSTICK").unwrap_or(&"cursor".to_string()).to_string();
|
.settings.get("LSTICK").unwrap_or(&"cursor".to_string()).to_string();
|
||||||
let lstick_sensitivity: u64 = config.get(&"default".to_string()).unwrap()
|
let lstick_sensitivity: u64 = config.get(&"default".to_string()).unwrap()
|
||||||
|
@ -100,6 +99,8 @@ impl EventReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn event_loop(&self) {
|
pub async fn event_loop(&self) {
|
||||||
|
let mut lstick_values = HashMap::from([("x", 0), ("y", 0)]);
|
||||||
|
let mut rstick_values = HashMap::from([("x", 0), ("y", 0)]);
|
||||||
let mut stream = self.stream.lock().await;
|
let mut stream = self.stream.lock().await;
|
||||||
while let Some(Ok(event)) = stream.next().await {
|
while let Some(Ok(event)) = stream.next().await {
|
||||||
match (event.event_type(), RelativeAxisType(event.code()), AbsoluteAxisType(event.code())) {
|
match (event.event_type(), RelativeAxisType(event.code()), AbsoluteAxisType(event.code())) {
|
||||||
|
@ -113,7 +114,7 @@ impl EventReader {
|
||||||
_ => Option::None,
|
_ => Option::None,
|
||||||
};
|
};
|
||||||
if let Some(event_string) = event_string_option {
|
if let Some(event_string) = event_string_option {
|
||||||
self.convert_axis_events(event, &event_string, true, false).await;
|
self.convert_axis_events(event, &event_string, true).await;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(_, _, AbsoluteAxisType::ABS_HAT0X) => {
|
(_, _, AbsoluteAxisType::ABS_HAT0X) => {
|
||||||
|
@ -123,7 +124,7 @@ impl EventReader {
|
||||||
1 => "BTN_DPAD_RIGHT".to_string(),
|
1 => "BTN_DPAD_RIGHT".to_string(),
|
||||||
_ => "BTN_DPAD_X".to_string(),
|
_ => "BTN_DPAD_X".to_string(),
|
||||||
};
|
};
|
||||||
self.convert_axis_events(event, &event_string, false, false).await;
|
self.convert_axis_events(event, &event_string, false).await;
|
||||||
},
|
},
|
||||||
(_, _, AbsoluteAxisType::ABS_HAT0Y) => {
|
(_, _, AbsoluteAxisType::ABS_HAT0Y) => {
|
||||||
let event_string: String = match event.value() {
|
let event_string: String = match event.value() {
|
||||||
|
@ -132,7 +133,7 @@ impl EventReader {
|
||||||
1 => "BTN_DPAD_DOWN".to_string(),
|
1 => "BTN_DPAD_DOWN".to_string(),
|
||||||
_ => "BTN_DPAD_Y".to_string(),
|
_ => "BTN_DPAD_Y".to_string(),
|
||||||
};
|
};
|
||||||
self.convert_axis_events(event, &event_string, false, false).await;
|
self.convert_axis_events(event, &event_string, false).await;
|
||||||
},
|
},
|
||||||
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_X | AbsoluteAxisType::ABS_Y) => {
|
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_X | AbsoluteAxisType::ABS_Y) => {
|
||||||
if ["cursor", "scroll"].contains(&self.settings.lstick.function.as_str()) {
|
if ["cursor", "scroll"].contains(&self.settings.lstick.function.as_str()) {
|
||||||
|
@ -148,17 +149,35 @@ impl EventReader {
|
||||||
else if AbsoluteAxisType(event.code()) == AbsoluteAxisType::ABS_Y { "y" }
|
else if AbsoluteAxisType(event.code()) == AbsoluteAxisType::ABS_Y { "y" }
|
||||||
else { "none" };
|
else { "none" };
|
||||||
let event_string_option: Option<String> = match clamped_value {
|
let event_string_option: Option<String> = match clamped_value {
|
||||||
-1 if axis == "x" => Option::Some("LSTICK_LEFT".to_string()),
|
-1 if axis == "x" && lstick_values.get("x").unwrap() != &-1 => {
|
||||||
-1 if axis == "y" => Option::Some("LSTICK_UP".to_string()),
|
lstick_values.insert("x", -1);
|
||||||
0 if axis == "x" => Option::Some("LSTICK_X".to_string()),
|
Option::Some("LSTICK_LEFT".to_string())
|
||||||
0 if axis == "y" => Option::Some("LSTICK_Y".to_string()),
|
},
|
||||||
1 if axis == "x" => Option::Some("LSTICK_RIGHT".to_string()),
|
-1 if axis == "y" && lstick_values.get("y").unwrap() != &-1 => {
|
||||||
1 if axis == "y" => Option::Some("LSTICK_DOWN".to_string()),
|
lstick_values.insert("y", -1);
|
||||||
|
Option::Some("LSTICK_UP".to_string())
|
||||||
|
},
|
||||||
|
0 if axis == "x" && lstick_values.get("x").unwrap() != &0 => {
|
||||||
|
lstick_values.insert("x", 0);
|
||||||
|
Option::Some("LSTICK_X".to_string())
|
||||||
|
},
|
||||||
|
0 if axis == "y" && lstick_values.get("y").unwrap() != &0 => {
|
||||||
|
lstick_values.insert("y", 0);
|
||||||
|
Option::Some("LSTICK_Y".to_string())
|
||||||
|
},
|
||||||
|
1 if axis == "x" && lstick_values.get("x").unwrap() != &1 => {
|
||||||
|
lstick_values.insert("x", 1);
|
||||||
|
Option::Some("LSTICK_RIGHT".to_string())
|
||||||
|
},
|
||||||
|
1 if axis == "y" && lstick_values.get("y").unwrap() != &1 => {
|
||||||
|
lstick_values.insert("y", 1);
|
||||||
|
Option::Some("LSTICK_DOWN".to_string())
|
||||||
|
},
|
||||||
_ => Option::None,
|
_ => Option::None,
|
||||||
};
|
};
|
||||||
if let Some(event_string) = event_string_option {
|
if let Some(event_string) = event_string_option {
|
||||||
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
||||||
self.convert_axis_events(clamped_event, &event_string, false, false).await;
|
self.convert_axis_events(clamped_event, &event_string, false).await;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.emit_default_event(event).await;
|
self.emit_default_event(event).await;
|
||||||
|
@ -178,27 +197,49 @@ impl EventReader {
|
||||||
else if AbsoluteAxisType(event.code()) == AbsoluteAxisType::ABS_RY { "y" }
|
else if AbsoluteAxisType(event.code()) == AbsoluteAxisType::ABS_RY { "y" }
|
||||||
else { "none" };
|
else { "none" };
|
||||||
let event_string_option: Option<String> = match clamped_value {
|
let event_string_option: Option<String> = match clamped_value {
|
||||||
-1 if axis == "x" => Option::Some("RSTICK_LEFT".to_string()),
|
-1 if axis == "x" && rstick_values.get("x").unwrap() != &-1 => {
|
||||||
-1 if axis == "y" => Option::Some("RSTICK_UP".to_string()),
|
rstick_values.insert("x", -1);
|
||||||
0 if axis == "x" => Option::Some("RSTICK_X".to_string()),
|
Option::Some("RSTICK_LEFT".to_string())
|
||||||
0 if axis == "y" => Option::Some("RSTICK_Y".to_string()),
|
},
|
||||||
1 if axis == "x" => Option::Some("RSTICK_RIGHT".to_string()),
|
-1 if axis == "y" && rstick_values.get("y").unwrap() != &-1 => {
|
||||||
1 if axis == "y" => Option::Some("RSTICK_DOWN".to_string()),
|
rstick_values.insert("y", -1);
|
||||||
|
Option::Some("RSTICK_UP".to_string())
|
||||||
|
},
|
||||||
|
0 if axis == "x" && rstick_values.get("x").unwrap() != &0 => {
|
||||||
|
rstick_values.insert("x", 0);
|
||||||
|
Option::Some("RSTICK_X".to_string())
|
||||||
|
},
|
||||||
|
0 if axis == "y" && rstick_values.get("y").unwrap() != &0 => {
|
||||||
|
rstick_values.insert("y", 0);
|
||||||
|
Option::Some("RSTICK_Y".to_string())
|
||||||
|
},
|
||||||
|
1 if axis == "x" && rstick_values.get("x").unwrap() != &1 => {
|
||||||
|
rstick_values.insert("x", 1);
|
||||||
|
Option::Some("RSTICK_RIGHT".to_string())
|
||||||
|
},
|
||||||
|
1 if axis == "y" && rstick_values.get("y").unwrap() != &1 => {
|
||||||
|
rstick_values.insert("y", 1);
|
||||||
|
Option::Some("RSTICK_DOWN".to_string())
|
||||||
|
},
|
||||||
_ => Option::None,
|
_ => Option::None,
|
||||||
};
|
};
|
||||||
if let Some(event_string) = event_string_option {
|
if let Some(event_string) = event_string_option {
|
||||||
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
||||||
self.convert_axis_events(clamped_event, &event_string, false, false).await;
|
self.convert_axis_events(clamped_event, &event_string, false).await;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.emit_default_event(event).await;
|
self.emit_default_event(event).await;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_Z) => {
|
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_Z) => {
|
||||||
self.convert_axis_events(event, &"BTN_TL2".to_string(), false, true).await;
|
let clamped_value = if event.value() > 0 { 1 } else { 0 };
|
||||||
|
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
||||||
|
self.convert_axis_events(clamped_event, &"BTN_TL2".to_string(), false).await;
|
||||||
},
|
},
|
||||||
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_RZ) => {
|
(EventType::ABSOLUTE, _, AbsoluteAxisType::ABS_RZ) => {
|
||||||
self.convert_axis_events(event, &"BTN_TR2".to_string(), false, true).await;
|
let clamped_value = if event.value() > 0 { 1 } else { 0 };
|
||||||
|
let clamped_event = InputEvent::new_now(event.event_type(), event.code(), clamped_value);
|
||||||
|
self.convert_axis_events(clamped_event, &"BTN_TR2".to_string(), false).await;
|
||||||
},
|
},
|
||||||
_ => {self.emit_default_event(event).await;}
|
_ => {self.emit_default_event(event).await;}
|
||||||
}
|
}
|
||||||
|
@ -224,19 +265,12 @@ impl EventReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn convert_axis_events(&self, event: InputEvent, event_string: &String, send_zero: bool, clamp_value: bool) {
|
async fn convert_axis_events(&self, event: InputEvent, event_string: &String, send_zero: bool) {
|
||||||
let path = self.config.get(&get_active_window(&self.current_desktop, &self.config).await).unwrap();
|
let path = self.config.get(&get_active_window(&self.current_desktop, &self.config).await).unwrap();
|
||||||
let modifiers = self.modifiers.lock().await.clone();
|
let modifiers = self.modifiers.lock().await.clone();
|
||||||
let value = {
|
|
||||||
if clamp_value && event.value() > 1 {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
event.value()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if let Some(event_hashmap) = path.modifiers.axis.get(&modifiers) {
|
if let Some(event_hashmap) = path.modifiers.axis.get(&modifiers) {
|
||||||
if let Some(event_list) = event_hashmap.get(event_string) {
|
if let Some(event_list) = event_hashmap.get(event_string) {
|
||||||
self.emit_event_without_modifiers(event_list, &modifiers, value).await;
|
self.emit_event_without_modifiers(event_list, &modifiers, event.value()).await;
|
||||||
if send_zero {
|
if send_zero {
|
||||||
self.emit_event_without_modifiers(event_list, &modifiers, 0).await;
|
self.emit_event_without_modifiers(event_list, &modifiers, 0).await;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +279,7 @@ impl EventReader {
|
||||||
}
|
}
|
||||||
if let Some(event_list) = path.bindings.axis.get(event_string) {
|
if let Some(event_list) = path.bindings.axis.get(event_string) {
|
||||||
println!("{:?}", event_list);
|
println!("{:?}", event_list);
|
||||||
self.emit_event(event_list, value).await;
|
self.emit_event(event_list, event.value()).await;
|
||||||
if send_zero {
|
if send_zero {
|
||||||
self.emit_event_without_modifiers(event_list, &modifiers, 0).await;
|
self.emit_event_without_modifiers(event_list, &modifiers, 0).await;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue