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.
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user