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