Update UI wording, handle case where device data comes in with all zeroes
This commit is contained in:
parent
5c9c7f7db2
commit
b77ede606d
|
|
@ -176,68 +176,74 @@ export const DeviceDataStream = GObject.registerClass({
|
|||
let dataView = new DataView(buffer);
|
||||
if (dataView.byteLength === DATA_VIEW_LENGTH) {
|
||||
let imuDateMs = dataViewBigUint(dataView, EPOCH_MS);
|
||||
const validKeepalive = isValidKeepAlive(toSec(imuDateMs));
|
||||
const displayFov = dataViewFloat(dataView, DISPLAY_FOV);
|
||||
const validKeepAlive = isValidKeepAlive(toSec(imuDateMs));
|
||||
const validData = validKeepAlive && displayFov !== 0.0;
|
||||
const version = dataViewUint8(dataView, VERSION);
|
||||
const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validKeepalive;
|
||||
const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validData;
|
||||
let imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA);
|
||||
const imuResetState = enabled && validKeepalive && imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0;
|
||||
const imuResetState = enabled && validData && imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0;
|
||||
const customBannerEnabled = dataViewUint8(dataView, CUSTOM_BANNER_ENABLED) !== 0;
|
||||
const sbsEnabled = dataViewUint8(dataView, SBS_ENABLED) !== 0;
|
||||
|
||||
if (validKeepAlive && !validData) Globals.logger.log('[ERROR] Received invalid device data');
|
||||
|
||||
// trigger "notify::" events for properties we want to check on every cycle
|
||||
if (enabled && this.widescreen_mode_state !== sbsEnabled) this.widescreen_mode_state = sbsEnabled;
|
||||
if (this.show_banner !== imuResetState) this.show_banner = imuResetState;
|
||||
if (this.custom_banner_enabled !== customBannerEnabled) this.custom_banner_enabled = customBannerEnabled;
|
||||
|
||||
if (!this.device_data) {
|
||||
this.device_data = {
|
||||
version,
|
||||
enabled,
|
||||
imuResetState,
|
||||
displayRes: dataViewUint32Array(dataView, DISPLAY_RES),
|
||||
sbsEnabled,
|
||||
displayFov: dataViewFloat(dataView, DISPLAY_FOV),
|
||||
lookAheadCfg: dataViewFloatArray(dataView, LOOK_AHEAD_CFG),
|
||||
lensDistanceRatio: dataViewFloat(dataView, LENS_DISTANCE_RATIO)
|
||||
};
|
||||
} else if (keepalive_only) {
|
||||
this.device_data = {
|
||||
...this.device_data,
|
||||
imuResetState,
|
||||
enabled,
|
||||
sbsEnabled
|
||||
}
|
||||
}
|
||||
|
||||
let success = keepalive_only;
|
||||
let attempts = 0;
|
||||
while (!success && attempts < 3) {
|
||||
if (dataView.byteLength === DATA_VIEW_LENGTH) {
|
||||
if (checkParityByte(dataView)) {
|
||||
this.device_data.imuData = imuData;
|
||||
this.device_data.imuDateMs = imuDateMs;
|
||||
this.imu_snapshots = {
|
||||
imu_data: imuData,
|
||||
timestamp_ms: imuDateMs
|
||||
};
|
||||
success = true;
|
||||
if (validData) {
|
||||
if (!this.device_data) {
|
||||
this.device_data = {
|
||||
version,
|
||||
enabled,
|
||||
imuResetState,
|
||||
displayRes: dataViewUint32Array(dataView, DISPLAY_RES),
|
||||
sbsEnabled,
|
||||
displayFov,
|
||||
lookAheadCfg: dataViewFloatArray(dataView, LOOK_AHEAD_CFG),
|
||||
lensDistanceRatio: dataViewFloat(dataView, LENS_DISTANCE_RATIO)
|
||||
};
|
||||
} else if (keepalive_only) {
|
||||
this.device_data = {
|
||||
...this.device_data,
|
||||
imuResetState,
|
||||
enabled,
|
||||
sbsEnabled
|
||||
}
|
||||
} else if (dataView.byteLength !== 0) {
|
||||
Globals.logger.log(`[ERROR] Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`)
|
||||
}
|
||||
|
||||
if (!success && ++attempts < 3) {
|
||||
data = this._ipc_file.load_contents(null);
|
||||
if (data[0]) {
|
||||
buffer = new Uint8Array(data[1]).buffer;
|
||||
dataView = new DataView(buffer);
|
||||
imuDateMs = dataViewBigUint(dataView, EPOCH_MS);
|
||||
imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA);
|
||||
|
||||
let attempts = 0;
|
||||
while (!success && attempts < 3) {
|
||||
if (dataView.byteLength === DATA_VIEW_LENGTH) {
|
||||
if (checkParityByte(dataView)) {
|
||||
this.device_data.imuData = imuData;
|
||||
this.device_data.imuDateMs = imuDateMs;
|
||||
this.imu_snapshots = {
|
||||
imu_data: imuData,
|
||||
timestamp_ms: imuDateMs
|
||||
};
|
||||
success = true;
|
||||
}
|
||||
} else if (dataView.byteLength !== 0) {
|
||||
Globals.logger.log(`[ERROR] Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`)
|
||||
}
|
||||
|
||||
if (!success && ++attempts < 3) {
|
||||
data = this._ipc_file.load_contents(null);
|
||||
if (data[0]) {
|
||||
buffer = new Uint8Array(data[1]).buffer;
|
||||
dataView = new DataView(buffer);
|
||||
imuDateMs = dataViewBigUint(dataView, EPOCH_MS);
|
||||
imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.breezy_desktop_actually_running = success && enabled && validKeepalive;
|
||||
this.breezy_desktop_actually_running = success && enabled && validData;
|
||||
} else {
|
||||
this.breezy_desktop_actually_running = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1096,7 +1096,7 @@ export const VirtualMonitorsActor = GObject.registerClass({
|
|||
// shift all monitors so they center around the target monitor, then adjusted by the offsets
|
||||
this._all_monitors.map(monitor => ({
|
||||
x: monitor.x - this.target_monitor.x - this.viewport_offset_x * this.target_monitor.width,
|
||||
y: monitor.y - this.target_monitor.y - this.viewport_offset_y * this.target_monitor.height,
|
||||
y: monitor.y - this.target_monitor.y + this.viewport_offset_y * this.target_monitor.height,
|
||||
width: monitor.width,
|
||||
height: monitor.height
|
||||
})),
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 831a016d71f638b683157f9d85d5ffc34848a1c1
|
||||
Subproject commit 4f299ecc7da6d4cdfb164cbcb22f60580fb2295a
|
||||
|
|
@ -153,7 +153,6 @@ class ConnectedDevice(Gtk.Box):
|
|||
|
||||
self._settings_displays_app_info = None
|
||||
|
||||
# use Gio.AppInfo.get_all() and find the one where appinfo.get_id() == 'gnome-display-panel.desktop'
|
||||
for appinfo in Gio.AppInfo.get_all():
|
||||
if appinfo.get_id() == 'gnome-display-panel.desktop':
|
||||
self._settings_displays_app_info = appinfo
|
||||
|
|
@ -185,6 +184,9 @@ class ConnectedDevice(Gtk.Box):
|
|||
self.effect_enable_switch.set_active(enabled)
|
||||
|
||||
def _handle_switch_enabled_state(self, switch, param):
|
||||
GLib.idle_add(self._handle_switch_enabled_state_gui, switch, param)
|
||||
|
||||
def _handle_switch_enabled_state_gui(self, switch, param):
|
||||
requesting_enabled = switch.get_active()
|
||||
|
||||
# never turn off the extension, disabling the effect is done via configs only
|
||||
|
|
@ -239,9 +241,13 @@ class ConnectedDevice(Gtk.Box):
|
|||
GLib.idle_add(self._on_virtual_displays_update_gui, virtual_display_manager)
|
||||
|
||||
def _on_virtual_displays_update_gui(self, virtual_display_manager):
|
||||
effect_enabled = self.effect_enable_switch.get_active()
|
||||
virtual_displays_present = len(virtual_display_manager.displays) > 0
|
||||
self.launch_display_settings_button.set_visible(
|
||||
self._settings_displays_app_info is not None and len(virtual_display_manager.displays) > 0
|
||||
self._settings_displays_app_info is not None and virtual_displays_present
|
||||
)
|
||||
self.monitor_wrapping_scheme_menu.set_sensitive(effect_enabled and virtual_displays_present)
|
||||
self.monitor_spacing_scale.set_sensitive(effect_enabled and virtual_displays_present)
|
||||
|
||||
for pid, child in self.virtual_displays_by_pid.items():
|
||||
self.top_features_group.remove(child)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Virtual monitors</property>
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Virtual displays</property>
|
||||
<property name="valign">2</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
|
@ -123,9 +123,9 @@
|
|||
</object>
|
||||
</property>
|
||||
<marks>
|
||||
<mark value="0.2" position="bottom"></mark>
|
||||
<mark value="1.0" position="bottom"></mark>
|
||||
<mark value="2.5" position="bottom"></mark>
|
||||
<mark value="0.2" position="bottom">0.2</mark>
|
||||
<mark value="1.0" position="bottom">1.0</mark>
|
||||
<mark value="2.5" position="bottom">2.5</mark>
|
||||
</marks>
|
||||
</object>
|
||||
</child>
|
||||
|
|
@ -159,8 +159,8 @@
|
|||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- dropdown menu -->Multi-monitor wrapping</property>
|
||||
<property name="subtitle" translatable="yes">When there are multiple monitors, choose how they should wrap around you.</property>
|
||||
<property name="title" translatable="yes"><!-- dropdown menu -->Display angling</property>
|
||||
<property name="subtitle" translatable="yes">When there are multiple displays, choose how they should angle towards you.</property>
|
||||
<property name="valign">2</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
|
@ -175,9 +175,9 @@
|
|||
<object class="GtkComboBoxText" id="monitor_wrapping_scheme_menu">
|
||||
<items>
|
||||
<item translatable="yes" id="automatic">Automatic</item>
|
||||
<item translatable="yes" id="horizontal">Horizontal</item>
|
||||
<item translatable="yes" id="vertical">Vertical</item>
|
||||
<item translatable="yes" id="none">None</item>
|
||||
<item translatable="yes" id="horizontal">Side-angled</item>
|
||||
<item translatable="yes" id="vertical">Top-angled</item>
|
||||
<item translatable="yes" id="none">Flat</item>
|
||||
</items>
|
||||
</object>
|
||||
</child>
|
||||
|
|
@ -187,8 +187,8 @@
|
|||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Multi-monitor spacing</property>
|
||||
<property name="subtitle" translatable="yes">Put empty space between monitors, when there are multiple.</property>
|
||||
<property name="title" translatable="yes"><!-- adjustment slider -->Display spacing</property>
|
||||
<property name="subtitle" translatable="yes">Put empty space between displays, when there are multiple.</property>
|
||||
<child>
|
||||
<object class="GtkScale" id="monitor_spacing_scale">
|
||||
<property name="valign">3</property>
|
||||
|
|
@ -206,11 +206,11 @@
|
|||
</object>
|
||||
</property>
|
||||
<marks>
|
||||
<mark value="0" position="bottom"></mark>
|
||||
<mark value="0" position="bottom">0</mark>
|
||||
<mark value="25" position="bottom"></mark>
|
||||
<mark value="50" position="bottom"></mark>
|
||||
<mark value="50" position="bottom">50</mark>
|
||||
<mark value="75" position="bottom"></mark>
|
||||
<mark value="100" position="bottom"></mark>
|
||||
<mark value="100" position="bottom">100</mark>
|
||||
</marks>
|
||||
</object>
|
||||
</child>
|
||||
|
|
@ -223,7 +223,6 @@
|
|||
<child>
|
||||
<object class="GtkScale" id="viewport_offset_x_scale">
|
||||
<property name="valign">3</property>
|
||||
<property name="draw-value">true</property>
|
||||
<property name="value-pos">0</property>
|
||||
<property name="digits">1</property>
|
||||
<property name="width-request">350</property>
|
||||
|
|
@ -237,11 +236,11 @@
|
|||
</object>
|
||||
</property>
|
||||
<marks>
|
||||
<mark value="-2.0" position="bottom"></mark>
|
||||
<mark value="-2.0" position="bottom">left</mark>
|
||||
<mark value="-1.0" position="bottom"></mark>
|
||||
<mark value="0.0" position="bottom"></mark>
|
||||
<mark value="0.0" position="bottom">center</mark>
|
||||
<mark value="1.0" position="bottom"></mark>
|
||||
<mark value="2.0" position="bottom"></mark>
|
||||
<mark value="2.0" position="bottom">right</mark>
|
||||
</marks>
|
||||
</object>
|
||||
</child>
|
||||
|
|
@ -254,7 +253,6 @@
|
|||
<child>
|
||||
<object class="GtkScale" id="viewport_offset_y_scale">
|
||||
<property name="valign">3</property>
|
||||
<property name="draw-value">true</property>
|
||||
<property name="value-pos">0</property>
|
||||
<property name="digits">1</property>
|
||||
<property name="width-request">350</property>
|
||||
|
|
@ -268,11 +266,11 @@
|
|||
</object>
|
||||
</property>
|
||||
<marks>
|
||||
<mark value="-2.0" position="bottom"></mark>
|
||||
<mark value="-2.0" position="bottom">down</mark>
|
||||
<mark value="-1.0" position="bottom"></mark>
|
||||
<mark value="0.0" position="bottom"></mark>
|
||||
<mark value="0.0" position="bottom">center</mark>
|
||||
<mark value="1.0" position="bottom"></mark>
|
||||
<mark value="2.0" position="bottom"></mark>
|
||||
<mark value="2.0" position="bottom">up</mark>
|
||||
</marks>
|
||||
</object>
|
||||
</child>
|
||||
|
|
|
|||
Loading…
Reference in New Issue