ps2sdk
1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
|
#include <tamtypes.h>
#include <kernel.h>
#include <stdio.h>
#include <string.h>
#include <sifrpc.h>
#include <sifcmd.h>
#include "libpad.h"
Go to the source code of this file.
Data Structures | |
struct | pad_state |
struct | pad_data |
Macros | |
#define | PAD_BIND_RPC_ID1 0x8000010f |
#define | PAD_BIND_RPC_ID2 0x8000011f |
#define | PAD_RPCCMD_OPEN 0x80000100 |
#define | PAD_RPCCMD_INFO_ACT 0x80000102 |
#define | PAD_RPCCMD_INFO_COMB 0x80000103 |
#define | PAD_RPCCMD_INFO_MODE 0x80000104 |
#define | PAD_RPCCMD_SET_MMODE 0x80000105 |
#define | PAD_RPCCMD_SET_ACTDIR 0x80000106 |
#define | PAD_RPCCMD_SET_ACTALIGN 0x80000107 |
#define | PAD_RPCCMD_GET_BTNMASK 0x80000108 |
#define | PAD_RPCCMD_SET_BTNINFO 0x80000109 |
#define | PAD_RPCCMD_SET_VREF 0x8000010a |
#define | PAD_RPCCMD_GET_PORTMAX 0x8000010b |
#define | PAD_RPCCMD_GET_SLOTMAX 0x8000010c |
#define | PAD_RPCCMD_CLOSE 0x8000010d |
#define | PAD_RPCCMD_END 0x8000010e |
#define | PAD_RPCCMD_INIT 0x00000100 |
Functions | |
static struct pad_data * | padGetDmaStr (int port, int slot) |
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, char actAlign[6]) |
int | padSetActDirect (int port, int slot, char actAlign[6]) |
int | padGetConnection (int port, int slot) |
Variables | |
int | _iop_reboot_count |
static const char | padStateString [8][16] |
static const char | padReqStateString [3][16] = {"COMPLETE", "FAILED", "BUSY"} |
static int | padInitialised = 0 |
static SifRpcClientData_t | padsif [2] |
static struct pad_state | PadState [2][8] |
Pad library functions Quite easy rev engineered from util demos.. Find any bugs? Mail me: pukko @hom e.se
Definition in file libpad.c.
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.
Definition at line 372 of file libpad.c.
References buffer, NULL, PAD_RPCCMD_END, padInitialised, padsif, and SifCallRpc().
int padEnterPressMode | ( | int | port, |
int | slot | ||
) |
Pressure sensitive mode ON
Definition at line 690 of file libpad.c.
References padSetButtonInfo(), port, and slot.
Referenced by initializePad(), main(), and pad_set_sensitivity().
int padExitPressMode | ( | int | port, |
int | slot | ||
) |
Check for newer version Pressure sensitive mode OFF
Definition at line 696 of file libpad.c.
References padSetButtonInfo(), port, and slot.
Referenced by main(), and pad_set_sensitivity().
int padGetButtonMask | ( | int | port, |
int | slot | ||
) |
Definition at line 703 of file libpad.c.
References buffer, NULL, PAD_RPCCMD_GET_BTNMASK, padsif, port, SifCallRpc(), and slot.
Referenced by padInfoPressMode().
int padGetConnection | ( | int | port, |
int | slot | ||
) |
|
static |
Common helper
Definition at line 253 of file libpad.c.
References pad_data::frame, pad_state::padData, PadState, port, slot, and SyncDCache().
Referenced by padGetReqState(), padGetState(), padInfoAct(), padInfoMode(), padRead(), and padSetReqState().
int padGetModVersion | ( | ) |
int padGetPortMax | ( | void | ) |
Returns # slots on the PS2 (usally 2)
Definition at line 548 of file libpad.c.
References buffer, NULL, PAD_RPCCMD_GET_PORTMAX, padsif, and SifCallRpc().
Referenced by main().
unsigned char padGetReqState | ( | int | port, |
int | slot | ||
) |
Get pad request state
Definition at line 511 of file libpad.c.
References padGetDmaStr(), port, pad_data::reqState, and slot.
Referenced by padGetState(), and padWait().
int padGetSlotMax | ( | int | port | ) |
Returns # slots the port has (usually 1) probably 4 if using a multi tap (not tested)
Definition at line 560 of file libpad.c.
References buffer, NULL, PAD_RPCCMD_GET_SLOTMAX, padsif, port, and SifCallRpc().
Referenced by main().
int padGetState | ( | int | port, |
int | slot | ||
) |
Get current pad state Wait until state == 6 (Ready) before trying to access the pad
Definition at line 482 of file libpad.c.
References PAD_RSTAT_BUSY, PAD_STATE_ERROR, PAD_STATE_EXECCMD, PAD_STATE_FINDPAD, PAD_STATE_STABLE, padGetDmaStr(), padGetReqState(), port, slot, and pad_data::state.
Referenced by find_controllers(), main(), pad_get_state(), padWait(), and waitPadReady().
unsigned char padInfoAct | ( | int | port, |
int | slot, | ||
int | word, | ||
int | byte | ||
) |
Get actuator status for this controller If padInfoAct(port, slot, -1, 0) != 0, the controller has actuators (i think ;) )
Definition at line 738 of file libpad.c.
References actuator, buffer, NULL, PAD_RPCCMD_INFO_ACT, PAD_RSTAT_BUSY, padGetDmaStr(), padSetReqState(), padsif, port, SifCallRpc(), and slot.
Referenced by initializePad(), main(), and pad_init_actuators().
int padInfoMode | ( | int | port, |
int | slot, | ||
int | infoMode, | ||
int | index | ||
) |
Get pad info (digital (4), dualshock (7), etc..)
Definition at line 588 of file libpad.c.
References buffer, index, infoMode, NULL, PAD_MODECUREXID, PAD_MODECURID, PAD_MODECUROFFS, PAD_MODETABLE, PAD_RPCCMD_INFO_MODE, PAD_RSTAT_BUSY, padGetDmaStr(), padSetReqState(), padsif, port, pad_data::reqState, SifCallRpc(), and slot.
Referenced by initializePad(), main(), pad_get_num_modes(), pad_get_type(), pad_has_type(), and pad_init_actuators().
int padInfoPressMode | ( | int | port, |
int | slot | ||
) |
Check if the pad has pressure sensitive buttons
Definition at line 675 of file libpad.c.
References padGetButtonMask(), port, and slot.
Referenced by initializePad(), main(), and pad_set_sensitivity().
int padInit | ( | int | mode | ) |
Initialise libpad
mode | Must be set to 0. |
Definition at line 297 of file libpad.c.
References _iop_reboot_count, mode, nopdelay(), NULL, PAD_BIND_RPC_ID1, PAD_BIND_RPC_ID2, padInitialised, padPortInit(), padsif, SifRpcClientData_t::server, and SifBindRpc().
Referenced by main().
int padPortClose | ( | int | port, |
int | slot | ||
) |
Closes an opened port.
port | Port to close |
slot | Slot to close |
Definition at line 449 of file libpad.c.
References buffer, NULL, pad_state::open, PAD_RPCCMD_CLOSE, padsif, PadState, port, SifCallRpc(), and slot.
Referenced by find_controllers(), and pad_close().
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 338 of file libpad.c.
References buffer, NULL, pad_state::open, PAD_RPCCMD_INIT, padsif, PadState, pad_state::port, SifCallRpc(), and pad_state::slot.
Referenced by padInit().
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 392 of file libpad.c.
References buffer, data, pad_data::frame, pad_data::length, NULL, pad_data::ok, pad_state::open, PAD_RPCCMD_OPEN, PAD_RSTAT_BUSY, PAD_STATE_EXECCMD, padArea, pad_state::padBuf, pad_state::padData, padsif, PadState, port, pad_data::reqState, SifCallRpc(), slot, and pad_data::state.
Referenced by find_controllers(), main(), and pad_open().
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 470 of file libpad.c.
References data, pad_data::data, pad_data::length, padGetDmaStr(), port, and slot.
Referenced by main(), and pad_get_buttons().
void padReqStateInt2String | ( | int | state, |
char | buf[16] | ||
) |
int padSetActAlign | ( | int | port, |
int | slot, | ||
char | act_align[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 777 of file libpad.c.
References actAlign, buffer, NULL, PAD_RPCCMD_SET_ACTALIGN, PAD_RSTAT_BUSY, padSetReqState(), padsif, port, SifCallRpc(), and slot.
Referenced by initializePad(), main(), and pad_init_actuators().
int padSetActDirect | ( | int | port, |
int | slot, | ||
char | act_align[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 800 of file libpad.c.
References actAlign, buffer, NULL, PAD_RPCCMD_SET_ACTDIR, padsif, port, SifCallRpc(), and slot.
Referenced by main(), pad_set_actuators(), and padStartAct().
int padSetButtonInfo | ( | int | port, |
int | slot, | ||
int | buttonInfo | ||
) |
Definition at line 717 of file libpad.c.
References buffer, buttonInfo, NULL, PAD_RPCCMD_SET_BTNINFO, PAD_RSTAT_BUSY, padSetReqState(), padsif, port, SifCallRpc(), and slot.
Referenced by padEnterPressMode(), and padExitPressMode().
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 656 of file libpad.c.
References buffer, lock, mode, NULL, PAD_RPCCMD_SET_MMODE, PAD_RSTAT_BUSY, padSetReqState(), padsif, port, SifCallRpc(), and slot.
Referenced by initializePad(), main(), and pad_set_mode().
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 521 of file libpad.c.
References padGetDmaStr(), port, pad_data::reqState, slot, and pad_data::state.
Referenced by padInfoAct(), padInfoMode(), padSetActAlign(), padSetButtonInfo(), and padSetMainMode().
void padStateInt2String | ( | int | state, |
char | buf[16] | ||
) |
Definition at line 532 of file libpad.c.
References padStateString, and pad_data::state.
Referenced by waitPadReady().
|
extern |
Referenced by padInit().
s32 actuator |
Definition at line 223 of file libpad.c.
Referenced by padInfoAct().
s8 align[6] |
Definition at line 230 of file libpad.c.
Referenced by remkroot().
union { ... } buffer |
Definition at line 232 of file libpad.c.
Referenced by padEnd(), padGetButtonMask(), padGetModVersion(), padGetPortMax(), padGetSlotMax(), padInfoAct(), padInfoMode(), padPortClose(), padPortInit(), padPortOpen(), padSetActAlign(), padSetActDirect(), padSetButtonInfo(), and padSetMainMode().
s32 buttonInfo |
Definition at line 213 of file libpad.c.
Referenced by padSetButtonInfo().
s32 command |
Definition at line 156 of file libpad.c.
Referenced by fileXioIoctl2(), NetManIoctl(), and NetManRpcIoctl().
s32 index |
Definition at line 194 of file libpad.c.
Referenced by ClearBufferLen(), ExpandScratchPad(), GetTLBEntry(), padInfoMode(), ProbeTLBEntry(), and SetTLBEntry().
s32 infoMode |
Definition at line 193 of file libpad.c.
Referenced by padInfoMode().
s32 lock |
Definition at line 200 of file libpad.c.
Referenced by pad_open(), pad_set_mode(), and padSetMainMode().
s32 mode |
Definition at line 184 of file libpad.c.
Referenced by padInit(), and padSetMainMode().
struct { ... } padActDirAlignArgs |
void* padArea |
Definition at line 178 of file libpad.c.
Referenced by padPortOpen().
struct { ... } padCloseArgs |
struct { ... } padGetButtonMaskArgs |
struct { ... } padInfoActArgs |
struct { ... } padInfoModeArgs |
|
static |
struct { ... } padModeResult |
struct { ... } padOpenArgs |
struct { ... } padOpenResult |
|
static |
Definition at line 149 of file libpad.c.
Referenced by padReqStateInt2String().
struct { ... } padResult |
struct { ... } padSetButtonInfoArgs |
struct { ... } padSetButtonInfoResult |
struct { ... } padSetMainModeArgs |
|
static |
Definition at line 154 of file libpad.c.
Referenced by padEnd(), padGetButtonMask(), padGetModVersion(), padGetPortMax(), padGetSlotMax(), padInfoAct(), padInfoMode(), padInit(), padPortClose(), padPortInit(), padPortOpen(), padSetActAlign(), padSetActDirect(), padSetButtonInfo(), and padSetMainMode().
struct { ... } padSlotMaxArgs |
|
static |
Port state data
Definition at line 154 of file libpad.c.
Referenced by padGetDmaStr(), padPortClose(), padPortInit(), and padPortOpen().
|
static |
Definition at line 146 of file libpad.c.
Referenced by padStateInt2String().
s32 port |
Definition at line 176 of file libpad.c.
Referenced by find_controllers(), initializePad(), main(), mcChdir(), mcDelete(), mcFormat(), mcGetDir(), mcGetEntSpace(), mcGetInfo(), mcMkDir(), mcOpen(), mcReadPage(), mcRename(), mcSetFileInfo(), mcUnformat(), mcWritePage(), mtapGetConnection(), mtapPortClose(), mtapPortOpen(), pad_open(), padEnterPressMode(), padExitPressMode(), padGetButtonMask(), padGetConnection(), padGetDmaStr(), padGetReqState(), padGetSlotMax(), padGetState(), padInfoAct(), padInfoMode(), padInfoPressMode(), padPortClose(), padPortOpen(), padRead(), padSetActAlign(), padSetActDirect(), padSetButtonInfo(), padSetMainMode(), padSetReqState(), padStartAct(), padStopAct(), padWait(), rmGetDmaStr(), RMMan_Close(), RMMan_Open(), RMMan_Read(), and waitPadReady().
s32 slot |
Definition at line 176 of file libpad.c.
Referenced by find_controllers(), initializePad(), main(), mcChdir(), mcDelete(), mcFormat(), mcGetDir(), mcGetEntSpace(), mcGetInfo(), mcMkDir(), mcOpen(), mcReadPage(), mcRename(), mcSetFileInfo(), mcUnformat(), mcWritePage(), pad_open(), padEnterPressMode(), padExitPressMode(), padGetButtonMask(), padGetConnection(), padGetDmaStr(), padGetReqState(), padGetState(), padInfoAct(), padInfoMode(), padInfoPressMode(), padPortClose(), padPortOpen(), padRead(), padSetActAlign(), padSetActDirect(), padSetButtonInfo(), padSetMainMode(), padSetReqState(), RMMan_Close(), RMMan_Open(), RMMan_Read(), and waitPadReady().