Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtConvertCase(1)

XtGetKeysymTable(1)

XtKeysymToKeycodeList(1)

XtRegisterCaseConverter(1)

XtSetKeyTranslator(1)

XtTranslateKey(1)

XtTranslateKeycode(1)

Name

XtKeyProc — prototype procedure to translate a key. 

Synopsis

typedef void (∗XtKeyProc)(Display ∗, KeyCode, Modifiers, Modifiers ∗, KeySym ∗);

    Display ∗display;
    KeyCode keycode;
    Modifiers modifiers;
    Modifiers ∗modifiers_return;
    KeySym ∗keysym_return;

Arguments

displaySpecifies the display from which to translate the events. 

keycodeSpecifies the keycode that is to be translated. 

modifiersSpecifies the mask that indicates what modifier keys (Shift, Meta, Control, etc.) are pressed. 

modifiers_return
Specifies the mask of modifier keys that the function actually evaluated in making the conversion.

keysym_return
Specifies the resulting keysym.

Description

The Resource Manager provides support for automatically translating keycodes in incoming key events into keysyms.  Keycode-to-keysym translator procedure pointers are of type XtKeyProc. 

This procedure takes a keycode and modifiers and produces a keysym.  For any given key translator function, modifiers_return will be a constant that indicates the subset of all modifiers that are examined by the key translator. 

The default translator is XtTranslateKey, an XtKeyProc that uses Shift and Lock modifiers with the interpretations defined by the core protocol.  The MIT R4 code for XtTranslateKey and associated internal routines is shown below. 

Examples

/∗
 ∗ The pd->defaultCaseConverter is _XtConvertCase or the function
 ∗ registered with XtRegisterCaseConverter.
 ∗/
void XtTranslateKey(dpy, keycode, modifiers,
        modifiers_return, keysym_return)
    register Display ∗dpy;
    KeyCode keycode;
    Modifiers modifiers;
    Modifiers ∗modifiers_return;
    KeySym ∗keysym_return;
{
    register XtPerDisplay pd = _XtGetPerDisplay(dpy);
    int per;
    register KeySym ∗syms;
    KeySym sym, lsym, usym;
     ∗modifiers_return = (ShiftMask|LockMask) | pd->mode_switch;
    if ((keycode < pd->min_keycode) || (keycode > pd->max_keycode))  {
       ∗keysym_return = NoSymbol;
        return;
    }
    per = pd->keysyms_per_keycode;
    syms = &pd->keysyms[(keycode - pd->min_keycode) ∗ per];
    while ((per > 2) && (syms[per - 1] == NoSymbol))
        per--;
    if ((per > 2) && (modifiers & pd->mode_switch)) {
        syms += 2;
      per -= 2;
    }
    if (!(modifiers & ShiftMask) &&
            (!(modifiers & LockMask) ||
            (pd->lock_meaning == NoSymbol))) {
        if ((per == 1) || (syms[1] == NoSymbol))
            (∗pd->defaultCaseConverter)(dpy, syms[0], keysym_return,
                                       &usym);
        else
            ∗keysym_return = syms[0];
    }
    else if (!(modifiers & LockMask) ||
           (dpy->lock_meaning != XK_Caps_Lock)) {
        if ((per == 1) || ((usym = syms[1]) == NoSymbol))
            (∗pd->defaultCaseConverter)(dpy, syms[0], &lsym, &usym);
        ∗keysym_return = usym;
    }
    else {
        if ((per == 1) || ((sym = syms[1]) == NoSymbol))
            sym = syms[0];
        (∗pd->defaultCaseConverter)(dpy, sym, &lsym, &usym);
        if (!(modifiers & ShiftMask) && (sym != syms[0]) &&
                ((sym != usym) || (lsym == usym)))
                (∗pd->defaultCaseConverter)(dpy, syms[0], &lsym, &usym);
            ∗keysym_return = usym;
    }
    if (∗keysym_return == XK_VoidSymbol)
        ∗keysym_return = NoSymbol;
}

The XtPerDisplay structure referenced in the example is an internal structure used to keep track of variables that may differ on a display-by-display basis. 

Structures

typedef unsigned int Modifiers;

Modifiers will be made up of the bitwise OR the following masks:

ShiftMaskShift key was depressed. 

LockMaskCaps Lock key was depressed. 

ControlMaskControl key was depressed. 

Mod1MaskKey defined as Mod1 was depressed. 

. 
.
.

Mod5MaskKey defined as Mod5 was depressed. 

StandardMask(ShiftMask | LockMask). 

For a more detailed discussion of processing keyboard input, see Chapter 13, Miscellaneous Toolkit Programming Techniques, in Volume Four, X Toolkit Intrinsics Programming Manual. 

See Also

XtConvertCase(1), XtGetKeysymTable(1), XtKeysymToKeycodeList(1), XtRegisterCaseConverter(1), XtSetKeyTranslator(1), XtTranslateKey(1), XtTranslateKeycode(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026