Fumofumotris/source/io/platforms/win.c

40 lines
694 B
C
Raw Normal View History

2024-03-25 05:34:59 +00:00
#include <iso646.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
2024-04-03 23:31:47 +00:00
#include <time.h>
#include <math.h>
2024-03-25 05:34:59 +00:00
#include "input.h"
#include "winhandler.h"
2024-04-03 23:31:47 +00:00
#include "term.h"
2024-03-25 05:34:59 +00:00
2024-04-03 23:31:47 +00:00
bool WindowsInit(struct Terminal *term)
2024-03-25 05:34:59 +00:00
{
2024-04-03 23:31:47 +00:00
if (!WinInitHandles())
2024-03-25 05:34:59 +00:00
return false;
2024-04-02 20:06:14 +00:00
if (!WinInitConsole())
2024-03-25 05:34:59 +00:00
return false;
2024-04-03 23:31:47 +00:00
if (!WinGetRefreshRate(&term->refresh_rate))
return false;
2024-04-02 20:06:14 +00:00
2024-03-25 05:34:59 +00:00
return true;
}
2024-04-02 00:55:30 +00:00
bool WindowsBlockInput(struct RecordBuffer *buf)
2024-03-25 05:34:59 +00:00
{
2024-03-26 20:11:58 +00:00
return WinBlockInput(buf);
2024-03-25 05:34:59 +00:00
}
bool WindowsWait(double seconds)
{
2024-04-03 23:31:47 +00:00
struct timespec duration = {
.tv_sec = seconds,
.tv_nsec = fmod(seconds, 1) * 1e9
};
return WinWait(duration);
2024-03-25 05:34:59 +00:00
}