Keycodes file for Windows with latest code?

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Keycodes file for Windows with latest code?

Post by emendelson »

Thanks to some superb recent work by rakslice, it's now possible to build SheepShaver for Windows with JIT enabled; thanks also to kanjitalk755 for incorporating rakslice's code into his own source.

I had no trouble building SheepShaver for Windows in MinGW with msys 1.0, in a setup where I had already built SDL2. The only trouble I have when launching SheepShaver is an error message "Cannot find vendor 'windows' in keycode translation file BasiliskII_keycodes.

I fixed this by copying BasiliskII_keycodes from the BasiliskII source into my SheepShaver folder and adding this line at line 361 of the file, above the line "sdl Quartz":

Code: Select all

sdl windows
This seems to produce the right keycodes for a US English system, but I doubt it will work elsewhere.

Does anyone know enough about these things to provide a fix that can be added to the code base?
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

New keycodes files were made available by me that will also work for other than qwerty keyboard lay-outs with SDL2 builds of BasiliskII and SheepShaver for Windows from the current kanjitalk755 source.

The files are included in the downloads of my latest BasiliskII and SheepShaver builds for macOS. The content of both files is identical, but the file names are different to conform to the exsisting file names used with the emulators, "keycodes" and "BasiliskII_keycodes" respectively.

Issues with using the Windows logo key for Mac modifier keys and a problem with using the Windows Alt Right (Alt Gr) key made it necessary to map the keys on a Windows keyboard to the Mac modifier keys as follows:

Ctrl Left --> Option
(Logo Left)
Alt Left --> Command
Space
Alt Right --> Option
(Logo Right)
(Menu --> International)
Ctrl Right --> Control
Last edited by Ronald P. Regensburg on Wed Mar 18, 2020 4:55 pm, edited 2 times in total.
Reason:  
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

Unfortunately, the new files do not work correctly.

The latest SheepShaver macOS Zip that you posted has a keycodes file named "keycodes".

Running the SheepShaver for Windows that I built today:

If the prefs do NOT list a keycodefile entry, and the file "keycodes" is present, then SheepShaver for Windows (newly built) gives an error message saying that it cannot find the file BasiliskII_keycodes.

