Is there a way to check if input is coming from a controller or a keyboard? I want my part of my camera effect only to happen if someone is using a joystick, because a keyboard is always 0 or 1 so it would always trigger this effect.

I thought I had it working, and it did seem to work... but now it doesn't seem so.

This is what I have done to detect keyboard or joystick:

func _input(event: InputEvent) -> void:
if (event is InputEventKey):
	keyb = true
else:
	keyb = false

func rotate_me(deltaVal):
if (!keyb):
	var read_input = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")
	...
        ...

rotate_me() is called in the _physics_process().

Edit: Seems to work fine when I'm testing it in Godot (F5 or F6), just not when it's exported to an executable. Why?

@eyeEmotion said: rotate_me() is called in the _physics_process().

Edit: Seems to work fine when I'm testing it in Godot (F5 or F6), just not when it's exported to an executable. Why?

Strange. I would think it would be the same in both the editor and the exported game. Maybe it’s a bug?

As for detecting whether its a controller, this might work:

if (event is InputEventJoypadButton) or (event is InputEventJoypadMotion):
    keyb = false
else:
    keyb = true

It is basically the opposite check, checking for a controller rather than joypad. I do not know if it will work though.

Tried that too (only with JoypadMotion that is). But it gave unwanted results with the camera-movement using the controller. But I will try it again, but this time with JoypadMotion and JoypadButton.

And indeed, there seems to be something strange about the exports. Certainly when at first it works flawlessly and then out of nowhere it doesn't. The funny thing is, now it works flawlessly again. Didn't do anything to the exported game. Will try again in half an hour. It's not my hardware, I got a pretty beefy computer, since it was bought especially for working with graphic and video-software.

Edit: so that jitter with the keyboard is back again with the exported file.

3 years later