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

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 »

Sorry to come back on this. But after a night's sleep I think I have a better idea.

Both names have been in use for years for the same file.
"BasiliskII_keycodes" with BasiliskII and "keycodes" with SheepShaver is true for the emulators distributed for OSX/macOS, but I am not sure which files are used on other platforms or by users who compile/build themselves.

Maybe make it like this for both BasiliskII and SheepShaver:

If "keycodes true" and no keycodefile or path defined
Look for "BasiliskII_keycodes"
If no "BasiliskII_keycodes"
Look for "keycodes"
Last edited by Ronald P. Regensburg on Sat Mar 21, 2020 7:16 am, edited 1 time in total.
Reason:  
kanjitalk755
Apple Corer
Posts: 239
Joined: Thu Nov 09, 2017 12:06 pm

Re: Keycodes file for Windows with latest code?

Post by kanjitalk755 »

I think it is better that BII/SS try to read first is not BasiliskII_keycodes but keycodes.
If you put all of SheepShaver, keycodes and BasiliskII_keycodes in the same folder, I think it is more natural to give priority to 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 »

The average user will not notice the difference, but I agree that it feels more natural to give "keycodes" priority. If ever other file names will circulate (I hope not) those could be added easily.

Edit: Judging by the comments at the top of the file, "keycodes" even was the original file name.
Last edited by Ronald P. Regensburg on Sat Mar 21, 2020 10:30 am, edited 1 time in total.
Reason:  
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.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

kanjitalk755 wrote: Fri Mar 20, 2020 2:10 am
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.
I have a Brazilian Acer Chromebook C731 with ABNT2 type keyboard with the infamous "Alt-Gr" key.

Image

With the default keymap under Linux X11 Basilisk II ("Use Raw Keycodes" disabled):

the Alt-Gr key acts like a COMMAND key.
the Search key (above the Left-Shift) acts like the OPTION key.

the keys: ç ~ ' (ccedilla/tilde/acute on the right side near the L and P keys) does not produce anything.
as you can notice, without the Alt-Gr, I cannot produce the "/" and "?" symbols assigned to the "q" and "w" respectively.

Under X.org running "xev" I get the following keycodes:

Left Alt = 64, Alt_L
Right Alt-Gr = 108, ISO_Level3_Shift
Search Button = 133, Super_L
ç = 47, ccedilla
~ = 48, dead_tilde
' = 34, dead_acute

I see that mapping in /usr/share/X11/xkb/keycodes/evdev

Code: Select all

        <LALT> = 64;
        <LCTL> = 37;
        <SPCE> = 65;
        <RCTL> = 105;
        <RALT> = 108;
        // Microsoft keyboard extra keys
        <LWIN> = 133;
        <RWIN> = 134;
        <COMP> = 135;
        alias <MENU> = <COMP>;
        alias <ALGR> = <RALT>;
	<LVL3> =   92;
Any chance I can get "/" and "?" with my weird ABNT2 keyboard? Alt-Gr + Q or W works fine under Linux.

I tried editing the BasiliskII_keycodes file and assigning the above keycodes to some letter to test the keys but it didn't work. I'm suspecting that the keycode output from XEV is not the "scancode" required by the BasiliskII_keycodes file.

[edit]
After further reading, it isn't. I found that the scancodes are taken from the file /usr/include/SDL2/SDL_scancode.h

Code: Select all

SDL_SCANCODE_RALT=230
What I cannot understand is why "BasiliskII_keycodes" has the line:

Code: Select all

113    55    # Alt Right (-> Command)
113 is not the scancode for Alt Right, it should be 230. What gives? Also, I have a feeling that BasiliskII is not processing my "BasiliskII_keycodes" file when enabling "Use Raw Keycodes". I'm not able to reassign RALT. I read somewhere that Alt-Gr produces TWO scancodes... I am confused already.

I am willing to test things out with the end goal of making Alt-Gr work...
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 »

I do not know which keycodes files you use or tried.

In the newer versions, I added scancode to keycode translations for SDL2 SheepShaver and BasiliskII builds on macOS and Windows hosts. For Linux and X11 those translations are not yet available. Adding those translations may only need a new header.

