📄 hpkeymap.c
字号:
return &DefaultKeySyms[kbd_family(key_id)];} /* This routine is called if the load-keytable-from-file routine fails * and you need a default KeySymRec. I need this for HP-UX 'cause the * extended and PS2 keyboards have different min keycodes and I want to * use the US Ascii keymap as the default. */KeySymsRec *hpDefaultKeySyms(key_id){ return hpKeySyms(key_id);}/* ******************************************************************** *//* ************************* Modifier Tables ************************** *//* ******************************************************************** */#define cT (ControlMask)#define sH (ShiftMask)#define lK (LockMask)#define mT (Mod1Mask) /* A modmap with no modifiers. To be used with null_keymap */static CARD8 null_modmap[MAP_LENGTH]; /* Shift table values up by 8. This offset is necessary to reserve * codes for mouse buttons. Note last 8 entries of table are * commented out to preserve length of table. * Note: '#define MIN_KEYCODE 8' is above */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000) /* This table is for the HP hil extended keyboards. * For the PS2 keyboards, the only difference is keycode 0. I used to * use the same table for both keyboard types (since keycode 0 can't * be generated by the extended keyboard) but that caused problems * with xmodmap. */static CARD8 hil_modmap[MAP_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, mT, mT, sH, sH, cT, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, mT, lK,/* 20-2f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 30-3f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50-5f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0,/*0, 0, 0, 0, 0, 0, 0, 0, /* f0-ff */}; /* Same table as the hil_modmap but for PS2 keyboards. Only * difference is keycode 0 is a control key. */static CARD8 PS2_modmap[MAP_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0, cT, 0, mT, mT, sH, sH, cT, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, mT, lK,/* 20-2f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 30-3f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50-5f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0,/*0, 0, 0, 0, 0, 0, 0, 0, /* f0-ff */};#endif#ifdef __apollo /* This table is for the Apollo NA and MN keyboards. */static CARD8 apollo_modmap[MAP_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20-2f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, mT, 0, 0, 0, 0, 0, 0, /* 30-3f */ 0, 0, 0, cT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, sH, 0, /* 50-5f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, sH, 0, 0, 0, 0, 0, /* 60-6f */ 0, 0, 0, 0, 0, mT, 0, mT, 0, 0, 0, 0, 0, 0, lK, 0, /* 70-7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0,/*0, 0, 0, 0, 0, 0, 0, 0, /* f0-ff */};#endif /* This routine returns the modifier map to be used with the keymap that * has keyboard/(X id) kbd_id. * Note: This is easy because each OS we support now only has one or * two mod maps for all keyboards it supports. */CARD8 *hpModMap(kbd_id){#if defined(__hpux) || defined(__hp_osf) || defined(hp9000) switch (kbd_family(kbd_id)) { case 0: return hil_modmap; /* Extended keyboard */ case 1: return PS2_modmap; /* PS2 keyboard */ case 2: return null_modmap; /* button box */ }#endif#ifdef __apollo return apollo_modmap;#endif}/* ******************************************************************** *//* ********************************* ********************************* *//* ******************************************************************** */ /* Routines in getkeysym.c */extern HPKKeyDeviceInfo *HPKlookup_kd_by_id(), *HPKlookup_kd_by_name();extern HPKModMap *HPKlookup_modmap(); /* Empty space that can be filled in when I read keyboard info from a * file. I don't think I can just overwrite (eg) the null_maps * because if they change keyboards, recycle and the I can't find a * map, the default won't work anymore. */static KeySym tmp_keymap[8 * 256]; /* biggest keymap */static CARD8 tmp_modmap[MAP_LENGTH];static void maparoo(kptr, keysyms_rec, complain, modmap, default_modmap) KeySymsRec *keysyms_rec; HPKKeyDeviceInfo *kptr; CARD8 **modmap, *default_modmap;{ CARD8 *the_modmap; HPKModMap *mptr; keysyms_rec->map = tmp_keymap; keysyms_rec->minKeyCode = kptr->min_keycode; keysyms_rec->maxKeyCode = kptr->max_keycode; keysyms_rec->mapWidth = kptr->columns; if (mptr = HPKlookup_modmap(kptr->modmap_name)) { memcpy(tmp_modmap, mptr->modmap, MAP_LENGTH); the_modmap = tmp_modmap; } else { if (complain) ErrorF("Could not find modmap \"%s\"- using default (NULL map).\n", kptr->modmap_name); the_modmap = default_modmap; } *modmap = the_modmap;} /* * Input: * keydevice_id: The keydevice ID. On HP-UX, this is the output of * hil_to_kbd_id(). * keysyms_rec: Pointer to a KeySymsRec to fill in. * modmap: Pointer to a pointer to a modmap. * Output: * keysyms_rec: FIlled in. * modmap: points to a modmap to use with the keysyms_rec. * Returns: * TRUE : everything went as expected * FALSE: Something went screwie, using default maps. * Notes: * Don't complain if can't load maps for the button box. */int HPKget_maps_by_id(keydevice_id, keysyms_rec, modmap) KeySymsRec *keysyms_rec; CARD8 **modmap;{ CARD8 *the_modmap; HPKKeyDeviceInfo *kptr; HPKModMap *mptr; *keysyms_rec = *hpDefaultKeySyms(keydevice_id); *modmap = hpModMap(keydevice_id); if (keydevice_id == KB_NULL) return TRUE; if (!HPKsetup()) { opps: if (keydevice_id != KB_BUTTON_BOX) ErrorF("Unable to load keytable - using defaults.\n"); } else { if (!HPKread_keymap(keydevice_id, tmp_keymap)) goto opps; if (kptr = HPKlookup_kd_by_id(keydevice_id)) maparoo(kptr, keysyms_rec, False, modmap, hpModMap(keydevice_id)); } HPKclean_up(); return TRUE;} /* * Input: * keydevice_name: * keysyms_rec: Pointer to a KeySymsRec to fill in. * modmap: Pointer to a pointer to a modmap. * Output: * keysyms_rec: FIlled in. * modmap: points to a modmap to use with the keysyms_rec. * Returns: * TRUE : everything went as expected * FALSE: Something went screwie, using null maps. */int HPKget_kb_info_by_name(keydevice_name, keysyms_rec, modmap) char *keydevice_name; KeySymsRec *keysyms_rec; CARD8 **modmap;{ int all_OK = TRUE; if (!HPKsetup()) { opps: ErrorF("Unable to load keytable \"%s\" - using defaults (NULL maps).\n", keydevice_name); *keysyms_rec = *hpDefaultKeySyms(KB_NULL); *modmap = hpModMap(KB_NULL); all_OK = FALSE; } else { HPKKeyDeviceInfo *kptr; if (!(kptr = HPKlookup_kd_by_name(keydevice_name)) || !HPKread_keymap(kptr->keydevice_id, tmp_keymap)) goto opps; maparoo(kptr, keysyms_rec, True, modmap, null_keymap); } HPKclean_up(); return all_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -