InputEventJoypadMotion returns as GD-NativeClass

Godot Version



Currently, I’m trying to use the “unhandled_input” function to detect if the user is playing with a keyboard or a controller.

What I’m actually doing is a function like this:

func _unhandled_input(event):
   if event == InputEventJoypadMotion:
      print("Playing with a controller!")
     print("Playing with a keyboard!")

This didn’t work as when using the controller’s left or right stick the if statement always returned false. Then I found the Input function is_match, which apparently could fix this, but it didn’t, not even setting the second parameter (exact_match) as false.

Testing with print, I noticed this:

  • Printing the given event from the unhandled input function returns the event as it is
  • But printing InputEventJoypadMotion, it returns <GDScriptNativeClass#-9223372025446268302> instead

Apparently as it returns this instead of the actual InputEventJoypadMotion thing, makes sense it can’t be compared with the event, neither with the is_match function.

Is this an engine bug or I’m doing something wrong? Please let me know and thanks in advance.

how about
if event is InputEventJoypadMotion:

I thought is and == were the same thing but in a ridiculous turn of events, this ended up working… thanks, lol.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.