Introduce xkb_keycode_t for keycodes

And use it consistently everywhere, including with a special long-safe
internal keycode type, to ease the transition to large keycodes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-02-15 14:34:08 +00:00
parent 8f01b14412
commit 4e22851141
15 changed files with 261 additions and 136 deletions

View File

@ -60,9 +60,16 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/Xfuncproto.h>
#include <X11/extensions/XKB.h>
#ifndef X_PROTOCOL
typedef unsigned char KeyCode;
#endif
typedef uint8_t xkb_keycode_t;
#define XKB_KEYCODE_MAX 255
#define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX)
#define xkb_keycode_is_legal_x11(kc) (kc <= XKB_KEYCODE_MAX)
#define xkb_keymap_keycode_range_is_legal(xkb) \
(xkb->max_key_code > 0 && \
xkb->max_key_code > xkb->min_key_code && \
xkb_keycode_is_legal_ext(xkb->min_key_code) && \
xkb_keycode_is_legal_ext(xkb->max_key_code))
/* Duplicate the modifier mask defines so libxkcommon can be used
* without X.h */
@ -153,7 +160,7 @@ struct xkb_switch_screen_action {
struct xkb_redirect_key_action {
uint8_t type;
uint8_t new_key;
xkb_keycode_t new_key;
uint8_t mods_mask;
uint8_t mods;
uint16_t vmods_mask;
@ -254,8 +261,8 @@ struct xkb_client_map {
unsigned char num_types;
struct xkb_key_type * types;
unsigned short size_syms;
unsigned short num_syms;
uint32_t size_syms;
uint32_t num_syms;
uint32_t *syms;
struct xkb_sym_map * key_sym_map;
@ -335,8 +342,8 @@ struct xkb_names {
uint32_t *radio_groups;
uint32_t phys_symbols;
unsigned char num_keys;
unsigned char num_key_aliases;
xkb_keycode_t num_keys;
xkb_keycode_t num_key_aliases;
unsigned short num_rg;
};
@ -599,7 +606,7 @@ struct xkb_controls {
unsigned short axt_opts_values;
unsigned int axt_ctrls_mask;
unsigned int axt_ctrls_values;
unsigned char per_key_repeat[XkbPerKeyBitArraySize];
unsigned char *per_key_repeat;
};
/* Common keyboard description structure */
@ -607,8 +614,8 @@ struct xkb_desc {
unsigned int defined;
unsigned short flags;
unsigned short device_spec;
KeyCode min_key_code;
KeyCode max_key_code;
xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code;
struct xkb_controls * ctrls;
struct xkb_server_map * server;
@ -645,23 +652,22 @@ struct xkb_desc {
struct xkb_map_changes {
unsigned short changed;
KeyCode min_key_code;
KeyCode max_key_code;
xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code;
unsigned char first_type;
unsigned char num_types;
KeyCode first_key_sym;
unsigned char num_key_syms;
KeyCode first_key_act;
unsigned char num_key_acts;
KeyCode first_key_behavior;
unsigned char num_key_behaviors;
KeyCode first_key_explicit;
unsigned char num_key_explicit;
KeyCode first_modmap_key;
unsigned char num_modmap_keys;
KeyCode first_vmodmap_key;
unsigned char num_vmodmap_keys;
unsigned char pad;
xkb_keycode_t first_key_sym;
xkb_keycode_t num_key_syms;
xkb_keycode_t first_key_act;
xkb_keycode_t num_key_acts;
xkb_keycode_t first_key_behavior;
xkb_keycode_t num_key_behaviors;
xkb_keycode_t first_key_explicit;
xkb_keycode_t num_key_explicit;
xkb_keycode_t first_modmap_key;
xkb_keycode_t num_modmap_keys;
xkb_keycode_t first_vmodmap_key;
xkb_keycode_t num_vmodmap_keys;
unsigned short vmods;
};
@ -682,10 +688,10 @@ struct xkb_name_changes {
unsigned char num_types;
unsigned char first_lvl;
unsigned char num_lvls;
unsigned char num_aliases;
xkb_keycode_t num_aliases;
unsigned char num_rg;
unsigned char first_key;
unsigned char num_keys;
xkb_keycode_t first_key;
xkb_keycode_t num_keys;
unsigned short changed_vmods;
unsigned long changed_indicators;
unsigned char changed_groups;

View File

@ -144,10 +144,8 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAl
}
if ((which & XkbKeyNamesMask) && !names->keys) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
return BadValue;
if (!xkb_keymap_keycode_range_is_legal(xkb))
return BadMatch;
names->keys = _XkbTypedCalloc(xkb->max_key_code + 1, struct xkb_key_name);
if (!names->keys)
@ -267,6 +265,13 @@ XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
return BadAlloc;
}
if (!xkb->ctrls->per_key_repeat) {
xkb->ctrls->per_key_repeat = _XkbTypedCalloc(xkb->max_key_code << 3,
unsigned char);
if (!xkb->ctrls->per_key_repeat)
return BadAlloc;
}
return Success;
}

View File

@ -37,10 +37,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
if (!xkb || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
return BadValue;
if ((which & XkbKeySymsMask) &&
((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))) {
if ((which & XkbKeySymsMask) && !xkb_keymap_keycode_range_is_legal(xkb)) {
#ifdef DEBUG
fprintf(stderr, "bad keycode (%d,%d) in XkbAllocClientMap\n",
xkb->min_key_code, xkb->max_key_code);
@ -106,9 +103,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
}
if (which & XkbModifierMapMask) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
if (!xkb_keymap_keycode_range_is_legal(xkb))
return BadMatch;
if (!map->modmap) {
@ -144,12 +139,13 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
else
map = xkb->server;
if (which & XkbExplicitComponentsMask) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
return BadMatch;
if (!which)
return Success;
if (!xkb_keymap_keycode_range_is_legal(xkb))
return BadMatch;
if (which & XkbExplicitComponentsMask) {
if (!map->explicit) {
i = xkb->max_key_code + 1;
map->explicit = _XkbTypedCalloc(i, unsigned char);
@ -159,11 +155,6 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
}
if (which&XkbKeyActionsMask) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
return BadMatch;
if (nNewActions < 1)
nNewActions = 1;
@ -200,11 +191,6 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
}
if (which & XkbKeyBehaviorsMask) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
return BadMatch;
if (!map->behaviors) {
i = xkb->max_key_code + 1;
map->behaviors = _XkbTypedCalloc(i, struct xkb_behavior);
@ -214,11 +200,6 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
}
if (which & XkbVirtualModMapMask) {
if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
(!XkbIsLegalKeycode(xkb->max_key_code)) ||
(xkb->max_key_code < xkb->min_key_code))
return BadMatch;
if (!map->vmodmap) {
i = xkb->max_key_code + 1;
map->vmodmap = _XkbTypedCalloc(i, uint32_t);
@ -279,10 +260,11 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
}
uint32_t *
XkbcResizeKeySyms(struct xkb_desc * xkb, int key, int needed)
XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
unsigned int needed)
{
int i, nSyms, nKeySyms;
unsigned nOldSyms;
uint32_t i, nSyms, nKeySyms;
uint32_t nOldSyms;
uint32_t *newSyms;
if (needed == 0) {
@ -291,10 +273,10 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, int key, int needed)
}
nOldSyms = XkbKeyNumSyms(xkb, key);
if (nOldSyms >= (unsigned)needed)
if (nOldSyms >= needed)
return XkbKeySymsPtr(xkb, key);
if (xkb->map->size_syms - xkb->map->num_syms >= (unsigned)needed) {
if (xkb->map->size_syms - xkb->map->num_syms >= needed) {
if (nOldSyms > 0)
memcpy(&xkb->map->syms[xkb->map->num_syms],
XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(uint32_t));
@ -343,9 +325,9 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, int key, int needed)
}
union xkb_action *
XkbcResizeKeyActions(struct xkb_desc * xkb, int key, int needed)
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
{
int i, nActs;
xkb_keycode_t i, nActs;
union xkb_action *newActs;
if (needed == 0) {
@ -372,7 +354,7 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, int key, int needed)
nActs = 1;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
int nKeyActs, nCopy;
xkb_keycode_t nKeyActs, nCopy;
if ((xkb->server->key_acts[i] == 0) && (i != key))
continue;

View File

@ -62,10 +62,10 @@ extern int
XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type *into);
extern uint32_t *
XkbcResizeKeySyms(struct xkb_desc * xkb, int key, int needed);
XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed);
extern union xkb_action *
XkbcResizeKeyActions(struct xkb_desc * xkb, int key, int needed);
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed);
extern void
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);

View File

@ -1038,6 +1038,7 @@ HandleRedirectKey(struct xkb_desc * xkb,
ExprResult rtrn;
struct xkb_redirect_key_action *act;
unsigned t1, t2;
xkb_keycode_t kc;
unsigned long tmp;
if (array_ndx != NULL)
@ -1050,12 +1051,12 @@ HandleRedirectKey(struct xkb_desc * xkb,
if (!ExprResolveKeyName(value, &rtrn, NULL, NULL))
return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name);
if (!FindNamedKey(xkb, tmp, &t1, True, CreateKeyNames(xkb), 0))
if (!FindNamedKey(xkb, tmp, &kc, True, CreateKeyNames(xkb), 0))
{
return ReportNotFound(action->type, field, "Key",
XkbcKeyNameText(rtrn.keyName.name));
}
act->new_key = t1;
act->new_key = kc;
return True;
case F_ModsToClear:
case F_Modifiers:

View File

@ -179,7 +179,7 @@ ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
info = (AliasInfo *) info->def.next)
{
unsigned long lname;
unsigned int kc;
xkb_keycode_t kc;
lname = KeyNameToLong(info->real);
if (!FindNamedKey(xkb, lname, &kc, False, CreateKeyNames(xkb), 0))

View File

@ -485,6 +485,69 @@ ExprResolveFloat(ExprDef * expr,
return False;
}
int
ExprResolveKeyCode(ExprDef * expr,
ExprResult * val_rtrn)
{
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
switch (expr->op)
{
case ExprValue:
if (expr->type != TypeInt)
{
ERROR
("Found constant of type %s where an int was expected\n",
exprTypeText(expr->type));
return False;
}
val_rtrn->uval = expr->value.uval;
return True;
case OpAdd:
case OpSubtract:
case OpMultiply:
case OpDivide:
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveKeyCode(left, &leftRtrn) &&
ExprResolveKeyCode(right, &rightRtrn))
{
switch (expr->op)
{
case OpAdd:
val_rtrn->uval = leftRtrn.uval + rightRtrn.uval;
break;
case OpSubtract:
val_rtrn->uval = leftRtrn.uval - rightRtrn.uval;
break;
case OpMultiply:
val_rtrn->uval = leftRtrn.uval * rightRtrn.uval;
break;
case OpDivide:
val_rtrn->uval = leftRtrn.uval / rightRtrn.uval;
break;
}
return True;
}
return False;
case OpNegate:
left = expr->value.child;
if (ExprResolveKeyCode(left, &leftRtrn))
{
val_rtrn->uval = ~leftRtrn.uval;
return True;
}
return False;
case OpUnaryPlus:
left = expr->value.child;
return ExprResolveKeyCode(left, val_rtrn);
default:
WSGO("Unknown operator %d in ResolveInteger\n", expr->op);
break;
}
return False;
}
int
ExprResolveInteger(ExprDef * expr,
ExprResult * val_rtrn,

View File

@ -105,6 +105,10 @@ extern int ExprResolveBoolean(ExprDef * /* expr */ ,
char * /* lookupPriv */
);
extern int ExprResolveKeyCode(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */
);
extern int ExprResolveInteger(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,

View File

@ -70,15 +70,14 @@ typedef struct _KeyNamesInfo
int errorCount;
unsigned fileID;
unsigned merge;
int computedMin; /* lowest keycode stored */
int computedMax; /* highest keycode stored */
int explicitMin;
int explicitMax;
int effectiveMin;
int effectiveMax;
unsigned long names[XkbMaxLegalKeyCode + 1]; /* 4-letter name of key, keycode is the index */
unsigned files[XkbMaxLegalKeyCode + 1];
unsigned char has_alt_forms[XkbMaxLegalKeyCode + 1];
xkb_keycode_t computedMin; /* lowest keycode stored */
xkb_keycode_t computedMax; /* highest keycode stored */
xkb_keycode_t explicitMin;
xkb_keycode_t explicitMax;
xkb_keycode_t arraySize;
unsigned long *names;
unsigned *files;
unsigned char *has_alt_forms;
IndicatorNameInfo *leds;
AliasInfo *aliases;
} KeyNamesInfo;
@ -88,6 +87,53 @@ static void HandleKeycodesFile(XkbFile * file,
unsigned merge,
KeyNamesInfo * info);
static int
ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
{
void *tmp;
int i;
tmp = _XkbTypedRealloc(info->names, newMax + 1, unsigned long);
if (!tmp) {
ERROR
("Couldn't reallocate for larger maximum keycode (%d)\n",
newMax);
ACTION("Maximum key value not changed\n");
return 0;
}
info->names = tmp;
for (i = info->arraySize + 1; i <= newMax; i++)
info->names[i] = 0;
tmp = _XkbTypedRealloc(info->files, newMax + 1, unsigned);
if (!tmp) {
ERROR
("Couldn't reallocate for larger maximum keycode (%d)\n",
newMax);
ACTION("Maximum key value not changed\n");
return 0;
}
info->files = tmp;
for (i = info->arraySize + 1; i <= newMax; i++)
info->files[i] = 0;
tmp = _XkbTypedRealloc(info->has_alt_forms, newMax + 1, unsigned char);
if (!tmp) {
ERROR
("Couldn't reallocate for larger maximum keycode (%d)\n",
newMax);
ACTION("Maximum key value not changed\n");
return 0;
}
info->has_alt_forms = tmp;
for (i = info->arraySize + 1; i <= newMax; i++)
info->has_alt_forms[i] = 0;
info->arraySize = newMax;
return 1;
}
static void
InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{
@ -278,13 +324,15 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
if (info->name != NULL)
free(info->name);
info->name = NULL;
info->computedMax = info->explicitMax = info->explicitMin = -1;
info->computedMin = 256;
info->effectiveMin = 8;
info->effectiveMax = 255;
bzero((char *) info->names, sizeof(info->names));
bzero((char *) info->files, sizeof(info->files));
bzero((char *) info->has_alt_forms, sizeof(info->has_alt_forms));
info->computedMax = info->explicitMax = info->explicitMin = 0;
info->computedMin = XKB_KEYCODE_MAX;
info->arraySize = 0;
free(info->names);
info->names = NULL;
free(info->files);
info->files = NULL;
free(info->has_alt_forms);
info->has_alt_forms = NULL;
if (info->leds)
ClearIndicatorNameInfo(info->leds, info);
if (info->aliases)
@ -298,6 +346,9 @@ InitKeyNamesInfo(KeyNamesInfo * info)
info->name = NULL;
info->leds = NULL;
info->aliases = NULL;
info->names = NULL;
info->files = NULL;
info->has_alt_forms = NULL;
ClearKeyNamesInfo(info);
info->errorCount = 0;
return;
@ -308,7 +359,7 @@ FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{
register int i;
for (i = info->effectiveMin; i <= info->effectiveMax; i++)
for (i = info->computedMin; i <= info->computedMax; i++)
{
if (info->names[i] == name)
return i;
@ -323,17 +374,15 @@ FindKeyByLong(KeyNamesInfo * info, unsigned long name)
*/
static Bool
AddKeyName(KeyNamesInfo * info,
int kc,
xkb_keycode_t kc,
char *name, unsigned merge, unsigned fileID, Bool reportCollisions)
{
int old;
unsigned long lval;
if ((kc < info->effectiveMin) || (kc > info->effectiveMax))
{
ERROR("Illegal keycode %d for name <%s>\n", kc, name);
ACTION("Must be in the range %d-%d inclusive\n",
info->effectiveMin, info->effectiveMax);
if (kc > info->arraySize && !ResizeKeyNameArrays(info, kc)) {
ERROR("Couldn't resize KeyNames arrays for keycode %d\n", kc);
ACTION("Ignoring key %d\n", kc);
return False;
}
if (kc < info->computedMin)
@ -444,6 +493,14 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
into->name = from->name;
from->name = NULL;
}
if (from->computedMax > into->arraySize &&
!ResizeKeyNameArrays(into, from->computedMax)) {
ERROR("Couldn't resize KeyNames arrays for key %d\n",
from->computedMax);
ACTION("Ignoring include file %s\n", from->name);
into->errorCount += 10;
return;
}
for (i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
@ -472,17 +529,17 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
}
if (!MergeAliases(&into->aliases, &from->aliases, merge))
into->errorCount++;
if (from->explicitMin > 0)
if (from->explicitMin != 0)
{
if ((into->explicitMin < 0)
|| (into->explicitMin > from->explicitMin))
into->effectiveMin = into->explicitMin = from->explicitMin;
into->explicitMin = from->explicitMin;
}
if (from->explicitMax > 0)
{
if ((into->explicitMax < 0)
|| (into->explicitMax < from->explicitMax))
into->effectiveMax = into->explicitMax = from->explicitMax;
into->explicitMax = from->explicitMax;
}
return;
}
@ -512,8 +569,8 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
else if (strcmp(stmt->file, "computed") == 0)
{
xkb->flags |= AutoKeyNames;
info->explicitMin = XkbMinLegalKeyCode;
info->explicitMax = XkbMaxLegalKeyCode;
info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0);
} /* parse file, store returned info in the xkb struct */
else if (ProcessIncludeFile(stmt, XkmKeyNamesIndex, &rtrn, &newMerge))
@ -582,17 +639,19 @@ HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
int code;
ExprResult result;
if (!ExprResolveInteger(stmt->value, &result, NULL, NULL))
if (!ExprResolveKeyCode(stmt->value, &result))
{
ACTION("No value keycode assigned to name <%s>\n", stmt->name);
return 0;
}
code = result.ival;
if ((code < info->effectiveMin) || (code > info->effectiveMax))
code = result.uval;
if ((info->explicitMin != 0 && code < info->explicitMin) ||
(info->explicitMax != 0 && code > info->explicitMax))
{
ERROR("Illegal keycode %d for name <%s>\n", code, stmt->name);
ACTION("Must be in the range %d-%d inclusive\n",
info->effectiveMin, info->effectiveMax);
info->explicitMin,
info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
return 0;
}
if (stmt->merge != MergeDefault)
@ -610,7 +669,7 @@ HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
/**
* Handle the minimum/maximum statement of the xkb file.
* Sets explicitMin/Max and effectiveMin/Max of the info struct.
* Sets explicitMin/Max of the info struct.
*
* @return 1 on success, 0 otherwise.
*/
@ -647,59 +706,57 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
return 0;
}
if (ExprResolveInteger(stmt->value, &tmp, NULL, NULL) == 0)
if (ExprResolveKeyCode(stmt->value, &tmp) == 0)
{
ACTION("Assignment to field %s ignored\n", field.str);
return 0;
}
if ((tmp.ival < XkbMinLegalKeyCode) || (tmp.ival > XkbMaxLegalKeyCode))
if (tmp.uval > XKB_KEYCODE_MAX)
{
ERROR
("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
tmp.ival, XkbMinLegalKeyCode, XkbMaxLegalKeyCode);
tmp.uval, 0, XKB_KEYCODE_MAX);
ACTION("Value of \"%s\" not changed\n", field.str);
return 0;
}
if (which == MIN_KEYCODE_DEF)
{
if ((info->explicitMax > 0) && (info->explicitMax < tmp.ival))
if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval))
{
ERROR
("Minimum key code (%d) must be <= maximum key code (%d)\n",
tmp.ival, info->explicitMax);
tmp.uval, info->explicitMax);
ACTION("Minimum key code value not changed\n");
return 0;
}
if ((info->computedMax > 0) && (info->computedMin < tmp.ival))
if ((info->computedMax > 0) && (info->computedMin < tmp.uval))
{
ERROR
("Minimum key code (%d) must be <= lowest defined key (%d)\n",
tmp.ival, info->computedMin);
tmp.uval, info->computedMin);
ACTION("Minimum key code value not changed\n");
return 0;
}
info->explicitMin = tmp.ival;
info->effectiveMin = tmp.ival;
info->explicitMin = tmp.uval;
}
if (which == MAX_KEYCODE_DEF)
{
if ((info->explicitMin > 0) && (info->explicitMin > tmp.ival))
if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval))
{
ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
tmp.ival, info->explicitMin);
tmp.uval, info->explicitMin);
ACTION("Maximum code value not changed\n");
return 0;
}
if ((info->computedMax > 0) && (info->computedMax > tmp.ival))
if ((info->computedMax > 0) && (info->computedMax > tmp.uval))
{
ERROR
("Maximum code (%d) must be >= highest defined key (%d)\n",
tmp.ival, info->computedMax);
tmp.uval, info->computedMax);
ACTION("Maximum code value not changed\n");
return 0;
}
info->explicitMax = tmp.ival;
info->effectiveMax = tmp.ival;
info->explicitMax = tmp.uval;
}
return 1;
}
@ -834,11 +891,11 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
if (info.errorCount == 0)
{
if (info.explicitMin > 0) /* if "minimum" statement was present */
xkb->min_key_code = info.effectiveMin;
xkb->min_key_code = info.explicitMin;
else
xkb->min_key_code = info.computedMin;
if (info.explicitMax > 0) /* if "maximum" statement was present */
xkb->max_key_code = info.effectiveMax;
xkb->max_key_code = info.explicitMax;
else
xkb->max_key_code = info.computedMax;
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)

