|
|
1.1 root 1: #include "copyright.h"
2:
3: /* $Header: XGetPntMap.c,v 1.5 87/09/11 08:09:56 toddb Exp $ */
4: /* Copyright Massachusetts Institute of Technology 1986 */
5:
6: #define NEED_REPLIES
7: #include "Xlibint.h"
8:
9: #define MIN(a, b) ((a) < (b) ? (a) : (b))
10:
11: int XGetPointerMapping (dpy, map, nmaps)
12: register Display *dpy;
13: unsigned char map[];
14: int nmaps;
15:
16: {
17: unsigned char mapping[256]; /* known fixed size */
18: long nbytes;
19: xGetPointerMappingReply rep;
20: register xReq *req;
21:
22: LockDisplay(dpy);
23: GetEmptyReq(GetPointerMapping, req);
24: (void) _XReply(dpy, (xReply *)&rep, 0, xFalse);
25:
26: nbytes = (long)rep.length << 2;
27: _XRead (dpy, (char *)mapping, nbytes);
28: /* don't return more data than the user asked for. */
29: if (rep.nElts) {
30: bcopy ((char *) mapping, (char *) map,
31: MIN((int)rep.nElts, nmaps) );
32: }
33: UnlockDisplay(dpy);
34: SyncHandle();
35: return ((int) rep.nElts);
36: }
37:
38: KeySym *XGetKeyboardMapping (dpy, first_keycode, count, keysyms_per_keycode)
39: register Display *dpy;
40: KeyCode first_keycode;
41: int count;
42: int *keysyms_per_keycode; /* RETURN */
43: {
44: long nbytes;
45: register KeySym *mapping = NULL;
46: xGetKeyboardMappingReply rep;
47: register xGetKeyboardMappingReq *req;
48:
49: LockDisplay(dpy);
50: GetReq(GetKeyboardMapping, req);
51: req->firstKeyCode = first_keycode;
52: req->count = count;
53: (void) _XReply(dpy, (xReply *)&rep, 0, xFalse);
54:
55: if (rep.length > 0) {
56: *keysyms_per_keycode = rep.keySymsPerKeyCode;
57: nbytes = (long)rep.length << 2;
58: mapping = (KeySym *) Xmalloc((unsigned) nbytes);
59:
60: _XRead (dpy, (char *)mapping, nbytes);
61: }
62: UnlockDisplay(dpy);
63: SyncHandle();
64: return (mapping);
65: }
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.