ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Support
 
<< Previous thread | Next thread >>
Keypresses in WM_TIMER
Moderators: kornalius, bmanske, PointOfLight
Author Post
Mike Halliday
Tue May 06 2008, 03:35pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
This is probably a simple question to answer, but I just can't figure it out! (I must admit though, I have spent all of 5 mins trying to solve it!) ha ha

In WM_TIMER, keypresses are checked every timer loop which is great for scrolling games and moving sprite games, but I have another application in mind.

My app scans for keypresses in WM_TIMER (as in the GAMEAPI examples) when I press any of the direction keys, my position counter zooms up or down etc. I want to be able to do the following;

Press an arrow key
Increment by 1
Press the same arrow key
Increment by 1

Get my drift?

What I get is

Press an arrow key
Increment until I release the arrow key (my counter zooms up and up!)

AAARRRGGGHHH!

I must have missed something, but I have tried all the examples and the help and still cant find anything to help me!

I have even tried the following;

WM_KEYDOWN:
if (KeysPressed$[wParam$] = 1)
KeysPressed$[wParam$] = 0;
else
KeysPressed$[wParam$] = 1;
end;

But that does not work.

Not massively urgent or important - Im sure if I scratch my head enough I will find it.

Cheers

Mike.

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
zehlein
Tue May 06 2008, 03:51pm

Registered Member #30
Joined: Tue Sep 12 2006, 03:00pm
Posts: 449
Use the FirstTime$ variable. It should be true by default. In the WM_Timer section change:

if (KeysPressed$[keys.vkLeft$] and FirstTime$)
...
FirstTime$=false;
end;

and in MAINPROC's WM_KEYUP set it back to true


There is a crack, a crack in everything. That's how the light gets in. (L. Cohen)
Back to top
Mike Halliday
Tue May 06 2008, 04:04pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
ooo, see I knew it would be something simple!

Ta muchly!

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
Mike Halliday
Tue May 06 2008, 04:10pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
implemented and well pleased with the result! - DOH - should have seen that solution before I asked the daft question.

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
PointOfLight
Wed May 07 2008, 08:02am

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
Question: rather than even checking in the WM_TIMER event, why not just increment your counter in the WM_KEYDOWN event?  Then you don't even need the FirstTime$ variable or all the extra associated logic.  Or am I missing something here?

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Mike Halliday
Wed May 07 2008, 09:27am

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
another solution! - again one that seems simple now that it has been pointed out!

I know why i had not tried this solution. I was under the impression that the key checks in WM_TIMER could not be used in the WM_KEYDOWN section. (Dont ask me why I thought that! rofl)

Any hoo, have a working piece of code so my quest has ended!

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System