QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

How to repeat a key using pspgl ?

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 ...

Reply
 
LinkBack Thread Tools
Old 05-26-2006, 12:38 PM   #1
 
Join Date: May 2006
Location: France
Posts: 3
Trader Feedback: 0
Default How to repeat a key using pspgl ?

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);

   ....
}
I will be glad if someone have an idea :icon_smil
Edorul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-27-2006, 04:33 AM   #2
 
Join Date: May 2006
Location: France
Posts: 3
Trader Feedback: 0
Default

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..
Edorul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
key , pspgl , repeat

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 09:01 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us