From 855ba3a1c94dc7d1a3febaa63b0741548e9625f6 Mon Sep 17 00:00:00 2001
From: Lorenzo Zanetti <mihares@msn.com>
Date: Sun, 15 Apr 2018 18:56:16 +0200
Subject: [PATCH 1/3] added the descriptor to the hid-ids.h

---
 hid-ids.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hid-ids.h b/hid-ids.h
index 7abbcf50..19bd21a3 100644
--- a/hid-ids.h
+++ b/hid-ids.h
@@ -31,6 +31,7 @@
 #define USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850	0x0522
 #define USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60	0x0781
 #define USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3	0x3031
+#define USB_DEVICE_ID_UCLOGIC_XPPEN_ARTIST_22HD	0x0047 //that's the added one for xppen artist 22
 
 #define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81	0x0081
 #define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45	0x0045

From becc5f4627035e63f7c65152f8fb51fc0ed1a086 Mon Sep 17 00:00:00 2001
From: Lorenzo Zanetti <mihares@msn.com>
Date: Sun, 15 Apr 2018 20:39:40 +0200
Subject: [PATCH 2/3] Added the report descriptor for the Uclogic XPPen Artist
 22HD. It's only one of the interfaces found in albisaro's driver --the firts
 one seems to be redundant, and doesn't actually drive the pen. Still the
 weird mouse and pen seen as separate devices --with the pen appearing only
 after the first contact with the monitor. Have no idea why that happens.

---
 hid-uclogic-core.c  |  4 ++
 hid-uclogic-rdesc.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
 hid-uclogic-rdesc.h |  4 ++
 3 files changed, 103 insertions(+)

diff --git a/hid-uclogic-core.c b/hid-uclogic-core.c
index 9bccfbdc..3cbf5ab3 100644
--- a/hid-uclogic-core.c
+++ b/hid-uclogic-core.c
@@ -129,6 +129,10 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 			break;
 		}
 		break;
+	case USB_DEVICE_ID_UCLOGIC_XPPEN_ARTIST_22HD:
+		rdesc = uclogic_rdesc_xppen_artist22HD_arr;
+		*rsize = uclogic_rdesc_xppen_artist22HD_size;
+		break;
 	}
 
 	return rdesc;
