Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

Commit

Permalink
#14 refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Aug 28, 2020
1 parent 7b0bcce commit 20dfe40
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions action/layer_on_action.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from evdev.events import KeyEvent

import host
import mapper
from action.action_type import ActionType
from log import debug
Expand All @@ -14,8 +13,9 @@ def __init__(self, layer):
self.type = ActionType.LayerOnAction
self.layer = layer

def handle(self, ui, e, config, *args):
def handle(self, _, e, *args):
debug('-- handling layer on action --')
mapper.active_layers[self.layer] = e.value == KeyEvent.key_down
if e.value == KeyEvent.key_up:
host.release_layer_keys(ui, self.layer, config)
mapper.enable_layer(self.layer)
else:
mapper.disable_layer(self.layer)
11 changes: 11 additions & 0 deletions mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ def find_key(pos, config):
layer_key = layer[pos]
if active_layers[layer_index] and layer_key != key.KC_TRANSPARENT:
return layer_key, layer_index


def enable_layer(layer):
global active_layers
active_layers[layer] = True


def disable_layer(layer):
global active_layers
active_layers[layer] = False
host.release_layer_keys(ui, self.layer, config)

0 comments on commit 20dfe40

Please sign in to comment.