diff options
| author | Andrés Cuervo <andrescuervor@gmail.com> | 2023-11-17 23:30:51 +0000 |
|---|---|---|
| committer | Andrés Cuervo <andrescuervor@gmail.com> | 2023-11-17 23:31:37 +0000 |
| commit | 38412bd0ec86e4b55ae41dcd829527b8f50c80de (patch) | |
| tree | cd5ff660141825ea37d712cfc1360b3c55753697 /virtual-programs | |
| parent | Remove pi/Keyboard.tcl, begin keyboard.folk in earnest (diff) | |
| download | folk-38412bd0ec86e4b55ae41dcd829527b8f50c80de.tar.gz folk-38412bd0ec86e4b55ae41dcd829527b8f50c80de.zip | |
Add eventPath check for keyboardStreams
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/keyboard.folk | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/virtual-programs/keyboard.folk b/virtual-programs/keyboard.folk index fcf31993..47d691d4 100644 --- a/virtual-programs/keyboard.folk +++ b/virtual-programs/keyboard.folk @@ -149,12 +149,25 @@ Start process "keyboard" { puts "=== Opened keyboard device: $firstKeyboard \\ $kb" } + proc findMatchingEventPath {searchList eventPath} { + foreach element $searchList { + set elEventPath [dict get $element eventPath] + if {$eventPath eq $elEventPath} { + return $element + } + } + return 0 + } + # e.g. getKeyEvent /dev/input/event0 proc getKeyEvent {keyboardSpecifier args} { puts "getting key event for $keyboardSpecifier" When /thisProcess/ has keyboards /keyboardsList/ { # Hmmmm, how to make this a global accessor? Always just pass in the keyboard array tooo???? That'd be dumb idk - set keyboardStream [dict get $keyboardsList $keyboardSpecifier] + puts "==== getKeyEvent: $keyboardsList" + puts "==== getKeyEvent: $keyboardSpecifier" + # set keyboardStream [dict get $keyboardsList $keyboardSpecifier] + set keyboardStream [findMatchingEventPath $keyboardsList $keyboardSpecifier] # TODO: Allow keyboardSpecifier to be a keyboard device file # e.g. /dev/input/by-path/platform-i8042-serio-0-event-kbd @@ -172,9 +185,12 @@ Start process "keyboard" { # unsigned int value; (0 for key release, 1 for press, 2 for repeat) # }; # + set kbEventPath [dict get $keyboardStream eventPath] while 1 { - binary scan [read $keyboardStream $evtBytes] $evtFormat tvSec tvUsec type code value + binary scan [read $kbEventPath $evtBytes] $evtFormat tvSec tvUsec type code value if {$type == 0x01} { + Retract keyboard $keyboardSpecifier claims key /k/ is /t/ with modifiers /m/ + Assert keyboard $keyboardSpecifier claims key [list $key] is [list $keyState] with modifiers [list $heldModifiers] return [list $code $value] } } @@ -187,9 +203,13 @@ Start process "keyboard" { puts "Found [llength $keyboardDevices] keyboards:" # TODO: Make a process for each eventPath found that's a keyboard! foreach keyboard $keyboardDevices { - puts " * eventpath: [dict get $keyboard eventPath]" + set eventPath [dict get $keyboard eventPath] + puts " * eventpath: $eventPath" + establishKeyPressListener $eventPath + getKeyEvent $eventPath foreach devlink [dict get $keyboard devLinks] { puts " ** : $devlink" + establishKeyPressListener $devlink } } Claim the default keyboard is [lindex $keyboardDevices 0] |
