Quoth Roman Belenov <rbele...@gmail.com>:
> UPD2 Switched to (probably) better names and created proper git diff
> New patch available at https://okturing.com/src/24408/body 
> New customization syntax: echo altgr 312 >/dev/buttonmapctl
> 
> Regards, Roman

Looking over this -- I think it might fit better if we add this to
the keyboard mapping. We already have support for making keyboard
input emit button presses with the 'M' entry, for example like we
have in /sys/lib/kbmap/mouse-csa

         # Use left Ctl, Start, Alt as mouse buttons (useful on laptops)
        0       29      M1
        2       91      M2
        0       56      M3

either extending it to allow an 'R' entry, or to allow buttons to sho
up in the central column, would probably make sense; either:

        0 29 R321

or, making the mouse buttons availale in the scan code column:

        shift M1 M2
        shift M2 M1

Since we now support opening the kbmap with OAPPEND, so we don't
clear it on a write, you could have:

        /sys/lib/kbmap/mouse-shuffle

that you add to any keyboard map with:

        cat /sys/lib/kbmap/mouse-shuffle >> /dev/kbmap

For the 'R' message approach, I have an entirely untested and likely
very broken sketch that I think might be a start; in addition to
making this code actually work, we'd need to adjust the corresponding
keyboard map to keep the shift swapping in place by default.

For the multiple M message approach, we'd need to be careful, I'm not
sure what happens when you have a mapping from A to B, and then B to A.

diff e87c6c0a4405c3775046476337df2194fd9d986c uncommitted
--- a/sys/include/keyboard.h
+++ b/sys/include/keyboard.h
@@ -72,5 +72,6 @@
        Kmiddle=        Spec|0x66,
        Kaltgr= Spec|0x67,
        Kmod4=  Spec|0x68,
-       Kmouse= Spec|0x100,
+       Kmouse= Spec|0x100, /* +5 values for the buttons */
+       Kremap= Spec|0x120, /* +999 values for shuffling keys */
 };
--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -907,9 +907,9 @@
                                break;
                }
 
-               if(mctlfd >= 0 && key.r == Kshift){
+               if(mctlfd >= 0 && key.r >= Kremap+1 && key.r <= Kremap + 999){
                        if(key.down){
-                               fprint(mctlfd, "buttonmap 132");
+                               fprint(mctlfd, "buttonmap %d", key.r - Kremap);
                        } else {
                                fprint(mctlfd, "swap");
                                fprint(mctlfd, "swap");
@@ -1289,6 +1289,8 @@
                                        goto Badarg;
                        }else if(*lp == 'M' && ('1' <= lp[1] && lp[1] <= '5'))
                                r = Kmouse+lp[1]-'0';
+                       else if(*lp == 'R' && ('1' <= lp[1] && lp[1] <= '5'))
+                               r = Kremap+strtoll(lp, &lp, 10);
                        else if(*lp>='0' && *lp<='9') /* includes 0x... */
                                r = strtoul(lp, &lp, 0);
                        else



------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M42c1389c24a6c0511d6c0be9
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to