From 94bffa104a3e9d82ca0acd1060c3a851622d1846 Mon Sep 17 00:00:00 2001 From: Jos van Mourik Date: Thu, 1 Aug 2024 20:47:15 +0200 Subject: [PATCH 1/5] Set CTS/DSR/DCD high like a real Microtouch --- src/device/mouse_microtouch_touchscreen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index b05e82054..20ec5351c 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -356,6 +356,10 @@ mtouch_init(const device_t *info) dev->serial = serial_attach(device_get_config_int("port"), NULL, mtouch_write, dev); dev->baud_rate = device_get_config_int("baudrate"); + serial_set_cts(dev->serial, 1); + serial_set_dsr(dev->serial, 1); + serial_set_dcd(dev->serial, 1); + fifo8_create(&dev->resp, 512); timer_add(&dev->host_to_serial_timer, mtouch_write_to_host, dev, 0); timer_add(&dev->reset_timer, microtouch_reset_complete, dev, 0); From 3b2072ac8cdc0436cecf0285cb6ddf6925525dae Mon Sep 17 00:00:00 2001 From: Jos van Mourik Date: Thu, 1 Aug 2024 22:40:20 +0200 Subject: [PATCH 2/5] Change mouse poll rate per mode to reflect serial write speed, optimize serial fifo lengths --- src/device/mouse_microtouch_touchscreen.c | 32 +++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index 20ec5351c..c91ed8065 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -19,6 +19,7 @@ /* TODO: - Properly implement GP/SP commands (formats are not documented at all, like anywhere; no dumps yet). + - Decouple serial packet generation from mouse poll rate. - Dynamic baud rate selection from software following this. - Add additional SMT2/3 formats as we currently only support Tablet, Hex and Dec. - Add additional SMT2/3 modes as we currently hardcode Mode Stream + Mode Status. @@ -56,7 +57,7 @@ const char* mtouch_identity[] = { typedef struct mouse_microtouch_t { double baud_rate; int b; - char cmd[512]; + char cmd[256]; int cmd_pos; int format; uint8_t id, cal_cntr, pen_mode; @@ -122,34 +123,45 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) mt_fifo8_puts(&mtouch->resp, mtouch_identity[mtouch->id]); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'D') { /* Format Decimal */ + mouse_set_sample_rate(106); mtouch->format = FORMAT_DEC; mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'H') { /* Format Hexadecimal */ + mouse_set_sample_rate(106); mtouch->format = FORMAT_HEX; mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') { /* Format Raw */ + mouse_set_sample_rate(106); mtouch->format = FORMAT_RAW; mtouch->cal_cntr = 0; mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'T') { /* Format Tablet */ + mouse_set_sample_rate(192); mtouch->format = FORMAT_TABLET; mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'S') { /* Mode Stream */ mt_fifo8_puts(&mtouch->resp, "0"); } + if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'T') { /* Mode Status */ + mt_fifo8_puts(&mtouch->resp, "0"); + } if (mtouch->cmd[0] == 'R') { /* Reset */ mtouch->in_reset = true; mtouch->cal_cntr = 0; mtouch->pen_mode = 3; - if (mtouch->id < 2) + if (mtouch->id < 2) { + mouse_set_sample_rate(106); mtouch->format = FORMAT_DEC; - else + } + else { + mouse_set_sample_rate(192); mtouch->format = FORMAT_TABLET; + } timer_on_auto(&mtouch->reset_timer, 500. * 1000.); } @@ -235,7 +247,7 @@ mtouch_poll(void *priv) { mouse_microtouch_t *dev = (mouse_microtouch_t *) priv; - if (fifo8_num_free(&dev->resp) <= 10 || dev->format == FORMAT_RAW) { + if (fifo8_num_free(&dev->resp) <= 256 - 10 || dev->format == FORMAT_RAW) { return 0; } @@ -360,18 +372,22 @@ mtouch_init(const device_t *info) serial_set_dsr(dev->serial, 1); serial_set_dcd(dev->serial, 1); - fifo8_create(&dev->resp, 512); + fifo8_create(&dev->resp, 256); timer_add(&dev->host_to_serial_timer, mtouch_write_to_host, dev, 0); timer_add(&dev->reset_timer, microtouch_reset_complete, dev, 0); timer_on_auto(&dev->host_to_serial_timer, (1000000. / dev->baud_rate) * 10); dev->id = device_get_config_int("identity"); dev->pen_mode = 3; - if (dev->id < 2) /* legacy controllers */ + if (dev->id < 2) { /* legacy controllers */ dev->format = FORMAT_DEC; - else + mouse_set_sample_rate(106); + } + else { dev->format = FORMAT_TABLET; - + mouse_set_sample_rate(192); + } + mouse_input_mode = device_get_config_int("crosshair") + 1; mouse_set_buttons(2); mouse_set_poll_ex(mtouch_poll_global); From 40dcbaa10efc58e6e346a1574a5db1cf98fbbda4 Mon Sep 17 00:00:00 2001 From: Jos van Mourik Date: Fri, 2 Aug 2024 00:16:49 +0200 Subject: [PATCH 3/5] Implement Mode Status --- src/device/mouse_microtouch_touchscreen.c | 71 ++++++++++++++--------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index c91ed8065..8faafbc49 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -22,7 +22,7 @@ - Decouple serial packet generation from mouse poll rate. - Dynamic baud rate selection from software following this. - Add additional SMT2/3 formats as we currently only support Tablet, Hex and Dec. - - Add additional SMT2/3 modes as we currently hardcode Mode Stream + Mode Status. + - Add additional SMT2/3 modes as we currently hardcode Mode Stream. */ #include #include @@ -59,7 +59,8 @@ typedef struct mouse_microtouch_t { int b; char cmd[256]; int cmd_pos; - int format; + uint8_t format; + bool mode_status; uint8_t id, cal_cntr, pen_mode; bool soh; bool in_reset; @@ -83,7 +84,7 @@ void microtouch_reset_complete(void *priv) { mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv; - + mtouch->in_reset = false; mt_fifo8_puts(&mtouch->resp, "0"); } @@ -92,7 +93,7 @@ void microtouch_calibrate_timer(void *priv) { mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv; - + if (!fifo8_num_used(&mtouch->resp)) { mtouch->cal_cntr--; mt_fifo8_puts(&mtouch->resp, "1"); @@ -147,12 +148,14 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'T') { /* Mode Status */ + mtouch->mode_status = true; mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'R') { /* Reset */ mtouch->in_reset = true; mtouch->cal_cntr = 0; mtouch->pen_mode = 3; + mtouch->mode_status = false; if (mtouch->id < 2) { mouse_set_sample_rate(106); @@ -255,7 +258,7 @@ mtouch_poll(void *priv) double abs_x; double abs_y; int b = mouse_get_buttons_ex(); - + mouse_get_abs_coords(&abs_x, &abs_y); if (abs_x >= 1.0) @@ -268,12 +271,13 @@ mtouch_poll(void *priv) abs_y = 0.0; if (enable_overscan) { int index = mouse_tablet_in_proximity - 1; - if (mouse_tablet_in_proximity == -1) + if (mouse_tablet_in_proximity == -1) { mouse_tablet_in_proximity = 0; - + } + abs_x *= monitors[index].mon_unscaled_size_x - 1; abs_y *= monitors[index].mon_efscrnsz_y - 1; - + if (abs_x <= (monitors[index].mon_overscan_x / 2.)) { abs_x = (monitors[index].mon_overscan_x / 2.); } @@ -303,16 +307,23 @@ mtouch_poll(void *priv) abs_y_int = 999 - (abs_y * 999); char buffer[10]; - if (b) { - if (!dev->b) { /* Touchdown */ - snprintf(buffer, sizeof(buffer), "\x19%03d,%03d\r", abs_x_int, abs_y_int); - } else { /* Touch Continuation */ - snprintf(buffer, sizeof(buffer), "\x1c%03d,%03d\r", abs_x_int, abs_y_int); + if (!dev->mode_status) { + if (b) { // Touch + snprintf(buffer, sizeof(buffer), "\x1%03d,%03d\r", abs_x_int, abs_y_int); + fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } - } else if (dev->b) { /* Liftoff */ - snprintf(buffer, sizeof(buffer), "\x18%03d,%03d\r", abs_x_int, abs_y_int); + } else { + if (b) { + if (!dev->b) { /* Touchdown Status */ + snprintf(buffer, sizeof(buffer), "\x19%03d,%03d\r", abs_x_int, abs_y_int); + } else { /* Touch Continuation Status */ + snprintf(buffer, sizeof(buffer), "\x1c%03d,%03d\r", abs_x_int, abs_y_int); + } + } else if (dev->b) { /* Liftoff Status */ + snprintf(buffer, sizeof(buffer), "\x18%03d,%03d\r", abs_x_int, abs_y_int); + } + fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } - fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } else if (dev->format == FORMAT_HEX) { @@ -320,16 +331,23 @@ mtouch_poll(void *priv) abs_y_int = 1023 - (abs_y * 1023); char buffer[10]; - if (b) { - if (!dev->b) { /* Touchdown */ - snprintf(buffer, sizeof(buffer), "\x19%03X,%03X\r", abs_x_int, abs_y_int); - } else { /* Touch Continuation */ - snprintf(buffer, sizeof(buffer), "\x1c%03X,%03X\r", abs_x_int, abs_y_int); + if (!dev->mode_status) { + if (b) { // Touch + snprintf(buffer, sizeof(buffer), "\x1%03X,%03X\r", abs_x_int, abs_y_int); + fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } - } else if (dev->b) { /* Liftoff */ - snprintf(buffer, sizeof(buffer), "\x18%03X,%03X\r", abs_x_int, abs_y_int); + } else { + if (b) { + if (!dev->b) { /* Touchdown Status */ + snprintf(buffer, sizeof(buffer), "\x19%03X,%03X\r", abs_x_int, abs_y_int); + } else { /* Touch Continuation Status */ + snprintf(buffer, sizeof(buffer), "\x1c%03X,%03X\r", abs_x_int, abs_y_int); + } + } else if (dev->b) { /* Liftoff Status */ + snprintf(buffer, sizeof(buffer), "\x18%03X,%03X\r", abs_x_int, abs_y_int); + } + fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } - fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer)); } else if (dev->format == FORMAT_TABLET) { @@ -365,7 +383,7 @@ void * mtouch_init(const device_t *info) { mouse_microtouch_t *dev = calloc(1, sizeof(mouse_microtouch_t)); - + dev->serial = serial_attach(device_get_config_int("port"), NULL, mtouch_write, dev); dev->baud_rate = device_get_config_int("baudrate"); serial_set_cts(dev->serial, 1); @@ -377,7 +395,8 @@ mtouch_init(const device_t *info) timer_add(&dev->reset_timer, microtouch_reset_complete, dev, 0); timer_on_auto(&dev->host_to_serial_timer, (1000000. / dev->baud_rate) * 10); dev->id = device_get_config_int("identity"); - dev->pen_mode = 3; + dev->pen_mode = 3; + dev->mode_status = false; if (dev->id < 2) { /* legacy controllers */ dev->format = FORMAT_DEC; From 49d71c19babb35997429b2637024140f8be4065c Mon Sep 17 00:00:00 2001 From: Jos van Mourik Date: Fri, 2 Aug 2024 01:24:00 +0200 Subject: [PATCH 4/5] Commands cleanup - Return 0 for unknown commands instead of 1, to not lock up software. - Add a few extra unknown commands. - Sort commands alphabetically to keep this mess organized. - Don't capitalize commands as no software i know needs it. --- src/device/mouse_microtouch_touchscreen.c | 83 ++++++++++++----------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index 8faafbc49..7e992dc22 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -103,36 +103,36 @@ microtouch_calibrate_timer(void *priv) void microtouch_process_commands(mouse_microtouch_t *mtouch) { - int i = 0; int fifo_used = fifo8_num_used(&mtouch->resp); mtouch->cmd[strcspn(mtouch->cmd, "\r")] = '\0'; mtouch->cmd_pos = 0; - for (i = 0; i < strlen(mtouch->cmd); i++) { - mtouch->cmd[i] = toupper(mtouch->cmd[i]); - } - if (mtouch->cmd[0] == 'Z') { /* Null */ + if (mtouch->cmd[0] == 'A' && (mtouch->cmd[1] == 'D' || mtouch->cmd[1] == 'E')) { /* Autobaud Enable/Disable */ mt_fifo8_puts(&mtouch->resp, "0"); } - if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */ - mtouch->pen_mode = 1; + if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */ mt_fifo8_puts(&mtouch->resp, "0"); - } - if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */ - mt_fifo8_puts(&mtouch->resp, "TP****00"); - } - if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') { /* Output Identity */ - mt_fifo8_puts(&mtouch->resp, mtouch_identity[mtouch->id]); + mtouch->cal_cntr = 2; } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'D') { /* Format Decimal */ mouse_set_sample_rate(106); mtouch->format = FORMAT_DEC; mt_fifo8_puts(&mtouch->resp, "0"); + } + if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'N') { /* Filter Number */ + mt_fifo8_puts(&mtouch->resp, "0"); + } + if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */ + mtouch->pen_mode = 1; + mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'H') { /* Format Hexadecimal */ mouse_set_sample_rate(106); mtouch->format = FORMAT_HEX; mt_fifo8_puts(&mtouch->resp, "0"); } + if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'Q') { /* ?? */ + mt_fifo8_puts(&mtouch->resp, "0"); + } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') { /* Format Raw */ mouse_set_sample_rate(106); mtouch->format = FORMAT_RAW; @@ -144,6 +144,17 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) mtouch->format = FORMAT_TABLET; mt_fifo8_puts(&mtouch->resp, "0"); } + if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'F') { /* ?? */ + mt_fifo8_puts(&mtouch->resp, "0"); + } + if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Get Parameter Block 1 */ + mt_fifo8_puts(&mtouch->resp, "A"); + fifo8_push_all(&mtouch->resp, (uint8_t *) "0000000000000000000000000\r", sizeof("0000000000000000000000000\r") - 1); + mt_fifo8_puts(&mtouch->resp, "0"); + } + if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'P') { /* ?? */ + mt_fifo8_puts(&mtouch->resp, "0"); + } if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'S') { /* Mode Stream */ mt_fifo8_puts(&mtouch->resp, "0"); } @@ -151,6 +162,20 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) mtouch->mode_status = true; mt_fifo8_puts(&mtouch->resp, "0"); } + if (mtouch->cmd[0] == 'N' && mtouch->cmd[1] == 'M') { /* ?? */ + mt_fifo8_puts(&mtouch->resp, "0"); + } + if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') { /* Output Identity */ + mt_fifo8_puts(&mtouch->resp, mtouch_identity[mtouch->id]); + } + if (mtouch->cmd[0] == 'P') { + if (mtouch->cmd[1] == 'F') mtouch->pen_mode = 3; /* Pen or Finger */ + else if (mtouch->cmd[1] == 'O') mtouch->pen_mode = 2; /* Pen Only */ + mt_fifo8_puts(&mtouch->resp, "0"); /* Also 'PL' Parameter Lock */ + } + if (mtouch->cmd[0] == 'Q' && mtouch->cmd[1] == 'P') { /* ?? */ + mt_fifo8_puts(&mtouch->resp, "0"); + } if (mtouch->cmd[0] == 'R') { /* Reset */ mtouch->in_reset = true; mtouch->cal_cntr = 0; @@ -168,34 +193,14 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) timer_on_auto(&mtouch->reset_timer, 500. * 1000.); } - if (mtouch->cmd[0] == 'A' && (mtouch->cmd[1] == 'D' || mtouch->cmd[1] == 'E')) { /* Autobaud Enable/Disable */ - mt_fifo8_puts(&mtouch->resp, "0"); - } - if (mtouch->cmd[0] == 'N' && mtouch->cmd[1] == 'M') { /* ?? */ - mt_fifo8_puts(&mtouch->resp, "1"); - } - if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'Q') { /* ?? */ - mt_fifo8_puts(&mtouch->resp, "1"); - } - if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'F') { /* ?? */ - mt_fifo8_puts(&mtouch->resp, "1"); - } - if (mtouch->cmd[0] == 'P') { - if (mtouch->cmd[1] == 'F') mtouch->pen_mode = 3; /* Pen or Finger */ - else if (mtouch->cmd[1] == 'O') mtouch->pen_mode = 2; /* Pen Only */ - mt_fifo8_puts(&mtouch->resp, "0");; - } - if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */ - mt_fifo8_puts(&mtouch->resp, "0"); - mtouch->cal_cntr = 2; - } - if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Get Parameter Block 1 */ - mt_fifo8_puts(&mtouch->resp, "A"); - fifo8_push_all(&mtouch->resp, (uint8_t *) "0000000000000000000000000\r", sizeof("0000000000000000000000000\r") - 1); - mt_fifo8_puts(&mtouch->resp, "0"); - } if (mtouch->cmd[0] == 'S' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Set Parameter Block 1 */ mt_fifo8_puts(&mtouch->resp, "A"); + } + if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */ + mt_fifo8_puts(&mtouch->resp, "TP****00"); + } + if (mtouch->cmd[0] == 'Z') { /* Null */ + mt_fifo8_puts(&mtouch->resp, "0"); } if (fifo8_num_used(&mtouch->resp) != fifo_used || mtouch->in_reset) { pclog("Command handled: %s\n", mtouch->cmd); From 282d4e0c70c3c6ee905d702c8ae654e8e901008c Mon Sep 17 00:00:00 2001 From: Jos van Mourik Date: Fri, 2 Aug 2024 15:09:52 +0200 Subject: [PATCH 5/5] Formatting, use selected bauddrate for serial retry timing too --- src/device/mouse_microtouch_touchscreen.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index 7e992dc22..2f5333121 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -109,7 +109,7 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) if (mtouch->cmd[0] == 'A' && (mtouch->cmd[1] == 'D' || mtouch->cmd[1] == 'E')) { /* Autobaud Enable/Disable */ mt_fifo8_puts(&mtouch->resp, "0"); } - if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */ + if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */ mt_fifo8_puts(&mtouch->resp, "0"); mtouch->cal_cntr = 2; } @@ -118,7 +118,7 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) mtouch->format = FORMAT_DEC; mt_fifo8_puts(&mtouch->resp, "0"); } - if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'N') { /* Filter Number */ + if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'N') { /* Filter Number */ mt_fifo8_puts(&mtouch->resp, "0"); } if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */ @@ -196,10 +196,10 @@ microtouch_process_commands(mouse_microtouch_t *mtouch) if (mtouch->cmd[0] == 'S' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Set Parameter Block 1 */ mt_fifo8_puts(&mtouch->resp, "A"); } - if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */ + if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */ mt_fifo8_puts(&mtouch->resp, "TP****00"); } - if (mtouch->cmd[0] == 'Z') { /* Null */ + if (mtouch->cmd[0] == 'Z') { /* Null */ mt_fifo8_puts(&mtouch->resp, "0"); } if (fifo8_num_used(&mtouch->resp) != fifo_used || mtouch->in_reset) { @@ -230,7 +230,7 @@ mtouch_write_to_host(void *priv) } no_write_to_machine: - timer_on_auto(&dev->host_to_serial_timer, (1000000.0 / (double) 9600.0) * (double) (1 + 8 + 1)); + timer_on_auto(&dev->host_to_serial_timer, (1000000.0 / (double) dev->baud_rate) * (double) (1 + 8 + 1)); } void @@ -415,9 +415,9 @@ mtouch_init(const device_t *info) mouse_input_mode = device_get_config_int("crosshair") + 1; mouse_set_buttons(2); mouse_set_poll_ex(mtouch_poll_global); - + mtouch_inst = dev; - + return dev; } @@ -430,7 +430,7 @@ mtouch_close(void *priv) /* Detach serial port from the mouse. */ if (dev && dev->serial && dev->serial->sd) memset(dev->serial->sd, 0, sizeof(serial_device_t)); - + free(dev); mtouch_inst = NULL; }