summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/kernel/ctrl.h169
-rw-r--r--include/user/ctrl.h202
2 files changed, 16 insertions, 355 deletions
diff --git a/include/kernel/ctrl.h b/include/kernel/ctrl.h
index 83449d3..d18fa6e 100644
--- a/include/kernel/ctrl.h
+++ b/include/kernel/ctrl.h
@@ -1,45 +1,19 @@
#ifndef _PSP2_KERN_CTRL_H_
#define _PSP2_KERN_CTRL_H_
-#include <psp2kern/types.h>
+#include_next <ctrl.h>
+
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum SceCtrlErrorCode {
- SCE_CTRL_ERROR_INVALID_ARG = (int)0x80340001,
- SCE_CTRL_ERROR_PRIV_REQUIRED = (int)0x80340002,
- SCE_CTRL_ERROR_FATAL = (int)0x803400FF
-} SceCtrlErrorCode;
-
-/** Enumeration for the digital controller buttons.
- * @note - L1/R1/L3/R3 only can bind using ::sceCtrlReadBufferPositiveExt2
- */
-typedef enum SceCtrlButtons {
- SCE_CTRL_SELECT = 0x00000001, //!< Select button.
- SCE_CTRL_L3 = 0x00000002, //!< L3 button.
- SCE_CTRL_R3 = 0x00000004, //!< R3 button.
- SCE_CTRL_START = 0x00000008, //!< Start button.
- SCE_CTRL_UP = 0x00000010, //!< Up D-Pad button.
- SCE_CTRL_RIGHT = 0x00000020, //!< Right D-Pad button.
- SCE_CTRL_DOWN = 0x00000040, //!< Down D-Pad button.
- SCE_CTRL_LEFT = 0x00000080, //!< Left D-Pad button.
- SCE_CTRL_LTRIGGER = 0x00000100, //!< Left trigger.
- SCE_CTRL_RTRIGGER = 0x00000200, //!< Right trigger.
- SCE_CTRL_L1 = 0x00000400, //!< L1 button.
- SCE_CTRL_R1 = 0x00000800, //!< R1 button.
- SCE_CTRL_TRIANGLE = 0x00001000, //!< Triangle button.
- SCE_CTRL_CIRCLE = 0x00002000, //!< Circle button.
- SCE_CTRL_CROSS = 0x00004000, //!< Cross button.
- SCE_CTRL_SQUARE = 0x00008000, //!< Square button.
- SCE_CTRL_INTERCEPTED = 0x00010000, //!< Input not available because intercepted by another application
- SCE_CTRL_PSBUTTON = SCE_CTRL_INTERCEPTED, //!< Playstation (Home) button.
- SCE_CTRL_HEADPHONE = 0x00080000, //!< Headphone plugged in.
- SCE_CTRL_VOLUP = 0x00100000, //!< Volume up button.
- SCE_CTRL_VOLDOWN = 0x00200000, //!< Volume down button.
- SCE_CTRL_POWER = 0x40000000 //!< Power button.
-} SceCtrlButtons;
+#define SCE_CTRL_PSBUTTON SCE_CTRL_INTERCEPTED //!< Playstation (Home) button.
+#define SCE_CTRL_HEADPHONE 0x00080000 //!< Headphone plugged in.
+#define SCE_CTRL_VOLUP 0x00100000 //!< Volume up button.
+#define SCE_CTRL_VOLDOWN 0x00200000 //!< Volume down button.
+#define SCE_CTRL_POWER 0x40000000 //!< Power button.
/** Enumeration for the controller types. */
typedef enum SceCtrlExternalInputMode {
@@ -50,50 +24,6 @@ typedef enum SceCtrlExternalInputMode {
SCE_CTRL_TYPE_DS4 = 8 //!< DualShock 4
} SceCtrlExternalInputMode;
-/** Controller mode. */
-typedef enum SceCtrlPadInputMode {
- /** Digital buttons only. */
- SCE_CTRL_MODE_DIGITAL = 0,
- /** Digital buttons + Analog support. */
- SCE_CTRL_MODE_ANALOG = 1,
- /** Same as ::SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks. */
- SCE_CTRL_MODE_ANALOG_WIDE = 2
-} SceCtrlPadInputMode;
-
-/** Returned controller data */
-typedef struct SceCtrlData {
- /** The current read frame. */
- uint64_t timeStamp;
- /** Bit mask containing zero or more of ::CtrlButtons. */
- unsigned int buttons;
- /** Left analogue stick, X axis. */
- unsigned char lx;
- /** Left analogue stick, Y axis. */
- unsigned char ly;
- /** Right analogue stick, X axis. */
- unsigned char rx;
- /** Right analogue stick, Y axis. */
- unsigned char ry;
- /** Reserved. */
- uint8_t reserved0[4];
- /** Left trigger (L2) */
- unsigned char lt;
- /** Right trigger (R2) */
- unsigned char rt;
- /** Reserved. */
- uint8_t reserved1[10];
-} SceCtrlData;
-
-/** Structure to pass as argument to ::sceCtrlSetRapidFire */
-typedef struct SceCtrlRapidFireRule {
- unsigned int Mask;
- unsigned int Trigger;
- unsigned int Target;
- unsigned int Delay;
- unsigned int Make;
- unsigned int Break;
-} SceCtrlRapidFireRule;
-
/** Structure to pass as argument to ::sceCtrlSetActuator */
typedef struct SceCtrlActuator {
unsigned char small; //!< Vibration strength of the small motor
@@ -125,89 +55,6 @@ typedef struct SceCtrlVirtualControllerDriver {
} SceCtrlVirtualControllerDriver;
/**
- * Set the controller mode.
- *
- * @param[in] mode - One of ::SceCtrlPadInputMode.
- *
- * @return The previous mode, <0 on error.
- */
-int sceCtrlSetSamplingMode(int mode);
-
-/**
- * Get the current controller mode.
- *
- * @param[out] pMode - Return value, see ::SceCtrlPadInputMode.
- *
- * @return The current mode, <0 on error.
- */
-int sceCtrlGetSamplingMode(int *pMode);
-
-/**
- * Get the controller state information (polling, positive logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlPeekBufferPositive(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Get the controller state information (polling, negative logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlPeekBufferNegative(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Get the controller state information (blocking, positive logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlReadBufferPositive(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Get the controller state information (blocking, negative logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlReadBufferNegative(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Set rules for button rapid fire
- *
- * @param[in] port - use 0.
- * @param[in] idx - rule index between 0-15
- * @param[in] pRule - structure ::SceCtrlRapidFireRule.
- *
- * @return 0, <0 on error.
- */
-int sceCtrlSetRapidFire(int port, int idx, const SceCtrlRapidFireRule* pRule);
-
-/**
- * Clear rules for button rapid fire
- *
- * @param[in] port - use 0.
- * @param[in] idx - rule index between 0-15
- *
- * @return 0, <0 on error.
- */
-int sceCtrlClearRapidFire(int port, int idx);
-
-/**
* Get controller port information.
*
* @param[out] info - see ::SceCtrlPortInfo
diff --git a/include/user/ctrl.h b/include/user/ctrl.h
index 221f2bb..8ba4a53 100644
--- a/include/user/ctrl.h
+++ b/include/user/ctrl.h
@@ -1,53 +1,19 @@
#ifndef _PSP2_CTRL_H_
#define _PSP2_CTRL_H_
+#include_next <ctrl.h>
+
#include <stdint.h>
-#include <psp2/types.h>
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum SceCtrlErrorCode {
- SCE_CTRL_ERROR_INVALID_ARG = (int)0x80340001,
- SCE_CTRL_ERROR_PRIV_REQUIRED = (int)0x80340002,
- SCE_CTRL_ERROR_NO_DEVICE = (int)0x80340020,
- SCE_CTRL_ERROR_NOT_SUPPORTED = (int)0x80340021,
- SCE_CTRL_ERROR_INVALID_MODE = (int)0x80340022,
- SCE_CTRL_ERROR_FATAL = (int)0x803400FF
-} SceCtrlErrorCode;
-
-/** Enumeration for the digital controller buttons.
- * @note - L1/R1/L3/R3 only can bind using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2
- * @note - Values bigger than 0x00010000 can be intercepted only with shell privileges
- * @note - Vita's L Trigger and R Trigger are mapped to L1 and R1 when using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2
- */
-typedef enum SceCtrlButtons {
- SCE_CTRL_SELECT = 0x00000001, //!< Select button.
- SCE_CTRL_L3 = 0x00000002, //!< L3 button.
- SCE_CTRL_R3 = 0x00000004, //!< R3 button.
- SCE_CTRL_START = 0x00000008, //!< Start button.
- SCE_CTRL_UP = 0x00000010, //!< Up D-Pad button.
- SCE_CTRL_RIGHT = 0x00000020, //!< Right D-Pad button.
- SCE_CTRL_DOWN = 0x00000040, //!< Down D-Pad button.
- SCE_CTRL_LEFT = 0x00000080, //!< Left D-Pad button.
- SCE_CTRL_LTRIGGER = 0x00000100, //!< Left trigger.
- SCE_CTRL_L2 = SCE_CTRL_LTRIGGER, //!< L2 button.
- SCE_CTRL_RTRIGGER = 0x00000200, //!< Right trigger.
- SCE_CTRL_R2 = SCE_CTRL_RTRIGGER, //!< R2 button.
- SCE_CTRL_L1 = 0x00000400, //!< L1 button.
- SCE_CTRL_R1 = 0x00000800, //!< R1 button.
- SCE_CTRL_TRIANGLE = 0x00001000, //!< Triangle button.
- SCE_CTRL_CIRCLE = 0x00002000, //!< Circle button.
- SCE_CTRL_CROSS = 0x00004000, //!< Cross button.
- SCE_CTRL_SQUARE = 0x00008000, //!< Square button.
- SCE_CTRL_INTERCEPTED = 0x00010000, //!< Input not available because intercepted by another application
- SCE_CTRL_PSBUTTON = SCE_CTRL_INTERCEPTED, //!< Playstation (Home) button.
- SCE_CTRL_HEADPHONE = 0x00080000, //!< Headphone plugged in.
- SCE_CTRL_VOLUP = 0x00100000, //!< Volume up button.
- SCE_CTRL_VOLDOWN = 0x00200000, //!< Volume down button.
- SCE_CTRL_POWER = 0x40000000 //!< Power button.
-} SceCtrlButtons;
+#define SCE_CTRL_PSBUTTON SCE_CTRL_INTERCEPTED //!< Playstation (Home) button.
+#define SCE_CTRL_HEADPHONE 0x00080000 //!< Headphone plugged in.
+#define SCE_CTRL_VOLUP 0x00100000 //!< Volume up button.
+#define SCE_CTRL_VOLDOWN 0x00200000 //!< Volume down button.
+#define SCE_CTRL_POWER 0x40000000 //!< Power button.
/** Enumeration for the controller types. */
typedef enum SceCtrlExternalInputMode {
@@ -58,68 +24,6 @@ typedef enum SceCtrlExternalInputMode {
SCE_CTRL_TYPE_DS4 = 8 //!< DualShock 4
} SceCtrlExternalInputMode;
-/** Controller mode. */
-typedef enum SceCtrlPadInputMode {
- /** Digital buttons only. */
- SCE_CTRL_MODE_DIGITAL = 0,
- /** Digital buttons + Analog support. */
- SCE_CTRL_MODE_ANALOG = 1,
- /** Same as ::SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks. */
- SCE_CTRL_MODE_ANALOG_WIDE = 2
-} SceCtrlPadInputMode;
-
-/** Returned controller data */
-typedef struct SceCtrlData {
- /** The current read frame. */
- uint64_t timeStamp;
- /** Bit mask containing zero or more of ::SceCtrlButtons. */
- unsigned int buttons;
- /** Left analogue stick, X axis. */
- unsigned char lx;
- /** Left analogue stick, Y axis. */
- unsigned char ly;
- /** Right analogue stick, X axis. */
- unsigned char rx;
- /** Right analogue stick, Y axis. */
- unsigned char ry;
- /** Up button */
- uint8_t up;
- /** Right button */
- uint8_t right;
- /** Down button */
- uint8_t down;
- /** Left button */
- uint8_t left;
- /** Left trigger (L2) */
- uint8_t lt;
- /** Right trigger (R2) */
- uint8_t rt;
- /** Left button (L1) */
- uint8_t l1;
- /** Right button (R1) */
- uint8_t r1;
- /** Triangle button */
- uint8_t triangle;
- /** Circle button */
- uint8_t circle;
- /** Cross button */
- uint8_t cross;
- /** Square button */
- uint8_t square;
- /** Reserved. */
- uint8_t reserved[4];
-} SceCtrlData;
-
-/** Structure to pass as argument to ::sceCtrlSetRapidFire */
-typedef struct SceCtrlRapidFireRule {
- unsigned int Mask;
- unsigned int Trigger;
- unsigned int Target;
- unsigned int Delay;
- unsigned int Make;
- unsigned int Break;
-} SceCtrlRapidFireRule;
-
/** Structure to pass as argument to ::sceCtrlSetActuator */
typedef struct SceCtrlActuator {
unsigned char small; //!< Vibration strength of the small motor
@@ -134,42 +38,13 @@ typedef struct SceCtrlPortInfo {
} SceCtrlPortInfo;
/**
- * Set the controller mode.
- *
- * @param[in] mode - One of ::SceCtrlPadInputMode.
- *
- * @return The previous mode, <0 on error.
- */
-int sceCtrlSetSamplingMode(SceCtrlPadInputMode mode);
-
-/**
* Set the controller extend mode.
*
* @param[in] mode - One of ::SceCtrlPadInputMode.
*
* @return The previous mode, <0 on error.
*/
-int sceCtrlSetSamplingModeExt(SceCtrlPadInputMode mode);
-
-/**
- * Get the current controller mode.
- *
- * @param[out] pMode - Return value, see ::SceCtrlPadInputMode.
- *
- * @return The current mode, <0 on error.
- */
-int sceCtrlGetSamplingMode(SceCtrlPadInputMode *pMode);
-
-/**
- * Get the controller state information (polling, positive logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlPeekBufferPositive(int port, SceCtrlData *pad_data, int count);
+int sceCtrlSetSamplingModeExt(SceUInt32 mode);
/**
* Get the controller state information (polling, positive logic).
@@ -185,28 +60,6 @@ int sceCtrlPeekBufferPositive(int port, SceCtrlData *pad_data, int count);
int sceCtrlPeekBufferPositiveExt2(int port, SceCtrlData *pad_data, int count);
/**
- * Get the controller state information (polling, negative logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlPeekBufferNegative(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Get the controller state information (blocking, positive logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlReadBufferPositive(int port, SceCtrlData *pad_data, int count);
-
-/**
* Get the controller extended state information (blocking, positive logic).
*
* This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER
@@ -220,38 +73,6 @@ int sceCtrlReadBufferPositive(int port, SceCtrlData *pad_data, int count);
int sceCtrlReadBufferPositiveExt2(int port, SceCtrlData *pad_data, int count);
/**
- * Get the controller state information (blocking, negative logic).
- *
- * @param[in] port - use 0.
- * @param[out] *pad_data - see ::SceCtrlData.
- * @param[in] count - Buffers count.
- *
- * @return Buffers count, between 1 and 'count'. <0 on error.
- */
-int sceCtrlReadBufferNegative(int port, SceCtrlData *pad_data, int count);
-
-/**
- * Set rules for button rapid fire
- *
- * @param[in] port - use 0.
- * @param[in] idx - rule index between 0-15
- * @param[in] pRule - structure ::SceCtrlRapidFireRule.
- *
- * @return 0, <0 on error.
- */
-int sceCtrlSetRapidFire(int port, int idx, const SceCtrlRapidFireRule* pRule);
-
-/**
- * Clear rules for button rapid fire
- *
- * @param[in] port - use 0.
- * @param[in] idx - rule index between 0-15
- *
- * @return 0, <0 on error.
- */
-int sceCtrlClearRapidFire(int port, int idx);
-
-/**
* Control the actuator (vibrate) on paired controllers.
*
* @param[in] port - use 1 for the first paired controller, etc.
@@ -312,13 +133,6 @@ int sceCtrlSetButtonIntercept(int intercept);
*/
int sceCtrlGetButtonIntercept(int *intercept);
-/**
- * Check if multi controller is supported
- *
- * @return 1 if yes, 0 if no
- */
-int sceCtrlIsMultiControllerSupported(void);
-
#ifdef __cplusplus
}
#endif