aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJan Düpmeier <j.duepmeier@googlemail.com>2017-11-07 11:32:11 +0100
committerJan Düpmeier <j.duepmeier@googlemail.com>2017-11-07 11:33:10 +0100
commit5793f6010fb6deb5d44be851adf7a2ecdcc38896 (patch)
tree83ab62f1c4382e600a82dde58fd2392f094ea22f
parent4265dc5892f4cec2aabf76b4922231d2878cc7ea (diff)
downloadmidimonster-5793f6010fb6deb5d44be851adf7a2ecdcc38896.tar.gz
midimonster-5793f6010fb6deb5d44be851adf7a2ecdcc38896.tar.bz2
midimonster-5793f6010fb6deb5d44be851adf7a2ecdcc38896.zip
uinput backend_start
-rw-r--r--uinput.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/uinput.c b/uinput.c
index e14ce59..9061c20 100644
--- a/uinput.c
+++ b/uinput.c
@@ -3,6 +3,8 @@
#include "minimonster.h"
#include "uinput.h"
+#define BACKEND_NAME "uinput"
+
int init() {
backend uinput = {
@@ -171,10 +173,52 @@ static int backend_handle(size_t num, managed_fd* fds) {
//TODO impl
}
-static int backend_start() {
+static int uinput_open_input_device(uinput_instance* data) {
+ if (!data->device_path) {
+ return 0;
+ }
+
+ data->fd_input = open(data->device_path, O_RDONLY | O_NONBLOCK);
+
+ if (data->fd_input < 0) {
+ fprintf(stderr, "Failed to open device %s: %s\n", data->device_path, strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
+
+static int uinput_create_output_device(uinput_instance* data) {
//TODO impl
}
+static int backend_start() {
+
+ size_t n;
+ instance** inst = NULL;
+ uinput_instance* data;
+ if (mm_backend_instances(BACKEND_NAME, &n, &inst)) {
+ fprintf(stderr, "Failed to fetch instance list\n");
+ return 1;
+ }
+
+ if (!n) {
+ free(inst);
+ return 0;
+ }
+
+ for (unsigned p = 0; p < n; p++) {
+ data = (uinput_instance*) inst[p]->impl;
+
+ if (data->name) {
+ uinput_create_output_device(data);
+ }
+ }
+
+ free(inst);
+ return 0;
+}
+
static int backend_shutdown() {
//TODO impl
}