* [9fans] [9front] mouse handling code on amd64
@ 2025-03-30 17:03 rbelenov
2025-03-30 21:03 ` cinap_lenrek
0 siblings, 1 reply; 14+ messages in thread
From: rbelenov @ 2025-03-30 17:03 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 1258 bytes --]
Hello,
I'm a newbie playing with 9front on laptop (in VirtualBox) and would like to try to make it work with one mouse key and modifiers (similar to https://github.com/rsc/plan9/commit/5375b476e0d0119bcd85517e337e99b1d7a0b7e0 ). 9front code looks different from plan9 and I'm confused with similar code in ps2mouseputc() in /sys/src/9/pc/mouse and m5mouseputc() in /sys/src/9/port/devmouse.c . Both files are compiled into the amd64 kernel; the former respects the shift argument, but I don't see how it is propagated from the keyboard (as far as I see, the code in /sys/src/9/pc/devkbd.c only calls it via auxputc pointer with the second argument 0); the latter has a comment about shift modifier, but I don't see it in the code. Where should I look for the actual code that propagates keybaord modifiers to mouse handling code?
Another question - how to specify the kernel during boot (e.g. if I copy the old one to /9fat/9pc64.orig and would like to use it in case newly compiled one does not work)?
Regards, Roman
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-Md0533d77b0c9c24558a3dd89
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1955 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-30 17:03 [9fans] [9front] mouse handling code on amd64 rbelenov
@ 2025-03-30 21:03 ` cinap_lenrek
2025-03-31 17:58 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: cinap_lenrek @ 2025-03-30 21:03 UTC (permalink / raw)
To: 9fans
> I'm a newbie playing with 9front on laptop (in VirtualBox) ....
https://fqa.9front.org/fqa.html
> ... and would like to try to make it work with one mouse key and modifiers (similar to https://github.com/rsc/plan9/commit/5375b476e0d0119bcd85517e337e99b1d7a0b7e0 ).
Keyboard scancode translation has been moved out of
the kernel in 9front. The keyboard device just
provides a file for the raw ps2 scancodes and
(devcons #c) just provides output (for kernel
prints).
The driver providing the full /dev/cons
(and /dev/kbd) is kbdfs(8):
source: /sys/src/cmd/aux/kbdfs/
The feature where you can map a keyboard key
to a mouse button and mouse button swap is
accomplished by it writing to /dev/mousein
and /dev/mousectl.
It also can send a note to the group for [Del]
key handling so that works on the initial console.
> Another question - how to specify the kernel during boot (e.g. if I copy the old one to /9fat/9pc64.orig and would like to use it in case newly compiled one does not work)?
from 9boot(8) manual:
After reading the configuration, the loader will automati-
cally attempt to boot the kernel that was specified by the
bootfile= parameter. If there is no such parameter, any key
gets pressed on the keyboard or the kernel file was not
found then the loader enters the interactive boot console.
so you can just press like spacebar or any other key until you
see the ">" prompt, then you can type:
bootfile=9pc64.bak
and to boot, type:
boot
Note:
Unless you use the efi variant, 9boot's fat code does not support
long file names, so restrict your backup kernel files to 8+3 names
such as 9pc64.bak or 9pc64.old.
--
cinap
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M55f79244844f479ef7e554bb
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-30 21:03 ` cinap_lenrek
@ 2025-03-31 17:58 ` Roman Belenov
2025-03-31 18:18 ` Roman Belenov
2025-04-01 9:46 ` cinap_lenrek
0 siblings, 2 replies; 14+ messages in thread
From: Roman Belenov @ 2025-03-31 17:58 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 653 bytes --]
Thank you!
I see that sending "buttonmap XYZ" to /dev/mousectl works and swaps the buttons. However, changing the code in /sys/src/cmd/aux/kbfs/kbdfs.c have no effect for me (after changes I did "mk install", checked that /bin/aux/kbdfs is updated and rebooted). Even after changing the string to "buttonmap 123" I see that shift key makes right button work as middle; I don't understand how it may work.
Regards, Roman
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M203fff89e4667296987e4a7c
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1235 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-31 17:58 ` Roman Belenov
@ 2025-03-31 18:18 ` Roman Belenov
2025-03-31 18:56 ` Romano
2025-04-01 9:46 ` cinap_lenrek
1 sibling, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-03-31 18:18 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 335 bytes --]
PS Is it possible that aux/kbdfs started from boot scripts is not the one bound later from /amd64/bin/aux ?
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M4d4be2e166f3f56a6dc3263a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 823 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-31 18:18 ` Roman Belenov
@ 2025-03-31 18:56 ` Romano
2025-04-01 8:03 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: Romano @ 2025-03-31 18:56 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
You might need to build and install a new kernel with the updated code in the 9fat partition.
On Mon, Mar 31, 2025, at 11:18 AM, Roman Belenov wrote:
> PS Is it possible that aux/kbdfs started from boot scripts is not the one bound later from /amd64/bin/aux ?
> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions <https://9fans.topicbox.com/groups/9fans> + participants <https://9fans.topicbox.com/groups/9fans/members> + delivery options <https://9fans.topicbox.com/groups/9fans/subscription> Permalink <https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M4d4be2e166f3f56a6dc3263a>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M701c311558bb845a37cff124
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1194 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-31 18:56 ` Romano
@ 2025-04-01 8:03 ` Roman Belenov
2025-04-01 14:10 ` Lucio De Re
0 siblings, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-04-01 8:03 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 324 bytes --]
But as far as I understand aux/kbdfs is a separate user mode binary, the kernel is not modified.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M5be57d8eef2bdebdbfed5036
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 812 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-03-31 17:58 ` Roman Belenov
2025-03-31 18:18 ` Roman Belenov
@ 2025-04-01 9:46 ` cinap_lenrek
1 sibling, 0 replies; 14+ messages in thread
From: cinap_lenrek @ 2025-04-01 9:46 UTC (permalink / raw)
To: 9fans
As others said, aux/kbdfs gets included in the kernel-image in a read-only
ram file-system so that the system can prompt you for your root-filesystem
and user-name on boot.
This is also true for alot of other file-servers like nusb/usbd, gefs...
So you need to also "mk install" the kernel and then manually copy
the kernel-image file into your 9fat.
--
cinap
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-Mfba0053d9cd2acbcc41ab361
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-01 8:03 ` Roman Belenov
@ 2025-04-01 14:10 ` Lucio De Re
2025-04-01 15:32 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: Lucio De Re @ 2025-04-01 14:10 UTC (permalink / raw)
To: 9fans
On 2025/04/01 10:03, Roman Belenov wrote:
> But as far as I understand aux/kbdfs is a separate user mode binary,
> the kernel is not modified.
There are a few binary executables included in the loaded kernel,
necessary during booting. A copy of aux/kbdfs may well be one of those.
You'll be able to determine that for certain by looking at the
configuration file that describes how the kernel is constructed
(/sys/src/9/pc/pc would be an obvious example, there are quite a few to
choose from).
Lucio.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-Mf1b04d4abcb502de7342d90a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-01 14:10 ` Lucio De Re
@ 2025-04-01 15:32 ` Roman Belenov
2025-04-02 3:22 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-04-01 15:32 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 865 bytes --]
The code moved from the kernel to userspace to be included in special filesystem inside kernel image? It's April 1st, right?
Seriously - I see that it's similar to initrd in Linux and rebuilding the kernel works, so now I can use 9front with touchpad with more comfort (there are physical buttons below touchpad, but they require too much effort to press; two fingers tap for right button work, but not for click-and-drag required to create new window). Now I can continue reading the intro, just reached the "take me to your leader" part ;)
PS Do you think it's a good idea to make mouse button swap customizable via /dev/consctl?
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M6ef764ed2518409ca68c6805
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1441 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-01 15:32 ` Roman Belenov
@ 2025-04-02 3:22 ` Roman Belenov
2025-04-02 4:02 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-04-02 3:22 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
I ended up with the following patch - http://okturing.com/src/24386/body
The default behavior is not changed, but it is possible to use any modifier (described in mtab) for any mouse button swap, e.g. locally I use
echo mouseswap shift 231 >/dev/mswapctl
echo mouseswap altgr 312 >/dev/mswapctl
to get buttons 2 and 3 from single tap on touchpad with shift and altgr pressed.
Didn't yet implement read from /dev/mswapctl, should provide current mappings.
Regards, Roman
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M311e614337a8b380b3aab971
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1373 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-02 3:22 ` Roman Belenov
@ 2025-04-02 4:02 ` Roman Belenov
2025-04-02 18:17 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-04-02 4:02 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
UPD Learned about readstr and added reading of the current state - https://okturing.com/src/24387/body
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M40c335a5462c0ebe8c2e4023
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 879 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-02 4:02 ` Roman Belenov
@ 2025-04-02 18:17 ` Roman Belenov
2025-04-02 19:10 ` ori
0 siblings, 1 reply; 14+ messages in thread
From: Roman Belenov @ 2025-04-02 18:17 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 438 bytes --]
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
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M6378d3d8565981286cc0d49b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 1047 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-02 18:17 ` Roman Belenov
@ 2025-04-02 19:10 ` ori
2025-04-03 6:53 ` Roman Belenov
0 siblings, 1 reply; 14+ messages in thread
From: ori @ 2025-04-02 19:10 UTC (permalink / raw)
To: 9fans
Quoth Roman Belenov <rbelenov@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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] [9front] mouse handling code on amd64
2025-04-02 19:10 ` ori
@ 2025-04-03 6:53 ` Roman Belenov
0 siblings, 0 replies; 14+ messages in thread
From: Roman Belenov @ 2025-04-03 6:53 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 301 bytes --]
Will the keys remapped this way still work as regular keyboard modifiers?
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T41a0e496bba0c957-M5adcdd287ddf415c110f4818
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 795 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-04-03 13:29 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-30 17:03 [9fans] [9front] mouse handling code on amd64 rbelenov
2025-03-30 21:03 ` cinap_lenrek
2025-03-31 17:58 ` Roman Belenov
2025-03-31 18:18 ` Roman Belenov
2025-03-31 18:56 ` Romano
2025-04-01 8:03 ` Roman Belenov
2025-04-01 14:10 ` Lucio De Re
2025-04-01 15:32 ` Roman Belenov
2025-04-02 3:22 ` Roman Belenov
2025-04-02 4:02 ` Roman Belenov
2025-04-02 18:17 ` Roman Belenov
2025-04-02 19:10 ` ori
2025-04-03 6:53 ` Roman Belenov
2025-04-01 9:46 ` cinap_lenrek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).