Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e87a471

Browse files
committedMay 21, 2020
Mirrored from master snippet repository
0 parents  commit e87a471

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
 

‎README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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.

‎main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

‎mbed-os.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/ARMmbed/mbed-os/#9a8c9e2c297f64c805698d72cd541ff3cd7fe538

0 commit comments

Comments
 (0)
Please sign in to comment.