How to configure Power Button in Basilisk II and SheepShaver

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

How to configure Power Button in Basilisk II and SheepShaver

Post 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?
Compact Macs will rule supreme for all eternity! :twisted:
User avatar
adespoton
Forum All-Star
Posts: 3179
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

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

Post 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.
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

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

Post by macplus »

Forgot to mention it, the format in the Keycodes file is like this: <SDL scancode> <Mac keycode>
Compact Macs will rule supreme for all eternity! :twisted:
User avatar
Ronald P. Regensburg
Expert User
Posts: 6456
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

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

Post 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.
User avatar
mabam
Master Emulator
Posts: 334
Joined: Wed Apr 10, 2013 9:32 am

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

Post 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.
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

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

Post 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.
Compact Macs will rule supreme for all eternity! :twisted:
User avatar
Ronald P. Regensburg
Expert User
Posts: 6456
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

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

Post 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.
User avatar
mabam
Master Emulator
Posts: 334
Joined: Wed Apr 10, 2013 9:32 am

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

Post 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.
User avatar
mabam
Master Emulator
Posts: 334
Joined: Wed Apr 10, 2013 9:32 am

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

Post 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?
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

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

Post by macplus »

I'm in a Windows machine. I want to assign the DEL key for it to be the Power button.
Compact Macs will rule supreme for all eternity! :twisted:
User avatar
mabam
Master Emulator
Posts: 334
Joined: Wed Apr 10, 2013 9:32 am

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

Post 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?
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

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

Post by macplus »

Nope, it does not work.
Compact Macs will rule supreme for all eternity! :twisted:
User avatar
mabam
Master Emulator
Posts: 334
Joined: Wed Apr 10, 2013 9:32 am

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

Post 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.
User avatar
macplus
Inquisitive Elf
Posts: 31
Joined: Sat Feb 04, 2017 5:12 am
Location: Argentina

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

Post by macplus »

Don't worry about it, it was just a lost cause.
Compact Macs will rule supreme for all eternity! :twisted:
DLudwig255
Inquisitive Elf
Posts: 26
Joined: Wed Jul 26, 2017 10:50 pm

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

Post 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!
Adam P
Tinkerer
Posts: 67
Joined: Wed Mar 31, 2010 11:55 pm
Location: Maine, U.S.
Contact:

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

Post 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.
Post Reply