I know nothing about coding, but here's an idea... In the game, triggers appear on screen (such as the floating blue sleep trigger at the front door of your farm house).
When your'e close enough to a blue floater, the associated keys to it are added to the list of keys in the top-left corner of the screen... So the idea is this : have the track switch levers act like the floating icons, but increase their range, so the closest track switch lever, when in range, shows two keys in the top-left menu ( for switching the track left and right). These keys can then be pressed by the player to change the position of the closest track switch lever. [The menu could also be set up to always display the keys for the closest switch lever, when onboard a train].
I'm sure all coding is hard! But this idea uses existing in-game mechanics to try to create a solution. I think its a good idea, but I've no idea is it's even possible :)