summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorAndrés Cuervo <andrescuervor@gmail.com>2023-11-29 21:56:16 +0000
committerAndrés Cuervo <andrescuervor@gmail.com>2023-11-29 21:56:16 +0000
commitc4300b63dc0c9d9045d7241dc021b0d723b7e856 (patch)
tree289242217e03b6e091f8d87f601bfe68a510bd4b /virtual-programs
parentRemove old reference code (diff)
downloadfolk-c4300b63dc0c9d9045d7241dc021b0d723b7e856.tar.gz
folk-c4300b63dc0c9d9045d7241dc021b0d723b7e856.zip
Simplify keyboard logging
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/keyboard.folk86
1 files changed, 39 insertions, 47 deletions
diff --git a/virtual-programs/keyboard.folk b/virtual-programs/keyboard.folk
index edbef9d7..740b7b1c 100644
--- a/virtual-programs/keyboard.folk
+++ b/virtual-programs/keyboard.folk
@@ -81,77 +81,69 @@ foreach keyboard $keyboardDevices {
Start process "keyboard-$eventPath" {
source "pi/KeyCodes.tcl"
Wish $::thisProcess shares statements like \
- [list keyboard /k/ claims /...anything/]
+ [list keyboard /k/ claims /k/ is /v/]
variable evtBytes 16
variable evtFormat iissi
if {[exec getconf LONG_BIT] == 64} {
set evtBytes 24
set evtFormat wwssi
}
+ Assert keyboard [rand] claims key A is "boop: [rand]"
set keyboardSpecifier $eventPath
variable eventPathChannel [open $eventPath r]
puts "starting keyboard process for $keyboard"
set readCount 0
while 1 {
set readCount [incr $readCount]
- puts "====\nreading ... (readCount: $readCount) ($eventPath) from ($eventPathChannel)"
binary scan [read $eventPathChannel $evtBytes] $evtFormat tvSec tvUsec type code value
if {$type > 0x04} {
set eventPathChannel [open $eventPath r]
binary scan [read $eventPathChannel $evtBytes] $evtFormat tvSec tvUsec type code value
}
- puts "from scan: (type | $type) (code | $code) $value"
- if {$type == 0x01} {
- puts "read: $tvSec $tvUsec $type ([expr $type == 0x01]) $code $value"
+ if {$type == 0x01 && $value == 1} {
puts "got key event ($keyboardSpecifier): $code => [keyFromCode $code false] | $value"
Retract keyboard $keyboardSpecifier key /k/ is /t/
Assert keyboard $keyboardSpecifier claims key [keyFromCode $code false] is [list $value]
- Claim keyboard $keyboardSpecifier claims thing
- # return [list $code $value]
}
}
+ # set kbEventPath [open $eventPath r]
+ # set keyStates [list up down repeat]
+ # set modifiers [dict create \
+ # shift 0 \
+ # ctrl 0 \
+ # alt 0 \
+ # ]
+
+ # set shift [dict get $modifiers shift]
+ # set key [keyFromCode $keyCode $shift]
+ # set keyState [lindex $keyStates $eventType]
+
+ # set isDown [expr {$keyState != "up"}]
+ # if {[string match *SHIFT $key]} {
+ # dict set modifiers shift $isDown
+ # }
+ # if {[string match *CTRL $key]} {
+ # dict set modifiers ctrl $isDown
+ # }
+ # if {[string match *ALT $key]} {
+ # dict set modifiers alt $isDown
+ # }
- return
-
- set kbEventPath [open $eventPath r]
-
- set keyStates [list up down repeat]
- set modifiers [dict create \
- shift 0 \
- ctrl 0 \
- alt 0 \
- ]
-
- set shift [dict get $modifiers shift]
- set key [keyFromCode $keyCode $shift]
- set keyState [lindex $keyStates $eventType]
-
- set isDown [expr {$keyState != "up"}]
- if {[string match *SHIFT $key]} {
- dict set modifiers shift $isDown
- }
- if {[string match *CTRL $key]} {
- dict set modifiers ctrl $isDown
- }
- if {[string match *ALT $key]} {
- dict set modifiers alt $isDown
- }
-
- set heldModifiers [dict keys [dict filter $modifiers value 1]]
+ # set heldModifiers [dict keys [dict filter $modifiers value 1]]
- while 1 {
- 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]
- puts "got key event ($keyboardSpecifier): $key $keyState $heldModifiers"
- # return [list $code $value]
- }
- }
- # establishKeyPressListener $eventPath
- # foreach devlink [dict get $keyboard devLinks] {
- # puts " -- : $devlink"
- # establishKeyPressListener $devlink
+ # while 1 {
+ # 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]
+ # puts "got key event ($keyboardSpecifier): $key $keyState $heldModifiers"
+ # # return [list $code $value]
+ # }
# }
+ # # establishKeyPressListener $eventPath
+ # # foreach devlink [dict get $keyboard devLinks] {
+ # # puts " -- : $devlink"
+ # # establishKeyPressListener $devlink
+ # # }
}
} \ No newline at end of file