VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

When I try to use the keyboard after starting certain applications (Windows 3.0 running a MS-DOS game) the keyboard acts strangely. Also when I try to open a text editor (like edit) in MS-DOS, all keys input "\" into the text editor, instead of normal input. Anyone knows what's the cause of this? My keyboard emulation works fine in Windows 3.0 itself and when running games like Ultima VI.

I've also noticed that for some reason keyboard input is too fast? I'm using the documented delays for inputting keys (single key input vs typematic key using the current typematic key rate). The main thread handles input and translates it into either PSP input or Keyboard/Mouse input(during Direct Input mode). The CPU thread then processes that data and updates keyboard(at the rate specified) and mouse(at the rate specified in PS/2 mode, or at a predetermined rate using Serial mouse mode(default)). It looks like the typematic mode is entered too fast? So it isn't delaying enough for some reason?

My input handling routine:
https://bitbucket.org/superfury/x86emu/src/70 … ard.c?at=master

It's the tickPendingKeys function that's handled every 1/1000th second that handles input and typematic rates (combined with calculateKeyboardStep). onKeyPress/onKeyRelease handle the moment a key(or PSP OSK mapped input for the keyboard) is pressed/released.

The keyboard emulation itself:
https://bitbucket.org/superfury/x86emu/src/70 … ard.c?at=master

The tables are taken from:
https://bitbucket.org/superfury/x86emu/src/70 … ata.c?at=master

Anyone knows why the keyboard doesn't work correctly in some MS-DOS programs (like edit, qbasic etc.) and why the keyboard starts using typematic mode too fast?

Last edited by superfury on 2015-09-22, 13:23. Edited 1 time in total.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 1, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've managed to get the keyboard input reasonably working. Single keys are processed correctly, multiple fast keypresses (like typing "test" with a speed of 160-170+ strikes per minute with four fingers) the keyboard input will only see things like "tst".

The full input handling (layer processing input from keyboard or PSP to PS/2 keyboard input keys):
https://bitbucket.org/superfury/x86emu/src/70 … ard.c?at=master

- getnspassed() gives the time passed since last call in nanoseconds.
- onKeyPress/onKeyRelease handle pressing and depressing of keyboard keys (all 104 keyboard keys plus the special "CAPTURE" key for a screen capture).
- calculateKeyboardStep() calculates the next stepping value to use for giving keyboard input (either the keyboard delay or the typematic rate delay).
- tickPressedKeys handles keyboard pressed keys, converts them to their input key to be pressed (either pressed key or last pressed key(during typematic keypresses).
- tickPendingKeys() is called before every CPU instruction (emulated 80(1)86 CPU instruction atm. When the CPU is set to Unlimited at maximum speed, when the CPU is set to Limited at 333KHz).
- releaseKeys is called by onKeySetChange.
- onKeySetChange is called by the PSP input method when a key set is changed (requiring release of all pressed keys).
- initEMUkeyboard is the initialisation of the module.
- cleanEMUkeyboard is called after the CPU has been paused for some time (like the emulator pause menu is used or the emulator debugger is processing a breakpoint). This is to make the input not process insanely big input time when the emulator is paused for longer times (1 second in the pause menu means the counter is increased by 1 second, thus it has to execute 1 second worth of input timing all at once (although it's limited to 1us processing in this case)).

Anyone can see why the input is missing keystrokes when inputted very fast (keys are processed at the timings given by the #define)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io