If I rename "keycodes" to "BasiliskII_keycodes", then SheepShaver loads correctly, but the upper-left key on US keyboards (~/`) types the wrong keys (the section mark, etc.)

Is there anyone testing under Windows who can help to sort this out? My build (identical to kanjitalk755's current code except for a different icon) may be found here:

http://www.columbia.edu/~em36/SheepShav ... ar2020.zip

SheepShaver is codesigned, and should run without difficulty.

EDIT: Wait - here is a fix for the upper-left key on the US keyboard. In the Windows (SDL2) section of the file, instead of

Code: Select all

53 10  # `
read

Code: Select all

52 10 # `
That fixes this key, at least.

However, CapsLock doesn't have any effect. I remember that there was a fix for this under macOS, but it doesn't seem to be working for Windows, unless I'm doing something wrong.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

The codes for BasiliskII and SheepShaver should be the same.
We had extensive testing with a Windows version of BasiliskII here: https://www.emaculation.com/forum/viewt ... =6&t=10515
You may have missed it.

The problem that BasiliskII, and apparently also SheepShaver, for Windows asks for a file BasiliskII_keycodes in the same folder as the emulator, must be a recently introduced bug in kanjitalk775 source. Unlike before, and unlike in the macOS versions, it is not possible to use a different file name or path.
Wait - here is a fix for the upper-left key on the US keyboard. In the Windows (SDL2) section of the file, instead of
I will look into that. Not all keyboards use that key for '. There are differences between ISO keyboards and ANSI keyboards. Generally, ANSI keyboards are used in the USA and ISO keyboards are used in the rest of the world.

Edit:
However, CapsLock doesn't have any effect. I remember that there was a fix for this under macOS, but it doesn't seem to be working for Windows, unless I'm doing something wrong.
I am not sure we tested that in BasiliskII for Windows.
Last edited by Ronald P. Regensburg on Wed Mar 18, 2020 6:38 pm, edited 1 time in total.
Reason:  
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

I built BasiliskII with current code. CapsLock doesn't work in the latest version, although it did work in my build from last September.

I'm working from a new system, and I made/installed the current SDL2 code in MinGW before building SS and BII. I wonder if that has anything to do with the problem?
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

Using scancode 52 is not right. 52 is the apostrophe, it should be on your keyboard between the ; key and the \ key.

53 is the key at the top left. On US ISO and ANSI Windows keyboards and on US ANSI Mac keyboards that key produces the grave accent (`) and with shift key the tilde (~). In US ISO Mac keyboards that key at the top left produces the section sign (§) and with shift the plus-minus sign (±). But ISO keyboards are rare in the US.

Code: Select all

SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI
                              *   and ISO keyboards). Produces GRAVE ACCENT and
                              *   TILDE in a US Windows layout and in US and UK
                              *   Mac layouts on ANSI keyboards, GRAVE ACCENT
                              *   and NOT SIGN in a UK Windows layout, SECTION
                              *   SIGN and PLUS-MINUS SIGN in US and UK Mac
                              *   layouts on ISO keyboards, SECTION SIGN and
                              *   DEGREE SIGN in a Swiss German layout (Mac:
                              *   only on ISO keyboards), CIRCUMFLEX ACCENT and
                              *   DEGREE SIGN in a German layout (Mac: only on
                              *   ISO keyboards), SUPERSCRIPT TWO and TILDE in a
                              *   French Windows layout, COMMERCIAL AT and
                              *   NUMBER SIGN in a French Mac layout on ISO
                              *   keyboards, and LESS-THAN SIGN and GREATER-THAN
                              *   SIGN in a Swiss German, German, or French Mac
                              *   layout on ANSI keyboards.
                              */
I think that for most Windows keyboards the issue can be solved by changing the original line

Code: Select all

53	10	# `
to

Code: Select all

53	50	# `
Can you confirm that?
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

emendelson wrote:I built BasiliskII with current code. CapsLock doesn't work in the latest version, although it did work in my build from last September.

I'm working from a new system, and I made/installed the current SDL2 code in MinGW before building SS and BII. I wonder if that has anything to do with the problem?
I don't think so. There are several changes in the source since september. One of the changes is a different handling of key mapping such that you can now set in the keycodes file which keys on your keyboard activate which Mac modifier keys in the emulator.

In the discussion I referred to above, we already found at least one bug with that. The caps lock not working could also be one, but it may also be an incorrect mapping in the keycodes file. I will check that first.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

Ronald P. Regensburg wrote:Using scancode 52 is not right. 52 is the apostrophe, it should be on your keyboard between the ; key and the \ key.

I think that for most Windows keyboards the issue can be solved by changing the original line

Code: Select all

53	10	# `
to

Code: Select all

53	50	# `
Can you confirm that?
Yes, that is correct. I wasn't looking closely enough.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

Ronald P. Regensburg wrote:In the discussion I referred to above, we already found at least one bug with that. The caps lock not working could also be one, but it may also be an incorrect mapping in the keycodes file. I will check that first.
Thank you. CapsLock definitely does not work in either BII or SS with the current code. This problem occurs even when no keycodes file is present, so it seems to be a problem in the source code, not in the keycodes file.

Also, kanjitalk755, SheepShaver gives an error message when it cannot find BasiliskII_keycodes at startup. This probably should not happen.
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

Ronald P. Regensburg wrote:The problem that BasiliskII, and apparently also SheepShaver, for Windows asks for a file BasiliskII_keycodes in the same folder as the emulator, must be a recently introduced bug in kanjitalk775 source. Unlike before, and unlike in the macOS versions, it is not possible to use a different file name or path.
I have changed SheepShaver's default keycodes file name to "SheepShaver_keycodes".
And I confirmed keycodes file path can be customized by prefs item "keycodefile".
emendelson wrote:I built BasiliskII with current code. CapsLock doesn't work in the latest version, although it did work in my build from last September.
Fixed.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

kanjitalk755 wrote:
Ronald P. Regensburg wrote:The problem that BasiliskII, and apparently also SheepShaver, for Windows asks for a file BasiliskII_keycodes in the same folder as the emulator, must be a recently introduced bug in kanjitalk775 source. Unlike before, and unlike in the macOS versions, it is not possible to use a different file name or path.
I have changed SheepShaver's default keycodes file name to "SheepShaver_keycodes".
And I confirmed keycodes file path can be customized by prefs item "keycodefile".
emendelson wrote:I built BasiliskII with current code. CapsLock doesn't work in the latest version, although it did work in my build from last September.
Fixed.
Tested in BasiliskII and working. Thank you, kanjitalk755! (Will build SheepShaver tomorrow.)
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

kanjitalk755 wrote:I have changed SheepShaver's default keycodes file name to "SheepShaver_keycodes".
That may cause problems for people upgrading to newer builds, at least in macOS. As long as I can remember, the keycodes file distributed with SheepShaver for macOS was named "keycodes".
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

While we are correcting possible bugs: There is an issue in BasiliskII for Windows (and I expect also in SheepShaver for Windows) with assigning Mac modifier keys to the Right Alt (Alt Gr) key. Not only the assigned modifier key will be activated, but also the Control key. For instance: Assigning the Mac Command key to the Alt Gr key will activate the Command key and the Control key together. Or assigning the Mac Option key to the Alt Gr key will activate the Option key and the Control key together. Assigning modifier keys to the Left Alt key and to the the Control keys works as expected. (The Windows logo keys are unusable in the emulator because they are hijacked for functions in Windows.)

As a workaround, in the current BasiliskII_keycodes file the Option key is assigned to both the Alt Gr key and the Left Control key. (With the Command key assigned to the Left Alt key.)
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

Ronald P. Regensburg wrote:That may cause problems for people upgrading to newer builds, at least in macOS. As long as I can remember, the keycodes file distributed with SheepShaver for macOS was named "keycodes".
It was "BasiliskII_keycodes" from the beginning of SDL2 version.
(See the git log of video_sdl2.cpp)
Ronald P. Regensburg wrote:While we are correcting possible bugs:...
Upload BasiliskII_keycodes the problem occurs and write the observed and expected behavior.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

kanjitalk755 wrote:It was "BasiliskII_keycodes" from the beginning of SDL2 version.
(See the git log of video_sdl2.cpp)
I was talking about SheepShaver for macOS. There the file people used was always just "keycodes".
Upload BasiliskII_keycodes the problem occurs and write the observed and expected behavior.
I do not have a Windows machine myself. I will search the discussion where the issue was found for the correct description: https://www.emaculation.com/forum/viewt ... =6&t=10515
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

For simplicity, I left only the "sdl windows" list in these files.

http://ronaldpr.home.xs4all.nl/sheepsha ... keycodes_2
This was the original file as first made by me.
- The Logo keys activated the Option key in the emulator as expected, but appeared to be useless by the way Windows intercepts any combo with these keys.
- The Left Alt key activated the Command key in the emulator as expected.
- The Right Alt (Alt Gr) key activated both Command and Control keys in the emulator and was thus useless.

http://ronaldpr.home.xs4all.nl/sheepsha ... keycodes_3
Here I tried to make the Right Alt key the Option key
- However, now the Right Alt key activated both Option and Control keys in the emulator, also useless.

http://ronaldpr.home.xs4all.nl/sheepsha ... keycodes_4
- By accident we found that if both the Left Control key and the Right Alt key were mapped to the Mac Option key, both keys each activated only the Option key in the emulator and could be used as Option key.
- The Left Alt key still worked as Command key in the emulator and the Right Control key still worked as Control key in the emulator.

In the interim final version I commented out the lines with the Logo keys.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

I don't have a keyboard with AltGr available here, so there's probably no point in my testing these, unless you have a specific request. I'll be glad to give it a try if there's something specific you wanted checked.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

Don't all Windows keyboards have an Alt key on both sides?

Edit: I posted the above information with the three keycodes files because kanjitalk755 asked for it to be able to investigate the reported problem with the Right Alt key.
Last edited by Ronald P. Regensburg on Thu Mar 19, 2020 8:20 pm, edited 2 times in total.
Reason:  
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: Keycodes file for Windows with latest code?

Post by emendelson »

Ronald P. Regensburg wrote:Don't all Windows keyboards have an Alt key on both sides?

Edit: I posted the above information with the three keycodes files because kanjitalk755 asked for it to be able to investigate the reported problem with the Right Alt key.
Yes, all Windows keyboards have a a LeftAlt and a RightAlt key. On US keyboards, these are identical. On non-US keyboards, the right Alt is called AltGr, and does the same thing that Ctrl-Alt does on US keyboards.

About the keycodes file, I'm still not entirely clear. Is the idea that your file:

http://ronaldpr.home.xs4all.nl/sheepsha ... keycodes_4

should take the place of the last section of the BasiliskII_keycodes file in your recent downloads (and that "sdl cocoa" should be added when replacing the last section of BasiliskII_keycodes with BasiliskII_keycodes_4)? If this is NOT the case, could you let us know?
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

Ronald P. Regensburg wrote:I was talking about SheepShaver for macOS. There the file people used was always just "keycodes".
I tested SheepShaver 4 May 2019 version from downloads page.
  • Defined "keycodes true"
    Undefined "keycodefile"
As a result, both keycodes and BasiliskII_keycodes were invalid.
In the latest source, SheepShaver_keycodes is valid.

About BasiliskII_keycodes_2,3,4:
I tested BasiliskII under Windows10 with Japanese keyboard (no AltGr), all of the keycodefile work expectedly.

I guess AltGr key issues scancodes both 224 and 230 sequentially.
In this case, all phenomena can be explained.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

emendelson wrote:On non-US keyboards, the right Alt is called AltGr, and does the same thing that Ctrl-Alt does on US keyboards.
kanjitalk755 wrote:I guess AltGr key issues scancodes both 224 and 230 sequentially.
In this case, all phenomena can be explained.
Yes, that explains the issue we encountered.

The version 4 keycodes file will then work identically on both US and non-US keyboards.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

kanjitalk755 wrote:In the latest source, SheepShaver_keycodes is valid.
In my first tests it did not work as I suppose is intended.

I built SheepShaver from current source.
In the same folder with SheepShaver all three keycodes files
keycodes
SheepShaver_keycodes
BasiliskII_keycodes

If defined, all three files work. But with keycodes true defined and no keycodefile defined, it does not work. Just like before.

I then deleted the line keycodefile from the prefs file. And then, indeed, it worked.

But normally there will always be that line. With no keycodefile defined it reads "keycodefile " (with a space).

All existing users use a file "keycodes". If I would distribute new "SheepShaver_keycodes" with new SheepShaver builds, those users will need to change their preferences settings. I think it is better to use the generally used name "keycodes" as default.
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

Then, in order to make simple specifications, both BII and SS common:
If ("keycodefile" is undefined) or ("keycodefile" is defined and file path is undefined), use "keycodes".

Is it OK?
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Keycodes file for Windows with latest code?

Post by Ronald P. Regensburg »

Although the content of the files is identical, I think it is better to use the names that have been used for as long as I remember. (I started using BasiliskII and SheepShaver some 15 years ago.)
For BasiliskII: "BasiliskII_keycodes"
For SheepShaver: "keycodes"
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

Changed to the file name you suggested.
Post Reply