Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard mapping on emulators #226

Open
jgharston opened this issue Dec 26, 2022 · 32 comments
Open

Keyboard mapping on emulators #226

jgharston opened this issue Dec 26, 2022 · 32 comments

Comments

@jgharston
Copy link
Contributor

I don't know how accurately the emulators I'm using match real hardware, so I could do with some real hardware test information. Hours online tracking down documentation hasn't been much help.

With KEGS, keypad-enter and keypad-equals both return '='. Is that the same on real hardware.
KEGS doesn't map anything to the IIgs keypad-clear key, the top-left keypad key, so I don't know what keycode it returns.
On KEGS, Shift-Keypad-key sets the KBDMOD 'KPAD' bit, but doesn't set the KBDMOD 'Shift Key' bit.

I think this is slightly different on KEGS for Android, so I'll check that later.

@bobbimanners
Copy link
Owner

I put out a question on the Apple II Slack to see if any of the emulators handles this properly. The two GS emulators I use (MAME and GSPort) don't simulate the ADB extended function keys as far as I know. I must admit I didn't test with teh keypad on the real GS, just the F-keys.

(KEGS is the parent of GSPlus, and is now being actively maintained again, so it's generally a good one.)

@bobbimanners
Copy link
Owner

Some KEGS info ...
all of the kegs based emulators use the function keys for their own uses. Not sure if it is possible to have the emulators ignore those keys and pass them through. The windows version of GSPlus does not handle the numpad.. Not sure about mame or any of the others though

@bobbimanners
Copy link
Owner

Maybe you want to try an emulator called Crossrunner. Just had someone check, and the ADB function keys are emulated there.

@bobbimanners
Copy link
Owner

bobbimanners commented Dec 26, 2022

Crossrunner:
https://1drv.ms/u/s!Ai7zHzBSA6KTgcgszmU32rvSi6iDnQ?e=3TuslW

Oh and it is for Windows >= 7

@ksherlock
Copy link

ksherlock commented Dec 27, 2022

  • Keypad enter generates a $0d key code.
  • Keypad Clear generates a $1b key code.
  • (in both cases the keypad is set. shift/option/etc modifiers should work as well)

The IIgs numeric keypad (and Apple Extended I) looks like:

C = / *
7 8 9 +
4 5 6 -
1 2 3 En
0   . ter

where C = clear, 0 is double-width, and Enter is double-height.

The platinum IIe is identical, but Clear is called "Esc".

The Apple Extended Keyboard II (and most modern mac-centric keyboards?) have the + and - keys swapped.

Windows looks like:

N / * -
7 8 9 +
4 5 6 +
1 2 3 En
0   . ter

Where N = num lock, + is double height, Enter is double height, and 0 is double width.

I think that's one reason emulators tend to get it wrong.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 27, 2022 via email

@bobbimanners
Copy link
Owner

Not sure what you are intending with the numeric pad but results of testing here on GS + Wombat + USB keyboard are that the function keys work (including with modifiers), but numpad does nothing.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 27, 2022 via email

@bobbimanners
Copy link
Owner

I should run your KBDTEST on the real GS and verify.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 27, 2022 via email

@bobbimanners
Copy link
Owner

KEGS is probably right. If the KEYPAD bit is set (I assume that is the 16 above, without checking), is the keyboard driver supposed to accept it or filter it out if not an f-key? I think my code only allowed f-keys through, but in principle we could have the number pad work also. Right now it doesn't on my setup at least.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 28, 2022 via email

@bobbimanners
Copy link
Owner

Ah I have to play with *FX238 then :)

