home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Shareware 1999 March
/
PCShareware-3-99.iso
/
IMPLE
/
DJGPP.RAR
/
DJGPP2
/
XLIB-SR0.ZIP
/
SRC
/
XLIBEMU
/
MODMAP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-26
|
2KB
|
84 lines
/* $Id: modmap.c 1.3 1994/01/26 19:23:03 ulrich Exp $ */
/*
* modmap.c
*
* X library functions for keyboard modifier mappings.
*/
#include "Xlibemu.h"
#include <X11/keysym.h>
/* see also getpntma.c */
static KeyCode _DefaultModifierMapping[16] = {
50 /* Shift_L */, 62 /* Shift_R */, /* Shift */
66 /* Caps_Lock */, 77 /* Num_Lock */, /* Lock */
37 /* Control_L */, 109 /* Control_R */, /* Control */
64 /* Alt_R */, 113 /* Mode_Switch */, /* Mod1 */
0, 0, /* Mod2 */
0, 0, /* Mod3 */
0, 0, /* Mod4 */
0, 0, /* Mod5 */
};
XModifierKeymap *
XGetModifierMapping(dpy)
register Display *dpy;
{
unsigned long nbytes;
XModifierKeymap *res;
nbytes = sizeof(_DefaultModifierMapping);
res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap));
if (res) res->modifiermap = (KeyCode *) Xmalloc ((unsigned) nbytes);
if ((! res) || (! res->modifiermap)) {
if (res) Xfree((char *) res);
res = (XModifierKeymap *) NULL;
} else {
memcpy (res->modifiermap, _DefaultModifierMapping, nbytes);
res->max_keypermod = 2;
}
return (res);
}
/*
* Returns:
* 0 Success
* 1 Busy - one or more old or new modifiers are down
* 2 Failed - one or more new modifiers unacceptable
*/
int
XSetModifierMapping(dpy, modifier_map)
register Display *dpy;
register XModifierKeymap *modifier_map;
{
return (2);
}
XModifierKeymap *
XNewModifiermap(keyspermodifier)
int keyspermodifier;
{
XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap)));
if (res) {
res->max_keypermod = keyspermodifier;
res->modifiermap = (keyspermodifier > 0 ?
(KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier))
: (KeyCode *) NULL);
if (keyspermodifier && (res->modifiermap == NULL)) {
Xfree((char *) res);
return (XModifierKeymap *) NULL;
}
}
return (res);
}
XFreeModifiermap(map)
XModifierKeymap *map;
{
if (map) {
if (map->modifiermap)
Xfree((char *) map->modifiermap);
Xfree((char *) map);
}
}