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"
|
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-22 22:13:13 +00:00
|
|
|
struct Game {
|
|
|
|
struct Event Start;
|
|
|
|
struct Event Draw;
|
|
|
|
struct Event Update;
|
|
|
|
|
|
|
|
Time time;
|
|
|
|
};
|
|
|
|
|
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-29 20:01:48 +00:00
|
|
|
CtrlMap(&ctrl, 0, BUTTON, 'A');
|
|
|
|
|
2024-04-22 22:13:13 +00:00
|
|
|
struct Game game;
|
|
|
|
CreateEvent(&game.Update);
|
|
|
|
|
2024-04-29 20:01:48 +00:00
|
|
|
struct InputHandle input_hand;
|
2024-04-25 07:04:43 +00:00
|
|
|
if (!BeginInputThread(&input_hand, &ctrl.recs, &ctrl.str))
|
2024-04-19 20:23:11 +00:00
|
|
|
ErrorExit("Input handle failed to initialize");
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-04-22 05:19:54 +00:00
|
|
|
while (true) {
|
2024-04-29 20:01:48 +00:00
|
|
|
if (!InputAquire(&input_hand))
|
|
|
|
ErrorExit("Aquire failed");
|
|
|
|
|
2024-04-30 04:43:41 +00:00
|
|
|
CtrlPoll(&ctrl);
|
|
|
|
|
|
|
|
struct InputAxis *a = CtrlGet(&ctrl, 0, BUTTON);
|
|
|
|
printf("%u", a);
|
|
|
|
printf("\t%u\n", a->is_down);
|
|
|
|
|
|
|
|
char silly[100] = { 0 };
|
|
|
|
CtrlInputString(&ctrl, 100, silly);
|
|
|
|
printf("%s\n", silly);
|
2024-04-29 20:01:48 +00:00
|
|
|
|
|
|
|
if (!InputRelease(&input_hand))
|
|
|
|
ErrorExit("Release failed");
|
2024-04-22 05:19:54 +00:00
|
|
|
|
2024-04-30 04:43:41 +00:00
|
|
|
_sleep(100);
|
|
|
|
|
2024-04-29 20:01:48 +00:00
|
|
|
EventInvokeUpdate(&game.Update, 0);
|
2024-04-22 05:19:54 +00:00
|
|
|
}
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|