How to detect Russian keyboard?

By konamiman

Paragon (1040)

Аватар пользователя konamiman

25-02-2019, 09:25

It looks like numeric keys aren't being properly detected by Nextor
in Russian machines
, thus making disk emulation mode quite cumbersome. I could easily fix that if I could somehow detect that Nextor is running in one such machine... but apparently, 0x2C in the BIOS of these says that it has an "international" keyboard.

So here it is, simple but complex question... how can I know programmatically if a MSX computer has a Russian keyboard?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Pencioner

Paladin (930)

Аватар пользователя Pencioner

25-02-2019, 09:59

one of workarounds (if nobody knows more proper way) could be looking into the character pattern table in BIOS and recognize Russian alphabet character in it - so that makes you sure the keyboard is also Russian Smile

By Eugeny_Brychkov

Paragon (1088)

Аватар пользователя Eugeny_Brychkov

25-02-2019, 10:21

2C/2D will not give much info. Reading character table in ROM is not reliable as character set and keyboard handler may be intercepted (like in GR8BIT's lang pack). The most obvious and correct way is to emulate press of the key, e.g. scan code 0x26 ('Q' on QWERTY keyboards), and check the character returned. If system returns 'J', then it is a Russian keyboard.

By konamiman

Paragon (1040)

Аватар пользователя konamiman

25-02-2019, 10:28

Eugeny_Brychkov wrote:

The most obvious and correct way is to emulate press of the key, e.g. scan code 0x26 ('Q' on QWERTY keyboards), and check the character returned.

Do you mean something like inserting that code manually in the keyboard buffer and then calling CHGET in BIOS?

By gdx

Prophet (2977)

Аватар пользователя gdx

25-02-2019, 10:32

Pencioner wrote:

one of workarounds (if nobody knows more proper way) could be looking into the character pattern table in BIOS and recognize Russian alphabet character in it - so that makes you sure the keyboard is also Russian

I thought of the same thing in the past because Russian, Korean and Arabic MSXs not give right info. You can also ask the user to successively press a few keys in the settings and save the result in the RTC but the MSX1 do not have it.

By Eugeny_Brychkov

Paragon (1088)

Аватар пользователя Eugeny_Brychkov

25-02-2019, 10:42

konamiman wrote:

Do you mean something like inserting that code manually in the keyboard buffer and then calling CHGET in BIOS?

No, this way you will have this char returned. You must emulate key actual press - e.g. disable interrupts, set respective bit in the keyboard key state matrix at NEWKEY/OLDKEY, and then call keypress -> keyboard character conversion handler, and then see what char is in the keyboard buffer BUF. I think it is doable, only the matter of testing and seeing how to implement it exactly.

By konamiman

Paragon (1040)

Аватар пользователя konamiman

25-02-2019, 11:06

Hummm... ok, here's the deal: if you (or any other fellow Russin develuser) provide me such i_am_russian routine, I'll use it in Nextor to provide proper key detection. Deal? Smile

By NYYRIKKI

Enlighted (5358)

Аватар пользователя NYYRIKKI

25-02-2019, 12:12

"convert scancode to character"-routine is located in #D89 (A=bitmask, B=Row) It is not quite standard entrypoint, but I think it works in practice on all models...

I just wonder would it be possible to use CHSNS and CHGET instead of direct access? This way you would not need to think about what kind of keyboard there is, but the problem might be interrupt handling.

By NYYRIKKI

Enlighted (5358)

Аватар пользователя NYYRIKKI

25-02-2019, 16:45

Here is my take on this subject...

NEWKEY	EQU	0FBE5H
CAPST	EQU	0FCABH
KANAST	EQU	0FCACH
CLIKSW	EQU	0F3DBH
KILBUF	EQU	0156H
CHGET	EQU     09FH

i_am_russian: ; in case of ZF

	DI
	CALL KILBUF
	LD HL,(CAPST)
	LD A,(CLIKSW)
	PUSH AF
	PUSH HL
	XOR A
	LD (KANAST),A   ; KANA OFF
	LD (CLIKSW),A   ; Shut up!
	DEC A
	LD (CAPST),A    ; CAPS ON
	LD (NEWKEY+6),A ; No SHIFT, CTRL etc.
	LD A,64
	LD B,7
	CALL 0D89H
	POP HL
	POP AF
	LD (CLIKSW),A
	LD (CAPST),HL
	CALL CHGET
	CP "J"
	RET

By konamiman

Paragon (1040)

Аватар пользователя konamiman

26-02-2019, 13:55

That worked! Nextorifying it then. Thanks! Smile