Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor cleanups. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | ams/sdl |
Files: | files | file ages | folders |
SHA3-256: |
c56a574a07261a7058fc9fb747ff3f82 |
User & Date: | ams 2024-06-19 07:03:30 |
Context
2024-06-19
| ||
07:15 | Indent files. check-in: cb74f9ba59 user: ams tags: ams/sdl | |
07:03 | Minor cleanups. check-in: c56a574a07 user: ams tags: ams/sdl | |
06:45 | Move allup key handling to respective backend. check-in: 032a512225 user: ams tags: ams/sdl | |
Changes
Changes to cadet.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | #include "ucode.h" #include "utrace.h" #include "iob.h" #include "kbd.h" #include "misc.h" #include "ucode.h" #include "utrace.h" | < < < < < < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include "ucode.h" #include "utrace.h" #include "iob.h" #include "kbd.h" #include "misc.h" #include "ucode.h" #include "utrace.h" /* * Second index in CADET_KBD_MAP, gives which shift must be generated. */ #define CADET_IX_UNSHIFT 0 #define CADET_IX_SHIFT 1 #define CADET_IX_TOP 2 |
︙ | ︙ | |||
54 55 56 57 58 59 60 | #define CADET_RIGHT_META 0165 #define CADET_RIGHT_SUPER 065 #define CADET_RIGHT_HYPER 0175 #define CADET_CAPSLOCK 0125 #define CADET_ALTLOCK 015 #define CADET_MODELOCK 03 | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #define CADET_RIGHT_META 0165 #define CADET_RIGHT_SUPER 065 #define CADET_RIGHT_HYPER 0175 #define CADET_CAPSLOCK 0125 #define CADET_ALTLOCK 015 #define CADET_MODELOCK 03 static unsigned short cadet_kbd_map[256][2]; static unsigned short cadet_modifier_map[11]; int cadet_shifts = CADET_IX_UNSHIFT; void cadet_allup_event(int mods) { int v; |
︙ | ︙ | |||
77 78 79 80 81 82 83 | if (iob_csr & (1 << 2)) { iob_csr |= 1 << 5; assert_unibus_interrupt(0260); } } } | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | if (iob_csr & (1 << 2)) { iob_csr |= 1 << 5; assert_unibus_interrupt(0260); } } } static void cadet_queue_all_keys_up(void) { cadet_shifts = CADET_IX_UNSHIFT; /* Hmm... */ kbd_queue_key_event((1 << 15) | 0); } void |
︙ | ︙ | |||
125 126 127 128 129 130 131 | *mods |= CADET_ALLUP_HYPER; break; case KBD_SUPER: *mods |= CADET_ALLUP_SUPER; break; default: WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", bucky); | < < < < | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | *mods |= CADET_ALLUP_HYPER; break; case KBD_SUPER: *mods |= CADET_ALLUP_SUPER; break; default: WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", bucky); break; } } static void cadet_process_shift(int scc, int keydown) { |
︙ | ︙ | |||
158 159 160 161 162 163 164 | } } void cadet_process_key( int keysym, /* keysym, acts as index into kbd_map */ int bi, /* bucky, acts as index into modifier_map */ | | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | } } void cadet_process_key( int keysym, /* keysym, acts as index into kbd_map */ int bi, /* bucky, acts as index into modifier_map */ int keydown, /* if key is down or up */ bool (*allup_key)(void) ) { int lmchar; /* Lisp Machine charachter to insert */ int scc; /* Space Cadet scancode. */ int wantshift; /* Index into second column in cadet_kbd_map. */ int shkey; /* Shift key being pressed. */ int oshift; |
︙ | ︙ | |||
243 244 245 246 247 248 249 250 251 252 253 254 255 256 | cadet_shifts = oshift; } void cadet_init(void) { NOTICE(TRACE_USIM, "kbd: using new (space cadet) keyboard\n"); cadet_modifier_map[KBD_SHIFT] = CADET_LEFT_SHIFT; cadet_modifier_map[KBD_TOP] = CADET_LEFT_TOP; cadet_modifier_map[KBD_CONTROL] = CADET_LEFT_CONTROL; cadet_modifier_map[KBD_META] = CADET_LEFT_META; cadet_modifier_map[KBD_SUPER] = CADET_LEFT_SUPER; cadet_modifier_map[KBD_HYPER] = CADET_LEFT_HYPER; cadet_modifier_map[KBD_SHIFT_LOCK] = CADET_CAPSLOCK; | > > > > < | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | cadet_shifts = oshift; } void cadet_init(void) { NOTICE(TRACE_USIM, "kbd: using new (space cadet) keyboard\n"); /* * Setup mapping from Space Cadet scan-codes to Lisp Machine * characters. */ cadet_modifier_map[KBD_SHIFT] = CADET_LEFT_SHIFT; cadet_modifier_map[KBD_TOP] = CADET_LEFT_TOP; cadet_modifier_map[KBD_CONTROL] = CADET_LEFT_CONTROL; cadet_modifier_map[KBD_META] = CADET_LEFT_META; cadet_modifier_map[KBD_SUPER] = CADET_LEFT_SUPER; cadet_modifier_map[KBD_HYPER] = CADET_LEFT_HYPER; cadet_modifier_map[KBD_SHIFT_LOCK] = CADET_CAPSLOCK; #define X(lmch, scc, wantshift) \ cadet_kbd_map[LMCH_##lmch][0] = scc; cadet_kbd_map[LMCH_##lmch][1] = wantshift; #include "cadet.defs" /* Hacks... */ #if 0 X(LMCH_bracketleft, 0166, CADET_IX_UNSHIFT); X(LMCH_bracketright, 0146, CADET_IX_UNSHIFT); X(LMCH_braceleft, 0132, CADET_IX_SHIFT); X(LMCH_braceright, 0137, CADET_IX_SHIFT); #endif #undef X } |
Changes to cadet.h.
1 2 | #pragma once | < < < < < < > | < | | 1 2 3 4 5 6 7 8 | #pragma once int cadet_shifts; extern void cadet_init(void); extern void cadet_allup_event(int); extern void cadet_process_key(int, int, int, bool (*)(void)); extern void cadet_press_bucky(int, int *, int *); |
Changes to knight.c.
︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 | kbd_event(kc, keydown); } void knight_init(void) { NOTICE(TRACE_USIM, "kbd (knight): initializing keyboard\n"); knight_modifier_map[KBD_SHIFT] = KNIGHT_SHIFT; knight_modifier_map[KBD_TOP] = KNIGHT_TOP; knight_modifier_map[KBD_CONTROL] = KNIGHT_CONTROL; knight_modifier_map[KBD_META] = KNIGHT_META; knight_modifier_map[KBD_SHIFT_LOCK] = KNIGHT_SHIFT_LOCK; | > > > > < < < < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | kbd_event(kc, keydown); } void knight_init(void) { NOTICE(TRACE_USIM, "kbd (knight): initializing keyboard\n"); /* * Setup mapping from Knight scan-codes to Lisp Machine * characters. */ knight_modifier_map[KBD_SHIFT] = KNIGHT_SHIFT; knight_modifier_map[KBD_TOP] = KNIGHT_TOP; knight_modifier_map[KBD_CONTROL] = KNIGHT_CONTROL; knight_modifier_map[KBD_META] = KNIGHT_META; knight_modifier_map[KBD_SHIFT_LOCK] = KNIGHT_SHIFT_LOCK; #define X(n, ign0) knight_kbd_map[LMCH_##n] = KNIGHT_##n; #include "knight.defs" #undef X } |
Changes to knight.h.
1 2 | #pragma once | < < < < < < | | 1 2 3 4 5 | #pragma once extern void knight_init(void); extern void knight_process_key(int, int, int); extern void knight_process_bucky(int, int *); |
Changes to mouse.c.
︙ | ︙ | |||
53 54 55 56 57 58 59 | } void mouse_poll(void) { static int prevstate; int state; | < < | < < < < | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | } void mouse_poll(void) { static int prevstate; int state; enum { Sdisabled, Sopen, Soff, Son }; state = DTP_FIX_VAL(amem[a_mouse_cursor_state]); if (state != prevstate && state == Son) { is_mouse_warp = 1; mouse_warp_x = DTP_FIX_VAL(amem[a_mouse_x]); mouse_warp_y = DTP_FIX_VAL(amem[a_mouse_y]); } |
︙ | ︙ |
Changes to notes.text.
︙ | ︙ | |||
61 62 63 64 65 66 67 | knight.c// Knight interface knight.defs knight.h FOO_init FOO_process_key // backend specific | | | | > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | knight.c// Knight interface knight.defs knight.h FOO_init FOO_process_key // backend specific FOO_beep ? xbeep ? mouse.c mouse.h uch11.c uch11.h hosts.text // tv and kbd sdl1.c sdl1.h sdl2.c sdl2.h x11.c x11.h misc.c misc.h |
︙ | ︙ |
Changes to sdl1.c.
︙ | ︙ | |||
64 65 66 67 68 69 70 | { SDL_Quit(); } /* * Returns the X11 modifier index of KEYCODE, or -1 if not found. */ | | > | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | { SDL_Quit(); } /* * Returns the X11 modifier index of KEYCODE, or -1 if not found. */ static int sdl1_bucky(SDL_KeyboardEvent e) { int mod = SDL_GetModState(); if (mod & KMOD_CTRL && (e.keysym.sym == SDLK_LCTRL || e.keysym.sym == SDLK_RCTRL)) return ControlMapIndex; if (mod & KMOD_SHIFT && (e.keysym.sym == SDLK_LSHIFT || e.keysym.sym == SDLK_RSHIFT)) return ShiftMapIndex; if (mod & KMOD_ALT && (e.keysym.sym == SDLK_LALT || e.keysym.sym == SDLK_RALT)) return Mod1MapIndex; // if (mod & KMOD_NUM) return Mod2MapIndex; // if (mod & KMOD_MODE) return Mod3MapIndex; // if (mod & KMOD_GUI && (e.keysym.sym == SDLK_LGUI || e.keysym.sym == SDLK_RGUI)) return Mod4MapIndex; // if (mod & KMOD_SCROLL) return Mod5MapIndex; return -1; } static int sdl1_keysym_to_xk(SDL_KeyboardEvent e) { switch (e.keysym.sym) { case SDLK_ESCAPE: return XK_Escape; case SDLK_F1: return XK_F1; case SDLK_F2: return XK_F2; case SDLK_F3: return XK_F3; |
︙ | ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | // case SDLK_RSUPER: return XK_Super_R; // case SDLK_LHYPER: return XK_Hyper_L; // case SDLK_RHYPER: return XK_Hyper_R; default: return XK_VoidSymbol; } } /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(SDL_KeyboardEvent e, int keydown) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | // case SDLK_RSUPER: return XK_Super_R; // case SDLK_LHYPER: return XK_Hyper_L; // case SDLK_RHYPER: return XK_Hyper_R; default: return XK_VoidSymbol; } } bool cadet_allup_key(void) { bool allup; int mods; int shifts; int statesize; Uint8 *state; allup = true; mods = 0; shifts = 0; state = SDL_GetKeyState(&statesize); for (int i = 0; allup && i < statesize; i++) { int bucky; if (state[i] != 1) continue; bucky = modifier_map[i]; DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i); cadet_press_bucky(bucky, &mods, &shifts); } if (allup == true) { DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts); cadet_shifts = shifts; cadet_allup_event(mods); } return allup; } /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(SDL_KeyboardEvent e, int keydown) |
︙ | ︙ | |||
252 253 254 255 256 257 258 | } void sdl1_beep(int v) { } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | } void sdl1_beep(int v) { } void sdl1_init(void) { NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n"); Foreground = 0xff; // White Background = 0x00; // Black |
︙ | ︙ |
Changes to x11.c.
︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | } } } XFreeModifiermap(modmap); return -1; } /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(XEvent *e, int keydown) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | } } } XFreeModifiermap(modmap); return -1; } /* * Check if all keys are up - too expensive? */ bool cadet_allup_key(void) { bool allup; int mods; int shifts; XModifierKeymap *modmap; char keymap[32]; allup = true; mods = 0; shifts = 0; modmap = x11_get_modifier_mapping(); x11_query_keymap(keymap); /* * For each modifier (and in turn, each keycode associated * with that modifier), check and see if it is down. If that * is the case, clear the set key from KEYMAP. * * Also keep track if we should do an all-up event, and track * the modifiers for later. */ for (int modifier = 0; modifier < 8; modifier++) { int bucky; bucky = modifier_map[modifier]; for (int i = 0; i < modmap->max_keypermod; i++) { KeyCode keycode; keycode = modmap->modifiermap[modifier * modmap->max_keypermod + i]; if (keymap[keycode / 8] & (1 << keycode % 8)) { keymap[keycode / 8] &= ~(1 << keycode % 8); /* Clear the key in KEYMAP. */ DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d); keycode = %d\n", bucky, keycode); cadet_press_bucky(bucky, &mods, &shifts); } } } XFreeModifiermap(modmap); /* * Check if any other key than modifiers (that got cleared * above) are set. If that is the case, do not generate an * all-up event. */ for (int i = 0; i < 32; i++) { if (keymap[i] != 0) { DEBUG(TRACE_KBD, "cadet_allup_key() - found a key that is up which is not a shift; keymap[%d] = 0%o\n", i, keymap[i]); allup = false; break; } } if (allup == true) { DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts); cadet_shifts = shifts; /* Keep track of shifts. */ cadet_allup_event(mods); /* Generate all-up event. */ } return allup; } /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(XEvent *e, int keydown) { |
︙ | ︙ | |||
180 181 182 183 184 185 186 | case IDLE_WORKING: XSetForeground(display, idle_gc, Background); break; } XDrawLine(display, window, idle_gc, tv_width - width - right, tv_height - bottom, tv_width - right, tv_height - bottom); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | case IDLE_WORKING: XSetForeground(display, idle_gc, Background); break; } XDrawLine(display, window, idle_gc, tv_width - width - right, tv_height - bottom, tv_width - right, tv_height - bottom); } void x11_beep(void) { XKeyboardControl kc; XKeyboardControl okc; static int onoff = 100; |
︙ | ︙ |