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.

Dark GDK / [dgdk .NET] Input Workaround

Author
Message
code master
20
Years of Service
User Offline
Joined: 4th Dec 2003
Location: Illinois
Posted: 24th Jan 2009 07:50
So I've had the problem with not being able to get dgdk to register a key press... I searched the forms and discovered this has to do with the focus of the control.

So, I set my fMain to register key_down, and Key_Up events.
In the respective subs, I checked the scan code of the key and sent it to my Application class. All is good and done.

Until I realize that I'm working with a single key code per event.

Long winded introduction aside, is there anyway to get the values of each code pressed? I want to control a model with my arrows keys, and this requires at least two keys operatable at a time. I also want to have form controls in my App, so removing the form is not really a solution.

Thanks!

A73
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location:
Posted: 24th Jan 2009 15:01
Hi code master,

as far as I know, there's no thing like a "simultaneous
keypress" under the WinForms definition. That is, some key is always pressed first.

A way to simulate the desired behaviour, woule be to track keydown & keyup events, measuring time difference between them, and if i.e. two keydown events occur within 60ms without intervening keyup, then you could treat it as a simultaneous keypress.

The real sequence of events is still and always linear - "key 1 down, key 2 down, key 3 down, ...".

Neither you should use threads and/or hooks at this point. I think a clear, simple event-driven way should be quite enough to achieve what you're looking for.

I hope this helps...

Cheers.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 25th Jan 2009 02:36 Edited at: 25th Jan 2009 02:37
I've never had to do this so I don't know what's possible but isn't there a way to tell if a key is still down? Could you do something like this? (pseudo code)



It has the overhead of having to (needlessly?) check for the first key down but when the second key is down it finds the first down and does what needs to be done when both are down.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
code master
20
Years of Service
User Offline
Joined: 4th Dec 2003
Location: Illinois
Posted: 26th Jan 2009 06:31
A73:

I like that idea... thanks a lot. I'll look into it.

Lilith:

That's the first thing that came to mind, but I've been unable to find a way to get if a key is currently down.

Does anyone know a way to do that?

Thanks!

mamaboy
15
Years of Service
User Offline
Joined: 24th Jan 2009
Location:
Posted: 26th Jan 2009 07:57
hi lilith
why we need to const a as integer and the keydown is b?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 26th Jan 2009 14:09
I was using pseudo code since I really don't know how to tell if a key is up or down in Windows without keeping track of the key up and key down events.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 4th Feb 2009 13:51
Any solution yet?

Im having this problem to.

Login to post a reply

Server time is: 2024-09-30 17:37:02
Your offset time is: 2024-09-30 17:37:02