Android export and various tweaks

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2023-11-04 23:45:43 +01:00
parent b7ef9bc01b
commit 4aeba8ea69
9 changed files with 270 additions and 39 deletions

View File

@ -24,6 +24,8 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_28t32") script = ExtResource("1_28t32")
osc_dest_port = 9001
debug = true
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1 layout_mode = 1
@ -39,8 +41,8 @@ theme_override_constants/margin_bottom = 20
[node name="GridContainer" type="GridContainer" parent="MarginContainer"] [node name="GridContainer" type="GridContainer" parent="MarginContainer"]
layout_mode = 2 layout_mode = 2
theme_override_constants/h_separation = 10 theme_override_constants/h_separation = 15
theme_override_constants/v_separation = 10 theme_override_constants/v_separation = 25
columns = 4 columns = 4
[node name="VSlider1" type="VSlider" parent="MarginContainer/GridContainer"] [node name="VSlider1" type="VSlider" parent="MarginContainer/GridContainer"]

View File

@ -37,3 +37,205 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\"" rm -rf \"{temp_dir}\""
[preset.1]
name="Android"
platform="Android"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="export/de.chrisarndt.osc_demo.apk"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.1.options]
custom_template/debug=""
custom_template/release=""
gradle_build/use_gradle_build=false
gradle_build/export_format=0
gradle_build/min_sdk=""
gradle_build/target_sdk=""
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=1
version/name="1.0"
package/unique_name="de.chrisarndt.osc_demo"
package/name="OSC Demo"
package/signed=true
package/app_category=0
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
graphics/opengl_debug=false
xr_features/xr_mode=0
xr_features/hand_tracking=0
xr_features/hand_tracking_frequency=0
xr_features/passthrough=0
screen/immersive_mode=true
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
user_data_backup/allow=false
command_line/extra_args=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
permissions/custom_permissions=PackedStringArray()
permissions/access_checkin_properties=false
permissions/access_coarse_location=false
permissions/access_fine_location=false
permissions/access_location_extra_commands=false
permissions/access_mock_location=false
permissions/access_network_state=true
permissions/access_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
permissions/add_voicemail=false
permissions/authenticate_accounts=false
permissions/battery_stats=false
permissions/bind_accessibility_service=false
permissions/bind_appwidget=false
permissions/bind_device_admin=false
permissions/bind_input_method=false
permissions/bind_nfc_service=false
permissions/bind_notification_listener_service=false
permissions/bind_print_service=false
permissions/bind_remoteviews=false
permissions/bind_text_service=false
permissions/bind_vpn_service=false
permissions/bind_wallpaper=false
permissions/bluetooth=false
permissions/bluetooth_admin=false
permissions/bluetooth_privileged=false
permissions/brick=false
permissions/broadcast_package_removed=false
permissions/broadcast_sms=false
permissions/broadcast_sticky=false
permissions/broadcast_wap_push=false
permissions/call_phone=false
permissions/call_privileged=false
permissions/camera=false
permissions/capture_audio_output=false
permissions/capture_secure_video_output=false
permissions/capture_video_output=false
permissions/change_component_enabled_state=false
permissions/change_configuration=false
permissions/change_network_state=false
permissions/change_wifi_multicast_state=false
permissions/change_wifi_state=false
permissions/clear_app_cache=false
permissions/clear_app_user_data=false
permissions/control_location_updates=false
permissions/delete_cache_files=false
permissions/delete_packages=false
permissions/device_power=false
permissions/diagnostic=false
permissions/disable_keyguard=false
permissions/dump=false
permissions/expand_status_bar=false
permissions/factory_test=false
permissions/flashlight=false
permissions/force_back=false
permissions/get_accounts=false
permissions/get_package_size=false
permissions/get_tasks=false
permissions/get_top_activity_info=false
permissions/global_search=false
permissions/hardware_test=false
permissions/inject_events=false
permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=true
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
permissions/manage_app_tokens=false
permissions/manage_documents=false
permissions/manage_external_storage=false
permissions/master_clear=false
permissions/media_content_control=false
permissions/modify_audio_settings=false
permissions/modify_phone_state=false
permissions/mount_format_filesystems=false
permissions/mount_unmount_filesystems=false
permissions/nfc=false
permissions/persistent_activity=false
permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_phone_state=false
permissions/read_profile=false
permissions/read_sms=false
permissions/read_social_stream=false
permissions/read_sync_settings=false
permissions/read_sync_stats=false
permissions/read_user_dictionary=false
permissions/reboot=false
permissions/receive_boot_completed=false
permissions/receive_mms=false
permissions/receive_sms=false
permissions/receive_wap_push=false
permissions/record_audio=false
permissions/reorder_tasks=false
permissions/restart_packages=false
permissions/send_respond_via_message=false
permissions/send_sms=false
permissions/set_activity_watcher=false
permissions/set_alarm=false
permissions/set_always_finish=false
permissions/set_animation_scale=false
permissions/set_debug_app=false
permissions/set_orientation=false
permissions/set_pointer_speed=false
permissions/set_preferred_applications=false
permissions/set_process_limit=false
permissions/set_time=false
permissions/set_time_zone=false
permissions/set_wallpaper=false
permissions/set_wallpaper_hints=false
permissions/signal_persistent_processes=false
permissions/status_bar=false
permissions/subscribed_feeds_read=false
permissions/subscribed_feeds_write=false
permissions/system_alert_window=false
permissions/transmit_ir=false
permissions/uninstall_shortcut=false
permissions/update_device_stats=false
permissions/use_credentials=false
permissions/use_sip=false
permissions/vibrate=false
permissions/wake_lock=false
permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
permissions/write_secure_settings=false
permissions/write_settings=false
permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false

