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