GLBasic forum

Main forum => Bug Reports => Topic started by: Ian Price on 2017-Jul-18

Title: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Jul-18
Anyone having keyboard delays/misses with the latest update of GLB (v14.497).

I'm writing a text based adventure game that worked fine before updating and going back to 12.XXX works well, but sometimes keys repeat, delay or are missed completely. Anyone else seeing similar behaviour?
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: dreamerman on 2017-Jul-18
Earlier I wasn't sure about that as I also use some inkey and custom functions for checking key state, but I have similar feelings, it only appears when using LimitFps (even on 60fps), with normal uncapped framerate and keyboard checking each 16ms (around 60fps) it's working properly. Didn't test if it appears only with latest patch but I have one game prototype built with earlier version of GLB that's using LimitFps 60 with vsync and it's working good.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Jul-18
I'm not using LIMITFPS as there are no time dependent features, but I'm definitely getting some issues. It could indeed be related to INKEY$ as I'm using that for input. Dunno. KEY(n) doesn't appear to be affected.

Thanks for the confirmation :)

Actually I've just noticed that the latest logfile for the update states "KEYWAIT" fixed - I'm guessing that this has had a knock-on effect in that it has now broken INKEY$
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: erico on 2017-Jul-21
I think not too long ago I read a very similar problem on the forum, will try to find out and let you know.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: AmazingJas on 2017-Jul-31
I too noticed massive problems with this, had to revert to an earlier version. I was using limitfps. Experienced it on both Win 7 and Win 10 machines.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Jul-31
you can do a workaround using you own version of INKEY$ using KEY(). Im have not seen what the code really does in the function (and Gernot might should send the lastest source as well).
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Jul-31
Please Note, Glbasic is NOT alone. Im got similar issue in KeyDelay issues even in AutoHotKey. So Windows must have broken some thing about that api INKEY$() using. So its could been more a Windows and not directly a glbasic issue.

We should create your own INKEY$() using KEY() instead, event on the command as well.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Jul-31
If it was just a Windows bug, it would affect ALL versions of GLB. It doesn't. INKEY$ is working in GLB 12.XX. Maybe Windows is fecked as well. :P Dunno.

Yes, we could roll our own version of INKEY$, but why reinvent the wheel? It's working in earlier versions of GLB, so no big deal. Just hope that Gernot fixes what he broke in a future update.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Jul-31
Auto hot key also Bugger to with extract same issue, also recently too, when I'm tried to remap game pad to keyboard. It's got very much delayed on some keys. Now I'm dropped game pad and used a real keyboard encoder.

I'm could take a look when time. But not sure I'm can do anything....

I'm also newer used inkey$, but allways prefer KEY(). The command can been strange sometimes. Even in Greedy mouse when I'm used Inkey$ like command for testing. I'm did prefer use my own function instead. So the issue must have been in very long time.

Same with print. I'm use my own font system.

Inkey might also not like keywait and key() me thinks and they may "steal" or improper input instead.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Jul-31
when im checking KEYWAIT (im have not the newest version)....

There is different between DEBUG and RELEASE versions. in the DEBUG release, its eill empty the INKEY$ as well. its seens not do that in the release version.

KEYWAIT should not effect INKEY, except if the fix was in the dxinput.cpp. Then something might have been broken. KEYWAIT is also quite strange. Its only wait when im PRESSING down a key, which is wrong behaiver for that command. Its should wait until the next keypress and then eventuelly send that keypress to the INKEY$. Its dosent do that, which is confirmed.

Until then you should use KEY(), which is not effected at all. But im want to know how im can invoke Scan2Ascii() in the dxinput.cpp? Then im could wipeout a simple workaround using that call directly in a inline.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Jul-31
I never use INKEY$ - it's just I needed it for a my text adventure. I always use KEY() in my games. In this case it's not necessary and would add a lot of needless code. I haven't used INKEY$ since coding on the CPC!!!

BTW I don't use print either, just my own bitmap font functions.

It's not a big deal and constantly saying "use KEY()" isn't actually resolving the issue. And It IS an issue. Full stop. Windows may also be buggered but GLB14.XX is definitely not right either.

I'm not expecting you to sort it out, but it IS a genuine bug.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Aug-01
It's just funny is same issue as in auto hot key issue I'm have. In a Extractly completely same malfunction behaveier. I'm not even sure it's was happens in a old version of auto hot key?

Very strange.

So... Glbasic is not alone and could been have been a new issue. I'm do not checked why it's happens here and its might only happens on some machines.

However there is still workaround, since you not know when thing got fixed and sometimes might newer did. I'm also did needed workaround various android bugs before it's finally got fixed. Few is still presents.

I'm also confirm keywait is not fixed. It's only works when key is pressed down. Also please tryout it's does same issue in the debug version. The code behaveier seens to been little bit different. Also I'm have not checked what Inkey really does in code in the background or what happens under a frameskip or such. Yet.

So something weird could have effected togheter. Property I'm can do nothing right now. Sorry.

All I'm can do is checking how scan codes can translated to char with a inline code. When done new Inkey function can been done in few lines. This is I'm checking later first. Workaround is better than nothing. Until that.

Ps. I'm deleted the next post. I'm are currently do a work around to been used until it got fixed.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Aug-01
Seems like a lot of work for you SF, for limited benefit tbh.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Aug-01
yes. im are not a advanced c++ programmer. howover this is a function that can been used as a workaround. im have only supported US keyboard for now. but other keyboard is very easy to been supported, if you read a keyboard.ini in your folder, so the keyboard layout can been changed that way. Im know this is not perfect, far away, but much better than nothing. what im should do is doing a system call to checking the visual scancode from Windows from the scancode. But im not sure how to do that.

its on purpose to hold the whole code into a the function. on some platforms, DIM static might require to been declared as GLOBAL...

But hey you have idea what im would do with this.

Code: (glbasic) [Select]
// a little workaround version of bugged INKEY$().
//
// Since im are not sure how TO detect the country keyboard layout (USA, German, France etc).
// Its best to read the layout from a inifile and put the result into those argument. example in this layout in the ini file:
//
//
// small=..1234567890....qwertyuiop....asdfghjkl.....zxcvbnm
// big=..1234567890....QWERTYUIOP....ASDFGHJKL.....ZXCVBNM
//
// you can also add extra keys and translate to chr values, example by using functions keys if you want. Something that is
// not possible with original INKEY$().
//
// Also this function might output more than one char, if two keys is pressed down same time on same frame.
FUNCTION INKEY2$: small$="..1234567890....qwertyuiop....asdfghjkl.....zxcvbnm", big$="..1234567890....QWERTYUIOP....ASDFGHJKL.....ZXCVBNM", skip$="."
STATIC i_scancodes[]
STATIC i_init=0

IF i_init=0
i_init=1
DIM i_scancodes[256]
ENDIF

LOCAL keys$=""

LOCAL keys[]
DIM keys[10]
LOCAL nr=-1
FOR i=1 TO 255
IF KEY(i)=1
i_scancodes[i]=i_scancodes[i]+1
ELSE
i_scancodes[i]=0
ENDIF

IF i_scancodes[i]=1 // here we could also eventuelly supports key repeat. but its up to you if you want.
nr=nr+1
IF nr<9
keys[nr]=i
ELSE
BREAK
ENDIF
ENDIF
NEXT

LOCAL ikey$=""
IF nr>-1
LOCAL letters$=small$
IF (KEY(42)=1 OR KEY(54)=1) AND big$<>"" THEN letters$=big$ // big letters, if required.
FOR i=0 TO 9
IF keys[i]>0
LOCAL ch$=MID$(letters$,keys[i],1)
IF ch$<>skip$ THEN ikey$=ikey$+ch$      // a letter
IF keys[i]=57 THEN ikey$=ikey$+" "      // spacebar
IF keys[i]=28 THEN ikey$=ikey$+CHR$(13) // enter
IF keys[i]=14 THEN ikey$=ikey$+CHR$(8)  // backspace
// you can expand it here with extra keys required, example F keys etc and use special letter to that.
ENDIF
NEXT
RETURN ikey$
ENDIF
RETURN ""
ENDFUNCTION

in a text adventure, you dont need to checking the full keyboard at all, and is property only in English anyway, but as im say the arguments in the function is designed so more keyboard layout easy can been added.

Please Note, INKEY$ here might return more than one letter, when two keys is pressed down on the same frame. The function is to been called every time by every SHOWSCREEN.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Aug-02
That's a nice function, but I'm just going to stick with using an older version of GLB - it works.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: spacefractal on 2017-Aug-02
you would property have more control over it... but expanding the function is possible and still control it.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: Ian Price on 2017-Aug-03
I personally don't need new functions though. The old glb version is perfectly fine for my adventure game. I doubt I'll ever need or use inkey afterwards. Others may, hence why I feel this bug needs to be fixed rather than worked around.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: retrogren on 2018-Jan-27
Hi,

Sorry for the slight necro-post   :blink:
This thread quite closely describes an issue that I'm currently having with my code - hope that's OK!

I started coding a little space invaders clone a couple of years back (the IDE was 14.001 I think) , and it went on hold 'cos of work/life etc...

Now I have some spare time, I re-installed GLBasic, updated to the latest verision (14.497) and had a play (without making any changes!)
I'm now getting some weird input lag on all key presses - the input simply isn't responding like it used to. 
I use key() for the control input.

So, based on Ian's experience, I downloaded an archive version of the IDE (12.308), tested the game, and the input is absolutely fine!
I'm on Windown 10 64 bit.

Is anyone aware of or looking at this issue?   Happy to provide more info if required!

Gren.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: dreamerman on 2018-Jan-27
Current GLBasic version is 15.089, You can see it at right upper corner of forum webpage, from what I remember this issue was fixed in one of ver. 15 updates.
Don't forget to use GLB_ON_LOOP if you plan to put game on mobiles.
Title: Re: Anyone having input issues with the latest update(14.497)?
Post by: retrogren on 2018-Jan-27
Thanks dreamerman!

I actually tried a manual update from inside GLBasic 14.497 (no updates found), and I also spotted that link you mentioned - but it went to a page that described SDK version 14.   So I assumed it wasn't ready yet!

Anyways - I've downloaded the SDK from that link (15.004), and the input lag issue has gone away   =D

Many thanks - issue resolved   :)