From b7eb2ae8cd480804e99f6bad9c456a24bafe9c45 Mon Sep 17 00:00:00 2001 From: Antti K Date: Sat, 26 Jul 2014 18:18:46 +0200 Subject: Rebrand to xkbcat Having taken all reasonable measures to reach the author, I'll rename to avoid confusion. --- compile | 2 +- xkbcat.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xspy.c | 136 --------------------------------------------------------------- 3 files changed, 133 insertions(+), 137 deletions(-) create mode 100644 xkbcat.c delete mode 100644 xspy.c diff --git a/compile b/compile index 9fde93e..5e1dc51 100755 --- a/compile +++ b/compile @@ -1 +1 @@ -clang -o xspy -lX11 xspy.c +clang -o xkbcat -lX11 xkbcat.c diff --git a/xkbcat.c b/xkbcat.c new file mode 100644 index 0000000..d8f4cb2 --- /dev/null +++ b/xkbcat.c @@ -0,0 +1,132 @@ +// to compile run "gcc -o xkbcat -lX11 xkbcat.c" +/* + xkbcat + Monitors key presses globally across X11. + + A rather simplified version of + `xspy` by Jon A. Maxwell (JAM) + as modified for easier physical key monitoring by Antti Korpi . +*/ + +/* + xspy polls the keyboard to determine the state of all keys on + the keyboard. By comparing results it determines which key has + been pressed. In this way it echos to the user all physical keys typed. +*/ + +#include +#include + +#include +#include +#include +#include + +#define VERSION "1.0c" +#define DEFAULT_DISPLAY ":0" +#define DEFAULT_DELAY 10000 +#define BIT(c, x) ( c[x/8]&(1<<(x%8)) ) +#define TRUE 1 +#define FALSE 0 + +#define KEYSYM_STRLEN 64 + +/* Global variables */ +extern Display *disp; +extern int PrintUp; + +Display *disp; +int PrintUp =FALSE; + +char *KeyCodeToStr(int code, int down); + +int usage() { + printf("%s\n%s\n%s\n%s\n%s%s%s\n", + "USAGE: xspy -display -delay -up", + " Options: display, specifies an X display.", + " delay, determines the polling frequency (.1 sec is 100000 usecs)", + " up, gives up transitions for some keys.", + " Version ",VERSION, ", by JAM"); + exit(0); +} + +int main(int argc, char *argv[]) { + char *hostname=DEFAULT_DISPLAY, + *char_ptr, + buf1[32], buf2[32], + *keys, + *saved; + int i, delay=DEFAULT_DELAY; + + /* get args */ + for (i=1; i -#include - -#include -#include -#include -#include - -#define VERSION "1.0c" -#define DEFAULT_DISPLAY ":0" -#define DEFAULT_DELAY 10000 -#define BIT(c, x) ( c[x/8]&(1<<(x%8)) ) -#define TRUE 1 -#define FALSE 0 - -#define KEYSYM_STRLEN 64 - -/* Global variables */ -extern Display *disp; -extern int PrintUp; - -Display *disp; -int PrintUp =FALSE; - -char *KeyCodeToStr(int code, int down); - -int usage() { - printf("%s\n%s\n%s\n%s\n%s%s%s\n", - "USAGE: xspy -display -delay -up", - " Options: display, specifies an X display.", - " delay, determines the polling frequency (.1 sec is 100000 usecs)", - " up, gives up transitions for some keys.", - " Version ",VERSION, ", by JAM"); - exit(0); -} - - - -int main(int argc, char *argv[]) { - char *hostname=DEFAULT_DISPLAY, - *char_ptr, - buf1[32], buf2[32], - *keys, - *saved; - int i, delay=DEFAULT_DELAY; - - /* get args */ - for (i=1; i