Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
samux
Date:
Wed Mar 13 10:23:01 2013 +0000
Revision:
5:e48791a1ef18
Parent:
4:b320d68e98e7
Child:
8:93da8ea2708b
add button, x, y, z event callbacks

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:a554658735bf 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
mbed_official 0:a554658735bf 2 *
mbed_official 0:a554658735bf 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 0:a554658735bf 4 * and associated documentation files (the "Software"), to deal in the Software without
mbed_official 0:a554658735bf 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
mbed_official 0:a554658735bf 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
mbed_official 0:a554658735bf 7 * Software is furnished to do so, subject to the following conditions:
mbed_official 0:a554658735bf 8 *
mbed_official 0:a554658735bf 9 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 0:a554658735bf 10 * substantial portions of the Software.
mbed_official 0:a554658735bf 11 *
mbed_official 0:a554658735bf 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 0:a554658735bf 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 0:a554658735bf 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 0:a554658735bf 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:a554658735bf 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 0:a554658735bf 17 */
mbed_official 0:a554658735bf 18
mbed_official 0:a554658735bf 19 #ifndef USBHOSTMOUSE_H
mbed_official 0:a554658735bf 20 #define USBHOSTMOUSE_H
mbed_official 0:a554658735bf 21
mbed_official 0:a554658735bf 22 #include "USBHostConf.h"
mbed_official 0:a554658735bf 23
mbed_official 0:a554658735bf 24 #if USBHOST_MOUSE
mbed_official 0:a554658735bf 25
mbed_official 0:a554658735bf 26 #include "USBHost.h"
mbed_official 0:a554658735bf 27
samux 1:0a457e34fa9e 28 /**
samux 1:0a457e34fa9e 29 * A class to communicate a USB mouse
samux 1:0a457e34fa9e 30 */
mbed_official 0:a554658735bf 31 class USBHostMouse : public IUSBEnumerator {
mbed_official 0:a554658735bf 32 public:
mbed_official 0:a554658735bf 33
mbed_official 0:a554658735bf 34 /**
mbed_official 0:a554658735bf 35 * Constructor
mbed_official 0:a554658735bf 36 */
mbed_official 0:a554658735bf 37 USBHostMouse();
mbed_official 0:a554658735bf 38
mbed_official 0:a554658735bf 39 /**
mbed_official 0:a554658735bf 40 * Try to connect a mouse device
mbed_official 0:a554658735bf 41 *
samux 3:0f5c32575eb8 42 * @return true if connection was successful
mbed_official 0:a554658735bf 43 */
mbed_official 0:a554658735bf 44 bool connect();
mbed_official 0:a554658735bf 45
mbed_official 0:a554658735bf 46 /**
mbed_official 0:a554658735bf 47 * Check if a mouse is connected
mbed_official 0:a554658735bf 48 *
mbed_official 0:a554658735bf 49 * @returns true if a mouse is connected
mbed_official 0:a554658735bf 50 */
mbed_official 0:a554658735bf 51 bool connected();
mbed_official 0:a554658735bf 52
mbed_official 0:a554658735bf 53 /**
mbed_official 0:a554658735bf 54 * Attach a callback called when a mouse event is received
mbed_official 0:a554658735bf 55 *
samux 2:5e8fdc541b98 56 * @param ptr function pointer
mbed_official 0:a554658735bf 57 */
samux 5:e48791a1ef18 58 inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) {
mbed_official 0:a554658735bf 59 if (ptr != NULL) {
mbed_official 0:a554658735bf 60 onUpdate = ptr;
mbed_official 0:a554658735bf 61 }
mbed_official 0:a554658735bf 62 }
samux 5:e48791a1ef18 63
samux 5:e48791a1ef18 64 /**
samux 5:e48791a1ef18 65 * Attach a callback called when the button state changes
samux 5:e48791a1ef18 66 *
samux 5:e48791a1ef18 67 * @param ptr function pointer
samux 5:e48791a1ef18 68 */
samux 5:e48791a1ef18 69 inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) {
samux 5:e48791a1ef18 70 if (ptr != NULL) {
samux 5:e48791a1ef18 71 onButtonUpdate = ptr;
samux 5:e48791a1ef18 72 }
samux 5:e48791a1ef18 73 }
samux 5:e48791a1ef18 74
samux 5:e48791a1ef18 75 /**
samux 5:e48791a1ef18 76 * Attach a callback called when the X axis value changes
samux 5:e48791a1ef18 77 *
samux 5:e48791a1ef18 78 * @param ptr function pointer
samux 5:e48791a1ef18 79 */
samux 5:e48791a1ef18 80 inline void attachXEvent(void (*ptr)(int8_t x)) {
samux 5:e48791a1ef18 81 if (ptr != NULL) {
samux 5:e48791a1ef18 82 onXUpdate = ptr;
samux 5:e48791a1ef18 83 }
samux 5:e48791a1ef18 84 }
samux 5:e48791a1ef18 85
samux 5:e48791a1ef18 86 /**
samux 5:e48791a1ef18 87 * Attach a callback called when the Y axis value changes
samux 5:e48791a1ef18 88 *
samux 5:e48791a1ef18 89 * @param ptr function pointer
samux 5:e48791a1ef18 90 */
samux 5:e48791a1ef18 91 inline void attachYEvent(void (*ptr)(int8_t y)) {
samux 5:e48791a1ef18 92 if (ptr != NULL) {
samux 5:e48791a1ef18 93 onYUpdate = ptr;
samux 5:e48791a1ef18 94 }
samux 5:e48791a1ef18 95 }
samux 5:e48791a1ef18 96
samux 5:e48791a1ef18 97 /**
samux 5:e48791a1ef18 98 * Attach a callback called when the Z axis value changes (scrolling)
samux 5:e48791a1ef18 99 *
samux 5:e48791a1ef18 100 * @param ptr function pointer
samux 5:e48791a1ef18 101 */
samux 5:e48791a1ef18 102 inline void attachZEvent(void (*ptr)(int8_t z)) {
samux 5:e48791a1ef18 103 if (ptr != NULL) {
samux 5:e48791a1ef18 104 onZUpdate = ptr;
samux 5:e48791a1ef18 105 }
samux 5:e48791a1ef18 106 }
mbed_official 0:a554658735bf 107
mbed_official 0:a554658735bf 108 protected:
mbed_official 0:a554658735bf 109 //From IUSBEnumerator
mbed_official 0:a554658735bf 110 virtual void setVidPid(uint16_t vid, uint16_t pid);
mbed_official 0:a554658735bf 111 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
mbed_official 0:a554658735bf 112 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
mbed_official 0:a554658735bf 113
mbed_official 0:a554658735bf 114 private:
mbed_official 0:a554658735bf 115 USBHost * host;
mbed_official 0:a554658735bf 116 USBDeviceConnected * dev;
mbed_official 0:a554658735bf 117 USBEndpoint * int_in;
mbed_official 0:a554658735bf 118 uint8_t report[4];
mbed_official 0:a554658735bf 119
mbed_official 0:a554658735bf 120 bool dev_connected;
mbed_official 0:a554658735bf 121 bool mouse_device_found;
mbed_official 0:a554658735bf 122 int mouse_intf;
mbed_official 0:a554658735bf 123
samux 5:e48791a1ef18 124 uint8_t buttons;
samux 5:e48791a1ef18 125 int8_t x;
samux 5:e48791a1ef18 126 int8_t y;
samux 5:e48791a1ef18 127 int8_t z;
samux 5:e48791a1ef18 128
mbed_official 0:a554658735bf 129 void rxHandler();
mbed_official 0:a554658735bf 130 void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z);
samux 5:e48791a1ef18 131 void (*onButtonUpdate)(uint8_t buttons);
samux 5:e48791a1ef18 132 void (*onXUpdate)(int8_t x);
samux 5:e48791a1ef18 133 void (*onYUpdate)(int8_t y);
samux 5:e48791a1ef18 134 void (*onZUpdate)(int8_t z);
mbed_official 0:a554658735bf 135 int report_id;
mbed_official 0:a554658735bf 136 void init();
mbed_official 0:a554658735bf 137 };
mbed_official 0:a554658735bf 138
mbed_official 0:a554658735bf 139 #endif
mbed_official 0:a554658735bf 140
mbed_official 0:a554658735bf 141 #endif