1. Which BasiliskII version/build do you use? Downloaded or compiled yourself? If compiled yourself, from which source code?

2. Which guest OS version is installed in BasiliskII? An ABNT2 keyboard layout is not available in BasiliskII with System 7.5.5. A Brazilian keyboard layout is available in MacOS 8.1, but it differs from the keyboard in your picture.

3. If you enable "Use Raw Keycodes" and give a path to a keycodes file that does not yet have the correct translations, you should get an error message when starting BasiliskII. Do you get that message and what is the exact text in it?

(Yes, the SDL2 scancode for the Right Alt key is 230, but that applies only to SheepShaver and BasiliskII versions that are built with SDL2. And, yes, on an ISO keyboard the Alt-Gr key produces two scancodes, because the Alt-Gr key equals Control-Alt on an ANSI keyboard.)
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 »

I studied the picture of your keyboard better. It will be difficult, to use your keyboard in BasiliskII. At least you need more modifier keys. If we can assign both Option and Command to keys on your keyboard (will depend on the BasiliskII build), there is still the issue of the missing compatible keyboard layout in BasiliskII. It is possible to map scancodes to keycodes, to keys on the physical keyboard. But the result of a key press is then determined by the keyboard layout chosen in BasiliskII. A regular Brazilian keyboard is very different from your keyboard. A ISO Spanish keyboard could be used. Some keys will work as expected, but other keys will produce different characters. For instance ç is then at the correct position on your keyboard, to the right will be the dead ~, and with shift key it will be the dead ^, but the key to the right of those keys will be the \ .

Is it possible to use a different keyboard with the Chromebook?
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Tue Jun 15, 2021 8:53 am I do not know which keycodes files you use or tried.

In the newer versions, I added scancode to keycode translations for SDL2 SheepShaver and BasiliskII builds on macOS and Windows hosts. For Linux and X11 those translations are not yet available. Adding those translations may only need a new header.

1. Which BasiliskII version/build do you use? Downloaded or compiled yourself? If compiled yourself, from which source code?

2. Which guest OS version is installed in BasiliskII? An ABNT2 keyboard layout is not available in BasiliskII with System 7.5.5. A Brazilian keyboard layout is available in MacOS 8.1, but it differs from the keyboard in your picture.

3. If you enable "Use Raw Keycodes" and give a path to a keycodes file that does not yet have the correct translations, you should get an error message when starting BasiliskII. Do you get that message and what is the exact text in it?

(Yes, the SDL2 scancode for the Right Alt key is 230, but that applies only to SheepShaver and BasiliskII versions that are built with SDL2. And, yes, on an ISO keyboard the Alt-Gr key produces two scancodes, because the Alt-Gr key equals Control-Alt on an ANSI keyboard.)
(1) I am using SDL2 version 2.0.9 that comes pre-packaged with Debian 10 Buster. I am not sure if this older SDL2 is a problem. I could compile v2.0.14 manually and try that too.

I compiled kanjitalk's Basilisk II "git clone" from about a month ago. [note] I just checked the README for kanjitalk's git and noticed he said I should use 2.0.10+. That could be a problem... maybe.

I used the keycode file from the "Basilisk II" sub-forum from Cat7's "BasiliskII-Windows-29-05-2021". You say that Linux and X11 translations are not yet available but the keycode file contains:

Code: Select all

#
# X11 server
# X.Org
#
sdl x11
sdl dga
The X.Org Foundation
9	53	# Esc
67	122	# F1
68	120	# F2
...
37	54	# Ctrl Left
115	58	# Logo Left (-> Option)
64	55	# Alt Left (-> Command)
65	49	# Space
113	55	# Alt Right (-> Command)
116	58	# Logo Right (-> Option)
117	50	# Menu (-> International)
109	54	# Ctrl Right
...
I do suspect that "sdl x11" and "sdl dga" is conflicting with the correct "The X.Org Foundation" driver string. I cannot be 100% sure that this is the string that SDL2 outputs. How can I test that?

(2) Guest OS 7.6.1. I just wanted the "?" and "/" keys... I don't really care for the dead symbols for Portuguese language. I was thinking of assigning the ccedilla key the "/?" key. Can't seem to do it.

(3) No error message. Incidentally there is a keycode file in /usr/local/share/BasiliskII/keycodes which seems to be an old version without the "The X.Org Foundation" signature.
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 existing keycodes files are not yet edited for use with SDL2 builds. We need the header that should be used for Linux/X11 SDL2 builds. The existing Linux/X11 headers are not for SDL2. The content of the keycodes file will be ignored without the needed header.

SDL 2.0.14 should be fine for compiling from kanjitalk source.

If the SDL2 pre-packaged version 2.0.9 that comes with Debian 10 Buster is not build from kanjitalk755 source, I am not sure it can be made to work (sort of) with your keyboard. In kanjitalk755 the possibility to re-map the modifier keys fork was introduced, which could prove to be essential as you have only Control and Alt keys.

A build from kanjitalk would show the error or warning I mentioned above. If the warning would not show, I can easily ask kanjitalk himself what the header for builds from his source should be.

Even when the correct translations are available in the keycode file, it will not in itself solve your issue in BasiliskII because your keyboard layout is not available in BasiliskII.

A key-by-key exchanging the translations in the keycodes file to match your keyboard with the layout chosen in BasiliskII could get most keys produce the characters you expect, but with the use of modifier keys you may get different results from what you would expect. There is no solution for that.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

First of all, a big thank you for your quick replies! This community is amazing.
Ronald P. Regensburg wrote: Wed Jun 16, 2021 8:53 am The existing keycodes files are not yet edited for use with SDL2 builds. We need the header that should be used for Linux/X11 SDL2 builds. The existing Linux/X11 headers are not for SDL2. The content of the keycodes file will be ignored without the needed header.
I'm a little confused here. From what I can understand, we are talking about Linux/X11 development headers, BasiliskII/kanjitalk755 source, and SDL2 source. We are also talking about <X11 keycode> <SDL2 scancode> <Mac keycode>. Is it correct to assume that:

X11 keycode = generated codes from "xmodmap -pke" or "xev"
SDL2 scancode = from SDL2 sources
Mac keycode = Macintosh hardware keycodes (any reference link to this table?)

What you are saying is that the code conversion from X11 to SDL2 is not yet updated in BasiliskII? In other words, just an updated "BasiliskII_keycodes" file?
SDL 2.0.14 should be fine for compiling from kanjitalk source.

If the SDL2 pre-packaged version 2.0.9 that comes with Debian 10 Buster is not built from kanjitalk755 source, I am not sure it can be made to work (sort of) with your keyboard. In kanjitalk755 the possibility to re-map the modifier keys fork was introduced, which could prove to be essential as you have only Control and Alt keys.
I am confused by your use of the phrase "from kanjitalk source". Don't you just compile SDL2 normally with "./configure", "make", and "make install"? Incidentally, I compiled SDL2 v.2.0.14 from source and then re-compiled BasiliskII against it, BUT it crashes with a segmentation fault! I tested the new SDL2 with a sample code and it works. Does SDL2 need something from BasiliskII source for it to work?

Note that with the pre-packaged SDL version 2.0.9 that comes with Debian 10 Buster, compiling BasiliskII works and runs just fine! What then does it mean "is not build from kanjitalk755 source"?
A build from kanjitalk would show the error or warning I mentioned above. If the warning would not show, I can easily ask kanjitalk himself what the header for builds from his source should be.
1. I need to figure out why the keycode file isn't being loaded and processed. I guess I have to write some code to determine the driver string if that's the condition.
2. Please do ask kanjitalk, if any BasiliskII headers are required for SDL2 compilation and what needs to be updated for BasiliskII keycode to be able to work with SDL2

I feel that this update is not a big project...
Even when the correct translations are available in the keycode file, it will not in itself solve your issue in BasiliskII because your keyboard layout is not available in BasiliskII.

A key-by-key exchanging the translations in the keycodes file to match your keyboard with the layout chosen in BasiliskII could get most keys produce the characters you expect, but with the use of modifier keys you may get different results from what you would expect. There is no solution for that.
Indeed, if Brazilian ABNT2 keymap is not available for Mac OS 7.6.1 then it won't run out-of-the-box. I find it curious that in the 90's there weren't any Portuguese keymaps available for 7.6.1. They did sell the first Mac Performas (PowerPC) in Brazil.

