Jump to content
  • Advertisement
Sign in to follow this  
lordGoldemort

Gamepad gesture recognition

This topic is 777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm considering incorporating gesture recognition in my game based on analog joystick input. It sorta screams "neural network" to me, but perhaps there is a more ad hoc mechanism. For example, if you had to draw a circle, some measure of the distribution of how far away the sampled values were from their centroid. That would be fine for simple shapes, though perhaps if I could define a path for each gesture I could still perform a similar trick. I can see problems with that, though, trying to work out which of the sample points belong to which segment of the path. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement

Hmm you could calculate the whole segment and not just consider the points. This way you could sample a whole shape and not just points. 

For example: The user points the joystick upwards, so you save the initial point and add whenever the user changed the angle.

This is of course simplified. You also need to measure the angle which the user directs the joystick, which is a simple sin/cos method.

Edited by WoopsASword

Share this post


Link to post
Share on other sites

If you wanna detect if a stick is rotated (for example in clockwise order), you have to map the two axes in a vector.
Then you look if a x or y value changes his presymbol (my bad english, presymbol means "+" or "-" for me).
This will result in a change of the actual quadrant of the circle.
And if you now detect this row of quadrant-changes .... you have your move.

You can add maybe a inner radius, so the player has to make a "big rotation" with the joystick.

I hope that wasnt too fast.

Share this post


Link to post
Share on other sites

a function for this could look like this:

#define QUADRANT_TOP_LEFT 0x01
#define QUADRANT_TOP_RIGHT 0x02
#define QUADRANT_BOTTOM_LEFT 0x03
#define QUADRANT_BOTTOM_LEFT 0x04

char getQuadrant(vec2f actual_stick_pos)
{
    if(actual_stick_pos.x < 0 &&
       actual_stick_pos.y > 0  )
        return QUADRANT_TOP_LEFT;
    
    if(actual_stick_pos.x > 0 &&
       actual_stick_pos.y > 0  )
        return QUADRANT_TOP_RIGHT;
    
    if(actual_stick_pos.x < 0 &&
       actual_stick_pos.y < 0 )
        return QUADRANT_BOTTOM_LEFT;
    
    if(actual_stick_pos.x > 0 &&
       actual_stick_pos.y < 0   )
        return QUADRANT_BOTTOM_RIGHT;
}

the you would have to create something like an array with 4 values.
So when the quadrant changes, the old quadrant gets in first place, the rest is shifting back.
Then you have to do a simple check of the array.

 

Share this post


Link to post
Share on other sites

a function for this could look like this:

#define QUADRANT_TOP_LEFT 0x01
#define QUADRANT_TOP_RIGHT 0x02
#define QUADRANT_BOTTOM_LEFT 0x03
#define QUADRANT_BOTTOM_LEFT 0x04

char getQuadrant(vec2f actual_stick_pos)
{
    if(actual_stick_pos.x < 0 &&
       actual_stick_pos.y > 0  )
        return QUADRANT_TOP_LEFT;
    
    if(actual_stick_pos.x > 0 &&
       actual_stick_pos.y > 0  )
        return QUADRANT_TOP_RIGHT;
    
    if(actual_stick_pos.x < 0 &&
       actual_stick_pos.y < 0 )
        return QUADRANT_BOTTOM_LEFT;
    
    if(actual_stick_pos.x > 0 &&
       actual_stick_pos.y < 0   )
        return QUADRANT_BOTTOM_RIGHT;
}

the you would have to create something like an array with 4 values.
So when the quadrant changes, the old quadrant gets in first place, the rest is shifting back.
Then you have to do a simple check of the array.

 

 

Thanks, I have been thinking along similar lines (pardon the pun!). I think it would be better to track octants (a bit more trig, but still quite easy) and it might also be useful to track velocity (or equivalently time between octants). It's not rocket science, but it could work quite well and be more CPU friendly that a neural network trained on patterns!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!