joydev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * Joystick device driver for the input driver suite.
  3. *
  4. * Copyright (c) 1999-2002 Vojtech Pavlik
  5. * Copyright (c) 1999 Colin Van Dyke
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <asm/io.h>
  13. #include <asm/system.h>
  14. #include <linux/delay.h>
  15. #include <linux/errno.h>
  16. #include <linux/joystick.h>
  17. #include <linux/input.h>
  18. #include <linux/kernel.h>
  19. #include <linux/major.h>
  20. #include <linux/slab.h>
  21. #include <linux/mm.h>
  22. #include <linux/miscdevice.h>
  23. #include <linux/module.h>
  24. #include <linux/poll.h>
  25. #include <linux/init.h>
  26. #include <linux/device.h>
  27. MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
  28. MODULE_DESCRIPTION("Joystick device interfaces");
  29. MODULE_SUPPORTED_DEVICE("input/js");
  30. MODULE_LICENSE("GPL");
  31. #define JOYDEV_MINOR_BASE 0
  32. #define JOYDEV_MINORS 16
  33. #define JOYDEV_BUFFER_SIZE 64
  34. struct joydev {
  35. int exist;
  36. int open;
  37. int minor;
  38. char name[16];
  39. struct input_handle handle;
  40. wait_queue_head_t wait;
  41. struct list_head client_list;
  42. struct device dev;
  43. struct js_corr corr[ABS_MAX + 1];
  44. struct JS_DATA_SAVE_TYPE glue;
  45. int nabs;
  46. int nkey;
  47. __u16 keymap[KEY_MAX - BTN_MISC + 1];
  48. __u16 keypam[KEY_MAX - BTN_MISC + 1];
  49. __u8 absmap[ABS_MAX + 1];
  50. __u8 abspam[ABS_MAX + 1];
  51. __s16 abs[ABS_MAX + 1];
  52. };
  53. struct joydev_client {
  54. struct js_event buffer[JOYDEV_BUFFER_SIZE];
  55. int head;
  56. int tail;
  57. int startup;
  58. struct fasync_struct *fasync;
  59. struct joydev *joydev;
  60. struct list_head node;
  61. };
  62. static struct joydev *joydev_table[JOYDEV_MINORS];
  63. static int joydev_correct(int value, struct js_corr *corr)
  64. {
  65. switch (corr->type) {
  66. case JS_CORR_NONE:
  67. break;
  68. case JS_CORR_BROKEN:
  69. value = value > corr->coef[0] ? (value < corr->coef[1] ? 0 :
  70. ((corr->coef[3] * (value - corr->coef[1])) >> 14)) :
  71. ((corr->coef[2] * (value - corr->coef[0])) >> 14);
  72. break;
  73. default:
  74. return 0;
  75. }
  76. return value < -32767 ? -32767 : (value > 32767 ? 32767 : value);
  77. }
  78. static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
  79. {
  80. struct joydev *joydev = handle->private;
  81. struct joydev_client *client;
  82. struct js_event event;
  83. switch (type) {
  84. case EV_KEY:
  85. if (code < BTN_MISC || value == 2)
  86. return;
  87. event.type = JS_EVENT_BUTTON;
  88. event.number = joydev->keymap[code - BTN_MISC];
  89. event.value = value;
  90. break;
  91. case EV_ABS:
  92. event.type = JS_EVENT_AXIS;
  93. event.number = joydev->absmap[code];
  94. event.value = joydev_correct(value, joydev->corr + event.number);
  95. if (event.value == joydev->abs[event.number])
  96. return;
  97. joydev->abs[event.number] = event.value;
  98. break;
  99. default:
  100. return;
  101. }
  102. event.time = jiffies_to_msecs(jiffies);
  103. list_for_each_entry(client, &joydev->client_list, node) {
  104. memcpy(client->buffer + client->head, &event, sizeof(struct js_event));
  105. if (client->startup == joydev->nabs + joydev->nkey)
  106. if (client->tail == (client->head = (client->head + 1) & (JOYDEV_BUFFER_SIZE - 1)))
  107. client->startup = 0;
  108. kill_fasync(&client->fasync, SIGIO, POLL_IN);
  109. }
  110. wake_up_interruptible(&joydev->wait);
  111. }
  112. static int joydev_fasync(int fd, struct file *file, int on)
  113. {
  114. int retval;
  115. struct joydev_client *client = file->private_data;
  116. retval = fasync_helper(fd, file, on, &client->fasync);
  117. return retval < 0 ? retval : 0;
  118. }
  119. static void joydev_free(struct device *dev)
  120. {
  121. struct joydev *joydev = container_of(dev, struct joydev, dev);
  122. joydev_table[joydev->minor] = NULL;
  123. kfree(joydev);
  124. }
  125. static int joydev_release(struct inode *inode, struct file *file)
  126. {
  127. struct joydev_client *client = file->private_data;
  128. struct joydev *joydev = client->joydev;
  129. joydev_fasync(-1, file, 0);
  130. list_del(&client->node);
  131. kfree(client);
  132. if (!--joydev->open && joydev->exist)
  133. input_close_device(&joydev->handle);
  134. put_device(&joydev->dev);
  135. return 0;
  136. }
  137. static int joydev_open(struct inode *inode, struct file *file)
  138. {
  139. struct joydev_client *client;
  140. struct joydev *joydev;
  141. int i = iminor(inode) - JOYDEV_MINOR_BASE;
  142. int error;
  143. if (i >= JOYDEV_MINORS)
  144. return -ENODEV;
  145. joydev = joydev_table[i];
  146. if (!joydev || !joydev->exist)
  147. return -ENODEV;
  148. get_device(&joydev->dev);
  149. client = kzalloc(sizeof(struct joydev_client), GFP_KERNEL);
  150. if (!client) {
  151. error = -ENOMEM;
  152. goto err_put_joydev;
  153. }
  154. client->joydev = joydev;
  155. list_add_tail(&client->node, &joydev->client_list);
  156. if (!joydev->open++ && joydev->exist) {
  157. error = input_open_device(&joydev->handle);
  158. if (error)
  159. goto err_free_client;
  160. }
  161. file->private_data = client;
  162. return 0;
  163. err_free_client:
  164. list_del(&client->node);
  165. kfree(client);
  166. err_put_joydev:
  167. put_device(&joydev->dev);
  168. return error;
  169. }
  170. static ssize_t joydev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
  171. {
  172. return -EINVAL;
  173. }
  174. static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  175. {
  176. struct joydev_client *client = file->private_data;
  177. struct joydev *joydev = client->joydev;
  178. struct input_dev *input = joydev->handle.dev;
  179. int retval = 0;
  180. if (!joydev->exist)
  181. return -ENODEV;
  182. if (count < sizeof(struct js_event))
  183. return -EINVAL;
  184. if (count == sizeof(struct JS_DATA_TYPE)) {
  185. struct JS_DATA_TYPE data;
  186. int i;
  187. for (data.buttons = i = 0; i < 32 && i < joydev->nkey; i++)
  188. data.buttons |= test_bit(joydev->keypam[i], input->key) ? (1 << i) : 0;
  189. data.x = (joydev->abs[0] / 256 + 128) >> joydev->glue.JS_CORR.x;
  190. data.y = (joydev->abs[1] / 256 + 128) >> joydev->glue.JS_CORR.y;
  191. if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE)))
  192. return -EFAULT;
  193. client->startup = 0;
  194. client->tail = client->head;
  195. return sizeof(struct JS_DATA_TYPE);
  196. }
  197. if (client->startup == joydev->nabs + joydev->nkey &&
  198. client->head == client->tail && (file->f_flags & O_NONBLOCK))
  199. return -EAGAIN;
  200. retval = wait_event_interruptible(joydev->wait,
  201. !joydev->exist ||
  202. client->startup < joydev->nabs + joydev->nkey ||
  203. client->head != client->tail);
  204. if (retval)
  205. return retval;
  206. if (!joydev->exist)
  207. return -ENODEV;
  208. while (client->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) {
  209. struct js_event event;
  210. event.time = jiffies_to_msecs(jiffies);
  211. if (client->startup < joydev->nkey) {
  212. event.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
  213. event.number = client->startup;
  214. event.value = !!test_bit(joydev->keypam[event.number], input->key);
  215. } else {
  216. event.type = JS_EVENT_AXIS | JS_EVENT_INIT;
  217. event.number = client->startup - joydev->nkey;
  218. event.value = joydev->abs[event.number];
  219. }
  220. if (copy_to_user(buf + retval, &event, sizeof(struct js_event)))
  221. return -EFAULT;
  222. client->startup++;
  223. retval += sizeof(struct js_event);
  224. }
  225. while (client->head != client->tail && retval + sizeof(struct js_event) <= count) {
  226. if (copy_to_user(buf + retval, client->buffer + client->tail, sizeof(struct js_event)))
  227. return -EFAULT;
  228. client->tail = (client->tail + 1) & (JOYDEV_BUFFER_SIZE - 1);
  229. retval += sizeof(struct js_event);
  230. }
  231. return retval;
  232. }
  233. /* No kernel lock - fine */
  234. static unsigned int joydev_poll(struct file *file, poll_table *wait)
  235. {
  236. struct joydev_client *client = file->private_data;
  237. struct joydev *joydev = client->joydev;
  238. poll_wait(file, &joydev->wait, wait);
  239. return ((client->head != client->tail || client->startup < joydev->nabs + joydev->nkey) ?
  240. (POLLIN | POLLRDNORM) : 0) | (joydev->exist ? 0 : (POLLHUP | POLLERR));
  241. }
  242. static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp)
  243. {
  244. struct input_dev *dev = joydev->handle.dev;
  245. int i, j;
  246. switch (cmd) {
  247. case JS_SET_CAL:
  248. return copy_from_user(&joydev->glue.JS_CORR, argp,
  249. sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
  250. case JS_GET_CAL:
  251. return copy_to_user(argp, &joydev->glue.JS_CORR,
  252. sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
  253. case JS_SET_TIMEOUT:
  254. return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
  255. case JS_GET_TIMEOUT:
  256. return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
  257. case JSIOCGVERSION:
  258. return put_user(JS_VERSION, (__u32 __user *) argp);
  259. case JSIOCGAXES:
  260. return put_user(joydev->nabs, (__u8 __user *) argp);
  261. case JSIOCGBUTTONS:
  262. return put_user(joydev->nkey, (__u8 __user *) argp);
  263. case JSIOCSCORR:
  264. if (copy_from_user(joydev->corr, argp,
  265. sizeof(joydev->corr[0]) * joydev->nabs))
  266. return -EFAULT;
  267. for (i = 0; i < joydev->nabs; i++) {
  268. j = joydev->abspam[i];
  269. joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);
  270. }
  271. return 0;
  272. case JSIOCGCORR:
  273. return copy_to_user(argp, joydev->corr,
  274. sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0;
  275. case JSIOCSAXMAP:
  276. if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1)))
  277. return -EFAULT;
  278. for (i = 0; i < joydev->nabs; i++) {
  279. if (joydev->abspam[i] > ABS_MAX)
  280. return -EINVAL;
  281. joydev->absmap[joydev->abspam[i]] = i;
  282. }
  283. return 0;
  284. case JSIOCGAXMAP:
  285. return copy_to_user(argp, joydev->abspam,
  286. sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0;
  287. case JSIOCSBTNMAP:
  288. if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)))
  289. return -EFAULT;
  290. for (i = 0; i < joydev->nkey; i++) {
  291. if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC)
  292. return -EINVAL;
  293. joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;
  294. }
  295. return 0;
  296. case JSIOCGBTNMAP:
  297. return copy_to_user(argp, joydev->keypam,
  298. sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0;
  299. default:
  300. if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) {
  301. int len;
  302. if (!dev->name)
  303. return 0;
  304. len = strlen(dev->name) + 1;
  305. if (len > _IOC_SIZE(cmd))
  306. len = _IOC_SIZE(cmd);
  307. if (copy_to_user(argp, dev->name, len))
  308. return -EFAULT;
  309. return len;
  310. }
  311. }
  312. return -EINVAL;
  313. }
  314. #ifdef CONFIG_COMPAT
  315. static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  316. {
  317. struct joydev_client *client = file->private_data;
  318. struct joydev *joydev = client->joydev;
  319. void __user *argp = (void __user *)arg;
  320. s32 tmp32;
  321. struct JS_DATA_SAVE_TYPE_32 ds32;
  322. int err;
  323. if (!joydev->exist)
  324. return -ENODEV;
  325. switch(cmd) {
  326. case JS_SET_TIMELIMIT:
  327. err = get_user(tmp32, (s32 __user *) arg);
  328. if (err == 0)
  329. joydev->glue.JS_TIMELIMIT = tmp32;
  330. break;
  331. case JS_GET_TIMELIMIT:
  332. tmp32 = joydev->glue.JS_TIMELIMIT;
  333. err = put_user(tmp32, (s32 __user *) arg);
  334. break;
  335. case JS_SET_ALL:
  336. err = copy_from_user(&ds32, argp,
  337. sizeof(ds32)) ? -EFAULT : 0;
  338. if (err == 0) {
  339. joydev->glue.JS_TIMEOUT = ds32.JS_TIMEOUT;
  340. joydev->glue.BUSY = ds32.BUSY;
  341. joydev->glue.JS_EXPIRETIME = ds32.JS_EXPIRETIME;
  342. joydev->glue.JS_TIMELIMIT = ds32.JS_TIMELIMIT;
  343. joydev->glue.JS_SAVE = ds32.JS_SAVE;
  344. joydev->glue.JS_CORR = ds32.JS_CORR;
  345. }
  346. break;
  347. case JS_GET_ALL:
  348. ds32.JS_TIMEOUT = joydev->glue.JS_TIMEOUT;
  349. ds32.BUSY = joydev->glue.BUSY;
  350. ds32.JS_EXPIRETIME = joydev->glue.JS_EXPIRETIME;
  351. ds32.JS_TIMELIMIT = joydev->glue.JS_TIMELIMIT;
  352. ds32.JS_SAVE = joydev->glue.JS_SAVE;
  353. ds32.JS_CORR = joydev->glue.JS_CORR;
  354. err = copy_to_user(argp, &ds32, sizeof(ds32)) ? -EFAULT : 0;
  355. break;
  356. default:
  357. err = joydev_ioctl_common(joydev, cmd, argp);
  358. }
  359. return err;
  360. }
  361. #endif /* CONFIG_COMPAT */
  362. static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
  363. {
  364. struct joydev_client *client = file->private_data;
  365. struct joydev *joydev = client->joydev;
  366. void __user *argp = (void __user *)arg;
  367. if (!joydev->exist)
  368. return -ENODEV;
  369. switch(cmd) {
  370. case JS_SET_TIMELIMIT:
  371. return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);
  372. case JS_GET_TIMELIMIT:
  373. return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);
  374. case JS_SET_ALL:
  375. return copy_from_user(&joydev->glue, argp,
  376. sizeof(joydev->glue)) ? -EFAULT : 0;
  377. case JS_GET_ALL:
  378. return copy_to_user(argp, &joydev->glue,
  379. sizeof(joydev->glue)) ? -EFAULT : 0;
  380. default:
  381. return joydev_ioctl_common(joydev, cmd, argp);
  382. }
  383. }
  384. static const struct file_operations joydev_fops = {
  385. .owner = THIS_MODULE,
  386. .read = joydev_read,
  387. .write = joydev_write,
  388. .poll = joydev_poll,
  389. .open = joydev_open,
  390. .release = joydev_release,
  391. .ioctl = joydev_ioctl,
  392. #ifdef CONFIG_COMPAT
  393. .compat_ioctl = joydev_compat_ioctl,
  394. #endif
  395. .fasync = joydev_fasync,
  396. };
  397. static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
  398. const struct input_device_id *id)
  399. {
  400. struct joydev *joydev;
  401. int i, j, t, minor;
  402. int error;
  403. for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
  404. if (minor == JOYDEV_MINORS) {
  405. printk(KERN_ERR "joydev: no more free joydev devices\n");
  406. return -ENFILE;
  407. }
  408. joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL);
  409. if (!joydev)
  410. return -ENOMEM;
  411. INIT_LIST_HEAD(&joydev->client_list);
  412. init_waitqueue_head(&joydev->wait);
  413. joydev->minor = minor;
  414. joydev->exist = 1;
  415. joydev->handle.dev = dev;
  416. joydev->handle.name = joydev->name;
  417. joydev->handle.handler = handler;
  418. joydev->handle.private = joydev;
  419. snprintf(joydev->name, sizeof(joydev->name), "js%d", minor);
  420. for (i = 0; i < ABS_MAX + 1; i++)
  421. if (test_bit(i, dev->absbit)) {
  422. joydev->absmap[i] = joydev->nabs;
  423. joydev->abspam[joydev->nabs] = i;
  424. joydev->nabs++;
  425. }
  426. for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
  427. if (test_bit(i + BTN_MISC, dev->keybit)) {
  428. joydev->keymap[i] = joydev->nkey;
  429. joydev->keypam[joydev->nkey] = i + BTN_MISC;
  430. joydev->nkey++;
  431. }
  432. for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
  433. if (test_bit(i + BTN_MISC, dev->keybit)) {
  434. joydev->keymap[i] = joydev->nkey;
  435. joydev->keypam[joydev->nkey] = i + BTN_MISC;
  436. joydev->nkey++;
  437. }
  438. for (i = 0; i < joydev->nabs; i++) {
  439. j = joydev->abspam[i];
  440. if (dev->absmax[j] == dev->absmin[j]) {
  441. joydev->corr[i].type = JS_CORR_NONE;
  442. joydev->abs[i] = dev->abs[j];
  443. continue;
  444. }
  445. joydev->corr[i].type = JS_CORR_BROKEN;
  446. joydev->corr[i].prec = dev->absfuzz[j];
  447. joydev->corr[i].coef[0] = (dev->absmax[j] + dev->absmin[j]) / 2 - dev->absflat[j];
  448. joydev->corr[i].coef[1] = (dev->absmax[j] + dev->absmin[j]) / 2 + dev->absflat[j];
  449. if (!(t = ((dev->absmax[j] - dev->absmin[j]) / 2 - 2 * dev->absflat[j])))
  450. continue;
  451. joydev->corr[i].coef[2] = (1 << 29) / t;
  452. joydev->corr[i].coef[3] = (1 << 29) / t;
  453. joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);
  454. }
  455. snprintf(joydev->dev.bus_id, sizeof(joydev->dev.bus_id),
  456. "js%d", minor);
  457. joydev->dev.class = &input_class;
  458. joydev->dev.parent = &dev->dev;
  459. joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor);
  460. joydev->dev.release = joydev_free;
  461. device_initialize(&joydev->dev);
  462. joydev_table[minor] = joydev;
  463. error = device_add(&joydev->dev);
  464. if (error)
  465. goto err_free_joydev;
  466. error = input_register_handle(&joydev->handle);
  467. if (error)
  468. goto err_delete_joydev;
  469. return 0;
  470. err_delete_joydev:
  471. device_del(&joydev->dev);
  472. err_free_joydev:
  473. put_device(&joydev->dev);
  474. return error;
  475. }
  476. static void joydev_disconnect(struct input_handle *handle)
  477. {
  478. struct joydev *joydev = handle->private;
  479. struct joydev_client *client;
  480. input_unregister_handle(handle);
  481. device_del(&joydev->dev);
  482. joydev->exist = 0;
  483. if (joydev->open) {
  484. input_close_device(handle);
  485. list_for_each_entry(client, &joydev->client_list, node)
  486. kill_fasync(&client->fasync, SIGIO, POLL_HUP);
  487. wake_up_interruptible(&joydev->wait);
  488. }
  489. put_device(&joydev->dev);
  490. }
  491. static const struct input_device_id joydev_blacklist[] = {
  492. {
  493. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
  494. .evbit = { BIT(EV_KEY) },
  495. .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
  496. }, /* Avoid itouchpads, touchscreens and tablets */
  497. { } /* Terminating entry */
  498. };
  499. static const struct input_device_id joydev_ids[] = {
  500. {
  501. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  502. .evbit = { BIT(EV_ABS) },
  503. .absbit = { BIT(ABS_X) },
  504. },
  505. {
  506. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  507. .evbit = { BIT(EV_ABS) },
  508. .absbit = { BIT(ABS_WHEEL) },
  509. },
  510. {
  511. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  512. .evbit = { BIT(EV_ABS) },
  513. .absbit = { BIT(ABS_THROTTLE) },
  514. },
  515. { } /* Terminating entry */
  516. };
  517. MODULE_DEVICE_TABLE(input, joydev_ids);
  518. static struct input_handler joydev_handler = {
  519. .event = joydev_event,
  520. .connect = joydev_connect,
  521. .disconnect = joydev_disconnect,
  522. .fops = &joydev_fops,
  523. .minor = JOYDEV_MINOR_BASE,
  524. .name = "joydev",
  525. .id_table = joydev_ids,
  526. .blacklist = joydev_blacklist,
  527. };
  528. static int __init joydev_init(void)
  529. {
  530. return input_register_handler(&joydev_handler);
  531. }
  532. static void __exit joydev_exit(void)
  533. {
  534. input_unregister_handler(&joydev_handler);
  535. }
  536. module_init(joydev_init);
  537. module_exit(joydev_exit);