Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Implement first stap at working keyboard input. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | ams/sdl1 |
Files: | files | file ages | folders |
SHA3-256: |
db7f9eef58de915f28e7f989106130e0 |
User & Date: | ams 2024-05-31 08:33:05 |
Context
2024-06-01
| ||
05:02 | sdl1.c: Remove unused stuff. check-in: e4e225b7e8 user: ams tags: ams/sdl1 | |
2024-05-31
| ||
08:33 | Implement first stap at working keyboard input. check-in: db7f9eef58 user: ams tags: ams/sdl1 | |
07:40 | Merge changes from ams/cleanup. check-in: e3ef95ff7c user: ams tags: ams/sdl1 | |
Changes
Changes to cadet.c.
︙ | ︙ | |||
228 229 230 231 232 233 234 | int wantshift; /* Index into second column in cadet_kbd_map. */ int shkey; /* Shift key being pressed. */ int oshift; if (!keydown && cadet_allup_key() == true) return; oshift = cadet_shifts; | | | | | | | 228 229 230 231 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 262 263 264 265 | int wantshift; /* Index into second column in cadet_kbd_map. */ int shkey; /* Shift key being pressed. */ int oshift; if (!keydown && cadet_allup_key() == true) return; oshift = cadet_shifts; printf("kbd (cadet): keysym = 0%o, bi = %d\n", keysym, bi); if (bi != -1) { int bucky; bucky = modifier_map[bi]; if (bucky == KBD_NoSymbol) { printf("kbd (cadet): unbound modifier (keysym = 0%o)\n", keysym); return; } scc = cadet_modifier_map[bucky]; cadet_process_shift(scc, keydown); printf("kbd (cadet): bucky pressed; scc = 0%o, shifts = 0%o (previous: 0%o)\n", scc, cadet_shifts, oshift); kbd_event(scc, keydown); return; } lmchar = kbd_map[keysym]; printf("kbd (cadet): kbd_map[%d] (lmchar) = 0%o\n", keysym, kbd_map[keysym]); if (lmchar > LMCH_CODE_LIMIT || lmchar == LMCH_NoSymbol) { NOTICE(TRACE_USIM, "kbd (cadet): unable to translate to lispm key (keysym = 0%o)\n", keysym); return; } scc = cadet_kbd_map[lmchar][0]; wantshift = cadet_kbd_map[lmchar][1]; printf("kbd (cadet): non bucky pressed; scc = 0%o, wantshift = %d\n", scc, wantshift); /* * If modifiers correct, just post the event, else * queue the event and post the appropriate shifts. */ if (((wantshift == CADET_IX_UNSHIFT) && ((cadet_shifts & (1 << CADET_IX_SHIFT)) == 0)) || (cadet_shifts & (1 << wantshift))) { kbd_event(scc, keydown); return; |
︙ | ︙ |
Changes to sdl1.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* sdl1.c --- SDL1 routines used by the TV and KBD interfaces */ #include <SDL.h> #include "tv.h" #include "kbd.h" #include "mouse.h" #include "utrace.h" #include "idle.h" SDL_Surface *screen; struct DisplayState { unsigned char *data; int linesize; int depth; int width; int height; }; static struct DisplayState display_state; static struct DisplayState *ds = &display_state; /* * This is shared between x11.c, and sdl1.c ... the only difference is * the hook in send_accumulated_updates. */ unsigned long Background; | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* sdl1.c --- SDL1 routines used by the TV and KBD interfaces */ #include <signal.h> #include <SDL.h> #include "tv.h" #include "kbd.h" #include "mouse.h" #include "utrace.h" #include "idle.h" SDL_Surface *screen; struct DisplayState { unsigned char *data; int linesize; int depth; int width; int height; }; static struct DisplayState display_state; static struct DisplayState *ds = &display_state; /* * Translation map for the host keyboard to a corresponding Lisp * Machine character or modifier. */ int sdl1_kbd_map[65535]; int sdl1_modifier_map[8]; /* * This is shared between x11.c, and sdl1.c ... the only difference is * the hook in send_accumulated_updates. */ unsigned long Background; |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 | static void sdl1_cleanup(void) { SDL_Quit(); } static void process_key(SDL_KeyboardEvent *e, int keydown) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | > | | | > | | > | > > | | < | < > | > > | | | > > > | > | > > > > > > > | | < < | | < | | | 75 76 77 78 79 80 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 156 157 158 159 160 | static void sdl1_cleanup(void) { SDL_Quit(); } /* * Returns the X11 modifier index of KEYCODE, or -1 if not found. */ int sdl1_bucky(SDLKey keycode) { // XModifierKeymap *modmap; // // modmap = XGetModifierMapping(display); // for (int modifier = 0; modifier < 8; modifier++) { // for (int i = 0; i < modmap->max_keypermod; i++) { // if (keycode == modmap->modifiermap[modifier * modmap->max_keypermod + i]) { // XFreeModifiermap(modmap); // return modifier; // } // } // } // XFreeModifiermap(modmap); return -1; } /* * 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) { // KeySym keysym; // SDLKey keycode; int bi; unsigned char buf[5]; idle_keyboard_activity(); // keycode = SDL_KeysymToKeycode(e->keysym.sym); //if (event->key.code == key) ... // XLookupString(&e->xkey, (char *)buf, sizeof(buf), &keysym, &status); // keycode = x11_keysym_to_keycode(keysym); // if (keycode == NoSymbol || keysym > NELEM(x11_kbd_map)) { // NOTICE(TRACE_USIM, "kbd (cadet): unable to translate to sdl1 keycode (keysym = 0%o)\n", keysym); // return; // } if (kbd_type == 0) { if (!keydown) return; bi = 0; // if (e->xkey.state & ShiftMask) // knight_process_bucky(x11_modifier_map[ShiftMapIndex], &bi); // if (e->xkey.state & LockMask) // knight_process_bucky(x11_modifier_map[LockMapIndex], &bi); // if (e->xkey.state & ControlMask) // knight_process_bucky(x11_modifier_map[ControlMapIndex], &bi); // if (e->xkey.state & Mod1Mask) // knight_process_bucky(x11_modifier_map[Mod1MapIndex], &bi); // if (e->xkey.state & Mod2Mask) // knight_process_bucky(x11_modifier_map[Mod2MapIndex], &bi); // if (e->xkey.state & Mod3Mask) // knight_process_bucky(x11_modifier_map[Mod3MapIndex], &bi); // if (e->xkey.state & Mod4Mask) // knight_process_bucky(x11_modifier_map[Mod4MapIndex], &bi); // if (e->xkey.state & Mod5Mask) // knight_process_bucky(x11_modifier_map[Mod5MapIndex], &bi); knight_process_key(e->keysym.sym, bi, keydown, sdl1_kbd_map, sdl1_modifier_map); } else { bi = sdl1_bucky(e->keysym.sym); cadet_process_key(e->keysym.sym, bi, keydown, sdl1_kbd_map, sdl1_modifier_map); } } void sdl1_event(void) { SDL_Event ev1, *ev = &ev1; send_accumulated_updates(); |
︙ | ︙ | |||
142 143 144 145 146 147 148 149 150 151 152 153 154 155 | } case SDL_QUIT: exit(0); break; } } } void sdl1_init(void) { NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n"); Foreground = 0xff; // White | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 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 262 263 264 | } case SDL_QUIT: exit(0); break; } } } void sdl1_default_kbd_map(void) { for (int i = 0; i < (int) NELEM(sdl1_kbd_map); i++) sdl1_kbd_map[i] = LMCH_NoSymbol; for (int i = 0; i < (int) NELEM(sdl1_modifier_map); i++) sdl1_modifier_map[i] = KBD_NoSymbol; /* *INDENT-OFF* */ /* * Initialize keyboard modifiers */ //SDL Modifier Meaning //KMOD_NONE No modifiers applicable //KMOD_NUM Numlock is down //KMOD_CAPS Capslock is down //KMOD_LCTRL Left Control is down //KMOD_RCTRL Right Control is down //KMOD_RSHIFT Right Shift is down //KMOD_LSHIFT Left Shift is down //KMOD_RALT Right Alt is down //KMOD_LALT Left Alt is down //KMOD_CTRL A Control key is down //KMOD_SHIFT A Shift key is down //KMOD_ALT An Alt key is down // x11_modifier_map[ShiftMapIndex] = KBD_SHIFT; // x11_modifier_map[LockMapIndex] = KBD_SHIFT_LOCK; // x11_modifier_map[ControlMapIndex] = KBD_CONTROL; // x11_modifier_map[Mod1MapIndex] = KBD_META; // x11_modifier_map[Mod2MapIndex] = KBD_NoSymbol; // x11_modifier_map[Mod3MapIndex] = KBD_NoSymbol; // x11_modifier_map[Mod4MapIndex] = KBD_TOP; // x11_modifier_map[Mod5MapIndex] = KBD_NoSymbol; /* * Initialize keyboard mapping. * * We cann't reuse lmch.defs here because the Lisp Machine * charachter set has names and charachters that do not have a * corresponding mapping in X11. */ /* Unshifted */ sdl1_kbd_map[SDLK_BACKQUOTE] = LMCH_grave; sdl1_kbd_map[SDLK_1] = LMCH_1; sdl1_kbd_map[SDLK_2] = LMCH_2; sdl1_kbd_map[SDLK_3] = LMCH_3; sdl1_kbd_map[SDLK_4] = LMCH_4; sdl1_kbd_map[SDLK_5] = LMCH_5; sdl1_kbd_map[SDLK_6] = LMCH_6; sdl1_kbd_map[SDLK_7] = LMCH_7; sdl1_kbd_map[SDLK_8] = LMCH_8; sdl1_kbd_map[SDLK_9] = LMCH_9; sdl1_kbd_map[SDLK_0] = LMCH_0; sdl1_kbd_map[SDLK_MINUS] = LMCH_minus; sdl1_kbd_map[SDLK_EQUALS] = LMCH_equal; /* *INDENT-ON* */ } void sdl1_init(void) { NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n"); Foreground = 0xff; // White |
︙ | ︙ |
Changes to ucfg.c.
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #ifdef WITH_X11 /* * Initialize default X11 keybaord translation map. */ x11_default_kbd_map(); x11_grab_keyboard = true; #elif WITH_SDL1 #endif /* * Initialize default idle values. */ idle_cycles = 0x0ffff * 10; idle_quantum = 0x0ffff; idle_timeout = 1000; | > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #ifdef WITH_X11 /* * Initialize default X11 keybaord translation map. */ x11_default_kbd_map(); x11_grab_keyboard = true; #elif WITH_SDL1 sdl1_default_kbd_map(); #endif /* * Initialize default idle values. */ idle_cycles = 0x0ffff * 10; idle_quantum = 0x0ffff; idle_timeout = 1000; |
︙ | ︙ |