Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: F401RE-USBHost mbed
Fork of USBHostMouse_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "USBHostMouse.h" 00003 00004 DigitalOut led(LED1); 00005 00006 void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) { 00007 printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z); 00008 } 00009 00010 int main() { 00011 USBHostMouse mouse; 00012 // connect a USB mouse 00013 if (!mouse.connect()) { 00014 error("USB mouse not found.\n"); 00015 } 00016 // when connected, attach handler called on mouse event 00017 mouse.attachEvent(onMouseEvent); 00018 Timer t; 00019 t.reset(); 00020 t.start(); 00021 for(;;) { 00022 if (t.read_ms() > 500) { 00023 led = !led; 00024 t.reset(); 00025 } 00026 USBHost::poll(); 00027 } 00028 }
Generated on Thu Jul 21 2022 09:44:48 by
1.7.2
