OldSchool Library
Controller

Data Structures

union  OSL_KEYLIST
 List of keys. More...
 
struct  OSL_CONTROLLER
 Controller type. More...
 
union  OSL_REMOTEKEYLIST
 List of remote keys. More...
 
struct  OSL_REMOTECONTROLLER
 Remote Controller type. More...
 

Macros

#define oslSetKeyAutorepeat(keys, init, interval)
 Sets the auto-repeat parameters for keys.
 
#define oslSetKeyAutorepeatMask(mask)
 Sets the key auto-repeat mask.
 
#define oslSetKeyAutorepeatInit(value)
 Sets the key auto-repeat initialization value.
 
#define oslSetKeyAutorepeatInterval(value)
 Sets the key auto-repeat interval value.
 
#define oslSetKeyAnalogToDPad(sensivity)
 Enables or disables automatic redirection from the analog stick to D-pad buttons.
 
#define oslSetRemoteKeyAutorepeat(keys, init, interval)
 Sets the auto-repeat parameters for remote keys.
 
#define oslSetRemoteKeyAutorepeatMask(mask)
 Sets the remote key auto-repeat mask.
 
#define oslSetRemoteKeyAutorepeatInit(value)
 Sets the remote key auto-repeat initialization value.
 
#define oslSetRemoteKeyAutorepeatInterval(value)
 Sets the remote key auto-repeat interval value.
 

Enumerations

enum  OSL_KEY_BITS {
  OSL_KEY_SELECT = 1 , OSL_KEY_START = 4 , OSL_KEY_UP = 5 , OSL_KEY_RIGHT = 6 ,
  OSL_KEY_DOWN = 7 , OSL_KEY_LEFT = 8 , OSL_KEY_L = 9 , OSL_KEY_R = 10 ,
  OSL_KEY_TRIANGLE = 13 , OSL_KEY_CIRCLE = 14 , OSL_KEY_CROSS = 15 , OSL_KEY_SQUARE = 16 ,
  OSL_KEY_HOME = 17 , OSL_KEY_HOLD = 18 , OSL_KEY_NOTE = 24
}
 Bit number for each key in the 'value' field. More...
 
enum  OSL_KEY_MASKS
 Mask for each key in the 'value' field. More...
 

Functions

OSL_CONTROLLERoslReadKeys ()
 Reads the current controller state and stores the result in the osl_pad structure.
 
int oslSetReadKeysFunction (int(*sceCtrlReadBufferPositive)(SceCtrlData *pad_data, int count))
 Sets an external function to read keys.
 
int oslUnsetReadKeysFunction ()
 Unsets the function set with oslSetReadKeysFunction.
 
int oslSetHoldForAnalog (int holdForAnalog)
 Decides if HOLD will affect the analog stick.
 
int oslWaitKey ()
 Waits for a key and returns its code.
 
int oslKbhit ()
 Determines whether a key is currently buffered and returns its code.
 
void oslFlushKey ()
 Flushes the key buffer, removing the pending key.
 
OSL_REMOTECONTROLLERoslReadRemoteKeys ()
 Reads the current remote controller state and stores the result in the osl_remote structure.
 
void oslFlushRemoteKey ()
 Flushes the remote key buffer, removing the pending key.
 
int oslIsRemoteExist ()
 Determines whether the remote is plugged in.
 

Variables

OSL_CONTROLLERosl_keys
 Current keys. Only here for compatibility, use osl_pad now.
 
OSL_CONTROLLER osl_pad
 Current keys.
 
OSL_REMOTECONTROLLERosl_remotekeys
 Current remote keys.
 
OSL_REMOTECONTROLLER osl_remote
 Current remote keys.
 

Detailed Description

Controller functions in OSLib.

Macro Definition Documentation

◆ oslSetKeyAutorepeat

#define oslSetKeyAutorepeat ( keys,
init,
interval )
Value:
OSL_CONTROLLER * osl_keys
Current keys. Only here for compatibility, use osl_pad now.
int autoRepeatMask
Keys affected by the auto-repeat feature.
Definition keys.h:58
short autoRepeatInterval
Interval before the auto-repeat feature activates.
Definition keys.h:57
short autoRepeatInit
Time for the initialization of the auto-repeat feature.
Definition keys.h:56

Sets the auto-repeat parameters for keys.

Parameters
keysThe keys affected by the auto-repeat feature.
initTime (in number of calls) before the auto-repeat feature turns on.
intervalTime interval between each key repeat when the auto-repeat has been turned on.

◆ oslSetKeyAutorepeatMask

#define oslSetKeyAutorepeatMask ( mask)
Value:

Sets the key auto-repeat mask.

Parameters
maskThe key auto-repeat mask.

◆ oslSetKeyAutorepeatInit

#define oslSetKeyAutorepeatInit ( value)
Value:

Sets the key auto-repeat initialization value.

Parameters
valueThe initialization value for auto-repeat.

◆ oslSetKeyAutorepeatInterval

#define oslSetKeyAutorepeatInterval ( value)
Value:

Sets the key auto-repeat interval value.

Parameters
valueThe interval value for auto-repeat.

◆ oslSetKeyAnalogToDPad

