Path: blob/main/system/include/X11/extensions/XKBstr.h
6169 views
/************************************************************1Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.23Permission to use, copy, modify, and distribute this4software and its documentation for any purpose and without5fee is hereby granted, provided that the above copyright6notice appear in all copies and that both that copyright7notice and this permission notice appear in supporting8documentation, and that the name of Silicon Graphics not be9used in advertising or publicity pertaining to distribution10of the software without specific prior written permission.11Silicon Graphics makes no representation about the suitability12of this software for any purpose. It is provided "as is"13without any express or implied warranty.1415SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS16SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY17AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON18GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL19DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,20DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE21OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH22THE USE OR PERFORMANCE OF THIS SOFTWARE.2324********************************************************/2526#ifndef _XKBSTR_H_27#define _XKBSTR_H_2829#include <X11/extensions/XKB.h>3031#define XkbCharToInt(v) ((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))32#define XkbIntTo2Chars(i,h,l) (((h)=((i>>8)&0xff)),((l)=((i)&0xff)))3334#if defined(WORD64) && defined(UNSIGNEDBITFIELDS)35#define Xkb2CharsToInt(h,l) ((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)):\36(int)(((h)<<8)|(l)&0x7fff))37#else38#define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l)))39#endif4041/*42* Common data structures and access macros43*/4445typedef struct _XkbStateRec {46unsigned char group;47unsigned char locked_group;48unsigned short base_group;49unsigned short latched_group;50unsigned char mods;51unsigned char base_mods;52unsigned char latched_mods;53unsigned char locked_mods;54unsigned char compat_state;55unsigned char grab_mods;56unsigned char compat_grab_mods;57unsigned char lookup_mods;58unsigned char compat_lookup_mods;59unsigned short ptr_buttons;60} XkbStateRec,*XkbStatePtr;61#define XkbModLocks(s) ((s)->locked_mods)62#define XkbStateMods(s) ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))63#define XkbGroupLock(s) ((s)->locked_group)64#define XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))65#define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group)66#define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group)6768typedef struct _XkbMods {69unsigned char mask; /* effective mods */70unsigned char real_mods;71unsigned short vmods;72} XkbModsRec,*XkbModsPtr;7374typedef struct _XkbKTMapEntry {75Bool active;76unsigned char level;77XkbModsRec mods;78} XkbKTMapEntryRec,*XkbKTMapEntryPtr;7980typedef struct _XkbKeyType {81XkbModsRec mods;82unsigned char num_levels;83unsigned char map_count;84XkbKTMapEntryPtr map;85XkbModsPtr preserve;86Atom name;87Atom * level_names;88} XkbKeyTypeRec, *XkbKeyTypePtr;8990#define XkbNumGroups(g) ((g)&0x0f)91#define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)92#define XkbOutOfRangeGroupAction(g) ((g)&0xc0)93#define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)94#define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))95#define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))9697/*98* Structures and access macros used primarily by the server99*/100101typedef struct _XkbBehavior {102unsigned char type;103unsigned char data;104} XkbBehavior;105106#define XkbAnyActionDataSize 7107typedef struct _XkbAnyAction {108unsigned char type;109unsigned char data[XkbAnyActionDataSize];110} XkbAnyAction;111112typedef struct _XkbModAction {113unsigned char type;114unsigned char flags;115unsigned char mask;116unsigned char real_mods;117unsigned char vmods1;118unsigned char vmods2;119} XkbModAction;120#define XkbModActionVMods(a) \121((short)(((a)->vmods1<<8)|((a)->vmods2)))122#define XkbSetModActionVMods(a,v) \123(((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))124125typedef struct _XkbGroupAction {126unsigned char type;127unsigned char flags;128char group_XXX;129} XkbGroupAction;130#define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX))131#define XkbSASetGroup(a,g) ((a)->group_XXX=(g))132133typedef struct _XkbISOAction {134unsigned char type;135unsigned char flags;136unsigned char mask;137unsigned char real_mods;138char group_XXX;139unsigned char affect;140unsigned char vmods1;141unsigned char vmods2;142} XkbISOAction;143144typedef struct _XkbPtrAction {145unsigned char type;146unsigned char flags;147unsigned char high_XXX;148unsigned char low_XXX;149unsigned char high_YYY;150unsigned char low_YYY;151} XkbPtrAction;152#define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX))153#define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY))154#define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX))155#define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY))156157typedef struct _XkbPtrBtnAction {158unsigned char type;159unsigned char flags;160unsigned char count;161unsigned char button;162} XkbPtrBtnAction;163164typedef struct _XkbPtrDfltAction {165unsigned char type;166unsigned char flags;167unsigned char affect;168char valueXXX;169} XkbPtrDfltAction;170#define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX))171#define XkbSASetPtrDfltValue(a,c) ((a)->valueXXX= ((c)&0xff))172173typedef struct _XkbSwitchScreenAction {174unsigned char type;175unsigned char flags;176char screenXXX;177} XkbSwitchScreenAction;178#define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX))179#define XkbSASetScreen(a,s) ((a)->screenXXX= ((s)&0xff))180181typedef struct _XkbCtrlsAction {182unsigned char type;183unsigned char flags;184unsigned char ctrls3;185unsigned char ctrls2;186unsigned char ctrls1;187unsigned char ctrls0;188} XkbCtrlsAction;189#define XkbActionSetCtrls(a,c) (((a)->ctrls3=(((c)>>24)&0xff)),\190((a)->ctrls2=(((c)>>16)&0xff)),\191((a)->ctrls1=(((c)>>8)&0xff)),\192((a)->ctrls0=((c)&0xff)))193#define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\194(((unsigned int)(a)->ctrls2)<<16)|\195(((unsigned int)(a)->ctrls1)<<8)|\196((unsigned int)((a)->ctrls0)))197198typedef struct _XkbMessageAction {199unsigned char type;200unsigned char flags;201unsigned char message[6];202} XkbMessageAction;203204typedef struct _XkbRedirectKeyAction {205unsigned char type;206unsigned char new_key;207unsigned char mods_mask;208unsigned char mods;209unsigned char vmods_mask0;210unsigned char vmods_mask1;211unsigned char vmods0;212unsigned char vmods1;213} XkbRedirectKeyAction;214215#define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|\216((unsigned int)(a)->vmods0))217#define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\218((a)->vmods_mask0=((m)&0xff)))219#define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|\220((unsigned int)(a)->vmods_mask0))221#define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\222((a)->vmods_mask0=((m)&0xff)))223224typedef struct _XkbDeviceBtnAction {225unsigned char type;226unsigned char flags;227unsigned char count;228unsigned char button;229unsigned char device;230} XkbDeviceBtnAction;231232typedef struct _XkbDeviceValuatorAction {233unsigned char type;234unsigned char device;235unsigned char v1_what;236unsigned char v1_ndx;237unsigned char v1_value;238unsigned char v2_what;239unsigned char v2_ndx;240unsigned char v2_value;241} XkbDeviceValuatorAction;242243typedef union _XkbAction {244XkbAnyAction any;245XkbModAction mods;246XkbGroupAction group;247XkbISOAction iso;248XkbPtrAction ptr;249XkbPtrBtnAction btn;250XkbPtrDfltAction dflt;251XkbSwitchScreenAction screen;252XkbCtrlsAction ctrls;253XkbMessageAction msg;254XkbRedirectKeyAction redirect;255XkbDeviceBtnAction devbtn;256XkbDeviceValuatorAction devval;257unsigned char type;258} XkbAction;259260typedef struct _XkbControls {261unsigned char mk_dflt_btn;262unsigned char num_groups;263unsigned char groups_wrap;264XkbModsRec internal;265XkbModsRec ignore_lock;266unsigned int enabled_ctrls;267unsigned short repeat_delay;268unsigned short repeat_interval;269unsigned short slow_keys_delay;270unsigned short debounce_delay;271unsigned short mk_delay;272unsigned short mk_interval;273unsigned short mk_time_to_max;274unsigned short mk_max_speed;275short mk_curve;276unsigned short ax_options;277unsigned short ax_timeout;278unsigned short axt_opts_mask;279unsigned short axt_opts_values;280unsigned int axt_ctrls_mask;281unsigned int axt_ctrls_values;282unsigned char per_key_repeat[XkbPerKeyBitArraySize];283} XkbControlsRec, *XkbControlsPtr;284285#define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask)286#define XkbAX_NeedOption(c,w) ((c)->ax_options&(w))287#define XkbAX_NeedFeedback(c,w) (XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))288289typedef struct _XkbServerMapRec {290unsigned short num_acts;291unsigned short size_acts;292XkbAction *acts;293294XkbBehavior *behaviors;295unsigned short *key_acts;296#if defined(__cplusplus) || defined(c_plusplus)297/* explicit is a C++ reserved word */298unsigned char *c_explicit;299#else300unsigned char *explicit;301#endif302unsigned char vmods[XkbNumVirtualMods];303unsigned short *vmodmap;304} XkbServerMapRec, *XkbServerMapPtr;305306#define XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])307308/*309* Structures and access macros used primarily by clients310*/311312typedef struct _XkbSymMapRec {313unsigned char kt_index[XkbNumKbdGroups];314unsigned char group_info;315unsigned char width;316unsigned short offset;317} XkbSymMapRec, *XkbSymMapPtr;318319typedef struct _XkbClientMapRec {320unsigned char size_types;321unsigned char num_types;322XkbKeyTypePtr types;323324unsigned short size_syms;325unsigned short num_syms;326KeySym *syms;327XkbSymMapPtr key_sym_map;328329unsigned char *modmap;330} XkbClientMapRec, *XkbClientMapPtr;331332#define XkbCMKeyGroupInfo(m,k) ((m)->key_sym_map[k].group_info)333#define XkbCMKeyNumGroups(m,k) (XkbNumGroups((m)->key_sym_map[k].group_info))334#define XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)335#define XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)336#define XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])337#define XkbCMKeyType(m,k,g) (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])338#define XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))339#define XkbCMKeySymsOffset(m,k) ((m)->key_sym_map[k].offset)340#define XkbCMKeySymsPtr(m,k) (&(m)->syms[XkbCMKeySymsOffset(m,k)])341342/*343* Compatibility structures and access macros344*/345346typedef struct _XkbSymInterpretRec {347KeySym sym;348unsigned char flags;349unsigned char match;350unsigned char mods;351unsigned char virtual_mod;352XkbAnyAction act;353} XkbSymInterpretRec,*XkbSymInterpretPtr;354355typedef struct _XkbCompatMapRec {356XkbSymInterpretPtr sym_interpret;357XkbModsRec groups[XkbNumKbdGroups];358unsigned short num_si;359unsigned short size_si;360} XkbCompatMapRec, *XkbCompatMapPtr;361362typedef struct _XkbIndicatorMapRec {363unsigned char flags;364unsigned char which_groups;365unsigned char groups;366unsigned char which_mods;367XkbModsRec mods;368unsigned int ctrls;369} XkbIndicatorMapRec, *XkbIndicatorMapPtr;370371#define XkbIM_IsAuto(i) ((((i)->flags&XkbIM_NoAutomatic)==0)&&\372(((i)->which_groups&&(i)->groups)||\373((i)->which_mods&&(i)->mods.mask)||\374((i)->ctrls)))375#define XkbIM_InUse(i) (((i)->flags)||((i)->which_groups)||\376((i)->which_mods)||((i)->ctrls))377378379typedef struct _XkbIndicatorRec {380unsigned long phys_indicators;381XkbIndicatorMapRec maps[XkbNumIndicators];382} XkbIndicatorRec,*XkbIndicatorPtr;383384typedef struct _XkbKeyNameRec {385char name[XkbKeyNameLength];386} XkbKeyNameRec,*XkbKeyNamePtr;387388typedef struct _XkbKeyAliasRec {389char real[XkbKeyNameLength];390char alias[XkbKeyNameLength];391} XkbKeyAliasRec,*XkbKeyAliasPtr;392393/*394* Names for everything395*/396typedef struct _XkbNamesRec {397Atom keycodes;398Atom geometry;399Atom symbols;400Atom types;401Atom compat;402Atom vmods[XkbNumVirtualMods];403Atom indicators[XkbNumIndicators];404Atom groups[XkbNumKbdGroups];405XkbKeyNamePtr keys;406XkbKeyAliasPtr key_aliases;407Atom *radio_groups;408Atom phys_symbols;409410unsigned char num_keys;411unsigned char num_key_aliases;412unsigned short num_rg;413} XkbNamesRec,*XkbNamesPtr;414415typedef struct _XkbGeometry *XkbGeometryPtr;416/*417* Tie it all together into one big keyboard description418*/419typedef struct _XkbDesc {420struct _XDisplay * dpy;421unsigned short flags;422unsigned short device_spec;423KeyCode min_key_code;424KeyCode max_key_code;425426XkbControlsPtr ctrls;427XkbServerMapPtr server;428XkbClientMapPtr map;429XkbIndicatorPtr indicators;430XkbNamesPtr names;431XkbCompatMapPtr compat;432XkbGeometryPtr geom;433} XkbDescRec, *XkbDescPtr;434#define XkbKeyKeyTypeIndex(d,k,g) (XkbCMKeyTypeIndex((d)->map,k,g))435#define XkbKeyKeyType(d,k,g) (XkbCMKeyType((d)->map,k,g))436#define XkbKeyGroupWidth(d,k,g) (XkbCMKeyGroupWidth((d)->map,k,g))437#define XkbKeyGroupsWidth(d,k) (XkbCMKeyGroupsWidth((d)->map,k))438#define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k)))439#define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k)))440#define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k)))441#define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k)))442#define XkbKeySym(d,k,n) (XkbKeySymsPtr(d,k)[n])443#define XkbKeySymEntry(d,k,sl,g) \444(XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))445#define XkbKeyAction(d,k,n) \446(XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)447#define XkbKeyActionEntry(d,k,sl,g) \448(XkbKeyHasActions(d,k)?\449XkbKeyAction(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))):NULL)450451#define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0)452#define XkbKeyNumActions(d,k) (XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)453#define XkbKeyActionsPtr(d,k) (XkbSMKeyActionsPtr((d)->server,k))454#define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&&\455((k)<=(d)->max_key_code))456#define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1)457458459/*460* The following structures can be used to track changes461* to a keyboard device462*/463typedef struct _XkbMapChanges {464unsigned short changed;465KeyCode min_key_code;466KeyCode max_key_code;467unsigned char first_type;468unsigned char num_types;469KeyCode first_key_sym;470unsigned char num_key_syms;471KeyCode first_key_act;472unsigned char num_key_acts;473KeyCode first_key_behavior;474unsigned char num_key_behaviors;475KeyCode first_key_explicit;476unsigned char num_key_explicit;477KeyCode first_modmap_key;478unsigned char num_modmap_keys;479KeyCode first_vmodmap_key;480unsigned char num_vmodmap_keys;481unsigned char pad;482unsigned short vmods;483} XkbMapChangesRec,*XkbMapChangesPtr;484485typedef struct _XkbControlsChanges {486unsigned int changed_ctrls;487unsigned int enabled_ctrls_changes;488Bool num_groups_changed;489} XkbControlsChangesRec,*XkbControlsChangesPtr;490491typedef struct _XkbIndicatorChanges {492unsigned int state_changes;493unsigned int map_changes;494} XkbIndicatorChangesRec,*XkbIndicatorChangesPtr;495496typedef struct _XkbNameChanges {497unsigned int changed;498unsigned char first_type;499unsigned char num_types;500unsigned char first_lvl;501unsigned char num_lvls;502unsigned char num_aliases;503unsigned char num_rg;504unsigned char first_key;505unsigned char num_keys;506unsigned short changed_vmods;507unsigned long changed_indicators;508unsigned char changed_groups;509} XkbNameChangesRec,*XkbNameChangesPtr;510511typedef struct _XkbCompatChanges {512unsigned char changed_groups;513unsigned short first_si;514unsigned short num_si;515} XkbCompatChangesRec,*XkbCompatChangesPtr;516517typedef struct _XkbChanges {518unsigned short device_spec;519unsigned short state_changes;520XkbMapChangesRec map;521XkbControlsChangesRec ctrls;522XkbIndicatorChangesRec indicators;523XkbNameChangesRec names;524XkbCompatChangesRec compat;525} XkbChangesRec, *XkbChangesPtr;526527/*528* These data structures are used to construct a keymap from529* a set of components or to list components in the server530* database.531*/532typedef struct _XkbComponentNames {533char * keymap;534char * keycodes;535char * types;536char * compat;537char * symbols;538char * geometry;539} XkbComponentNamesRec, *XkbComponentNamesPtr;540541typedef struct _XkbComponentName {542unsigned short flags;543char * name;544} XkbComponentNameRec,*XkbComponentNamePtr;545546typedef struct _XkbComponentList {547int num_keymaps;548int num_keycodes;549int num_types;550int num_compat;551int num_symbols;552int num_geometry;553XkbComponentNamePtr keymaps;554XkbComponentNamePtr keycodes;555XkbComponentNamePtr types;556XkbComponentNamePtr compat;557XkbComponentNamePtr symbols;558XkbComponentNamePtr geometry;559} XkbComponentListRec, *XkbComponentListPtr;560561/*562* The following data structures describe and track changes to a563* non-keyboard extension device564*/565typedef struct _XkbDeviceLedInfo {566unsigned short led_class;567unsigned short led_id;568unsigned int phys_indicators;569unsigned int maps_present;570unsigned int names_present;571unsigned int state;572Atom names[XkbNumIndicators];573XkbIndicatorMapRec maps[XkbNumIndicators];574} XkbDeviceLedInfoRec,*XkbDeviceLedInfoPtr;575576typedef struct _XkbDeviceInfo {577char * name;578Atom type;579unsigned short device_spec;580Bool has_own_state;581unsigned short supported;582unsigned short unsupported;583584unsigned short num_btns;585XkbAction * btn_acts;586587unsigned short sz_leds;588unsigned short num_leds;589unsigned short dflt_kbd_fb;590unsigned short dflt_led_fb;591XkbDeviceLedInfoPtr leds;592} XkbDeviceInfoRec,*XkbDeviceInfoPtr;593594#define XkbXI_DevHasBtnActs(d) (((d)->num_btns>0)&&((d)->btn_acts!=NULL))595#define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))596#define XkbXI_DevHasLeds(d) (((d)->num_leds>0)&&((d)->leds!=NULL))597598typedef struct _XkbDeviceLedChanges {599unsigned short led_class;600unsigned short led_id;601unsigned int defined; /* names or maps changed */602struct _XkbDeviceLedChanges *next;603} XkbDeviceLedChangesRec,*XkbDeviceLedChangesPtr;604605typedef struct _XkbDeviceChanges {606unsigned int changed;607unsigned short first_btn;608unsigned short num_btns;609XkbDeviceLedChangesRec leds;610} XkbDeviceChangesRec,*XkbDeviceChangesPtr;611612#endif /* _XKBSTR_H_ */613614615