Enhance keySyms

* Direct translate from X.Org's xproto/keysymdef.h
* Adds the key description as JSON data
* Update examples where the `x11.keySyms` API changes
This commit is contained in:
Aurélio A. Heckert 2015-10-31 17:37:58 -03:00
parent f21c8d3c2a
commit de2b73ca2b
5 changed files with 2547 additions and 1002 deletions

View file

@ -12,7 +12,7 @@ var ButtonRelease = x11.eventMask.ButtonRelease;
// image and coords file from http://www.patrick-wied.at/projects/heatmap-keyboard/
// TODO: add simple tool to use&tag coords in own keyboard photo
// jpeg decoder is slightly modified version of https://github.com/notmasteryet/jpgjs
var kbdImg = require('./node-jpg').readJpeg('./keyboard.jpg');
var kbdImg = require('./node-jpg').readJpeg(__dirname+'/keyboard.jpg');
var keycoords = require('./coordinates');
// from https://github.com/substack/node-keysym

View file

@ -5,7 +5,7 @@ var keysym = require('keysym');
var ks = x11.keySyms;
var ks2Name = {};
for (var key in ks)
ks2Name[ ks[key] ] = key;
ks2Name[ ks[key].code ] = key;
var kk2Name = {};
x11.createClient(function(err, display) {

View file

@ -250,7 +250,7 @@ x11.createClient(function(err, display) {
var ks = x11.keySyms;
var ks2Name = {};
for (var key in ks)
ks2Name[ ks[key] ] = key;
ks2Name[ ks[key].code ] = key;
var kk2Name = {};
var min = display.min_keycode;
var max = display.max_keycode;

File diff suppressed because it is too large Load diff

35
lib/keysyms.update.sh Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash -e
keysymdef_url=http://cgit.freedesktop.org/xorg/proto/xproto/plain/keysymdef.h
keysymdef=$(mktemp)
wget $keysymdef_url -O $keysymdef
(
echo "
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\\
This file is automatically translated from X.Org's xproto/keysymdef.h
Please, do not update this file with your hands, run $(basename "$0").
\\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
module.exports = {
"
sed -r '
s/#ifdef\s+/\/\/ Group /
s/#endif.*//
s/#define\s+([^ ]+)(\s+)([^ ]+)\s*\/\*\s*([^\*]+[^ ])\s*\*\// \1:\2{ code: \3, description: "\4" },/
s/(\b)U\+([0-9A-F]+)(\b)/\1(\\u\2)\3/i
s/#define\s+([^ ]+)(\s+)([^ ]+)/ \1:\2{ code: \3, description: null },/
#s/#define\s+([^ ]+)(\s+[^ ]+)/ \1:\2,/
' $keysymdef
echo -n '
NoSymbol: 0
};'
) > "$(dirname "$0")/keysyms.js"
rm $keysymdef