Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move send_accumulated_updates and accumulate_update to tv.c. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | ams/sdl |
Files: | files | file ages | folders |
SHA3-256: |
8f1f5f72ee0666205795187385beb7fe |
User & Date: | ams 2024-06-25 09:39:04 |
Context
2024-06-25
| ||
09:54 | ucfg.c: Handle setting modifiers in config file. check-in: 7bf9883f4f user: ams tags: ams/sdl | |
09:39 | Move send_accumulated_updates and accumulate_update to tv.c. check-in: 8f1f5f72ee user: ams tags: ams/sdl | |
08:09 | sdl2.c: Map Top key... check-in: d9db9b2bd7 user: ams tags: ams/sdl | |
Changes
Changes to sdl2.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | #include <X11/keysym.h> // for XK_FOO meh #include <X11/X.h> // for FOOMapIndex meh SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *texture; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <X11/keysym.h> // for XK_FOO meh #include <X11/X.h> // for FOOMapIndex meh SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *texture; int sdl2_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)) |
︙ | ︙ | |||
269 270 271 272 273 274 275 276 277 278 279 280 | knight_process_key(e.keysym.sym, bi, keydown); } else { bi = sdl2_bucky(e); cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key); } } void sdl2_event(void) { SDL_Event ev; | > > > > > > > > > > | | 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 | knight_process_key(e.keysym.sym, bi, keydown); } else { bi = sdl2_bucky(e); cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key); } } void update(int u_minh, int u_minv, int hs, int vs) { SDL_UpdateTexture(texture, NULL, tv_bitmap, tv_width * sizeof(Uint32)); // Flush SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); } void sdl2_event(void) { SDL_Event ev; send_accumulated_updates(&update); kbd_dequeue_key_event(); if (is_mouse_warp) { is_mouse_warp = 0; SDL_WarpMouseInWindow(window, mouse_warp_x, mouse_warp_y); } while (SDL_PollEvent(&ev)) { switch (ev.type) { |
︙ | ︙ |
Changes to sdl2.h.
1 2 3 4 5 6 7 | #pragma once #include <SDL2/SDL.h> extern void sdl2_init(void); extern void sdl2_event(void); | < < < < | 1 2 3 4 5 6 7 8 | #pragma once #include <SDL2/SDL.h> extern void sdl2_init(void); extern void sdl2_event(void); extern void sdl2_beep(int); |
Changes to tv.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | uint32_t tv_width; uint32_t tv_height; uint32_t tv_bitmap[1024 * 1024]; static int tv_csr; static int tv_colorbit; static void tv_post_60hz_interrupt(void) { tv_csr |= 1 << 4; assert_xbus_interrupt(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | uint32_t tv_width; uint32_t tv_height; uint32_t tv_bitmap[1024 * 1024]; static int tv_csr; static int tv_colorbit; unsigned long Background; unsigned long Foreground; static int u_minh = 0x7fffffff; static int u_maxh; static int u_minv = 0x7fffffff; static int u_maxv; static void accumulate_update(int h, int v, int hs, int vs) { if (h < u_minh) u_minh = h; if (h + hs > u_maxh) u_maxh = h + hs; if (v < u_minv) u_minv = v; if (v + vs > u_maxv) u_maxv = v + vs; } void send_accumulated_updates(void (*fn)(int, int , int , int)) { int hs; int vs; hs = u_maxh - u_minh; vs = u_maxv - u_minv; if (u_minh != 0x7fffffff && u_minv != 0x7fffffff && u_maxh && u_maxv) { (*fn)(u_minh, u_minv, hs, vs); } u_minh = 0x7fffffff; u_maxh = 0; u_minv = 0x7fffffff; u_maxv = 0; } static void tv_post_60hz_interrupt(void) { tv_csr |= 1 << 4; assert_xbus_interrupt(); } |
︙ | ︙ |
Changes to tv.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #pragma once #include <stdint.h> extern int tv_monitor; extern uint32_t tv_bitmap[1024 * 1024]; extern uint32_t tv_width; extern uint32_t tv_height; extern void tv_init(void); extern void tv_poll(void); extern void tv_write(uint32_t, uint32_t); extern void tv_read(uint32_t, uint32_t *); extern void tv_xbus_read(uint32_t, uint32_t *); extern void tv_xbus_write(uint32_t, uint32_t); extern void tv_screenshot(char *); | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #pragma once #include <stdint.h> extern int tv_monitor; extern uint32_t tv_bitmap[1024 * 1024]; extern uint32_t tv_width; extern uint32_t tv_height; extern unsigned long Background; extern unsigned long Foreground; extern void tv_init(void); extern void tv_poll(void); extern void tv_write(uint32_t, uint32_t); extern void tv_read(uint32_t, uint32_t *); extern void tv_xbus_read(uint32_t, uint32_t *); extern void tv_xbus_write(uint32_t, uint32_t); extern void tv_screenshot(char *); extern void send_accumulated_updates(void (*fn)(int, int , int , int)); |
Changes to x11.c.
︙ | ︙ | |||
189 190 191 192 193 194 195 | knight_process_key(keysym, bi, keydown); } else { bi = x11_bucky(keycode); cadet_process_key(keysym, bi, keydown, &cadet_allup_key); } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | knight_process_key(keysym, bi, keydown); } else { bi = x11_bucky(keycode); cadet_process_key(keysym, bi, keydown, &cadet_allup_key); } } void x11_idle_change_handler(int mode) { static int width = 22, bottom = 2, right = 2; switch (mode) { case IDLE_IDLE: |
︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 270 271 272 273 | kc.bell_pitch = 755; /* Hz */ kc.bell_duration = 10; /* milliseconds */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &kc); XBell(display, onoff); /* display, percent */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &okc); #endif } void x11_event(void) { XEvent e; | > > > > > > > | | 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 | kc.bell_pitch = 755; /* Hz */ kc.bell_duration = 10; /* milliseconds */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &kc); XBell(display, onoff); /* display, percent */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &okc); #endif } void update(int u_minh, int u_minv, int hs, int vs) { XPutImage(display, window, gc, ximage, u_minh, u_minv, u_minh, u_minv, hs, vs); XFlush(display); } void x11_event(void) { XEvent e; send_accumulated_updates(&update); kbd_dequeue_key_event(); if (is_mouse_warp) { is_mouse_warp = 0; XWarpPointer(display, None, window, 0, 0, 0, 0, mouse_warp_x, mouse_warp_y); } while (XCheckWindowEvent(display, window, EVENT_MASK, &e)) { switch (e.type) { |
︙ | ︙ |
Changes to x11.h.
︙ | ︙ | |||
11 12 13 14 15 16 17 | extern int x11_query_keymap(char[32]); extern KeyCode x11_keysym_to_keycode(KeySym); extern XModifierKeymap *x11_get_modifier_mapping(void); extern int x11_bucky(KeyCode); extern void x11_init(void); extern void x11_event(void); | < < < < < | 11 12 13 14 15 16 17 | extern int x11_query_keymap(char[32]); extern KeyCode x11_keysym_to_keycode(KeySym); extern XModifierKeymap *x11_get_modifier_mapping(void); extern int x11_bucky(KeyCode); extern void x11_init(void); extern void x11_event(void); |