From 96c8caa329c1661f12332e5f96df7a306ecb0117 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu, 29 Feb 2024 10:23:27 +1000
Subject: [PATCH] tablet: add a bustype event to the initial burst of tablet
 events

Just VID/PID is not enough, we need the bustype too. And since we now
have that event remove the mention of USB from zwp_tablet_v2.id.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 stable/tablet/tablet-v2.xml | 42 ++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/stable/tablet/tablet-v2.xml b/stable/tablet/tablet-v2.xml
index d75c97b2..0dbbde14 100644
--- a/stable/tablet/tablet-v2.xml
+++ b/stable/tablet/tablet-v2.xml
@@ -598,17 +598,22 @@
     </event>
 
     <event name="id">
-      <description summary="tablet device USB vendor/product id">
-	The USB vendor and product IDs for the tablet device.
+      <description summary="tablet device vendor/product id">
+	The vendor and product IDs for the tablet device.
 
-	If the device has no USB vendor/product ID, this event is not sent.
+	The interpretation of the id depends on the wp_tablet.bustype.
+	Prior to version v2 of this protocol, the id was implied to be a USB
+	vendor and product ID. If no wp_tablet.bustype is sent, the ID
+	is to be interpreted as USB vendor and product ID.
+
+	If the device has no vendor/product ID, this event is not sent.
 	This can happen for virtual devices or non-USB devices, for instance.
 
 	This event is sent in the initial burst of events before the
 	wp_tablet.done event.
       </description>
-      <arg name="vid" type="uint" summary="USB vendor id"/>
-      <arg name="pid" type="uint" summary="USB product id"/>
+      <arg name="vid" type="uint" summary="vendor id"/>
+      <arg name="pid" type="uint" summary="product id"/>
     </event>
 
     <event name="path">
@@ -649,6 +654,33 @@
 	the object.
       </description>
     </event>
+
+    <!-- Version 2 additions -->
+
+    <enum name="bustype" since="2">
+      <description summary="bus type ">
+	Describes the bus types this tablet is connected to.
+      </description>
+      <entry name="usb" value="3" summary="USB"/>
+      <entry name="bluetooth" value="5" summary="Bluetooth"/>
+      <entry name="virtual" value="6" summary="Virtual"/>
+      <entry name="serial" value="17" summary="Serial"/>
+      <entry name="i2c" value="24" summary="I2C"/>
+    </enum>
+
+    <event name="bustype" since="2">
+      <description summary="tablet device bus type">
+	The bustype argument is one of the BUS_ defines in the Linux kernel's
+	linux/input.h
+
+	If the device has no known bustype or the bustype cannot be
+	queried, this event is not sent.
+
+	This event is sent in the initial burst of events before the
+	wp_tablet.done event.
+      </description>
+      <arg name="bustype" type="uint" enum="bustype" summary="bus type"/>
+    </event>
   </interface>
 
   <interface name="zwp_tablet_pad_ring_v2" version="2">
-- 
GitLab