dualsense-ts 6.2.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ import {
9
9
  BatteryIndicator,
10
10
  MuteLedControls,
11
11
  } from "./hud";
12
+ import { AudioIndicator } from "./hud/AudioIndicator";
12
13
  import { Debugger } from "./hud/Debugger";
13
14
  import { RightStick } from "./hud/RightStick";
14
15
  import { LeftShoulder, RightShoulder } from "./hud/ShoulderVisualization";
@@ -505,6 +506,7 @@ export const App = () => {
505
506
  <ControllerConnection />
506
507
  <BatteryIndicator />
507
508
  <MuteLedControls />
509
+ <AudioIndicator />
508
510
  <LightbarFadeButtons />
509
511
  {connected && (
510
512
  <>
@@ -0,0 +1,114 @@
1
+ import { useContext, useEffect, useState } from "react";
2
+ import { Tag } from "@blueprintjs/core";
3
+
4
+ import { ControllerContext } from "../Controller";
5
+
6
+ export const AudioIndicator = () => {
7
+ const controller = useContext(ControllerContext);
8
+ const [mic, setMic] = useState(controller.microphone.state);
9
+ const [headphone, setHeadphone] = useState(controller.headphone.state);
10
+ const [connected, setConnected] = useState(controller.connection.state);
11
+
12
+ useEffect(() => {
13
+ controller.microphone.on("change", ({ state }) => setMic(state));
14
+ controller.headphone.on("change", ({ state }) => setHeadphone(state));
15
+ controller.connection.on("change", ({ state }) => setConnected(state));
16
+ // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ }, []);
18
+
19
+ if (!connected) return null;
20
+ if (!mic && !headphone) return null;
21
+
22
+ let label: string;
23
+ if (mic && headphone) {
24
+ label = "Headset";
25
+ } else if (headphone) {
26
+ label = "Headphones";
27
+ } else {
28
+ label = "Mic";
29
+ }
30
+
31
+ const icon = (
32
+ <svg
33
+ width="14"
34
+ height="14"
35
+ viewBox="0 0 14 14"
36
+ fill="currentColor"
37
+ style={{ display: "block" }}
38
+ >
39
+ {headphone ? (
40
+ <>
41
+ {/* Headphone band */}
42
+ <path
43
+ d="M2 8 Q2 2 7 2 Q12 2 12 8"
44
+ fill="none"
45
+ stroke="currentColor"
46
+ strokeWidth="1.2"
47
+ strokeLinecap="round"
48
+ />
49
+ {/* Left ear cup */}
50
+ <rect x="1" y="7.5" width="2.5" height="4" rx="1" />
51
+ {/* Right ear cup */}
52
+ <rect x="10.5" y="7.5" width="2.5" height="4" rx="1" />
53
+ {/* Mic boom (only when mic is also connected) */}
54
+ {mic && (
55
+ <>
56
+ <line
57
+ x1="3"
58
+ y1="11"
59
+ x2="5"
60
+ y2="13"
61
+ stroke="currentColor"
62
+ strokeWidth="1.2"
63
+ strokeLinecap="round"
64
+ />
65
+ <circle cx="5.5" cy="13" r="1" />
66
+ </>
67
+ )}
68
+ </>
69
+ ) : (
70
+ <>
71
+ {/* Standalone microphone */}
72
+ <rect x="4.5" y="1" width="5" height="7" rx="2.5" />
73
+ <path
74
+ d="M2.5 6.5 Q2.5 11 7 11 Q11.5 11 11.5 6.5"
75
+ fill="none"
76
+ stroke="currentColor"
77
+ strokeWidth="1.2"
78
+ strokeLinecap="round"
79
+ />
80
+ <line
81
+ x1="7"
82
+ y1="11"
83
+ x2="7"
84
+ y2="13"
85
+ stroke="currentColor"
86
+ strokeWidth="1.2"
87
+ strokeLinecap="round"
88
+ />
89
+ <line
90
+ x1="5"
91
+ y1="13"
92
+ x2="9"
93
+ y2="13"
94
+ stroke="currentColor"
95
+ strokeWidth="1.2"
96
+ strokeLinecap="round"
97
+ />
98
+ </>
99
+ )}
100
+ </svg>
101
+ );
102
+
103
+ return (
104
+ <Tag minimal={true} intent="none" icon={icon} title={
105
+ mic && headphone
106
+ ? "Headset with microphone connected"
107
+ : headphone
108
+ ? "Headphones connected (no microphone)"
109
+ : "Microphone connected (no headphones)"
110
+ }>
111
+ {label}
112
+ </Tag>
113
+ );
114
+ };
@@ -2,6 +2,7 @@
2
2
  * @file Automatically generated by barrelsby.
3
3
  */
4
4
 
5
+ export * from "./AudioIndicator";
5
6
  export * from "./BatteryIndicator";
6
7
  export * from "./BumperVisualization";
7
8
  export * from "./ControllerConnection";