aboutsummaryrefslogtreecommitdiffstats
path: root/libgamepad_open_device.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-25 12:35:05 +0200
committerMattias Andrée <maandree@kth.se>2022-07-25 12:35:05 +0200
commit41ae3f04fd22d22c552742458344591061822884 (patch)
tree00ef785370327ebf578efa49a38c430523c4924a /libgamepad_open_device.c
parentAdd test-visual (diff)
downloadlibgamepad-41ae3f04fd22d22c552742458344591061822884.tar.gz
libgamepad-41ae3f04fd22d22c552742458344591061822884.tar.bz2
libgamepad-41ae3f04fd22d22c552742458344591061822884.tar.xz
m + add force feedback support
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamepad_open_device.c')
-rw-r--r--libgamepad_open_device.c5
1 files changed, 5 insertions, 0 deletions
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)