Julius Werner | aa27929 | 2019-07-18 19:33:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 3 | * Use of this source code is governed by a BSD-style license that can be |
| 4 | * found in the LICENSE file. |
| 5 | */ |
| 6 | |
| 7 | #include "dev.h" |
| 8 | #include "input.h" |
| 9 | #include "util.h" |
| 10 | |
| 11 | /* |
| 12 | * We believe that there's a limit of 32 /dev/input/eventX devices in the |
| 13 | * kernel. It's not quite clear. Anyway, we should probably never have more than |
| 14 | * that in practice on Chrome OS anyway, so our algorithm is to check for the |
| 15 | * first 32 nodes explicitly, then keep checking for any further ones until we |
| 16 | * find an entry missing. (This is way simpler than using actual POSIX globbing |
| 17 | * or directory entry APIs.) |
| 18 | */ |
| 19 | #define EVDEV_MAX 32 |
| 20 | |
| 21 | int dev_init(void) |
| 22 | { |
| 23 | char path[64]; |
| 24 | int i; |
| 25 | |
| 26 | for (i = 0;; i++) { |
| 27 | snprintf(path, sizeof(path), "/dev/input/event%d", i); |
| 28 | if (access(path, F_OK)) { |
| 29 | if (i >= EVDEV_MAX) |
| 30 | break; |
| 31 | else |
| 32 | continue; |
| 33 | } |
| 34 | input_add(path); |
| 35 | } |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | void dev_close(void) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | void dev_add_fds(fd_set* read_set, fd_set* exception_set, int *maxfd) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | void dev_dispatch_io(fd_set* read_set, fd_set* exception_set) |
| 49 | { |
| 50 | } |