![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on How to repeat a key using pspgl ? within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hello, I'm testing pspgl and I try to read PSP pad with GLUT functions, but I can't repeat a key ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
Hello,
I'm testing pspgl and I try to read PSP pad with GLUT functions, but I can't repeat a key when it's pressed. For example with the code below, when I push X button it's add 0.2 to z value but to add again 0.2 to z it's not automatic, I need to release X and push it again, and so on so... it's very painful ![]() Code:
void keyPressed(unsigned char key, int x, int y)
{
switch (key) {
case 'x': /* cross */
z += 0.2f;
break;
}
}
int main(int argc, char **argv)
{
....
glutKeyboardFunc(&keyPressed);
....
}
|
|
|
|
|
|
|
#2 |
|
I found the reason why key repeating don't function. It's coming from pspgl itself. So I modified "glut.c" in pspgl code and it works as I want.
If it could help someone I post my modifications. Code:
void glutMainLoop (void)
{
if (glut_reshape_func)
glut_reshape_func(width, height);
sceCtrlSetSamplingCycle (0);
sceCtrlSetSamplingMode (PSP_CTRL_MODE_ANALOG);
do {
if (glut_joystick_func) {
struct SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
glut_joystick_func (pad.Buttons,
(pad.Lx * 2000L) / 256 - 1000,
(pad.Ly * 2000L) / 256 - 1000, 0);
}
//@@@ old part of keypad reading
/* while (1) {
struct SceCtrlLatch latch;
int i;
sceCtrlReadLatch(&latch);
if (latch.uiMake == 0 && latch.uiBreak == 0)
break;
for (i=0; i<sizeof(keycode)/sizeof(keycode[0]); i++) {
if (latch.uiMake & (1 << i))
key(keycode[i], 1);
if (latch.uiBreak & (1 << i))
key(keycode[i], 0);
}
};
*/
// @@@ new part from Edorul : permit to repeat special key
// @@@ and mouse key but not normal keys
SceCtrlData pad;
static unsigned int oldbuttons = 0;
int i;
sceCtrlReadBufferPositive(&pad, 1);
for (i=0; i<sizeof(keycode)/sizeof(keycode[0]); i++) {
// no key repeat if it's a normal key
if (KEY_TYPE(keycode[i]) == KEY_TYPE_ASCII) {
if (!(oldbuttons & (1 << i))&&(pad.Buttons & (1 << i)))
key(keycode[i], 1);
}
else
if (pad.Buttons & (1 << i))
key(keycode[i], 1);
// no repeat when key released
if (!(pad.Buttons & (1 << i))&&(oldbuttons & (1 << i)))
key(keycode[i], 0);
}
oldbuttons = pad.Buttons;
// @@@ end of the new part
if (glut_display_func && glut_redisplay_posted) {
glut_redisplay_posted = 0;
glut_display_func();
}
if (glut_idle_func)
glut_idle_func();
} while (1);
}
Last edited by Edorul; 05-27-2006 at 04:46 AM.. |
|
|
|
|
![]() |
| Tags |
| key , pspgl , repeat |
| Thread Tools | |
|
|