3 Button Simulation with 1 Button Mouse?
I'm looking for a way to deal with a 1 button bluetooth mouse, and
simulate button 2 and 3 in some way using the keyboard.
I thought I could use xmodmap to remap some useless keyboard keys to
mouse buttons, but xmodmap treats keyboard and button mapping separately.
This is on Linux with the Xorg server. I know of an approach involving
recompiling the kernel keyboard driver, but would prefer a userland
approach.
Re: 3 Button Simulation with 1 Button Mouse?
In article <nI-dnYL5oYgLrcHbnZ2dnUVZ_hCdnZ2d@comcast.com>,
Ken Mandelberg <km@mathcs.emory.edu> wrote:[color=blue]
>I'm looking for a way to deal with a 1 button bluetooth mouse, and
>simulate button 2 and 3 in some way using the keyboard.
>
>I thought I could use xmodmap to remap some useless keyboard keys to
>mouse buttons, but xmodmap treats keyboard and button mapping separately.
>
>This is on Linux with the Xorg server. I know of an approach involving
>recompiling the kernel keyboard driver, but would prefer a userland
>approach.[/color]
Enable mousekeys (xkbset m) and then use xmodmap to assign the
Pointer_Button2 and Pointer_Button3 keysyms to your useless keys.
Pointer_Drag2 and Pointer_Drag3 might also be useful.
Or try mouseemu ([url]http://www.biophys.uni-duesseldorf.de/~schmitz/mouseemu/[/url])
--
Alan Curry
[email]pacman@world.std.com[/email]
Re: 3 Button Simulation with 1 Button Mouse?
On 2007-05-29, Ken Mandelberg <km@mathcs.emory.edu> wrote:
[color=blue]
> I'm looking for a way to deal with a 1 button bluetooth mouse, and
> simulate button 2 and 3 in some way using the keyboard.
>
> I thought I could use xmodmap to remap some useless keyboard keys to
> mouse buttons, but xmodmap treats keyboard and button mapping separately.
>
> This is on Linux with the Xorg server. I know of an approach involving
> recompiling the kernel keyboard driver, but would prefer a userland
> approach.[/color]
A possible solution is to grab the keyboard and mouse (or do
whatever window managers do to intercept keystrokes that are
meaningful to them before managed windows see them) and send
them back to application windows after translation.
/* FIXME - do something to intercept events */
for (;;)
{
XEvent ev;
XNextEvent (dpy, &ev);
/* Keycode 42 = button 2, keycode 69 = button 3 */
if ((ev.type == KeyPress || ev.type == KeyRelease)
&& (ev.xkey.keycode == 42 || ev.xkey.keycode == 69))
{
XEvent ev2;
ev2.type = ev.type == KeyPress ? ButtonPress : ButtonRelease;
#define f ev.xkey;
#define t ev2.xbutton;
t.serial = f.serial;
t.send_event = f.send_event;
t.display = f.display;
t.window = f.window;
t.root = f.root;
t.subwindow = f.subwindow;
t.time = f.time;
t.x = f.x;
t.y = f.y;
t.x_root = f.x_root;
t.y_root = f.y_root;
t.state = f.state;
t.button = ev.xkey.keycode == 42 ? Button2 : Button3;
ev = ev2;
}
/* FIXME - do something to send ev back to the window
where it occurred. XSendEvent(3) ? */
}
You'd have to run that "on top" of your window manager if it has
bindings that use button 2 or 3. If the key you choose is not a
modifier, the auto-repeat will bite you.
Not tested and possibly a stupid idea.
--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: [email]mozirymaq@scrutable.com[/email] [email]nufywofaf@hatteras.com[/email])
"Duty, honor, country" -- Douglas MacArthur
"Travail, famille, patrie" -- Philippe Pétain