Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/xorg-server/dist/hw/sun Initialize ModMap dyn...
details: https://anonhg.NetBSD.org/xsrc/rev/40b89943ecfb
branches: trunk
changeset: 10518:40b89943ecfb
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Jul 30 14:15:49 2020 +0000
description:
Initialize ModMap dynamically using keymap data per each keyboard.
Now ScrollLock LED works properly.
diffstat:
external/mit/xorg-server/dist/hw/sun/sunKbd.c | 86 +++++++++++++++++++++--
external/mit/xorg-server/dist/hw/sun/sunKeyMap.c | 15 ----
2 files changed, 77 insertions(+), 24 deletions(-)
diffs (159 lines):
diff -r be2f86433018 -r 40b89943ecfb external/mit/xorg-server/dist/hw/sun/sunKbd.c
--- a/external/mit/xorg-server/dist/hw/sun/sunKbd.c Wed Jul 29 17:29:53 2020 +0000
+++ b/external/mit/xorg-server/dist/hw/sun/sunKbd.c Thu Jul 30 14:15:49 2020 +0000
@@ -58,10 +58,17 @@
#endif
#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
#define MAX_KEYCODE 255 /* limited by the protocol */
+#define NUM_KEYCODES (MAX_KEYCODE - MIN_KEYCODE + 1)
#ifndef KB_SUN4
#define KB_SUN4 4
#endif
+#define Meta_Mask Mod1Mask
+#define Mode_switch_Mask Mod2Mask
+#define Alt_Mask Mod3Mask
+#define Num_Lock_Mask Mod4Mask
+#define ScrollLockMask Mod5Mask
+
#define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \
if ((tv1).tv_usec < (tv2).tv_usec) { \
(tv1).tv_usec += 1000000; \
@@ -79,6 +86,7 @@
}
static void sunKbdHandlerNotify(int, int, void *);
+static void sunInitModMap(const KeySymsRec *, CARD8 *);
static void SwapLKeys(KeySymsRec *);
static void SetLights(KeybdCtrl *, int);
static KeyCode LookupKeyCode(KeySym, XkbDescPtr, KeySymsPtr);
@@ -605,13 +613,12 @@
int
sunKbdProc(DeviceIntPtr device, int what)
{
- int i;
DevicePtr pKeyboard = (DevicePtr) device;
sunKbdPrivPtr pPriv;
KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
XkbRMLVOSet rmlvo;
+ CARD8 workingModMap[MAP_LENGTH];
- static CARD8 *workingModMap = NULL;
static KeySymsRec *workingKeySyms;
switch (what) {
@@ -633,14 +640,8 @@
}
if (workingKeySyms->maxKeyCode > MAX_KEYCODE)
workingKeySyms->maxKeyCode = MAX_KEYCODE;
- }
- if (!workingModMap) {
- workingModMap = malloc(MAP_LENGTH);
- (void) memset(workingModMap, 0, MAP_LENGTH);
- for(i=0; sunModMaps[sunKbdPriv.type][i].key != 0; i++)
- workingModMap[sunModMaps[sunKbdPriv.type][i].key + MIN_KEYCODE] =
- sunModMaps[sunKbdPriv.type][i].modifiers;
+ sunInitModMap(workingKeySyms, workingModMap);
}
pKeyboard->devicePrivate = (void *)&sunKbdPriv;
@@ -696,6 +697,73 @@
return Success;
}
+/*-------------------------------------------------------------------------
+ * sunInitModMap --
+ * Initialize ModMap per specified KeyMap table.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------*/
+static void
+sunInitModMap(
+ const KeySymsRec *KeySyms, /* KeyMap data to set ModMap */
+ CARD8 *ModMap /* ModMap to be initialized */
+)
+{
+ KeySym *k;
+ int i, min, max, width;
+
+ for (i = 0; i < MAP_LENGTH; i++)
+ ModMap[i] = NoSymbol;
+
+ min = KeySyms->minKeyCode;
+ max = KeySyms->maxKeyCode;
+ width = KeySyms->mapWidth;
+ for (i = min, k = KeySyms->map; i < max; i++, k += width) {
+ switch (*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ ModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ ModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ ModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ ModMap[i] = Alt_Mask;
+ break;
+
+ case XK_Num_Lock:
+ ModMap[i] = Num_Lock_Mask;
+ break;
+
+ case XK_Scroll_Lock:
+ ModMap[i] = ScrollLockMask;
+ break;
+
+ case XK_Meta_L:
+ case XK_Meta_R:
+ ModMap[i] = Meta_Mask;
+ break;
+
+ case SunXK_AltGraph:
+ ModMap[i] = Mode_switch_Mask;
+ break;
+ }
+ }
+}
+
/*-
*-----------------------------------------------------------------------
* sunKbdGetEvents --
diff -r be2f86433018 -r 40b89943ecfb external/mit/xorg-server/dist/hw/sun/sunKeyMap.c
--- a/external/mit/xorg-server/dist/hw/sun/sunKeyMap.c Wed Jul 29 17:29:53 2020 +0000
+++ b/external/mit/xorg-server/dist/hw/sun/sunKeyMap.c Thu Jul 30 14:15:49 2020 +0000
@@ -111,21 +111,6 @@
#define XK_R15 NoSymbol
#endif
-/* twm and Motif have hard-coded dependencies on Meta being Mod1 :-( */
-#if 0
-/* This set has optimal characteristics for use in the Toolkit... */
-#define Meta_Mask Mod1Mask
-#define Mode_switch_Mask Mod2Mask
-#define Num_Lock_Mask Mod3Mask
-#define Alt_Mask Mod4Mask
-#else
-/* but this set is compatible with what we shipped in R6. */
-#define Meta_Mask Mod1Mask
-#define Mode_switch_Mask Mod2Mask
-#define Alt_Mask Mod3Mask
-#define Num_Lock_Mask Mod4Mask
-#endif
-
#ifdef US2
static KeySym US2Keymap[] = {
Home |
Main Index |
Thread Index |
Old Index