BlackOneとAndroidの連携デモプログラム AndroidAccessoryを改造してBlackOneとAndroidが連携できるようにしました。 サポートしているのは、デモアプリの ”Buttons” B1-SW1, B2-SW2, B3-SW3 ”LED2” RGB-LED のみです。 LCDに表示するイメージをマイクロSDカードに入れてLCDのソケットに挿入しておく必要があります。 イメージは、320X240ドットで”\Image”という名前のフォルダの直下に”10.jpg”という名前で入れてください。

Dependencies:   TextLCD mbed

Committer:
techand
Date:
Fri Dec 23 04:33:33 2011 +0000
Revision:
0:7b556109fd46

        

Who changed what in which revision?

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