void microtouch_rx(int count, UINT8* data) { int i; for ( i = 0; (i < count) && ((microtouch.rx_buffer_ptr + i) < 16); i++ ) { microtouch.rx_buffer[i+microtouch.rx_buffer_ptr] = data[i]; microtouch.rx_buffer_ptr++; } if (microtouch.rx_buffer_ptr > 0 && (microtouch.rx_buffer[microtouch.rx_buffer_ptr-1] == 0x0d)) { // check command if ( microtouch_check_command( "MS", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.mode_stream = 1; microtouch.mode_inactive = 0; } else if ( microtouch_check_command( "MI", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.mode_inactive = 1; } else if ( microtouch_check_command( "R", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.tx_buffer_num = 0; microtouch.reset_done = 1; } else if ( microtouch_check_command( "FT", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.format_tablet = 1; } // send response microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x01; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x30; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x0d; microtouch.rx_buffer_ptr = 0; } };
void microtouch_rx(int count, UINT8* data) { int i; for ( i = 0; (i < count) && ((microtouch.rx_buffer_ptr + i) < 16); i++ ) { microtouch.rx_buffer[i+microtouch.rx_buffer_ptr] = data[i]; microtouch.rx_buffer_ptr++; } if (microtouch.rx_buffer_ptr > 0 && (microtouch.rx_buffer[microtouch.rx_buffer_ptr-1] == 0x0d)) { if (LOG) { char command[16]; memset(command, 0, sizeof(command)); strncpy( command, (const char*)microtouch.rx_buffer + 1, microtouch.rx_buffer_ptr - 2 ); logerror("Microtouch: received command %s\n", command); } // check command if ( microtouch_check_command( "MS", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.mode_stream = 1; microtouch.mode_inactive = 0; } else if ( microtouch_check_command( "MI", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.mode_inactive = 1; } else if ( microtouch_check_command( "R", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.tx_buffer_num = 0; microtouch.reset_done = 1; } else if ( microtouch_check_command( "FT", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.format_tablet = 1; } else if ( microtouch_check_command( "FD", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { microtouch.format_decimal = 1; } else if ( microtouch_check_command("OI", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) ) { // output identity - SMT3, ver 01.00 microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x01; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 'Q'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = '1'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = '0'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = '1'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = '0'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = '0'; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x0d; microtouch.rx_buffer_ptr = 0; return; } // send response microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x01; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x30; microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x0d; microtouch.rx_buffer_ptr = 0; } };