source: rtos_arduino/trunk/arduino_lib/libraries/USBHost/src/MouseController.cpp@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 2.2 KB
Line 
1/*
2 Copyright (c) 2012 Arduino. All right reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <MouseController.h>
20
21extern "C" {
22void __mouseControllerEmptyCallback() { }
23}
24
25void mouseClicked() __attribute__ ((weak, alias("__mouseControllerEmptyCallback")));
26void mouseDragged() __attribute__ ((weak, alias("__mouseControllerEmptyCallback")));
27void mouseMoved() __attribute__ ((weak, alias("__mouseControllerEmptyCallback")));
28void mousePressed() __attribute__ ((weak, alias("__mouseControllerEmptyCallback")));
29void mouseReleased() __attribute__ ((weak, alias("__mouseControllerEmptyCallback")));
30
31int MouseController::getXChange() {
32 int r = dx;
33 dx = 0;
34 return r;
35}
36
37int MouseController::getYChange() {
38 int r = dy;
39 dy = 0;
40 return r;
41}
42
43void MouseController::OnMouseMove(MOUSEINFO *mi) {
44 dx += mi->dX;
45 dy += mi->dY;
46 if (buttons != 0)
47 mouseDragged();
48 else
49 mouseMoved();
50}
51
52void MouseController::OnLeftButtonUp(MOUSEINFO *mi) {
53 buttons &= ~LEFT_BUTTON;
54 mouseReleased();
55 mouseClicked();
56}
57
58void MouseController::OnLeftButtonDown(MOUSEINFO *mi) {
59 buttons |= LEFT_BUTTON;
60 mousePressed();
61}
62
63void MouseController::OnMiddleButtonUp(MOUSEINFO *mi) {
64 buttons &= ~MIDDLE_BUTTON;
65 mouseReleased();
66 mouseClicked();
67}
68
69void MouseController::OnMiddleButtonDown(MOUSEINFO *mi) {
70 buttons |= MIDDLE_BUTTON;
71 mousePressed();
72}
73
74void MouseController::OnRightButtonUp(MOUSEINFO *mi) {
75 buttons &= ~RIGHT_BUTTON;
76 mouseReleased();
77 mouseClicked();
78}
79
80void MouseController::OnRightButtonDown(MOUSEINFO *mi) {
81 buttons |= RIGHT_BUTTON;
82 mousePressed();
83}
Note: See TracBrowser for help on using the repository browser.