Skip to main content
gamedev.net
🔒 Locked

err, console problem

Started by daher 10 replies 1k views
Original Post
daher
daher
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
____________________________________MSN | AIM | YIM | ICQ
jenova
jenova
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.
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.
daher
daher
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
____________________________________MSN | AIM | YIM | ICQ
Wavarian
Wavarian
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.
alargeduck
alargeduck
whatabout WM_KEYDOWN instead of WM _CHAR?
daher
daher
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
____________________________________MSN | AIM | YIM | ICQ
Lukerd
Lukerd
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"
"To err is human, to really mess up requires a computer"
TheGilb
TheGilb
I tink WM_CHAR will be sent to ur program upon keydown and keyup...
Crawl
Crawl
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.
--------
123cs
123cs
I''m using WM_CHAR in my console and it works great
"Art is a lie that lets us recognize the truth." - Pablo Picasso
daher
daher
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
____________________________________MSN | AIM | YIM | ICQ
jenova
jenova
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.
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.