From d93b32e3ad28f1b46d0ea317d7c72165d63cd805 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 8 Feb 2013 13:56:28 +0100 Subject: Initialize presenterctl for Logitech R400 --- .gitignore | 1 + Makefile | 4 ++++ presenterctl.sh | 24 ++++++++++++++++++++++++ repeat-xi2.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 presenterctl.sh create mode 100644 repeat-xi2.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06cbdff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +repeat-xi2 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2dc2717 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: repeat-xi2 + +%: %.c + gcc -ggdb -Wall $(shell pkg-config --libs --cflags x11) $< -o $@ diff --git a/presenterctl.sh b/presenterctl.sh new file mode 100755 index 0000000..3e3e750 --- /dev/null +++ b/presenterctl.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +[[ "x$1" = "xremove" ]] && exec sh -c 'xinput remove-master "remote pointer"' + +xinput remove-master "remote pointer" &> /dev/null +xinput create-master remote +$(dirname $0 )/repeat-xi2 `xinput --list --id-only "remote keyboard"` 500 8 + +for id in `xinput --list --id-only | sed "s/[^0-9]*//g"` +do + name=`xinput --list-props "$id" | sed -n "1s/.*'\([^']*\)'.*/\\1/p"` + [[ "x$name" != "xLogitech USB Receiver" ]] && continue; + + xinput reattach "$id" "remote pointer" +done + +echo -n "Attach 'TPPS/2 IBM TrackPoint' to 'remote pointer'? (Y/n): " +read attach +[[ "x$attach" = "xn" ]] && exit + +xinput reattach "TPPS/2 IBM TrackPoint" "remote pointer" +echo -n "Type enter to attach back to core pointer." +read +xinput reattach "TPPS/2 IBM TrackPoint" "Virtual core pointer" diff --git a/repeat-xi2.c b/repeat-xi2.c new file mode 100644 index 0000000..47c69b1 --- /dev/null +++ b/repeat-xi2.c @@ -0,0 +1,40 @@ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + Display *dpy; + XkbDescPtr xkb; + unsigned int id, delay, interval; + + if (argc < 4) + exit(1); + + id = atoi(argv[1]); + delay = atoi(argv[2]); + interval = atoi(argv[3]); + + dpy = XOpenDisplay(NULL); + if (!dpy) + exit(2); + + xkb = XkbGetKeyboard(dpy, XkbControlsMask, id); + if (!xkb) + exit(3); + + /* With X.Org-Server 1.13.1 on Gentoo ctrls is unexpectedly NULL. */ + if (!xkb->ctrls) + XkbGetControls(dpy, XkbRepeatKeysMask, xkb); + + xkb->ctrls->repeat_delay = delay; + xkb->ctrls->repeat_interval = 1000 / interval; + + XkbSetControls(dpy, XkbRepeatKeysMask, xkb); + XkbFreeKeyboard(xkb, 0, True); + + XCloseDisplay(dpy); + + return 0; +} -- cgit