Fumofumotris/rewrite/c/controller.c
2024-05-24 00:36:13 -05:00

45 lines
948 B
C

#include "controller.h"
#include <stdlib.h>
bool CreateController(struct Controller *ctrl, struct Pool *pool, usize axes)
{
*ctrl = (struct Controller) {
.map.v_codes = calloc(16, sizeof(u16)),
.map.v_bind_ptrs = calloc(16, sizeof(struct InputVBind *)),
.map.n = 16,
.v_axes = calloc(16, sizeof(struct InputVAxis)),
.v_binds = calloc(16, sizeof(struct InputVBind)),
.v_axes_n = 16,
.v_binds_n = 16
};
}
u32 as_v_code(u16 scan_code, u8 type)
{
return (u32)scan_code | ((u32)type << 16);
}
void ControllerBindV(struct Controller *ctrl, u16 v_bind, u16 v_axis)
{
ctrl->v_binds[v_bind].v_axis = &ctrl->v_axes[v_axis];
}
void ControllerBind(struct Controller *ctrl, u16 scan_code, u8 type, u16 v_bind)
{
u32 v_code = as_v_code(scan_code, type);
struct InputVBind *v_bind = &ctrl->v_binds[v_bind];
}
void ControllerPoll(struct Controller *ctrl, struct InputRecord *recs, usize n)
{
for (usize i = 0; i < n; i++) {
}
}