usb_hid.c (194677) | usb_hid.c (195967) |
---|---|
1/* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ 2 3 4#include <sys/cdefs.h> | 1/* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ 2 3 4#include <sys/cdefs.h> |
5__FBSDID("$FreeBSD: head/sys/dev/usb/usb_hid.c 194677 2009-06-23 02:19:59Z thompsa $"); | 5__FBSDID("$FreeBSD: head/sys/dev/usb/usb_hid.c 195967 2009-07-30 00:17:08Z alfred $"); |
6/*- 7 * Copyright (c) 1998 The NetBSD Foundation, Inc. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to The NetBSD Foundation 11 * by Lennart Augustsson (lennart@augustsson.net) at 12 * Carlstedt Research & Technology. 13 * --- 59 unchanged lines hidden (view full) --- 73#include <dev/usb/usb_device.h> 74#include <dev/usb/usb_request.h> 75 76static void hid_clear_local(struct hid_item *); 77static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize); 78 79#define MAXUSAGE 64 80#define MAXPUSH 4 | 6/*- 7 * Copyright (c) 1998 The NetBSD Foundation, Inc. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to The NetBSD Foundation 11 * by Lennart Augustsson (lennart@augustsson.net) at 12 * Carlstedt Research & Technology. 13 * --- 59 unchanged lines hidden (view full) --- 73#include <dev/usb/usb_device.h> 74#include <dev/usb/usb_request.h> 75 76static void hid_clear_local(struct hid_item *); 77static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize); 78 79#define MAXUSAGE 64 80#define MAXPUSH 4 |
81#define MAXID 16 82 83struct hid_pos_data { 84 int32_t rid; 85 uint32_t pos; 86}; 87 |
|
81struct hid_data { 82 const uint8_t *start; 83 const uint8_t *end; 84 const uint8_t *p; 85 struct hid_item cur[MAXPUSH]; | 88struct hid_data { 89 const uint8_t *start; 90 const uint8_t *end; 91 const uint8_t *p; 92 struct hid_item cur[MAXPUSH]; |
93 struct hid_pos_data last_pos[MAXID]; |
|
86 int32_t usages_min[MAXUSAGE]; 87 int32_t usages_max[MAXUSAGE]; 88 int32_t usage_last; /* last seen usage */ 89 uint32_t loc_size; /* last seen size */ 90 uint32_t loc_count; /* last seen count */ 91 uint8_t kindset; /* we have 5 kinds so 8 bits are enough */ 92 uint8_t pushlevel; /* current pushlevel */ 93 uint8_t ncount; /* end usage item count */ --- 20 unchanged lines hidden (view full) --- 114 c->designator_minimum = 0; 115 c->designator_maximum = 0; 116 c->string_index = 0; 117 c->string_minimum = 0; 118 c->string_maximum = 0; 119 c->set_delimiter = 0; 120} 121 | 94 int32_t usages_min[MAXUSAGE]; 95 int32_t usages_max[MAXUSAGE]; 96 int32_t usage_last; /* last seen usage */ 97 uint32_t loc_size; /* last seen size */ 98 uint32_t loc_count; /* last seen count */ 99 uint8_t kindset; /* we have 5 kinds so 8 bits are enough */ 100 uint8_t pushlevel; /* current pushlevel */ 101 uint8_t ncount; /* end usage item count */ --- 20 unchanged lines hidden (view full) --- 122 c->designator_minimum = 0; 123 c->designator_maximum = 0; 124 c->string_index = 0; 125 c->string_minimum = 0; 126 c->string_maximum = 0; 127 c->set_delimiter = 0; 128} 129 |
130static void 131hid_switch_rid(struct hid_data *s, struct hid_item *c, int32_t next_rID) 132{ 133 uint8_t i; 134 135 /* check for same report ID - optimise */ 136 137 if (c->report_ID == next_rID) 138 return; 139 140 /* save current position for current rID */ 141 142 if (c->report_ID == 0) { 143 i = 0; 144 } else { 145 for (i = 1; i != MAXID; i++) { 146 if (s->last_pos[i].rid == c->report_ID) 147 break; 148 if (s->last_pos[i].rid == 0) 149 break; 150 } 151 } 152 if (i != MAXID) { 153 s->last_pos[i].rid = c->report_ID; 154 s->last_pos[i].pos = c->loc.pos; 155 } 156 157 /* store next report ID */ 158 159 c->report_ID = next_rID; 160 161 /* lookup last position for next rID */ 162 163 if (next_rID == 0) { 164 i = 0; 165 } else { 166 for (i = 1; i != MAXID; i++) { 167 if (s->last_pos[i].rid == next_rID) 168 break; 169 if (s->last_pos[i].rid == 0) 170 break; 171 } 172 } 173 if (i != MAXID) { 174 s->last_pos[i].rid = next_rID; 175 c->loc.pos = s->last_pos[i].pos; 176 } else { 177 DPRINTF("Out of RID entries, position is set to zero!\n"); 178 c->loc.pos = 0; 179 } 180} 181 |
|
122/*------------------------------------------------------------------------* 123 * hid_start_parse 124 *------------------------------------------------------------------------*/ 125struct hid_data * 126hid_start_parse(const void *d, usb_size_t len, int kindset) 127{ 128 struct hid_data *s; 129 --- 238 unchanged lines hidden (view full) --- 368 case 6: 369 c->unit = dval; 370 break; 371 case 7: 372 /* mask because value is unsigned */ 373 s->loc_size = dval & mask; 374 break; 375 case 8: | 182/*------------------------------------------------------------------------* 183 * hid_start_parse 184 *------------------------------------------------------------------------*/ 185struct hid_data * 186hid_start_parse(const void *d, usb_size_t len, int kindset) 187{ 188 struct hid_data *s; 189 --- 238 unchanged lines hidden (view full) --- 428 case 6: 429 c->unit = dval; 430 break; 431 case 7: 432 /* mask because value is unsigned */ 433 s->loc_size = dval & mask; 434 break; 435 case 8: |
376 c->report_ID = dval; 377 /* new report - reset position */ 378 c->loc.pos = 0; | 436 hid_switch_rid(s, c, dval); |
379 break; 380 case 9: 381 /* mask because value is unsigned */ 382 s->loc_count = dval & mask; 383 break; 384 case 10: /* Push */ 385 s->pushlevel ++; 386 if (s->pushlevel < MAXPUSH) { --- 358 unchanged lines hidden --- | 437 break; 438 case 9: 439 /* mask because value is unsigned */ 440 s->loc_count = dval & mask; 441 break; 442 case 10: /* Push */ 443 s->pushlevel ++; 444 if (s->pushlevel < MAXPUSH) { --- 358 unchanged lines hidden --- |