2024-03-25 05:34:59 +00:00
|
|
|
#pragma once
|
2024-05-08 22:07:31 +00:00
|
|
|
#include "dictionary.h"
|
2024-04-30 21:41:31 +00:00
|
|
|
#include "fumocommon.h"
|
2024-04-18 05:04:44 +00:00
|
|
|
#include "input.h"
|
2024-04-16 22:14:53 +00:00
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
struct ControlMapping {
|
|
|
|
u16 code;
|
|
|
|
u16 bind;
|
|
|
|
u16 type;
|
|
|
|
};
|
|
|
|
|
2024-05-08 12:47:46 +00:00
|
|
|
struct ControlAxis {
|
2024-05-07 03:29:10 +00:00
|
|
|
nsec last_pressed;
|
|
|
|
nsec last_released;
|
2024-04-11 19:57:22 +00:00
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
union {
|
2024-04-10 14:03:57 +00:00
|
|
|
struct Button but;
|
|
|
|
struct Axis axis;
|
|
|
|
struct Joystick js;
|
2024-04-11 19:57:22 +00:00
|
|
|
union InputData data;
|
2024-04-09 22:10:30 +00:00
|
|
|
};
|
2024-04-18 21:20:44 +00:00
|
|
|
|
|
|
|
union InputID id;
|
2024-04-23 20:33:32 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u8f is_down : 1;
|
|
|
|
u8f is_held : 1;
|
|
|
|
u8f is_up : 1;
|
|
|
|
};
|
2024-03-25 05:34:59 +00:00
|
|
|
};
|
|
|
|
|
2024-04-18 21:20:44 +00:00
|
|
|
struct Controller {
|
2024-04-23 06:35:19 +00:00
|
|
|
struct {
|
2024-05-08 22:07:31 +00:00
|
|
|
struct ControlAxis *buf[IO_BUF_SIZE];
|
2024-04-23 06:35:19 +00:00
|
|
|
u8f len;
|
2024-05-08 22:07:31 +00:00
|
|
|
} pending;
|
2024-04-18 21:20:44 +00:00
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
struct Dictionary codes;
|
|
|
|
struct Dictionary binds;
|
2024-05-02 22:17:37 +00:00
|
|
|
};
|
2024-03-25 05:34:59 +00:00
|
|
|
|
|
|
|
|
2024-05-02 22:17:37 +00:00
|
|
|
bool CreateController(struct Controller *ctrl);
|
2024-05-08 12:47:46 +00:00
|
|
|
|
2024-05-02 22:17:37 +00:00
|
|
|
void FreeController(struct Controller *ctrl);
|
2024-03-25 05:34:59 +00:00
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
struct ControlAxis *ControllerMap(
|
|
|
|
struct Controller *ctrl,
|
|
|
|
struct ControlMapping *map
|
|
|
|
);
|
2024-04-19 06:38:45 +00:00
|
|
|
|
2024-05-07 22:10:15 +00:00
|
|
|
bool ControllerMapMulti(
|
|
|
|
struct Controller *ctrl,
|
2024-05-08 12:47:46 +00:00
|
|
|
usize n,
|
2024-05-08 22:07:31 +00:00
|
|
|
struct ControlMapping *maps,
|
|
|
|
struct ControlAxis **axis_ptrs
|
2024-05-07 22:10:15 +00:00
|
|
|
);
|
|
|
|
|
2024-05-08 12:47:46 +00:00
|
|
|
struct ControlAxis *ControllerGet(struct Controller *ctrl, u16f code, u16f type);
|
2024-04-19 06:38:45 +00:00
|
|
|
|
2024-05-02 22:17:37 +00:00
|
|
|
void ControllerPoll(struct Controller *ctrl, struct RecordBuffer *recs);
|
2024-04-19 06:38:45 +00:00
|
|
|
|