 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Vale
Joined: 22 Jul 2005 Posts: 4
|
Posted: Fri Jul 29, 2005 10:41 am Post subject: Multipul button input? |
|
|
ok im using the PSPSDK header pspctrl.h:
| Code: |
#ifndef __CTRL_H__
#define __CTRL_H__
#ifdef __cplusplus
extern "C" {
#endif
enum CtrlButtons
{
CTRL_SQUARE = 0x8000,
CTRL_TRIANGLE = 0x1000,
CTRL_CIRCLE = 0x2000,
CTRL_CROSS = 0x4000,
CTRL_UP = 0x0010,
CTRL_DOWN = 0x0040,
CTRL_LEFT = 0x0080,
CTRL_RIGHT = 0x0020,
CTRL_START = 0x0008,
CTRL_SELECT = 0x0001,
CTRL_LTRIGGER = 0x0100,
CTRL_RTRIGGER = 0x0200,
};
/** Returned controller data */
typedef struct _ctrl_data
{
/** The current read frame */
u32 frame;
/** Bit mask containing zero or more of CtrlButtons */
u32 buttons;
/** Analogue stick, X direction */
u8 analog_x;
/** Analogue stick, Y direction */
u8 analog_y;
/** Dummy padding value */
u16 dummy;
/** Seemingly unused */
u32 unused;
} __attribute__((packed)) ctrl_data_t;
/**
* Set controller sample rate
*
* @par Example:
* @see sceCtrlReadBufferPositive
*
* @param arg Should be set to 0
*/
void sceCtrlSetSamplingCycle(int arg);
/**
* Set the sampling mode
*
* @par Example:
* @see sceCtrlReadBufferPositive
*
* @param on - Pass 1 to enable analogue mode
*/
void sceCtrlSetSamplingMode(int on);
/**
* Read buffer positive
*
* @par Example:
* @code
* ctrl_data_t pad;
* sceCtrlSetSamplingCycle(0);
* sceCtrlSetSamplingMode(1);
* sceCtrlReadBufferPositive(&pad, 1);
* // Do something with the read controller data
* @endcode
*
* @param pad_data - Structure to hold the returned pad data
* @param option - Unknown function. Always set to 1
*/
void sceCtrlReadBufferPositive(ctrl_data_t *pad_data, int option);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif
|
I was wondering if anyone knew a good way to get two button input using it. Im working on a simple program and when the player pushes a direction and square then he'll run, i've got the running and etc programed but I can't seem to get it to do multipul button inputs. Can anyone help me? Thanks in advanced - Vale |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Fri Jul 29, 2005 10:55 am Post subject: |
|
|
| Code: | if (buttons & CTRL_SQUARE){
my_square_func();
}
if (buttons & CTRL_UP){
my_up_func();
}
if (buttons & (CTRL_LTRIGGER | CTRL_RTRIGGER)){
my_R1_and_L1_func();
} | With something like that you should be able to detect multiple keypresses and do various stuff. _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Vale
Joined: 22 Jul 2005 Posts: 4
|
Posted: Fri Jul 29, 2005 11:02 am Post subject: |
|
|
| Perfect! Thank You! |
|
| Back to top |
|
 |
|
|
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
|