Embed:
(wiki syntax)
Show/hide line numbers
USBAbsMouse.h
00001 /* USBAbsMouse.h */ 00002 /* USB device example: Mouse with absolute positioning */ 00003 /* Copyright (c) 2011 ARM Limited. All rights reserved. */ 00004 00005 #ifndef _ABSOLUTE_MOUSE_ 00006 #define _ABSOLUTE_MOUSE_ 00007 00008 #include "GenericMouse.h" 00009 #include "USBHID.h" 00010 00011 /** USB device: an absolute mouse 00012 * 00013 * Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard. 00014 * 00015 * Example: 00016 * @code 00017 * 00018 * #include "mbed.h" 00019 * #include "USBAbsMouse.h" 00020 * 00021 * USBAbsMouse mouse; 00022 * 00023 * #define STEP (20) 00024 * 00025 * int main(void) 00026 * { 00027 * int32_t a = X_MIN; 00028 * int32_t dir = STEP; 00029 * 00030 * while (1) 00031 * { 00032 * mouse.move(a, a); 00033 * 00034 * if (((a+dir) > X_MAX) || ((a+dir) < X_MIN)) 00035 * { 00036 * // Change direction 00037 * dir = -dir; 00038 * } 00039 * 00040 * a += dir; 00041 * } 00042 * } 00043 * 00044 * @endcode 00045 */ 00046 class USBAbsMouse: public GenericMouse, public USBHID 00047 { 00048 public: 00049 /** 00050 * Constructor for a USBAbsMouse (an absolute mouse) 00051 */ 00052 USBAbsMouse(){}; 00053 00054 /** 00055 * Write a state of the mouse 00056 * 00057 * @param x x absolute position 00058 * @param y y absolute position 00059 * @param buttons buttons state (first bit represents MOUSE_LEFT, second bit MOUSE_RIGHT and third bit MOUSE_MIDDLE) 00060 * @param z wheel state (>0 to scroll down, <0 to scroll up) 00061 * @return true if there is no error, false otherwise 00062 */ 00063 virtual bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z); 00064 00065 virtual uint8_t * ReportDesc(); 00066 00067 00068 00069 }; 00070 00071 #endif
Generated on Fri Jul 15 2022 02:22:27 by 1.7.2