9.5 Keyboard Preferences

Xlib provides routines to control beep pitch and volume, key click, Shift-Lock mode, mouse acceleration, keyboard lights and keyboard auto-repeat. Not all servers will actually be able to control all of these parameters.

There are five routines that deal with the keyboard and pointer preferences. XGetKeyboardControl() and XChangeKeyboardControl() are the primary routines for getting or setting all these preferences at once. XAutoRepeatOff() and XAutoRepeatOn() set the global keyboard auto-repeat status but are not able to control the auto-repeat of individual keys as XChangeKeyboardControl() can.

9.5.1 Setting Keyboard Preferences

XChangeKeyboardControl() uses the standard X method of changing internal structure members. The values argument to XChangeKeyboardControl() specifies the structure containing the desired values; the value_mask argument specifies which members in the structure specified in values should replace the current settings. See the reference page for XChangeKeyboardControl() in Volume Two, Xlib Reference Manual, for a list of the mask symbols.

Example 9-13 shows the XKeyboardControl() structure.

Example 9-13. The XKeyboardControl() structure

typedef struct {
    int key_click_percent;
    int bell_percent;
    int bell_pitch;
    int bell_duration;
    int led;
    int led_mode;    /* LedModeOn or LedModeOff */
int key;
    int auto_repeat_mode;    /* AutoRepeatModeOff, AutoRepeatModeOn,
                              * AutoRepeatModeDefault */
} XKeyboardControl;

The following list describes each member of ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.