Apply clang-format

This commit is contained in:
Cacodemon345
2024-05-05 14:55:42 +06:00
parent 34ec412bae
commit 4fe7090047

View File

@@ -34,8 +34,7 @@
#include <86box/fifo.h>
#include <86box/video.h> /* Needed to account for overscan. */
enum mtouch_modes
{
enum mtouch_modes {
MODE_TABLET = 1,
MODE_RAW = 2
};
@@ -56,29 +55,32 @@ typedef struct mouse_microtouch_t {
pc_timer_t reset_timer;
} mouse_microtouch_t;
static mouse_microtouch_t* mtouch_inst = NULL;
static mouse_microtouch_t *mtouch_inst = NULL;
void microtouch_reset_complete(void *priv)
void
microtouch_reset_complete(void *priv)
{
mouse_microtouch_t *mtouch = (mouse_microtouch_t*)priv;
mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv;
mtouch->in_reset = false;
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
void microtouch_calibrate_timer(void *priv)
void
microtouch_calibrate_timer(void *priv)
{
mouse_microtouch_t *mtouch = (mouse_microtouch_t*)priv;
mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv;
if (!fifo8_num_used(&mtouch->resp)) {
mtouch->cal_cntr--;
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "1\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "1\r", 2);
}
}
void microtouch_process_commands(mouse_microtouch_t* mtouch)
void
microtouch_process_commands(mouse_microtouch_t *mtouch)
{
int i = 0;
mtouch->cmd[strcspn(mtouch->cmd, "\r")] = '\0';
@@ -89,30 +91,30 @@ void microtouch_process_commands(mouse_microtouch_t* mtouch)
}
if (mtouch->cmd[0] == 'Z' || (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O')) {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "QM****00\r", sizeof("QM****00\r") - 1);
fifo8_push_all(&mtouch->resp, (uint8_t *) "QM****00\r", sizeof("QM****00\r") - 1);
}
if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "Q10200\r", sizeof("Q10200\r") - 1);
fifo8_push_all(&mtouch->resp, (uint8_t *) "Q10200\r", sizeof("Q10200\r") - 1);
}
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'T') {
mtouch->mode = MODE_TABLET;
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') {
mtouch->mode = MODE_RAW;
mtouch->cal_cntr = 0;
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'S') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'R') {
mtouch->in_reset = true;
@@ -122,34 +124,35 @@ void microtouch_process_commands(mouse_microtouch_t* mtouch)
}
if (mtouch->cmd[0] == 'A' && (mtouch->cmd[1] == 'D' || mtouch->cmd[1] == 'E')) {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'N' && mtouch->cmd[1] == 'M') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "1\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "1\r", 2);
}
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'Q') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "1\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "1\r", 2);
}
if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'F') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "1\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "1\r", 2);
}
if (mtouch->cmd[0] == 'P') {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
}
if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) {
fifo8_push(&mtouch->resp, 1);
fifo8_push_all(&mtouch->resp, (uint8_t*) "0\r", 2);
fifo8_push_all(&mtouch->resp, (uint8_t *) "0\r", 2);
mtouch->cal_cntr = 2;
}
}
void mtouch_write_to_host(void *priv)
void
mtouch_write_to_host(void *priv)
{
mouse_microtouch_t *dev = (mouse_microtouch_t*)priv;
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
if ((dev->serial->type >= SERIAL_16550) && dev->serial->fifo_enabled) {
if (fifo_get_full(dev->serial->rcvr_fifo)) {
goto no_write_to_machine;
@@ -171,10 +174,11 @@ no_write_to_machine:
timer_on_auto(&dev->host_to_serial_timer, (1000000.0 / (double) 9600.0) * (double) (1 + 8 + 1));
}
void mtouch_write(serial_t* serial, void* priv, uint8_t data)
void
mtouch_write(serial_t *serial, void *priv, uint8_t data)
{
mouse_microtouch_t *dev = (mouse_microtouch_t*)priv;
if (data == '\x1'){
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
if (data == '\x1') {
dev->soh = 1;
} else if (dev->soh) {
if (data != '\r') {
@@ -189,7 +193,7 @@ void mtouch_write(serial_t* serial, void* priv, uint8_t data)
static int
mtouch_poll(void *priv)
{
mouse_microtouch_t *dev = (mouse_microtouch_t*)priv;
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
if (dev->mode != MODE_RAW && fifo8_num_free(&dev->resp) >= 10) {
unsigned int abs_x_int = 0, abs_y_int = 0;
@@ -222,8 +226,8 @@ mtouch_poll(void *priv)
}
abs_x -= (monitors[index].mon_overscan_x / 2.);
abs_y -= (monitors[index].mon_overscan_y / 2.);
abs_x = abs_x / (double)monitors[index].mon_xsize;
abs_y = abs_y / (double)monitors[index].mon_ysize;
abs_x = abs_x / (double) monitors[index].mon_xsize;
abs_y = abs_y / (double) monitors[index].mon_ysize;
if (abs_x >= 1.0)
abs_x = 1.0;
if (abs_y >= 1.0)
@@ -270,12 +274,14 @@ mtouch_poll(void *priv)
return 0;
}
static void mtouch_poll_global(void)
static void
mtouch_poll_global(void)
{
mtouch_poll(mtouch_inst);
}
void* mtouch_init(const device_t* info)
void *
mtouch_init(const device_t *info)
{
mouse_microtouch_t *dev = calloc(1, sizeof(mouse_microtouch_t));
@@ -294,7 +300,8 @@ void* mtouch_init(const device_t* info)
return dev;
}
void mtouch_close(void* priv)
void
mtouch_close(void *priv)
{
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
@@ -342,4 +349,3 @@ const device_t mouse_mtouch_device = {
.force_redraw = NULL,
.config = mtouch_config
};