Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256824
b: refs/heads/master
c: a4d1919
h: refs/heads/master
v: v3
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jul 11, 2011
1 parent 257047e commit 8f0961c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23c063cb02b69244bbc215cb81c2cad0208fbecf
refs/heads/master: a4d19197627e2a8645cccd9039edf513c6384297
18 changes: 18 additions & 0 deletions trunk/drivers/hid/hid-wiimote.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,22 @@ static int wiimote_input_event(struct input_dev *dev, unsigned int type,
return 0;
}

struct wiiproto_handler {
__u8 id;
size_t size;
void (*func)(struct wiimote_data *wdata, const __u8 *payload);
};

static struct wiiproto_handler handlers[] = {
{ .id = 0 }
};

static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
u8 *raw_data, int size)
{
struct wiimote_data *wdata = hid_get_drvdata(hdev);
struct wiiproto_handler *h;
int i;

if (!atomic_read(&wdata->ready))
return -EBUSY;
Expand All @@ -143,6 +155,12 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
if (size < 1)
return -EINVAL;

for (i = 0; handlers[i].id; ++i) {
h = &handlers[i];
if (h->id == raw_data[0] && h->size < size)
h->func(wdata, &raw_data[1]);
}

return 0;
}

Expand Down

0 comments on commit 8f0961c

Please sign in to comment.