FS#1265 - Shortcut for zooming in with "+" not implemented

Attached to Project: OpenTTD
Opened by krase (krase) - Sunday, 30 September 2007, 09:26 GMT
Last edited by Thijs Marinussen (Yexo) - Tuesday, 08 November 2011, 19:55 GMT
Type Patch
Category Interface
Status Closed
Assigned To No-one
Operating System All
Severity High
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


On laptops where there is no numpad it's very inconvenient to zoom in by pressing Shift+F5. The "-" however is implemented so i assume that it has simply been forgotten to implement zooming in with the normal "+" key.
This task depends upon

Closed by  Thijs Marinussen (Yexo)
Tuesday, 08 November 2011, 19:55 GMT
Reason for closing:  Out of date
Additional comments about closing:  Can be done by modifying hotkeys.cfg now
Comment by Remko Bijker (Rubidium) - Saturday, 24 November 2007, 23:26 GMT
It doesn't work on Windows or MacOS.
Comment by t0mt0m (t0mt0m) - Tuesday, 01 April 2008, 07:46 GMT
With the current svn version the '+' and '-' keys are working properly (zoom in/out) on windows (selfcompiled openttd)
Comment by Leif Linse (Zuu) - Wednesday, 16 April 2008, 19:10 GMT
Nightly build (r12717), windows XP: '-' works but not '+' for zooming. Which is a bit annoying to have to click on the zoom-in button in the toolbar.

(when talking about +, = and other keys the non-numpad versions are meant)

So I've taken the patch and by hand implemented it in current svn version of OpenTTD. (the drivers have been reorganized a bit since r11101) I've managed to get the keycode for Windows by simply run synergy[1] in debug level 1 and read the value from the debug window. The keycode for Mac was found after help from Mwa (on IRC). Notable, on mac = and + share the same keycode. While that is ok in this patch, someone in future might be mislead to though that WKC_PLUS and WKC_EQUALS express different keys on all platforms. So an alternative approach could be make the SDL and Win32 driver send WKC_EQUALS when '+' is detected to make it work equal on all platforms.

[1] Synergy is an open source tool to share keyboard(s) and pointing devices attached to one computer between several computers.
Comment by Martin Hauge (wollollo) - Monday, 19 January 2009, 20:00 GMT
This does not work in current (r15152) on my laptop running Arch Linux, nor does it work in 0.6.3
Comment by frosch (frosch) - Monday, 19 January 2009, 20:45 GMT
Ok, let me guess:
1) trunk works for all keyboards where '+' is in fact shift+'='.
2) This patch works for all keyboards where '+' can be typed without shift.
3) Both fail for keyboards where '+' is types with shift+(some key, but not '=') (e.g. from wikipedia: hungarian, swiss and turkish keyboards).

Non-latin keyboards likely fail for both zooming in and out.
Comment by Leif Linse (Zuu) - Tuesday, 20 January 2009, 01:02 GMT
The problem is that OpenTTD requires that the 'correct' combination of meta keys and normal keys should be typed to trigger an action. On some actions there exist fall-through checks for with and without shift. But in most cases there are no fall-through checks for other meta keys such as Alt Gr.

SDL have a feature that when enabled translates meta key + other key to a unicode value of the character typed. It is a bit tricky to use since when the user releases a key, SDL only sends the non-translated value. So when I press AltGr+A SDL gives the unicode value for semicolon (as well as the keycode for the a-key) but then when I releases my a-key the keycode for the a-key is sent. (I use a specialized version of the Svorak keyboard layout) The way OpenTTD works however makes it only see the keycode for a and that altgr was pressed, but not that according to my keyboard layout that becomes a semicolon.

I have dug a little in the keyboard stuff when I made my attempt on configurable hotkeys and from that I think that to 'fix' OpenTTD to work on keyboard layouts that are too far away from the American Qwerty layout will require a lot of effort. OpenTTD hotkeys need to be changed to symbol based instead of being trigged based on a combination of keycode and a meta key.

The keycodes that OpenTTD uses they give the correct A-Z character on dvorak, which has only A and M common with qwerty, but things like AltGr+j for equals sign it does not handle.