summaryrefslogtreecommitdiffstats
path: root/hidd/sdp.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2004-07-29 09:08:35 +0000
committerMarcel Holtmann <marcel@holtmann.org>2004-07-29 09:08:35 +0000
commit560a2768ee675ed0abd685f062eef1eab58a304f (patch)
treea78ce6c3bdc12cf18e357b7362966c266879d7f5 /hidd/sdp.c
parenta488cafcdbd15928f43cbe3096853b894a4cc63f (diff)
Add EPoX endian quirk for buggy keyboards
Diffstat (limited to 'hidd/sdp.c')
-rw-r--r--hidd/sdp.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/hidd/sdp.c b/hidd/sdp.c
index 31020130..24ed4b53 100644
--- a/hidd/sdp.c
+++ b/hidd/sdp.c
@@ -32,14 +32,6 @@
#include <stdio.h>
#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <sys/poll.h>
-#include <sys/ioctl.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
@@ -49,6 +41,31 @@
#include "hidd.h"
+static void epox_endian_quirk(unsigned char *data, int size)
+{
+ /* USAGE_PAGE (Keyboard) 05 07
+ * USAGE_MINIMUM (0) 19 00
+ * USAGE_MAXIMUM (65280) 2A 00 FF <= must be FF 00
+ * LOGICAL_MINIMUM (0) 15 00
+ * LOGICAL_MAXIMUM (65280) 26 00 FF <= must be FF 00
+ */
+ unsigned char pattern[] = { 0x05, 0x07, 0x19, 0x00, 0x2a, 0x00, 0xff,
+ 0x15, 0x00, 0x26, 0x00, 0xff };
+ int i;
+
+ if (!data)
+ return;
+
+ for (i = 0; i < size - sizeof(pattern); i++) {
+ if (!memcmp(data + i, pattern, sizeof(pattern))) {
+ data[i + 5] = 0xff;
+ data[i + 6] = 0x00;
+ data[i + 10] = 0xff;
+ data[i + 11] = 0x00;
+ }
+ }
+}
+
int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *req)
{
uint32_t range = 0x0000ffff;
@@ -140,6 +157,7 @@ int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *r
if (req->rd_data) {
memcpy(req->rd_data, (unsigned char *) pdlist->val.str, pdlist->unitSize);
req->rd_size = pdlist->unitSize;
+ epox_endian_quirk(req->rd_data, req->rd_size);
}
}