BUT as I said, I just want BasiliskII to produce standard US keyboard characters without the need for modifier keys. I just need to remap missing keys (?/) to the unused keys (ccedilla). In this manner, in X11 mode, I get my normal ABNT2 keys and inside BasiliskII I get normal US remapped keys.

Anyways, until this SDL2 update is done, I am going to buy some US keyboard stickers and "convert" my ABNT2 keyboard to work as a US keyboard.
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 »

It appears difficult to make myself understandable. I'l try again.

1. A BasiliskII build compiled with SDL2 will generate SDL2 scancodes.

2. Builds from kanjitalk755 contain features that are not available on builds from other sources, some of which (like the possibility to re-map modifier keys) may be needed.
(kanjitalk755/macemu master branch is at this moment 587 commits ahead and 2 commits behind the original cebix/macemu master.)

3. The keycodes files translate (SDL2) scancodes to mac keycodes. The mac keycodes do not refer to characters, but to the physical locations of keys on the keyboard. The characters (or other functions) shown with the keycodes in the keycodes files are the characters that will be produced by the various keys on an US English keyboard. The keyboard layout chosen in the MacOS in BasiliskII will determine which characters (or other functions) are produced by which physical keys.

4. The Brazilian keyboard layout in MacOS comes closest to your keyboard. It is available in MacOS 8.1 and in MacOS 9.0.4. You use MacOS 7.6.1? If it is not available there, a copy from one of those other OS versions can probably be installed in the System file in 7.6.1.

5. I will ask kanjitalk755 for the header needed in the keycodes file with the SDL2 scancodes to mac keycodes translations. I am not entirely certain that the header needed for his SDL2 port is the same as the header needed for SDL2 ports by others.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

ebann wrote: Wed Jun 16, 2021 3:30 pm Incidentally, I compiled SDL2 v.2.0.14 from source and then re-compiled BasiliskII against it, BUT it crashes with a segmentation fault! I tested the new SDL2 with a sample code and it works. Does SDL2 need something from BasiliskII source for it to work?
I found out why it crashed... I was missing a few development packages, namely:

Code: Select all

$ sudo apt-get install build-essential xorg-dev libudev-dev libts-dev libgl1-mesa-dev libglu1-mesa-dev libasound2-dev libpulse-dev libopenal-dev libogg-dev libvorbis-dev libaudiofile-dev libpng12-dev libfreetype6-dev libusb-dev libdbus-1-dev zlib1g-dev libdirectfb-dev
I have SDL2 version 2.0.14 up and running. BasiliskII works fine. Will do some testing and report back if anything new. I wrote another script that fully automates the Debian Linux installation/configuration plus the compilation of SDL2 and BasiliskII on my specific Chromebook (Acer C731).
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Wed Jun 16, 2021 4:17 pm 4. The Brazilian keyboard layout in MacOS comes closest to your keyboard. It is available in MacOS 8.1 and in MacOS 9.0.4. You use MacOS 7.6.1? If it is not available there, a copy from one of those other OS versions can probably be installed in the System file in 7.6.1.
Is there a gentle soul willing to pull out the Brazilian or Portuguese keyboard layout files from their Mac OS 8.1/9.0.4 so that I can test SDL2 keycodes/scancodes?

Thanks a bunch!
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 needed header is "sdl x11".

Download this archive: http://ronaldpr.home.xs4all.nl/emaculat ... 1_test.zip

Edit: You can use the Brazilian keyboard file in this download, but do not use the keycodes file yet. It appears that the sdl x11 header was already in use in the file for other translations. I will return here after I consulted kanjitalk755 again.

It contains two files:

1. BasiliskII_keycodes
Translation from SDL2 scancodes is identical for all host systems.
I added the header to the translations for Windows. In Windows the middle modifier key cannot be used and on your keyboard the middle modifier key is missing. So the special modifications for the modifier keys will be the same:
- Left control key can be used as the Mac Option key
- Left Alt key can be used as the Mac Command key
- Right Alt key can (probably) be used as the Mac Option Key
- Right Control key can be used as the Mac Control key
See notes below

