Skip to content
This repository was archived by the owner on Jun 18, 2023. It is now read-only.

Commit f272399

Browse files
committed
Changed: ctrl & display documentation (see message)
* Improve doc by adding links to various elements in `ctrl` & `display`.
1 parent 8bd87f9 commit f272399

File tree

2 files changed

+114
-168
lines changed

2 files changed

+114
-168
lines changed

src/ctrl.rs

Lines changed: 106 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub enum SceCtrlErrorCode {
1414
}
1515

1616
/// Enumeration for the digital controller buttons.
17-
///
17+
///
1818
/// Notes :
19-
/// > L1/R1/L3/R3 only can bind using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2
20-
///
19+
/// > L1/R1/L3/R3 only can bind using [sceCtrlPeekBufferPositiveExt2] and [sceCtrlReadBufferPositiveExt2]
20+
///
2121
/// > Values bigger than 0x00010000 can be intercepted only with shell privileges
22-
///
23-
/// > Vita's L Trigger and R Trigger are mapped to L1 and R1 when using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2
22+
///
23+
/// > Vita's L Trigger and R Trigger are mapped to L1 and R1 when using [sceCtrlPeekBufferPositiveExt2] and [sceCtrlReadBufferPositiveExt2]
2424
#[repr(C)]
2525
pub enum SceCtrlButtons {
2626
/// Select button.
@@ -59,7 +59,7 @@ pub enum SceCtrlButtons {
5959
SCE_CTRL_SQUARE = 0x00008000,
6060
/// Input not available because intercercepted by another application
6161
SCE_CTRL_INTERCEPTED = 0x00010000,
62-
// SCE_CTRL_PSBUTTON : defined in SceCtrlButtons Implementation
62+
// SCE_CTRL_PSBUTTON : defined in SceCtrlButtons Implementation
6363
/// Headphone plugged in.
6464
SCE_CTRL_HEADPHONE = 0x00080000,
6565
/// Volume up button.
@@ -73,11 +73,11 @@ pub enum SceCtrlButtons {
7373
/// Implementation for SceCtrlButtons : Fixing missing enum variant
7474
impl SceCtrlButtons {
7575
/// L2 button.
76-
pub const SCE_CTRL_L2:SceCtrlButtons = SceCtrlButtons::SCE_CTRL_LTRIGGER;
76+
pub const SCE_CTRL_L2: SceCtrlButtons = SceCtrlButtons::SCE_CTRL_LTRIGGER;
7777
/// R2 button.
78-
pub const SCE_CTRL_R2:SceCtrlButtons = SceCtrlButtons::SCE_CTRL_RTRIGGER;
78+
pub const SCE_CTRL_R2: SceCtrlButtons = SceCtrlButtons::SCE_CTRL_RTRIGGER;
7979
/// Playstation (Home) button.
80-
pub const SCE_CTRL_PSBUTTON:SceCtrlButtons = SceCtrlButtons::SCE_CTRL_INTERCEPTED;
80+
pub const SCE_CTRL_PSBUTTON: SceCtrlButtons = SceCtrlButtons::SCE_CTRL_INTERCEPTED;
8181
}
8282

8383
/// Enumeration for the controller types.
@@ -102,7 +102,7 @@ pub enum SceCtrlPadInputMode {
102102
SCE_CTRL_MODE_DIGITAL = 0,
103103
/// Digital buttons + Analog support.
104104
SCE_CTRL_MODE_ANALOG = 1,
105-
/// Same as ::SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks.
105+
/// Same as [SCE_CTRL_MODE_ANALOG](crate::ctrl::SceCtrlPadInputMode::SCE_CTRL_MODE_ANALOG), but with larger range for analog sticks.
106106
SCE_CTRL_MODE_ANALOG_WIDE = 2,
107107
}
108108

@@ -111,7 +111,7 @@ pub enum SceCtrlPadInputMode {
111111
pub struct SceCtrlData {
112112
/// The current read frame.
113113
pub timeStamp: u64,
114-
/// Bit mask containing zero or more of ::SceCtrlButtons.
114+
/// Bit mask containing zero or more of [SceCtrlButtons].
115115
pub buttons: u32,
116116
/// Left analogue stick, X axis.
117117
pub lx: u8,
@@ -149,7 +149,7 @@ pub struct SceCtrlData {
149149
_reserved: [u8; 4],
150150
}
151151

152-
/// Structure to pass as argument to ::sceCtrlSetRapidFire
152+
/// Structure to pass as argument to [sceCtrlSetRapidFire]
153153
#[repr(C)]
154154
pub struct SceCtrlRapidFireRule {
155155
pub Mask: u32,
@@ -160,7 +160,7 @@ pub struct SceCtrlRapidFireRule {
160160
pub Break: u32,
161161
}
162162

163-
/// Structure to pass as argument to ::sceCtrlSetActuator
163+
/// Structure to pass as argument to [sceCtrlSetActuator]
164164
#[repr(C)]
165165
pub struct SceCtrlActuator {
166166
/// Vibration strength of the small motor
@@ -171,220 +171,166 @@ pub struct SceCtrlActuator {
171171
unk: [u8; 6],
172172
}
173173

174-
/// Structure to pass as argument to ::sceCtrlGetControllerPortInfo
174+
/// Structure to pass as argument to [sceCtrlGetControllerPortInfo]
175175
#[repr(C)]
176176
pub struct SceCtrlPortInfo {
177-
/// Controller type of each port (See ::SceCtrlExternalInputMode)
177+
/// Controller type of each port (See [SceCtrlExternalInputMode])
178178
pub port: [u8; 5],
179179
/// Unknown
180180
unk: [u8; 11],
181181
}
182182

183183
#[cfg_attr(not(feature = "dox"), link(kind = "static", name = "SceCtrl_stub"))]
184184
extern "C" {
185-
/// Set the controller mode.
186-
///
187-
/// * `mode` - One of ::SceCtrlPadInputMode.
188-
///
185+
/// Set the controller mode
186+
///
187+
/// * `mode` - One of [SceCtrlPadInputMode].
188+
///
189189
/// Returns he previous mode, < 0 on error.
190-
pub fn sceCtrlSetSamplingMode(
191-
mode: SceCtrlPadInputMode
192-
) -> i32;
190+
pub fn sceCtrlSetSamplingMode(mode: SceCtrlPadInputMode) -> i32;
193191

194-
/// Set the controller extend mode.
192+
/// Set the controller extend mode
193+
///
194+
/// * `mode` - One of [SceCtrlPadInputMode].
195195
///
196-
/// * `mode` - One of ::SceCtrlPadInputMode.
197-
///
198196
/// Returns the previous mode, < 0 on error.
199-
pub fn sceCtrlSetSamplingModeExt(
200-
mode: SceCtrlPadInputMode
201-
) -> i32;
197+
pub fn sceCtrlSetSamplingModeExt(mode: SceCtrlPadInputMode) -> i32;
202198

203-
/// Get the current controller mode.
199+
/// Get the current controller mode
200+
///
201+
/// * `pMode` (out) - Return value, see [SceCtrlPadInputMode].
204202
///
205-
/// * `pMode` (out) - Return value, see ::SceCtrlPadInputMode.
206-
///
207203
/// Returns the previous mode, < 0 on error.
208-
pub fn sceCtrlGetSamplingMode(
209-
pMode: *mut SceCtrlPadInputMode
210-
) -> i32;
204+
pub fn sceCtrlGetSamplingMode(pMode: *mut SceCtrlPadInputMode) -> i32;
211205

212-
/// Get the controller state information (polling, positive logic).
206+
/// Get the controller state information (polling, positive logic)
213207
///
214208
/// * `port` - use 0.
215-
/// * `*pad_data` (out) - see ::SceCtrlData.
209+
/// * `*pad_data` (out) - see [SceCtrlData].
216210
/// * `count` - Buffers count. Up to 64 buffers can be requested.
217-
///
211+
///
218212
/// Returns buffers count, between 1 and 'count'. < 0 on error.
219-
pub fn sceCtrlPeekBufferPositive(
220-
port: i32,
221-
pad_data: *mut SceCtrlData,
222-
count: i32
223-
) -> i32;
213+
pub fn sceCtrlPeekBufferPositive(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
224214

225-
/// Get the controller state information (polling, positive logic).
215+
/// Get the controller state information (polling, positive logic)
216+
///
217+
/// This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER.
226218
///
227-
/// This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER
228-
///
229219
/// * `port` - use 0.
230-
/// * `*pad_data` (out) - see ::SceCtrlData.
220+
/// * `*pad_data` (out) - see [SceCtrlData].
231221
/// * `count` - Buffers count. Up to 64 buffers can be requested.
232-
///
222+
///
233223
/// Returns buffers count, between 1 and 'count'. < 0 on error.
234-
pub fn sceCtrlPeekBufferPositiveExt2(
235-
port: i32,
236-
pad_data: *mut SceCtrlData,
237-
count: i32
238-
) -> i32;
224+
pub fn sceCtrlPeekBufferPositiveExt2(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
239225

240-
/// Get the controller state information (polling, negative logic).
241-
///
226+
/// Get the controller state information (polling, negative logic)
227+
///
242228
/// * `port` - use 0.
243-
/// * `*pad_data` (out) - see ::SceCtrlData.
229+
/// * `*pad_data` (out) - see [SceCtrlData].
244230
/// * `count` - Buffers count. Up to 64 buffers can be requested.
245-
///
231+
///
246232
/// Returns buffers count, between 1 and 'count'. < 0 on error.
247-
pub fn sceCtrlPeekBufferNegative(
248-
port: i32,
249-
pad_data: *mut SceCtrlData,
250-
count: i32
251-
) -> i32;
233+
pub fn sceCtrlPeekBufferNegative(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
252234

253-
/// Get the controller state information (blocking, positive logic).
254-
///
235+
/// Get the controller state information (blocking, positive logic)
236+
///
255237
/// * `port` - use 0.
256-
/// * `*pad_data` (out) - see ::SceCtrlData.
238+
/// * `*pad_data` (out) - see [SceCtrlData].
257239
/// * `count` - Buffers count. Up to 64 buffers can be requested.
258-
///
240+
///
259241
/// Returns buffers count, between 1 and 'count'. < 0 on error.
260-
pub fn sceCtrlReadBufferPositive(
261-
port: i32,
262-
pad_data: *mut SceCtrlData,
263-
count: i32
264-
) -> i32;
242+
pub fn sceCtrlReadBufferPositive(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
265243

266-
/// Get the controller extended state information (blocking, positive logic).
244+
/// Get the controller extended state information (blocking, positive logic)
245+
///
246+
/// This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER.
267247
///
268-
/// This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER
269-
///
270248
/// * `port` - use 0.
271-
/// * `*pad_data` (out) - see ::SceCtrlData.
249+
/// * `*pad_data` (out) - see [SceCtrlData].
272250
/// * `count` - Buffers count. Up to 64 buffers can be requested.
273-
///
251+
///
274252
/// Returns buffers count, between 1 and 'count'. < 0 on error.
275-
pub fn sceCtrlReadBufferPositiveExt2(
276-
port: i32,
277-
pad_data: *mut SceCtrlData,
278-
count: i32
279-
) -> i32;
253+
pub fn sceCtrlReadBufferPositiveExt2(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
280254

281-
/// Get the controller state information (blocking, negative logic).
282-
///
255+
/// Get the controller state information (blocking, negative logic)
256+
///
283257
/// * `port` - use 0.
284-
/// * `*pad_data` (out) - see ::SceCtrlData.
258+
/// * `*pad_data` (out) - see [SceCtrlData].
285259
/// * `count` - Buffers count. Up to 64 buffers can be requested.
286-
///
260+
///
287261
/// Returns buffers count, between 1 and 'count'. < 0 on error.
288-
pub fn sceCtrlReadBufferNegative(
289-
port: i32,
290-
pad_data: *mut SceCtrlData,
291-
count: i32
292-
) -> i32;
262+
pub fn sceCtrlReadBufferNegative(port: i32, pad_data: *mut SceCtrlData, count: i32) -> i32;
293263

294-
/// Set rules for button rapid fire.
295-
///
264+
/// Set rules for button rapid fire
265+
///
296266
/// * `port` - use 0.
297-
/// * `idx` - rule index between 0-15
298-
/// * `pRule` - structure ::SceCtrlRapidFireRule.
299-
///
267+
/// * `idx` - rule index between 0-15.
268+
/// * `pRule` - structure [SceCtrlRapidFireRule].
269+
///
300270
/// Returns 0 on success, < 0 on error.
301-
pub fn sceCtrlSetRapidFire(
302-
port: i32,
303-
idx: i32,
304-
pRule: *const SceCtrlRapidFireRule
305-
);
271+
pub fn sceCtrlSetRapidFire(port: i32, idx: i32, pRule: *const SceCtrlRapidFireRule);
306272

307-
/// Clear rules for button rapid fire.
308-
///
273+
/// Clear rules for button rapid fire
274+
///
309275
/// * `port` - use 0.
310-
/// * `idx` - rule index between 0-15
311-
///
276+
/// * `idx` - rule index between 0-15.
277+
///
312278
/// Returns 0 on success, < 0 on error.
313-
pub fn sceCtrlClearRapidFire(
314-
port: i32,
315-
idx: i32
316-
) -> i32;
279+
pub fn sceCtrlClearRapidFire(port: i32, idx: i32) -> i32;
317280

318-
/// Control the actuator (vibrate) on paired controllers.
319-
///
281+
/// Control the actuator (vibrate) on paired controllers
282+
///
320283
/// * `port` - use 1 for the first paired controller, etc.
321-
/// * `state` - see ::SceCtrlActuator
322-
///
284+
/// * `state` - see [SceCtrlActuator].
285+
///
323286
/// Returns 0 on success, < 0 on error.
324-
pub fn sceCtrlSetActuator(
325-
port: i32,
326-
pState: *const SceCtrlActuator
327-
) -> i32;
287+
pub fn sceCtrlSetActuator(port: i32, pState: *const SceCtrlActuator) -> i32;
328288

329-
/// Control the light bar on paired controllers.
330-
///
289+
/// Control the light bar on paired controllers
290+
///
331291
/// * `port` - use 1 for the first paired controller, etc.
332-
/// * `r` - red intensity
333-
/// * `g` - green intensity
334-
/// * `b` - blue intensity
335-
///
292+
/// * `r` - red intensity.
293+
/// * `g` - green intensity.
294+
/// * `b` - blue intensity.
295+
///
336296
/// Returns 0 on success, < 0 on error.
337-
pub fn sceCtrlSetLightBar(
338-
port: i32,
339-
r: SceUInt8,
340-
g: SceUInt8,
341-
b: SceUInt8
342-
) -> i32;
297+
pub fn sceCtrlSetLightBar(port: i32, r: SceUInt8, g: SceUInt8, b: SceUInt8) -> i32;
343298

344299
/// Get controller port information.
345-
///
346-
/// * `info` (out) - see ::SceCtrlPortInfo
347-
///
300+
///
301+
/// * `info` (out) - see [SceCtrlPortInfo].
302+
///
348303
/// Returns 0 on success, < 0 on error.
349-
pub fn sceCtrlGetControllerPortInfo(
350-
info: *mut SceCtrlPortInfo
351-
) -> i32;
304+
pub fn sceCtrlGetControllerPortInfo(info: *mut SceCtrlPortInfo) -> i32;
352305

353-
/// Get controller battery information.
354-
///
306+
/// Get controller battery information
307+
///
355308
/// * `port` - use 1 for the first paired controller, etc.
356-
/// * `batt` (out) - battery level, between 0-5, 0xEE charging, 0xEF charged
357-
///
309+
/// * `batt` (out) - battery level, between 0-5, 0xEE charging, 0xEF charged.
310+
///
358311
/// Returns 0 on success, < 0 on error.
359-
pub fn sceCtrlGetBatteryInfo(
360-
port: i32,
361-
batt: *mut SceUInt8
362-
) -> i32;
312+
pub fn sceCtrlGetBatteryInfo(port: i32, batt: *mut SceUInt8) -> i32;
363313

364-
/// Sets intercept.
365-
///
366-
/// If true, allows the current thread to intercept controls. The use case
367-
/// might be, for example, a game plugin that wishes to capture input without
368-
/// having the input sent to the game thread.
369-
///
370-
/// * `intercept` - Boolean value
371-
///
314+
/// Sets intercept
315+
///
316+
/// If true, allows the current thread to intercept controls.
317+
/// The use case might be, for example, a game plugin that wishes to
318+
/// capture input without having the input sent to the game thread.
319+
///
320+
/// * `intercept` - Boolean value.
321+
///
372322
/// Returns 0 on success, < 0 on error.
373-
pub fn sceCtrlSetButtonIntercept(
374-
intercept: i32
375-
) -> i32;
323+
pub fn sceCtrlSetButtonIntercept(intercept: i32) -> i32;
376324

377-
/// Gets intercept.
378-
///
379-
/// * `intercept` (out) - Boolean value
325+
/// Gets intercept
326+
///
327+
/// * `intercept` (out) - Boolean value.
380328
///
381329
/// Returns 0 on success, < 0 on error.
382-
pub fn sceCtrlGetButtonIntercept(
383-
intercept: *mut i32
384-
) -> i32;
330+
pub fn sceCtrlGetButtonIntercept(intercept: *mut i32) -> i32;
385331

386-
/// Check if multi controller is supported.
332+
/// Check if multi controller is supported
387333
///
388-
/// Returns 1 if yes, 0 if no
334+
/// Returns 1 if yes, 0 if no.
389335
pub fn sceCtrlIsMultiControllerSupported() -> i32;
390336
}

0 commit comments

Comments
 (0)