PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
libpad.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  padButtonStatus
 

Macros

#define PAD_LEFT   0x0080
 
#define PAD_DOWN   0x0040
 
#define PAD_RIGHT   0x0020
 
#define PAD_UP   0x0010
 
#define PAD_START   0x0008
 
#define PAD_R3   0x0004
 
#define PAD_L3   0x0002
 
#define PAD_SELECT   0x0001
 
#define PAD_SQUARE   0x8000
 
#define PAD_CROSS   0x4000
 
#define PAD_CIRCLE   0x2000
 
#define PAD_TRIANGLE   0x1000
 
#define PAD_R1   0x0800
 
#define PAD_L1   0x0400
 
#define PAD_R2   0x0200
 
#define PAD_L2   0x0100
 
#define PAD_STATE_DISCONN   0x00
 
#define PAD_STATE_FINDPAD   0x01
 
#define PAD_STATE_FINDCTP1   0x02
 
#define PAD_STATE_EXECCMD   0x05
 
#define PAD_STATE_STABLE   0x06
 
#define PAD_STATE_ERROR   0x07
 
#define PAD_RSTAT_COMPLETE   0x00
 
#define PAD_RSTAT_FAILED   0x01
 
#define PAD_RSTAT_BUSY   0x02
 
#define PAD_TYPE_NEJICON   0x2
 
#define PAD_TYPE_KONAMIGUN   0x3
 
#define PAD_TYPE_DIGITAL   0x4
 
#define PAD_TYPE_ANALOG   0x5
 
#define PAD_TYPE_NAMCOGUN   0x6
 
#define PAD_TYPE_DUALSHOCK   0x7
 
#define PAD_TYPE_JOGCON   0xE
 
#define PAD_TYPE_EX_TSURICON   0x100
 
#define PAD_TYPE_EX_JOGCON   0x300
 
#define PAD_MODECURID   1
 
#define PAD_MODECUREXID   2
 
#define PAD_MODECUROFFS   3
 
#define PAD_MODETABLE   4
 
#define PAD_MMODE_DIGITAL   0
 
#define PAD_MMODE_DUALSHOCK   1
 
#define PAD_MMODE_UNLOCK   2
 
#define PAD_MMODE_LOCK   3
 
#define PAD_ACTFUNC   1
 
#define PAD_ACTSUB   2
 
#define PAD_ACTSIZE   3
 
#define PAD_ACTCURR   4
 

Functions

struct padButtonStatus __attribute__ ((packed))
 
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 word, int byte)
 
int padSetActAlign (int port, int slot, const char act_align[6])
 
int padSetActDirect (int port, int slot, char act_align[6])
 
int padGetConnection (int port, int slot)
 

Variables

unsigned char ok
 
unsigned char mode
 
unsigned short btns
 
unsigned char rjoy_h
 
unsigned char rjoy_v
 
unsigned char ljoy_h
 
unsigned char ljoy_v
 
unsigned char right_p
 
unsigned char left_p
 
unsigned char up_p
 
unsigned char down_p
 
unsigned char triangle_p
 
unsigned char circle_p
 
unsigned char cross_p
 
unsigned char square_p
 
unsigned char l1_p
 
unsigned char r1_p
 
unsigned char l2_p
 
unsigned char r2_p
 
unsigned char unkn16 [12]
 

Detailed Description

Pad externals

Definition in file libpad.h.


Data Structure Documentation

◆ padButtonStatus

struct padButtonStatus

Button info

Definition at line 95 of file libpad.h.

Data Fields
unsigned char ok
unsigned char mode
unsigned short btns
unsigned char rjoy_h
unsigned char rjoy_v
unsigned char ljoy_h
unsigned char ljoy_v
unsigned char right_p
unsigned char left_p
unsigned char up_p
unsigned char down_p
unsigned char triangle_p
unsigned char circle_p
unsigned char cross_p
unsigned char square_p
unsigned char l1_p
unsigned char r1_p
unsigned char l2_p
unsigned char r2_p
unsigned char unkn16[12]

Macro Definition Documentation

◆ PAD_LEFT

#define PAD_LEFT   0x0080

Definition at line 23 of file libpad.h.

◆ PAD_DOWN

#define PAD_DOWN   0x0040

Definition at line 24 of file libpad.h.

◆ PAD_RIGHT

#define PAD_RIGHT   0x0020

Definition at line 25 of file libpad.h.

◆ PAD_UP

#define PAD_UP   0x0010

Definition at line 26 of file libpad.h.

◆ PAD_START

#define PAD_START   0x0008

Definition at line 27 of file libpad.h.

◆ PAD_R3

#define PAD_R3   0x0004

Definition at line 28 of file libpad.h.

◆ PAD_L3

#define PAD_L3   0x0002

Definition at line 29 of file libpad.h.

◆ PAD_SELECT

#define PAD_SELECT   0x0001

Definition at line 30 of file libpad.h.

◆ PAD_SQUARE

#define PAD_SQUARE   0x8000

Definition at line 31 of file libpad.h.

◆ PAD_CROSS

#define PAD_CROSS   0x4000

Definition at line 32 of file libpad.h.

◆ PAD_CIRCLE

#define PAD_CIRCLE   0x2000

Definition at line 33 of file libpad.h.

◆ PAD_TRIANGLE

#define PAD_TRIANGLE   0x1000

Definition at line 34 of file libpad.h.

◆ PAD_R1

#define PAD_R1   0x0800

Definition at line 35 of file libpad.h.

◆ PAD_L1

#define PAD_L1   0x0400

Definition at line 36 of file libpad.h.

◆ PAD_R2

#define PAD_R2   0x0200

Definition at line 37 of file libpad.h.

◆ PAD_L2

#define PAD_L2   0x0100

Definition at line 38 of file libpad.h.

◆ PAD_STATE_DISCONN

#define PAD_STATE_DISCONN   0x00

Definition at line 43 of file libpad.h.

◆ PAD_STATE_FINDPAD

#define PAD_STATE_FINDPAD   0x01

Definition at line 44 of file libpad.h.

◆ PAD_STATE_FINDCTP1

#define PAD_STATE_FINDCTP1   0x02

Definition at line 45 of file libpad.h.

◆ PAD_STATE_EXECCMD

#define PAD_STATE_EXECCMD   0x05

Definition at line 46 of file libpad.h.

◆ PAD_STATE_STABLE

#define PAD_STATE_STABLE   0x06

Definition at line 47 of file libpad.h.

◆ PAD_STATE_ERROR

#define PAD_STATE_ERROR   0x07

Definition at line 48 of file libpad.h.

◆ PAD_RSTAT_COMPLETE

#define PAD_RSTAT_COMPLETE   0x00

Definition at line 53 of file libpad.h.

◆ PAD_RSTAT_FAILED

#define PAD_RSTAT_FAILED   0x01

Definition at line 54 of file libpad.h.

◆ PAD_RSTAT_BUSY

#define PAD_RSTAT_BUSY   0x02

Definition at line 55 of file libpad.h.

◆ PAD_TYPE_NEJICON

#define PAD_TYPE_NEJICON   0x2

Definition at line 60 of file libpad.h.

◆ PAD_TYPE_KONAMIGUN

#define PAD_TYPE_KONAMIGUN   0x3

Definition at line 61 of file libpad.h.

◆ PAD_TYPE_DIGITAL

#define PAD_TYPE_DIGITAL   0x4

Definition at line 62 of file libpad.h.

◆ PAD_TYPE_ANALOG

#define PAD_TYPE_ANALOG   0x5

Definition at line 63 of file libpad.h.

◆ PAD_TYPE_NAMCOGUN

#define PAD_TYPE_NAMCOGUN   0x6

Definition at line 64 of file libpad.h.

◆ PAD_TYPE_DUALSHOCK

#define PAD_TYPE_DUALSHOCK   0x7

Definition at line 65 of file libpad.h.

◆ PAD_TYPE_JOGCON

#define PAD_TYPE_JOGCON   0xE

Definition at line 66 of file libpad.h.

◆ PAD_TYPE_EX_TSURICON

#define PAD_TYPE_EX_TSURICON   0x100

Definition at line 67 of file libpad.h.

◆ PAD_TYPE_EX_JOGCON

#define PAD_TYPE_EX_JOGCON   0x300

Definition at line 68 of file libpad.h.

◆ PAD_MODECURID

#define PAD_MODECURID   1

Definition at line 72 of file libpad.h.

◆ PAD_MODECUREXID

