-
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.
Config refactor; Added send_press_duration
- Loading branch information
Showing
16 changed files
with
218 additions
and
68 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
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
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
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,36 @@ | ||
import threading | ||
from dataclasses import dataclass | ||
|
||
from tapper.model import types_ | ||
from tapper.model.tap_tree_shadow import STap | ||
|
||
|
||
@dataclass | ||
class ActionConfig: | ||
"""Config for a single action. See tap_tree for info on configs.""" | ||
|
||
send_interval: float | ||
send_press_duration: float | ||
|
||
@classmethod | ||
def from_tap(cls, tap: STap) -> "ActionConfig": | ||
return ActionConfig( | ||
send_interval=tap.send_interval, send_press_duration=tap.send_press_duration | ||
) | ||
|
||
|
||
config_thread_local_storage = threading.local() | ||
|
||
|
||
def wrapped_action(tap: STap) -> types_.Action: | ||
""" | ||
:param tap: source. | ||
:return: Action that sets config before running. | ||
""" | ||
config = ActionConfig.from_tap(tap) | ||
|
||
def wrapped() -> None: | ||
config_thread_local_storage.action_config = config | ||
tap.action() | ||
|
||
return wrapped |
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
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
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
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
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
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
Oops, something went wrong.