View File

@ -3,7 +3,7 @@ extends Node
class_name OSCReceiver class_name OSCReceiver
@export var default_address:String = "0.0.0.0" @export var default_address:String = "*"
@export var default_port: int = 9001 @export var default_port: int = 9001
@export var poll_interval: float = 0.05 @export var poll_interval: float = 0.05
@export var debug: bool = false @export var debug: bool = false
@ -33,10 +33,10 @@ func register_callback(oscaddress, argtypes, callback):
_observers[[oscaddress, argtypes]].append(callback) _observers[[oscaddress, argtypes]].append(callback)
func start_server(address:String = default_address, port:int = default_port): func start_server(port:int = default_port, bind_address:String = default_address):
_server = UDPServer.new() _server = UDPServer.new()
if _server.listen(port, address) != OK: if _server.listen(port, bind_address) != OK:
_debug("OSCReceiver could not bind to port: %s" % port) _debug("OSCReceiver could not bind to port: %s" % port)
else: else:
_debug("OSCReceiver listening on port: %s" % port) _debug("OSCReceiver listening on port: %s" % port)

View File

@ -3,17 +3,18 @@ extends Node
class_name OSCSender class_name OSCSender
@export var default_address:String = "0.0.0.0" @export var default_address:String = "127.0.0.1"
@export var default_port: int = 9001 @export var default_port: int = 9000
@export var debug: bool = false @export var debug: bool = false
var _address: String var _address: String
var _port: int var _port: int
var socket = PacketPeerUDP.new() var _socket = PacketPeerUDP.new()
func _init(): func _init():
_address = default_address _address = default_address
_port = default_port _port = default_port
_socket.set_dest_address(_address, _port)
func _debug(msg): func _debug(msg):
@ -23,18 +24,18 @@ func _debug(msg):
func set_destination(dest): func set_destination(dest):
if dest is int: if dest is int:
socket.set_dest_address(_address, dest) _socket.set_dest_address(_address, dest)
_port = dest _port = dest
elif dest is String: elif dest is String:
socket.set_dest_address(dest, _port) _socket.set_dest_address(dest, _port)
_address = dest _address = dest
elif dest is Array: elif dest is Array:
socket.set_dest_address(dest[0], dest[1]) _socket.set_dest_address(dest[0], dest[1])
_address = dest[0] _address = dest[0]
_port = dest[1] _port = dest[1]
func send_osc(dest, oscaddress: String, argtypes: String, values: Array): func send_osc(oscaddress: String, argtypes: String, values: Array, dest = null):
assert(oscaddress.begins_with("/")) assert(oscaddress.begins_with("/"))
var buf = StreamPeerBuffer.new() var buf = StreamPeerBuffer.new()
buf.set_big_endian(true) buf.set_big_endian(true)
@ -79,7 +80,7 @@ func send_osc(dest, oscaddress: String, argtypes: String, values: Array):
if dest != null: if dest != null:
set_destination(dest) set_destination(dest)
socket.put_packet(buf.get_data_array()) _socket.put_packet(buf.get_data_array())
return OK return OK

