Fonction:
keyCombi( a ) // le premier argument est toujours une constante Keycode ainsi que les suivants sauf le dernier argument
keyCombi( a, b ) // Le dernier argument peut être une constante Keycode ou un caractère sous forme de char, de tableau de char ou de String
keyCombi( a, b, c )
keyCombi( a, b, c, d )
Description:
Permet de créer des combinaisons de raccourcis, exemple:
CTRL+ALT+SUPP
CTRL+C
etc...
Arguments:
Prend 1 à 4 arguments, utilisent un char ou une constante Keycode
Le premier argument sera toujours une constante Keycode
Infos supplémentaires:
Cette fonction fonctionne en touche physique et non en valeur, par exemple ''E' , 'e' ou '€' sont égaux,
Les 3 appels donneront le même résultat:
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, 'E')
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, 'e')
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, '€');
Valeur de retour:
Retourne 1 si la fonction réussie sinon renvoie 0
Exemple:
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, 'A'); // tout sélectionner
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, 'C'); // copier
KeyboardEx.keyCombi(TINY_KEY_LEFT_CTRL, 'V'); // coller
Constantes utilisables (voir la déclaration de l'énumération Keycode dans le fichier KeyboardEx.h)
TINY_KEY_RETURN TINY_KEY_CAPS_LOCK TINY_KEY_ESCAPE TINY_KEY_BACKSPACE TINY_KEY_TAB TINY_KEY_SPACE TINY_KEY_PRINT_SCREEN TINY_KEY_SCROLL_LOCK TINY_KEY_PAUSE TINY_KEY_INSERT TINY_KEY_HOME TINY_KEY_DELETE TINY_KEY_END TINY_KEY_PAGE_UP TINY_KEY_PAGE_DOWN |
TINY_KEY_F1 TINY_KEY_F2 TINY_KEY_F3 TINY_KEY_F4 TINY_KEY_F5 TINY_KEY_F6 TINY_KEY_F7 TINY_KEY_F8 TINY_KEY_F9 TINY_KEY_F10 TINY_KEY_F11 TINY_KEY_F12 |
TINY_KEY_ARROW_RIGHT TINY_KEY_ARROW_LEFT_ TINY_KEY _ARROW_DOWN TINY_KEY_ARROW_UP TINY_KEY_APPLICATION TINY_KEY_CONTROL_LEFT TINY_KEY_SHIFT_LEFT TINY_KEY_ALT_LEFT TINY_KEY_GUI_LEFT TINY_KEY_CONTROL_RIGHT TINY_KEY_SHIFT_RIGHT TINY_KEY_ALT_RIGHT TINY_KEY_GUI_RIGHT |
Code:
#include "Adafruit_TinyUSB.h" #include "KeyboardEx.h" // Report ID enum { RID_KEYBOARD = 1, // RID_MOUSE, RID_CONSUMER_CONTROL, // Media, volume etc .. }; // HID report descriptor using TinyUSB's template uint8_t const desc_hid_report[] = { //TUD_HID_REPORT_DESC_KEYBOARD(), TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(RID_KEYBOARD) ), //TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(RID_MOUSE) ), TUD_HID_REPORT_DESC_CONSUMER( HID_REPORT_ID(RID_CONSUMER_CONTROL) ) }; Adafruit_USBD_HID usb_hid; // -------------------------------------------------------------------------- const char chaine_Clavier_FR[] = {" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€£¤§¨°²µÀÂÃÄÈÊËÌÎÏÑÒÔÕÖÙÛÜàâãäçèéêëìîïñòôõöùûüÿ"}; void setup() { usb_hid.setPollInterval(2); usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report)); usb_hid.setReportCallback(get_report_callback , hid_report_callback); usb_hid.begin(); KeyboardEx.begin(usb_hid, RID_KEYBOARD); // KeyboardEx.setOS(Windows); // Si vous êtes sur Windows, permet l'utilisation des Alt Codes. // KeyboardEx.setDelay(5); // valeur par défaut, si problème augmenter la valeur à 10. // Commenter ces lignes si vous n'utilisez oas le port série Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } delay(6000); } void loop() { static int oneloop = 0; byte ret = 0;
// n'aime pas le while(1) if (!oneloop) { oneloop = 1; // ************************************************************************************** // Test fonction -> KeyboardEx.keyCombi(...) // ************************************************************************************** KeyboardEx.println(F("*** Test fonction -> KeyboardEx.keyCombi(...) ***")); delay(1000); ret = KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'a'); // tout sélectionner delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'c'); // copier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_END); // touche Fin du clavier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_RETURN); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'v'); // coller delay(1000); delay(1000); ret = KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'A'); // tout sélectionner delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'C'); // copier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_END); // touche Fin du clavier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_RETURN); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, 'V'); // coller delay(1000); delay(1000); ret = KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, "A"); // tout sélectionner delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, "C"); // copier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_END); // touche Fin du clavier delay(1000); ret &= KeyboardEx.keyCombi(TINY_KEY_RETURN); ret &= KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, "V"); // coller delay(1000); // ret &=KeyboardEx.printKeypad(ret); // delay(3000); // ret &= KeyboardEx.keyCombi(TINY_KEY_GUI_LEFT, "e"); // lancer le poste de travail // delay(3000); // ret &=KeyboardEx.keyCombi(TINY_KEY_CONTROL_LEFT, TINY_KEY_ALT_LEFT, TINY_KEY_DELETE); // Gestionnaire de Tâche KeyboardEx.println(); KeyboardEx.print("Retour des fonctions: "); KeyboardEx.printKeypad(ret); KeyboardEx.end(); } } uint16_t get_report_callback (uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) { // Mettre Null à la place de get_report_callback dans cette fonction ci- dessous déclarée plus haut // si vous souhaitez supprmer cette procédure // usb_hid.setReportCallback(get_report_callback , hid_report_callback) -> usb_hid.setReportCallback(Null , hid_report_callback); // not used in this example return 0; } // Output report callback for LED indicator such as Caplocks void hid_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) { uint8_t ledIndicator; // LED indicator is output report with only 1 byte length if ( report_type != HID_REPORT_TYPE_OUTPUT ) return; // KEYBOARD_LED_KANA (8) | KEYBOARD_LED_COMPOSE (3) | KEYBOARD_LED_SCROLLLOCK (4) | KEYBOARD_LED_CAPSLOCK (2) | KEYBOARD_LED_NUMLOCK (1) // buffer[0] si clavier seul // ou buffer[1] si plusieurs reports if (bufsize == 2) { ledIndicator = buffer[1]; } else { ledIndicator = buffer[0]; } // Allumer la led de la carte si CAPSLOCK (verrouillage des majuscule) est activé // La led ne s'allumera pas sur Adafruit QT py car c'est une Neopixel // mais sur un Seeeduino XIAO ok digitalWrite(LED_BUILTIN, !(ledIndicator & KEYBOARD_LED_CAPSLOCK)); } |