From 41ae3f04fd22d22c552742458344591061822884 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 25 Jul 2022 12:35:05 +0200 Subject: m + add force feedback support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libgamepad_open_device.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libgamepad_open_device.c') diff --git a/libgamepad_open_device.c b/libgamepad_open_device.c index 5b32658..87868cb 100644 --- a/libgamepad_open_device.c +++ b/libgamepad_open_device.c @@ -16,6 +16,7 @@ libgamepad_open_device(struct libgamepad_device *devicep, int dirfd, const char devicep->buttons = NULL; devicep->absolute_axes = NULL; devicep->relative_axes = NULL; + memset(devicep->force_feedback_support, 0, sizeof(devicep->force_feedback_support)); if (path && *path) { devicep->fd = openat(dirfd, path, mode); @@ -63,6 +64,10 @@ libgamepad_open_device(struct libgamepad_device *devicep, int dirfd, const char devicep->relative_axis_map[i] = (int16_t)devicep->nrelative_axes++; } + for (i = 0; i < FF_CNT; i++) + if (libevdev_has_event_code(devicep->dev, EV_FF, i)) + devicep->force_feedback_support[i / 8] |= (uint8_t)(1 << (i & 7)); + if (devicep->nbuttons) { devicep->buttons = calloc(devicep->nbuttons, sizeof(*devicep->buttons)); if (!devicep->buttons) -- cgit v1.2.3-70-g09d2