Skip to content

Commit fced8f8

Browse files
committed
add back setDevice logic I accidentally removed
1 parent c2bab32 commit fced8f8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/Game.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
22
import Phaser from "phaser";
33
import { gameConfig } from "../game/config";
44
import { ConnectDevice } from "./ConnectDevice";
5+
import { GameScene } from "../game/scenes/GameScene";
56

67
const Game = () => {
78
const [device, setDevice] = useState<HIDDevice | null>(null);
@@ -66,6 +67,18 @@ const Game = () => {
6667
};
6768
}, []);
6869

70+
useEffect(() => {
71+
if (device) {
72+
(
73+
gameRef.current?.scene.getScene("ScenarioScene") as GameScene
74+
)?.setDevice(device);
75+
} else {
76+
(
77+
gameRef.current?.scene.getScene("ScenarioScene") as GameScene
78+
)?.closeDevice();
79+
}
80+
}, [device, gameRef]);
81+
6982
// Force container to take up full size
7083
useEffect(() => {
7184
if (containerRef.current) {

0 commit comments

Comments
 (0)