View File

@ -13,6 +13,7 @@ config_version=5
config/name="OSC Demo" config/name="OSC Demo"
run/main_scene="res://UI.tscn" run/main_scene="res://UI.tscn"
config/features=PackedStringArray("4.1") config/features=PackedStringArray("4.1")
boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1)
[debug] [debug]
@ -20,9 +21,17 @@ settings/fps/force_fps=30
[display] [display]
window/size/viewport_width=300 window/size/viewport_width=362
window/size/viewport_height=400 window/size/viewport_height=800
window/stretch/mode="canvas_items"
window/handheld/orientation=1
[input_devices]
pointing/emulate_touch_from_mouse=true
[rendering] [rendering]
renderer/rendering_method="mobile"
textures/vram_compression/import_etc2_astc=true
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"

View File

@ -2,8 +2,8 @@ extends VSlider
func recv_osc(msg_info, values): func recv_osc(msg_info, values):
print("Sender IP: %s" % msg_info["ip"]) #print("Sender IP: %s" % msg_info["ip"])
print("Sender Port: %d" % msg_info["port"]) #print("Sender Port: %d" % msg_info["port"])
print("Address: %s" % msg_info["address"]) #print("Address: %s" % msg_info["address"])
print("Types: %s" % msg_info["types"]) #print("Types: %s" % msg_info["types"])
set_value_no_signal(clampf(values[0], 0.0, 1.0)) set_value_no_signal(clampf(values[0], 0.0, 1.0))

View File

@ -3,11 +3,11 @@ PORT=9001
for ctrl in 0 1 2 3; do for ctrl in 0 1 2 3; do
for value in `LC_ALL=C seq 0.1 0.1 1.0`; do for value in `LC_ALL=C seq 0.1 0.1 1.0`; do
oscsend $HOST $PORT /slider/$ctrl/set f $value oscsend $HOST $PORT /slider/$ctrl f $value
sleep 0.1 sleep 0.1
done done
oscsend $HOST $PORT /button/$ctrl/set i 1 oscsend $HOST $PORT /button/$ctrl i 1
sleep 1 sleep 1
oscsend $HOST $PORT /button/$ctrl/set i 0 oscsend $HOST $PORT /button/$ctrl i 0
done done

View File

@ -2,8 +2,8 @@ extends Button
func recv_osc(msg_info, values): func recv_osc(msg_info, values):
print("Sender IP: %s" % msg_info["ip"]) #print("Sender IP: %s" % msg_info["ip"])
print("Sender Port: %d" % msg_info["port"]) #print("Sender Port: %d" % msg_info["port"])
print("Address: %s" % msg_info["address"]) #print("Address: %s" % msg_info["address"])
print("Types: %s" % msg_info["types"]) #print("Types: %s" % msg_info["types"])
set_pressed_no_signal(bool(values[0])) set_pressed_no_signal(bool(values[0]))

43
ui.gd
View File

