This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bab3d01
commit 976e7ae
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ class ActionType(Enum): | |
LayerOnAction = 3 | ||
LayerModAction = 4 | ||
LayerToggleAction = 5 | ||
LayerTapAction = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from evdev.events import KeyEvent | ||
|
||
import host | ||
import mapper | ||
from action.action_type import ActionType | ||
from log import debug | ||
|
||
|
||
class LayerTapAction: | ||
type: ActionType | ||
layer: int | ||
key: int | ||
|
||
def __init__(self, layer, key): | ||
self.type = ActionType.LayerTapAction | ||
self.layer = layer | ||
self.key = key | ||
|
||
def handle(self, ui, e, config, pos, *args): | ||
debug('-- handling layer tap action --') | ||
if e.value == KeyEvent.key_down: | ||
debug(f'LT is pressed, enabling layer [{self.layer}]') | ||
mapper.enable_layer(self.layer, self, config) | ||
else: | ||
debug(f'LT is released, disabling layer [{self.layer}]') | ||
mapper.disable_layer(ui, self.layer, config) | ||
since_last_press = (e.timestamp() - mapper.last_press_timestamps[pos]) * 1000 | ||
debug(f'since last press: {since_last_press}') | ||
if since_last_press <= config.tapping_term: | ||
debug('writing key press') | ||
host.write_tap(ui, self.key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters