diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | config.h | 44 | ||||
-rw-r--r-- | xmouseless.c | 31 |
3 files changed, 41 insertions, 35 deletions
@@ -1 +0,0 @@ -- check if key repeat is enabled at start @@ -1,27 +1,16 @@ -#include <X11/Xlib.h> -#include <X11/Xutil.h> /* the rate at which the mouse moves */ -#define MOVE_RATE 30 +static const unsigned int move_rate = 30; /* the speed with no modifier */ -#define DEFAULT_SPEED 10 +static const unsigned int default_speed = 20; -typedef struct { - KeySym keysym; - int x; - int y; -} MoveBinding; - -typedef struct { - KeySym keysym; - int button; -} ClickBinding; - -typedef struct { - KeySym keysym; - int speed; -} SpeedBindings; +static SpeedBindings speed_bindings[] = { + /* key speed */ + { XK_Super_L, 100 }, + { XK_Alt_L, 50 }, + { XK_a, 2 }, +}; static MoveBinding move_bindings[] = { /* key x y */ @@ -35,23 +24,22 @@ static MoveBinding move_bindings[] = { { XK_period, 1, 1 }, }; +/* 1: left + * 2: middle + * 3: right + * 4: scroll up + * 5: scroll down */ static ClickBinding click_bindings[] = { /* key button */ { XK_space, 1 }, { XK_f, 1 }, { XK_d, 2 }, { XK_s, 3 }, - { XK_minus, 4 }, - { XK_plus, 5 }, -}; - -static SpeedBindings speed_bindings[] = { - /* key speed */ - { XK_Super_L, 200 }, - { XK_Alt_L, 50 }, - { XK_a, 2 }, + { XK_plus, 4 }, + { XK_minus, 5 }, }; +/* exits on key release which allows click and exit with one key */ static unsigned int exit_keys[] = { XK_Escape, XK_q, XK_space }; diff --git a/xmouseless.c b/xmouseless.c index 0eb54f0..90dd4b1 100644 --- a/xmouseless.c +++ b/xmouseless.c @@ -11,16 +11,35 @@ #include <X11/XKBlib.h> #include <X11/extensions/XTest.h> +#define LENGTH(X) (sizeof X / sizeof X[0]) + + +typedef struct { + KeySym keysym; + int x; + int y; +} MoveBinding; + +typedef struct { + KeySym keysym; + int button; +} ClickBinding; + +typedef struct { + KeySym keysym; + int speed; +} SpeedBindings; + +/* load configuration */ #include "config.h" -#define LENGTH(X) (sizeof X / sizeof X[0]) Display *dpy; int screen; Window root; pthread_t movethread; -unsigned int speed = DEFAULT_SPEED; +static unsigned int speed = default_speed; struct { int x; @@ -84,7 +103,7 @@ void *moveforever(void *val) { if (mouseinfo.move_x != 0 || mouseinfo.move_y != 0) { moverelative(speed * mouseinfo.move_x, speed * mouseinfo.move_y); } - usleep(1000000 / MOVE_RATE); + usleep(1000000 / move_rate); } } @@ -115,8 +134,8 @@ void handle_keypress(XKeyEvent event) { /* speed bindings */ for (i = 0; i < LENGTH(speed_bindings); i++) { if (speed_bindings[i].keysym == keysym) { - printf("speed: %i\n", speed_bindings[i].speed); speed = speed_bindings[i].speed; + printf("speed: %i\n", speed); } } } @@ -147,8 +166,8 @@ void handle_keyrelease(XKeyEvent event) { /* speed bindings */ for (i = 0; i < LENGTH(speed_bindings); i++) { if (speed_bindings[i].keysym == keysym) { - printf("speed: %i\n", DEFAULT_SPEED); - speed = DEFAULT_SPEED; + speed = default_speed; + printf("speed: %i\n", speed); } } |