'-----------------------
'--- New INKEY$ test ---
'-----------------------
i$ = ""
i$ = KB1031toCP437Inkey$
'--------------------------
'--- KB1031toCP437Inkey ---
'--------------------------
' This alternative INKEY$ function is made for use in Germany/Austria
' and any QB64-GL versions (>= 1.000). It will directly map the inputs
' from a german keyboard to the chars available in Cp437, hence you
' don't need to setup a custom unicode font and _MAPUNICODE table, you
' can stay with QB64's built-in fonts and standard codepage 437.
' By this means it solves the INKEY$ issues introduced with the transition
' from using SDL to using OpenGL regarding special/international chars.
' However, it does not fix the regular INPUT, LINE INPUT and INPUT$ when
' used for keyboard input, here you should create your own functions,
' which use this function to get its inputs.
'----------
' SYNTAX:
' keypress$ = KB1031toCP437Inkey$
'----------
' RESULT:
' --- keypress$ ---
' Equivalent to the INKEY$ result (see Wiki-Page at www.qb64.org).
'----------
' ACCENTS:
' Note that the accents keys on german keyboards are so called
' preselection keys, different from modifier keys (Shift/Ctrl/Alt)
' you don't need to hold them while typing accented chars. You just
' press it once followed by pressing the letter key once to get the
' respective accented char (eg. ` + e = Š). To get the accent char
' itself you either press the space bar after the accent preselection
' or you press the accent preselection key twice.
'----------
' LIMITS:
' Note that the following keys and key combos are not supported
' for various reasons:
'
' Two Byte Characters Key CHR$(0) + "?"
' -------------------------------------------------------------
' CHR$(0) + CHR$(16-50) [Alt] + letter
' rarely used, not in alphabetical order, KB layout dependent,
' => returns the regular char instead (Alt modifier ignored)
' CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64)
' rarely used, almost useless for most applications,
' => returns nothing
' CHR$(0) + CHR$(120-129) [Alt] + number
' ignored in favor for alternative Alt + ASCII code input method,
' => returns nothing, but collects numbers to built an ASCII code,
' the respective char is returned when releasing the Alt-Key
' CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "‚" or "ƒ"
' rarely used, KB layout dependent,
' => returns the regular char instead (Alt modifier ignored)
'---------------------------------------------------------------------
'--- clear result, get next key press/release ---
KB1031toCP437Inkey$ = ""
'--- ignore releases (except number/preselection keys) ---
IF (hit&
> -48 OR hit&
< -57) AND hit&
<> -220 AND hit&
<> -221 GOTO noInput
'--- get modifiers ---
'--- check preselection keys (accents) ---
IF preKey&
<> 0 THEN 'double preselection key press IF preKey&
= -221 AND hit&
= -221 AND NOT shift%
THEN hit&
= 39 'not really Acute, but similar replacement IF hit&
< 0 THEN 'update after false values (eg. š release = -220) preKey& = hit&
IF shift%
THEN preKey&
= -preKey&
preKey& = 0
ELSE 'first preselection key press preKey& = hit&
IF shift%
THEN preKey&
= -preKey&
ELSEIF preKey&
<> 0 AND hit&
> 0 AND hit&
<= 255 THEN 'any key after preselection key press READ cnt%
'start accent lookup hit& = charCode&
preKey& = 0
IF hit&
= charCode&
GOTO setInkey
'accent found, go directly to evaluation '--- use Alt + number keys to enter Cp437 char codes ---
'[Alt] + Number (CHR$(0) + CHR$({120-129}) ignored in favor
'for the alternative Alt + ASCII code input method
number$
= number$
+ CHR$(-hit&
) IF charCode&
>= 32 AND charCode&
<= 255 THEN hit&
= charCode&
number$ = "": preKey& = 0
'--- control sequences and special behavior ---
IF shift%
AND hit&
= 9 THEN hit&
= 15 * 256 'reverse TAB IF ctrl%
AND (hit&
>= 65 AND hit&
<= 90) THEN hit&
= hit&
- 64 IF ctrl%
AND (hit&
>= 97 AND hit&
<= 122) THEN hit&
= hit&
- 96 IF hit&
= 128 THEN hit&
= 238:
GOTO setInkey
'ü (replacement for superscript 3) IF hit&
= 167 THEN hit&
= 21:
GOTO setInkey
' (hence also available via Ctrl-u) IF hit&
= 179 THEN hit&
= 252:
GOTO setInkey
'î (replacement for Euro sign) charCode& = hit& \ 256
'following modifier priority is (Alt -> Ctrl -> Shift)
IF charCode&
>= 59 AND charCode&
<= 68 THEN 'F1-F10 IF alt%
THEN hit&
= (charCode&
+ 45) * 256:
GOTO setInkey
IF ctrl%
THEN hit&
= (charCode&
+ 35) * 256:
GOTO setInkey
IF shift%
THEN hit&
= (charCode&
+ 25) * 256:
GOTO setInkey
IF alt%
THEN hit&
= (charCode&
+ 6) * 256:
GOTO setInkey
IF ctrl%
THEN hit&
= (charCode&
+ 4) * 256:
GOTO setInkey
IF shift%
THEN hit&
= (charCode&
+ 2) * 256:
GOTO setInkey
'--- bring the system codepage mapped inputs back to Cp437, if available ---
hit& = i%
IF hit&
<> i%
THEN hit&
= 0 'no Cp437 entry found '--- finally encode the usual INKEY$ result ---
setInkey:
IF hit&
<= 255 THEN KB1031toCP437Inkey$
= CHR$(hit&
) noInput:
'-----------------------------
KB1031toCP437_Circonflex:
DATA 7,32,94,65,143,97,131,101,136,105,140,111,147,117,150 KB1031toCP437_Acute:
DATA 7,32,39,69,144,97,160,101,130,105,161,111,162,117,163 KB1031toCP437_Grave:
DATA 6,32,96,97,133,101,138,105,141,111,149,117,151 KB1031toCP437_None:
KB1031toCP437_Cp437:
DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197 DATA 201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402 DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187 DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488 DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575 DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600 DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745 DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,32