2. Brazilian keyboard.img
Add that disk image to the volumes list for BasiliskII.
From the mounted image drag the file "Brazilian" onto the System Folder
You will be asked to install the file in System, allow installation.
The Brazilian keyboard layout will be available as a choice in the Keyboard control panel

Note: 1 The edited keycodes file will work with a BasiliskII build compiled from kanjitalk755 fork. It will only work in builds from other forks if in the source code keycode_init() in video_sdl2.cpp happens to be the same as in kanjitalk755 fork.

Note 2: The possibility to re-map modifier keys in the keycodes file was introduced in kanjitalk755 fork. It may or may not work in builds from other forks. If it does not work, you will have no key that can work as Option key in BasiliskII.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Thu Jun 17, 2021 8:23 am 2. Brazilian keyboard.img
Add that disk image to the volumes list for BasiliskII.
From the mounted image drag the file "Brazilian" onto the System Folder
You will be asked to install the file in System, allow installation.
The Brazilian keyboard layout will be available as a choice in the Keyboard control panel
Thanks Ronald!

I tested the "Brazilian" keyboard map and this is what I discovered: it's the Apple version of the Portuguese keyboard, I believe before the standardization to ABNT and then ABNT2. The picture below is from Apple's website.

Image

The main difference between ABNT and ABNT2 is shown below, notice the "new" AltGr key!

Image

I don't think "activating" the AltGr key is going to work as a modifier key. It would be quicker to convert to US QWERTY with this:

Image

Let me know how else I can help because I am still trying to understand all these keyboard code translations. If I can get my ABNT2 keyboard working then all other languages should be a similar process.
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 »

In the keycodes file in the download, remove the sdl x11 header from these lines:

Code: Select all

#
sdl x11
sdl dga
The X.Org Foundation
change to

Code: Select all

#
sdl dga
The X.Org Foundation
Then the keycodes file should provide the correct translations for a SDL2 build.
(Both SDL1 and SDL2 translations were in the file with the same header, thus preventing the keycodes file to work properly.)

In BasiliskII you can then choose your keyboard layout in the Keyboard control panel, whether Brazilian or US English or any other available layout. The Key Caps application (available from the Apple menu) will show the active keyboard layout. You can check the layout in Key Caps by pressing keys and see the result.
(I do not know if you can select multiple layouts in MacOS 7.6.1. If so, you can select between the choices from a menu at the right side of the menu bar that will show the choice with a flag image.)

If you use a BasiliskII build from kanjitalk755 source (I am not sure about builds from other forks) the modifier keys will be mapped like this.
- Left control key can be used as the Mac Option key
- Left Alt key can be used as the Mac Command key
- Right Alt key can (possibly) be used as the Mac Option Key
- Right Control key can be used as the Mac Control key

This is done because otherwise you would not have an option key and it is needed to produce many characters that are not available with just the letter keys and the shift key. And in MacOS the Command key is more important than the Control key. You can also check the result of different key combinations in the Key Caps application.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Fri Jun 18, 2021 8:03 am ...
In BasiliskII you can then choose your keyboard layout in the Keyboard control panel, whether Brazilian or US English or any other available layout. The Key Caps application (available from the Apple menu) will show the active keyboard layout. You can check the layout in Key Caps by pressing keys and see the result.
(I do not know if you can select multiple layouts in MacOS 7.6.1. If so, you can select between the choices from a menu at the right side of the menu bar that will show the choice with a flag image.)
Key Caps is a really nice tool, thanks for the tip!
If you use a BasiliskII build from kanjitalk755 source (I am not sure about builds from other forks) the modifier keys will be mapped like this.
- Left control key can be used as the Mac Option key
- Left Alt key can be used as the Mac Command key
- Right Alt key can (possibly) be used as the Mac Option Key
- Right Control key can be used as the Mac Control key

This is done because otherwise you would not have an option key and it is needed to produce many characters that are not available with just the letter keys and the shift key. And in MacOS the Command key is more important than the Control key. You can also check the result of different key combinations in the Key Caps application.
I did use kanjitalk755 source. The remaps are as follows on my Chromebook:

Chrome SEARCH = Mac Option
LEFT_ALT = Mac Option
RIGHT_ALTGR = Mac Command

A few keys don't work, such as:

