jtmm2/inc/input.h

44 lines
718 B
C
Raw Normal View History

2021-12-15 23:55:44 +01:00
#pragma once
2021-12-23 11:52:37 +01:00
#include "conf.h"
2021-12-15 23:55:44 +01:00
2021-12-19 00:30:09 +01:00
enum Key {
K_LEFT,
K_RIGHT,
K_UP,
K_DOWN,
K_JUMP,
K_POLARITY,
K_EXIT,
2021-12-20 18:00:17 +01:00
K_SKIP,
2021-12-19 00:30:09 +01:00
K_EDITOR,
K_SCROLL_UP,
K_SCROLL_DOWN,
2021-12-21 00:14:49 +01:00
K_DEBUG,
2021-12-23 15:54:44 +01:00
K_SAVE_REPLAY,
K_PLAYBACK,
2021-12-19 00:30:09 +01:00
K_COUNT
};
2021-12-15 23:55:44 +01:00
enum KeyState { KS_UP, KS_DOWN, KS_PRESS };
2021-12-23 15:54:44 +01:00
typedef short PackedFrame;
2021-12-23 11:52:37 +01:00
2021-12-15 23:55:44 +01:00
struct Input {
enum Key keys[K_COUNT];
enum KeyState states[K_COUNT];
2021-12-23 15:54:44 +01:00
int replay_cursor, replay_end, playback;
2021-12-23 11:52:37 +01:00
PackedFrame replay[REPLAY_SIZE];
2021-12-15 23:55:44 +01:00
};
void input_init(void);
void input_update(void);
2021-12-23 15:54:44 +01:00
void input_dump_replay(void);
void input_load_replay(void);
2021-12-15 23:55:44 +01:00
2022-01-12 22:36:10 +01:00
void input_set_down(enum Key);
void input_set_pressed(enum Key);
void input_set_up(enum Key);
2021-12-15 23:55:44 +01:00
int input_down(enum Key);
int input_pressed(enum Key);
int input_up(enum Key);