Gamepad gesture recognition

Started by
3 comments, last by lordGoldemort 7 years, 10 months ago

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?

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.

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.

When I was young, every muscle but one was weak,
when I get older, every muscle will be hardened, but one not.

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.

When I was young, every muscle but one was weak,
when I get older, every muscle will be hardened, but one not.

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!

This topic is closed to new replies.

Advertisement