|
PS2SDK
PS2 Homebrew Libraries
|
#include <tamtypes.h>#include <kernel.h>#include <stdio.h>#include <string.h>#include <sifrpc.h>#include <sifcmd.h>#include "libpad.h"
Include dependency graph for libpad.c:Go to the source code of this file.
Data Structures | |
| struct | pad_data_new |
| struct | pad_data_old |
| union | pad_data_u |
| struct | pad_state |
| struct | open_slot |
| struct | .padInitArgs |
| struct | .padOpenResult |
| struct | .padResult |
| struct | .padOpenArgs |
| struct | .padCloseArgs |
| struct | .padSlotMaxArgs |
| struct | .padInfoModeArgs |
| struct | .padSetMainModeArgs |
| struct | .padModeResult |
| struct | .padGetButtonMaskArgs |
| struct | .padSetButtonInfoArgs |
| struct | .padSetButtonInfoResult |
| struct | .padInfoActArgs |
| struct | .padActDirAlignArgs |
Functions | |
| static SifRpcClientData_t padsif[2] | __attribute__ ((aligned(64))) |
| static struct pad_data_new * | padGetDmaStrNew (int port, int slot) |
| static struct pad_data_old * | padGetDmaStrOld (int port, int slot) |
| static struct open_slot * | padGetConnDmaStr (void) |
| int | padInit (int mode) |
| int | padPortInit (int mode) |
| int | padEnd (void) |
| int | padPortOpen (int port, int slot, void *padArea) |
| int | padPortClose (int port, int slot) |
| unsigned char | padRead (int port, int slot, struct padButtonStatus *data) |
| int | padGetState (int port, int slot) |
| unsigned char | padGetReqState (int port, int slot) |
| int | padSetReqState (int port, int slot, int state) |
| void | padStateInt2String (int state, char buf[16]) |
| void | padReqStateInt2String (int state, char buf[16]) |
| int | padGetPortMax (void) |
| int | padGetSlotMax (int port) |
| int | padGetModVersion () |
| int | padInfoMode (int port, int slot, int infoMode, int index) |
| int | padSetMainMode (int port, int slot, int mode, int lock) |
| int | padInfoPressMode (int port, int slot) |
| int | padEnterPressMode (int port, int slot) |
| int | padExitPressMode (int port, int slot) |
| int | padGetButtonMask (int port, int slot) |
| int | padSetButtonInfo (int port, int slot, int buttonInfo) |
| unsigned char | padInfoAct (int port, int slot, int actuator, int cmd) |
| int | padSetActAlign (int port, int slot, const char actAlign[6]) |
| int | padSetActDirect (int port, int slot, const char actAlign[6]) |
| int | padGetConnection (int port, int slot) |
Variables | ||
| int | _iop_reboot_count | |
| static const char * | padStateString [] | |
| static const char * | padReqStateString [] | |
| static int | padInitialised = 0 | |
| s32 | command | |
| struct { | ||
| s32 | command | |
| s32 | unused [3] | |
| void * | statBuf | |
| } | padInitArgs | |
| struct { | ||
| s32 | unknown [3] | |
| s32 | result | |
| s32 | unknown2 | |
| void * | padBuf | |
| } | padOpenResult | |
| struct { | ||
| s32 | unknown [3] | |
| s32 | result | |
| } | padResult | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | unknown | |
| void * | padArea | |
| } | padOpenArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | unknown | |
| s32 | mode | |
| } | padCloseArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| } | padSlotMaxArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | infoMode | |
| s32 | index | |
| } | padInfoModeArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | mode | |
| s32 | lock | |
| } | padSetMainModeArgs | |
| struct { | ||
| s32 | unknown [5] | |
| s32 | result | |
| } | padModeResult | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| } | padGetButtonMaskArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | buttonInfo | |
| } | padSetButtonInfoArgs | |
| struct { | ||
| s32 | unknown [4] | |
| s32 | result | |
| } | padSetButtonInfoResult | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s32 | actuator | |
| s32 | act_cmd | |
| } | padInfoActArgs | |
| struct { | ||
| s32 | command | |
| s32 | port | |
| s32 | slot | |
| s8 | align [6] | |
| } | padActDirAlignArgs | |
| char | buffer [128] | |
| static struct pad_state | PadState [2][8] | |
Pad library functions Quite easy rev engineered from util demos.. Find any bugs? Mail me: pukko.nosp@m.@hom.nosp@m.e.se
Definition in file libpad.c.
| struct pad_data_new |
| struct pad_data_old |
| union pad_data_u |
Collaboration diagram for pad_data_u:| Data Fields | ||
|---|---|---|
| struct pad_data_old | oldPadData[2] | |
| struct pad_data_new | newPadData[2] | |
| struct pad_state |
Collaboration diagram for pad_state:| Data Fields | ||
|---|---|---|
| int | open | |
| unsigned int | port | |
| unsigned int | slot | |
| union pad_data_u * | padData | |
| unsigned char * | padBuf | |
| struct open_slot |
| struct .padInitArgs |
| struct .padOpenResult |
| struct .padOpenArgs |
| struct .padCloseArgs |
| struct .padInfoModeArgs |
| struct .padSetMainModeArgs |
| struct .padModeResult |
| struct .padGetButtonMaskArgs |
| struct .padSetButtonInfoArgs |
| struct .padSetButtonInfoResult |
| struct .padInfoActArgs |
| struct .padActDirAlignArgs |
|
static |
Port state data
|
static |
Common helper
Definition at line 255 of file libpad.c.
Referenced by padGetReqState(), padGetState(), padInfoAct(), padInfoMode(), padRead(), and padSetReqState().
|
static |
|
static |
Returns the data for pad (opened) status. This seems to have been removed from the official SDKs, very early during the PS2's lifetime.
Definition at line 281 of file libpad.c.
Referenced by padGetConnection().
| int padInit | ( | int | mode | ) |
Initialise libpad
| mode | Must be set to 0. |
Definition at line 300 of file libpad.c.
References __attribute__, and padPortInit().
| int padPortInit | ( | int | mode | ) |
Initialise pad ports. Automatically called by padInit(), there is no need to call this function directly.
| mode | Must be set to 0. |
Note: PADMAN from release 1.3.4 does not have this function implemented. As a result, it is impossible to reinitialize libpad after calling padEnd().
Definition at line 386 of file libpad.c.
Referenced by padInit().
| int padEnd | ( | void | ) |
Ends all pad communication Note: PADMAN from release 1.3.4 does not have padPortInit implemented. As a result, it is impossible to reinitialize libpad after calling padEnd(). This was known as padClose in the really early official SDK releases.
| int padPortOpen | ( | int | port, |
| int | slot, | ||
| void * | padArea ) |
| port | Port to open |
| slot | Slot to open |
| padArea | The address of the buffer for storing the pad status. Must be a 256-byte region (2xsizeof(struct pad_data). Must be a 64-byte aligned address. For the old libpad, at least 16-bytes alignment. |
Definition at line 462 of file libpad.c.
Referenced by pad_open().
| int padPortClose | ( | int | port, |
| int | slot ) |
Closes an opened port.
| port | Port to close |
| slot | Slot to close |
Definition at line 574 of file libpad.c.
Referenced by pad_close(), and padEnd().
| unsigned char padRead | ( | int | port, |
| int | slot, | ||
| struct padButtonStatus * | data ) |
Read pad data
| port | Port number of the pad to get the status for. |
| slot | Slot number of the pad to get the status for. |
| data | A pointer to a 32 byte array where the result is stored |
Definition at line 612 of file libpad.c.
References padGetDmaStrNew().
Referenced by pad_get_buttons().
| int padGetState | ( | int | port, |
| int | slot ) |
Get current pad state Wait until state == 6 (Ready) before trying to access the pad
Definition at line 645 of file libpad.c.
References padGetDmaStrNew(), and padGetReqState().
Referenced by pad_get_state().
| unsigned char padGetReqState | ( | int | port, |
| int | slot ) |
Get pad request state
Definition at line 687 of file libpad.c.
References padGetDmaStrNew().
Referenced by padGetState().
| int padSetReqState | ( | int | port, |
| int | slot, | ||
| int | state ) |
Set pad request state (after a param setting) No need to export this one perhaps..
Definition at line 706 of file libpad.c.
References padGetDmaStrNew().
Referenced by padInfoAct(), padInfoMode(), padSetActAlign(), and padSetMainMode().
| int padGetPortMax | ( | void | ) |
| int padGetSlotMax | ( | int | port | ) |
| int padGetModVersion | ( | ) |
| int padInfoMode | ( | int | port, |
| int | slot, | ||
| int | infoMode, | ||
| int | index ) |
Get pad info (digital (4), dualshock (7), etc..)
Definition at line 805 of file libpad.c.
References padGetDmaStrNew(), and padSetReqState().
Referenced by pad_get_num_modes(), pad_get_type(), pad_has_type(), and pad_init_actuators().
| int padSetMainMode | ( | int | port, |
| int | slot, | ||
| int | mode, | ||
| int | lock ) |
mode = 1, -> Analog/dual shock enabled; mode = 0 -> Digital lock = 3 -> Mode not changeable by user
Definition at line 866 of file libpad.c.
References padSetReqState().
Referenced by pad_set_mode().
| int padInfoPressMode | ( | int | port, |
| int | slot ) |
Check if the pad has pressure sensitive buttons
Definition at line 897 of file libpad.c.
Referenced by pad_set_sensitivity().
| int padEnterPressMode | ( | int | port, |
| int | slot ) |
Pressure sensitive mode ON
Definition at line 903 of file libpad.c.
Referenced by pad_set_sensitivity().
| int padExitPressMode | ( | int | port, |
| int | slot ) |
Check for newer version Pressure sensitive mode OFF
Definition at line 909 of file libpad.c.
Referenced by pad_set_sensitivity().
| int padSetButtonInfo | ( | int | port, |
| int | slot, | ||
| int | buttonInfo ) |
| unsigned char padInfoAct | ( | int | port, |
| int | slot, | ||
| int | actuator, | ||
| int | cmd ) |
Get actuator status for this controller If padInfoAct(port, slot, -1, 0) != 0, the controller has actuators (i think ;) )
Definition at line 972 of file libpad.c.
References padGetDmaStrNew(), and padSetReqState().
Referenced by pad_init_actuators().
| int padSetActAlign | ( | int | port, |
| int | slot, | ||
| const char | actAlign[6] ) |
Initalise actuators. On dual shock controller: act_align[0] = 0 enables 'small' engine act_align[1] = 1 enables 'big' engine set act_align[2-5] to 0xff (disable)
Definition at line 1025 of file libpad.c.
References padSetReqState().
Referenced by pad_init_actuators().
| int padSetActDirect | ( | int | port, |
| int | slot, | ||
| const char | actAlign[6] ) |
Set actuator status on dual shock controller, act_align[0] = 0/1 turns off/on 'small' engine act_align[1] = 0-255 sets 'big' engine speed
Definition at line 1056 of file libpad.c.
Referenced by pad_set_actuators().
| int padGetConnection | ( | int | port, |
| int | slot ) |
Returns whether the device at port,slot is connected (1 = connected) Appears to have been removed very early during the PS2's lifetime. If possible, use the documented padGetState instead.
NOT SUPPORTED with module rom0:padman
Definition at line 1088 of file libpad.c.
References padGetConnDmaStr().
|
static |
|
static |