Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 52 additions & 23 deletions src/ctrl/pspctrl_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,81 @@
#ifndef __CTRL_KERNEL_H__
#define __CTRL_KERNEL_H__

#include <psptypes.h>

/** The callback function used by ::sceCtrlSetSpecialButtonCallback(). */
typedef void (*SceKernelButtonCallbackFunction)(u32 cur_buttons, u32 last_buttons, void *opt);

/** Button mask settings. */
typedef enum SceCtrlButtonMaskMode {
/** No mask for the specified buttons. Button input is normally recognized. */
SCE_CTRL_MASK_NO_MASK = 0,
/**
* The specified buttons are ignored, that means even if these buttons are pressed by the user
* they won't be shown as pressed internally.
*
* You can only block user buttons for applications running in User Mode.
*/
SCE_CTRL_MASK_IGNORE_BUTTONS = 1,
/**
* The specified buttons show up as being pressed, even if the user does not press them.
*
* You can only turn ON user buttons for applications running in User Mode.
*/
SCE_CTRL_MASK_APPLY_BUTTONS = 2,
} SceCtrlButtonMaskMode;

#ifdef __cplusplus
extern "C" {
#endif

/**
* Set the controller button masks
* Sets a button mask mode for one or more buttons.
*
* You can only mask user mode buttons in user applications. Masking of kernel
* mode buttons is ignored as well as buttons used in kernel mode applications.
*
* @param buttons The button value for which the button mask mode will be applied for. One or more buttons of `SceCtrlButtons`.
* @param mask_mode Specifies the type of the button mask. One of `SceCtrlButtonMaskMode`.
*
* @param mask - The bits to setup
* @param type - The type of operation (0 clear, 1 set mask, 2 set button)
* @return The previous button mask type for the given buttons. One of `SceCtrlButtonMaskMode`.
*
* @par Example:
* @example Example:
* @code
* sceCtrl_driver_7CA723DC(0xFFFF, 1); // Mask lower 16bits
* sceCtrl_driver_7CA723DC(0x10000, 2); // Always return HOME key
* sceCtrlSetButtonIntercept(0xFFFF, 1); // Mask lower 16bits
* sceCtrlSetButtonIntercept(0x10000, 2); // Always return HOME key
* // Do something
* sceCtrl_driver_7CA723DC(0x10000, 0); // Unset HOME key
* sceCtrl_driver_7CA723DC(0xFFFF, 0); // Unset mask
* sceCtrlSetButtonIntercept(0x10000, 0); // Unset HOME key
* sceCtrlSetButtonIntercept(0xFFFF, 0); // Unset mask
* @endcode
*/
void sceCtrl_driver_7CA723DC(unsigned int mask, unsigned type);
u32 sceCtrlSetButtonIntercept(u32 buttons, u32 mask_mode);

/**
* Get button mask mode
* Get button mask mode.
*
* @param mask - The bitmask to check
* @param buttons The buttons to check for. One or more buttons of `SceCtrlButtons`.
*
* @return 0 no setting, 1 set in button mask, 2 set in button set
* @return The button mask mode for the given buttons. One of `SceCtrlButtonMaskMode`.
*/
int sceCtrl_driver_5E77BC8A(unsigned int mask);
u32 sceCtrlGetButtonIntercept(u32 buttons);

/**
* Setup a controller callback
* Registers a button callback.
*
* @param no - The number of the callback (0-3)
* @param mask - The bits to check for
* @param cb - The callback function (int curr_but, int last_but, void *arg)
* @param arg - User defined argument passed
* @param slot The slot used to register the callback. Between 0 - 3.
* @param button_mask Bitwise OR'ed button values which will be checked for being pressed. One or more buttons of `SceCtrlButtons`.
* @param callback A pointer to the callback function handling the button callbacks.
* @param opt Optional user argument. Passed to the callback function as its third argument.
*
* @return 0 on success, < 0 on error
* @return 0 on success, < 0 on error.
*/
int sceCtrl_driver_5C56C779(int no, unsigned int mask, void (*cb)(int, int, void*), void *arg);
int sceCtrlSetSpecialButtonCallback(u32 slot, u32 button_mask, SceKernelButtonCallbackFunction callback, void *opt);

/* Just define some random names for the functions to make them easier to use */
#define sceCtrlSetButtonMasks sceCtrl_driver_7CA723DC
#define sceCtrlGetButtonMask sceCtrl_driver_5E77BC8A
#define sceCtrlRegisterButtonCallback sceCtrl_driver_5C56C779
#define sceCtrlSetButtonMasks sceCtrlSetButtonIntercept
#define sceCtrlGetButtonMask sceCtrlGetButtonIntercept
#define sceCtrlRegisterButtonCallback sceCtrlSetSpecialButtonCallback


#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/sceCtrl.S
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
IMPORT_FUNC "sceCtrl",0x0B588501,sceCtrlReadLatch
#endif
#ifdef F_sceCtrl_0011
IMPORT_FUNC "sceCtrl",0x348D99D4,sceCtrl_348D99D4
IMPORT_FUNC "sceCtrl",0x348D99D4,sceCtrlSetSuspendingExtraSamples
#endif
#ifdef F_sceCtrl_0012
IMPORT_FUNC "sceCtrl",0xAF5960F3,sceCtrl_AF5960F3
IMPORT_FUNC "sceCtrl",0xAF5960F3,sceCtrlGetSuspendingExtraSamples
#endif
#ifdef F_sceCtrl_0013
IMPORT_FUNC "sceCtrl",0xA68FD260,sceCtrlClearRapidFire
Expand Down
12 changes: 6 additions & 6 deletions src/ctrl/sceCtrl_driver.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "pspimport.s"

// Build List
// sceCtrl_driver_0000.o sceCtrl_driver_0001.o sceCtrl_driver_0002.o sceCtrl_driver_0003.o sceCtrl_driver_0004.o sceCtrl_driver_0005.o sceCtrl_driver_0006.o sceCtrl_driver_0007.o sceCtrl_driver_0008.o sceCtrl_driver_0009.o sceCtrl_driver_0010.o sceCtrl_driver_0011.o sceCtrl_driver_0012.o sceCtrl_driver_0013.o sceCtrl_driver_0014.o sceCtrl_driver_0015.o sceCtrl_driver_0016.o sceCtrl_driver_0017.o sceCtrl_driver_0018.o sceCtrl_driver_0019.o sceCtrl_driver_0020.o sceCtrl_driver_0021.o sceCtrl_driver_0022.o sceCtrl_driver_0023.o
// sceCtrl_driver_0000.o sceCtrl_driver_0001.o sceCtrl_driver_0002.o sceCtrl_driver_0003.o sceCtrl_driver_0004.o sceCtrl_driver_0005.o sceCtrl_driver_0006.o sceCtrl_driver_0007.o sceCtrl_driver_0008.o sceCtrl_driver_0009.o sceCtrl_driver_0010.o sceCtrl_driver_0011.o sceCtrl_driver_0012.o sceCtrl_driver_0013.o sceCtrl_driver_0014.o sceCtrl_driver_0015.o sceCtrl_driver_0016.o sceCtrl_driver_0017.o sceCtrl_driver_0018.o sceCtrl_driver_0019.o sceCtrl_driver_0020.o sceCtrl_driver_0021.o sceCtrl_driver_0022.o sceCtrl_driver_0023.o

#ifdef F_sceCtrl_driver_0000
IMPORT_START "sceCtrl_driver",0x00010000
Expand Down Expand Up @@ -57,10 +57,10 @@
IMPORT_FUNC "sceCtrl_driver",0xB7CEAED4,sceCtrlGetIdleCancelKey
#endif
#ifdef F_sceCtrl_driver_0017
IMPORT_FUNC "sceCtrl_driver",0x348D99D4,sceCtrl_driver_348D99D4
IMPORT_FUNC "sceCtrl_driver",0x348D99D4,sceCtrlSetSuspendingExtraSamples
#endif
#ifdef F_sceCtrl_driver_0018
IMPORT_FUNC "sceCtrl_driver",0xAF5960F3,sceCtrl_driver_AF5960F3
IMPORT_FUNC "sceCtrl_driver",0xAF5960F3,sceCtrlGetSuspendingExtraSamples
#endif
#ifdef F_sceCtrl_driver_0019
IMPORT_FUNC "sceCtrl_driver",0xA68FD260,sceCtrlClearRapidFire
Expand All @@ -69,13 +69,13 @@
IMPORT_FUNC "sceCtrl_driver",0x6841BE1A,sceCtrlSetRapidFire
#endif
#ifdef F_sceCtrl_driver_0021
IMPORT_FUNC "sceCtrl_driver",0x7CA723DC,sceCtrl_driver_7CA723DC
IMPORT_FUNC "sceCtrl_driver",0x7CA723DC,sceCtrlSetButtonIntercept
#endif
#ifdef F_sceCtrl_driver_0022
IMPORT_FUNC "sceCtrl_driver",0x5E77BC8A,sceCtrl_driver_5E77BC8A
IMPORT_FUNC "sceCtrl_driver",0x5E77BC8A,sceCtrlGetButtonIntercept
#endif
#ifdef F_sceCtrl_driver_0023
IMPORT_FUNC "sceCtrl_driver",0x5C56C779,sceCtrl_driver_5C56C779
IMPORT_FUNC "sceCtrl_driver",0x5C56C779,sceCtrlSetSpecialButtonCallback
#endif
#ifdef F_sceCtrl_driver_0024
IMPORT_FUNC "sceCtrl_driver",0xA7144800,sceCtrlSetIdleCancelThreshold
Expand Down