leezer3 / OpenBVE

OpenBVE- A free train simulator
http://www.openbve-project.net
280 stars 52 forks source link

Master Controller UpFast/DownFast sounds and Brake Handle ApplyFast/ReleaseFast sounds do not play when using a joystick or external controller #791

Open RetentiveGOAT opened 2 years ago

RetentiveGOAT commented 2 years ago

Description

In the sound.cfg file, I have sounds set up for both UpFast and DownFast under the Master Controller section, and both ApplyFast and ReleaseFast for the Brake Handle section. These sounds trigger fine whenever using the keyboard to quickly release and apply brakes, and vice versa when quickly taking or knocking off power notches. However, when I try to use my joystick to do the same, the sounds do not trigger at all. I'm using openBVE 1.8.3.2.

Related information

leezer3 commented 2 years ago

Sorry, missed this...

This is going to be a consequence of joystick axis polling, and the way the notch is determined as a result.

Using the keyboard on the other hand, whilst the key is held down, we generate key-repeat events once every half-second. We can detect that the key is still held down, and therefore fire the IncreaseFast sound.

With a joystick axis however, the position is returned as an absolute on the axis (generally from -1 to 1, although this varies) We then normalise this to the 0 - 1 range, and multiply this by the number of axis to determine the final notch. There's no direct way to detect that the joystick axis is still physically moving, and it may also skip notches depending on the movement speed and exact range of travel of the axis in question.