Code: Select all
#ifndef __CTRL_H__
#define __CTRL_H__
#ifdef __cplusplus
extern "C" {
#endif
enum CtrlButtons
{
CTRL_SQUARE = 0x8000,
CTRL_TRIANGLE = 0x1000,
CTRL_CIRCLE = 0x2000,
CTRL_CROSS = 0x4000,
CTRL_UP = 0x0010,
CTRL_DOWN = 0x0040,
CTRL_LEFT = 0x0080,
CTRL_RIGHT = 0x0020,
CTRL_START = 0x0008,
CTRL_SELECT = 0x0001,
CTRL_LTRIGGER = 0x0100,
CTRL_RTRIGGER = 0x0200,
};
/** Returned controller data */
typedef struct _ctrl_data
{
/** The current read frame */
u32 frame;
/** Bit mask containing zero or more of CtrlButtons */
u32 buttons;
/** Analogue stick, X direction */
u8 analog_x;
/** Analogue stick, Y direction */
u8 analog_y;
/** Dummy padding value */
u16 dummy;
/** Seemingly unused */
u32 unused;
} __attribute__((packed)) ctrl_data_t;
/**
* Set controller sample rate
*
* @par Example:
* @see sceCtrlReadBufferPositive
*
* @param arg Should be set to 0
*/
void sceCtrlSetSamplingCycle(int arg);
/**
* Set the sampling mode
*
* @par Example:
* @see sceCtrlReadBufferPositive
*
* @param on - Pass 1 to enable analogue mode
*/
void sceCtrlSetSamplingMode(int on);
/**
* Read buffer positive
*
* @par Example:
* @code
* ctrl_data_t pad;
* sceCtrlSetSamplingCycle(0);
* sceCtrlSetSamplingMode(1);
* sceCtrlReadBufferPositive(&pad, 1);
* // Do something with the read controller data
* @endcode
*
* @param pad_data - Structure to hold the returned pad data
* @param option - Unknown function. Always set to 1
*/
void sceCtrlReadBufferPositive(ctrl_data_t *pad_data, int option);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif