2 * Roccat Pyra driver for Linux
4 * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
15 * Roccat Pyra is a mobile gamer mouse which comes in wired and wireless
16 * variant. Wireless variant is not tested.
17 * Userland tools can be found at http://sourceforge.net/projects/roccat
20 #include <linux/device.h>
21 #include <linux/input.h>
22 #include <linux/hid.h>
23 #include <linux/usb.h>
24 #include <linux/module.h>
25 #include <linux/slab.h>
27 #include "hid-roccat.h"
28 #include "hid-roccat-pyra.h"
30 static uint profile_numbers
[5] = {0, 1, 2, 3, 4};
32 /* pyra_class is used for creating sysfs attributes via roccat char device */
33 static struct class *pyra_class
;
35 static void profile_activated(struct pyra_device
*pyra
,
36 unsigned int new_profile
)
38 pyra
->actual_profile
= new_profile
;
39 pyra
->actual_cpi
= pyra
->profile_settings
[pyra
->actual_profile
].y_cpi
;
42 static int pyra_send_control(struct usb_device
*usb_dev
, int value
,
43 enum pyra_control_requests request
)
46 struct pyra_control control
;
48 if ((request
== PYRA_CONTROL_REQUEST_PROFILE_SETTINGS
||
49 request
== PYRA_CONTROL_REQUEST_PROFILE_BUTTONS
) &&
50 (value
< 0 || value
> 4))
53 control
.command
= PYRA_COMMAND_CONTROL
;
54 control
.value
= value
;
55 control
.request
= request
;
57 len
= usb_control_msg(usb_dev
, usb_sndctrlpipe(usb_dev
, 0),
58 USB_REQ_SET_CONFIGURATION
,
59 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
60 PYRA_USB_COMMAND_CONTROL
, 0, (char *)&control
,
61 sizeof(struct pyra_control
),
62 USB_CTRL_SET_TIMEOUT
);
64 if (len
!= sizeof(struct pyra_control
))
70 static int pyra_receive_control_status(struct usb_device
*usb_dev
)
73 struct pyra_control control
;
78 len
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
79 USB_REQ_CLEAR_FEATURE
,
80 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
|
82 PYRA_USB_COMMAND_CONTROL
, 0, (char *)&control
,
83 sizeof(struct pyra_control
),
84 USB_CTRL_SET_TIMEOUT
);
86 /* requested too early, try again */
87 } while (len
== -EPROTO
);
89 if (len
== sizeof(struct pyra_control
) &&
90 control
.command
== PYRA_COMMAND_CONTROL
&&
91 control
.request
== PYRA_CONTROL_REQUEST_STATUS
&&
95 hid_err(usb_dev
, "receive control status: unknown response 0x%x 0x%x\n",
96 control
.request
, control
.value
);
101 static int pyra_get_profile_settings(struct usb_device
*usb_dev
,
102 struct pyra_profile_settings
*buf
, int number
)
106 retval
= pyra_send_control(usb_dev
, number
,
107 PYRA_CONTROL_REQUEST_PROFILE_SETTINGS
);
112 retval
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
113 USB_REQ_CLEAR_FEATURE
,
114 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_IN
,
115 PYRA_USB_COMMAND_PROFILE_SETTINGS
, 0, (char *)buf
,
116 sizeof(struct pyra_profile_settings
),
117 USB_CTRL_SET_TIMEOUT
);
119 if (retval
!= sizeof(struct pyra_profile_settings
))
125 static int pyra_get_profile_buttons(struct usb_device
*usb_dev
,
126 struct pyra_profile_buttons
*buf
, int number
)
130 retval
= pyra_send_control(usb_dev
, number
,
131 PYRA_CONTROL_REQUEST_PROFILE_BUTTONS
);
136 retval
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
137 USB_REQ_CLEAR_FEATURE
,
138 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_IN
,
139 PYRA_USB_COMMAND_PROFILE_BUTTONS
, 0, (char *)buf
,
140 sizeof(struct pyra_profile_buttons
),
141 USB_CTRL_SET_TIMEOUT
);
143 if (retval
!= sizeof(struct pyra_profile_buttons
))
149 static int pyra_get_settings(struct usb_device
*usb_dev
,
150 struct pyra_settings
*buf
)
153 len
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
154 USB_REQ_CLEAR_FEATURE
,
155 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_IN
,
156 PYRA_USB_COMMAND_SETTINGS
, 0, buf
,
157 sizeof(struct pyra_settings
), USB_CTRL_SET_TIMEOUT
);
158 if (len
!= sizeof(struct pyra_settings
))
163 static int pyra_get_info(struct usb_device
*usb_dev
, struct pyra_info
*buf
)
166 len
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
167 USB_REQ_CLEAR_FEATURE
,
168 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_IN
,
169 PYRA_USB_COMMAND_INFO
, 0, buf
,
170 sizeof(struct pyra_info
), USB_CTRL_SET_TIMEOUT
);
171 if (len
!= sizeof(struct pyra_info
))
176 static int pyra_set_profile_settings(struct usb_device
*usb_dev
,
177 struct pyra_profile_settings
const *settings
)
180 len
= usb_control_msg(usb_dev
, usb_sndctrlpipe(usb_dev
, 0),
181 USB_REQ_SET_CONFIGURATION
,
182 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
183 PYRA_USB_COMMAND_PROFILE_SETTINGS
, 0, (char *)settings
,
184 sizeof(struct pyra_profile_settings
),
185 USB_CTRL_SET_TIMEOUT
);
186 if (len
!= sizeof(struct pyra_profile_settings
))
188 if (pyra_receive_control_status(usb_dev
))
193 static int pyra_set_profile_buttons(struct usb_device
*usb_dev
,
194 struct pyra_profile_buttons
const *buttons
)
197 len
= usb_control_msg(usb_dev
, usb_sndctrlpipe(usb_dev
, 0),
198 USB_REQ_SET_CONFIGURATION
,
199 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
200 PYRA_USB_COMMAND_PROFILE_BUTTONS
, 0, (char *)buttons
,
201 sizeof(struct pyra_profile_buttons
),
202 USB_CTRL_SET_TIMEOUT
);
203 if (len
!= sizeof(struct pyra_profile_buttons
))
205 if (pyra_receive_control_status(usb_dev
))
210 static int pyra_set_settings(struct usb_device
*usb_dev
,
211 struct pyra_settings
const *settings
)
214 len
= usb_control_msg(usb_dev
, usb_sndctrlpipe(usb_dev
, 0),
215 USB_REQ_SET_CONFIGURATION
,
216 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
217 PYRA_USB_COMMAND_SETTINGS
, 0, (char *)settings
,
218 sizeof(struct pyra_settings
), USB_CTRL_SET_TIMEOUT
);
219 if (len
!= sizeof(struct pyra_settings
))
221 if (pyra_receive_control_status(usb_dev
))
226 static ssize_t
pyra_sysfs_read_profilex_settings(struct file
*fp
,
227 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
228 loff_t off
, size_t count
)
231 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
232 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
234 if (off
>= sizeof(struct pyra_profile_settings
))
237 if (off
+ count
> sizeof(struct pyra_profile_settings
))
238 count
= sizeof(struct pyra_profile_settings
) - off
;
240 mutex_lock(&pyra
->pyra_lock
);
241 memcpy(buf
, ((char const *)&pyra
->profile_settings
[*(uint
*)(attr
->private)]) + off
,
243 mutex_unlock(&pyra
->pyra_lock
);
248 static ssize_t
pyra_sysfs_read_profilex_buttons(struct file
*fp
,
249 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
250 loff_t off
, size_t count
)
253 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
254 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
256 if (off
>= sizeof(struct pyra_profile_buttons
))
259 if (off
+ count
> sizeof(struct pyra_profile_buttons
))
260 count
= sizeof(struct pyra_profile_buttons
) - off
;
262 mutex_lock(&pyra
->pyra_lock
);
263 memcpy(buf
, ((char const *)&pyra
->profile_buttons
[*(uint
*)(attr
->private)]) + off
,
265 mutex_unlock(&pyra
->pyra_lock
);
270 static ssize_t
pyra_sysfs_write_profile_settings(struct file
*fp
,
271 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
272 loff_t off
, size_t count
)
275 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
276 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
277 struct usb_device
*usb_dev
= interface_to_usbdev(to_usb_interface(dev
));
281 struct pyra_profile_settings
*profile_settings
;
283 if (off
!= 0 || count
!= sizeof(struct pyra_profile_settings
))
286 profile_number
= ((struct pyra_profile_settings
const *)buf
)->number
;
287 profile_settings
= &pyra
->profile_settings
[profile_number
];
289 mutex_lock(&pyra
->pyra_lock
);
290 difference
= memcmp(buf
, profile_settings
,
291 sizeof(struct pyra_profile_settings
));
293 retval
= pyra_set_profile_settings(usb_dev
,
294 (struct pyra_profile_settings
const *)buf
);
296 memcpy(profile_settings
, buf
,
297 sizeof(struct pyra_profile_settings
));
299 mutex_unlock(&pyra
->pyra_lock
);
304 return sizeof(struct pyra_profile_settings
);
307 static ssize_t
pyra_sysfs_write_profile_buttons(struct file
*fp
,
308 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
309 loff_t off
, size_t count
)
312 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
313 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
314 struct usb_device
*usb_dev
= interface_to_usbdev(to_usb_interface(dev
));
318 struct pyra_profile_buttons
*profile_buttons
;
320 if (off
!= 0 || count
!= sizeof(struct pyra_profile_buttons
))
323 profile_number
= ((struct pyra_profile_buttons
const *)buf
)->number
;
324 profile_buttons
= &pyra
->profile_buttons
[profile_number
];
326 mutex_lock(&pyra
->pyra_lock
);
327 difference
= memcmp(buf
, profile_buttons
,
328 sizeof(struct pyra_profile_buttons
));
330 retval
= pyra_set_profile_buttons(usb_dev
,
331 (struct pyra_profile_buttons
const *)buf
);
333 memcpy(profile_buttons
, buf
,
334 sizeof(struct pyra_profile_buttons
));
336 mutex_unlock(&pyra
->pyra_lock
);
341 return sizeof(struct pyra_profile_buttons
);
344 static ssize_t
pyra_sysfs_read_settings(struct file
*fp
,
345 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
346 loff_t off
, size_t count
)
349 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
350 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
352 if (off
>= sizeof(struct pyra_settings
))
355 if (off
+ count
> sizeof(struct pyra_settings
))
356 count
= sizeof(struct pyra_settings
) - off
;
358 mutex_lock(&pyra
->pyra_lock
);
359 memcpy(buf
, ((char const *)&pyra
->settings
) + off
, count
);
360 mutex_unlock(&pyra
->pyra_lock
);
365 static ssize_t
pyra_sysfs_write_settings(struct file
*fp
,
366 struct kobject
*kobj
, struct bin_attribute
*attr
, char *buf
,
367 loff_t off
, size_t count
)
370 container_of(kobj
, struct device
, kobj
)->parent
->parent
;
371 struct pyra_device
*pyra
= hid_get_drvdata(dev_get_drvdata(dev
));
372 struct usb_device
*usb_dev
= interface_to_usbdev(to_usb_interface(dev
));
376 if (off
!= 0 || count
!= sizeof(struct pyra_settings
))
379 mutex_lock(&pyra
->pyra_lock
);
380 difference
= memcmp(buf
, &pyra
->settings
, sizeof(struct pyra_settings
));
382 retval
= pyra_set_settings(usb_dev
,
383 (struct pyra_settings
const *)buf
);
385 memcpy(&pyra
->settings
, buf
,
386 sizeof(struct pyra_settings
));
388 mutex_unlock(&pyra
->pyra_lock
);
393 profile_activated(pyra
, pyra
->settings
.startup_profile
);
395 return sizeof(struct pyra_settings
);
399 static ssize_t
pyra_sysfs_show_actual_cpi(struct device
*dev
,
400 struct device_attribute
*attr
, char *buf
)
402 struct pyra_device
*pyra
=
403 hid_get_drvdata(dev_get_drvdata(dev
->parent
->parent
));
404 return snprintf(buf
, PAGE_SIZE
, "%d\n", pyra
->actual_cpi
);
407 static ssize_t
pyra_sysfs_show_actual_profile(struct device
*dev
,
408 struct device_attribute
*attr
, char *buf
)
410 struct pyra_device
*pyra
=
411 hid_get_drvdata(dev_get_drvdata(dev
->parent
->parent
));
412 return snprintf(buf
, PAGE_SIZE
, "%d\n", pyra
->actual_profile
);
415 static ssize_t
pyra_sysfs_show_firmware_version(struct device
*dev
,
416 struct device_attribute
*attr
, char *buf
)
418 struct pyra_device
*pyra
=
419 hid_get_drvdata(dev_get_drvdata(dev
->parent
->parent
));
420 return snprintf(buf
, PAGE_SIZE
, "%d\n", pyra
->firmware_version
);
423 static ssize_t
pyra_sysfs_show_startup_profile(struct device
*dev
,
424 struct device_attribute
*attr
, char *buf
)
426 struct pyra_device
*pyra
=
427 hid_get_drvdata(dev_get_drvdata(dev
->parent
->parent
));
428 return snprintf(buf
, PAGE_SIZE
, "%d\n", pyra
->settings
.startup_profile
);
431 static struct device_attribute pyra_attributes
[] = {
432 __ATTR(actual_cpi
, 0440, pyra_sysfs_show_actual_cpi
, NULL
),
433 __ATTR(actual_profile
, 0440, pyra_sysfs_show_actual_profile
, NULL
),
434 __ATTR(firmware_version
, 0440,
435 pyra_sysfs_show_firmware_version
, NULL
),
436 __ATTR(startup_profile
, 0440,
437 pyra_sysfs_show_startup_profile
, NULL
),
441 static struct bin_attribute pyra_bin_attributes
[] = {
443 .attr
= { .name
= "profile_settings", .mode
= 0220 },
444 .size
= sizeof(struct pyra_profile_settings
),
445 .write
= pyra_sysfs_write_profile_settings
448 .attr
= { .name
= "profile1_settings", .mode
= 0440 },
449 .size
= sizeof(struct pyra_profile_settings
),
450 .read
= pyra_sysfs_read_profilex_settings
,
451 .private = &profile_numbers
[0]
454 .attr
= { .name
= "profile2_settings", .mode
= 0440 },
455 .size
= sizeof(struct pyra_profile_settings
),
456 .read
= pyra_sysfs_read_profilex_settings
,
457 .private = &profile_numbers
[1]
460 .attr
= { .name
= "profile3_settings", .mode
= 0440 },
461 .size
= sizeof(struct pyra_profile_settings
),
462 .read
= pyra_sysfs_read_profilex_settings
,
463 .private = &profile_numbers
[2]
466 .attr
= { .name
= "profile4_settings", .mode
= 0440 },
467 .size
= sizeof(struct pyra_profile_settings
),
468 .read
= pyra_sysfs_read_profilex_settings
,
469 .private = &profile_numbers
[3]
472 .attr
= { .name
= "profile5_settings", .mode
= 0440 },
473 .size
= sizeof(struct pyra_profile_settings
),
474 .read
= pyra_sysfs_read_profilex_settings
,
475 .private = &profile_numbers
[4]
478 .attr
= { .name
= "profile_buttons", .mode
= 0220 },
479 .size
= sizeof(struct pyra_profile_buttons
),
480 .write
= pyra_sysfs_write_profile_buttons
483 .attr
= { .name
= "profile1_buttons", .mode
= 0440 },
484 .size
= sizeof(struct pyra_profile_buttons
),
485 .read
= pyra_sysfs_read_profilex_buttons
,
486 .private = &profile_numbers
[0]
489 .attr
= { .name
= "profile2_buttons", .mode
= 0440 },
490 .size
= sizeof(struct pyra_profile_buttons
),
491 .read
= pyra_sysfs_read_profilex_buttons
,
492 .private = &profile_numbers
[1]
495 .attr
= { .name
= "profile3_buttons", .mode
= 0440 },
496 .size
= sizeof(struct pyra_profile_buttons
),
497 .read
= pyra_sysfs_read_profilex_buttons
,
498 .private = &profile_numbers
[2]
501 .attr
= { .name
= "profile4_buttons", .mode
= 0440 },
502 .size
= sizeof(struct pyra_profile_buttons
),
503 .read
= pyra_sysfs_read_profilex_buttons
,
504 .private = &profile_numbers
[3]
507 .attr
= { .name
= "profile5_buttons", .mode
= 0440 },
508 .size
= sizeof(struct pyra_profile_buttons
),
509 .read
= pyra_sysfs_read_profilex_buttons
,
510 .private = &profile_numbers
[4]
513 .attr
= { .name
= "settings", .mode
= 0660 },
514 .size
= sizeof(struct pyra_settings
),
515 .read
= pyra_sysfs_read_settings
,
516 .write
= pyra_sysfs_write_settings
521 static int pyra_init_pyra_device_struct(struct usb_device
*usb_dev
,
522 struct pyra_device
*pyra
)
524 struct pyra_info
*info
;
527 mutex_init(&pyra
->pyra_lock
);
529 info
= kmalloc(sizeof(struct pyra_info
), GFP_KERNEL
);
532 retval
= pyra_get_info(usb_dev
, info
);
537 pyra
->firmware_version
= info
->firmware_version
;
540 retval
= pyra_get_settings(usb_dev
, &pyra
->settings
);
544 for (i
= 0; i
< 5; ++i
) {
545 retval
= pyra_get_profile_settings(usb_dev
,
546 &pyra
->profile_settings
[i
], i
);
550 retval
= pyra_get_profile_buttons(usb_dev
,
551 &pyra
->profile_buttons
[i
], i
);
556 profile_activated(pyra
, pyra
->settings
.startup_profile
);
561 static int pyra_init_specials(struct hid_device
*hdev
)
563 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
564 struct usb_device
*usb_dev
= interface_to_usbdev(intf
);
565 struct pyra_device
*pyra
;
568 if (intf
->cur_altsetting
->desc
.bInterfaceProtocol
569 == USB_INTERFACE_PROTOCOL_MOUSE
) {
571 pyra
= kzalloc(sizeof(*pyra
), GFP_KERNEL
);
573 hid_err(hdev
, "can't alloc device descriptor\n");
576 hid_set_drvdata(hdev
, pyra
);
578 retval
= pyra_init_pyra_device_struct(usb_dev
, pyra
);
580 hid_err(hdev
, "couldn't init struct pyra_device\n");
584 retval
= roccat_connect(pyra_class
, hdev
);
586 hid_err(hdev
, "couldn't init char dev\n");
588 pyra
->chrdev_minor
= retval
;
589 pyra
->roccat_claimed
= 1;
592 hid_set_drvdata(hdev
, NULL
);
601 static void pyra_remove_specials(struct hid_device
*hdev
)
603 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
604 struct pyra_device
*pyra
;
606 if (intf
->cur_altsetting
->desc
.bInterfaceProtocol
607 == USB_INTERFACE_PROTOCOL_MOUSE
) {
608 pyra
= hid_get_drvdata(hdev
);
609 if (pyra
->roccat_claimed
)
610 roccat_disconnect(pyra
->chrdev_minor
);
611 kfree(hid_get_drvdata(hdev
));
615 static int pyra_probe(struct hid_device
*hdev
, const struct hid_device_id
*id
)
619 retval
= hid_parse(hdev
);
621 hid_err(hdev
, "parse failed\n");
625 retval
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
);
627 hid_err(hdev
, "hw start failed\n");
631 retval
= pyra_init_specials(hdev
);
633 hid_err(hdev
, "couldn't install mouse\n");
644 static void pyra_remove(struct hid_device
*hdev
)
646 pyra_remove_specials(hdev
);
650 static void pyra_keep_values_up_to_date(struct pyra_device
*pyra
,
653 struct pyra_mouse_event_button
const *button_event
;
656 case PYRA_MOUSE_REPORT_NUMBER_BUTTON
:
657 button_event
= (struct pyra_mouse_event_button
const *)data
;
658 switch (button_event
->type
) {
659 case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2
:
660 profile_activated(pyra
, button_event
->data1
- 1);
662 case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI
:
663 pyra
->actual_cpi
= button_event
->data1
;
670 static void pyra_report_to_chrdev(struct pyra_device
const *pyra
,
673 struct pyra_roccat_report roccat_report
;
674 struct pyra_mouse_event_button
const *button_event
;
676 if (data
[0] != PYRA_MOUSE_REPORT_NUMBER_BUTTON
)
679 button_event
= (struct pyra_mouse_event_button
const *)data
;
681 switch (button_event
->type
) {
682 case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2
:
683 case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI
:
684 roccat_report
.type
= button_event
->type
;
685 roccat_report
.value
= button_event
->data1
;
686 roccat_report
.key
= 0;
687 roccat_report_event(pyra
->chrdev_minor
,
688 (uint8_t const *)&roccat_report
,
689 sizeof(struct pyra_roccat_report
));
691 case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO
:
692 case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT
:
693 case PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH
:
694 if (button_event
->data2
== PYRA_MOUSE_EVENT_BUTTON_PRESS
) {
695 roccat_report
.type
= button_event
->type
;
696 roccat_report
.key
= button_event
->data1
;
698 * pyra reports profile numbers with range 1-5.
699 * Keeping this behaviour.
701 roccat_report
.value
= pyra
->actual_profile
+ 1;
702 roccat_report_event(pyra
->chrdev_minor
,
703 (uint8_t const *)&roccat_report
,
704 sizeof(struct pyra_roccat_report
));
710 static int pyra_raw_event(struct hid_device
*hdev
, struct hid_report
*report
,
713 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
714 struct pyra_device
*pyra
= hid_get_drvdata(hdev
);
716 if (intf
->cur_altsetting
->desc
.bInterfaceProtocol
717 != USB_INTERFACE_PROTOCOL_MOUSE
)
720 pyra_keep_values_up_to_date(pyra
, data
);
722 if (pyra
->roccat_claimed
)
723 pyra_report_to_chrdev(pyra
, data
);
728 static const struct hid_device_id pyra_devices
[] = {
729 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
,
730 USB_DEVICE_ID_ROCCAT_PYRA_WIRED
) },
731 /* TODO add USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS after testing */
735 MODULE_DEVICE_TABLE(hid
, pyra_devices
);
737 static struct hid_driver pyra_driver
= {
739 .id_table
= pyra_devices
,
741 .remove
= pyra_remove
,
742 .raw_event
= pyra_raw_event
745 static int __init
pyra_init(void)
749 /* class name has to be same as driver name */
750 pyra_class
= class_create(THIS_MODULE
, "pyra");
751 if (IS_ERR(pyra_class
))
752 return PTR_ERR(pyra_class
);
753 pyra_class
->dev_attrs
= pyra_attributes
;
754 pyra_class
->dev_bin_attrs
= pyra_bin_attributes
;
756 retval
= hid_register_driver(&pyra_driver
);
758 class_destroy(pyra_class
);
762 static void __exit
pyra_exit(void)
764 class_destroy(pyra_class
);
765 hid_unregister_driver(&pyra_driver
);
768 module_init(pyra_init
);
769 module_exit(pyra_exit
);
771 MODULE_AUTHOR("Stefan Achatz");
772 MODULE_DESCRIPTION("USB Roccat Pyra driver");
773 MODULE_LICENSE("GPL v2");