joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.77k stars 381 forks source link

Request: Set Ctrl-Alt as host key #2026

Closed emendelson closed 3 years ago

emendelson commented 3 years ago

Now that Wengier's work on TTF output makes DOSBox-X far more suitable for applications, I hope it might be possible to add an option to use Ctrl-Alt instead of F11 or F12 as the host key. Applications like WordPerfect use both F11 and F12. For my WordPerfect fork, I change multiple keyboard mappings to MMOD1|MMOD2 and various function keys. But people who use standard DOSBox-X to run applications that use F11 or F12 will find problems, and they're not the kind of user who will know how to manage the mapper interface.

Is there any hope of adding this option? It may be there already, but I can't find it, if so. Thank you.

joncampbell123 commented 3 years ago

Open the mapper and look at the bottom left, where the modifier keys are defined (i.e. Mod1, Mod2, etc. mapped to CTRL, Shift etc). One of them is "Host".

It was added as a modifier key explicitly so that you can redefine it.

emendelson commented 3 years ago

I'm probably being stupid, but I think the mapper only allows me to change the Host key to a standard keyboard key (alpha, function, etc) PLUS (optionally) one or more modifiers. I can't see any way to modify the host key to ONLY "mod1 mod2"

joncampbell123 commented 3 years ago

If that were true, then it would be impossible to implement the default mapping: Host modifier = F12 (F11 on Windows).

joncampbell123 commented 3 years ago

You should be able to select the Host modifier, delete the existing mapping, and add a new one. You don't need to select and modifier keys as an additional requirement.

In fact, I'm not entirely sure the Host key could even work with modifiers. It was intended to be a single host key, VirtualBox style, after all.

emendelson commented 3 years ago

OK, again, I'm sure I'm being stupid, but I'm trying to set the host key to the Ctrl-Alt combination, not to a key that's used by DOS application software. Does your sentence "In fact..." mean that this is impossible? If so, I won't waste any more time on this question!

joncampbell123 commented 3 years ago

Alright, let me clear some things up here.

I originally intended the Host key to be a singular key you can hold to do DOSBox-X mapper shortcuts, in the same way you hold right-CTRL in VirtualBox for it's shortcuts.

However doing a quick test in DOSBox-X, you can attach additional modifiers to the Host key.

In your case, you want CTRL+Alt to be the host key combination. I did a quick test to see if that is possible, and here's how you can do it.

Delete the existing Host key mapping, then click "Add" and tap Alt to make it the Host key. Then down below select mod1. Mod1 by default is Ctrl. You should be able to highlight the "Host" key button only by holding CTRL and Alt at the same time. If I exit out of the mapper, I can bring it up with CTRL+ALT+m.

Note that in this setup, only CTRL+Alt will work (first CTRL, then Alt). Alt+CTRL (first Alt, then CTRL) will not work.

Of course on my system that makes anything mapped to the function keys impossible because on Linux/X11 CTRL+ALT+Fn key changes the virtual terminal away from the X server and brings up the Linux console. :)

grapeli commented 3 years ago

Of course on my system that makes anything mapped to the function keys impossible because on Linux/X11 CTRL+ALT+Fn key changes the virtual terminal away from the X server and brings up the Linux console. :)

You can modify this behavior, disable it (in many ways). https://unix.stackexchange.com/questions/34158/rebinding-disabling-ctrlaltf-virtual-terminal-console-switching

Wengier commented 3 years ago

@joncampbell123 I would suggest to change the default HOST key too, because F11/F12 may not be considered a good one, and they also depend on the operating system (F11 for Windows and F12 otherwise). Ctrl+Alt is a candidate, but mappings like Ctrl+Shift or Alt+Shift can also be considered if they don't cause other problems.

joncampbell123 commented 3 years ago

F12 was chosen because it's widely used by DOS and Windows 3.11 applications, compared to F1-F10 used by DOS programs, or CTRL/ALT/Shift combinations by, say, WordPerfect.

For the smaller set of DOS games or demoscene executables that use F12, it's often a screenshot key, or a debug key, etc.

Wengier commented 3 years ago

In this case I think there can perhaps be a menu option to let users choose a common host key to override the mapper-defined host key, because apparently there does not exist a single host key that is perfect for all DOS executables, and letting the users to do the dynamic switch will likely overcome this problem. Compared with the mapper editor, a menu option will be much easier to operate.

emendelson commented 3 years ago

Delete the existing Host key mapping, then click "Add" and tap Alt to make it the Host key. Then down below select mod1. Mod1 by default is Ctrl. You should be able to highlight the "Host" key button only by holding CTRL and Alt at the same time. If I exit out of the mapper, I can bring it up with CTRL+ALT+m.

Note that in this setup, only CTRL+Alt will work (first CTRL, then Alt). Alt+CTRL (first Alt, then CTRL) will not work.

@joncampbell123 Under Windows 10, I followed this procedure, with the result shown here:

Capture

Unfortunately, pressing Ctrl, then Alt, then a letter does nothing. I hold down left Ctrl, then tap Alt, then M (or C), but nothing happens. I also tried various other sequences, but nothing happens. Even I'm doing something wrong, I wonder whether ordinary non-technical users should be asked to remember that kind of sequence.

joncampbell123 commented 3 years ago

Seems to work here. CTRL+ALT makes the Host key light up to indicate it's being triggered. dosbox-x-althost

emendelson commented 3 years ago

But does it work outside the mapper, when you're at the command line? That's where I tested it. (It also lights up for me in the mapper, but I can't make it work at the command line.)

Wengier commented 3 years ago

@joncampbell123 and @emendelson I have already added a menu group "Select host key" (under "Main") where you can select a host key including Ctrl+Alt, Ctrl+Shift, Alt+Shift, or just use the mapper-defined host key as in previously done in my PR. A new "hostkey" config option is added (in [dosbox] section) so that you can set it from config file. You don't need to mess up with the mapper in such case any more.

emendelson commented 3 years ago

@Wengier - The new code works perfectly; in my code, I changed the hostkey setting to "ctrlalt" (from "mapper"), and this makes it much easier to use DOSBox-X with applications.