Based on PS3_BlueUSB with reference to http://blog.goo.ne.jp/roboz80/e/10e7bf38d3a63b996ca2894e9fb5e3b6

Dependencies:   TextLCD mbed

Committer:
kenbumono
Date:
Tue Jul 05 08:25:40 2011 +0000
Revision:
0:44619612f575

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenbumono 0:44619612f575 1 /*
kenbumono 0:44619612f575 2 Copyright (c) 2011 Bart Janssens
kenbumono 0:44619612f575 3
kenbumono 0:44619612f575 4 Permission is hereby granted, free of charge, to any person obtaining a copy
kenbumono 0:44619612f575 5 of this software and associated documentation files (the "Software"), to deal
kenbumono 0:44619612f575 6 in the Software without restriction, including without limitation the rights
kenbumono 0:44619612f575 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
kenbumono 0:44619612f575 8 copies of the Software, and to permit persons to whom the Software is
kenbumono 0:44619612f575 9 furnished to do so, subject to the following conditions:
kenbumono 0:44619612f575 10
kenbumono 0:44619612f575 11 The above copyright notice and this permission notice shall be included in
kenbumono 0:44619612f575 12 all copies or substantial portions of the Software.
kenbumono 0:44619612f575 13
kenbumono 0:44619612f575 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
kenbumono 0:44619612f575 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
kenbumono 0:44619612f575 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
kenbumono 0:44619612f575 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
kenbumono 0:44619612f575 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kenbumono 0:44619612f575 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
kenbumono 0:44619612f575 20 THE SOFTWARE.
kenbumono 0:44619612f575 21 */
kenbumono 0:44619612f575 22
kenbumono 0:44619612f575 23 /* Defines for the PS3 Buttons
kenbumono 0:44619612f575 24 */
kenbumono 0:44619612f575 25
kenbumono 0:44619612f575 26
kenbumono 0:44619612f575 27 #define BUTTONSELECT 0
kenbumono 0:44619612f575 28 #define BUTTONLANALOG 1
kenbumono 0:44619612f575 29 #define BUTTONRANALOG 2
kenbumono 0:44619612f575 30 #define BUTTONSTART 3
kenbumono 0:44619612f575 31 #define BUTTONUP 4
kenbumono 0:44619612f575 32 #define BUTTONRIGHT 5
kenbumono 0:44619612f575 33 #define BUTTONDOWN 6
kenbumono 0:44619612f575 34 #define BUTTONLEFT 7
kenbumono 0:44619612f575 35 #define BUTTONL2 8
kenbumono 0:44619612f575 36 #define BUTTONR2 9
kenbumono 0:44619612f575 37 #define BUTTONL1 10
kenbumono 0:44619612f575 38 #define BUTTONR1 11
kenbumono 0:44619612f575 39 #define BUTTONTRIANGEL 12
kenbumono 0:44619612f575 40 #define BUTTONCIRCLE 13
kenbumono 0:44619612f575 41 #define BUTTONCROSS 14
kenbumono 0:44619612f575 42 #define BUTTONSQUARE 15
kenbumono 0:44619612f575 43 #define BUTTONPS 16
kenbumono 0:44619612f575 44
kenbumono 0:44619612f575 45
kenbumono 0:44619612f575 46 /* Defines for the PS3 Joysticks
kenbumono 0:44619612f575 47 */
kenbumono 0:44619612f575 48
kenbumono 0:44619612f575 49 #define LEFTJOYSTICKX 0
kenbumono 0:44619612f575 50 #define LEFTJOYSTICKY 1
kenbumono 0:44619612f575 51 #define RIGHTJOYSTICKX 2
kenbumono 0:44619612f575 52 #define RIGHTJOYSTICKY 3
kenbumono 0:44619612f575 53
kenbumono 0:44619612f575 54
kenbumono 0:44619612f575 55 /* Defines for the PS3 Accelerometers and Gyro
kenbumono 0:44619612f575 56 */
kenbumono 0:44619612f575 57
kenbumono 0:44619612f575 58 #define ACCELOROMETERX 0
kenbumono 0:44619612f575 59 #define ACCELOROMETERY 1
kenbumono 0:44619612f575 60 #define ACCELOROMETERZ 2
kenbumono 0:44619612f575 61 #define GYROMETERZ 3
kenbumono 0:44619612f575 62
kenbumono 0:44619612f575 63 /* Defines for the PS3 LED and Rumble
kenbumono 0:44619612f575 64 */
kenbumono 0:44619612f575 65 #define PS3LED1 0x01
kenbumono 0:44619612f575 66 #define PS3LED2 0x02
kenbumono 0:44619612f575 67 #define PS3LED3 0x04
kenbumono 0:44619612f575 68 #define PS3LED4 0x08
kenbumono 0:44619612f575 69 #define PSRUMBLEHIGH 0x10
kenbumono 0:44619612f575 70 #define PSRUMBLELOW 0x20
kenbumono 0:44619612f575 71
kenbumono 0:44619612f575 72 //Structure which describes the type 01 input report
kenbumono 0:44619612f575 73 typedef struct {
kenbumono 0:44619612f575 74 u8 ReportType; //Report Type 01
kenbumono 0:44619612f575 75 u8 Reserved1; // Unknown
kenbumono 0:44619612f575 76 u16 ButtonState; // Main buttons
kenbumono 0:44619612f575 77 u8 PSButtonState; // PS button
kenbumono 0:44619612f575 78 u8 Reserved2; // Unknown
kenbumono 0:44619612f575 79 u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid
kenbumono 0:44619612f575 80 u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid
kenbumono 0:44619612f575 81 u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid
kenbumono 0:44619612f575 82 u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid
kenbumono 0:44619612f575 83 u8 Reserved3[4]; // Unknown
kenbumono 0:44619612f575 84 u8 PressureUp; // digital Pad Up button Pressure 0 - 255
kenbumono 0:44619612f575 85 u8 PressureRight; // digital Pad Right button Pressure 0 - 255
kenbumono 0:44619612f575 86 u8 PressureDown; // digital Pad Down button Pressure 0 - 255
kenbumono 0:44619612f575 87 u8 PressureLeft; // digital Pad Left button Pressure 0 - 255
kenbumono 0:44619612f575 88 u8 PressureL2; // digital Pad L2 button Pressure 0 - 255
kenbumono 0:44619612f575 89 u8 PressureR2; // digital Pad R2 button Pressure 0 - 255
kenbumono 0:44619612f575 90 u8 PressureL1; // digital Pad L1 button Pressure 0 - 255
kenbumono 0:44619612f575 91 u8 PressureR1; // digital Pad R1 button Pressure 0 - 255
kenbumono 0:44619612f575 92 u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255
kenbumono 0:44619612f575 93 u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255
kenbumono 0:44619612f575 94 u8 PressureCross; // digital Pad Cross button Pressure 0 - 255
kenbumono 0:44619612f575 95 u8 PressureSquare; // digital Pad Square button Pressure 0 - 255
kenbumono 0:44619612f575 96 u8 Reserved4[3]; // Unknown
kenbumono 0:44619612f575 97 u8 Charge; // charging status ? 02 = charge, 03 = normal
kenbumono 0:44619612f575 98 u8 Power; // Battery status ?
kenbumono 0:44619612f575 99 u8 Connection; // Connection Type ?
kenbumono 0:44619612f575 100 u8 Reserved5[9]; // Unknown
kenbumono 0:44619612f575 101 u16 AccelX; // X axis accelerometer Big Endian 0 - 1023
kenbumono 0:44619612f575 102 u16 AccelY; // Y axis accelerometer Big Endian 0 - 1023
kenbumono 0:44619612f575 103 u16 AccelZ; // Z axis accelerometer Big Endian 0 - 1023
kenbumono 0:44619612f575 104 u16 GyroZ; // Z axis Gyro Big Endian 0 - 1023
kenbumono 0:44619612f575 105
kenbumono 0:44619612f575 106 } ps3report;
kenbumono 0:44619612f575 107
kenbumono 0:44619612f575 108 class Ps3USB
kenbumono 0:44619612f575 109 {
kenbumono 0:44619612f575 110
kenbumono 0:44619612f575 111
kenbumono 0:44619612f575 112 public:
kenbumono 0:44619612f575 113 Ps3USB(int device, int configuration, int interfaceNumber);
kenbumono 0:44619612f575 114 int Enable();
kenbumono 0:44619612f575 115 int SetPair(u8* bdAddr);
kenbumono 0:44619612f575 116 int ShowPair();
kenbumono 0:44619612f575 117 int Led(int i);
kenbumono 0:44619612f575 118 int Rumble(u8 duration_right, u8 power_right, u8 duration_left, u8 power_left);
kenbumono 0:44619612f575 119 int _count;
kenbumono 0:44619612f575 120
kenbumono 0:44619612f575 121 private:
kenbumono 0:44619612f575 122 int input_ep;
kenbumono 0:44619612f575 123 int output_ep;
kenbumono 0:44619612f575 124 int _device;
kenbumono 0:44619612f575 125 int _configuration;
kenbumono 0:44619612f575 126 int _interfaceNumber;
kenbumono 0:44619612f575 127
kenbumono 0:44619612f575 128 u8 ledrumble[48] ;
kenbumono 0:44619612f575 129
kenbumono 0:44619612f575 130 };
kenbumono 0:44619612f575 131
kenbumono 0:44619612f575 132 void PS3EventCallback(int device, int endpoint, int status, u8* data, int len, void* userData);
kenbumono 0:44619612f575 133 int ParsePs3Result(const u8* data, int len, int count);
kenbumono 0:44619612f575 134
kenbumono 0:44619612f575 135