Skip to content

Commit

Permalink
🐛 #261 Fix compatibility with Hyperkey
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Mar 21, 2024
1 parent 15cf637 commit 5da35d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Loop/Managers/LoopManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ class LoopManager: ObservableObject {
} else {
self.currentlyPressedModifiers.insert(event.keyCode)
}

// Backup system in case keys are pressed at the exact same time
let flags = event.modifierFlags.convertToCGKeyCode()
if flags.count > 1 && !self.currentlyPressedModifiers.contains(flags) {
for key in flags where CGKeyCode.keyToImage.contains(where: { $0.key == key }) {
self.currentlyPressedModifiers.insert(key)
}
}
}

private func openLoop() {
Expand Down
11 changes: 11 additions & 0 deletions Loop/Settings/Keybindings/Keybind Recorder/TriggerKeycorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ struct TriggerKeycorder: View {
}
}

// Backup system in case keys are pressed at the exact same time
let flags = event.modifierFlags.convertToCGKeyCode()
if flags.count > 1 && !self.selectionKey.contains(flags) {
for key in flags where CGKeyCode.keyToImage.contains(where: { $0.key == key }) {
self.selectionKey.insert(key)
withAnimation(.snappy(duration: 0.1)) {
self.isCurrentlyPressed = true
}
}
}

if event.modifierFlags.wasKeyUp && !self.selectionKey.isEmpty {
self.finishedObservingKeys()
return
Expand Down

0 comments on commit 5da35d9

Please sign in to comment.