diff --git a/main.c b/main.c index 74ea469..dde6cc5 100644 --- a/main.c +++ b/main.c @@ -84,7 +84,7 @@ int main(int argc, char ** argv) { //dev_out_thread_data.timeout_ms = 400; dev_out_thread_data.in_message_pipe_fd = in_message_pipes[0]; dev_out_thread_data.out_message_pipe_fd = out_message_pipes[1]; - dev_out_thread_data.gamepad = GAMEPAD_DUALSENSE; + dev_out_thread_data.gamepad = GAMEPAD_DUALSHOCK; pthread_t dev_in_thread; dev_in_thread_creation = pthread_create(&dev_in_thread, NULL, dev_in_thread_func, (void*)(&dev_in_thread_data)); diff --git a/virt_ds4.c b/virt_ds4.c index b9cfb53..d8cd663 100644 --- a/virt_ds4.c +++ b/virt_ds4.c @@ -504,6 +504,40 @@ int virt_dualshock_event(virt_dualshock_t *const gamepad, gamepad_status_t *cons const uint8_t lightbar_blink_on = ev.u.output.data[9]; const uint8_t lightbar_blink_off = ev.u.output.data[10]; + if ((valid_flag0 & DS4_OUTPUT_VALID_FLAG0_LED)) { + const out_message_t msg = { + .type = OUT_MSG_TYPE_LEDS, + .data = { + .leds = { + .r = lightbar_red, + .g = lightbar_green, + .b = lightbar_blue, + } + } + }; + + const int write_res = write(out_message_pipe_fd, (void*)&msg, sizeof(msg)); + if (write_res != 0) { + return write_res; + } + } else if (valid_flag0 & DS4_OUTPUT_VALID_FLAG0_LED_BLINK) { + const out_message_t msg = { + .type = OUT_MSG_TYPE_LEDS, + .data = { + .leds = { + .r = lightbar_red, + .g = lightbar_green, + .b = lightbar_blue, + } + } + }; + + const int write_res = write(out_message_pipe_fd, (void*)&msg, sizeof(msg)); + if (write_res != 0) { + return write_res; + } + } + if ((valid_flag0 & DS4_OUTPUT_VALID_FLAG0_MOTOR)) { out_device_status->motors_intensity[0] = motor_left; out_device_status->motors_intensity[1] = motor_right;