int (* handler)(int sel) Help Me

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

Moderators: cheriff, TyRaNiD

Post Reply
Zer01ne
Posts: 28
Joined: Mon Sep 08, 2008 7:15 am

int (* handler)(int sel) Help Me

Post by Zer01ne »

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: Select all

vlfGuiAddEventHandler(PSP_CTRL_CROSS, -1, i want use handler here, NULL);
Thanks
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

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...
Zer01ne
Posts: 28
Joined: Mon Sep 08, 2008 7:15 am

Post by Zer01ne »

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)
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

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?
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

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
Zer01ne
Posts: 28
Joined: Mon Sep 08, 2008 7:15 am

Post by Zer01ne »

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: Select all

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

Code: Select all

vlfGuiAddMenuEx(int noptions, char **items, int defaultsel, int (* handler)(int sel), int x, int y);
how to use the param

Code: Select all

int (* handler)(int sel)
in function

Code: Select all

vlfGuiAddEventHandler(int buttons, int wait, int (* func)(void *), void *param);
for use one function with the PSP_CTRL_CROSS the param

Code: Select all

int (* handler)(int sel)
receive the user function with the selection for choice Menu you know ?
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

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 !
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

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
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

Another good resource for function pointers / functors / callbacks I use is: http://www.newty.de/fpt/callback.html
Post Reply