xwem-devel
[Top] [All Lists]

hacking the keyboard

From: Richard Klinda <ignotus@xxxxxxxxxxx>
Subject: hacking the keyboard
Date: Fri, 29 Apr 2005 22:11:10 +0200
Organization: We just joined the civil hair patrol!
Sender: ignotus@xxxxxxxxxxx
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux)
Hello, I noticed that I never use the repeat feature of the F1-F12 keys,
here is how you can disable the repeat for these keys (don't ask how
much of my blood and sweat is in this line)[1]:

  ## turning off repeat for F1-F12 (=> .xinitrc)
  xkbset perkeyrepeat 
00ffffffdffffbbf02c0ff7ffedfe5ffffffffffffffffffffffffffffffffff

(Each bit represents the on/off state of the repeat feature for one key.)

Okay, now with a little C program it is possible to differentiate
beetween keyboard hits (when you press/release the key in question) and
long keyboard hits (when you press, wait half a second then release).
I made that C program, grab it from here:

  http://ignotus.linuxforum.hu/stuff/blafi.c

The elisp snippet that generated that code is here (you probably don't
need this):
  http://ignotus.linuxforum.hu/stuff/bla.el (yeah, both the .c and .el
  are equally ugly, stupid etc, consider it "proof of concept" code..)

Compile it with: cc -L/usr/X11R6/lib -lX11 -lXtst -o blafi blafi.c

Run with ./blafi.

Now blafi intercepts every F1-F10 key hits / releases, when you just hit
the key it sends it to the client, but when you keep it pressed for more
than 0.5 seconds then it sends "hyper alt F-key".  (I left out F11 F12
because I use them very frequently)

So you can bind different functionality for them that way:
  binding normal F1: (xwem-global-set-key [(f1)] 'foo)
  binding long F1: (xwem-global-set-key [(hyper alt f1)] 'foo)
  ....

+10 FREE KEYS! :)

NOTE: I wrote this code some months ago and used it for keys 1,2,3 ...0,
but after a week or two I saw that it is very disturbing and for various
reasons I wanted to have repeat or them, so I let this whole thing to
rot.  But today I missed some free kesy very much and thought that "the
F-keys would be superb choice for blafi", so I made the lisp snippet
below to find out their bits and voila.

================================================================

Footnotes:
[1]  If you want to find out which bit controls a specific key, here is
how I did it:

,----
| (defun fukxkb (&optional original offset partlength)
|   "Open an eshell buffer, then M-x fukxkb"
|   (interactive)
|   (unless original (setq original
|                          ;; set it to your starting value
|                          
"00ffffffdffffbbffadfffffffdfe5ffffffffffffffffffffffffffffffffff"))
|   (unless offset (setq offset 0))
|   (unless partlength (setq partlength 64))
|   (setq offset (truncate offset))
|   (let* ((new (concat
|                (subseq original 0 offset)
|                (make-string (/ partlength 2) ?0)
|                (subseq original (+ offset (/ partlength 2))))))
|          (insert "xkbset perkeyrepeat " new ) (eshell-send-input)
|     (if (y-or-n-p "try the key in question, is it repeating? ")
|         (fukxkb original (+ offset (/ partlength 2)) (/ partlength 2))
|         (fukxkb original offset (/ partlength 2))
|         )))
`----

It goes through the least amount of possibilities by "binary search
method", guides you to the last byte, you have to find the last bit
(inside that last byte) by yourself (trial&error).

-- 
Richard Klinda  \/
                /\  Show me your init.el and I'll you tell who you are.

<Prev in Thread] Current Thread [Next in Thread>