aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy.h
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-11 14:30:48 -0400
committeriamcheeseman <[email protected]>2026-05-11 14:30:48 -0400
commitf4017a52d90567c2df482c5d553076dc706ac59b (patch)
tree6cce9684cee03370188e6c46e745fabb64007a46 /teensy/teensy.h
parentda2585ddc49abb80e7457ccc2805fff884eb2021 (diff)
Allow user input
Diffstat (limited to 'teensy/teensy.h')
-rw-r--r--teensy/teensy.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/teensy/teensy.h b/teensy/teensy.h
index cf0479f..568430c 100644
--- a/teensy/teensy.h
+++ b/teensy/teensy.h
@@ -4,7 +4,6 @@
#include <limits.h>
#include "teensy_common.h"
-#include "teensy_context.h"
#include "teensy_list.h"
#define ty_vec2(x, y) ((struct ty_vec2){x, y})
@@ -21,6 +20,30 @@
#define TY_COLOR_CYAN ty_color(0, 255, 255)
#define TY_COLOR_WHITE ty_color(255, 255, 255)
+// Virtual controller. Keyboard keys are also mapped to this.
+enum ty_button {
+ TY_BTN_LEFT_UP, // D-pad #1 up
+ TY_BTN_LEFT_DOWN, // D-pad #1 down
+ TY_BTN_LEFT_LEFT, // D-pad #1 left
+ TY_BTN_LEFT_RIGHT, // D-pad #1 right
+
+ TY_BTN_RIGHT_UP, // D-pad #2 up
+ TY_BTN_RIGHT_DOWN, // D-pad #2 down
+ TY_BTN_RIGHT_LEFT, // D-pad #2 left
+ TY_BTN_RIGHT_RIGHT, // D-pad #2 right
+
+ TY_BTN_ACTION_1, // A
+ TY_BTN_ACTION_2, // B
+ TY_BTN_ACTION_3, // X
+ TY_BTN_ACTION_4, // Y
+
+ // for use in the editor
+ TY_BTN_DB_CTRL,
+ TY_BTN_DB_SHIFT,
+
+ TY_BTN_COUNT,
+};
+
struct ty_hints {
int scr_width;
int scr_height;
@@ -28,12 +51,6 @@ struct ty_hints {
int ticrate;
};
-struct ty_ctx {
- struct ty_hints hints;
- double ticrate;
- double prev_tic_ts;
-};
-
struct ty_color {
uint8_t r;
uint8_t g;
@@ -81,6 +98,11 @@ struct ty_renderer {
void ty_init(struct ty_hints hints);
void ty_deinit(void);
+// If the button is being held down
+bool ty_button_down(enum ty_button btn);
+// If the button was pressed just now
+bool ty_button_pressed(enum ty_button btn);
+
// Whether or not the main loop should continue executing.
bool ty_is_game_running(void);
// Gets the real time that the game has been running.