chiark / gitweb /
better bind-input command construction
authorian <ian>
Sun, 13 Jul 2008 21:51:42 +0000 (21:51 +0000)
committerian <ian>
Sun, 13 Jul 2008 21:51:42 +0000 (21:51 +0000)
hostside/gui

index e0a294ac721847537fa89c0c8a500ccc354a5c30..9e29278779d7c9ea7f501ea3eea42fe08778bfc2 100755 (executable)
@@ -525,8 +525,22 @@ proc ib-create/wheelmouse {devid wunique desc} {
     set in(speedw) $w
 }
 
+proc ib-evcmd/wheelmouse {devid target} {
+    return [ib-evcmd-construct $devid $target --grab]
+}
+
 #---------- input device evdev binding ----------
 
+proc ib-evcmd-construct {devid target xargs} {
+    upvar #0 input/$devid in
+    manyset $target ev sysfs
+    return [concat \
+           [list ./evdev-manip] $xargs \
+           [list --stdin-monitor \
+                 --expect-sysfs /sys$sysfs/$ev/dev \
+                 /dev/input/$ev]]
+}
+
 proc bind-input {bus vendor product version concrete args} {
     global input_bindings
     set devid $bus:$vendor:$product:$version
@@ -604,15 +618,8 @@ proc scan-input-bindings {} {
        if {$newlast > $now + $inputretrymax} continue
        if {$newlast < $now} { set newlast $now }
        set in(laststart) $newlast
-       if {[catch { info args ib-evcmd/$in(concrete) }]} {
-           manyset [lindex $target($devid) 0] ev sysfs
-           set cmdl [list 2>@ stderr ./evdev-manip --grab --stdin-monitor \
-                   --expect-sysfs /sys$sysfs/$ev/dev \
-                   /dev/input/$ev]
-       } else {
-           set cmdl [eval [list ib-evcmd/$in(concrete) $devid] \
-                                $target($devid)]
-       }
+       set cmdl [eval [list ib-evcmd/$in(concrete) $devid] $target($devid)]
+       lappend cmdl 2>@ stderr
        catch-for-input-binding $devid {
            debug "ib $devid running $cmdl"
            set in(chan) [open |$cmdl r+]