Resetting Axes not working as expected

I have a knob which is attached as joystick to my computer. I can rotate it 360 + Deg.
I would like to use it in unity, sadly i can only attach it as a joystick axes so it gives me values from -1 / 0 / 1.

My idea was to reset axes when e.g. -1 is reached and add another -1 so i end up at -2 which would be 180 deg.
Sadly Input.ResetInputAxes(); is not working at all.

Is there any

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class joystick : MonoBehaviour {

    private float axis = 0.0f;
    private float axisold = 0.0f;
    private float rot = 0.0f;
    private float degree = 90.0f;

    // Use this for initialization
    void Start () {

    }
  
    // Update is called once per frame
    void Update () {


        axis = (Input.GetAxisRaw("Horizontal"));
        rot = (axisold + axis) * degree;
        Debug.Log(axis);

        transform.eulerAngles = new Vector3(90.0f, 0.0f, rot);

        if (axis == -1.0f || axis == 1.0f) {
            axisold = axis;

            Input.ResetInputAxes(); // NOT WORKING

            axis = 0.0f;
            rot = 0.0f;
        }
    }
}

way i could use my knob to habe the rotation equivalent?

So the problem is that this knob can rotate arbitrarily, i.e. it has no limits?

In that case, it should not be presenting itself to the OS as a joystick. Joysticks don’t do that. In fact, hardly anything does that… mice do (with deltas), as do scroll wheels. Perhaps you can get it to present itself as one of them.

If so, then you could set up a Unity axis of the corresponding type, and get unlimited input from this thing.

But if it doesn’t present itself as one of those, then I think you’d need to dig into some low-level SDK for this device. You might have to contact the manufacturer and see what they suggest. Be sure to mention what OS you want to use it on.

What joystick is this? This sounds like a flight controller. There are several flight controllers that have knobs like that.

Oooh, oooh, don’t forget Atari VCS pong/combat controllers and also Tempest arcade machines! :slight_smile:

Seriously though, if it works, it will probably be by telling you deltas each frame that you are responsible for accumulating, much like the mouse wheel.

1 Like