Data Structures | |
union | OSL_KEYLIST |
struct | OSL_CONTROLLER |
union | OSL_REMOTEKEYLIST |
struct | OSL_REMOTECONTROLLER |
Defines | |
#define | oslSetKeyAutorepeat(keys, init, interval) ( osl_keys->autoRepeatMask = keys, osl_keys->autoRepeatInit = init, osl_keys->autoRepeatInterval = interval ) |
#define | oslSetKeyAutorepeatMask(mask) (osl_keys->autoRepeatMask=mask) |
#define | oslSetKeyAutorepeatInit(value) (osl_keys->autoRepeatInit=value) |
#define | oslSetKeyAutorepeatInterval(value) (osl_keys->autoRepeatInterval=value) |
#define | oslSetKeyAnalogToDPad(sensivity) (osl_keys->analogToDPadSensivity = sensivity) |
#define | oslSetRemoteKeyAutorepeat(keys, init, interval) ( osl_remotekeys->autoRepeatMask = keys, osl_remotekeys->autoRepeatInit = init, osl_remotekeys->autoRepeatInterval = interval ) |
#define | oslSetRemoteKeyAutorepeatMask(mask) (osl_remotekeys->autoRepeatMask=mask) |
#define | oslSetRemoteKeyAutorepeatInit(value) (osl_remotekeys->autoRepeatInit=value) |
#define | oslSetRemoteKeyAutorepeatInterval(value) (osl_remotekeys->autoRepeatInterval=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 } |
enum | OSL_KEY_MASKS |
Functions | |
OSL_CONTROLLER * | oslReadKeys () |
int | oslSetReadKeysFunction (int(*sceCtrlReadBufferPositive)(SceCtrlData *pad_data, int count)) |
int | oslUnsetReadKeysFunction () |
int | oslSetHoldForAnalog (int holdForAnalog) |
int | oslWaitKey () |
int | oslKbhit () |
void | oslFlushKey () |
OSL_REMOTECONTROLLER * | oslReadRemoteKeys () |
void | oslFlushRemoteKey () |
int | oslIsRemoteExist () |
Variables | |
OSL_CONTROLLER * | osl_keys |
OSL_CONTROLLER | osl_pad |
OSL_REMOTECONTROLLER | osl_remote |
#define oslSetKeyAutorepeat | ( | keys, | |||
init, | |||||
interval | ) | ( osl_keys->autoRepeatMask = keys, osl_keys->autoRepeatInit = init, osl_keys->autoRepeatInterval = interval ) |
Sets the auto-repeat parameters (all at once).
keys | Sets the keys affected by the autorepeat feature. If these keys are held for long enough, they will be reported more times in the pressed member in the osl_pad structure. It's the ideal thing to handle a menu, just check for the 'pressed' member and move the cursor when it's set. The auto-repeat feature will automatically work. Typical keys the user would expect to be auto-repeated are: OSL_KEYMASK_UP|OSL_KEYMASK_RIGHT|OSL_KEYMASK_DOWN|OSL_KEYMASK_LEFT|OSL_KEYMASK_R|OSL_KEYMASK_L. As you see, just OR the masks of the keys you want to be auto-repeated. | |
init | Time (in number of calls, so at 60 fps, 60 = 1 second) before the auto-repeat feature turns on. Usually you must wait a while (1/2 second or more) before the auto-repeat is turned on, but once it's on, the key will be repeated more than each 1/2 second. A typical value here is 40 (2/3 second). | |
interval | Time interval between each key repeat when the auto-repeat has been turned on. A typical value is 10 (1/6 of a second); with the example above, you would press the key, then 2/3 second later it begins to auto-repeat the key each 1/6 second. |
#define oslSetKeyAutorepeatMask | ( | mask | ) | (osl_keys->autoRepeatMask=mask) |
Separate routine setting the key auto-repeat mask.
#define oslSetKeyAutorepeatInit | ( | value | ) | (osl_keys->autoRepeatInit=value) |
Separate routine setting the key auto-repeat initialization value.
#define oslSetKeyAutorepeatInterval | ( | value | ) | (osl_keys->autoRepeatInterval=value) |
Separate routine setting the key auto-repeat interval value.
#define oslSetKeyAnalogToDPad | ( | sensivity | ) | (osl_keys->analogToDPadSensivity = sensivity) |
Enables or disable automatic redirection from the analog stick to D-Pad buttons (down, left, etc.).
sensivity | Sensivity for the analog press. Analog values go from -128 to 127, so the maximum sensivity value you can set is 127, meaning the stick needs to be at least at -127 or +127 in each direction to be treated as a directional key. |
Note: Diagonal keys are supported as well with the stick, and this is really a good idea to at least enable this if you don't want to threat the stick separately. Some people (including me) have a weak D-Pad and it's extremely hard to play any game or app that needs the up/down keys, or even worse: diagonals.
//Enable default analog handler oslSetKeyAnalogToDPad(80); //Read keys oslReadKeys(); //The stick is upwards OR the D-pad's up direction is held if (osl_pad.held.up) {} //If you want to differenciate stick and D-pad, you can also do something like this: //Make sure default analog handler is disabled! oslSetKeyAnalogToDPad(0); oslReadKeys(); //D-Pad if (osl_pad.held.up) {} //Stick if (osl_pad.analogY < -80) {}
#define oslSetRemoteKeyAutorepeat | ( | keys, | |||
init, | |||||
interval | ) | ( osl_remotekeys->autoRepeatMask = keys, osl_remotekeys->autoRepeatInit = init, osl_remotekeys->autoRepeatInterval = interval ) |
Sets the auto-repeat parameters (all at once).
keys | Sets the keys affected by the autorepeat feature. If these keys are held for long enough, they will be reported more times in the pressed member in the osl_pad structure. It's the ideal thing to handle a menu, just check for the 'pressed' member and move the cursor when it's set. The auto-repeat feature will automatically work. Typical keys the user would expect to be auto-repeated are: OSL_KEYMASK_UP|OSL_KEYMASK_RIGHT|OSL_KEYMASK_DOWN|OSL_KEYMASK_LEFT|OSL_KEYMASK_R|OSL_KEYMASK_L. As you see, just OR the masks of the keys you want to be auto-repeated. | |
init | Time (in number of calls, so at 60 fps, 60 = 1 second) before the auto-repeat feature turns on. Usually you must wait a while (1/2 second or more) before the auto-repeat is turned on, but once it's on, the key will be repeated more than each 1/2 second. A typical value here is 40 (2/3 second). | |
interval | Time interval between each key repeat when the auto-repeat has been turned on. A typical value is 10 (1/6 of a second); with the example above, you would press the key, then 2/3 second later it begins to auto-repeat the key each 1/6 second. |
#define oslSetRemoteKeyAutorepeatMask | ( | mask | ) | (osl_remotekeys->autoRepeatMask=mask) |
Separate routine setting the key auto-repeat mask.
#define oslSetRemoteKeyAutorepeatInit | ( | value | ) | (osl_remotekeys->autoRepeatInit=value) |
Separate routine setting the key auto-repeat initialization value.
#define oslSetRemoteKeyAutorepeatInterval | ( | value | ) | (osl_remotekeys->autoRepeatInterval=value) |
Separate routine setting the key auto-repeat interval value.
enum OSL_KEY_BITS |
Bit number for each key in the 'value' field. One of these values is returned by oslKbhit or oslWaitKey.
keyPressed = oslWaitKey(); if (keyPressed == OSL_KEY_START) ...
enum OSL_KEY_MASKS |
Mask for each key in the 'value' field. To extract for example the select key, you can do the following:
oslReadKeys(); if (osl_pad.held.value & OSL_KEYMASK_SELECT) ... //This is equivalent to: if (osl_pad.held.select) ...
The keymasks description is exactly the same as keybits, they are just named OSL_KEYMASK_xxx instead of OSL_KEY_xxx.
OSL_CONTROLLER* oslReadKeys | ( | ) |
Reads the current controller state and stores the result in the osl_pad structure. Returns a pointer to the actual key structure. It may seem cleaner to store this pointer and access data from it, but you can do however you want.
int oslSetReadKeysFunction | ( | int(*)(SceCtrlData *pad_data, int count) | sceCtrlReadBufferPositive | ) |
Sets an external function to read keys. You can pass to it a function from a kernel prx, so you'll be able to read all buttons (VOLUME_UP, VOLUME_DOWN, NOTE...)
int oslUnsetReadKeysFunction | ( | ) |
Unsets the function set with oslSetReadKeysFunction
int oslSetHoldForAnalog | ( | int | holdForAnalog | ) |
Decide if HOLD will affect also the analog (default=NO).
int oslWaitKey | ( | ) |
Waits for a key and returns its code. Compare the code against one of the OSL_KEYBITS values.
int oslKbhit | ( | ) |
Determines whether a key is currently buffered and returns its code, or 0 else. Compare the code against one of the OSL_KEYBITS values.
void oslFlushKey | ( | ) |
Flushes the key buffer, removing the pending key (retrievable with oslKbhit).
OSL_REMOTECONTROLLER* oslReadRemoteKeys | ( | ) |
Reads the current remote controller state and stores the result in the osl_remote structure. Returns a pointer to the actual key structure. It may seem cleaner to store this pointer and access data from it, but you can do however you want.
void oslFlushRemoteKey | ( | ) |
Flushes the remote key buffer, removing the pending key.
int oslIsRemoteExist | ( | ) |
Determines whether the remote is plugged in.
Current keys. Only here for compatibility, use osl_pad now.
Current keys. In this structure you will find three members: pressed, released and held.
Each of these members is an union, containing a structure of type OSL_KEYLIST (contains a member for each key):
oslReadKeys(); if (osl_pad.pressed.start) oslDebug("A pause should be thrown!"); if (osl_pad.held.up) oslDebug("Moving the main character upwards!");
Look at OSL_CONTROLLER for more information.
Current remote keys. In this structure you will find three members: pressed, released and held.
Each of these members is an union, containing a structure of type OSL_REMOTEKEYLIST (contains a member for each key):
oslReadRemoteKeys(); if (osl_remote.pressed.rmplaypause) oslDebug("A pause should be thrown!"); if (osl_remote.held.rmforward) oslDebug("Do something!");
Look at OSL_REMOTECONTROLLER for more information.