resolve TODOs regarding input.h

Wed, 02 Jul 2025 23:21:17 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 02 Jul 2025 23:21:17 +0200
changeset 174
0009b982bc7d
parent 173
bd57fe3f6360
child 175
e5544920377e

resolve TODOs regarding input.h

a) mouse position must be integer, because it can be negative (though rarely)
b) we should not trade "access complexity" for space in the scancodes array

src/ascension/input.h file | annotate | diff | comparison | revisions
src/context.c file | annotate | diff | comparison | revisions
--- a/src/ascension/input.h	Tue Jul 01 20:28:49 2025 +0200
+++ b/src/ascension/input.h	Wed Jul 02 23:21:17 2025 +0200
@@ -54,8 +54,6 @@
     /**
      * State of the keys.
      *
-     * TODO: reduce this to a reasonable size
-     *
      * @see asc_key_pressed()
      * @see asc_key_released()
      * @see asc_key_down()
@@ -82,7 +80,6 @@
 #define asc_mouse_x asc_context.input.mouse_x
 #define asc_mouse_y asc_context.input.mouse_y
 #define asc_mouse_window asc_context.input.mouse_window
-// TODO: think about whether this should be asc_vec2u
 #define asc_mouse_pos ((asc_vec2i) {asc_mouse_x, asc_mouse_y})
 
 #define asc_mouse_move_x asc_context.input.mouse_xrel
--- a/src/context.c	Tue Jul 01 20:28:49 2025 +0200
+++ b/src/context.c	Wed Jul 02 23:21:17 2025 +0200
@@ -187,7 +187,7 @@
             case SDL_KEYDOWN:
                 // we only set the down and press flags if the key is not already known to be down
                 if (asc_key_up(event.key.keysym.scancode)) {
-                    asc_set_flag(asc_context.input.keys[event.key.keysym.scancode], ASC_KEY_DOWN_FLAG|ASC_KEY_PRESS_FLAG);
+                    asc_context.input.keys[event.key.keysym.scancode] = ASC_KEY_DOWN_FLAG|ASC_KEY_PRESS_FLAG;
                 }
                 break;
             case SDL_KEYUP:

mercurial