3 Button Simulation with 1 Button Mouse? - Xwindows

This is a discussion on 3 Button Simulation with 1 Button Mouse? - Xwindows ; 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, ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: 3 Button Simulation with 1 Button Mouse?

  1. 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.



  2. Re: 3 Button Simulation with 1 Button Mouse?

    In article ,
    Ken Mandelberg wrote:
    >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.


    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 (http://www.biophys.uni-duesseldorf.d...mitz/mouseemu/)

    --
    Alan Curry
    pacman@world.std.com

  3. Re: 3 Button Simulation with 1 Button Mouse?

    On 2007-05-29, Ken Mandelberg wrote:

    > 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.


    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
    (Counterfeit: mozirymaq@scrutable.com nufywofaf@hatteras.com)
    "Duty, honor, country" -- Douglas MacArthur
    "Travail, famille, patrie" -- Philippe Pétain

+ Reply to Thread