summaryrefslogtreecommitdiff
path: root/rcm-server-udev.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-server-udev.c')
-rw-r--r--rcm-server-udev.c62
1 files changed, 1 insertions, 61 deletions
diff --git a/rcm-server-udev.c b/rcm-server-udev.c
index d29b4d9..797335b 100644
--- a/rcm-server-udev.c
+++ b/rcm-server-udev.c
@@ -1,21 +1,18 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <libudev.h>
#include <unistd.h>
#include <string.h>
#include <systemd/sd-bus.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "utils.h"
#include "shared.h"
#include "rcm-server-main.h"
#include "rcm-server-keymap.h"
#include "rcm-server-evdev.h"
+#include "rcm-server-lirc.h"
#include "rcm-server-udev.h"
static void
@@ -37,63 +34,6 @@ remove_device(struct manager *mgr, struct udev_device *udev)
}
}
-static int
-lirc_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
-{
- struct device *device = userdata;
- uint8_t buf[100];
- ssize_t bytes_read;
-
- if (fd != device->lirc_fd)
- fprintf(stderr, "lirc fd mismatch: %i != %i\n", device->lirc_fd, fd);
-
- if (revents & EPOLLHUP) {
- fprintf(stderr, "lirc connection closed!\n");
- close(fd);
- device->lirc_fd = -1;
- return 0;
- }
-
- if (!(revents & EPOLLIN)) {
- fprintf(stderr, "unexpected lirc event: %" PRIu32 "\n", revents);
- return 0;
- }
-
- while ((bytes_read = read(fd, buf, sizeof(buf))) > 0)
- printf("Read %zi bytes from lirc dev\n", bytes_read);
-
- return 0;
-}
-
-static int
-lirc_setup(struct device *device, const char *path)
-{
- if (!device)
- return -EINVAL;
-
- if (device->lirc_fd >= 0) {
- printf("Multiple lirc devices!?\n");
- return 0;
- }
-
- device->lirc_fd = open(path, O_RDWR | O_NONBLOCK);
- if (device->lirc_fd < 0) {
- printf("Failed to open lirc device %s: %s\n", path, strerror(errno));
- return -errno;
- }
-
- if (sd_event_add_io(device->mgr->event, &device->lirc_ev,
- device->lirc_fd, EPOLLIN, lirc_read, device) < 0) {
- printf("Failed to add event source for lirc device %s: %s\n",
- path, strerror(errno));
- close(device->lirc_fd);
- device->lirc_fd = -1;
- return -errno;
- }
-
- return 0;
-}
-
static void
add_device(struct manager *mgr, struct udev_device *udev)
{