input: added epox_endian_quirk function

This commit is contained in:
Claudio Takahasi 2007-08-03 13:43:24 +00:00
parent ebd3c8b3a8
commit 2639da11e0

View File

@ -181,6 +181,31 @@ static int get_handles(struct pending_req *pr, const char *uuid,
return 0;
}
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;
}
}
}
static void extract_hid_record(sdp_record_t *rec, struct hidp_connadd_req *req)
{
sdp_data_t *pdlist, *pdlist2;
@ -233,6 +258,7 @@ static void extract_hid_record(sdp_record_t *rec, struct hidp_connadd_req *req)
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);
}
}
}