うおーるぼっとをWiiリモコンでコントロールする新しいプログラムです。 以前のものより、Wiiリモコンが早く繋がる様になりました。 It is a program which controls A with the Wii remote. ※ A Bluetooth dongle and a Wii remote control are needed.

Dependencies:   USBHost mbed FATFileSystem mbed-rtos

Committer:
jksoft
Date:
Mon Jun 10 16:01:50 2013 +0000
Revision:
0:fccb789424fc
1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:fccb789424fc 1 /* mbed USBHost Library
jksoft 0:fccb789424fc 2 * Copyright (c) 2006-2013 ARM Limited
jksoft 0:fccb789424fc 3 *
jksoft 0:fccb789424fc 4 * Licensed under the Apache License, Version 2.0 (the "License");
jksoft 0:fccb789424fc 5 * you may not use this file except in compliance with the License.
jksoft 0:fccb789424fc 6 * You may obtain a copy of the License at
jksoft 0:fccb789424fc 7 *
jksoft 0:fccb789424fc 8 * http://www.apache.org/licenses/LICENSE-2.0
jksoft 0:fccb789424fc 9 *
jksoft 0:fccb789424fc 10 * Unless required by applicable law or agreed to in writing, software
jksoft 0:fccb789424fc 11 * distributed under the License is distributed on an "AS IS" BASIS,
jksoft 0:fccb789424fc 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jksoft 0:fccb789424fc 13 * See the License for the specific language governing permissions and
jksoft 0:fccb789424fc 14 * limitations under the License.
jksoft 0:fccb789424fc 15 */
jksoft 0:fccb789424fc 16
jksoft 0:fccb789424fc 17 #ifndef USBHOSTMOUSE_H
jksoft 0:fccb789424fc 18 #define USBHOSTMOUSE_H
jksoft 0:fccb789424fc 19
jksoft 0:fccb789424fc 20 #include "USBHostConf.h"
jksoft 0:fccb789424fc 21
jksoft 0:fccb789424fc 22 #if USBHOST_MOUSE
jksoft 0:fccb789424fc 23
jksoft 0:fccb789424fc 24 #include "USBHost.h"
jksoft 0:fccb789424fc 25
jksoft 0:fccb789424fc 26 /**
jksoft 0:fccb789424fc 27 * A class to communicate a USB mouse
jksoft 0:fccb789424fc 28 */
jksoft 0:fccb789424fc 29 class USBHostMouse : public IUSBEnumerator {
jksoft 0:fccb789424fc 30 public:
jksoft 0:fccb789424fc 31
jksoft 0:fccb789424fc 32 /**
jksoft 0:fccb789424fc 33 * Constructor
jksoft 0:fccb789424fc 34 */
jksoft 0:fccb789424fc 35 USBHostMouse();
jksoft 0:fccb789424fc 36
jksoft 0:fccb789424fc 37 /**
jksoft 0:fccb789424fc 38 * Try to connect a mouse device
jksoft 0:fccb789424fc 39 *
jksoft 0:fccb789424fc 40 * @return true if connection was successful
jksoft 0:fccb789424fc 41 */
jksoft 0:fccb789424fc 42 bool connect();
jksoft 0:fccb789424fc 43
jksoft 0:fccb789424fc 44 /**
jksoft 0:fccb789424fc 45 * Check if a mouse is connected
jksoft 0:fccb789424fc 46 *
jksoft 0:fccb789424fc 47 * @returns true if a mouse is connected
jksoft 0:fccb789424fc 48 */
jksoft 0:fccb789424fc 49 bool connected();
jksoft 0:fccb789424fc 50
jksoft 0:fccb789424fc 51 /**
jksoft 0:fccb789424fc 52 * Attach a callback called when a mouse event is received
jksoft 0:fccb789424fc 53 *
jksoft 0:fccb789424fc 54 * @param ptr function pointer
jksoft 0:fccb789424fc 55 */
jksoft 0:fccb789424fc 56 inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) {
jksoft 0:fccb789424fc 57 if (ptr != NULL) {
jksoft 0:fccb789424fc 58 onUpdate = ptr;
jksoft 0:fccb789424fc 59 }
jksoft 0:fccb789424fc 60 }
jksoft 0:fccb789424fc 61
jksoft 0:fccb789424fc 62 /**
jksoft 0:fccb789424fc 63 * Attach a callback called when the button state changes
jksoft 0:fccb789424fc 64 *
jksoft 0:fccb789424fc 65 * @param ptr function pointer
jksoft 0:fccb789424fc 66 */
jksoft 0:fccb789424fc 67 inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) {
jksoft 0:fccb789424fc 68 if (ptr != NULL) {
jksoft 0:fccb789424fc 69 onButtonUpdate = ptr;
jksoft 0:fccb789424fc 70 }
jksoft 0:fccb789424fc 71 }
jksoft 0:fccb789424fc 72
jksoft 0:fccb789424fc 73 /**
jksoft 0:fccb789424fc 74 * Attach a callback called when the X axis value changes
jksoft 0:fccb789424fc 75 *
jksoft 0:fccb789424fc 76 * @param ptr function pointer
jksoft 0:fccb789424fc 77 */
jksoft 0:fccb789424fc 78 inline void attachXEvent(void (*ptr)(int8_t x)) {
jksoft 0:fccb789424fc 79 if (ptr != NULL) {
jksoft 0:fccb789424fc 80 onXUpdate = ptr;
jksoft 0:fccb789424fc 81 }
jksoft 0:fccb789424fc 82 }
jksoft 0:fccb789424fc 83
jksoft 0:fccb789424fc 84 /**
jksoft 0:fccb789424fc 85 * Attach a callback called when the Y axis value changes
jksoft 0:fccb789424fc 86 *
jksoft 0:fccb789424fc 87 * @param ptr function pointer
jksoft 0:fccb789424fc 88 */
jksoft 0:fccb789424fc 89 inline void attachYEvent(void (*ptr)(int8_t y)) {
jksoft 0:fccb789424fc 90 if (ptr != NULL) {
jksoft 0:fccb789424fc 91 onYUpdate = ptr;
jksoft 0:fccb789424fc 92 }
jksoft 0:fccb789424fc 93 }
jksoft 0:fccb789424fc 94
jksoft 0:fccb789424fc 95 /**
jksoft 0:fccb789424fc 96 * Attach a callback called when the Z axis value changes (scrolling)
jksoft 0:fccb789424fc 97 *
jksoft 0:fccb789424fc 98 * @param ptr function pointer
jksoft 0:fccb789424fc 99 */
jksoft 0:fccb789424fc 100 inline void attachZEvent(void (*ptr)(int8_t z)) {
jksoft 0:fccb789424fc 101 if (ptr != NULL) {
jksoft 0:fccb789424fc 102 onZUpdate = ptr;
jksoft 0:fccb789424fc 103 }
jksoft 0:fccb789424fc 104 }
jksoft 0:fccb789424fc 105
jksoft 0:fccb789424fc 106 protected:
jksoft 0:fccb789424fc 107 //From IUSBEnumerator
jksoft 0:fccb789424fc 108 virtual void setVidPid(uint16_t vid, uint16_t pid);
jksoft 0:fccb789424fc 109 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
jksoft 0:fccb789424fc 110 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
jksoft 0:fccb789424fc 111
jksoft 0:fccb789424fc 112 private:
jksoft 0:fccb789424fc 113 USBHost * host;
jksoft 0:fccb789424fc 114 USBDeviceConnected * dev;
jksoft 0:fccb789424fc 115 USBEndpoint * int_in;
jksoft 0:fccb789424fc 116 uint8_t report[4];
jksoft 0:fccb789424fc 117
jksoft 0:fccb789424fc 118 bool dev_connected;
jksoft 0:fccb789424fc 119 bool mouse_device_found;
jksoft 0:fccb789424fc 120 int mouse_intf;
jksoft 0:fccb789424fc 121
jksoft 0:fccb789424fc 122 uint8_t buttons;
jksoft 0:fccb789424fc 123 int8_t x;
jksoft 0:fccb789424fc 124 int8_t y;
jksoft 0:fccb789424fc 125 int8_t z;
jksoft 0:fccb789424fc 126
jksoft 0:fccb789424fc 127 void rxHandler();
jksoft 0:fccb789424fc 128 void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z);
jksoft 0:fccb789424fc 129 void (*onButtonUpdate)(uint8_t buttons);
jksoft 0:fccb789424fc 130 void (*onXUpdate)(int8_t x);
jksoft 0:fccb789424fc 131 void (*onYUpdate)(int8_t y);
jksoft 0:fccb789424fc 132 void (*onZUpdate)(int8_t z);
jksoft 0:fccb789424fc 133 int report_id;
jksoft 0:fccb789424fc 134 void init();
jksoft 0:fccb789424fc 135 };
jksoft 0:fccb789424fc 136
jksoft 0:fccb789424fc 137 #endif
jksoft 0:fccb789424fc 138
jksoft 0:fccb789424fc 139 #endif