diff options
| author | Omar Rizwan <omar@omar.website> | 2024-01-29 17:53:59 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2024-01-29 17:53:59 +0000 |
| commit | e7cbd176f03cf335c8ab6ce9185905a55a095d4d (patch) | |
| tree | bd1fa14d18ad6846ecb7dca8c7356ff597852967 /virtual-programs | |
| parent | Fix Alt+ESC restart (diff) | |
| download | folk-e7cbd176f03cf335c8ab6ce9185905a55a095d4d.tar.gz folk-e7cbd176f03cf335c8ab6ce9185905a55a095d4d.zip | |
keyboard: Use binary translation; fixes event reader going off rails
No need to reset on invalid code now.
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/keyboard.folk | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/virtual-programs/keyboard.folk b/virtual-programs/keyboard.folk index 83c83a5e..819e6afc 100644 --- a/virtual-programs/keyboard.folk +++ b/virtual-programs/keyboard.folk @@ -52,6 +52,8 @@ foreach keyboard $keyboardDevices { Claim keyboards are $keyboardDevices Start process "keyboard-$keyboard" { source "pi/KeyCodes.tcl" + set KEY_STATES [list up down repeat] + Wish $::thisProcess shares statements like \ [list keyboard /kb/ claims key /k/ is /t/ with modifiers /m/ with rand /r/] variable evtBytes 16 @@ -61,8 +63,10 @@ foreach keyboard $keyboardDevices { set evtFormat wwssi } set keyboardSpecifier $keyboard + variable keyboardChannel [open $keyboard r] - set keyStates [list up down repeat] + chan configure $keyboardChannel -translation binary + set modifiers [dict create \ shift 0 \ ctrl 0 \ @@ -70,14 +74,10 @@ foreach keyboard $keyboardDevices { ] while 1 { binary scan [read $keyboardChannel $evtBytes] $evtFormat tvSec tvUsec type code value - if {$type > 0x04} { - set keyboardChannel [open $keyboard r] - binary scan [read $keyboardChannel $evtBytes] $evtFormat tvSec tvUsec type code value - } - if {$type == 0x01} { + if {$type == 0x01} { ;# EV_KEY set shift [dict get $modifiers shift] set key [keyFromCode $code $shift] - set keyState [lindex $keyStates $value] + set keyState [lindex $KEY_STATES $value] set isDown [expr {$keyState != "up"}] if {[string match *SHIFT $key]} { @@ -97,4 +97,4 @@ foreach keyboard $keyboardDevices { } } } -}
\ No newline at end of file +} |
