unified menu wip and some reorganization for it
[libpicofe.git] / common / input.c
CommitLineData
2258f158 1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
fce20e73 5#include "common.h"
2258f158 6#include "input.h"
34581c95 7#include "../linux/in_evdev.h"
13b692eb 8#include "../gp2x/in_gp2x.h"
2258f158 9
10typedef struct
11{
12 int drv_id;
7f022a8d 13 int drv_fd_hnd;
2258f158 14 void *drv_data;
2258f158 15 char *name;
906bdc9f 16 int *binds;
2258f158 17 int probed:1;
2258f158 18} in_dev_t;
19
da767bd5 20static in_drv_t in_drivers[IN_DRVID_COUNT];
2258f158 21static in_dev_t in_devices[IN_MAX_DEVS];
22static int in_dev_count = 0;
13b692eb 23static int in_have_async_devs = 0;
2258f158 24
da767bd5 25#define DRV(id) in_drivers[(unsigned)(id) < IN_DRVID_COUNT ? (id) : 0]
26
13b692eb 27
2258f158 28static int in_bind_count(int drv_id)
29{
da767bd5 30 int count = DRV(drv_id).get_bind_count();
2258f158 31 if (count <= 0)
32 printf("input: failed to get bind count for drv %d\n", drv_id);
33
34 return count;
35}
36
37static int *in_alloc_binds(int drv_id)
38{
da767bd5 39 int count, *binds;
2258f158 40
41 count = in_bind_count(drv_id);
da767bd5 42 if (count <= 0)
2258f158 43 return NULL;
2258f158 44
da767bd5 45 binds = calloc(count * 2, sizeof(binds[0]));
46 if (binds == NULL)
47 return NULL;
48
49 DRV(drv_id).get_def_binds(binds + count);
50 memcpy(binds, binds + count, count * sizeof(binds[0]));
51
52 return binds;
2258f158 53}
54
55static void in_free(in_dev_t *dev)
56{
da767bd5 57 if (dev->probed)
58 DRV(dev->drv_id).free(dev->drv_data);
2258f158 59 dev->probed = 0;
60 dev->drv_data = NULL;
61 free(dev->name);
62 dev->name = NULL;
63 free(dev->binds);
64 dev->binds = NULL;
65}
66
13b692eb 67/* to be called by drivers
68 * async devices must set drv_fd_hnd to -1 */
7f022a8d 69void in_register(const char *nname, int drv_id, int drv_fd_hnd, void *drv_data)
2258f158 70{
da767bd5 71 int i, ret, dupe_count = 0, *binds;
2258f158 72 char name[256], *name_end, *tmp;
73
74 strncpy(name, nname, sizeof(name));
75 name[sizeof(name)-12] = 0;
76 name_end = name + strlen(name);
77
78 for (i = 0; i < in_dev_count; i++)
79 {
80 if (in_devices[i].name == NULL)
81 continue;
82 if (strcmp(in_devices[i].name, name) == 0)
83 {
84 if (in_devices[i].probed) {
85 dupe_count++;
86 sprintf(name_end, " [%d]", dupe_count);
87 continue;
88 }
89 goto update;
90 }
91 }
92
93 if (i >= IN_MAX_DEVS)
94 {
95 /* try to find unused device */
96 for (i = 0; i < IN_MAX_DEVS; i++)
97 if (!in_devices[i].probed) break;
98 if (i >= IN_MAX_DEVS) {
99 printf("input: too many devices, can't add %s\n", name);
100 return;
101 }
102 in_free(&in_devices[i]);
103 }
104
105 tmp = strdup(name);
106 if (tmp == NULL)
107 return;
108
109 binds = in_alloc_binds(drv_id);
110 if (binds == NULL) {
111 free(tmp);
112 return;
113 }
114
115 in_devices[i].name = tmp;
116 in_devices[i].binds = binds;
117 if (i + 1 > in_dev_count)
118 in_dev_count = i + 1;
119
120 printf("input: new device #%d \"%s\"\n", i, name);
121update:
122 in_devices[i].probed = 1;
123 in_devices[i].drv_id = drv_id;
7f022a8d 124 in_devices[i].drv_fd_hnd = drv_fd_hnd;
2258f158 125 in_devices[i].drv_data = drv_data;
da767bd5 126
127 if (in_devices[i].binds != NULL) {
128 ret = DRV(drv_id).clean_binds(drv_data, in_devices[i].binds);
129 if (ret == 0) {
130 /* no useable binds */
131 free(in_devices[i].binds);
132 in_devices[i].binds = NULL;
133 }
134 }
2258f158 135}
136
137void in_probe(void)
138{
139 int i;
13b692eb 140
141 in_have_async_devs = 0;
2258f158 142 for (i = 0; i < in_dev_count; i++)
143 in_devices[i].probed = 0;
144
da767bd5 145 for (i = 1; i < IN_DRVID_COUNT; i++)
146 in_drivers[i].probe();
2258f158 147
148 /* get rid of devs without binds and probes */
149 for (i = 0; i < in_dev_count; i++) {
150 if (!in_devices[i].probed && in_devices[i].binds == NULL) {
151 in_dev_count--;
152 if (i < in_dev_count) {
153 free(in_devices[i].name);
154 memmove(&in_devices[i], &in_devices[i+1],
155 (in_dev_count - i) * sizeof(in_devices[0]));
156 }
13b692eb 157
158 continue;
2258f158 159 }
13b692eb 160
161 if (in_devices[i].probed && in_devices[i].drv_fd_hnd == -1)
162 in_have_async_devs = 1;
2258f158 163 }
13b692eb 164
165 if (in_have_async_devs)
166 printf("input: async-only devices detected..\n");
2258f158 167}
168
7f022a8d 169/* async update */
2258f158 170int in_update(void)
171{
172 int i, result = 0;
173
174 for (i = 0; i < in_dev_count; i++) {
906bdc9f 175 in_dev_t *dev = &in_devices[i];
906bdc9f 176 if (dev->probed && dev->binds != NULL) {
177 switch (dev->drv_id) {
da767bd5 178#ifdef IN_EVDEV
595491c4 179 case IN_DRVID_EVDEV:
86883f7f 180 result |= in_evdev_update(dev->drv_data, dev->binds);
595491c4 181 break;
13b692eb 182#endif
183#ifdef IN_GP2X
184 case IN_DRVID_GP2X:
185 result |= in_gp2x_update(dev->drv_data, dev->binds);
186 break;
da767bd5 187#endif
595491c4 188 }
2258f158 189 }
190 }
191
192 return result;
193}
194
906bdc9f 195static int menu_key_state = 0;
196
595491c4 197void in_set_blocking(int is_blocking)
198{
13b692eb 199 int i, ret;
595491c4 200
13b692eb 201 /* have_async_devs means we will have to do all reads async anyway.. */
202 if (!in_have_async_devs) {
203 for (i = 0; i < in_dev_count; i++) {
204 if (in_devices[i].probed)
205 DRV(in_devices[i].drv_id).set_blocking(in_devices[i].drv_data, is_blocking);
206 }
595491c4 207 }
906bdc9f 208
209 menu_key_state = 0;
13b692eb 210
906bdc9f 211 /* flush events */
13b692eb 212 do {
213 ret = in_update_keycode(NULL, NULL, 0);
214 } while (ret >= 0);
595491c4 215}
216
7f022a8d 217/* TODO: move.. */
218#include <unistd.h>
13b692eb 219#include <sys/time.h>
220#include <time.h>
221
222static int in_update_kc_async(int *dev_id_out, int *is_down_out, int timeout_ms)
223{
224 struct timeval start, now;
225 int i, is_down, result;
226
227 gettimeofday(&start, NULL);
228
229 while (1)
230 {
231 for (i = 0; i < in_dev_count; i++) {
232 in_dev_t *d = &in_devices[i];
233 if (!d->probed)
234 continue;
235
236 result = DRV(d->drv_id).update_keycode(d->drv_data, &is_down);
237 if (result == -1)
238 continue;
239
240 if (dev_id_out)
241 *dev_id_out = i;
242 if (is_down_out)
243 *is_down_out = is_down;
244 return result;
245 }
246
247 if (timeout_ms >= 0) {
248 gettimeofday(&now, NULL);
249 if ((now.tv_sec - start.tv_sec) * 1000 +
250 (now.tv_usec - start.tv_usec) / 1000 > timeout_ms)
251 break;
252 }
253
254 usleep(10000);
255 }
256
257 return -1;
258}
7f022a8d 259
34581c95 260/*
13b692eb 261 * wait for a press, always return some keycode or -1 on timeout or error
34581c95 262 */
906bdc9f 263int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
34581c95 264{
fce20e73 265 int result = 0, dev_id = 0, is_down, result_menu;
7f022a8d 266 int fds_hnds[IN_MAX_DEVS];
267 int i, ret, count = 0;
268 in_drv_t *drv;
269
13b692eb 270 if (in_have_async_devs) {
271 result = in_update_kc_async(&dev_id, &is_down, timeout_ms);
272 if (result == -1)
273 return -1;
274 drv = &DRV(in_devices[dev_id].drv_id);
275 goto finish;
276 }
277
7f022a8d 278 for (i = 0; i < in_dev_count; i++) {
279 if (in_devices[i].probed)
280 fds_hnds[count++] = in_devices[i].drv_fd_hnd;
281 }
34581c95 282
283 if (count == 0) {
284 /* don't deadlock, fail */
285 printf("input: failed to find devices to read\n");
286 exit(1);
287 }
288
7f022a8d 289again:
290 /* TODO: move this block to platform/linux */
291 {
292 struct timeval tv, *timeout = NULL;
293 int fdmax = -1;
294 fd_set fdset;
295
296 if (timeout_ms >= 0) {
297 tv.tv_sec = timeout_ms / 1000;
298 tv.tv_usec = (timeout_ms % 1000) * 1000;
299 timeout = &tv;
300 }
595491c4 301
7f022a8d 302 FD_ZERO(&fdset);
303 for (i = 0; i < count; i++) {
304 if (fds_hnds[i] > fdmax) fdmax = fds_hnds[i];
305 FD_SET(fds_hnds[i], &fdset);
306 }
307
308 ret = select(fdmax + 1, &fdset, NULL, NULL, timeout);
309 if (ret == -1)
310 {
311 perror("input: select failed");
312 sleep(1);
13b692eb 313 return -1;
7f022a8d 314 }
315
316 if (ret == 0)
13b692eb 317 return -1; /* timeout */
7f022a8d 318
319 for (i = 0; i < count; i++)
320 if (FD_ISSET(fds_hnds[i], &fdset))
321 ret = fds_hnds[i];
322 }
323
324 for (i = 0; i < in_dev_count; i++) {
325 if (in_devices[i].drv_fd_hnd == ret) {
906bdc9f 326 dev_id = i;
327 break;
595491c4 328 }
329 }
7f022a8d 330
331 drv = &DRV(in_devices[dev_id].drv_id);
332 result = drv->update_keycode(in_devices[dev_id].drv_data, &is_down);
333
13b692eb 334 /* update_keycode() might return -1 when some not interesting
7f022a8d 335 * event happened, like sync event for evdev.
336 * XXX: timeout restarts.. */
13b692eb 337 if (result == -1)
7f022a8d 338 goto again;
34581c95 339
13b692eb 340finish:
906bdc9f 341 /* keep track of menu key state, to allow mixing
fce20e73 342 * in_update_keycode() and in_menu_wait_any() calls */
7f022a8d 343 result_menu = drv->menu_translate(result);
906bdc9f 344 if (result_menu != 0) {
345 if (is_down)
346 menu_key_state |= result_menu;
347 else
348 menu_key_state &= ~result_menu;
349 }
350
351 if (dev_id_out != NULL)
352 *dev_id_out = dev_id;
353 if (is_down_out != NULL)
354 *is_down_out = is_down;
34581c95 355 return result;
356}
357
fce20e73 358/* same as above, only return bitfield of PBTN_* */
359int in_menu_wait_any(int timeout_ms)
595491c4 360{
906bdc9f 361 int keys_old = menu_key_state;
595491c4 362
363 while (1)
364 {
da767bd5 365 int code, is_down = 0, dev_id = 0;
595491c4 366
906bdc9f 367 code = in_update_keycode(&dev_id, &is_down, timeout_ms);
13b692eb 368 if (code >= 0)
369 code = DRV(in_devices[dev_id].drv_id).menu_translate(code);
595491c4 370
fce20e73 371 if (timeout_ms >= 0)
906bdc9f 372 break;
13b692eb 373 if (code < 0)
906bdc9f 374 continue;
375 if (keys_old != menu_key_state)
595491c4 376 break;
377 }
378
906bdc9f 379 return menu_key_state;
595491c4 380}
381
fce20e73 382/* wait for menu input, do autorepeat */
383int in_menu_wait(int interesting)
384{
385 static int inp_prev = 0;
6c263f30 386 static int repeats = 0;
387 int ret, release = 0, wait = 666;
fce20e73 388
6c263f30 389 if (repeats)
390 wait = 33;
fce20e73 391
6c263f30 392 ret = in_menu_wait_any(wait);
393 if (ret == inp_prev)
394 repeats++;
fce20e73 395
396 while (!(ret & interesting)) {
397 ret = in_menu_wait_any(-1);
398 release = 1;
399 }
400
6c263f30 401 if (release || ret != inp_prev)
fce20e73 402 repeats = 0;
6c263f30 403
fce20e73 404 inp_prev = ret;
405
6c263f30 406 /* we don't need diagonals in menus */
fce20e73 407 if ((ret & PBTN_UP) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
408 if ((ret & PBTN_UP) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
409 if ((ret & PBTN_DOWN) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
410 if ((ret & PBTN_DOWN) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
411
412 return ret;
413}
414
da767bd5 415const int *in_get_dev_binds(int dev_id)
416{
417 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
418 return NULL;
419
420 return in_devices[dev_id].binds;
421}
422
423const int *in_get_dev_def_binds(int dev_id)
424{
425 int count;
426
427 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
428 return NULL;
429
430 count = in_bind_count(in_devices[dev_id].drv_id);
431 return in_devices[dev_id].binds + count;
432}
433
434int in_get_dev_bind_count(int dev_id)
435{
436 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
437 return 0;
438
439 return in_bind_count(in_devices[dev_id].drv_id);
440}
441
fce20e73 442const char *in_get_dev_name(int dev_id, int must_be_active)
da767bd5 443{
444 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
445 return NULL;
446
fce20e73 447 if (must_be_active && !in_devices[dev_id].probed)
448 return NULL;
da767bd5 449 return in_devices[dev_id].name;
450}
451
906bdc9f 452/* never returns NULL */
595491c4 453const char *in_get_key_name(int dev_id, int keycode)
454{
906bdc9f 455 static char xname[16];
456 const char *name;
457
595491c4 458 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
459 return "Unkn0";
da767bd5 460
906bdc9f 461 name = DRV(in_devices[dev_id].drv_id).get_key_name(keycode);
462 if (name != NULL)
463 return name;
464
465 /* assume scancode */
466 if ((keycode >= '0' && keycode <= '9') || (keycode >= 'a' && keycode <= 'z')
467 || (keycode >= 'A' && keycode <= 'Z'))
468 sprintf(xname, "%c", keycode);
469 else
470 sprintf(xname, "\\x%02X", keycode);
471 return xname;
472}
473
474int in_bind_key(int dev_id, int keycode, int mask, int force_unbind)
475{
476 int ret, count;
477 in_dev_t *dev;
478
479 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
480 return -1;
481 dev = &in_devices[dev_id];
482
483 if (dev->binds == NULL) {
484 if (force_unbind)
485 return 0;
486 dev->binds = in_alloc_binds(dev->drv_id);
487 if (dev->binds == NULL)
488 return -1;
489 }
490
491 count = in_bind_count(dev->drv_id);
492 if (keycode < 0 || keycode >= count)
493 return -1;
494
495 if (force_unbind)
496 dev->binds[keycode] &= ~mask;
497 else
498 dev->binds[keycode] ^= mask;
499
500 ret = DRV(dev->drv_id).clean_binds(dev->drv_data, dev->binds);
501 if (ret == 0) {
502 free(dev->binds);
503 dev->binds = NULL;
504 }
505
506 return 0;
da767bd5 507}
508
509/* returns device id, or -1 on error */
510int in_config_parse_dev(const char *name)
511{
512 int drv_id = -1, i;
513
514 for (i = 0; i < IN_DRVID_COUNT; i++) {
515 int len = strlen(in_drivers[i].prefix);
516 if (strncmp(name, in_drivers[i].prefix, len) == 0) {
517 drv_id = i;
518 break;
519 }
520 }
521
522 if (drv_id < 0) {
523 printf("input: missing driver for %s\n", name);
524 return -1;
525 }
526
527 for (i = 0; i < in_dev_count; i++)
528 {
529 if (in_devices[i].name == NULL)
530 continue;
531 if (strcmp(in_devices[i].name, name) == 0)
532 return i;
533 }
534
535 if (i >= IN_MAX_DEVS)
536 {
537 /* try to find unused device */
538 for (i = 0; i < IN_MAX_DEVS; i++)
539 if (in_devices[i].name == NULL) break;
540 if (i >= IN_MAX_DEVS) {
541 printf("input: too many devices, can't add %s\n", name);
542 return -1;
543 }
544 }
545
546 memset(&in_devices[i], 0, sizeof(in_devices[i]));
547
548 in_devices[i].name = strdup(name);
549 if (in_devices[i].name == NULL)
550 return -1;
551
552 if (i + 1 > in_dev_count)
553 in_dev_count = i + 1;
554 in_devices[i].drv_id = drv_id;
555
556 return i;
557}
558
6c263f30 559/*
560 * To reduce size of game specific configs, default binds are not saved.
561 * So we mark default binds in in_config_start(), override them in in_config_bind_key(),
562 * and restore whatever default binds are left in in_config_end().
563 */
da767bd5 564void in_config_start(void)
565{
566 int i;
567
568 /* mark all default binds, so they get overwritten by func below */
569 for (i = 0; i < IN_MAX_DEVS; i++) {
570 int n, count, *binds, *def_binds;
571
906bdc9f 572 binds = in_devices[i].binds;
573 if (binds == NULL)
da767bd5 574 continue;
575
576 count = in_bind_count(in_devices[i].drv_id);
da767bd5 577 def_binds = binds + count;
578
579 for (n = 0; n < count; n++)
580 if (binds[n] == def_binds[n])
581 binds[n] = -1;
582 }
583}
584
585int in_config_bind_key(int dev_id, const char *key, int binds)
586{
906bdc9f 587 int count, kc;
588 in_dev_t *dev;
da767bd5 589
590 if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
591 return -1;
906bdc9f 592 dev = &in_devices[dev_id];
da767bd5 593
906bdc9f 594 count = in_bind_count(dev->drv_id);
595
596 /* maybe a raw code? */
597 if (key[0] == '\\' && key[1] == 'x') {
598 char *p = NULL;
599 kc = (int)strtoul(key + 2, &p, 16);
600 if (p == NULL || *p != 0)
601 kc = -1;
602 }
603 else {
604 /* device specific key name */
605 if (dev->binds == NULL) {
606 dev->binds = in_alloc_binds(dev->drv_id);
607 if (dev->binds == NULL)
608 return -1;
609 in_config_start();
610 }
611
612 kc = DRV(dev->drv_id).get_key_code(key);
613 if (kc < 0 && strlen(key) == 1) {
614 /* assume scancode */
615 kc = key[0];
616 }
da767bd5 617 }
618
906bdc9f 619 if (kc < 0 || kc >= count) {
da767bd5 620 printf("input: bad key: %s\n", key);
621 return -1;
595491c4 622 }
623
906bdc9f 624 if (dev->binds[kc] == -1)
625 dev->binds[kc] = 0;
626 dev->binds[kc] |= binds;
da767bd5 627
628 return 0;
629}
630
631void in_config_end(void)
632{
633 int i;
634
635 for (i = 0; i < IN_MAX_DEVS; i++) {
636 int n, ret, count, *binds, *def_binds;
906bdc9f 637 in_dev_t *dev = &in_devices[i];
da767bd5 638
906bdc9f 639 if (dev->binds == NULL)
da767bd5 640 continue;
641
906bdc9f 642 count = in_bind_count(dev->drv_id);
643 binds = dev->binds;
da767bd5 644 def_binds = binds + count;
645
646 for (n = 0; n < count; n++)
647 if (binds[n] == -1)
648 binds[n] = def_binds[n];
649
906bdc9f 650 if (dev->drv_data == NULL)
da767bd5 651 continue;
652
906bdc9f 653 ret = DRV(dev->drv_id).clean_binds(dev->drv_data, binds);
da767bd5 654 if (ret == 0) {
655 /* no useable binds */
906bdc9f 656 free(dev->binds);
657 dev->binds = NULL;
da767bd5 658 }
659 }
595491c4 660}
661
da767bd5 662void in_debug_dump(void)
663{
664 int i;
665
666 printf("# drv probed binds name\n");
667 for (i = 0; i < IN_MAX_DEVS; i++) {
668 in_dev_t *d = &in_devices[i];
669 if (!d->probed && d->name == NULL && d->binds == NULL)
670 continue;
671 printf("%d %3d %6c %5c %s\n", i, d->drv_id, d->probed ? 'y' : 'n',
672 d->binds ? 'y' : 'n', d->name);
673 }
674}
675
676/* handlers for unknown/not_preset drivers */
677
678static void in_def_probe(void) {}
679static void in_def_free(void *drv_data) {}
680static int in_def_get_bind_count(void) { return 0; }
681static void in_def_get_def_binds(int *binds) {}
682static int in_def_clean_binds(void *drv_data, int *binds) { return 0; }
683static void in_def_set_blocking(void *data, int y) {}
7f022a8d 684static int in_def_update_keycode(void *drv_data, int *is_down) { return 0; }
da767bd5 685static int in_def_menu_translate(int keycode) { return keycode; }
686static int in_def_get_key_code(const char *key_name) { return 0; }
687static const char *in_def_get_key_name(int keycode) { return NULL; }
688
2258f158 689void in_init(void)
690{
da767bd5 691 int i;
692
693 memset(in_drivers, 0, sizeof(in_drivers));
2258f158 694 memset(in_devices, 0, sizeof(in_devices));
695 in_dev_count = 0;
da767bd5 696
697 for (i = 0; i < IN_DRVID_COUNT; i++) {
698 in_drivers[i].prefix = "none:";
699 in_drivers[i].probe = in_def_probe;
700 in_drivers[i].free = in_def_free;
701 in_drivers[i].get_bind_count = in_def_get_bind_count;
702 in_drivers[i].get_def_binds = in_def_get_def_binds;
703 in_drivers[i].clean_binds = in_def_clean_binds;
704 in_drivers[i].set_blocking = in_def_set_blocking;
7f022a8d 705 in_drivers[i].update_keycode = in_def_update_keycode;
da767bd5 706 in_drivers[i].menu_translate = in_def_menu_translate;
707 in_drivers[i].get_key_code = in_def_get_key_code;
708 in_drivers[i].get_key_name = in_def_get_key_name;
709 }
710
13b692eb 711#ifdef IN_GP2X
712 in_gp2x_init(&in_drivers[IN_DRVID_GP2X]);
713#endif
da767bd5 714#ifdef IN_EVDEV
715 in_evdev_init(&in_drivers[IN_DRVID_EVDEV]);
716#endif
2258f158 717}
718
da767bd5 719#if 0
2258f158 720int main(void)
721{
34581c95 722 int ret;
723
2258f158 724 in_init();
725 in_probe();
726
595491c4 727 in_set_blocking(1);
728
729#if 1
730 while (1) {
731 int dev = 0, down;
732 ret = in_update_keycode(&dev, &down);
733 printf("#%i: %i %i (%s)\n", dev, down, ret, in_get_key_name(dev, ret));
734 }
735#else
2258f158 736 while (1) {
fce20e73 737 ret = in_menu_wait_any();
34581c95 738 printf("%08x\n", ret);
2258f158 739 }
595491c4 740#endif
2258f158 741
742 return 0;
743}
da767bd5 744#endif