Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Some Helpful Input Functions

Author
Message
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 25th Dec 2008 03:21 Edited at: 25th Dec 2008 03:36
AHHH!!!! Sorry, I forgot the [DBP] at the top. It might work with DBC too though, if someone could test it that'd be great .

I made some functions to help get more data specific data about keyboard and mouse input. There are four functions:

GetLeftMouseState( )
GetMiddleMouseState( )
GetRightMouseState( )
GetKeyState( Key as Integer )

All four of these functions will return one of four values: _PRESSED, _DOWN, _RELEASED, or _UP.

_PRESSED is returned once when the button/key is initially pressed.

After that _DOWN is returned while the button/key is down.

Once the button/key is released _RELEASED is returned once.

After that _UP is returned until the next time the mouse/key is pressed.

This is useful if you only want to register individual clicks/key presses or want to check if a mouse button was just released.

Here's the constants and arrays required, this stuff will probably go near the top of your code:



And here are the functions:



If you have any questions about how to use it or want some example code just ask.

Xsnip3rX
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: Washington State
Posted: 26th Dec 2008 13:27
I think you can edit your post and it will edit the thread?

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 26th Dec 2008 16:38
Quote: "I think you can edit your post and it will edit the thread?"



Nahh, I think a mod needs to edit the title.

draknir_
17
Years of Service
User Offline
Joined: 19th Oct 2006
Location: Netherlands
Posted: 7th Jan 2009 18:30 Edited at: 7th Jan 2009 18:31
Thanks, I've never bothered to implement this myself, but it's actually quite handy.

Login to post a reply

Server time is: 2024-05-18 16:00:51
Your offset time is: 2024-05-18 16:00:51