aboutsummaryrefslogtreecommitdiff
path: root/src/pad/inc
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-07-03 00:49:03 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-03-30 08:20:20 +0200
commit6b9f686913efc3725b2690033cd4f398e07076ba (patch)
treee9aa91a6b9f617d78123ebe7ad272fc42a60d306 /src/pad/inc
parentc9e6ae44a9aeb89b3f48f3443d6baa80103f7445 (diff)
downloadjancity-6b9f686913efc3725b2690033cd4f398e07076ba.tar.gz
Add project source code
Diffstat (limited to 'src/pad/inc')
-rw-r--r--src/pad/inc/pad.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/pad/inc/pad.h b/src/pad/inc/pad.h
new file mode 100644
index 0000000..2579c84
--- /dev/null
+++ b/src/pad/inc/pad.h
@@ -0,0 +1,49 @@
+#ifndef PAD_H
+#define PAD_H
+
+#include <pad/port.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define PAD_KEYS \
+ X(PAD_KEY_LEFT) \
+ X(PAD_KEY_RIGHT) \
+ X(PAD_KEY_UP) \
+ X(PAD_KEY_DOWN) \
+ X(PAD_KEY_A) \
+ X(PAD_KEY_B) \
+ X(PAD_KEY_C) \
+ X(PAD_KEY_D) \
+ X(PAD_KEY_E) \
+ X(PAD_KEY_OPTIONS)
+
+enum pad_key
+{
+#define X(x) x,
+ PAD_KEYS
+#undef X
+};
+
+struct pad
+{
+ int player;
+ int mask, oldmask;
+ struct pad_port port;
+};
+
+void pad_init(int player, struct pad *p);
+void pad_update(struct pad *p);
+bool pad_pressed(const struct pad *p, enum pad_key k);
+bool pad_justpressed(const struct pad *p, enum pad_key k);
+bool pad_released(const struct pad *p, enum pad_key k);
+const char *pad_str(enum pad_key k);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PAD_H */