Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 10, 2009 9:06:19 GMT -5
Hi Guilect,
i have ascertained that the Keyboard Buffer will not be cleared. We need a command like KEY.CLEAR. Would be much easier to write a keyboard handling. I have spent a lot of time in order to write an acceptable keyboard input. The Keyboard Buffer is a ring Buffer with Tail and head. The Buffer is empty, when the tail and the head get the same position. But I am sure that you know it !
best regards
|
|
|
Post by Guilect on Jan 10, 2009 20:33:29 GMT -5
Never had any problems with keyboard buffer before...
But, I will look into a key.clear
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 11, 2009 12:46:20 GMT -5
Hi Guilect,
if i go to keyboard input and i pressed the Return key. Then i cannot do a keyboard input, because it is jumps out of the keyboard input before i type some Names. The keyboard input uses also a return key for leaving. Look here:
Option Explicit Public Count
Sub Main() Graphics.Initialize 640,480,True,32 Key.Initialize Mouse.Initialize Count =0
While True KeyStart System.ProcessMessages iF Key.Pressed(vk_windowX) Then Exit Sub Wend
Graphics.Terminate Key.Terminate Mouse.Terminate End Sub
Call Main
Sub KeyStart() 'System.Pause 25 iF Key.Pressed(vk_return) Then Count = Count +1 Graphics.SetTitle("You pressed Return key! " & Count & "x") End iF End Sub
|
|
|
Post by Guilect on Jan 11, 2009 17:02:35 GMT -5
I checked the keyboard buffer and it is fine. It gets cleared every time you call Key.Pressed(xxxx).
What you are doing is just running a very tight loop and calling the key.pressed routine many times a second. Say 60 times a second. So you see 60 returns.
Assume the return key is being held down: In your loop you:
call the key.pressed routine key.pressed returns true and the keyboard buffer is cleared you increment the count loop to beginning again at the rate of ~ 60 times a second
When a human presses the return key it is held down for many milliseconds, all this time your very fast loop in incrementing the count.
A very fast update on keys is what is wanted in games. And this is accomplished via the DirectX Direct Input module which the Key object in Brutus2D is using.
To do what you want, there is a simple method :
Option Explicit Public Count, returnkeyup
returnkeyup = false
Sub Main() Graphics.Initialize 640,480,True,32 Key.Initialize Mouse.Initialize Count =0
While True KeyStart System.ProcessMessages iF Key.Pressed(vk_windowX) Then Exit Sub Wend
Graphics.Terminate Key.Terminate Mouse.Terminate End Sub
Call Main
Sub KeyStart() 'System.Pause 25 iF Key.Pressed(vk_return) = false then returnkeyup = true iF Key.Pressed(vk_return) = true and returnkeyup = true Then returnkeyup = false Count = Count +1 Graphics.SetTitle("You pressed Return key! " & Count & "x") End iF End Sub
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 11, 2009 18:16:37 GMT -5
yes, that also denouement ! I can need it.
apart from that, BlitzMax has a ClearKeys command. And it work fantastic !
Thank you for your open ear. For the moment i have nothing to bleat !
|
|