class_name VRPN_Button
extends Node

@export var vrpn_client : VRPN_Client = null
@export var button_sensor : String = "Button0"
@export var register_on_ready : bool = true

var state : int = 0

signal on_vrpn_button(data:Dictionary)

func _ready():
	if not vrpn_client:
		push_warning("No VRPN client for button on '%s' given." % [self.name])
	elif register_on_ready:
		vrpn_client.buttons.append(self)

func _on_vrpn(vrpn_data : Dictionary) -> void:
	if vrpn_data['sensor'] == button_sensor:
		on_vrpn_button.emit(vrpn_data)
