Re: [dev] mapping keyboard buttons to move the mouse?

From: Donald Chai <donald.chai_AT_gmail.com>
Date: Thu, 27 Aug 2009 11:35:31 -0700

On Aug 27, 2009, at 5:56 AM, hessiess_AT_hessiess.com wrote:

> Sure, I have attached a tar of what I currently have, it just moves
> the
> cursor right 1 pixel at a time, It is so fast that it locks the
> cursor to
> the right side of the screen, so it is limited to 4000 iterations.
>
> How do you create a event receiver with xlib to catch mod5(alt gr) +
> some
> key regardless of the focused window?

Check the source code to dwm for this. In fact, if you're already
using dwm, it might be easiest to simply bolt on this functionality (/
me puts on flame suit).

diff -r 63e19dad219c config.def.h
--- a/config.def.h Tue Aug 18 15:59:38 2009 +0100
+++ b/config.def.h Thu Aug 27 11:30:57 2009 -0700
@@ -48,6 +48,13 @@
  static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb",
normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor,
NULL };
  static const char *termcmd[] = { "uxterm", NULL };

+static void
+movecursor(const Arg *arg)
+{
+ const int delta = 5;
+ XWarpPointer(dpy, None, None, 0, 0, 0, 0, (arg->i % 2) * delta,
(arg->i / 2) * delta);
+}
+
  static Key keys[] = {
         /* modifier key function
argument */
         { MODKEY, XK_p, spawn,
{.v = dmenucmd } },
@@ -57,6 +64,10 @@
         { MODKEY, XK_k, focusstack,
{.i = -1 } },
         { MODKEY, XK_h, setmfact,
{.f = -0.05} },
         { MODKEY, XK_l, setmfact,
{.f = +0.05} },
+ { MODKEY, XK_Left, movecursor, {.i
= -1} },
+ { MODKEY, XK_Right, movecursor, {.i
= +1} },
+ { MODKEY, XK_Up, movecursor, {.i
= -2} },
+ { MODKEY, XK_Down, movecursor, {.i
= +2} },
         { MODKEY, XK_Return, zoom,
{0} },
         { MODKEY, XK_Tab, view,
{0} },
         { MODKEY|ShiftMask, XK_c, killclient,
{0} },
Received on Thu Aug 27 2009 - 18:35:31 UTC

This archive was generated by hypermail 2.2.0 : Thu Aug 27 2009 - 18:48:01 UTC