Joystick enabled version of USBHID -library. Has full Playstation 3 functionality including button pressures and a working home-button implementation, while maintaining full PC/MAC/linux -compatibility. basic operation of the lib: #include "mbed.h" #include "usbhid.h" USBJoystick joystick; int main() { while(1) { char dpad = 0xf; /*only the rightmost 4 bits matter*/ short button = 0xff; /*only the rightmost 13 bits matter*/ /*buttons are square, cross, circle, triangle, l1, r1, l2, r2, l3, r3, home.*/ char stick1x = 0; char stick1y = 0; char stick2x = 0; char stick2y = 0; joystick.joystick(dpad, buttons, stick1x, stick1y, stick2x, stick2y); wait_ms(5); } }
USBMouse.h
- Committer:
- innocopter
- Date:
- 2012-05-11
- Revision:
- 0:237d5ef643e9
File content as of revision 0:237d5ef643e9:
#include "usbhid.h" #ifndef MBED_USBMOUSE_H #define MBED_USBMOUSE_H /* Class: USBMouse * Emulate a USB Mouse HID device * * Example: * > #include "mbed.h" * > #include "USBMouse.h" * > * > USBMouse mouse; * > * > int main() { * > while(1) { * > mouse.move(10, 0); * > wait(2); * > } * > } */ class USBMouse : private usbhid { public: /* Constructor: USBMouse * Create a USB Mouse using the mbed USB Device interface */ USBMouse(); /* Function: move * Move the mouse * * Variables: * x - Distance to move in x-axis * y - Distance to move in y-axis */ void move(int x, int y); /* Function: scroll * Scroll the scroll wheel * * Variables: * z - Distance to scroll scroll wheel */ void scroll(int z); /* Function: buttons * Set the state of the buttons * * Variables: * left - set the left button as down (1) or up (0) * middle - set the middle button as down (1) or up (0) * right - set the right button as down (1) or up (0) */ void buttons(int left, int middle, int right); private: int _buttons; }; #endif