dualsense-ts 5.2.3 → 5.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.
Files changed (43) hide show
  1. package/dist/hid/hid_provider.d.ts +6 -2
  2. package/dist/hid/hid_provider.d.ts.map +1 -1
  3. package/dist/hid/hid_provider.js +4 -2
  4. package/dist/hid/hid_provider.js.map +1 -1
  5. package/dist/hid/node_hid_provider.d.ts +1 -0
  6. package/dist/hid/node_hid_provider.d.ts.map +1 -1
  7. package/dist/hid/node_hid_provider.js +4 -1
  8. package/dist/hid/node_hid_provider.js.map +1 -1
  9. package/dist/hid/web_hid_provider.d.ts +1 -0
  10. package/dist/hid/web_hid_provider.d.ts.map +1 -1
  11. package/dist/hid/web_hid_provider.js +6 -2
  12. package/dist/hid/web_hid_provider.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/hid/hid_provider.ts +10 -4
  15. package/src/hid/node_hid_provider.ts +7 -1
  16. package/src/hid/web_hid_provider.ts +9 -2
  17. package/webhid_example/build/asset-manifest.json +27 -17
  18. package/webhid_example/build/index.html +1 -1
  19. package/webhid_example/build/static/css/main.237f8cfa.css +2 -0
  20. package/webhid_example/build/static/css/main.237f8cfa.css.map +1 -0
  21. package/webhid_example/build/static/js/blueprint-icons-16px-paths.0c2662b2.chunk.js +2 -0
  22. package/webhid_example/build/static/js/blueprint-icons-16px-paths.0c2662b2.chunk.js.map +1 -0
  23. package/webhid_example/build/static/js/blueprint-icons-20px-paths.e0ebc028.chunk.js +2 -0
  24. package/webhid_example/build/static/js/blueprint-icons-20px-paths.e0ebc028.chunk.js.map +1 -0
  25. package/webhid_example/build/static/js/blueprint-icons-all-paths-loader.53883a20.chunk.js +2 -0
  26. package/webhid_example/build/static/js/blueprint-icons-all-paths-loader.53883a20.chunk.js.map +1 -0
  27. package/webhid_example/build/static/js/blueprint-icons-all-paths.e643b2c5.chunk.js +2 -0
  28. package/webhid_example/build/static/js/blueprint-icons-all-paths.e643b2c5.chunk.js.map +1 -0
  29. package/webhid_example/build/static/js/blueprint-icons-split-paths-by-size-loader.6d8a31ce.chunk.js +2 -0
  30. package/webhid_example/build/static/js/blueprint-icons-split-paths-by-size-loader.6d8a31ce.chunk.js.map +1 -0
  31. package/webhid_example/build/static/js/main.38a225bc.js +3 -0
  32. package/webhid_example/build/static/js/{main.5428c4b5.js.LICENSE.txt → main.38a225bc.js.LICENSE.txt} +0 -23
  33. package/webhid_example/build/static/js/main.38a225bc.js.map +1 -0
  34. package/webhid_example/package.json +2 -20
  35. package/webhid_example/public/index.html +2 -2
  36. package/webhid_example/src/App.tsx +7 -2
  37. package/webhid_example/src/hud/Debugger.tsx +124 -0
  38. package/webhid_example/src/hud/HUDLayout.tsx +14 -0
  39. package/webhid_example/src/hud/index.tsx +2 -0
  40. package/webhid_example/build/static/css/main.6dc04a6e.css +0 -2
  41. package/webhid_example/build/static/css/main.6dc04a6e.css.map +0 -1
  42. package/webhid_example/build/static/js/main.5428c4b5.js +0 -3
  43. package/webhid_example/build/static/js/main.5428c4b5.js.map +0 -1
@@ -5,8 +5,9 @@
5
5
  "author": "Nate Dube <nate@ndube.com>",
6
6
  "license": "GPL-3.0",
