VGUI Joypad Input in SDK 2013

Grab your favourite IDE and tinker with the innards of game engines

VGUI Joypad Input in SDK 2013

Postby SM Sith Lord on Fri Dec 06, 2013 10:44 am

I need my VGUI panel to capture the left analog stick from the joypad. In 2007 SDK, I was able to do this using the following code:
Code: Select all
void CHDViewInput::OnKeyCodePressed(KeyCode code)
{
   if( IsJoystickAxisCode(code) ) {
      if( code == KEY_XSTICK1_UP )
         m_bMoveUp = true;
      else if( code == KEY_XSTICK1_DOWN )
         m_bMoveDown = true;
      else if( code == KEY_XSTICK1_LEFT )
         m_bMoveLeft = true;
      else if( code == KEY_XSTICK1_RIGHT )
         m_bMoveRight = true;

      return;
   }
}


In 2007, this code would capture the left analog stick and ignore all other joypad input. However, in 2013 SDK this does nothing. This is probably due to the improved controller support in the new SDK. Now you can control the main menu with the dpad on your joystick; you couldn't do that back in 2007.

Does anybody know how to make my VGUI panel capture the left analog stick of the joypad in 2013?
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: VGUI Joypad Input in SDK 2013

Postby zombie@computer on Fri Dec 06, 2013 5:56 pm

No idea but maybe code is a bitfield now? I mean you'd need to check if (code & KEY_XSTICK1_UP) instead of == ?
When you are up to your neck in shit, keep your head up high
User avatar
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: VGUI Joypad Input in SDK 2013

Postby SM Sith Lord on Sat Dec 07, 2013 2:06 pm

The problem is that no code what so ever gets sent when I move the joystick while in a VGUI menu now. :( The method isn't even called anymore.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: VGUI Joypad Input in SDK 2013

Postby zombie@computer on Sat Dec 07, 2013 2:09 pm

Ah. Thats a problem then :|
When you are up to your neck in shit, keep your head up high
User avatar
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: VGUI Joypad Input in SDK 2013

Postby Garrador on Sun Dec 08, 2013 5:52 pm

Is
Code: Select all
Panel::OnKeyCodeTyped(KeyCode keycode)
called when you move the stick??

Browsed through the source code on github, and in that function this was commented out:

Code: Select all
// legacy handling - need to re-enable for older apps?
                /*
                if ( code == KEY_XSTICK1_RIGHT || code == KEY_XBUTTON_RIGHT )
                {
                RequestFocusNext();
                return;
                }
                else if ( code == KEY_XSTICK1_LEFT || code == KEY_XBUTTON_LEFT )
                {
                RequestFocusPrev();
                return;
                }
                */


Might this affect it? Perhaps there is some problem with focusing input on the panel whilst using a joypad..
You click on Build or type
make (or some equivalent), and you are astonished, then mortified, as you realize that the whole world is being
recompiled and relinked!
- Scott Meyers
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Re: VGUI Joypad Input in SDK 2013

Postby SM Sith Lord on Mon Dec 09, 2013 12:48 pm

I haven't tried monitoring higher up in the inheritance hierarchy yet, I'll look there next, thank you. I know that the OnKeyCodePressed doesn't get called from my panel, which inherits from the Panel class, but I actually haven't tried tapping into the OnKeyTyped message at all yet.

The code you found there seems like they were thinking about letting the analog stick change your menu selection, however only the d-pad does that now. RequestFocusNext() must be the function to step through the different buttons/elements you have in your panel. Very helpful. I'll post here if I figure anything new out.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Return to Programming

Who is online

Users browsing this forum: No registered users

cron