Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymo111 committed May 2, 2024
1 parent 2fab777 commit e1fe82e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Package for ${{ matrix.os }}
run: python dist.py -d
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v2
if: runner.os == 'Windows'
- name: Install WiX
run: dotnet tool install --global wix
Expand Down
1 change: 1 addition & 0 deletions nexus/Freqlog/Definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ActionType(Enum):
"""Enum for key action type"""
PRESS = 1
RELEASE = 2
CLICK = 3


class CaseSensitivity(Enum):
Expand Down
10 changes: 5 additions & 5 deletions nexus/Freqlog/Freqlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _on_release(self, key: str, event_time: time) -> None:

def _on_click(self, button: str, event_time: time) -> None:
"""Store PRESS, key and current time in queue"""
self.q.put((ActionType.PRESS, button, datetime.fromtimestamp(event_time)))
self.q.put((ActionType.CLICK, button, datetime.fromtimestamp(event_time)))

def _log_word(self, word: str, start_time: datetime, end_time: datetime) -> None:
"""
Expand Down Expand Up @@ -147,7 +147,7 @@ def _log_and_reset_word(min_length: int = 2) -> None:
while self.is_logging:
try:
action: ActionType
key: str | str
key: str
time_pressed: datetime

# Blocking here makes the while-True non-blocking
Expand Down Expand Up @@ -190,7 +190,7 @@ def _log_and_reset_word(min_length: int = 2) -> None:
continue

# Handle whitespace/disallowed keys
if key not in self.allowed_chars:
if key not in self.allowed_chars | self.modifier_keys and not active_modifier_keys:
# If key is whitespace/disallowed and timing is more than chord_char_threshold, log and reset word
if (word and avg_char_time_after_last_bs and
avg_char_time_after_last_bs > timedelta(milliseconds=self.chord_char_threshold)):
Expand All @@ -206,15 +206,15 @@ def _log_and_reset_word(min_length: int = 2) -> None:
word += "\n"
case _:
# FIXME: deal with scancodes
word += key
pass
last_key_was_disallowed = True
self.q.task_done()
continue

# On non-chord key, log and reset word if it exists
# Non-chord key = key in modifier keys or non-key
# FIXME: support modifier keys in chords
if key in self.modifier_keys:
if action == ActionType.CLICK or key in self.modifier_keys:
logging.debug(f"Non-chord key: {key}")
if word:
_log_and_reset_word()
Expand Down

0 comments on commit e1fe82e

Please sign in to comment.