@ -1,49 +1,66 @@
extends Control extends Control
const OSCReceiver = preload("res://osc_receiver.gd") const OSCReceiver = preload("res://osc_receiver.gd")
var osc_server: OSCReceiver var osc_server: OSCReceiver
const OSCSender = preload("res://osc_sender.gd") const OSCSender = preload("res://osc_sender.gd")
var osc_client: OSCSender var osc_client: OSCSender
@export var osc_server_address:String = "*"
@export var osc_server_port: int = 9001
@export var osc_dest_address:String = "127.0.0.1"
@export var osc_dest_port: int = 9000
@export var debug: bool = false
func _ready(): func _ready():
osc_client = OSCSender.new() osc_client = OSCSender.new()
osc_client.debug = debug
osc_client.set_destination([osc_dest_address, osc_dest_port])
osc_server = OSCReceiver.new() osc_server = OSCReceiver.new()
osc_server.debug = debug
add_child(osc_server) add_child(osc_server)
var button_callback = Callable(self, "_button_pressed") var button_callback = Callable(self, "_button_pressed")
var slider_callback = Callable(self, "_slider_moved") var slider_callback = Callable(self, "_slider_moved")
# configure all sensors # configure all sensors
for i in range(4): for i in range(4):
var nodename = "VSlider%d" % (i + 1) var nodename = "VSlider%d" % (i + 1)
var osc_addr = "/slider/%d/set" % i var osc_addr = "/slider/%d" % i
var slider_node = find_child(nodename) var slider_node = find_child(nodename)
osc_server.register_callback(osc_addr, "f", slider_node.recv_osc) osc_server.register_callback(osc_addr, "f", slider_node.recv_osc)
slider_node.value_changed.connect(slider_callback.bind(i)) slider_node.value_changed.connect(slider_callback.bind(i))
for i in range(4): for i in range(4):
var nodename = "Button%d" % (i + 1) var nodename = "Button%d" % (i + 1)
var osc_addr = "/button/%d/set" % i var osc_addr = "/button/%d" % i
var button_node = find_child(nodename) var button_node = find_child(nodename)
osc_server.register_callback(osc_addr, "i", button_node.recv_osc) osc_server.register_callback(osc_addr, "i", button_node.recv_osc)
button_node.pressed.connect(button_callback.bind(button_node, i)) button_node.pressed.connect(button_callback.bind(button_node, i))
# start listening for osc messages # start listening for osc messages
osc_server.start_server() osc_server.start_server(osc_server_port, osc_server_address)
func _button_pressed(btn: Button, idx: int): func _button_pressed(btn: Button, idx: int):
print("Button %s pressed: state = %s" % [idx, btn.button_pressed]) _debug("Button %s pressed: state = %s" % [idx, btn.button_pressed])
osc_client.send_osc(9000, "/button/%d" % idx, "i", [1 if btn.button_pressed else 0]) osc_client.send_osc("/button/%d" % idx, "i", [1 if btn.button_pressed else 0])
func _slider_moved(value: float, idx: int): func _slider_moved(value: float, idx: int):
print("Slider %d moved: value = %f" % [idx, value]) _debug("Slider %d moved: value = %f" % [idx, value])
osc_client.send_osc(9000, "/slider/%d" % idx, "f", [value]) osc_client.send_osc("/slider/%d" % idx, "f", [value])
func recv_osc(msg_info, values): func recv_osc(msg_info, values):
print("Sender IP: %s" % msg_info["ip"]) _debug("Sender IP: %s" % msg_info["ip"])
print("Sender Port: %d" % msg_info["port"]) _debug("Sender Port: %d" % msg_info["port"])
print("Address: %s" % msg_info["address"]) _debug("Address: %s" % msg_info["address"])
print("Types: %s" % msg_info["types"]) _debug("Types: %s" % msg_info["types"])
print("Values:", values) _debug("Values: %s" % values)
func _debug(msg):
if debug:
print(msg)