File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## USBMouse relative positioning example
2
+
3
+ The example emulates mouse over USB port.
4
+
5
+ 1 . Flash the board, and ensure the target's auxiliary USB is plugged into the PC.
6
+ 2 . Reset the target.
7
+ 3 . The mouse pointer should move on the screen making a cycle.
8
+
9
+ ** Note:** With a relative mouse, the USBMouse move function will move the mouse x, y pixels away from its previous position on the screen.
10
+ MIRRORED FROM MASTER EXAMPLE SNIPPETS REPOSITORY: mbed-os-examples-docs_only.
11
+ ANY CHANGES MADE DIRECTLY TO THIS REPOSITORY WILL BE AUTOMATICALLY OVERWRITTEN.
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2006-2020 Arm Limited and affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ #include " mbed.h"
6
+ #include " USBMouse.h"
7
+
8
+ // create mouse object
9
+ USBMouse mouse;
10
+
11
+ int main ()
12
+ {
13
+ int16_t x = 0 ;
14
+ int16_t y = 0 ;
15
+ int32_t radius = 10 ;
16
+ int32_t angle = 0 ;
17
+
18
+ while (1 ) {
19
+ // will cause mouse to move in a circle
20
+ x = cos ((double )angle * 3.14 / 180.0 ) * radius;
21
+ y = sin ((double )angle * 3.14 / 180.0 ) * radius;
22
+
23
+ // will move mouse x, y away from its previous position on the screen
24
+ mouse.move (x, y);
25
+ angle += 3 ;
26
+ ThisThread::sleep_for (10 );
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ https://github.com/ARMmbed/mbed-os/#9a8c9e2c297f64c805698d72cd541ff3cd7fe538
You can’t perform that action at this time.
0 commit comments