#define oslSetKeyAnalogToDPad ( sensivity)
Value:
signed char analogToDPadSensivity
Minimum sensitivity for analog to D-pad conversion. 0 disables this feature, 127 is maximum sensitivi...
Definition keys.h:61

Enables or disables automatic redirection from the analog stick to D-pad buttons.

Parameters
sensivitySensitivity for the analog press. A typical value is 80.

◆ oslSetRemoteKeyAutorepeat

#define oslSetRemoteKeyAutorepeat ( keys,
init,
interval )
Value:
OSL_REMOTECONTROLLER * osl_remotekeys
Current remote keys.
int autoRepeatMask
Keys affected by the auto-repeat feature.
Definition keys.h:245
short autoRepeatInterval
Interval before the auto-repeat feature activates.
Definition keys.h:244
short autoRepeatInit
Time for the initialization of the auto-repeat feature.
Definition keys.h:243

Sets the auto-repeat parameters for remote keys.

Parameters
keysThe keys affected by the auto-repeat feature.
initTime (in number of calls) before the auto-repeat feature turns on.
intervalTime interval between each key repeat when the auto-repeat has been turned on.

◆ oslSetRemoteKeyAutorepeatMask

#define oslSetRemoteKeyAutorepeatMask ( mask)
Value:

Sets the remote key auto-repeat mask.

Parameters
maskThe key auto-repeat mask.

◆ oslSetRemoteKeyAutorepeatInit

#define oslSetRemoteKeyAutorepeatInit ( value)
Value:

Sets the remote key auto-repeat initialization value.

Parameters
valueThe initialization value for auto-repeat.

◆ oslSetRemoteKeyAutorepeatInterval

#define oslSetRemoteKeyAutorepeatInterval ( value)
Value:

Sets the remote key auto-repeat interval value.

Parameters
valueThe interval value for auto-repeat.

Enumeration Type Documentation

◆ OSL_KEY_BITS

Bit number for each key in the 'value' field.

This enumeration defines the bit positions for each key in the value field of OSL_KEYLIST.

Enumerator
OSL_KEY_SELECT 

Select key.

OSL_KEY_START 

Start key.

OSL_KEY_UP 

Up D-pad key.

OSL_KEY_RIGHT 

Right D-pad key.

OSL_KEY_DOWN 

Down D-pad key.

OSL_KEY_LEFT 

Left D-pad key.

OSL_KEY_L 

L shoulder key.

OSL_KEY_R 

R shoulder key.

OSL_KEY_TRIANGLE 

Triangle key.

OSL_KEY_CIRCLE 

Circle key.

OSL_KEY_CROSS 

Cross key.

OSL_KEY_SQUARE 

Square key.

OSL_KEY_HOME 

Home key (may not work in normal operation).

OSL_KEY_HOLD 

Hold key (power switch in the opposite direction).

OSL_KEY_NOTE 

Note key (may not work).

◆ OSL_KEY_MASKS

Mask for each key in the 'value' field.

This enumeration defines the bitmasks for each key in the value field of OSL_KEYLIST.

Function Documentation

◆ oslReadKeys()

OSL_CONTROLLER * oslReadKeys ( )
extern

Reads the current controller state and stores the result in the osl_pad structure.

Returns
A pointer to the actual key structure.

◆ oslSetReadKeysFunction()

int oslSetReadKeysFunction ( int(* sceCtrlReadBufferPositive )(SceCtrlData *pad_data, int count))
extern

Sets an external function to read keys.

Parameters
sceCtrlReadBufferPositiveThe external function to read keys.
Returns
0 on success, non-zero on failure.

◆ oslUnsetReadKeysFunction()

int oslUnsetReadKeysFunction ( )
extern

Unsets the function set with oslSetReadKeysFunction.

Returns
0 on success, non-zero on failure.

◆ oslSetHoldForAnalog()

int oslSetHoldForAnalog ( int holdForAnalog)
extern

Decides if HOLD will affect the analog stick.

Parameters
holdForAnalog1 to enable, 0 to disable.
Returns
0 on success, non-zero on failure.

◆ oslWaitKey()

int oslWaitKey ( )
extern

Waits for a key and returns its code.

Returns
The key code.

◆ oslKbhit()

int oslKbhit ( )
extern

Determines whether a key is currently buffered and returns its code.

Returns
The key code if a key is buffered, 0 otherwise.

◆ oslReadRemoteKeys()

OSL_REMOTECONTROLLER * oslReadRemoteKeys ( )
extern

Reads the current remote controller state and stores the result in the osl_remote structure.

Returns
A pointer to the actual key structure.

◆ oslIsRemoteExist()

int oslIsRemoteExist ( )

Determines whether the remote is plugged in.

Returns
1 if the remote is plugged in, 0 otherwise.

Variable Documentation

◆ osl_pad

OSL_CONTROLLER osl_pad
extern

Current keys.

This structure holds the current state of the controller.

◆ osl_remotekeys

OSL_REMOTECONTROLLER* osl_remotekeys
extern

Current remote keys.

This structure holds the current state of the remote controller.

◆ osl_remote

OSL_REMOTECONTROLLER osl_remote
extern

Current remote keys.

This structure holds the current state of the remote controller.