2024-03-25 05:34:59 +00:00
|
|
|
#include <iso646.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-04-15 19:29:51 +00:00
|
|
|
#include "ctrl.h"
|
2024-04-18 05:04:44 +00:00
|
|
|
#include "input.h"
|
2024-03-25 05:34:59 +00:00
|
|
|
#include "fumotris.h"
|
|
|
|
#include "term.h"
|
|
|
|
#include "tetr.h"
|
2024-04-03 23:31:47 +00:00
|
|
|
#include "event.h"
|
2024-04-16 22:14:53 +00:00
|
|
|
#include "platform.h"
|
2024-03-25 05:34:59 +00:00
|
|
|
|
2024-04-19 20:23:11 +00:00
|
|
|
void ErrorExit(char *message)
|
|
|
|
{
|
|
|
|
printf(message);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-04-09 07:00:48 +00:00
|
|
|
int main()
|
|
|
|
{
|
2024-04-19 20:23:11 +00:00
|
|
|
if (!PlatformInit())
|
|
|
|
ErrorExit("Platform failed to initialize");
|
|
|
|
|
|
|
|
struct Controller ctrl;
|
|
|
|
if (!CreateCtrl(&ctrl))
|
|
|
|
ErrorExit("Out of memory");
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-04-19 20:23:11 +00:00
|
|
|
struct InputThreadHandle input;
|
|
|
|
if (!BeginInputThread(&input, &ctrl.buf))
|
|
|
|
ErrorExit("Input handle failed to initialize");
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-04-22 05:19:54 +00:00
|
|
|
CtrlMap(&ctrl, 0, BUTTON, 'A');
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
bool poll = CtrlPoll(&ctrl);
|
|
|
|
printf("poll: %u\n", poll);
|
|
|
|
|
|
|
|
struct InputAxis *a = CtrlGet(&ctrl, 0, BUTTON);
|
|
|
|
printf("get: %llu\n", a);
|
|
|
|
|
|
|
|
printf("val: %u\n", a->but.value);
|
|
|
|
}
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|