set_joy_callback

From ArchaicPixels: HuC and PCEAS Documentation

Jump to: navigation, search

from original documentation

set_joy_callback(char num, char mask, char keys, void (*proc)());

     You can program the library to call one of your function
     when a certain joypad key as been pressed.
     The best use of this function is to handle game pause
     mode when the player press the START button.
     'num' is the numero of the callback to install,
     for now there's only one callback (0), but future
     versions of the library may have more.
     'mask' indicates which joypad to scan (one bit
     for each joypad, with bit 0 for joypad 0, etc...),
     and 'keys' indicates which keypresses to look,
     usualy just JOY_STRT. 'proc' is the address
     of the function you want to be called by the library. 

set_joy_callback

Prototypes:

set_joy_callback(char num, char mask, char keys, void (*proc)());

Arguments:

num: The number of the callback to install
mask: The joypad(s) to scan
keys: The keys to look for (defined in huc.h)
proc: The procedure to call

Returns:

None

Description:

You can program the library to call one of your functions when a certain joypad key has been pressed. A good example of this function is to handle game pause mode when the player presses the START button.

For now, "num" can only be 0, as only one callback is supported. This may change in the future. "mask" indicates the joypad mask to use. Each joypad gets one bit, so the first joypad would be 0x01, the second would be 0x02, both would be 0x03, etc. "keys" indicates which keypresses to look for. Finally, "proc" is the address of the function you want to have executed by the callback.

For the callback to work correctly, the function you wish to use must precede set_joy_callback.

Complete Example:

#include "huc.h"

my_function()
{
  put_string("JOY_STRT pressed.", 0, 0);
  while(1) { vsync(); }
}

main()
{
  set_joy_callback (0, 0x01, JOY_STRT, my_function);
  while(1) { vsync(); }
}
Personal tools