Skip to content

Commit 3a14dfd

Browse files
authored
major refactor (#4)
1 parent d09ea5c commit 3a14dfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3407
-2940
lines changed

.github/workflows/deploy-demo.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@ jobs:
2222
url: ${{ steps.deployment.outputs.page_url }}
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v3
26-
- uses: pnpm/action-setup@v2
25+
- uses: actions/checkout@v5
26+
- uses: pnpm/action-setup@v4
27+
- uses: actions/setup-node@v6
2728
with:
28-
version: latest
29-
- uses: actions/setup-node@v3
30-
with:
31-
node-version: 20
29+
node-version: "lts/*"
3230
cache: "pnpm"
33-
- run: pnpm install
34-
- run: pnpm build
35-
- run: pnpm -C demo build --base "/webnect/"
36-
- uses: actions/configure-pages@v3
37-
- uses: actions/upload-pages-artifact@v1
31+
- run: pnpm install --frozen-lockfile
32+
33+
- run: pnpm run -C driver build
34+
- run: pnpm run -C demo build --base "/webnect/"
35+
- uses: actions/configure-pages@v5
36+
- uses: actions/upload-pages-artifact@v4
3837
with:
3938
path: "./demo/dist"
4039
- id: deployment
41-
uses: actions/deploy-pages@v1
40+
uses: actions/deploy-pages@v4

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ jobs:
1010
publish:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: pnpm/action-setup@v2
13+
- uses: actions/checkout@v5
14+
- uses: pnpm/action-setup@v4
15+
- uses: actions/setup-node@v6
1516
with:
16-
version: latest
17-
- uses: actions/setup-node@v3
18-
with:
19-
node-version: 20
17+
node-version: "lts/*"
2018
cache: "pnpm"
21-
- run: pnpm install
22-
- run: pnpm lint
23-
- run: pnpm build
24-
- run: pnpm publish
19+
- run: pnpm install --frozen-lockfile
20+
21+
- run: pnpm publish ./driver

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
2-
.DS_Store
3-
tmp
4-
dist
2+
dist
3+
*.local

README.md

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,97 @@ this is a webusb driver for microsoft's xbox360 kinect.
66

77
<https://github.com/turbocrime/webnect/assets/134443988/40879425-cd91-4bae-a14f-633dc0f8d88c>
88

9-
chrome only :'C mozzy dont do webusb
9+
webusb is only available in chrome.
1010

11-
i have never written a usb driver before, nor even a typescript library, so critique is welcome.
11+
this driver at least works with "Xbox NUI Motor" PID `0x02b0` and "Xbox NUI
12+
Camera" PID `0x02ae` devices, labelled "Model 1414", because that's what i found
13+
at goodwill.
1214

13-
this driver at least works with "Xbox NUI Motor" PID `0x02b0` and "Xbox NUI Camera" PID `0x02ae` devices, labelled "Model 1414", because that's what i found at goodwill. i there may be a few externally-identical models of "kinect", some with dramatic hardware revisions. if your device doesn't work with this, please verify that it works at all, and then send me the details.
15+
if your device doesn't work with this, please verify that it works at all, and
16+
then send me the details.
1417

1518
## what
1619

17-
the kinect is an early consumer depth sensor based on structured light projection, plus some other goodies. it was released in 2010 as a gamer thing and nobody cares about it anymore except me
20+
the kinect is an early consumer depth sensor based on structured light
21+
projection, plus some other goodies. it was released in 2010 as a gamer thing
22+
and nobody cares about it anymore except me
1823

19-
they're fun, and they go for like $5 now. plus they're usb2, so i can drive them with throwaway SBCs like an rpi3. maybe not with this driver, but that's how i got familiar. i been using them for video synth input, and interactive generative art installations
24+
they're fun, and they go for like $5 now. plus they're usb2, so i can drive them
25+
with throwaway SBCs like an rpi3. i've been using them for video synth input,
26+
and interactive art installations
2027

21-
a webusb driver lets more folks see it in person :) after i rewrite everything :)
28+
a webusb driver lets more folks see it in person :)
2229

23-
## ware
30+
## why
2431

25-
original kinect only.
32+
building libfreenect with emscripten turned out to be impossible for various
33+
reasons. whatever. it's the future and webusb is real
2634

27-
### Xbox NUI Motor
35+
## ware
2836

29-
* accelerometer
30-
* tilt servo
31-
* blinkenlights
37+
original xbox 360 kinect only.
3238

33-
### Xbox NUI Camera
39+
- Xbox NUI Motor
40+
- accelerometer
41+
- tilt servo
42+
- LED light
3443

35-
* depth 11bpp, 10bpp
36-
* visible 8bpp bayer, 16bpp yuv
37-
* infrared 10bpp
38-
* arbitrary register manipulation
44+
- Xbox NUI Camera
45+
- depth 11bpp, 10bpp
46+
- visible bayer, yuv
47+
- infrared 10bpp
48+
- register manipulation
3949

