2009-04-08 08:46:25 -06:00
|
|
|
#include "xkbmisc.h"
|
2012-02-15 04:49:10 -07:00
|
|
|
#include "xkbcommon/xkbcommon.h"
|
2009-01-20 19:57:22 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static void print_keysym(const char *s)
|
|
|
|
{
|
2010-07-02 09:50:01 -06:00
|
|
|
KeySym ks = xkb_string_to_keysym(s);
|
2009-01-20 19:57:22 -07:00
|
|
|
if (ks == NoSymbol)
|
|
|
|
printf("NoSymbol\n");
|
|
|
|
else
|
2009-01-22 21:18:33 -07:00
|
|
|
printf("0x%lX\n", ks);
|
2009-01-20 19:57:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void print_string(KeySym ks)
|
|
|
|
{
|
2010-10-08 13:33:18 -06:00
|
|
|
char s[16];
|
|
|
|
|
|
|
|
xkb_keysym_to_string(ks, s, sizeof s);
|
|
|
|
printf("%s\n", s);
|
2009-01-20 19:57:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int mode;
|
|
|
|
KeySym sym;
|
|
|
|
|
|
|
|
if (argc < 3) {
|
|
|
|
fprintf(stderr, "error: not enough arguments\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "-k") == 0) {
|
|
|
|
mode = 0;
|
|
|
|
sym = strtoul(argv[2], NULL, 16);
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[1], "-s") == 0)
|
|
|
|
mode = 1;
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "error: unrecognized argument \"%s\"\n", argv[1]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == 0)
|
|
|
|
print_string(sym);
|
|
|
|
else
|
|
|
|
print_keysym(argv[2]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|