~^ key (to the right of CCEDILLA key)
the key to the right of the letter P key, A and O letter with the line underneath
& (SHIFT-6)
the upper-leftmost key (PLUS_MINUS and PARAGRAPH_SYMBOL) is the same as the <> key (left of the letter Z).
ALT_GR works as RIGHT_ALT now
need to convert Chrome SEARCH key to CAPS_LOCK

I can say that the keycode file almost works 100%. How can I fix the remaining broken keys?

PS. Even if I make it work 100%, it will require "relabeling" a lot of the keys to match Apple's Brazilian keyboard layout. I hope they sell this kind of key stickers...

PS2. I just realized that this keyboard is a Portuguese keymap from Portugal PT-PT instead of Brazil PT-BR. I wonder why the file was named "Brazilian" then??? Unless Brazil didn't have ABNT/ABNT2 when Apple sold them here.

I found this sticker set for PT-PT and should work very nicely with my Chromebook. Prettier stickers than the US I just ordered :mrgreen:

Image
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 keycodes file works fine for all standard ISO and ANSI keyboards for any language. The problem is that the ChromeBook has its own non-standard keyboard.

Which keyboard layout do you use now in BasiliskII?

I will see if I can suggest a few changes, but not all will work. I doubt that the Chrome Search key can be made into a CapsLock key. I will need for each key that does not work as expected, which key or keys appear selected in Key Caps and which results are shown in Key Caps when that key is pressed.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Sat Jun 19, 2021 9:27 am The keycodes file works fine for all standard ISO and ANSI keyboards for any language. The problem is that the Chromebook has its own non-standard keyboard.

Which keyboard layout do you use now in BasiliskII?

I will see if I can suggest a few changes, but not all will work. I doubt that the Chrome Search key can be made into a CapsLock key. I will need for each key that does not work as expected, which key or keys appear selected in Key Caps and which results are shown in Key Caps when that key is pressed.
I'm testing both US and Brazilian (or is it Portuguese?) keyboard layouts.

I solved the Search=CapsLock problem at the X windows level for "pc105" keymap and US layout in Basilisk:

Code: Select all

nano /usr/share/X11/xkb/symbols/pc
Find and replace this line as so:

Code: Select all

key <LWIN> { [Caps_Lock] };
Originally <LWIN> was mapped to [Super_L]. Clear the xkb settings cache:

Code: Select all