The Beeb documentation is more centralized and better organized I think. Every generation of Apple II had its own docs (][/}{+, //e, //c and GS) and each has its own quirks. There are also a pile of Apple 'Tech Notes' to clarify various corner cases. The Apple docs are generally pretty good but there are too many of them, and it is hard to know if you are looking in the right place.

For the //e the Technical Reference Manual is the most useful. The GS splits this into a Hardware Reference Manual and a Firmware Reference Manual. The ProDOS Technical Reference manual is also very useful.

Let me know if there is anything in particular you are looking for. I have a folder of handy PDFs!

@jgharston
Copy link
Contributor Author

Something that would be useful is to run in Apple Basic on real hardware:
10 LET A=PEEK(49152)
20 IF A>127 THEN PRINT A-128
30 GOTO 10

And tell me what pressing Ctrl-(~) gives. I can't find if it does (ASC"~"AND31) which is 28 or (ASC""AND31) which is 0. Or even, just ignores Ctrl and gives ` or ~.

@bobbimanners
Copy link
Owner

Will do that right now.

@bobbimanners
Copy link
Owner

On the GS, Ctrl-~ gives me 96 (same as ~ with no modifiers)

@bobbimanners
Copy link
Owner

And I get 48 for keypad 0, same as 0 on the main keyboard.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 28, 2022 via email

@bobbimanners
Copy link
Owner

This is my ROM01 GS, which has a Wombat and a USB keyboard (Mac USB keyboard circa 2005). I don't have an actual ADB keyboard, but the Wombat is equivalent to an ADB Extended keyboard. I can ask other people on the Apple II Slack to test on with various keyboards if need be.

Running your one-liner, I get this for the main keyboard number keys:
30 4
31 4
etc.

And for the keypad, I get:
D 14 (Enter)
18 14 (Clear)
but all the others are dead / filtered out ...

@bobbimanners
Copy link
Owner

A bit more testing info for you from my GS. I was playing with View and noticed that the numpad is working as F-keys, so that is good. However, the arrow keys no longer seem to be working on the GS at least.

@bobbimanners
Copy link
Owner

Had a quick test in MAME using the (simulated) //e, and arrow keys don't work in View there either. However they do work in BBC BASIC both in MAME and on my (real) GS.

@jgharston
Copy link
Contributor Author

Weird. It looks like oddities of emulator implementation. On my desktop, but not my laptop, Applecorn doesn't give anything from Ctrl-digit, but KEGS gives digits from Ctrl-digit, which is a bugger because the Windows UK keyboard driver translates RightAlt into ALT+CTRL.
I'm very reluctant to make any OS changes on my development desktop as it is now my sole remaining machine that will properly go full-screen for PDP11 emulation. That was a frustrating kick in the nuts when my laptop said "Welcome to Windows 7!" and weeks of frustratedly trying to get full-screen code to work again.

@jgharston
Copy link
Contributor Author

I spent yesterday frustatedly trying to get my Android tablet to re-install KEGS and Apple2ix. I think it's near death, and at this rate if it doesn't behave it's going to be percussively punished over the edge of the table.

@bobbimanners
Copy link
Owner

Yes, not sure what the deal is with the arrow keys. They did used to work prior to refactoring, so I guess we can see what it was doing then and compare.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 31, 2022 via email

@bobbimanners
Copy link
Owner

The non functioning arrow keys in View or ISO Pascal editor is reproducible in MAME. Tried it the other day.

@ksherlock
Copy link

ksherlock commented Dec 31, 2022

Apple IIgs, ROM 1, original keyboard (the ADB code to key code translation is handled by the ADB glu code which differs between ROM versions.

Modifier bits always reflect shift/ctrl/etc status.

  • keypad: modifiers don't affect the key code
  • non-letters: control modifiers don't affect the key code. Exceptions:
    • Control-2: key code 0
    • Control-6: keycode 30
    • Control--: keycode 31
    • Control-[: keycode 27
    • Control-]: keycode 29
    • Control-\: keycode 2
  • Everything else works as expected.

Shift doesn't affect the above control codes.

This looks consistent with your keycode chart.

MAME (250) doesn't handle control-6 or control-- correctly. MAME also loses the keypad modifier bit when shift/control are used with keypad entry (eg, shift-keypad 4 generates modifier 1 instead of modifier 17). MAME is switching to proper ADB next month which should fix those problems so I'll try again with it enabled.

@ksherlock
Copy link

I just noticed, numpad clear isn't escape ($1b / 27), it's cancel ($18 / 24).

MAME with ADB emulation seems to get everything correct (or will ; there's a mapping problem with clear/=).

@ksherlock
Copy link

Also, the arrow keys ($7b-$7e) the Macintosh Toolbox diagram are a lie :) The actual ADB codes are $3b-$3e but the macintosh software remaps them to $7b-$7e before giving them to applications. On the Apple II, they're 8, 21, 10, 11; no keypad modifier.

@jgharston
Copy link
Contributor Author

jgharston commented Dec 31, 2022 via email

@jgharston
Copy link
Contributor Author

jgharston commented Dec 31, 2022 via email

@bobbimanners
Copy link
Owner

@jgharston Anything else to do here, or shall I close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants