[comp.windows.x] Keymapping

jkh@VIOLET.BERKELEY.EDU (Jordan K. Hubbard) (01/29/88)

Has anyone written a utility for mapping keys around in
a relatively painless way? For instance, I'd like to get my "F1"
key on the LK201 (microvax) keyboard to be escape, but there doesn't
seem to be any easy way to do it. All those keysyms give me a headache.

					Jordan

jtkohl@athena.mit.edu (John T Kohl) (01/29/88)

In article <8801290235.AA20303@violet.berkeley.edu> jkh@VIOLET.BERKELEY.EDU (Jordan K. Hubbard) writes:
>Has anyone written a utility for mapping keys around in
>a relatively painless way? For instance, I'd like to get my "F1"
>key on the LK201 (microvax) keyboard to be escape, but there doesn't
>seem to be any easy way to do it.

Here is a (relatively gross) program to do what you want.
I haven't posted it before since I thought I would eventually find a way
to use XRebindKeysym, but my attempts to use it failed.

See sections 7.9 and 10.1 of Xlib manual for more info.

to use the program, you give it pairs of args to be rebound, like so:
	xkbdmap F1 Escape F9 Escape
which redefines F1 and F9 to be Escape keys.  This is NOT idempotent and
irreversible.  (more reasons not to release this, but you asked.... :-)

Enjoy.

Compile by
cc -o xkbdmap xkbdmap.c -lX11

---------------------xkbdmap.c------------
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>

main(argc, argv)
int argc;
char **argv;
{
	KeySym old, new;
	int old_code;
	Display *dpy;

	if (!(dpy = XOpenDisplay(getenv("DISPLAY")))) {
		fprintf(stderr,"Cannot open display '%s'\n",getenv("DISPLAY"));
		exit(1);
	}
	argv++, argc--;

	if (argc & 0x1) {
		fprintf(stderr,"must use even # args\n");
		exit(1);
	}
	while (argc > 1) {
		old = XStringToKeysym(*argv++);
		new = XStringToKeysym(*argv++);
		argc--, argc--;
		old_code = XKeysymToKeycode(dpy, old);
		XChangeKeyboardMapping(dpy, old_code, 1, &new, 1);
	}
	XFlush(dpy);
	XCloseDisplay(dpy);
	exit(0);
}
---------------end kbdmap.c---------------------
----
John Kohl
MIT/Project Athena

cookec@mmlai.UUCP (Kiliki) (08/09/89)

I am haveing problems getting information out of the people at 
Locus Computing and hope some of you can help me out.  I am using
PC-Xsight on a 286 platform with 4 MB of memory.  I would like to know:

1) where are the functions keys?  vt100 emulation is a bit ruff without them.

2) when will the promised upgrade be out that will allow me to use all 4 MB?

any help is welcome.....

please mail me at cookec@mmlai.uucp as I don't read this group very often.

horen@cadence.cadence.com (Jonathan B. Horen ) (05/03/90)

Can anyone tell me how to access the character that appears at decimal
location 127 (0x007f) from the keyboard? We are using one of the fonts
from the X11R3 misc directory, oldera (a Parsi font) for one of our
member's Motif window manager menus, but missing one letter is like
playing Solitaire with a deck of 51... (apologies to the Statler
brothers).

Also, does anyone know how to force the menu entries in Motif to align
flush right? Hebrew, which I use, and Parsi, as well as Arabic, go from
right-to-left, rather than left-to-right, and look kind of half-assed
when they show up flush-left (Motif's menu titles are automatically
centered, so there's no problem).

 +------------------------+--------------------------------------------------+
 | _J_o_n_a_t_h_a_n_ _B_._ _H_o_r_e_n_ _ _ _ _  | |  .           |                                 |
 | _C_a_d_e_n_c_e_ _D_e_s_i_g_n_ _S_y_s_t_e_m_s | |__ (/\   \  / |__     Lilmod Al Manat Lelamed   |
 |                        |  _/ / _\  _\/   _/     Lilmod Al Manat La'asot   |
 | _h_o_r_e_n_@_c_a_d_e_n_c_e_._c_o_m      |            -:   -                                |
 +------------------------+--------------------------------------------------+