 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
JustChris
Joined: 03 Nov 2005 Posts: 21
|
Posted: Fri Nov 25, 2005 8:20 am Post subject: Receiving input in pspgl |
|
|
I have played around with the pspgl sprite demo long enough to finally be able to port my game logic from a shooter I made in SDL (on PC) over to the PSP. I'm stuck on how pspgl receives all the key inputs, though.
Using glutJoystickFunc is straightforward, but the sprite demo only shows the letters assigned to the Square, Triangle, Cross and Circle buttons. I really want to get input with the directional buttons rather than the analog nub. So which letters on the keyboard correspond the D-pad directions, as well as Select and Start? I could not find the assignment to these particular buttons in GL/glut.h. |
|
| Back to top |
|
 |
Shatterdome
Joined: 22 Nov 2005 Posts: 11
|
Posted: Fri Nov 25, 2005 9:37 am Post subject: |
|
|
Wel i'll give you the answer because I wish someone would have told me when I was trying to figure it out :P
| Code: |
#include <pspctrl.h>
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_SQUARE)
sceKernelExitGame();
if (pad.Buttons & PSP_CTRL_LEFT)
xmod = -1;
if (pad.Buttons & PSP_CTRL_DOWN)
ymod = 1;
if (pad.Buttons & PSP_CTRL_RIGHT)
xmod = 1;
if (pad.Buttons & PSP_CTRL_UP)
ymod = -1
|
It's not using glut.h, but I don't see why you couldn't use it, it's pretty straight forward....just replace UP or RIGHT etc with TRIANGLE or SELECT or START...I THINK triggers are LTRIGGER RTRIGGER...
Prolly a better way to do it, but this works for me :P |
|
| Back to top |
|
 |
JustChris
Joined: 03 Nov 2005 Posts: 21
|
Posted: Fri Nov 25, 2005 2:32 pm Post subject: |
|
|
| I already know how to do this with pspctrl.h, but here I'm just looking for the glut way. Meanwhile, I'll just try to combine that functionality with glut and see what happens, if using two different input methods conflict at all. |
|
| Back to top |
|
 |
JustChris
Joined: 03 Nov 2005 Posts: 21
|
Posted: Mon Jan 09, 2006 2:01 pm Post subject: |
|
|
Let me see it anyone can answer this question. In the pspgl sprite demo (the one with the sky background and 4 rows of icons that you can shake and rotate) there is a list of keys assigned to 4 buttons on the PSP.
Near the beginning of the file I find the four actions defined here
| Code: | #define RUMBLE (1<<0)
#define ROCKING (1<<1)
#define ZOOM (1<<2)
#define PAUSE (1<<3)
|
And further down is the keydown function which gets initialized in the main loop. The comments were already in the file when I opened it.
| Code: |
static void keydown (unsigned char key, int x, int y)
{
press = 0;
switch (key) {
case 'd': /* delta, triangle */
press |= ROCKING;
break;
case 'o': /* round */
press |= PAUSE;
break;
case 'q': /* square*/
press |= RUMBLE;
break;
case 'x': /* cross button */
press |= ZOOM;
break;
default:
;
}
} |
How were the letters chosen assigned to the buttons on the PSP and how can I, for example, figure out the letters that correspond to the other buttons? The demo only used these buttons plus the analog nub. Plus, do the numbers defined in the four actions have any significance?[/code] |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Tue Jan 10, 2006 10:47 am Post subject: |
|
|
Note that glut is a standard API, and not psp-specific, so you can look for documentation elsewhere. But like the rest of PSPGL, it isn't complete compared to real glut, but it's worth trying anyway.
The letters are somewhat arbitrary but are intended to be mnemonic: 'o' looks like a circle, 'd' for a triangle-shaped delta, 'q' for sQuare, 's' for select, 'a' for stArt, 'x' for cross, etc.
The arrow keys come through the Special callback, so you need something like: | Code: |
void specialkey(int key, int x, int y)
{
switch(key) {
case GLUT_KEY_UP: ...
case GLUT_KEY_DOWN:....
}
}
//...
glutSpecialFunc(specialkey);
glutSpecialUpFunc(specialkeyup); |
Look at glut.c in PSPGL to see how this is implemented. |
|
| Back to top |
|
 |
JustChris
Joined: 03 Nov 2005 Posts: 21
|
Posted: Tue Jan 10, 2006 1:49 pm Post subject: |
|
|
| I know that Glut is not PSP-specific, but I was just thinking that the code for the controls was initialized somewhere else. But now it makes sense to me, now that I know where to look and saw how it was done. And I can see it all boils down to using pspctrl.h and sceCtrlReadBufferPositive in the glutMainLoop function. Pretty clever. |
|
| 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
|