-
Notifications
You must be signed in to change notification settings - Fork 0
/
bridge_api.py
64 lines (55 loc) · 2.56 KB
/
bridge_api.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import bridge_api_internal as bridge
from types import SimpleNamespace
import atexit
bridge.InitializeApp()
def terminate():
bridge.CloseApp()
atexit.register(terminate)
def get_number_of_devices():
return bridge.GetNumDevices()
def get_device(device_index):
num_devices = bridge.GetNumDevices()
if device_index >= num_devices:
raise Exception("No display " + str(device_index) + " connected. Devices connected: " + str(num_devices))
info = SimpleNamespace(
bridge_core_version = bridge.GetHoloPlayCoreVersion(),
bridge_service_version = bridge.GetHoloPlayServiceVersion(),
hdmi_name = bridge.GetDeviceHDMIName(device_index),
device_type = bridge.GetDeviceType(device_index),
button0_down = bridge.GetDevicePropertyInt(device_index, "/buttons/0") == 1,
button1_down = bridge.GetDevicePropertyInt(device_index, "/buttons/1") == 1,
button2_down = bridge.GetDevicePropertyInt(device_index, "/buttons/2") == 1,
button3_down = bridge.GetDevicePropertyInt(device_index, "/buttons/3") == 1
)
window = SimpleNamespace(
x = bridge.GetDevicePropertyWinX(device_index),
y = bridge.GetDevicePropertyWinY(device_index),
w = bridge.GetDevicePropertyScreenW(device_index),
h = bridge.GetDevicePropertyScreenH(device_index),
aspect_ratio = bridge.GetDevicePropertyDisplayAspect(device_index)
)
shader = SimpleNamespace(
lenticular_pitch = bridge.GetDevicePropertyPitch(device_index),
lenticular_tilt = bridge.GetDevicePropertyTilt(device_index),
center_offset = bridge.GetDevicePropertyCenter(device_index),
subpixel_size = bridge.GetDevicePropertySubp(device_index),
fringe = bridge.GetDevicePropertyFringe(device_index),
red_index = bridge.GetDevicePropertyRi(device_index),
blue_index = bridge.GetDevicePropertyBi(device_index),
should_invert = bridge.GetDevicePropertyInvView(device_index),
vertex_shader = bridge.GetVertexShaderGLSL(),
fragment_shader = bridge.GetFragmentShaderGLSL()
)
quilt = SimpleNamespace(
recommended_texture_resolution_w = bridge.GetDevicePropertyQuiltX(device_index),
recommended_texture_resolution_h = bridge.GetDevicePropertyQuiltY(device_index),
tiling_dimension_x = bridge.GetDevicePropertyTileX(device_index),
tiling_dimension_y = bridge.GetDevicePropertyTileY(device_index)
)
device = SimpleNamespace(
info = info,
window = window,
shader = shader,
quilt = quilt
)
return device