#define PAD_MODECUREXID   2

Definition at line 73 of file libpad.h.

◆ PAD_MODECUROFFS

#define PAD_MODECUROFFS   3

Definition at line 74 of file libpad.h.

◆ PAD_MODETABLE

#define PAD_MODETABLE   4

Definition at line 75 of file libpad.h.

◆ PAD_MMODE_DIGITAL

#define PAD_MMODE_DIGITAL   0

Definition at line 80 of file libpad.h.

◆ PAD_MMODE_DUALSHOCK

#define PAD_MMODE_DUALSHOCK   1

Definition at line 81 of file libpad.h.

◆ PAD_MMODE_UNLOCK

#define PAD_MMODE_UNLOCK   2

Definition at line 83 of file libpad.h.

◆ PAD_MMODE_LOCK

#define PAD_MMODE_LOCK   3

Definition at line 84 of file libpad.h.

◆ PAD_ACTFUNC

#define PAD_ACTFUNC   1

Definition at line 89 of file libpad.h.

◆ PAD_ACTSUB

#define PAD_ACTSUB   2

Definition at line 90 of file libpad.h.

◆ PAD_ACTSIZE

#define PAD_ACTSIZE   3

Definition at line 91 of file libpad.h.

◆ PAD_ACTCURR

#define PAD_ACTCURR   4

Definition at line 92 of file libpad.h.

Function Documentation

◆ __attribute__()

struct padButtonStatus __attribute__ ( (packed)  )

Definition at line 20 of file gpt_types.h.

◆ padInit()

int padInit ( int  mode)

Initialise libpad

Parameters
modeMust be set to 0.
Returns
== 1 => OK

Definition at line 297 of file libpad.c.

References padPortInit().

◆ padPortInit()

int padPortInit ( int  mode)

Initialise pad ports. Automatically called by padInit(), there is no need to call this function directly.

Parameters
modeMust be set to 0.
Returns
== 1 => OK

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().

Returns
== 1 => OK

Definition at line 338 of file libpad.c.

References PadState.

Referenced by padInit().

◆ padEnd()

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.

Returns
== 1 => OK

Definition at line 374 of file libpad.c.

◆ padPortOpen()

int padPortOpen ( int  port,
int  slot,
void *  padArea 
)
Parameters
portPort to open
slotSlot to open
padAreaThe 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.
Returns
!= 0 => OK

Definition at line 394 of file libpad.c.

References PadState.

Referenced by pad_open().

◆ padPortClose()

int padPortClose ( int  port,
int  slot 
)

Closes an opened port.

Parameters
portPort to close
slotSlot to close
Returns
!= 0 => OK

Definition at line 451 of file libpad.c.

References PadState.

Referenced by pad_close(), and padEnd().

◆ padRead()

unsigned char padRead ( int  port,
int  slot,
struct padButtonStatus data 
)

Read pad data

Parameters
portPort number of the pad to get the status for.
slotSlot number of the pad to get the status for.
dataA pointer to a 32 byte array where the result is stored
Returns
!= 0 => OK

Definition at line 472 of file libpad.c.

References padGetDmaStr().

Referenced by pad_get_buttons().

◆ padGetState()

int padGetState ( int  port,
int  slot 
)

Get current pad state Wait until state == 6 (Ready) before trying to access the pad

Definition at line 484 of file libpad.c.

References padGetDmaStr(), and padGetReqState().

Referenced by pad_get_state().

◆ padGetReqState()

unsigned char padGetReqState ( int  port,
int  slot 
)

Get pad request state

Definition at line 513 of file libpad.c.

References padGetDmaStr().

Referenced by padGetState().

◆ padSetReqState()

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 523 of file libpad.c.

References padGetDmaStr().

Referenced by padInfoAct(), padInfoMode(), padSetActAlign(), and padSetMainMode().

◆ padStateInt2String()

void padStateInt2String ( int  state,
char  buf[16] 
)

Definition at line 534 of file libpad.c.

◆ padReqStateInt2String()

void padReqStateInt2String ( int  state,
char  buf[16] 
)

Definition at line 543 of file libpad.c.

◆ padGetPortMax()

int padGetPortMax ( void  )

Returns # slots on the PS2 (usally 2)

Definition at line 550 of file libpad.c.

