forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

int (* handler)(int sel) Help Me

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Zer01ne



Joined: 08 Sep 2008
Posts: 29

PostPosted: Sun Oct 12, 2008 12:58 am    Post subject: int (* handler)(int sel) Help Me Reply with quote

Sorry for my bad English
OK
I code a function for use a menu with xy vlfGuiAddMenuEx for perfect text alignement
where is handler ? How to use it in vlfGuiAddEventHandler? please help me
If i finish this function im release this source code on this forum
Code:
vlfGuiAddEventHandler(PSP_CTRL_CROSS, -1, i want use handler here, NULL);

Thanks
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sun Oct 12, 2008 1:09 am    Post subject: Reply with quote

Read the dc6-7 src, I remember that this function is used to perform the operation of a menu...
I'm not sure, read the src posted by moonlight in the "d6 graphics" thread...
_________________
Get Xplora!
Back to top
View user's profile Send private message
Zer01ne



Joined: 08 Sep 2008
Posts: 29

PostPosted: Sun Oct 12, 2008 3:17 am    Post subject: Reply with quote

I think but i construct a new function for use a Menu with perfect alignement the function vlfGuiCentralMenu use the VLF_ALIGNEMENT_CENTER for text alignement i code a new function for use a x and y for personalize a Menu and use the param of vlfGuiCentralMenu but a dont know use param int (*handler)(int sel)
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sun Oct 12, 2008 4:36 am    Post subject: Reply with quote

mmm...
I haven't understand very well what you want to do...
I've see that in the dc src this function is used to reset something parameters...
I've understand that you want to know how to build a function and use it with vlfGuiAddEventHandler, right?
_________________
Get Xplora!
Back to top
View user's profile Send private message
phobox



Joined: 24 Mar 2008
Posts: 140

PostPosted: Sun Oct 12, 2008 4:41 am    Post subject: Reply with quote

how to use
int vlfGuiAddEventHandler(int buttons, int wait, int (* func)(void *), void *param);

-first arg: pass one of PSP_CTRL_* (or the extra ones defined in vlf.h)
-second arg: time to wait, -1 no delay.
-3rd arg the function that will be called when there is the event (a button has been pressed)
the prototipe of this function hase to be
int myHandlerFunc(void* something)

-the 4th arg is the param that should be passed to the handler func. if you don't need params set it to NULL.

hope it helped
Back to top
View user's profile Send private message
Zer01ne



Joined: 08 Sep 2008
Posts: 29

PostPosted: Sun Oct 12, 2008 9:45 am    Post subject: Reply with quote

nonono i know use the vlfGuiAddEventHandler but i dont know for use the param int (* handler)(int sel) in my function vlfGuiAddMenuEx Dark_Alex use this param on function vlfAddEventHandler for the vlfGuiCentralMenu

Dark_Alex function
Code:
vlfGuiCentralMenu(int noptions, char **items, int defaultsel, int (* handler)(int sel), int dispx, int dispy);

My function
Code:
vlfGuiAddMenuEx(int noptions, char **items, int defaultsel, int (* handler)(int sel), int x, int y);

how to use the param
Code:
int (* handler)(int sel)

in function
Code:
vlfGuiAddEventHandler(int buttons, int wait, int (* func)(void *), void *param);
for use one function with the PSP_CTRL_CROSS the param
Code:
int (* handler)(int sel)
receive the user function with the selection for choice Menu you know ?
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Sun Oct 12, 2008 11:04 am    Post subject: Reply with quote

read this wikipedia article : here

when you have understood it, you will see that phobox has answered to your question.
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Oct 12, 2008 11:45 am    Post subject: Reply with quote

int (* handler)(int sel)

is a pointer to a function taking an int as a parameter and returning an int.
So if you defined a function

int do_something_with_sel(int sel)
{
return something;
}

You could pass 'do_something_with_sel' to that parameter.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Onii



Joined: 05 Oct 2008
Posts: 40

PostPosted: Sun Oct 12, 2008 1:20 pm    Post subject: Reply with quote

Another good resource for function pointers / functors / callbacks I use is: http://www.newty.de/fpt/callback.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group