arduino stuffs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extends Node

var input: Vector2

onready var lb = $Label


func prepare(v: Vector2) -> Vector2:
	v = v.normalized()
	if v.x < 0:
		v.x = 1 - v.x
	if v.y < 0:
		v.y = 1 - v.y
	v = v.round()
	return v


func _physics_process(_delta):
	input = get_input()
	lb.text =str(input)
	SerialIO.send("H%s,%s" % [input.x, input.y])


func get_input() -> Vector2:
	var x := Input.get_action_strength("leftpaddle")
	var y := Input.get_action_strength("rightpaddle")
	if Input.is_action_pressed("lb"):
		x = x + 1 if x != 0 else 1.01
	if Input.is_action_pressed("rb"):
		y = y + 1 if y != 0 else 1.01
	return (Vector2(x, y) * 100).round()