Fumofumotris/source/fumoengine/input/ctrl.h
Julia 7c58e46fc4 dict
dicks
2024-05-09 00:32:58 -05:00

60 lines
996 B
C

#pragma once
#include "dictionary.h"
#include "fumocommon.h"
#include "input.h"
struct ControlMapping {
u16 code;
u16 bind;
u16 type;
};
struct InputAxis {
nsec last_pressed;
nsec last_released;
union {
struct Button but;
struct Axis axis;
struct Joystick js;
union InputData data;
};
u16 type;
bool is_down;
bool is_held;
bool is_up;
};
struct Controller {
struct InputAxis *pending[IO_BUF_SIZE];
usize pending_len;
struct InputAxis *axes;
usize axes_len;
struct Dictionary binds;
};
bool CreateController(struct Controller *ctrl);
void FreeController(struct Controller *ctrl);
struct InputAxis *ControllerMap(
struct Controller *ctrl,
struct ControlMapping *map
);
bool ControllerMapMulti(
struct Controller *ctrl,
usize n,
struct ControlMapping *maps,
struct InputAxis **axis_ptrs
);
void ControllerPoll(struct Controller *ctrl, struct RecordBuffer *recs);