From befcfe87b126ba3c438c598514de91f853b4a334 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 8 Dec 2023 20:01:20 +0100 Subject: [PATCH] why no rumble? --- dev_in.c | 7 +++++-- message.h | 4 ++-- virt_ds4.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dev_in.c b/dev_in.c index 3d256e5..e3c0f57 100644 --- a/dev_in.c +++ b/dev_in.c @@ -3,6 +3,7 @@ #include "message.h" #include "dev_evdev.h" #include "dev_iio.h" +#include typedef enum dev_in_type { DEV_IN_TYPE_NONE, @@ -195,9 +196,11 @@ static void handle_rumble_device(dev_in_ev_t *const in_dev, const out_message_ru } } + printf("Rumble for %s: l=%d, r=%d\n", libevdev_get_name(in_dev->evdev), (int)in_rumble_msg->motors_left, (int)in_rumble_msg->motors_right); + // load the new effect data - in_dev->ff_effect.u.rumble.strong_magnitude = in_rumble_msg->strong_magnitude; - in_dev->ff_effect.u.rumble.weak_magnitude = in_rumble_msg->weak_magnitude; + in_dev->ff_effect.u.rumble.strong_magnitude = in_rumble_msg->motors_left << (uint16_t)8; + in_dev->ff_effect.u.rumble.weak_magnitude = in_rumble_msg->motors_right << (uint16_t)8; // upload the new effect to the device const int effect_upload_res = ioctl(fd, EVIOCSFF, &in_dev->ff_effect); diff --git a/message.h b/message.h index 1fe3349..88d92fc 100644 --- a/message.h +++ b/message.h @@ -62,8 +62,8 @@ typedef struct in_message { typedef struct out_message_rumble { - uint16_t strong_magnitude; - uint16_t weak_magnitude; + uint8_t motors_left; + uint8_t motors_right; } out_message_rumble_t; typedef struct out_message_leds { diff --git a/virt_ds4.c b/virt_ds4.c index 404d951..4c3af70 100644 --- a/virt_ds4.c +++ b/virt_ds4.c @@ -648,8 +648,8 @@ int virt_dualshock_event(virt_dualshock_t *const gamepad, gamepad_status_t *cons .type = OUT_MSG_TYPE_RUMBLE, .data = { .rumble = { - .strong_magnitude = motor_left == 0 ? 0 : (uint16_t)0x00FF | ((uint16_t)motor_left << (uint16_t)8), - .weak_magnitude = motor_right == 0 ? 0 : (uint16_t)0x00FF | ((uint16_t)motor_right << (uint16_t)8), + .motors_left = motor_left, + .motors_right = motor_right, } } };