mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-21 07:19:30 -07:00
Deferring the holoplay import until it's determined that it's needed. Changing the holoplay effect version a little.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import * as HoloPlayCore from "../../lib/holoplaycore.module.js";
|
||||
|
||||
const recordedDevice = {
|
||||
buttons: [0, 0, 0, 0],
|
||||
calibration: {
|
||||
@@ -34,14 +32,6 @@ const recordedDevice = {
|
||||
windowCoords: [1440, 900],
|
||||
};
|
||||
|
||||
const getDetectedDevice = new Promise(
|
||||
(resolve, reject) =>
|
||||
new HoloPlayCore.Client(
|
||||
(data) => resolve(data.devices?.[0]),
|
||||
(error) => resolve(null)
|
||||
)
|
||||
);
|
||||
|
||||
const interpretDevice = (device) => {
|
||||
if (device == null) {
|
||||
return { enabled: false, tileX: 1, tileY: 1 };
|
||||
@@ -84,9 +74,16 @@ export default async (useHoloplay = false, useRecordedDevice = false) => {
|
||||
if (!useHoloplay) {
|
||||
return interpretDevice(null);
|
||||
}
|
||||
const detectedDevice = await getDetectedDevice;
|
||||
if (detectedDevice == null && useRecordedDevice) {
|
||||
const HoloPlayCore = await import("../../lib/holoplaycore.module.js");
|
||||
const device = await new Promise(
|
||||
(resolve, reject) =>
|
||||
new HoloPlayCore.Client(
|
||||
(data) => resolve(data.devices?.[0]),
|
||||
(error) => resolve(null)
|
||||
)
|
||||
);
|
||||
if (device == null && useRecordedDevice) {
|
||||
return interpretDevice(recordedDevice);
|
||||
}
|
||||
return interpretDevice(detectedDevice);
|
||||
return interpretDevice(device);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user