sudo rm -rf /var/lib/xkb/*
Reboot your laptop.

I will test this edit with the "abnt2" (PT-BR) and Portuguese (PT-PT) files at the X level and see how that translates into Basilisk.

PS. This edit only works at the X windows level. It will not work on a text terminal. I check to see how to do that as well.
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 Brazilian keyboard layout I provided is for a Brazilian Portugese keyboard. It may differ from a European Portugese keyboard, like there are differences between US English, British English, Canadian English, and Australian English keyboards.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Sat Jun 19, 2021 4:55 pm The Brazilian keyboard layout I provided is for a Brazilian Portugese keyboard. It may differ from a European Portugese keyboard, like there are differences between US English, British English, Canadian English, and Australian English keyboards.
I managed to get everything working with the "Brazilian" keyboard layout you gave me and the included BasiliskII_keycodes file.

The secret lies in the Linux keyboard configuration in "/etc/default/keyboard":

XKBMODEL="pc105"
XKBLAYOUT="pt"
XKBVARIANT="mac_nodeadkeys"
XKBOPTIONS=""
BACKSPACE=""

With the above Search=CapsLock edit, all the keys translate correctly in Basilisk using the "Brazilian" keyboard layout. The tiny trick was to choose "no dead-keys" so that Mac OS 7.6.1 can process the modifier process itself.

Let it be known that the translation it produces is the PT-PT as per Apple's Portuguese keyboard which is from Portugal. Brazil uses a different layout and I confess that I have never seen a Brazilian styled ABNT or ABNT2 keyboard layout with their products.

If there is indeed another file called "Portuguese" keyboard layout for European Portuguese, I'd like to test it out as well!

Image
Last edited by ebann on Sat Jun 19, 2021 9:10 pm, edited 1 time in total.
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 »

In Key Caps Mac dead keys are indicated with a grey or dotted border around the key. For instance the tilde to the right of the ç. That key followed by the n will produce ñ. And that same key with the shift key followed by a i will produce î.
ebann
Tinkerer
Posts: 52
Joined: Tue Jan 19, 2021 10:26 pm

Re: Keycodes file for Windows with latest code?

Post by ebann »

Ronald P. Regensburg wrote: Sat Jun 19, 2021 7:26 pm In Key Caps Mac dead keys are indicated with a grey or dotted border around the key. For instance the tilde to the right of the ç. That key followed by the n will produce ñ. And that same key with the shift key followed by a i will produce î.
Got it! I just had to disable dead keys on the Linux system because it interferes with Mac OS 7.6.1 dead keys mechanism, i.e., the keys wouldn't work.

Also, there is a mistake in your BasiliskII_keycodes file. In the SDL2 for X11: (1) the keycode for COMMAND and OPTION are inverted. Should be OPTION=55 and COMMAND=58., (2) the scancode 53 for the apostrophe key (upper left key next to the 1 key) is incorrectly marked the same as the International keycode 50. The apostrophe key should be set to keycode 10.

Code: Select all

...
53    10     # apostrophe
...
224    54    # L_CTRL = Control
#226    55   # Disable L_ALT
230    58    # R_ALT = Command
228    55    # R_CTRL = Option
...
In this manner, my Chromebook works as follows:

Search_Key = Caps Lock
L_CTRL = Control key
L_ALT = Alt key (i3 windows manager intercepts this "mod" key; also assigned Apple Command key from somewhere else)
R_ALT = Command key
R_CTRL = Option key

I can attest that the keycode file works as intended for SDL2 under Linux X11. :cool: Great job Ronald and Kanjitalk775!

Any chance there exist a "Brazilian ABNT2" keyboard layout file out there? Maybe I can hack one... I've seen a ResEdit article about it: https://eclecticlight.co/2016/06/04/the ... resources/

NOTE: I did the ResEdit thing and BEHOLD... I managed to hack the "Brazilian" keyboard layout into a "Brazilian ABNT2" keyboard layout! Everything works without needing to apply any keyboard stickers! :mrgreen:

The file is here: https://github.com/ekbann/chromebook-ba ... n/keyboard
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 »

ebann wrote: Sat Jun 19, 2021 9:27 pmAlso, there is a mistake in your BasiliskII_keycodes file. In the SDL2 for X11: (1) the keycode for COMMAND and OPTION are inverted. Should be OPTION=55 and COMMAND=58.
No, the Mac keycode for Option is 58 and the Mac keycode for Command is 55. Maybe you mixed up the names for the Mac modifier keys?

Apparently your Left Alt key cannot be used because it is intercepted by the host.

Your mapping is now:

Left Control --> Mac Control
Left Alt (cannot be used in the emulator)

Right Alt --> Mac Option
Right Control --> Mac Command

So, pressing the Right Alt key you should see these keys highlighted in Key Caps:
Control | Option | Command | Space bar | Command | Option | Control

and pressing the Right Control key these keys:
Control | Option | Command | Space bar | Command | Option | Control

(2) the scancode 53 for the apostrophe key (upper left key next to the 1 key) is incorrectly marked the same as the International keycode 50. The apostrophe key should be set to keycode 10.
Yes, you are right. I will correct that. I do not know how it got there as most was simply copied from the sdl cocoa list where the translation is correctly 10.

NOTE: I did the ResEdit thing and BEHOLD... I managed to hack the "Brazilian" keyboard layout into a "Brazilian ABNT2" keyboard layout! Everything works without needing to apply any keyboard stickers! :mrgreen:
Nice!

Extensive documentation about SD2 scancodes and differences between ISO and ANSI keyboards and different language layouts can be found here: https://www.libsdl.org/tmp/SDL/include/SDL_scancode.h
No mention of ABNT2 keyboards, but it seems similar to ISO keyboards as it has the "Non-US Backslash" key in the lower left corner.
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 »

And here about Portuguese and Brazilian ABNT/ABNT2 keyboards: https://en.wikipedia.org/wiki/Portugues ... ard_layout
Your Chromebook keyboard differs in that it is missing the Logo keys on a regular ABNT/ABNT2 keyboard.
Post Reply