commit e2a7c00e1ab3c69adbe59276363ec56f7d543bd1
parent b0711e5ef42687c75611f06fba03889f6a70a908
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Sun, 30 Jun 2019 18:35:19 -0700
Move input stuff to separate files
Diffstat:
5 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -5,21 +5,7 @@
 #include "collision.c"
 #include "render.c"
 #include "world.c"
-
-internal bool btn_is_down(u32 button_states, enum GameButton b)
-{
-    assert(b < NUM_GAME_BUTTONS);
-    bool result = button_states & (1 << b);
-    return result;
-}
-
-internal bool btn_was_just_pressed(struct GameInput *game_input, enum GameButton b)
-{
-    assert(game_input);
-    assert(b < NUM_GAME_BUTTONS);
-    bool result = game_input->button_downs & (1 << b);
-    return result;
-}
+#include "input.c"
 
 internal void move_mode_print(enum MoveMode s)
 {
diff --git a/src/game.h b/src/game.h
@@ -23,6 +23,7 @@
 #include "memory.h"
 #include "render.h"
 #include "world.h"
+#include "input.h"
 #include "platform.h"
 
 static_assert(-1 == ~0, "Implementation doesn't use two's complement");
diff --git a/src/input.c b/src/input.c
@@ -0,0 +1,14 @@
+internal inline bool btn_is_down(u32 button_states, enum GameButton b)
+{
+    assert(b < NUM_GAME_BUTTONS);
+    bool result = button_states & (1 << b);
+    return result;
+}
+
+internal bool btn_was_just_pressed(struct GameInput *game_input, enum GameButton b)
+{
+    assert(game_input);
+    assert(b < NUM_GAME_BUTTONS);
+    bool result = game_input->button_downs & (1 << b);
+    return result;
+}
diff --git a/src/input.h b/src/input.h
@@ -0,0 +1,24 @@
+enum GameButton
+{
+    BTN_LEFT,
+    BTN_RIGHT,
+    BTN_UP,
+    BTN_DOWN,
+    BTN_JUMP,
+    BTN_DEBUG_FLOAT,
+
+    NUM_GAME_BUTTONS,
+    NULL_GAME_BUTTON,
+};
+
+// TODO: define static assert without string arg
+static_assert(NUM_GAME_BUTTONS <= 32, "");
+
+struct GameInput
+{
+    f32 dt;
+    u32 button_states;
+    u32 prev_button_states;
+    u32 button_ups;
+    u32 button_downs;
+};
diff --git a/src/platform.h b/src/platform.h
@@ -7,31 +7,6 @@
 #define KIBIBYTES(n) (n) * 1024LL
 #define MEBIBYTES(n) KIBIBYTES((n) * 1024LL)
 
-enum GameButton
-{
-    BTN_LEFT,
-    BTN_RIGHT,
-    BTN_UP,
-    BTN_DOWN,
-    BTN_JUMP,
-    BTN_DEBUG_FLOAT,
-
-    NUM_GAME_BUTTONS,
-    NULL_GAME_BUTTON,
-};
-
-// TODO: define static assert without string arg
-static_assert(NUM_GAME_BUTTONS <= 32, "");
-
-struct GameInput
-{
-    f32 dt;
-    u32 button_states;
-    u32 prev_button_states;
-    u32 button_ups;
-    u32 button_downs;
-};
-
 #define PLATFORM_READ_ENTIRE_FILE(name) char *(name)(char *file_path)
 typedef PLATFORM_READ_ENTIRE_FILE(platform_read_entire_file_func);