◆ padGetSlotMax()

int padGetSlotMax ( int  port)

Returns # slots the port has (usually 1) probably 4 if using a multi tap (not tested)

Definition at line 562 of file libpad.c.

◆ padGetModVersion()

int padGetModVersion ( )

Returns the padman.irx version NOT SUPPORTED on module rom0:padman

Definition at line 575 of file libpad.c.

◆ padInfoMode()

int padInfoMode ( int  port,
int  slot,
int  infoMode,
int  index 
)

Get pad info (digital (4), dualshock (7), etc..)

Returns
3 - KONAMI GUN; 4 - DIGITAL PAD; 5 - JOYSTICK; 6 - NAMCO GUN; 7 - DUAL SHOCK

Definition at line 590 of file libpad.c.

References padGetDmaStr(), and padSetReqState().

Referenced by pad_get_num_modes(), pad_get_type(), pad_has_type(), and pad_init_actuators().

◆ padSetMainMode()

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 658 of file libpad.c.

References padSetReqState().

Referenced by pad_set_mode().

◆ padInfoPressMode()

int padInfoPressMode ( int  port,
int  slot 
)

Check if the pad has pressure sensitive buttons

Definition at line 677 of file libpad.c.

Referenced by pad_set_sensitivity().

◆ padEnterPressMode()

int padEnterPressMode ( int  port,
int  slot 
)

Pressure sensitive mode ON

Definition at line 692 of file libpad.c.

Referenced by pad_set_sensitivity().

◆ padExitPressMode()

int padExitPressMode ( int  port,
int  slot 
)

Check for newer version Pressure sensitive mode OFF

Definition at line 698 of file libpad.c.

Referenced by pad_set_sensitivity().

◆ padGetButtonMask()

int padGetButtonMask ( int  port,
int  slot 
)

Definition at line 705 of file libpad.c.

◆ padSetButtonInfo()

int padSetButtonInfo ( int  port,
int  slot,
int  buttonInfo 
)

Definition at line 719 of file libpad.c.

◆ padInfoAct()

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 740 of file libpad.c.

References padGetDmaStr(), and padSetReqState().

Referenced by pad_init_actuators().

◆ padSetActAlign()

int padSetActAlign ( int  port,
int  slot,
const 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 779 of file libpad.c.

References padSetReqState().

Referenced by pad_init_actuators().

◆ padSetActDirect()

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 802 of file libpad.c.

Referenced by pad_set_actuators().

◆ padGetConnection()

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 825 of file libpad.c.

Variable Documentation

◆ ok

unsigned char ok

Definition at line 0 of file libpad.h.

◆ mode

unsigned char mode

Definition at line 1 of file libpad.h.

◆ btns

unsigned short btns

Definition at line 2 of file libpad.h.

◆ rjoy_h

unsigned char rjoy_h

Definition at line 4 of file libpad.h.

◆ rjoy_v

unsigned char rjoy_v

Definition at line 5 of file libpad.h.

◆ ljoy_h

unsigned char ljoy_h

Definition at line 6 of file libpad.h.

◆ ljoy_v

unsigned char ljoy_v

Definition at line 7 of file libpad.h.

◆ right_p

unsigned char right_p

Definition at line 9 of file libpad.h.

◆ left_p

unsigned char left_p

Definition at line 10 of file libpad.h.

◆ up_p

unsigned char up_p

Definition at line 11 of file libpad.h.

◆ down_p

unsigned char down_p

Definition at line 12 of file libpad.h.

◆ triangle_p

unsigned char triangle_p

Definition at line 13 of file libpad.h.

◆ circle_p

unsigned char circle_p

Definition at line 14 of file libpad.h.

◆ cross_p

unsigned char cross_p

Definition at line 15 of file libpad.h.

◆ square_p

unsigned char square_p

Definition at line 16 of file libpad.h.

◆ l1_p

unsigned char l1_p

Definition at line 17 of file libpad.h.

◆ r1_p

unsigned char r1_p

Definition at line 18 of file libpad.h.

◆ l2_p

unsigned char l2_p

Definition at line 19 of file libpad.h.

◆ r2_p

unsigned char r2_p

Definition at line 20 of file libpad.h.

◆ unkn16

unsigned char unkn16[12]

Definition at line 21 of file libpad.h.