Quellcode durchsuchen

Added Contact Count to Teensy3 multi touch report

teensy4-core
purple-ben vor 4 Jahren
Ursprung
Commit
d55184e556
3 geänderte Dateien mit 21 neuen und 4 gelöschten Zeilen
  1. +5
    -0
      teensy3/usb_desc.c
  2. +2
    -2
      teensy3/usb_desc.h
  3. +14
    -2
      teensy3/usb_touch.c

+ 5
- 0
teensy3/usb_desc.c Datei anzeigen

@@ -394,6 +394,11 @@ static uint8_t multitouch_report_desc[] = {
0x95, 0x01, // Report Count (1)
0x09, 0x56, // Usage (Scan Time)
0x81, 0x02, // Input (variable,absolute)
0x09, 0x54, // USAGE (Contact count)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x0D, // Usage Page (Digitizers)
0x09, 0x55, // Usage (Contact Count Maximum)
0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)

+ 2
- 2
teensy3/usb_desc.h Datei anzeigen

@@ -370,7 +370,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define KEYMEDIA_INTERVAL 4
#define MULTITOUCH_INTERFACE 3 // Touchscreen
#define MULTITOUCH_ENDPOINT 5
#define MULTITOUCH_SIZE 8
#define MULTITOUCH_SIZE 16
#define MULTITOUCH_FINGERS 10
#define ENDPOINT1_CONFIG ENDPOINT_TRANSMIT_ONLY
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
@@ -410,7 +410,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define MOUSE_INTERVAL 2
#define MULTITOUCH_INTERFACE 4 // Touchscreen
#define MULTITOUCH_ENDPOINT 5
#define MULTITOUCH_SIZE 8
#define MULTITOUCH_SIZE 16
#define MULTITOUCH_FINGERS 10
#define ENDPOINT1_CONFIG ENDPOINT_TRANSMIT_ONLY
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY

+ 14
- 2
teensy3/usb_touch.c Datei anzeigen

@@ -86,12 +86,14 @@ void usb_touchscreen_release(uint8_t finger)
// 5: Y msb
// 6: scan time lsb
// 7: scan time msb
// 8: contact count

// Called by the start-of-frame interrupt.
//
void usb_touchscreen_update_callback(void)
{
uint8_t contact_count = 0;

if (scan_index == 0) {
if (usb_tx_packet_count(MULTITOUCH_ENDPOINT) > 1) {
// wait to begin another scan if if more than
@@ -100,7 +102,16 @@ void usb_touchscreen_update_callback(void)
}
scan_timestamp = millis() * 10;
scan_count = 0;

// Get the contact count (usage 0x54)
// Only set this value on first contact
// Subsequent concurrent contacts should report 0
for (uint8_t i = 0; i < MULTITOUCH_FINGERS; i++)
{
if (contactid[i]) contact_count++;
}
}

while (scan_index < MULTITOUCH_FINGERS) {
uint32_t press = pressure[scan_index];
uint32_t id = contactid[scan_index];
@@ -123,7 +134,8 @@ void usb_touchscreen_update_callback(void)
*(tx_packet->buf + 5) = ypos[scan_index] >> 8;
*(tx_packet->buf + 6) = scan_timestamp;
*(tx_packet->buf + 7) = scan_timestamp >> 8;
tx_packet->len = 8;
*(tx_packet->buf + 8) = contact_count;
tx_packet->len = 9;
usb_tx(MULTITOUCH_ENDPOINT, tx_packet);
scan_index++;
return;

Laden…
Abbrechen
Speichern