So here's what my a new, full-sized, virtual keyboard might look like under my new system:
My_Keyboard
(0) = CHR$(0) + "27,ESC" + STRING$(2,0) + "15104,F1" + STRING$(2,0) + "15360,F2" + _
My_Keyboard
(1) = "`1234567890-=" + CHR$(0) + "19200,BKSP" + CHR$(0)My_Keyboard
(2) = CHR$(0) + "9,TAB" + CHR$(0) + "QWERTYUIOP[]\"My_Keyboard
(3) = CHR$(0) + "100301,CAPS" + CHR$(0) + "ASDFGHJKL;'" + CHR$(0) + "13,ENTER" + CHR$(0)My_Keyboard
(4) = CHR$(0) + "100304,SHIFT" + CHR$(0) + "ZXCVBNM,./" + CHR$(0) + "100303,SHIFT" + CHR$(0)My_Keyboard
(5) = CHR$(0) + "100306,CTRL" + STRING$(2,0) + "0,WIN" + STRING$(2,0) + "100308,ALT" + _
k = KB_Input(My_Keyboard(), 50, 30, 50, 100)
DIM Keyboard_Values
(l
TO u
, 0 TO 256) FOR i
= l
TO u
'get longest line LL = LL + 1
keyboard_image
= _NEWIMAGE((Xsize
+ 2) * LL
, (Ysize
+ 2) * (u
- l
+ 1), 32) 'now build the keyboard
top = (i - l) * Ysize + Ypos
count = 0
left = (count) * Xsize + Xpos
count = count + 1
repeat = 1
'look for the comma
comma_position
= INSTR(j
, KB
(i
), ",") IF comma_position
THEN 'we have a value, label value$
= MID$(KB
(i
), j
+ 1, comma_position
- j
- 1) j = comma_position + 1
ELSE 'cry loud and hard so we can sort it out while programming our keyboard layout scream_and_die:
PRINT "You have an invalid keyboard layout!"
IF end_position
THEN 'we're extracting the label out$
= MID$(KB
(i
), j
, end_position
- j
) repeat = 1
j = end_position
LINE (left
, top
)-STEP(Xsize
* repeat
, Ysize
), -1, B
Keyboard_Values(i, count) = c
count = count + 1
repeat = repeat - 1
Keyboard_Values(i, count) = c
Hardware_Keyboard_Image
= _COPYIMAGE(keyboard_image
, 33)
oldmouse = -1
_PUTIMAGE (Xpos
, Ypos
), Hardware_Keyboard_Image
Xon
= INT((mx
- Xpos
) / Xsize
) + 1 Yon
= INT((my
- Ypos
) / Ysize
) + l
'LOCATE 1, 1: PRINT Xon, Yon
oldmouse = mb
[ You are not allowed to view this attachment ]
That's actually not looking so bad, if I do say so myself!
And the whole thing builds itself from scratch, once you give it your chosen layout. The one which made the keyboard in the screen shot is this one:
DIM My_Keyboard(5) AS STRING
My_Keyboard(0) = CHR$(0) + "27,ESC" + STRING$(2,0) + "15104,F1" + STRING$(2,0) + "15360,F2" + _
STRING$(2,0) + "15616,F3" + STRING$(2,0) + "15872,F4" + STRING$(2,0) + "16128,F5" + _
STRING$(2,0) + "16384,F6" + STRING$(2,0) + "16640,F7" + STRING$(2,0) + "16896,F8" + _
STRING$(2,0) + "17152,F9" + STRING$(2,0) + "17408,F10" + STRING$(2,0) + "34048,F11" + _
STRING$(2,0) + "34304,F12" + CHR$(0)
My_Keyboard(1) = "`1234567890-=" + CHR$(0) + "19200,BKSP" + CHR$(0)
My_Keyboard(2) = CHR$(0) + "9,TAB" + CHR$(0) + "QWERTYUIOP[]\"
My_Keyboard(3) = CHR$(0) + "100301,CAPS" + CHR$(0) + "ASDFGHJKL;'" + CHR$(0) + "13,ENTER" + CHR$(0)
My_Keyboard(4) = CHR$(0) + "100304,SHIFT" + CHR$(0) + "ZXCVBNM,./" + CHR$(0) + "100303,SHIFT" + CHR$(0)
My_Keyboard(5) = CHR$(0) + "100306,CTRL" + STRING$(2,0) + "0,WIN" + STRING$(2,0) + "100308,ALT" + _
STRING$(2,0) + "32,SPACE" + STRING$(2,0) + "100307,ALT" + STRING$(2,0) + "0,WIN" + STRING$(2,0) + "0,MENU" + _
STRING$(2,0) + "100305,CTRL" + CHR$(0)
It looks a little complicated when you first take a glance at it, but it's not. It's basically using the syntax which I was talking about above.
For normal keys, you just put them in quotes. "QWERTYUIOP[]\"
For any special keys, you identify them with CHR$(0) + "code_value,LABEL" + CHR$(0).
So the TAB key, for instance is: CHR$(0) + "9,TAB" + CHR$(0).
So that whole row becomes CHR$(0) + "9,TAB" + CHR$(0) + "QWERTYUIOP[]\"
And with that, you can build a keyboard of any layout which you might want for your programs, and then use the mouse to interact with it. (Or a touchscreen.)