QB64 bug or exception?
#11
It's a racing issue. Think how fast the loop travels, several hundreds of times per second. Now multiply that sound call over and over... See what I'm getting at? Sound plays in the background and every time it is called again, before it finishes, that process keeps multiplying to some degree.

Try this...

Code: (Select All)
FOR i = 1 TO 4000
    SOUND 1000, .1
NEXT

Run it and note that it immediately exits, but the sound keeps playing a lot longer than 1/10th of a second.

I actually tried what you came across with the _KEYDOWN example, and didn't include it so I wouldn't drive folks crazy. My best guess as to why INKEY$ doesn't work the same way is because it has some built in delay that negates the racing vulnerability we find in the _KEYDOWN statement.

Pete
Reply
#12
It happens with printing "A" as well, not just the sound in that last example.

check this out... I can get 3,4,5, even 6 keys to read on one pass through the loop.... but up and down arrows don't always seem to get noticed. ... on my laptop.  BUT on my separate usb keyboard I can get all 4 arrows at the same time and the space key (both keyboards are talking to the same computer)


Code: (Select All)
Do
    _Limit 60
    kv = 0
    If _KeyDown(32) Then
        Sound 1000, 0.1
        kv = kv + 1
    End If
    If _KeyDown(27) Then GoTo exitloop
    If _KeyDown(97) Then
        Print "A";
        kv = kv + 2
    End If
    If _KeyDown(98) Then
        Print "B";
        kv = kv + 64
    End If
    If _KeyDown(99) Then
        Print "C";
        kv = kv + 128
    End If


    If _KeyDown(19200) Then
        Print "<-";
        kv = kv + 4
    End If
    If _KeyDown(19712) Then
        Print "->";
        kv = kv + 8
    End If
    If _KeyDown(18432) Then
        Print "up";
        kv = kv + 16
    End If
    If _KeyDown(20480) Then
        Print "down";
        kv = kv + 32
    End If

    If kv <> 0 Then Print kv;

Loop
exitloop:
argggh.
Reply
#13
Wow, this is getting really weird. So I plugged in my USB keyboard to my laptop. On my laptop I can get arrow right and arrow down with space bar all to register. On my USB keyboard, it won't register the same key presses! So now we also have a hardware inconsistency in the mix.

Pete
Reply
#14
I have at least one laptop which ignores keyboard and touchpad response on occasion. It's not too serious but it bothered me a few times. Especially on HP computers having that setting that cannot be turned off, the user forced to wait at least one second, after typing in a key to be able to click one of the touchpad buttons. But plug in a wireless USB mouse and then nothing else could be plugged in, such as an external USB disk because they could fight with each other...
Reply




Users browsing this thread: 6 Guest(s)