summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorAndrés Cuervo <andrescuervor@gmail.com>2023-11-10 20:58:24 +0000
committerAndrés Cuervo <andrescuervor@gmail.com>2023-11-10 20:58:24 +0000
commitf6cb5760eb98caae80e76279271c28c40b0eb95b (patch)
treef02ed111f1b97f62c897597a7bdc64c4b0fef09e /virtual-programs
parentAdd virtual-programs/keyboard.folk (diff)
downloadfolk-f6cb5760eb98caae80e76279271c28c40b0eb95b.tar.gz
folk-f6cb5760eb98caae80e76279271c28c40b0eb95b.zip
Add keyboard progress
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/editor.folk10
-rw-r--r--virtual-programs/keyboard.folk50
2 files changed, 54 insertions, 6 deletions
diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk
index 8d3e12ad..705bcd39 100644
--- a/virtual-programs/editor.folk
+++ b/virtual-programs/editor.folk
@@ -1,8 +1,10 @@
set id "editor-1"
-set ::debug_cursor true
-set ::debug_print true
+set ::debug_cursor false
+set ::debug_print false
-When /page/ is editor /n/ & /page/ has region /r/ {
+# When /page/ is editor /n/ & /page/ has region /r/ {
+When /page/ is a keyboard with path /kbPath/ & /page/ has region /r/ {
+ # Claim $this is a keyboard with path /dev/input/by-path/platform-i8042-serio-0-event-kbd
Wish $page is outlined gray
Claim $id has region [region move $r up 450px]
}
@@ -381,4 +383,4 @@ Claim $this has demo {
# Ideally:
Claim $this is keyboard with path /dev/input/by-path/platform-i8042-serio-0-event-kbd
-} \ No newline at end of file
+}
diff --git a/virtual-programs/keyboard.folk b/virtual-programs/keyboard.folk
index 630ab1f5..ef122eec 100644
--- a/virtual-programs/keyboard.folk
+++ b/virtual-programs/keyboard.folk
@@ -3,7 +3,7 @@ set ::debug_keyboard true
# TODO: Make this respond to a keyboard being plugged in or unplugged
# TODO: Make this the main keyboard logic and change keyboard.tcl to just use utilities from in here or from some share utils/keyboard.tcl
-When /someone/ claims /keyboardPage/ is keyboard with path /kbPath/ {
+When /someone/ claims /keyboardPage/ is a keyboard with path /kbPath/ {
# (2023-11-07) on folk0 this is /dev/input/by-path/platform-i8042-serio-0-event-kbd
# (2023-11-08) on folk-convivial this is /dev/input/by-path/pci-0000:04:00.3-usb-0:3:1.0-event-kbd
Wish $keyboardPage is outlined white
@@ -74,4 +74,50 @@ When /keyboard/ is a valid keyboard {
# 123452 platform-i8042-serio-0-event-kbd l
# 123453 platform-i8042-serio-0-event-kbd l
# 123454 platform-i8042-serio-0-event-kbd o
-} \ No newline at end of file
+}
+
+Claim $this has demo {
+ # TODO: Move this out into the top of keyboard.folk, I think? (2023-11-09 @cwervo)
+ # Keyboard detection functions
+ proc udevadm_properties {device} {
+ set status [catch {exec udevadm info --query=property --name=$device} result]
+ if {$status == 0} {
+ return $result
+ } else {
+ return ""
+ }
+ }
+
+ proc is_keyboard {device} {
+ set properties [udevadm_properties $device]
+ if {$properties eq ""} {
+ return false
+ }
+ # Check if device is a keyboard and not a mouse
+ set isKeyboard [string match *ID_INPUT_KEYBOARD=1* $properties]
+ set isMouse [string match *ID_INPUT_MOUSE=1* $properties]
+ return [expr {$isKeyboard && !$isMouse}]
+ }
+
+ set result [exec ls /dev/input/by-path]
+ set keyboards [list]
+
+ foreach device $result {
+ set fullDevice "/dev/input/by-path/$device"
+ set keyboardCheck [is_keyboard $fullDevice]
+ # Only add the device to the list if it is a keyboard
+ if {$keyboardCheck} {
+ # lappend keyboards "$device // \n[udevadm_properties $fullDevice]\n"
+ lappend keyboards $fullDevice
+ }
+ }
+
+ # The following lines seem to be pseudo-code or comments, they should be removed or corrected
+ Wish $this is outlined white
+
+ foreach kb $keyboards {
+ Wish $this is labelled "----- $kb"
+ Claim $this is a keyboard with path $kb
+ Wish $this draws a circle with color navy filled true radius 10
+ }
+}