Jump to content
  • Advertisement
Sign in to follow this  
zike22

Keyboard preasure sensitivity??

This topic is 4852 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

How do you do preasure sensitivy in a pc game it's done all the time here's what I mean. ex: you tap space the character jumps a little you hit space with more preasure the character jumps higher. Or something like that, how is this done? Is is based on how long a key is pressed based on a fraction of a second?? Help me out, thanks

Share this post


Link to post
Share on other sites
Advertisement
If you are using Direct Input, poll the device and while the key is pressed keep incrementing a "pressure" variable. This will tell you how much "pressure" was applied. When the key is released reset it to 0. Of course you will want a cutoff point so it will not continue to accumulate forever. If/When that cutoff point is reached because the key was held long enough then reset the variable to 0.

Share this post


Link to post
Share on other sites
Pressure does not exist on keyboards. Incidentally, if someone exerts more pressure on a key, they also have a tendency to hold it down significantly longer. So you can simulate pressure sensitivity just by measuring the time a key was held.

Share this post


Link to post
Share on other sites
Just so it's clear, there's no way on any keyboard I know of to get an analog type value of how much pressure is being used on a key. A key is either down or up. Your example is just testing the duration of the keypress -- not how hard it was pressed. So keep track of how long the key was down by subtracting the timestamp of the keydown from the timestamp of the keyup. Then react based upon the resulting value. Firewalker's suggestion is essentially the same as mine.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!