40-
visible and infrared stream from the same endpoint, so you can only have one at a time. you can use my pipeline and get a `ReadableStream<ImageData>` that you just blit to canvas, or set a custom deraw function.
50+
visible and infrared stream from the same hardware endpoint, so you can only
51+
have one of those at a time.
4152

42-
## why
53+
## how
4354

44-
building libfreenect with emscripten turned out to be impossible for various reasons. whatever. it's the future and webusb is real
55+
go dig your kinect out of the closet. plug it in. open
56+
<https://turbocrime.github.io/webnect>
4557

46-
## how
58+
or for a local demo, clone this repo and run:
4759

48-
go dig your kinect out of the closet. plug it in. open <https://turbocrime.github.io/webnect>
60+
```bash
61+
pnpm install
62+
pnpm dev
63+
```
4964

50-
for a local demo, clone this repo.
65+
demo web server opens on vite default `https://localhost:5173`
5166

5267
## diy
5368

54-
available on npm as [`@webnect/webnect`](https://www.npmjs.com/package/@webnect/webnect)
69+
available on npm as
70+
[`@webnect/driver`](https://www.npmjs.com/package/@webnect/driver)
5571

56-
no docs yet, but it's pretty simple. you can grab a new kinect camera with
72+
### its broken??
5773

58-
```typescript
59-
import k from "@webnect/webnect";
60-
const dev: USBDevice = await k.claimNuiCamera();
61-
const kcam = k.Camera(dev);
62-
kcam.mode({ depth: k.DEPTH_MODE });
63-
const depthStream: ReadableStream<ImageData> = kcam.depth.getReader();
64-
```
74+
#### is webusb available?
6575

66-
alternatively, if you want raw frames in a specific mode, you could
76+
if your browser doesn't have webusb, you can't use this.
6777

68-
```typescript
69-
import k, { Modes, CamType, CamFmtVisible } from "@webnect/webnect";
70-
const dev: USBDevice = await k.claimNuiCamera();
71-
const kcam = k.Camera(dev, {
72-
modes: { depth: Modes.OFF, video: { stream: CamType.VISIBLE, format: CamFmtVisible.YUV_16B } },
73-
deraw: { depth: false, video: false }
74-
});
75-
const yuvFrameStream: ReadableStream<ArrayBuffer> = kcam.video.getReader();
76-
```
78+
webusb is only available in secure contexts.
7779

78-
### um its broekn??
80+
#### no device to select?
7981

80-
if you see an empty device selection modal, you probably have the wrong model kinect. you can check your usb devices with `lsusb` on linux or on `system_profiler SPUSBDataType` on macos
82+
if you see an empty device selection modal, you probably have the wrong model
83+
kinect.
8184

82-
if you see glitchy stream output, haha nice. cool
85+
if the motor is available but the camera is not, make sure your kinect is
86+
powered correctly.
8387

84-
### bad parts
88+
check your usb devices:
89+
- on linux use `lsusb`
90+
- on macos use `system_profiler SPUSBDataType`
8591

86-
a single kinect is technically three devices in a trenchcoat. afaict there's no way to associate them, because webusb won't expose bus position. it doesn't matter; you probably only plugged in one kinect anyway.
92+
#### its glitchy
8793

88-
also, typescript aint exactly the optimal language for bitmath or destructuring binary data
94+
haha nice. cool
8995

90-
## way
96+
### bad parts
9197

92-
probably going after pose features next, maybe alignment of video to depth. and then firmware/audio stuff.
98+
a single kinect is technically three USB devices in a trenchcoat. full control
99+
requires multiple permission requests.
93100

94-
someday.... kinect2?
101+
the motor device does not report a serial number, so there's no way to reliably
102+
associate the motors if you have multiple kinects.

biome.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
3-
"organizeImports": {
4-
"enabled": false
5-
},
2+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
3+
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4+
"formatter": { "enabled": true, "indentStyle": "tab" },
65
"linter": {
76
"enabled": true,
87
"rules": {
98
"recommended": true,
10-
"style": {
11-
"noNonNullAssertion": "off"
12-
},
13-
"suspicious": {
14-
"noDebugger": "warn"
15-
}
9+
"style": { "useBlockStatements": "error" },
10+
"nursery": { "noFloatingPromises": "error" }
1611
}
12+
},
13+
"css": { "formatter": { "enabled": true } },
14+
"html": { "formatter": { "enabled": true } },
15+
"javascript": { "formatter": { "enabled": true } },
16+
"json": { "formatter": { "enabled": true } },
17+
"assist": {
18+
"enabled": true,
19+
"actions": { "source": { "organizeImports": "on" } }
1720
}
1821
}

demo/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)