From ce24174e93d82e1f7d62a26cd6de7b519a6f8e2f Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 13 Feb 2013 22:51:20 -0500
Subject: [PATCH] first step towards supporting wiimote plus (does not work yet
 but at least it is being recognized).

---
 l2ork_addons/cwiid/libcwiid/bluetooth.c      | 8 ++++++--
 l2ork_addons/cwiid/libcwiid/cwiid_internal.h | 3 +++
 l2ork_addons/cwiid/libcwiid/process.c        | 2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/l2ork_addons/cwiid/libcwiid/bluetooth.c b/l2ork_addons/cwiid/libcwiid/bluetooth.c
index 8019d5729..ed0314165 100644
--- a/l2ork_addons/cwiid/libcwiid/bluetooth.c
+++ b/l2ork_addons/cwiid/libcwiid/bluetooth.c
@@ -115,9 +115,12 @@ int cwiid_get_bdinfo_array(int dev_id, unsigned int timeout, int max_bdinfo,
 	     i++) {
 		/* Filter by class */
 		if (!(flags & BT_NO_WIIMOTE_FILTER) &&
-		  ((dev_list[i].dev_class[0] != WIIMOTE_CLASS_0) ||
+		  (((dev_list[i].dev_class[0] != WIIMOTE_CLASS_0) ||
 		   (dev_list[i].dev_class[1] != WIIMOTE_CLASS_1) ||
-		   (dev_list[i].dev_class[2] != WIIMOTE_CLASS_2))) {
+		   (dev_list[i].dev_class[2] != WIIMOTE_CLASS_2)) &&
+		  ((dev_list[i].dev_class[0] != WIIMOTE_PLUS_CLASS_0) ||
+		   (dev_list[i].dev_class[1] != WIIMOTE_PLUS_CLASS_1) ||
+		   (dev_list[i].dev_class[2] != WIIMOTE_CLASS_2)))) {
 			continue;
 		}
 
@@ -132,6 +135,7 @@ int cwiid_get_bdinfo_array(int dev_id, unsigned int timeout, int max_bdinfo,
 		/* Filter by name */
 		if (!(flags & BT_NO_WIIMOTE_FILTER) &&
 		  strncmp((*bdinfo)[bdinfo_count].name, WIIMOTE_NAME, BT_NAME_LEN) &&
+		  strncmp((*bdinfo)[bdinfo_count].name, WIIMOTE_PLUS_NAME, BT_NAME_LEN) &&
 		  strncmp((*bdinfo)[bdinfo_count].name, WIIBALANCE_NAME, BT_NAME_LEN)) {
 			continue;
 		}
diff --git a/l2ork_addons/cwiid/libcwiid/cwiid_internal.h b/l2ork_addons/cwiid/libcwiid/cwiid_internal.h
index 52a7fc4b9..fe1e96dff 100644
--- a/l2ork_addons/cwiid/libcwiid/cwiid_internal.h
+++ b/l2ork_addons/cwiid/libcwiid/cwiid_internal.h
@@ -79,10 +79,13 @@
 
 /* Wiimote specific magic numbers */
 #define WIIMOTE_NAME "Nintendo RVL-CNT-01"
+#define WIIMOTE_PLUS_NAME "Nintendo RVL-CNT-01-TR"
 #define WIIBALANCE_NAME "Nintendo RVL-WBC-01"
 #define WIIMOTE_CLASS_0 0x04
 #define WIIMOTE_CLASS_1 0x25
 #define WIIMOTE_CLASS_2 0x00
+#define WIIMOTE_PLUS_CLASS_0 0x08
+#define WIIMOTE_PLUS_CLASS_1 0x05
 
 /* Wiimote port/channel/PSMs */
 #define CTL_PSM	17
diff --git a/l2ork_addons/cwiid/libcwiid/process.c b/l2ork_addons/cwiid/libcwiid/process.c
index 226b3c8d3..31c8f1fd3 100644
--- a/l2ork_addons/cwiid/libcwiid/process.c
+++ b/l2ork_addons/cwiid/libcwiid/process.c
@@ -369,7 +369,7 @@ int process_write(struct wiimote *wiimote, unsigned char *data)
 	struct rw_mesg rw_mesg;
 
 	if (wiimote->rw_status != RW_WRITE) {
-		cwiid_err(wiimote, "Received unexpected write report");
+		cwiid_err(wiimote, "Received unexpected write report %d", wiimote->rw_status);
 		return -1;
 	}
 
-- 
GitLab