Author Topic: Custom keyboard shortcuts (override default keys)  (Read 1579 times)

0 Members and 1 Guest are viewing this topic.

Offline Isaac.Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3386
  • Total likes: 254
  • Helpful: 90
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Custom keyboard shortcuts (override default keys)
« on: January 21, 2016, 03:08:21 AM »
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...

Offline Yona-TYT

Re: Custom keyboard shortcuts (override default keys)
« Reply #1 on: January 21, 2016, 05:35:24 AM »

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. ;)



Offline Vladki

Re: Custom keyboard shortcuts (override default keys)
« Reply #2 on: January 21, 2016, 07:43:03 AM »
You can set/change key shortcuts in menuconf.tab.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2504
  • Total likes: 261
  • Helpful: 88
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Custom keyboard shortcuts (override default keys)
« Reply #3 on: January 21, 2016, 11:07:19 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

Offline Isaac.Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3386
  • Total likes: 254
  • Helpful: 90
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Custom keyboard shortcuts (override default keys)
« Reply #4 on: January 21, 2016, 01:38:00 PM »
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?)
« Last Edit: January 21, 2016, 03:15:49 PM by Isaac.Eiland-Hall »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2504
  • Total likes: 261
  • Helpful: 88
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Custom keyboard shortcuts (override default keys)
« Reply #5 on: January 21, 2016, 03:46:56 PM »
I believe I read something from prissi that all you need is to use the internal name of that road
ex.:
Code: [Select]
toolbar[6][12]=that_road_name,,s

Offline HaydenRead

Re: Custom keyboard shortcuts (override default keys)
« Reply #6 on: January 21, 2016, 05:48:29 PM »
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.

Offline Vladki

Re: Custom keyboard shortcuts (override default keys)
« Reply #7 on: January 21, 2016, 06:45:00 PM »
Map it to info tool - usually key a.

Offline HaydenRead

Re: Custom keyboard shortcuts (override default keys)
« Reply #8 on: January 21, 2016, 07:45:08 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).

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2504
  • Total likes: 261
  • Helpful: 88
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Custom keyboard shortcuts (override default keys)
« Reply #9 on: January 21, 2016, 07:53:40 PM »
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'.

Offline Vladki

Re: Custom keyboard shortcuts (override default keys)
« Reply #10 on: January 21, 2016, 09:05:18 PM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Custom keyboard shortcuts (override default keys)
« Reply #11 on: January 21, 2016, 09:07:41 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).

Offline HaydenRead

Re: Custom keyboard shortcuts (override default keys)
« Reply #12 on: January 21, 2016, 09:23:20 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.

Offline Isaac.Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3386
  • Total likes: 254
  • Helpful: 90
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Custom keyboard shortcuts (override default keys)
« Reply #13 on: January 21, 2016, 10:08:00 PM »
Posting about technical issues often scares the OS into performing correctly. :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8656
  • Total likes: 283
  • Helpful: 226
  • Languages: De,EN,JP
Re: Custom keyboard shortcuts (override default keys)
« Reply #14 on: January 21, 2016, 10:47:52 PM »
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
Code: [Select]
toolbar[0][55]=general_tool[19],,h,SimpleBusStop

To raise a flat tile with 'l' best edit the slopetools
Code: [Select]
toolbar[1][6]=general_tool[4],14,l,82 #all up slope