|
| 1 | +use crate::types::SceUChar8; |
| 2 | +use crate::types::SceUInt; |
| 3 | +use crate::types::SceUInt64; |
| 4 | +use crate::types::SceUInt8; |
| 5 | + |
| 6 | +#[repr(C)] |
| 7 | +pub enum SceCtrlErrorCode { |
| 8 | + SCE_CTRL_ERROR_INVALID_ARG = 0x80340001, |
| 9 | + SCE_CTRL_ERROR_PRIV_REQUIRED = 0x80340002, |
| 10 | + SCE_CTRL_ERROR_NO_DEVICE = 0x80340020, |
| 11 | + SCE_CTRL_ERROR_NOT_SUPPORTED = 0x80340021, |
| 12 | + SCE_CTRL_ERROR_INVALID_MODE = 0x80340022, |
| 13 | + SCE_CTRL_ERROR_FATAL = 0x803400FF, |
| 14 | +} |
| 15 | + |
| 16 | +#[repr(C)] |
| 17 | +pub enum SceCtrlButtons { |
| 18 | + /// Select button. |
| 19 | + SCE_CTRL_SELECT = 0x00000001, |
| 20 | + /// L3 button. |
| 21 | + SCE_CTRL_L3 = 0x00000002, |
| 22 | + /// R3 button. |
| 23 | + SCE_CTRL_R3 = 0x00000004, |
| 24 | + /// Start button. |
| 25 | + SCE_CTRL_START = 0x00000008, |
| 26 | + /// Up D-Pad button. |
| 27 | + SCE_CTRL_UP = 0x00000010, |
| 28 | + /// Right D-Pad button. |
| 29 | + SCE_CTRL_RIGHT = 0x00000020, |
| 30 | + /// Down D-Pad button. |
| 31 | + SCE_CTRL_DOWN = 0x00000040, |
| 32 | + /// Left D-Pad button. |
| 33 | + SCE_CTRL_LEFT = 0x00000080, |
| 34 | + /// Left trigger. |
| 35 | + SCE_CTRL_LTRIGGER = 0x00000100, |
| 36 | + // /// L2 button. |
| 37 | + // SCE_CTRL_L2 = SCE_CTRL_LTRIGGER, |
| 38 | + /// Right trigger. |
| 39 | + SCE_CTRL_RTRIGGER = 0x00000200, |
| 40 | + // /// R2 button. |
| 41 | + // SCE_CTRL_R2 = SCE_CTRL_RTRIGGER, |
| 42 | + /// L1 button. |
| 43 | + SCE_CTRL_L1 = 0x00000400, |
| 44 | + /// R1 button. |
| 45 | + SCE_CTRL_R1 = 0x00000800, |
| 46 | + /// Triangle button. |
| 47 | + SCE_CTRL_TRIANGLE = 0x00001000, |
| 48 | + /// Circle button. |
| 49 | + SCE_CTRL_CIRCLE = 0x00002000, |
| 50 | + /// Cross button. |
| 51 | + SCE_CTRL_CROSS = 0x00004000, |
| 52 | + /// Square button. |
| 53 | + SCE_CTRL_SQUARE = 0x00008000, |
| 54 | + /// Input not available because intercercepted by another application |
| 55 | + SCE_CTRL_INTERCEPTED = 0x00010000, |
| 56 | + // /// Playstation (Home) button. |
| 57 | + // SCE_CTRL_PSBUTTON = SCE_CTRL_INTERCEPTED, |
| 58 | + /// Headphone plugged in. |
| 59 | + SCE_CTRL_HEADPHONE = 0x00080000, |
| 60 | + /// Volume up button. |
| 61 | + SCE_CTRL_VOLUP = 0x00100000, |
| 62 | + /// Volume down button. |
| 63 | + SCE_CTRL_VOLDOWN = 0x00200000, |
| 64 | + /// Power button. |
| 65 | + SCE_CTRL_POWER = 0x40000000, |
| 66 | +} |
| 67 | + |
| 68 | +#[repr(u8)] |
| 69 | +pub enum SceCtrlExternalInputMode { |
| 70 | + /// Unpaired controller |
| 71 | + SCE_CTRL_TYPE_UNPAIRED = 0, |
| 72 | + /// Physical controller for VITA |
| 73 | + SCE_CTRL_TYPE_PHY = 1, |
| 74 | + /// Virtual controller for PSTV |
| 75 | + SCE_CTRL_TYPE_VIRT = 2, |
| 76 | + /// DualShock 3 |
| 77 | + SCE_CTRL_TYPE_DS3 = 4, |
| 78 | + /// DualShock 4 |
| 79 | + SCE_CTRL_TYPE_DS4 = 8, |
| 80 | +} |
| 81 | + |
| 82 | +#[repr(C)] |
| 83 | +pub enum SceCtrlPadInputMode { |
| 84 | + /// Digital buttons only. |
| 85 | + SCE_CTRL_MODE_DIGITAL = 0, |
| 86 | + /// Digital buttons + Analog support. |
| 87 | + SCE_CTRL_MODE_ANALOG = 1, |
| 88 | + /// Same as ::SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks. |
| 89 | + SCE_CTRL_MODE_ANALOG_WIDE = 2, |
| 90 | +} |
| 91 | + |
| 92 | +#[repr(C)] |
| 93 | +pub struct SceCtrlData { |
| 94 | + /// The current read frame. |
| 95 | + pub timeStamp: u64, |
| 96 | + /** Bit mask containing zero or more of ::SceCtrlButtons. */ |
| 97 | + pub buttons: u32, |
| 98 | + /** Left analogue stick, X axis. */ |
| 99 | + pub lx: u8, |
| 100 | + /** Left analogue stick, Y axis. */ |
| 101 | + pub ly: u8, |
| 102 | + /** Right analogue stick, X axis. */ |
| 103 | + pub rx: u8, |
| 104 | + /** Right analogue stick, Y axis. */ |
| 105 | + pub ry: u8, |
| 106 | + /** Up button */ |
| 107 | + pub up: u8, |
| 108 | + /** Right button */ |
| 109 | + pub right: u8, |
| 110 | + /** Down button */ |
| 111 | + pub down: u8, |
| 112 | + /** Left button */ |
| 113 | + pub left: u8, |
| 114 | + /** Left trigger (L2) */ |
| 115 | + pub lt: u8, |
| 116 | + /** Right trigger (R2) */ |
| 117 | + pub rt: u8, |
| 118 | + /** Left button (L1) */ |
| 119 | + pub l1: u8, |
| 120 | + /** Right button (R1) */ |
| 121 | + pub r1: u8, |
| 122 | + /** Triangle button */ |
| 123 | + pub triangle: u8, |
| 124 | + /// Circle button |
| 125 | + pub circle: u8, |
| 126 | + /** Cross button */ |
| 127 | + pub cross: u8, |
| 128 | + /** Square button */ |
| 129 | + pub square: u8, |
| 130 | + /** Reserved. */ |
| 131 | + _reserved: [u8; 4], |
| 132 | +} |
| 133 | + |
| 134 | +#[repr(C)] |
| 135 | +pub struct SceCtrlRapidFireRule { |
| 136 | + pub Mask: u32, |
| 137 | + pub Trigger: u32, |
| 138 | + pub Target: u32, |
| 139 | + pub Delay: u32, |
| 140 | + pub Make: u32, |
| 141 | + pub Break: u32, |
| 142 | +} |
| 143 | + |
| 144 | +#[repr(C)] |
| 145 | +pub struct SceCtrlActuator { |
| 146 | + pub small: u8, |
| 147 | + pub large: u8, |
| 148 | + pub unk: [u8; 6], |
| 149 | +} |
| 150 | + |
| 151 | +#[repr(C)] |
| 152 | +pub struct SceCtrlPortInfo { |
| 153 | + port: [SceCtrlExternalInputMode; 5], |
| 154 | + unk: [u8; 11], |
| 155 | +} |
| 156 | + |
| 157 | +#[cfg_attr(not(feature = "dox"), link(kind = "static", name = "SceCtrl_stub"))] |
| 158 | +extern "C" { |
| 159 | + pub fn sceCtrlSetSamplingMode(mode: SceCtrlPadInputMode) -> i32; |
| 160 | + pub fn sceCtrlSetSamplingModeExt(mode: SceCtrlPadInputMode) -> i32; |
| 161 | + pub fn sceCtrlGetSamplingMode(pMode: *mut SceCtrlPadInputMode) -> i32; |
| 162 | + pub fn sceCtrlPeekBufferPositive(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 163 | + pub fn sceCtrlPeekBufferPositiveExt2(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 164 | + pub fn sceCtrlPeekBufferNegative(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 165 | + pub fn sceCtrlReadBufferPositive(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 166 | + pub fn sceCtrlReadBufferPositiveExt2(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 167 | + pub fn sceCtrlReadBufferNegative(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32; |
| 168 | + pub fn sceCtrlSetRapidFire(port: i32, idx: i32, pRule: *const SceCtrlRapidFireRule); |
| 169 | + pub fn sceCtrlClearRapidFire(port: i32, idx: i32) -> i32; |
| 170 | + pub fn sceCtrlSetActuator(port: i32, pState: *const SceCtrlActuator) -> i32; |
| 171 | + pub fn sceCtrlSetLightBar(port: i32, r: u8, g: u8, b: u8) -> i32; |
| 172 | + pub fn sceCtrlGetControllerPortInfo(info: *mut SceCtrlPortInfo) -> i32; |
| 173 | + pub fn sceCtrlGetBatteryInfo(port: i32, batt: *mut u8) -> i32; |
| 174 | + pub fn sceCtrlSetButtonIntercept(intercept: i32) -> i32; |
| 175 | + pub fn sceCtrlGetButtonIntercept(intercept: *mut i32) -> i32; |
| 176 | + pub fn sceCtrlIsMultiControllerSupported() -> i32; |
| 177 | +} |
0 commit comments