7
7
  "private": true,
8
+ "homepage": "dualsense-ts",
8
9
  "dependencies": {
9
- "@blueprintjs/core": "^4.11.4",
10
+ "@blueprintjs/core": "5",
10
11
  "@blueprintjs/icons": "^4.8.0",
11
12
  "@blueprintjs/popover2": "^1.7.4",
12
13
  "@blueprintjs/select": "^4.8.4",
@@ -70,24 +71,5 @@
70
71
  "last 1 firefox version",
71
72
  "last 1 safari version"
72
73
  ]
73
- },
74
- "jest": {
75
- "moduleFileExtensions": [
76
- "js",
77
- "json",
78
- "ts",
79
- "tsx"
80
- ],
81
- "rootDir": "src",
82
- "testRegex": ".*\\.spec\\.ts$",
83
- "transform": {
84
- "^.+\\.(t|j)s$": "ts-jest"
85
- },
86
- "collectCoverageFrom": [
87
- "**/*.(t|j)s"
88
- ],
89
- "coverageDirectory": "../coverage",
90
- "testEnvironment": "node",
91
- "preset": "ts-jest"
92
74
  }
93
75
  }
@@ -2,10 +2,10 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
- <link rel="icon" href="dualsense-ts/%PUBLIC_URL%/favicon.ico" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="theme-color" content="#000000" />
8
- <link rel="manifest" href="dualsense-ts/%PUBLIC_URL%/manifest.json" />
8
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
9
9
  <!-- Start Single Page Apps for GitHub Pages -->
10
10
  <script type="text/javascript">
11
11
  // Single Page Apps for GitHub Pages
@@ -2,6 +2,8 @@ import styled from "styled-components";
2
2
 
3
3
  import { Reticle, ControllerConnection } from "./hud";
4
4
  import { ControllerContext, controller } from "./Controller";
5
+ import { Debugger } from "./hud/Debugger";
6
+ import { HUDLayout } from "./hud/HUDLayout";
5
7
 
