How to regist a callback of control pad button event

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
zealot0630
Posts: 1
Joined: Sun Nov 12, 2006 9:13 pm

How to regist a callback of control pad button event

Post by zealot0630 »

It seem that call sceCtrlReadBufferPositive is insufficient and waste a lot of battery.
It is better to regist a callback function like sceKernelRegisterExitCallback, and once pad button is pressed, kernel calls the function which registed before
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Re: How to regist a callback of control pad button event

Post by hlide »

zealot0630 wrote:It seem that call sceCtrlReadBufferPositive is insufficient and waste a lot of battery.
It is better to regist a callback function like sceKernelRegisterExitCallback, and once pad button is pressed, kernel calls the function which registed before
oh i see your point you would like to catch a new buttons state when there IS a change. I presume this would only happen at each vsync since pad is read at this pace and so a callback would be called only at a VSYNC pace but only if there is a real change.

I dunno if we can register and use those callbacks in user mode but there is something which sounds promising in pspsdk\ctrl\pspctrl_kernel.h :

Code: Select all

#define sceCtrlSetButtonMasks sceCtrl_driver_7CA723DC
#define sceCtrlGetButtonMask sceCtrl_driver_5E77BC8A
#define sceCtrlRegisterButtonCallback sceCtrl_driver_5C56C779
Interesting, without your post, i would have never seen thoses functions.

thx for your post.
Last edited by hlide on Tue Nov 14, 2006 11:56 pm, edited 1 time in total.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

However i'm still unsure whether that callback system can handle analogic pad.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

a question for MrBrown or Tyranid :

Code: Select all

/**
 * Get button mask mode
 *
 * @mask - The bitmask to check
 *
 * @return 0 no setting, 1 set in button mask, 2 set in button set
 */
when you pass the "bitmask" as argument, does it mean a bitmask compatible with the enumerated values of PspCtrlButtons with the only difference that only one bit in bitmask should be set ? this isn't the bit number, is this ?

Are there any other sceCtrl_driver_XXXXX functions not dicovered ? so far as I can guess, we cannot handle analogic pad with this callback system.
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

1) mask is of form "BUTTON1 | BUTTON2 | BUTTON3 ...." with standard key names like in the .Buttons
2)everything has more or less been discovered, afaik.
Post Reply