From 967a7f656cd741bbd5423eb740c8763bd5c14110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= Date: Wed, 26 Mar 2025 18:11:00 +0100 Subject: [PATCH] build correct with new adb value --- lib/ADB-pour-Framework-Arduino | 2 +- src/hid_keyboard.cpp | 20 +++++++++++++++++ src/hid_keyboard.h | 39 ++++++++++++---------------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/lib/ADB-pour-Framework-Arduino b/lib/ADB-pour-Framework-Arduino index b3a1047..a18f716 160000 --- a/lib/ADB-pour-Framework-Arduino +++ b/lib/ADB-pour-Framework-Arduino @@ -1 +1 @@ -Subproject commit b3a104781ea91c907d3545b028743f837acdbd9e +Subproject commit a18f71613a14df5f3d71080748c17409f1c2ce23 diff --git a/src/hid_keyboard.cpp b/src/hid_keyboard.cpp index f419d1e..fb2e516 100644 --- a/src/hid_keyboard.cpp +++ b/src/hid_keyboard.cpp @@ -136,3 +136,23 @@ bool hid_keyboard_remove_key_from_report(hid_key_report* report, uint8_t hid_key } return report_changed; } + +/** + * @brief Met à jour les modificateurs dans le rapport HID. + * + * @param report Pointeur vers le rapport HID. + * @param modifier Code du modificateur (ex. Shift, Ctrl). + * @param pressed Indique si le modificateur est pressé (true) ou relâché (false). + * @return true si le rapport a été modifié, false sinon. + */ +bool hid_keyboard_update_modifier_in_report(hid_key_report* report, uint8_t modifier, bool pressed) { + uint8_t old_modifiers = report->modifiers; + + if (pressed) { + report->modifiers |= modifier; // Active le bit correspondant au modificateur. + } else { + report->modifiers &= ~modifier; // Désactive le bit correspondant au modificateur. + } + + return old_modifiers != report->modifiers; // Retourne true si le rapport a été modifié. +} diff --git a/src/hid_keyboard.h b/src/hid_keyboard.h index d9ff567..21444d3 100644 --- a/src/hid_keyboard.h +++ b/src/hid_keyboard.h @@ -4,17 +4,15 @@ * @part of Apple-ADB-Ressurector * Inspiré et basé sur le travail initial de Szymon Łopaciuk https://github.com/szymonlopaciuk/stm32-adb2usb * - * * @date 2025 - * @author Clément SAILLANT - * Dépôt actuel : https://github.com/electron-rare/Apple-ADB-Ressurector * @license GNU GPL v3 */ -#ifndef HID_KEYBOARD_h -#define HID_KEYBOARD_h +#ifndef HID_KEYBOARD_H +#define HID_KEYBOARD_H #include +#include #include "adb.h" #define KEY_REPORT_KEYS_COUNT 6 /**< Nombre maximum de touches dans un rapport HID. */ @@ -54,15 +52,6 @@ void hid_keyboard_send_report(hid_key_report* report); */ bool hid_keyboard_set_keys_from_adb_register(hid_key_report* report, adb_data reg); -/** - * @brief Met à jour les modificateurs du rapport HID à partir d'un registre ADB. - * - * @param report Pointeur vers le rapport HID. - * @param reg Données du registre ADB. - * @return true si le rapport a été modifié, false sinon. - */ -bool hid_keyboard_set_modifiers_from_adb_register(hid_key_report* report, adb_data reg); - /** * @brief Met à jour une touche spécifique dans le rapport HID. * @@ -73,16 +62,6 @@ bool hid_keyboard_set_modifiers_from_adb_register(hid_key_report* report, adb_da */ bool hid_keyboard_update_key_in_report(hid_key_report* report, uint8_t hid_keycode, bool released); -/** - * @brief Met à jour un modificateur spécifique dans le rapport HID. - * - * @param report Pointeur vers le rapport HID. - * @param adb_keycode Code ADB du modificateur. - * @param released Indique si le modificateur est relâché. - * @return true si le rapport a été modifié, false sinon. - */ -bool hid_keyboard_update_modifier_in_report(hid_key_report* report, uint8_t adb_keycode, bool released); - /** * @brief Ajoute une touche au rapport HID. * @@ -101,4 +80,14 @@ bool hid_keyboard_add_key_to_report(hid_key_report* report, uint8_t hid_keycode) */ bool hid_keyboard_remove_key_from_report(hid_key_report* report, uint8_t hid_keycode); -#endif \ No newline at end of file +/** + * @brief Met à jour les modificateurs dans le rapport HID. + * + * @param report Pointeur vers le rapport HID. + * @param modifier Code du modificateur (ex. Shift, Ctrl). + * @param pressed Indique si le modificateur est pressé (true) ou relâché (false). + * @return true si le rapport a été modifié, false sinon. + */ +bool hid_keyboard_update_modifier_in_report(hid_key_report* report, uint8_t modifier, bool pressed); + +#endif // HID_KEYBOARD_H \ No newline at end of file