🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #1803

Epoch Key Mapping Utility

#1803
From: Ron M. Shapiro
Date: Wed, 24 Jul 1991 12:17
128 lines
3729 bytes
Fellow Epochites --

For what it is worth, I wrote a small X program to interactively determine
the X keysyms mappped to the keyboard.  I have tested it on an apollo X11R3
and sun4 X11R4.  This should allow you to quickly determine the names to
use to remap the keyboard using 'rebind-key' and 'global-set-key' or whatever.

The source follows.  Compile with   cc -o xkey xkey.c   or by the method
you normally use (no, there is no Makefile!).

Hope it is of some use.

-- Ron

#######  cut here  ########
/*
 *      xkey : show X key information
 *
 *      Written by Ron Shapiro      rms@apollo.srl.ford.com
 *
 *	Permission to use, copy, modify and distribute (without charge) this
 *	software, documentation, images, etc. is granted, provided that this 
 *	comment and the author's name is retained.
 *
 */

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include <stdio.h>

#define TRUE 1
#define FALSE 0

Display *display;
int screen_num;

static char *progname;

void main(int argc, char **argv)
{
  Window win;
  unsigned int width, height;
  int x, y;
  unsigned int border_width = 4;
  unsigned int display_width, display_height;
  unsigned int icon_width, icon_height;
  char *window_name = "xkey";
  char *icon_name = "xkey";
  Pixmap icon_pixmap;
  XSizeHints size_hints;
  XIconSize *size_list;
  int count;
  XEvent report;
  GC gc;
  XFontStruct *font_info;
  char *display_name = NULL;
  int window_size = 0;

  XEvent event;
  char buffer[10];
  int bufsize = 10;
  XComposeStatus compose;
  KeySym key;
  XWMHints xwmh;

  xwmh.flags = InputHint|StateHint;
  xwmh.input = 1;
  xwmh.initial_state = NormalState;

  progname = argv[0];

  if ( (display = XOpenDisplay(display_name)) == NULL )
    {
      fprintf(stderr, "%s: cannot connect to X server %s\n",
	       progname,XDisplayName(display_name));
      exit(-1);
    }


  screen_num = DefaultScreen(display);
  x = y = 0;
  width = 100;
  height = 50;

  win = XCreateSimpleWindow(display, RootWindow(display,screen_num),
			    x, y, width, height, border_width,
			    BlackPixel(display,screen_num),
			    WhitePixel(display,screen_num));

  size_hints.flags = PPosition | PSize | PMinSize;
  size_hints.x = x;
  size_hints.y = y;
  size_hints.width = width;
  size_hints.height = height;
  size_hints.min_width = 100;
  size_hints.min_height = 50;

  XSetStandardProperties(display,win,window_name,icon_name,icon_pixmap, argv,
			 argc, &size_hints);

  XSelectInput(display,win,KeyPressMask);
  XSetWMHints(display,win,&xwmh);
  XMapWindow(display,win);

  fprintf(stderr,"Place pointer in window and type.\n");
  
  while (TRUE)
    {
      *buffer = NULL;
      XNextEvent(display,&report);
      switch (report.type)
	{
	case KeyPress:
	  XLookupString(&report,buffer,bufsize,&key,&compose);
	  fprintf(stderr,
		  "The keycode = %d  The keysym = %d  The buffer = \"%s\"\n"
		  ,report.keycode,key,buffer);
	  fprintf(stderr,"The X string for the key is \"%s\"\n",
		  XKeysymToString(key));
	  break;
	default:
	  break;
	  }
    }
}
Technical Details
Message-ID: <9107241217.AA04658@apollo.srl.ford.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!cae1.srl.ford.com!rms

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,b2fc6d085e39e1ef,start
X-Google-Attributes: gidfc7ee,public
X-Google-ArrivalTime: 1991-07-24 12:33:21 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!cae1.srl.ford.com!rms
From: rms@cae1.srl.ford.com (Ron M. Shapiro)
Newsgroups: gnu.epoch.misc
Subject: Epoch Key Mapping Utility
Message-ID: <9107241217.AA04658@apollo.srl.ford.com>
Date: 24 Jul 91 12:17:19 GMT
Sender: daemon@cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 128