News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Custom keyboard shortcuts (override default keys)

Started by Isaac Eiland-Hall, January 21, 2016, 03:08:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Isaac Eiland-Hall

This is probably  more work than anyone wishes to do, but I thought I'd throw it out there anyway just in case. :)

I have long wished I could override the default shortcut keys in Simutrans. The vast majority of them I never use, and there's no shortcuts for the things I wish I could have.

As for the method: Probably supplying a keys.conf. Maybe the easiest structure would be to mirror the structure used to build the in-game menus, where you can specify the item associated with the key (because in a best-case scenario, it'd be nice to be able to supply a keys.conf globally and/or for each pak, where one could map out commands or menu items to a key).

So, like, in my case, for pak128 I'd map out a key for a particular bus stop, the raise/lower tile commands (not the same as u/d, but the ones that affect the single tile), among others. Some keys are already handy - 's' for the last street; but I'd map specific roads to specific keys since I like to use elevated ways and regular ways - along with bridges, for that matter...

But also being able to map the road menu would mean I could more easily clear all windows for a while, and only open it when needed...

Yona-TYT


Speaking of "Custom keyboards", one thing that is a little annoying in Simutrans, is when a "tool" is selected. For example when constructed "slopes", it would be very useful be able to move the selector "forward / backward" with a keyboard shortcut, although it would be much better to use the mouse wheel.


All this in order to allow quick switching between tools. ;)



Vladki


An_dz

Quote from: Yona-TYT on January 21, 2016, 05:35:24 AM
it would be very useful be able to move the selector "forward / backward" with a keyboard shortcut, although it would be much better to use the mouse wheel.
Seems doable, and I guess I remember which file to edit, but I'm busy with the website.

Some suggestions:
Scroll wheel over a toolbar to change selection.
Alt+Scroll wheel anywhere to change selection of the current focused toolbar
Ctrl+Tab to change selection of the current focused toolbar
Ctrl+1/2/PgUp/PgDw to change focused toolbar

Isaac Eiland-Hall

#4
Quote from: Vladki on January 21, 2016, 07:43:03 AM
You can set/change key shortcuts in menuconf.tab.

Woah. My mind is blown. I completely managed to miss this.

edit: But how can I assign specific roads/stations? It looks like these are dynamically generated.

Quote# roadtools (waytype 1)
toolbar[6][0]=ways(1,0)
toolbar[6][1]=ways(1,1)
toolbar[6][2]=bridges(1)
toolbar[6][3]=tunnels(1)
toolbar[6][4]=wayobjs(1)
toolbar[6][5]=signs(1)
toolbar[6][6]=general_tool[17],18,,1
toolbar[6][7]=general_tool[33],,,1
toolbar[6][8]=buildings(33,1)
toolbar[6][9]=buildings(34,1)
toolbar[6][10]=buildings(35,1)
toolbar[6][11]=general_tool[14],,s,1

I'm guessing that last line is where 's' to select last-used road is defined? So I'm not sure how to define a specific road, or a specific station. (Is this documented anywhere so I don't have to bother anyone for this?)

An_dz

I believe I read something from prissi that all you need is to use the internal name of that road
ex.:
toolbar[6][12]=that_road_name,,s

HaydenRead

The one I am currently wondering how to do is map a key to 'do nothing'
Currently if I press an unallocated key it displays 'keyboard help', which means if I have mapped that key to a screen recording program then the first thing recorded each time is the 'keyboard help' screen coming up.

Vladki


HaydenRead

Quote from: Vladki on January 21, 2016, 06:45:00 PM
Map it to info tool - usually key a.
Not sure if you are meaning map the screen recorder to the letter 'a' (which would cause issues when typing), or Map the info tool to the key allocated for the screen recorder (i.e. F11/F12), in which case can multiple keys be mapped to a single command?

Also, how are the 'Fx (F2,F3...F12) keys listed in menuconf.tab? (I see home HOME and END listed, so I am guessing it is just F12 as an example, but I can't actually find any reference to an 'Fx' Key).

Another one I would like to map is <Alt>+<F4> to exit (Simutrans is about the only application I have found on Windows that does not recognize this command as exit). I realize there is ^ to indicate the use of <Ctrl>, but not sure if there is a similar convention for <Alt>.

(and also switching to the info tool isn't quite 'do nothing' but I guess it is close, and the best option currently available with Simutrans).



Also, in regards to the original comments, I think having the option of a keysconf.tab in the user directory that overrides menuconf.tab would be good, as I would like to be able to set keys for all PakSets I play, without having to go in and manually edit each PakSet's menuconf.tab file (also when a new version of the PakSet is released, if I just download and extract it over top, it overwrites the menuconf.tab).

An_dz

Vladki was talking about mapping the key that should do nothing, to select the Simutrans Inspect tool. Which currently is assigned with the letter 'a'.

Vladki

Yeah, just try editing menuconf and see if you can define the inspect tool twice, with different keys. Once the original (a) and second with the key to you use to start recording.

Ters

Quote from: HaydenRead on January 21, 2016, 07:45:08 PM
Another one I would like to map is <Alt>+<F4> to exit (Simutrans is about the only application I have found on Windows that does not recognize this command as exit).

Alt+F4 is handled by Windows. Simutrans doesn't need to map it. In fact, it might not even see it. If it doesn't work for you, something else must be blocking it. It works for me with the GDI version, and I'm pretty sure it worked for SDL as well (SDL1, haven't tried SDL2).

HaydenRead

Quote from: Ters on January 21, 2016, 09:07:41 PM
Alt+F4 is handled by Windows. Simutrans doesn't need to map it. In fact, it might not even see it. If it doesn't work for you, something else must be blocking it. It works for me with the GDI version, and I'm pretty sure it worked for SDL as well (SDL1, haven't tried SDL2).
Just tried again, Alt+F4 is working fine for me now, so not sure why it wasn't working last time I tried using it. Must have been a Windows issue.

Isaac Eiland-Hall

Posting about technical issues often scares the OS into performing correctly. :)

prissi

About building a certain station
You need to define a toolbar which is never called (in case the tool has an automatic icon) or if not, just append it to the end of toolbar[0].

The numbers of the tools in the toolbar must have no holes!

For to build the simple bus stop with the key 'h' use

toolbar[0][55]=general_tool[19],,h,SimpleBusStop


To raise a flat tile with 'l' best edit the slopetools

toolbar[1][6]=general_tool[4],14,l,82 #all up slope