diff --git a/hid-uclogic-rdesc.c b/hid-uclogic-rdesc.c
index 638463b4..7e750ec7 100644
--- a/hid-uclogic-rdesc.c
+++ b/hid-uclogic-rdesc.c
@@ -717,3 +717,98 @@ const __u8 uclogic_rdesc_buttonpad_arr[] = {
 const size_t uclogic_rdesc_buttonpad_size =
 			sizeof(uclogic_rdesc_buttonpad_arr);
 
+/* fixed uclogic xppen artist 22HD report descriptor (old interface 1) */
+const __u8 uclogic_rdesc_xppen_artist22HD_arr[] = {
+	0x05, 0x01,         /*  Usage Page (Desktop),                   */
+	0x09, 0x02,         /*  Usage (Mouse),                          */
+	0xA1, 0x01,         /*  Collection (Application),               */
+	0x09, 0x01,         /*      Usage (Pointer),                    */
+	0xA1, 0x00,         /*      Collection (Physical),              */
+	0x85, 0x01,         /*          Report ID (1),                  */
+	0x05, 0x09,         /*          Usage Page (Button),            */
+	0x19, 0x01,         /*          Usage Minimum (01h),            */
+	0x29, 0x05,         /*          Usage Maximum (05h),            */
+	0x95, 0x05,         /*          Report Count (5),               */
+	0x75, 0x01,         /*          Report Size (1),                */
+	0x15, 0x00,         /*          Logical Minimum (0),            */
+	0x25, 0x01,         /*          Logical Maximum (1),            */
+	0x81, 0x02,         /*          Input (Variable),               */
+	0x95, 0x03,         /*          Report Count (3),               */
+	0x81, 0x01,         /*          Input (Constant),               */
+	0x05, 0x01,         /*          Usage Page (Desktop),           */
+	0x09, 0x30,         /*          Usage (X),                      */
+	0x09, 0x31,         /*          Usage (Y),                      */
+	0x95, 0x02,         /*          Report Count (2),               */
+	0x75, 0x10,         /*          Report Size (16),               */
+	0x16, 0x00, 0x80,   /*          Logical Minimum (-32768),       */
+	0x26, 0xFF, 0x7F,   /*          Logical Maximum (32767),        */
+	0x81, 0x06,         /*          Input (Variable, Relative),     */
+	0x09, 0x38,         /*          Usage (Wheel),                  */
+	0x15, 0x81,         /*          Logical Minimum (-127),         */
+	0x25, 0x7F,         /*          Logical Maximum (127),          */
+	0x95, 0x01,         /*          Report Count (1),               */
+	0x75, 0x08,         /*          Report Size (8),                */
+	0x81, 0x06,         /*          Input (Variable, Relative),     */
+	0x05, 0x0C,         /*          Usage Page (Consumer),          */
+	0x0A, 0x38, 0x02,   /*          Usage (AC Pan),                 */
+	0x95, 0x01,         /*          Report Count (1),               */
+	0x75, 0x08,         /*          Report Size (8),                */
+	0x81, 0x06,         /*          Input (Variable, Relative),     */
+	0xC0,               /*      End Collection,                     */
+	0xC0,               /*  End Collection,                         */
+	0x06, 0x01, 0xFF,   /*  Usage Page (FF01h),                     */
+	0x09, 0x00,         /*  Usage (00h),                            */
+	0xA1, 0x01,         /*  Collection (Application),               */
+	0x85, 0x08,         /*      Report ID (8),                      */
+	0x15, 0x00,         /*      Logical Minimum (0),                */
+	0x26, 0xFF, 0x00,   /*      Logical Maximum (255),              */
+	0x09, 0x00,         /*      Usage (00h),                        */
+	0x75, 0x08,         /*      Report Size (8),                    */
+	0x95, 0x05,         /*      Report Count (5),                   */
+	0xB1, 0x02,         /*      Feature (Variable),                 */
+	0xC0,               /*  End Collection,                         */
+	0x05, 0x0D,         /*  Usage Page (Digitizer),                 */
+	0x09, 0x02,         /*  Usage (Pen),                            */
+	0xA1, 0x01,         /*  Collection (Application),               */
+	0x85, 0x0A,         /*      Report ID (10),                     */
+	0x09, 0x20,         /*      Usage (Stylus),                     */
+	0xA1, 0x00,         /*      Collection (Physical),              */
+	0x09, 0x42,         /*          Usage (Tip Switch),             */
+	0x09, 0x44,         /*          Usage (Barrel Switch),          */
+	0x09, 0x45,         /*          Usage (Eraser),                 */
+	0x09, 0x3C,         /*          Usage (Invert),                 */
+	0x09, 0x43,         /*          Usage (Secondary Tip Switch),   */
+	0x09, 0x44,         /*          Usage (Barrel Switch),          */
+	0x15, 0x00,         /*          Logical Minimum (0),            */
+	0x25, 0x01,         /*          Logical Maximum (1),            */
+	0x75, 0x01,         /*          Report Size (1),                */
+	0x95, 0x06,         /*          Report Count (6),               */
+	0x81, 0x02,         /*          Input (Variable),               */
+	0x09, 0x32,         /*          Usage (In Range),               */
+	0x75, 0x01,         /*          Report Size (1),                */
+	0x95, 0x01,         /*          Report Count (1),               */
+	0x81, 0x02,         /*          Input (Variable),               */
+	0x81, 0x03,         /*          Input (Constant, Variable),     */
+	0x05, 0x01,         /*          Usage Page (Desktop),           */
+	0x09, 0x30,         /*          Usage (X),                      */
+	0x09, 0x31,         /*          Usage (Y),                      */
+	0x55, 0x0D,         /*          Unit Exponent (13),             */
+	0x65, 0x33,         /*          Unit (Inch^3),                  */
+	0x26, 0x00, 0x08,   /*          Logical Maximum (2048),         */
+	0x35, 0x00,         /*          Physical Minimum (0),           */
+	0x46, 0x00, 0x08,   /*          Physical Maximum (2048),        */
+	0x75, 0x10,         /*          Report Size (16),               */
+	0x95, 0x02,         /*          Report Count (2),               */
+	0x81, 0x02,         /*          Input (Variable),               */
+	0x05, 0x0D,         /*          Usage Page (Digitizer),         */
+	0x09, 0x30,         /*          Usage (Tip Pressure),           */
+	0x26, 0xFF, 0x07,   /*          Logical Maximum (2047),         */
+	0x75, 0x10,         /*          Report Size (16),               */
+	0x95, 0x01,         /*          Report Count (1),               */
+	0x81, 0x02,         /*          Input (Variable),               */
+	0xC0,               /*      End Collection,                     */
+	0xC0                /*  End Collection                          */
+};
+
+const size_t uclogic_rdesc_xppen_artist22HD_size =
+			sizeof(uclogic_rdesc_xppen_artist22HD_arr);
diff --git a/hid-uclogic-rdesc.h b/hid-uclogic-rdesc.h
index 6e58d44f..f173e18b 100644
--- a/hid-uclogic-rdesc.h
+++ b/hid-uclogic-rdesc.h
@@ -107,4 +107,8 @@ extern const size_t uclogic_rdesc_ugee_ex07_template_size;
 extern const __u8 uclogic_rdesc_buttonpad_arr[];
 extern const size_t uclogic_rdesc_buttonpad_size;
 
+/* Report descriptor for the XP pen artist 22HD */
+extern const __u8 uclogic_rdesc_xppen_artist22HD_arr[];
+extern const size_t uclogic_rdesc_xppen_artist22HD_size;
+
 #endif /* _HID_UCLOGIC_RDESC_H */

From f90934b55909e0187d9d41d8552404bb97794f38 Mon Sep 17 00:00:00 2001
From: Lorenzo Zanetti <mihares@msn.com>
Date: Thu, 5 Jul 2018 21:03:31 +0200
Subject: [PATCH 3/3] Three tiny modifications needed to get rid of a warning
 and a complaint about a missing flag  --that looked like it came out of the
 Kernel itself. But who knows. Seem to work now.

---
 hid-uclogic-core.c  | 2 +-
 hid-uclogic-rdesc.c | 2 +-
 hid-uclogic-rdesc.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hid-uclogic-core.c b/hid-uclogic-core.c
index 3cbf5ab3..a60f6a2f 100644
--- a/hid-uclogic-core.c
+++ b/hid-uclogic-core.c
@@ -434,7 +434,7 @@ static int uclogic_probe(struct hid_device *hdev,
 	 * than the pen, so use QUIRK_MULTI_INPUT for all tablets.
 	 */
 	hdev->quirks |= HID_QUIRK_MULTI_INPUT;
-	hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT;
+	/* hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; */
 
 	/* Allocate and assign driver data */
 	drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
diff --git a/hid-uclogic-rdesc.c b/hid-uclogic-rdesc.c
index 7e750ec7..2bb9724f 100644
--- a/hid-uclogic-rdesc.c
+++ b/hid-uclogic-rdesc.c
@@ -718,7 +718,7 @@ const size_t uclogic_rdesc_buttonpad_size =
 			sizeof(uclogic_rdesc_buttonpad_arr);
 
 /* fixed uclogic xppen artist 22HD report descriptor (old interface 1) */
-const __u8 uclogic_rdesc_xppen_artist22HD_arr[] = {
+__u8 uclogic_rdesc_xppen_artist22HD_arr[] = {
 	0x05, 0x01,         /*  Usage Page (Desktop),                   */
 	0x09, 0x02,         /*  Usage (Mouse),                          */
 	0xA1, 0x01,         /*  Collection (Application),               */
diff --git a/hid-uclogic-rdesc.h b/hid-uclogic-rdesc.h
index f173e18b..924508b0 100644
--- a/hid-uclogic-rdesc.h
+++ b/hid-uclogic-rdesc.h
@@ -108,7 +108,7 @@ extern const __u8 uclogic_rdesc_buttonpad_arr[];
 extern const size_t uclogic_rdesc_buttonpad_size;
 
 /* Report descriptor for the XP pen artist 22HD */
-extern const __u8 uclogic_rdesc_xppen_artist22HD_arr[];
+extern __u8 uclogic_rdesc_xppen_artist22HD_arr[];
 extern const size_t uclogic_rdesc_xppen_artist22HD_size;
 
 #endif /* _HID_UCLOGIC_RDESC_H */