
USBHostMouse Hello World
Revision 0:c14069b9487e, committed 2013-03-06
- Comitter:
- samux
- Date:
- Wed Mar 06 17:06:16 2013 +0000
- Child:
- 1:81bb6aab8be3
- Commit message:
- USBHostMouse Hello World
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBHost.lib Wed Mar 06 17:06:16 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/USBHost/#a554658735bf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 06 17:06:16 2013 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "USBHostMouse.h" + +DigitalOut led(LED1); + +void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) { + printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z); +} + +void mouse_task(void const *) { + + USBHostMouse mouse; + + while(1) { + // try to connect a USB mouse + while(!mouse.connect()) + Thread::wait(500); + + // when connected, attach handler called on mouse event + mouse.attach(onMouseEvent); + + // wait until the mouse is disconnected + while(mouse.connected()) + Thread::wait(500); + } +} + +int main() { + Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4); + while(1) { + led=!led; + Thread::wait(500); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 06 17:06:16 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file