6
8
  const AppContainer = styled.div`
7
9
  display: flex;
@@ -18,8 +20,11 @@ export const App = () => {
18
20
  return (
19
21
  <ControllerContext.Provider value={controller}>
20
22
  <AppContainer className="AppContainer">
21
- <Reticle />
22
- <ControllerConnection />
23
+ <HUDLayout>
24
+ <Reticle />
25
+ <ControllerConnection />
26
+ <Debugger />
27
+ </HUDLayout>
23
28
  </AppContainer>
24
29
  </ControllerContext.Provider>
25
30
  );
@@ -0,0 +1,124 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { Card, Section, Elevation, Switch, Slider } from "@blueprintjs/core";
4
+ import { DualsenseHIDState } from "dualsense-ts";
5
+
6
+ import { ControllerContext } from "../Controller";
7
+
8
+ const StyledDebugger = styled.div`
9
+ grid-column: 1;
10
+ grid-row: 1/-1;
11
+ justify-content: right;
12
+ align-items: top;
13
+ display: flex;
14
+ opacity: 0.7;
15
+ padding: 1vw;
16
+ width: 20vw;
17
+ `;
18
+
19
+ const ScrollablePre = styled.pre`
20
+ overflow: scroll;
21
+ word-break: normal !important;
22
+ word-wrap: normal !important;
23
+ white-space: pre !important;
24
+ width: 15vw;
25
+ max-height: 30vw;
26
+ `;
27
+
28
+ export const Debugger = () => {
29
+ const controller = React.useContext(ControllerContext);
30
+ const [controllerState, setDebugState] = React.useState<DualsenseHIDState>(
31
+ controller.hid.state
32
+ );
33
+
34
+ const [showReport, setShowReport] = React.useState<boolean>(false);
35
+ const [showState, setShowState] = React.useState<boolean>(false);
36
+ const [byteOffset, setByteOffset] = React.useState<number>(0);
37
+ controller.hid.provider.reportOffset = byteOffset;
38
+
39
+ React.useEffect(() => {
40
+ controller.on("change", (controller) => {
41
+ setDebugState(controller.hid.state);
42
+ });
43
+ // eslint-disable-next-line react-hooks/exhaustive-deps
44
+ }, []);
45
+
46
+ let reportBuffer: string = "";
47
+ let reportLength: string = "";
48
+ if (controller.hid.provider.buffer) {
49
+ const report = controller.hid.provider.buffer as DataView;
50
+ reportBuffer = `const report = Buffer.from([${new Uint8Array(
51
+ report.buffer
52
+ ).join(", ")}])`;
53
+ reportLength = `${report.byteLength} bytes`;
54
+ } else {
55
+ reportBuffer = "Waiting for report...";
56
+ reportLength = "unknown";
57
+ }
58
+
59
+ const connected = controller.hid.provider.connected;
60
+
61
+ return (
62
+ <StyledDebugger className="Debugger">
63
+ <Card interactive={false} elevation={Elevation.TWO}>
64
+ <Section title={"Debugger"}>
65
+ <Card compact={true}>
66
+ Connected: {controller.hid.provider.connected ? "yes" : "no"}
67
+ {connected
68
+ ? `, ${controller.hid.provider.wireless ? "bluetooth" : "usb"}`
69
+ : ""}
70
+ </Card>
71
+ </Section>
72
+ <Section title={"Outputs"}>
73
+ <Card compact={true}>
74
+ <Switch
75
+ label={"Show Input State"}
76
+ checked={showState}
77
+ onChange={() => setShowState(!showState)}
78
+ />
79
+ <Switch
80
+ label={"Show Report Buffer"}
81
+ checked={showReport}
82
+ onChange={() => setShowReport(!showReport)}
83
+ />
84
+ </Card>
85
+ </Section>
86
+ {showReport
87
+ ? [
88
+ <Section
89
+ title={"HID Report"}
90
+ subtitle={`Buffer Length: ${reportLength}`}
91
+ >
92
+ <Card compact={true}>
93
+ <h5>Byte Offset</h5>
94
+ <Slider
95
+ value={byteOffset}
96
+ min={-2}
97
+ max={20}
98
+ stepSize={1}
99
+ onChange={setByteOffset}
100
+ labelValues={[byteOffset]}
101
+ />
102
+ <h5>Buffer Sample</h5>
103
+ <ScrollablePre>{reportBuffer}</ScrollablePre>
104
+ </Card>
105
+ </Section>,
106
+ ]
107
+ : []}
108
+ {showState
109
+ ? [
110
+ <Section title={"Input State"} compact={true}>
111
+ <ScrollablePre>
112
+ {Object.entries(controllerState)
113
+ .map(
114
+ ([key, val], index) => `${key}: ${JSON.stringify(val)}`
115
+ )
116
+ .join("\n")}
117
+ </ScrollablePre>
118
+ </Section>,
119
+ ]
120
+ : []}
121
+ </Card>
122
+ </StyledDebugger>
123
+ );
124
+ };
@@ -0,0 +1,14 @@
1
+ import styled from "styled-components";
2
+
3
+ export const HUDLayout = styled.div`
4
+ z-index: 10;
5
+ position: absolute;
6
+ top: 0;
7
+ left: 0;
8
+ right: 0;
9
+ bottom: 0;
10
+ overflow: hidden;
11
+ display: grid;
12
+ grid-template-columns: 1fr 1fr 30% 1fr 1fr;
13
+ grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr;
14
+ `;
@@ -3,6 +3,8 @@
3
3
  */
4
4
 
5
5
  export * from "./ControllerConnection";
6
+ export * from "./Debugger";
7
+ export * from "./HUDLayout";
6
8
  export * from "./RenderedElement";
7
9
  export * from "./Reticle";
8
10
  export * from "./Spinner";