hid-roccat-pyra.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * Roccat Pyra driver for Linux
  3. *
  4. * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. /*
  13. * Roccat Pyra is a mobile gamer mouse which comes in wired and wireless
  14. * variant. Wireless variant is not tested.
  15. * Userland tools can be found at http://sourceforge.net/projects/roccat
  16. */
  17. #include <linux/device.h>
  18. #include <linux/input.h>
  19. #include <linux/hid.h>
  20. #include <linux/module.h>
  21. #include <linux/slab.h>
  22. #include <linux/hid-roccat.h>
  23. #include "hid-ids.h"
  24. #include "hid-roccat-common.h"
  25. #include "hid-roccat-pyra.h"
  26. static uint profile_numbers[5] = {0, 1, 2, 3, 4};
  27. /* pyra_class is used for creating sysfs attributes via roccat char device */
  28. static struct class *pyra_class;
  29. static void profile_activated(struct pyra_device *pyra,
  30. unsigned int new_profile)
  31. {
  32. pyra->actual_profile = new_profile;
  33. pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi;
  34. }
  35. static int pyra_send_control(struct usb_device *usb_dev, int value,
  36. enum pyra_control_requests request)
  37. {
  38. struct roccat_common2_control control;
  39. if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS ||
  40. request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) &&
  41. (value < 0 || value > 4))
  42. return -EINVAL;
  43. control.command = ROCCAT_COMMON_COMMAND_CONTROL;
  44. control.value = value;
  45. control.request = request;
  46. return roccat_common2_send(usb_dev, ROCCAT_COMMON_COMMAND_CONTROL,
  47. &control, sizeof(struct roccat_common2_control));
  48. }
  49. static int pyra_get_profile_settings(struct usb_device *usb_dev,
  50. struct pyra_profile_settings *buf, int number)
  51. {
  52. int retval;
  53. retval = pyra_send_control(usb_dev, number,
  54. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  55. if (retval)
  56. return retval;
  57. return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS,
  58. buf, PYRA_SIZE_PROFILE_SETTINGS);
  59. }
  60. static int pyra_get_settings(struct usb_device *usb_dev,
  61. struct pyra_settings *buf)
  62. {
  63. return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  64. buf, PYRA_SIZE_SETTINGS);
  65. }
  66. static int pyra_set_settings(struct usb_device *usb_dev,
  67. struct pyra_settings const *settings)
  68. {
  69. return roccat_common2_send_with_status(usb_dev,
  70. PYRA_COMMAND_SETTINGS, settings,
  71. PYRA_SIZE_SETTINGS);
  72. }
  73. static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj,
  74. char *buf, loff_t off, size_t count,
  75. size_t real_size, uint command)
  76. {
  77. struct device *dev =
  78. container_of(kobj, struct device, kobj)->parent->parent;
  79. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  80. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  81. int retval;
  82. if (off >= real_size)
  83. return 0;
  84. if (off != 0 || count != real_size)
  85. return -EINVAL;
  86. mutex_lock(&pyra->pyra_lock);
  87. retval = roccat_common2_receive(usb_dev, command, buf, real_size);
  88. mutex_unlock(&pyra->pyra_lock);
  89. if (retval)
  90. return retval;
  91. return real_size;
  92. }
  93. static ssize_t pyra_sysfs_write(struct file *fp, struct kobject *kobj,
  94. void const *buf, loff_t off, size_t count,
  95. size_t real_size, uint command)
  96. {
  97. struct device *dev =
  98. container_of(kobj, struct device, kobj)->parent->parent;
  99. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  100. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  101. int retval;
  102. if (off != 0 || count != real_size)
  103. return -EINVAL;
  104. mutex_lock(&pyra->pyra_lock);
  105. retval = roccat_common2_send_with_status(usb_dev, command, (void *)buf, real_size);
  106. mutex_unlock(&pyra->pyra_lock);
  107. if (retval)
  108. return retval;
  109. return real_size;
  110. }
  111. #define PYRA_SYSFS_W(thingy, THINGY) \
  112. static ssize_t pyra_sysfs_write_ ## thingy(struct file *fp, \
  113. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  114. loff_t off, size_t count) \
  115. { \
  116. return pyra_sysfs_write(fp, kobj, buf, off, count, \
  117. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  118. }
  119. #define PYRA_SYSFS_R(thingy, THINGY) \
  120. static ssize_t pyra_sysfs_read_ ## thingy(struct file *fp, \
  121. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  122. loff_t off, size_t count) \
  123. { \
  124. return pyra_sysfs_read(fp, kobj, buf, off, count, \
  125. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  126. }
  127. #define PYRA_SYSFS_RW(thingy, THINGY) \
  128. PYRA_SYSFS_W(thingy, THINGY) \
  129. PYRA_SYSFS_R(thingy, THINGY)
  130. #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
  131. { \
  132. .attr = { .name = #thingy, .mode = 0660 }, \
  133. .size = PYRA_SIZE_ ## THINGY, \
  134. .read = pyra_sysfs_read_ ## thingy, \
  135. .write = pyra_sysfs_write_ ## thingy \
  136. }
  137. #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \
  138. { \
  139. .attr = { .name = #thingy, .mode = 0440 }, \
  140. .size = PYRA_SIZE_ ## THINGY, \
  141. .read = pyra_sysfs_read_ ## thingy, \
  142. }
  143. #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \
  144. { \
  145. .attr = { .name = #thingy, .mode = 0220 }, \
  146. .size = PYRA_SIZE_ ## THINGY, \
  147. .write = pyra_sysfs_write_ ## thingy \
  148. }
  149. PYRA_SYSFS_W(control, CONTROL)
  150. PYRA_SYSFS_RW(info, INFO)
  151. PYRA_SYSFS_RW(profile_settings, PROFILE_SETTINGS)
  152. PYRA_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)
  153. PYRA_SYSFS_R(settings, SETTINGS)
  154. static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp,
  155. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  156. loff_t off, size_t count)
  157. {
  158. struct device *dev =
  159. container_of(kobj, struct device, kobj)->parent->parent;
  160. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  161. ssize_t retval;
  162. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  163. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  164. if (retval)
  165. return retval;
  166. return pyra_sysfs_read(fp, kobj, buf, off, count,
  167. PYRA_SIZE_PROFILE_SETTINGS,
  168. PYRA_COMMAND_PROFILE_SETTINGS);
  169. }
  170. static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp,
  171. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  172. loff_t off, size_t count)
  173. {
  174. struct device *dev =
  175. container_of(kobj, struct device, kobj)->parent->parent;
  176. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  177. ssize_t retval;
  178. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  179. PYRA_CONTROL_REQUEST_PROFILE_BUTTONS);
  180. if (retval)
  181. return retval;
  182. return pyra_sysfs_read(fp, kobj, buf, off, count,
  183. PYRA_SIZE_PROFILE_BUTTONS,
  184. PYRA_COMMAND_PROFILE_BUTTONS);
  185. }
  186. static ssize_t pyra_sysfs_write_settings(struct file *fp,
  187. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  188. loff_t off, size_t count)
  189. {
  190. struct device *dev =
  191. container_of(kobj, struct device, kobj)->parent->parent;
  192. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  193. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  194. int retval = 0;
  195. struct pyra_roccat_report roccat_report;
  196. struct pyra_settings const *settings;
  197. if (off != 0 || count != PYRA_SIZE_SETTINGS)
  198. return -EINVAL;
  199. mutex_lock(&pyra->pyra_lock);
  200. settings = (struct pyra_settings const *)buf;
  201. retval = pyra_set_settings(usb_dev, settings);
  202. if (retval) {
  203. mutex_unlock(&pyra->pyra_lock);
  204. return retval;
  205. }
  206. profile_activated(pyra, settings->startup_profile);
  207. roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2;
  208. roccat_report.value = settings->startup_profile + 1;
  209. roccat_report.key = 0;
  210. roccat_report_event(pyra->chrdev_minor,
  211. (uint8_t const *)&roccat_report);
  212. mutex_unlock(&pyra->pyra_lock);
  213. return PYRA_SIZE_SETTINGS;
  214. }
  215. static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
  216. struct device_attribute *attr, char *buf)
  217. {
  218. struct pyra_device *pyra =
  219. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  220. return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
  221. }
  222. static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
  223. struct device_attribute *attr, char *buf)
  224. {
  225. struct pyra_device *pyra =
  226. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  227. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  228. struct pyra_settings settings;
  229. mutex_lock(&pyra->pyra_lock);
  230. roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  231. &settings, PYRA_SIZE_SETTINGS);
  232. mutex_unlock(&pyra->pyra_lock);
  233. return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
  234. }
  235. static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
  236. struct device_attribute *attr, char *buf)
  237. {
  238. struct pyra_device *pyra;
  239. struct usb_device *usb_dev;
  240. struct pyra_info info;
  241. dev = dev->parent->parent;
  242. pyra = hid_get_drvdata(dev_get_drvdata(dev));
  243. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  244. mutex_lock(&pyra->pyra_lock);
  245. roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO,
  246. &info, PYRA_SIZE_INFO);
  247. mutex_unlock(&pyra->pyra_lock);
  248. return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
  249. }
  250. static struct device_attribute pyra_attributes[] = {
  251. __ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL),
  252. __ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL),
  253. __ATTR(firmware_version, 0440,
  254. pyra_sysfs_show_firmware_version, NULL),
  255. __ATTR(startup_profile, 0440,
  256. pyra_sysfs_show_actual_profile, NULL),
  257. __ATTR_NULL
  258. };
  259. static struct bin_attribute pyra_bin_attributes[] = {
  260. PYRA_BIN_ATTRIBUTE_W(control, CONTROL),
  261. PYRA_BIN_ATTRIBUTE_RW(info, INFO),
  262. PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS),
  263. PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS),
  264. PYRA_BIN_ATTRIBUTE_RW(settings, SETTINGS),
  265. {
  266. .attr = { .name = "profile1_settings", .mode = 0440 },
  267. .size = PYRA_SIZE_PROFILE_SETTINGS,
  268. .read = pyra_sysfs_read_profilex_settings,
  269. .private = &profile_numbers[0]
  270. },
  271. {
  272. .attr = { .name = "profile2_settings", .mode = 0440 },
  273. .size = PYRA_SIZE_PROFILE_SETTINGS,
  274. .read = pyra_sysfs_read_profilex_settings,
  275. .private = &profile_numbers[1]
  276. },
  277. {
  278. .attr = { .name = "profile3_settings", .mode = 0440 },
  279. .size = PYRA_SIZE_PROFILE_SETTINGS,
  280. .read = pyra_sysfs_read_profilex_settings,
  281. .private = &profile_numbers[2]
  282. },
  283. {
  284. .attr = { .name = "profile4_settings", .mode = 0440 },
  285. .size = PYRA_SIZE_PROFILE_SETTINGS,
  286. .read = pyra_sysfs_read_profilex_settings,
  287. .private = &profile_numbers[3]
  288. },
  289. {
  290. .attr = { .name = "profile5_settings", .mode = 0440 },
  291. .size = PYRA_SIZE_PROFILE_SETTINGS,
  292. .read = pyra_sysfs_read_profilex_settings,
  293. .private = &profile_numbers[4]
  294. },
  295. {
  296. .attr = { .name = "profile1_buttons", .mode = 0440 },
  297. .size = PYRA_SIZE_PROFILE_BUTTONS,
  298. .read = pyra_sysfs_read_profilex_buttons,
  299. .private = &profile_numbers[0]
  300. },
  301. {
  302. .attr = { .name = "profile2_buttons", .mode = 0440 },
  303. .size = PYRA_SIZE_PROFILE_BUTTONS,
  304. .read = pyra_sysfs_read_profilex_buttons,
  305. .private = &profile_numbers[1]
  306. },
  307. {
  308. .attr = { .name = "profile3_buttons", .mode = 0440 },
  309. .size = PYRA_SIZE_PROFILE_BUTTONS,
  310. .read = pyra_sysfs_read_profilex_buttons,
  311. .private = &profile_numbers[2]
  312. },
  313. {
  314. .attr = { .name = "profile4_buttons", .mode = 0440 },
  315. .size = PYRA_SIZE_PROFILE_BUTTONS,
  316. .read = pyra_sysfs_read_profilex_buttons,
  317. .private = &profile_numbers[3]
  318. },
  319. {
  320. .attr = { .name = "profile5_buttons", .mode = 0440 },
  321. .size = PYRA_SIZE_PROFILE_BUTTONS,
  322. .read = pyra_sysfs_read_profilex_buttons,
  323. .private = &profile_numbers[4]
  324. },
  325. __ATTR_NULL
  326. };
  327. static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
  328. struct pyra_device *pyra)
  329. {
  330. struct pyra_settings settings;
  331. int retval, i;
  332. mutex_init(&pyra->pyra_lock);
  333. retval = pyra_get_settings(usb_dev, &settings);
  334. if (retval)
  335. return retval;
  336. for (i = 0; i < 5; ++i) {
  337. retval = pyra_get_profile_settings(usb_dev,
  338. &pyra->profile_settings[i], i);
  339. if (retval)
  340. return retval;
  341. }
  342. profile_activated(pyra, settings.startup_profile);
  343. return 0;
  344. }
  345. static int pyra_init_specials(struct hid_device *hdev)
  346. {
  347. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  348. struct usb_device *usb_dev = interface_to_usbdev(intf);
  349. struct pyra_device *pyra;
  350. int retval;
  351. if (intf->cur_altsetting->desc.bInterfaceProtocol
  352. == USB_INTERFACE_PROTOCOL_MOUSE) {
  353. pyra = kzalloc(sizeof(*pyra), GFP_KERNEL);
  354. if (!pyra) {
  355. hid_err(hdev, "can't alloc device descriptor\n");
  356. return -ENOMEM;
  357. }
  358. hid_set_drvdata(hdev, pyra);
  359. retval = pyra_init_pyra_device_struct(usb_dev, pyra);
  360. if (retval) {
  361. hid_err(hdev, "couldn't init struct pyra_device\n");
  362. goto exit_free;
  363. }
  364. retval = roccat_connect(pyra_class, hdev,
  365. sizeof(struct pyra_roccat_report));
  366. if (retval < 0) {
  367. hid_err(hdev, "couldn't init char dev\n");
  368. } else {
  369. pyra->chrdev_minor = retval;
  370. pyra->roccat_claimed = 1;
  371. }
  372. } else {
  373. hid_set_drvdata(hdev, NULL);
  374. }
  375. return 0;
  376. exit_free:
  377. kfree(pyra);
  378. return retval;
  379. }
  380. static void pyra_remove_specials(struct hid_device *hdev)
  381. {
  382. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  383. struct pyra_device *pyra;
  384. if (intf->cur_altsetting->desc.bInterfaceProtocol
  385. == USB_INTERFACE_PROTOCOL_MOUSE) {
  386. pyra = hid_get_drvdata(hdev);
  387. if (pyra->roccat_claimed)
  388. roccat_disconnect(pyra->chrdev_minor);
  389. kfree(hid_get_drvdata(hdev));
  390. }
  391. }
  392. static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id)
  393. {
  394. int retval;
  395. retval = hid_parse(hdev);
  396. if (retval) {
  397. hid_err(hdev, "parse failed\n");
  398. goto exit;
  399. }
  400. retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  401. if (retval) {
  402. hid_err(hdev, "hw start failed\n");
  403. goto exit;
  404. }
  405. retval = pyra_init_specials(hdev);
  406. if (retval) {
  407. hid_err(hdev, "couldn't install mouse\n");
  408. goto exit_stop;
  409. }
  410. return 0;
  411. exit_stop:
  412. hid_hw_stop(hdev);
  413. exit:
  414. return retval;
  415. }
  416. static void pyra_remove(struct hid_device *hdev)
  417. {
  418. pyra_remove_specials(hdev);
  419. hid_hw_stop(hdev);
  420. }
  421. static void pyra_keep_values_up_to_date(struct pyra_device *pyra,
  422. u8 const *data)
  423. {
  424. struct pyra_mouse_event_button const *button_event;
  425. switch (data[0]) {
  426. case PYRA_MOUSE_REPORT_NUMBER_BUTTON:
  427. button_event = (struct pyra_mouse_event_button const *)data;
  428. switch (button_event->type) {
  429. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  430. profile_activated(pyra, button_event->data1 - 1);
  431. break;
  432. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  433. pyra->actual_cpi = button_event->data1;
  434. break;
  435. }
  436. break;
  437. }
  438. }
  439. static void pyra_report_to_chrdev(struct pyra_device const *pyra,
  440. u8 const *data)
  441. {
  442. struct pyra_roccat_report roccat_report;
  443. struct pyra_mouse_event_button const *button_event;
  444. if (data[0] != PYRA_MOUSE_REPORT_NUMBER_BUTTON)
  445. return;
  446. button_event = (struct pyra_mouse_event_button const *)data;
  447. switch (button_event->type) {
  448. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  449. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  450. roccat_report.type = button_event->type;
  451. roccat_report.value = button_event->data1;
  452. roccat_report.key = 0;
  453. roccat_report_event(pyra->chrdev_minor,
  454. (uint8_t const *)&roccat_report);
  455. break;
  456. case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO:
  457. case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT:
  458. case PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH:
  459. if (button_event->data2 == PYRA_MOUSE_EVENT_BUTTON_PRESS) {
  460. roccat_report.type = button_event->type;
  461. roccat_report.key = button_event->data1;
  462. /*
  463. * pyra reports profile numbers with range 1-5.
  464. * Keeping this behaviour.
  465. */
  466. roccat_report.value = pyra->actual_profile + 1;
  467. roccat_report_event(pyra->chrdev_minor,
  468. (uint8_t const *)&roccat_report);
  469. }
  470. break;
  471. }
  472. }
  473. static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report,
  474. u8 *data, int size)
  475. {
  476. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  477. struct pyra_device *pyra = hid_get_drvdata(hdev);
  478. if (intf->cur_altsetting->desc.bInterfaceProtocol
  479. != USB_INTERFACE_PROTOCOL_MOUSE)
  480. return 0;
  481. if (pyra == NULL)
  482. return 0;
  483. pyra_keep_values_up_to_date(pyra, data);
  484. if (pyra->roccat_claimed)
  485. pyra_report_to_chrdev(pyra, data);
  486. return 0;
  487. }
  488. static const struct hid_device_id pyra_devices[] = {
  489. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  490. USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
  491. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  492. USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
  493. { }
  494. };
  495. MODULE_DEVICE_TABLE(hid, pyra_devices);
  496. static struct hid_driver pyra_driver = {
  497. .name = "pyra",
  498. .id_table = pyra_devices,
  499. .probe = pyra_probe,
  500. .remove = pyra_remove,
  501. .raw_event = pyra_raw_event
  502. };
  503. static int __init pyra_init(void)
  504. {
  505. int retval;
  506. /* class name has to be same as driver name */
  507. pyra_class = class_create(THIS_MODULE, "pyra");
  508. if (IS_ERR(pyra_class))
  509. return PTR_ERR(pyra_class);
  510. pyra_class->dev_attrs = pyra_attributes;
  511. pyra_class->dev_bin_attrs = pyra_bin_attributes;
  512. retval = hid_register_driver(&pyra_driver);
  513. if (retval)
  514. class_destroy(pyra_class);
  515. return retval;
  516. }
  517. static void __exit pyra_exit(void)
  518. {
  519. hid_unregister_driver(&pyra_driver);
  520. class_destroy(pyra_class);
  521. }
  522. module_init(pyra_init);
  523. module_exit(pyra_exit);
  524. MODULE_AUTHOR("Stefan Achatz");
  525. MODULE_DESCRIPTION("USB Roccat Pyra driver");
  526. MODULE_LICENSE("GPL v2");