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 "ctrl.h"
|
|
|
|
#include "fumotris.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "win.h"
|
|
|
|
#endif
|
|
|
|
|
2024-03-26 20:11:58 +00:00
|
|
|
#define IO_BUF_SIZE 8
|
2024-03-25 05:34:59 +00:00
|
|
|
|
2024-03-26 20:11:58 +00:00
|
|
|
struct input_args {
|
|
|
|
Ctrl *ctrl;
|
|
|
|
struct InputBuffer *in_buf;
|
|
|
|
};
|
2024-03-25 05:34:59 +00:00
|
|
|
|
2024-03-26 20:11:58 +00:00
|
|
|
void *block_input(void *args_ptr)
|
2024-03-25 05:34:59 +00:00
|
|
|
{
|
2024-03-26 20:11:58 +00:00
|
|
|
struct input_args *args = args_ptr;
|
|
|
|
Ctrl *ctrl = args->ctrl;
|
|
|
|
struct InputBuffer *in_buf = args->in_buf;
|
2024-03-25 05:34:59 +00:00
|
|
|
|
|
|
|
input_loop:
|
|
|
|
bool success;
|
2024-03-26 20:11:58 +00:00
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
#ifdef _WIN32
|
2024-03-26 20:11:58 +00:00
|
|
|
success = WindowsBlockInput(&in_buf);
|
2024-03-25 05:34:59 +00:00
|
|
|
#endif
|
|
|
|
|
2024-03-26 20:11:58 +00:00
|
|
|
if (!success)
|
2024-03-25 05:34:59 +00:00
|
|
|
exit(1);
|
|
|
|
|
|
|
|
goto input_loop;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartInput(Ctrl *ctrl)
|
|
|
|
{
|
|
|
|
pthread_t input_thread;
|
|
|
|
pthread_create(&input_thread, nullptr, block_input, ctrl);
|
|
|
|
//pthread_join(input_thread, nullptr);
|
|
|
|
}
|