View File

@ -247,7 +247,7 @@ typedef struct _KeyNameDesc
Bool
FindNamedKey(struct xkb_desc * xkb,
unsigned long name,
unsigned int *kc_rtrn,
xkb_keycode_t *kc_rtrn,
Bool use_aliases, Bool create, int start_from)
{
register unsigned n;
@ -285,11 +285,6 @@ FindNamedKey(struct xkb_desc * xkb,
{
if ((!xkb->names) || (!xkb->names->keys))
{
if (xkb->min_key_code < XkbMinLegalKeyCode)
{
xkb->min_key_code = XkbMinLegalKeyCode;
xkb->max_key_code = XkbMaxLegalKeyCode;
}
if (XkbcAllocNames(xkb, XkbKeyNamesMask, 0, 0) != Success)
{
if (warningLevel > 0)

View File

@ -77,7 +77,7 @@ extern Bool ProcessIncludeFile(IncludeStmt * /* stmt */ ,
extern Bool FindNamedKey(struct xkb_desc * /* xkb */ ,
unsigned long /* name */ ,
unsigned int * /* kc_rtrn */ ,
xkb_keycode_t * /* kc_rtrn */ ,
Bool /* use_aliases */ ,
Bool /* create */ ,
int /* start_from */

View File

@ -1719,7 +1719,7 @@ HandleSymbolsFile(XkbFile * file,
}
static Bool
FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, unsigned int *kc_rtrn)
FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
{
register int i, j;
register Bool gotOne;
@ -1952,7 +1952,8 @@ static Bool
CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
{
register int i;
unsigned okc, kc, width, tmp, nGroups;
xkb_keycode_t okc, kc;
unsigned width, tmp, nGroups;
struct xkb_key_type * type;
Bool haveActions, autoType, useAlias;
uint32_t *outSyms;
@ -2158,7 +2159,7 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
static Bool
CopyModMapDef(struct xkb_desc * xkb, ModMapEntry *entry)
{
unsigned kc;
xkb_keycode_t kc;
if ((!entry->haveSymbol)
&&

View File

@ -135,7 +135,7 @@
}
%type <ival> Number Integer Float SignedNumber
%type <uval> XkbCompositeType FileType MergeMode OptMergeMode
%type <uval> DoodadType Flag Flags OptFlags
%type <uval> DoodadType Flag Flags OptFlags KeyCode
%type <str> KeyName MapName OptMapName KeySym
%type <sval> FieldSpec Ident Element String
%type <any> DeclList Decl
@ -325,7 +325,7 @@ VarDecl : Lhs EQUALS Expr SEMI
{ $$= BoolVarCreate($2,0); }
;
KeyNameDecl : KeyName EQUALS Expr SEMI
KeyNameDecl : KeyName EQUALS KeyCode SEMI
{
KeycodeDef *def;
@ -707,6 +707,13 @@ Terminal : String
free($1);
$$= expr;
}
| KeyCode
{
ExprDef *expr;
expr= ExprCreate(ExprValue,TypeKeyCode);
expr->value.uval= $1;
$$= expr;
}
;
OptKeySymList : KeySymList { $$= $1; }
@ -749,6 +756,9 @@ Float : FLOAT { $$= scanInt; }
Integer : INTEGER { $$= scanInt; }
;
KeyCode : INTEGER { $$= scanULong; }
;
KeyName : KEYNAME { $$= strdup(scanBuf); }
;

View File

@ -39,6 +39,7 @@ char *scanFile = NULL;
int lineNum = 0;
int scanInt;
unsigned long scanULong;
static char *s;
char scanBuf[1024];
@ -145,6 +146,7 @@ alternate_group return ALTERNATE_GROUP;
[0-9]+ {
char *end;
scanInt = strtol(yytext, &end, 0);
scanULong = strtoul(yytext, &end, 0);
return INTEGER;
}

View File

@ -3,5 +3,4 @@ xkb_keymap {
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us" };
xkb_geometry { include "pc(pc105)" };
};