Page 1 of 1

How to configure Power Button in Basilisk II and SheepShaver

Posted: Fri Jun 23, 2017 12:10 am
by macplus
As many of you may know, old Macs used to have a Power Button on their keyboards (at least until the iMac came around) that turned off the system. I know that I can configure the Power button to work in both Basilisk II and SheepShaver (cause someone said it made it work) so I looked at the BasiliskII_keycodes file, but I can't figure the file out. Just a bunch of numbers and letters that I don't know their meaning. Can someone help me? Why it has to be so damn difficult to get a button working?

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Fri Jun 23, 2017 4:19 am
by adespoton
The mac power button is hex code 0x66 -- I'm not sure what this is in the keycodes file, but that should help.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Fri Jun 23, 2017 8:04 pm
by macplus
Forgot to mention it, the format in the Keycodes file is like this: <SDL scancode> <Mac keycode>

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sat Jun 24, 2017 11:23 am
by Ronald P. Regensburg
macplus wrote:old Macs used to have a Power Button on their keyboards (at least until the iMac came around) that turned off the system.
Some older machines needed to be turned off physically after shutdown. If I remember well, pressing the power button while the system was still running would bring up the shutdown/sleep/restart dialog, while ctrl-cmd-opt-power would result in shutdown without dialog.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sat Jun 24, 2017 12:27 pm
by mabam
I use a Macally keyboard that still has the power button:
Image
Ronald P. Regensburg wrote:If I remember well, pressing the power button while the system was still running would bring up the shutdown/sleep/restart dialog, while ctrl-cmd-opt-power would result in shutdown without dialog.
I wasn't aware of the latter. Just tested it and it works as advertised. That is, on Mountain Lion.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jun 25, 2017 8:02 am
by macplus
Well, thanks for the info, but that wasn't what I was asking for! Just tell me how to configure the button and that's it. End of story.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jun 25, 2017 10:42 am
by Ronald P. Regensburg
I don't think there is a way to use a power key inside these emulators.

The equivalent of pressing the power key on a real hardware Mac is stopping the emulator.

Stopping the emulator will bring up the restart/shutdown (or restart/sleep/shutdown) dialog.
Stopping the emulator with ctrl-cmd-op pressed will make the emulator shut down without dialog.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jun 25, 2017 11:59 am
by mabam
In my case, when pressing the power button the shutdown dialog appears in both, the host macOS and Mac OS in SheepShaver. I use the standard keycodes file provided with SheepShaver.

You could have an AppleScript or LauchDaemon watch the shutdown dialog in your host macOS. (If you use a bash script to start SheepShaver, e.g. for tap networking, you could make the AppleScript start with SheepShaver automatically.) Once the dialog appears the script checks for SheepShaver being the frontmost application. If it is, the script closes the dialog in your host system. (Not the most beautiful solution, but it should work.)

If the dialog does not also appear in SheepShaver in your case (which isn't entirely clear to me from what I read), you could make the script tell SheepShaver to quit in order to trigger the dialog within SheepShaver.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jun 25, 2017 6:47 pm
by mabam
macplus wrote:Well, thanks for the info, but that wasn't what I was asking for!
The Macally story was just a detour as part of what Ronald wrote was new to me.
But I tend to need a bit longer until I understand what others really mean. So my last post also seems to have missed the point. Sorry.

What I found in the keycodes file is this:

Code: Select all

# Quartz (1:1 translation actually)
#
sdl Quartz
…
127	127	# Power
So the hex code 0x66 mentioned by adespoton seems to translate into 127 for the keycodes file. Is that what you were looking for?

EDIT:
I suppose you're on a Mac. Which key on your keyboard is the one you would like to use as power key for SheepShaver?

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sat Jul 01, 2017 10:30 pm
by macplus
I'm in a Windows machine. I want to assign the DEL key for it to be the Power button.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jul 02, 2017 11:23 am
by mabam
In the "BasiliskII_keycodes" file (for SheepShaver the name should be similar) there are four tables, the last one being titled "Windows". In that last table, scroll to the line

Code: Select all

211	117	# Delete
and change 117 to 127, as that is the code for the power key:

Code: Select all

211	127	# Delete
Does that make the DEL key work as power key for you?

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jul 02, 2017 8:19 pm
by macplus
Nope, it does not work.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Sun Jul 02, 2017 9:39 pm
by mabam
Then I don't know a solution, I'm afraid. This works on a Mac, but I don't know much about Windows.

Maybe there's a Windows tool that could watch your keystrokes when SheepShaver is active and trigger an action to be performed or script to be ran. You could have it tell SheepShaver to quit, as this will make the restart/sleep/shutdown dialog appear in the emulated Mac OS, as Ronald wrote earlier. Maybe there is someone here who could tell you how to do that.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Mon Jul 03, 2017 11:45 pm
by macplus
Don't worry about it, it was just a lost cause.

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Tue Aug 01, 2017 10:37 pm
by DLudwig255
Hi all,

Just as a followup to this, from someone who is trying to get MacsBug working in Basilisk:

The Mac power key is 0x7f (or 127 in decimal), not 0x66. I am unsure what 0x66 is. Possibly an SDL key code or scan code, perhaps? It's not the power key, though. Only when I mapped something to Mac key 0x7f did MacsBug launch (it runs when Mac-side Command + Power is pressed).

I hope this helps!

Re: How to configure Power Button in Basilisk II and SheepSh

Posted: Thu Aug 03, 2017 12:15 pm
by Adam P
I remember being able to configure the power button to F15 for build 142 years ago, and it worked, being able to enter MacsBug via Alt-F15. (The incomplete 68k CPU emulation broke instruction stepping in MacsBug, but having a debugger is better than not having one.)

As far as I know, the problem here is an old one, in the key code reader.

I conducted a test using the 2015 build of Basilisk II. I changed the prefs file to use the key codes file, and set the (forward) Delete key to Power (#127). I typed a few characters into a text box and hit Delete in the middle. The result: "." was typed. Some other keys were incorrectly producing number keys.

It appears the bug where bit #7 is ignored is still present in the code, making the right hand side of the keyboard map to the lower keys in the key code file.