Archived

This topic is now archived and is closed to further replies.

daher

err, console problem

Recommended Posts

hi, i've created a console ( hmm, not bad ) but seems i got a problem, all keys are inserted twice! if i type "quit" it would be on the console as "qQuUiItT". and of course the enter key enters two commands into the console did i missed somthin overhere? this is how i do it: 1) switch (Msg) 2) case WM_CHAR: 3) console.insert(wParam); if this is a silly question, please help me i am not a programmer, i am a mechanical engineering student. ( and this is my hobby ) ... :'( "The Railgun Master" DaHeR Edited by - DaHeR on January 15, 2002 10:21:01 AM

Share this post


Link to post
Share on other sites
i don''t use console functions much. but i presume if you remove the ".insert(wParam)" that will fix that. most likely your keypresses are automatically echo''d to the console.

Share this post


Link to post
Share on other sites
quote:
Original post by jenova
most likely your keypresses are automatically echo''d to the console.


no way man, how would u think so....

it doesn''t work



"The Railgun Master"
DaHeR

Share this post


Link to post
Share on other sites
It is because your game is checking keypresses too quickly. The console is checking keys at what, once every millisecond (or even more), and when you press down a key, you hold it down long enough for it to process 2 keydown messages for that key you pressed.

Either you can limit the speed, or just set that key''s flag to false after you''ve processed it the first time.

Share this post


Link to post
Share on other sites
quote:
Original post by alargeduck
whatabout WM_KEYDOWN instead of WM _CHAR?

quote:
Original post by wAVaRiaN
just set that key''s flag to false after you''ve processed it the first time.


thanx for replying...

but are u saying that i have to process all the keys being held and turn off the keys processed?
dont u think that this idea makes my game very slow?
and heh, if the user pressed ''a'' i have to check the shift status to determin ''a'' or ''A''...

there should be a problem with that, belive me
does any one else gorra better idea?

"The Railgun Master"
DaHeR

Share this post


Link to post
Share on other sites
Hey

I''ve got a working console and all I did was when a key was input I got the current time (using GetTickCount. The next time a key was pressed if the currenttime - previoustime < 100 (milliseconds?) then I don''t input it else I enter that key.

Works for me

"To err is human, to really mess up requires a computer"

Share this post


Link to post
Share on other sites
Yeah, i think TheGilb is right. WM_CHAR probably does come up every time you press or release a button (but this doesn''t explain why one is a capitol letter and the other isn''t). I think your better of using WM_KEYDOWN.

Share this post


Link to post
Share on other sites
oh i think i am very sorry...

after reading the code 6 times . i found the problem.
the problem was :

switch(msg)
case WM_KEYDOWN:
{ do somthing }
break; <- i forgot this plaese forgive me...
case WM_CHAR:
{ do the console }
break;

again i am sorry...


"The Railgun Master"
DaHeR

Share this post


Link to post
Share on other sites
n/p. may i suggest the "Ctrl+F10" option with VC++. it does wonders.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites