|
Post by tomct2 on Mar 10, 2020 19:26:19 GMT
Hi Folks!
happy to see Basic continues to live !
I have reams of old basic apps that date back to MS Basic 2.x,,, compile,,,link thence QuickBasic, thence PowerBasic.
on a MS Surface GO tablet - running in a legacy console - the virtual keyboard returns the usual and expected codes for the "standard keyboard" but the two character length extended keyboard (and mouse 4 character codes) show up as blank - unable to trap stuff like up/down arrows. ((code for experimenting:
do k$=waitkey$ print len(k$) - shows two
print k$/ascii/hex/etc - no joy loop ))
anyone discovered (I presume...) the API used by virtual keyboards and how to return keycodes from it?
|
|
|
Post by B+ on Mar 10, 2020 19:46:39 GMT
Don't think Just Basic is up for API calls, Liberty probably but you can get key press and mouse by a different route in what I call a "designer" window (as opposed to the mainwin console like scrolling B&W).
|
|
|
Post by Rod on Mar 11, 2020 10:20:57 GMT
Don't know where waitkey$ comes from, Just BASIC uses inkey$ for keypress input and when (event) for capturing mouse actions. I have only ever come across two character input using inkey$, never four. You need to split the input string if you want to see individual characters and as most are unprintable you really need to look at the asc value. But we are not really answering your question.
'INKEY.BAS - how to use the Inkey$ variable open "Inkey$ example" for graphics as #graph #graph, "when characterInput [fetch]" #graph, "setfocus" wait
[fetch] 'a character was typed! key$ = Inkey$ if len(key$)=1 then print "Inkey$ length = ";len(key$);" "; print "ASC value = ";asc(key$);" "; print "Glyph character is ";key$ end if if len(key$)=2 then print "Inkey$ length = ";len(key$);" "; print "First ASC value = ";asc(left$(key$,1));" "; print "Second ASC value = ";asc(right$(key$,1)) if key$=chr$(0)+chr$(16) then print "Shift released" end if wait
|
|
|
Post by tomct2 on Mar 11, 2020 14:58:27 GMT
WAITKEY$ is similar to INKEY$ but releases the time slices to the OS until a key press.
a mouse click returns a string len of four - the first being two null (255) characters - evaluated in similar fashion as the len 2 returns.
the problem is - the virtual keyboard returns two characters for the extended keys, but they are asc()=0 for both left and right character. apparently the virtual keyboard buffer is "elsewhere" . . .
|
|
|
Post by Rod on Mar 11, 2020 16:05:51 GMT
Ok, you are not using JUST BASIC, what BASIC or other software are you using? I see Power BASIC has that command you describe. I am sure you will get more sensible answers on their forum.
|
|
|
Post by tomct2 on Mar 12, 2020 12:51:45 GMT
yes, it;'s PowerBasic Console Compiler. I tried to ask there, joined, got a confirm message, confirmed, can log in, cannot post an answer nor start a new thread, sent email to contact listed, no answer. so I'm looking for other resources. also posted in a Microsoft group. they said the knew but couldn't tell me. oh . . .
|
|
|
Post by B+ on Mar 12, 2020 15:40:08 GMT
yes, it;'s PowerBasic Console Compiler. I tried to ask there, joined, got a confirm message, confirmed, can log in, cannot post an answer nor start a new thread, sent email to contact listed, no answer. so I'm looking for other resources. also posted in a Microsoft group. they said the knew but couldn't tell me. oh . . . "they said the(y) knew but couldn't tell me. oh . . ." what a joke! Well here there is a bit of a learning curve getting a window going; just follow a template until you are up to speed with the details. A number of people here eager to help folks get started. The Help in IDE is invaluable for me who plays around with several Basics (but not PowerBasic). JB has definite advantages of tested GUI and arbitrary long integers which comes in handy doing stuff with numbers. Oh you can copy to clipboard the output from mainwin which comes in handy too.
|
|
|
Post by tomct2 on Mar 12, 2020 17:04:08 GMT
to be clear - I have code that functions _perfectly_ with an attached keyboard on non-tablets. the problem is the virtual on-screen keyboard of a Surface GO does not work the same. specifically, if I touch a letter or Alt-(letter) key (or others of the "old standard" keyboard, it returns / acts "as normal." ))the tablet has 3-4 virtual keyboards, I'm using the QWERTY one(( if I press or mouse on the UP ARROW key, the key/mouse stroke is detected butvirtual keyboard returns a len()=2 empty string. ))the asterisks are by code printed to show any leading/trailing blanks((
'somehow,,,get a key == k$ print k$ result * * - two blanks print left$(k$,1) result * * - one blank print asc(left$(k$,1)) result 0 print right$(k$,1) result * * - one blank print asc(right(k$,1)) result 0
UP ARROW on a wired attached extended 101 keyboard returns a two character string: * H* ...which I have been trapping for decades....
somehow the virtual keyboard buffer is "different" - that is the issue: where to find it?
|
|
|
Post by Rod on Mar 12, 2020 18:43:00 GMT
I'm not sure you are understanding. This is a very specific forum. That's why it survives. We cannot help you with Power BASIC. Move over to Just BASIC and the doors to bliss and understanding will fall away.
|
|
|
Post by tomct2 on Mar 12, 2020 19:09:07 GMT
sorry - but you didn't read the op nor do you understand the question. it's not an issue of what language is used to capture the virtual keyboard input.
|
|
|
Post by Rod on Mar 12, 2020 19:31:23 GMT
Well first off Just BASIC does not deal with API. Second Just BASIC does not have a waitkey$ function. Most importantly this is a forum that discusses one language, Just BASIC. So I don’t know who is misunderstanding who.
I did understand your question but I could not understand why you were asking it on our forum. Perhaps if you see the difference between Just BASIC and Power BASIC you will understand my confusion.
Have you actually ever fired up Just BASIC? Try a few example programs. Many use the keyboard and mouse.
|
|
|
Post by tomct2 on Mar 12, 2020 22:56:00 GMT
thanks. all gone.
|
|
|
Post by Rod on Mar 15, 2020 18:47:20 GMT
I have browsed a bit about keyboard and mouse. It isn't really about one API or one dll. Essentially all keyboard and mouse actions reach your .bas program via Windows Messaging. So you have to set up to receive and handle these messages yourself if your system does not. Just BASIC simplifies the process by capturing keyboard messages to inkey$ and mouse messages to when mouse events. For example if we wished to capture "gestures", which are not currently catered for, we would need to register with Windows to receive these messages then use something like WMLiberty.dll to capture them and react within our program. This is of course impossible with Just BASIC but has been shown to work in Liberty BASIC.
Power BASIC it would seem has opted to hook mouse activity onto inkey$ and delivers a four byte message rather than a two byte message.
So I think a "solution" would be hard to find. If the native code does not do it, the native code needs changes. Else it all becomes too difficult.
But it should all just work, backwards compatibility is paramount so I don't know why these virtual keyboards don't conform. That's the second fix.
|
|