From 560a2768ee675ed0abd685f062eef1eab58a304f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 29 Jul 2004 09:08:35 +0000 Subject: Add EPoX endian quirk for buggy keyboards --- hidd/sdp.c | 34 ++++++++++++++++++++++++++-------- 1 file 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 #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include @@ -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); } } -- cgit