Jump to content

VKB T-Rudder wheel brake plugin using JoystickGremlin


ThePops

Recommended Posts

Hello, and merry Christmas 🙂

This is a plugin for JoystickGremlin to map an analog slider and rudder pedals to work like a typical Russian WWII fighter, Spitfire and many GA aircraft. Or simply to have proper braking in any sim when using T-Rudder pedals 🙂  What's needed is:

  • A stick (or a throttle) with a an extra analogue slider or rotation to work as brakes (I have a WinWing F-16 stick with enough sliders)
  • VKB T-Rudder pedals (any pedals will obviously work, but none as well as a T-Rudder 🙂 )
  • vJoy software
  • JoystickGremlin software
  • The plugin itself (further down)

For the basics of vJoy and Joystick Gremlin I suggest reading this excellent post. In addition HidHide could be useful in general, but it's not needed for the purpose here.

First you need to set up vJoy. The only thing needed is two axis. Any axis will do. As a minimum one vJoy device with 2 axis is needed.

Then Joystick Gremlin and the plugin must be set up. There is no need to configure anything at this point (like remapping, curves etc), because the plugin will handle everything. I tried this a year or so ago looking at plugins, but gave up because I couldn't for the life of me figure out how these plugins even were supposed to work. Looking at the plugin examples, they have no detailed hardware addresses or anything... It turned out that this Gremlin software is truly amazing, although lacking in documentation. In the mean time I made my own brake pedals that works, sort of, but with none of the precise control you get with a proper brake/rudder mix.

The plugin itself is a small Python script. I merely "hacked" one of the examples. It can be downloaded below, or simply cutn paste. An important thing is that the plugin does not work by itself. It must be imported and configured into Joystick Gremlin. This is done by opening Joystick Gremlin, chose the plugin tab and the Add Plugin button at the bottom.

JG-01.png

Once the file is chosen, it will look like this:

JG-02.png

At this stage the plugin must be configured. Just push the configure button, and a set of configurable setting (all that is needed) pops up to the right.

JG-03.png

There you map the physical brake and rudder axis to the corresponding virtual axis that was made in the first step. The activate button can be on or off. Remember to save the configuration, or Joystick Gremlin will forget all about it when you close, and there is no reminder before closing. You can view if everything is working in the viewer in the tools menu. I found that sometimes when a tried a new plugin, I had to push the activate button on and off a few times etc before it worked, but that could easily have been due to my plugin not working properly (with a working plugin, it just works).

For those who have tried IL-2, this brake/rudder mix works exactly as that (which is exactly as it works in the real aircraft). It requires a tiny bit of getting used to if you have tried only brake pedals, but we're talking minutes, not hours. A real Piper Cub has heel brakes, also fundamentally different from toe brakes, but more intuitive actually, and easily adopted.

It's fully possible to tweak the brake input to use 2 or 3 buttons instead of a slider, or even just one single button, but the finer feeling and precise control will then be limited. 

 

import math

import gremlin
from gremlin.user_plugin import *


mode = ModeVariable("Mode", "Mode in which to use these settings")

pa_brake = PhysicalInputVariable(
           "Physical brake Axis",
           "Physical brake axis input",
           [gremlin.common.InputType.JoystickAxis]
)
pa_rudder = PhysicalInputVariable(
            "Physical rudder Axis",
            "Physical rudder axis input",
            [gremlin.common.InputType.JoystickAxis]
)
va_leftBrake = VirtualInputVariable(
               "vJoy left brake Axis",
               "Virtual left brake axis output",
               [gremlin.common.InputType.JoystickAxis]
)
va_rightBrake = VirtualInputVariable(
               "vJoy right brake Axis",
               "Virtual right brake axis output",
               [gremlin.common.InputType.JoystickAxis]
)


# Decorators for the two physical axes
dec_brake  = pa_brake.create_decorator(mode.value)
dec_rudder = pa_rudder.create_decorator(mode.value)


# Storage for the last known axis values
brake_value = 0.0
rudder_value = 0.0


def update_vjoy(vjoy):
 
    leftRudder  =  rudder_value
    rightRudder = -rudder_value
    if leftRudder > 0.0:
       leftBrake = min(-2.0*leftRudder + 1.0, brake_value)
    else:
       leftBrake = brake_value
    
    if rightRudder > 0.0:
       rightBrake = min(-2.0*rightRudder + 1.0, brake_value)
    else:
       rightBrake = brake_value
   
    vjoy[va_leftBrake.vjoy_id].axis(va_leftBrake.input_id).value = leftBrake
    vjoy[va_rightBrake.vjoy_id].axis(va_rightBrake.input_id).value = rightBrake


@dec_brake.axis(pa_brake.input_id)
def axis1(event, vjoy):
    global brake_value
    brake_value = event.value
    update_vjoy(vjoy)


@dec_rudder.axis(pa_rudder.input_id)
def axis2(event, vjoy):
    global rudder_value
    rudder_value = event.value
    update_vjoy(vjoy)


 

   brake_sticknrudder.py

Link to comment
Share on other sites

An update and improvements.

I tried using some usable axis on the throttle as brake instead of my usual slider on my stick, and run into trouble. The plugin above assumes that each axis starts at -1.0 and ends at 1.0 (in Gremlin scaling). This is often the case, but far from always, which is the reason axis can be inverted in all games. In addition, many axis are spring loaded to mid point position. If using that axis as a brake, you would typically only use half of that axis. When using an axis going from 0 (zero braking) to -1 (full braking) for instance, this needs to be scaled appropriately

This new plugin is updated to account for that. Both brake and rudder axis can now start at any point and end at any point, fully user configurable. However, I then discovered a bug in Joystick Gremlin 13.3. The input field for the plugin FloatVariable is bugged. It does not import the correct default value, it does not use the correct min and max values, and can only take numbers from 0.0 to 99.99. This was a bummer, especially since the software is no longer updated. What I did was to make the Python file itself easy configurable. It's called brake_sticknrudder_v02.py below. It's all explained in the comments in the file.

A bit of Googling I found that Joystick Gremlin actually IS being updated. A person has forked off version 13.3, and it's now version 13.40.3. The updates include 64 bit (was 32 bit), newer Python (much faster), newer Qt and a host of other improvements. This new version is called Joystick Gremlin Ex and can be found here (look at the right side for the release version). And wouldn't you know, the input field bug is fixed as well 🙂 I made another plugin for Gremlin Ex. This will only work in Gremlin Ex, because it creates a divide by zero error in 13.3 due to the default values being set to zero. This file is called brake_sticknrudder_v02_EX.py

The Ex version does not have an installer, just unzip it to some folder (not the Program Files folder). It uses the same profile files as the 13.3 version, and you can run either one (not at the same time though).

JG-EX.png

brake_sticknrudder_v02.py brake_sticknrudder_v02_EX.py

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...