Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f0db8e66e | ||
|
|
7cc6e46afe | ||
|
|
7b63ff3a1a | ||
|
|
6124dee2db | ||
|
|
cbbfcdc99e | ||
|
|
b77f5f105f | ||
|
|
743424dc01 | ||
|
|
1b131d7ea7 | ||
|
|
df9ee3b57f | ||
|
|
3bd7ee8586 | ||
|
|
828f480424 | ||
|
|
e285bdb999 | ||
|
|
0b75d1c62e | ||
|
|
b02e14ecdf | ||
|
|
f135c31904 | ||
|
|
396e77ac38 | ||
|
|
17cd942148 | ||
|
|
1a44443c41 | ||
|
|
89e8545d80 | ||
|
|
f4d12e0b7a | ||
|
|
9bb2f9da74 | ||
|
|
121aeadbd8 | ||
|
|
e0046ede81 | ||
|
|
571eec24d3 | ||
|
|
0e75256520 | ||
|
|
882d7d0b5b | ||
|
|
486120d9c0 | ||
|
|
d81664ba7c | ||
|
|
3e36cc551f | ||
|
|
7e387ea541 | ||
|
|
46c9f1c722 | ||
|
|
32045ffa61 | ||
|
|
1d9e52b92f | ||
|
|
f0ed581b3d | ||
|
|
62551a2f88 | ||
|
|
d4d8d8be09 | ||
|
|
3ce8f47905 | ||
|
|
1fe10cf615 | ||
|
|
856d2ea49a | ||
|
|
d24bd93084 | ||
|
|
1802ca12fd | ||
|
|
87f6c7db95 | ||
|
|
ec0cc7d2e4 | ||
|
|
169d981e6f | ||
|
|
2fb8995e68 | ||
|
|
3a3e339aca | ||
|
|
cd2c1d73c0 | ||
|
|
d89de5e6fc | ||
|
|
8fbb9e4d9f | ||
|
|
61505c2375 | ||
|
|
8c96763a8a | ||
|
|
748a76cf06 | ||
|
|
ff6e971f62 | ||
|
|
bcff45da56 | ||
|
|
ec1a146449 | ||
|
|
63d2724f35 | ||
|
|
7c0d5af821 | ||
|
|
ca06dc025f | ||
|
|
60098bba46 | ||
|
|
358b53c0be | ||
|
|
47b90603e2 | ||
|
|
af16cd43c8 | ||
|
|
e9510bcfa0 | ||
|
|
dedc8cace4 | ||
|
|
35da7d4874 |
@@ -2,9 +2,9 @@
|
||||
|
||||
# [slidershim](https://github.com/4yn/slidershim)
|
||||
|
||||
Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller. Has support for keyboard/gamepad output and LED lighting.
|
||||
Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller. Has support for keyboard/gamepad output and LED lighting. Requires Windows 8 or later.
|
||||
|
||||
[Download link](https://github.com/4yn/slidershim/releases/latest)
|
||||
[Download link](https://github.com/4yn/slidershim/releases/latest) | [Demo Video (Brokestalgia)](https://youtu.be/1PEtBP3cOew) | [UMIGURI setup instructions](https://user-images.githubusercontent.com/8877057/175786037-c0c3238b-5032-4d69-833c-5fb147d85734.mp4)
|
||||
|
||||
> Starting 0.2.0, there are reports that windows defender may block this software. You may need to disable windows defender the first time you run slidershim. If you are not comfortable with this, you can [download an older version here](https://github.com/4yn/slidershim/releases/tag/v0.1.4) that is known to be OK with windows defender.
|
||||
|
||||
@@ -12,16 +12,70 @@ Software adapter for various Chunithm slider controllers with a built-in Brokeni
|
||||
|
||||
## Changelog
|
||||
|
||||
- v0.6.0
|
||||
- Support Laverita v3. Thanks @sr1canskhsia
|
||||
- v0.5.1
|
||||
- Support SSL/wss if brokenithm used with tunnelling. Thanks @kokarare1212
|
||||
- v0.5.0
|
||||
- Support for Yubideck 3.0 firmware
|
||||
- v0.4.3
|
||||
- Make Yubideck USB reports more flexible when reading data
|
||||
- v0.4.2
|
||||
- Fix HORI Project Diva gamepad slider output order
|
||||
- v0.4.1
|
||||
- Fix misplaced checkbox label (clicking on "use DirectInput" would check "disable air" instead)
|
||||
- Make Yuancon USB reports more flexible when reading data
|
||||
- v0.4.0
|
||||
- Add DirectInput keyboard emulation using [oblitum/Interception](https://github.com/oblitum/Interception)
|
||||
- Add slide LED support for some controllers
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Older changelog</summary>
|
||||
|
||||
- v0.3.1
|
||||
- Fix wrong key in UMIGURI keyboard layout
|
||||
- v0.3.0
|
||||
- Add UMIGURI LED controller server support
|
||||
- Add UMIGURI default keyboard layout
|
||||
- v0.2.8
|
||||
- Add slider only layout (no buttons) for Project Diva gamepad output
|
||||
- Add options button to Project Diva gamepad output
|
||||
- v0.2.7
|
||||
- Add HORI Project Diva gamepad output and lighting mode
|
||||
- v0.2.6
|
||||
- Add Yubideck controller support
|
||||
- Add option to change Brokenithm sever port
|
||||
- v0.2.5
|
||||
- Add 6k and 4k keyboard output options
|
||||
- Add settings for reactive LED colors
|
||||
- v0.2.4
|
||||
- Restore support for older tablet devices for brokenithm by compiling brokenithm JS with older babel preset
|
||||
- Fix keys staying pressed even after brokenithm controller is closed
|
||||
- New Brokestalgia 28k web touch controller option
|
||||
- v0.2.3
|
||||
- Fix first and last buttons not working with brokenithm
|
||||
- Add option to disable air strings for controllers
|
||||
- Add option to slow down lighting updates
|
||||
- v0.2.2
|
||||
- Retcon serial slider name
|
||||
- Fix crash on some systems due to time math
|
||||
- Add link to repo
|
||||
- v0.2.1
|
||||
- Reactive + Rainbow mode
|
||||
- Fixed byte order for serial slider lights
|
||||
- v0.2.0
|
||||
- Added support for Hori Project DIVA slider protocol
|
||||
- Added support for serial slider protocol
|
||||
- Added 16 key keyboard layout
|
||||
- v0.1.4
|
||||
- Initial public release
|
||||
|
||||
</details>
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
1. [Download here](https://github.com/4yn/slidershim/releases/latest)
|
||||
2. Extract to any location you like.
|
||||
2. Run the msi installer (recommended for first run) or extract zip to any location you like.
|
||||
3. Run `slidershim.exe`.
|
||||
4. Pick your input device, output method and preferred lighting.
|
||||
5. Click apply.
|
||||
@@ -39,9 +93,10 @@ Software adapter for various Chunithm slider controllers with a built-in Brokeni
|
||||
|
||||
1. Set the device option to "Brokenithm" and apply.
|
||||
2. Allow firewall access to `slidershim.exe`
|
||||
> For more info on setting up firewall, check out [instructions at brokenithm-kb](https://github.com/4yn/brokenithm-kb#setup)
|
||||
3. Connect a touch device to the same wifi or local network as your windows machine
|
||||
> Windows hotspot works too, but make sure to give "public" firewall access
|
||||
4. Open the web controller in your tablet device web browser. One of the links should work.
|
||||
4. Open the web controller in your touch device web browser. One of the links should work.
|
||||
1. Either manually type in the IP address if you know what IP it is;
|
||||
2. Or scan the generated "Broknenithm QR" to get a list of clickable links and save some typing.
|
||||
5. (Optional) Add the webpage to home screen and/or enable guided access to avoid accidentally exiting the web controller.
|
||||
@@ -54,13 +109,20 @@ Voltex layout disables air tower, Neardayo layout enables air tower.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<details>
|
||||
<summary><strong>slidershim crashes when I am running it for the first time</strong></summary>
|
||||
|
||||
- Use the .msi installer file instead of the .zip. You may be missing some windows addons that the installer will take care of (specifically Edge WebView).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>My controller is not recognised</strong></summary>
|
||||
|
||||
- slidershim supports the GAMO2 Tasoller and Yuancon Laverita v2 controllers on HID firmware.
|
||||
- slidershim supports the GAMO2 Tasoller, Yuancon Laverita v2 and ZhouSensor 大四 / Yubideck controllers on HID firmware.
|
||||
- If you are using a Tasoller controller, make sure it has the correct HID firmware installed.
|
||||
- If your hardware controller is not one of these, it will not work.
|
||||
- If you have a device that communicates using serial protocol, chances are it will work with the "Diva Slider over Serial" option
|
||||
- If you have a device that communicates using serial protocol, chances are it will work with the "Slider over Serial" option
|
||||
- Hotplug is not supported. If you plugged in the controller after starting slidershim, re-connect your controller by just clicking the "Apply" button (even if it is grey).
|
||||
|
||||
</details>
|
||||
@@ -73,6 +135,13 @@ Voltex layout disables air tower, Neardayo layout enables air tower.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Keyboard / XBOX Controller output feels sluggish</strong></summary>
|
||||
|
||||
- Increase output polling rate. This does not change how fast your controller is updated, but it does reduce lag with keyboard / XBOX controller simulation.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>The Brokenithm controller cannot be loaded</strong></summary>
|
||||
|
||||
@@ -92,9 +161,10 @@ Voltex layout disables air tower, Neardayo layout enables air tower.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>slidershim 2.0 crashes right after I turn it on</strong></summary>
|
||||
<summary><strong>slidershim 0.2.0 crashes right after I turn it on</strong></summary>
|
||||
|
||||
I'm not sure why this happens. I suspect some cases are because of windows defender and other antivirus software stopping the process while running. Try disabling antivirus or using an [older version of slidershim](https://github.com/4yn/slidershim/releases/tag/v0.1.4).
|
||||
- I'm not sure why this happens. I suspect some cases are because of windows defender and other antivirus software stopping the process while running.
|
||||
- Try disabling antivirus or using an [older version of slidershim](https://github.com/4yn/slidershim/releases/tag/v0.1.4).
|
||||
|
||||
</details>
|
||||
|
||||
@@ -115,21 +185,34 @@ I'm not sure why this happens. I suspect some cases are because of windows defen
|
||||
|
||||
## Technical Information
|
||||
|
||||
- Built with Rust, [tauri](https://github.com/tauri-apps/tauri) + [Svelte](https://github.com/sveltejs/svelte), [rusb](https://github.com/a1ien/rusb), [vigem](https://github.com/ViGEm/ViGEmClient)[-client](https://github.com/CasualX/vigem-client), [hyper](https://github.com/hyperium/hyper/), [tokio-](https://github.com/snapview/tokio-tungstenite)[tungstenite](https://github.com/snapview/tungstenite-rs), [serialport](https://crates.io/crates/serialport), [dtolnay/cxx](https://github.com/dtolnay/cxx) and [wjwwood/serial](https://github.com/wjwwood/serial)
|
||||
- Built with Rust, [tauri](https://github.com/tauri-apps/tauri) + [Svelte](https://github.com/sveltejs/svelte), [rusb](https://github.com/a1ien/rusb), [vigem](https://github.com/ViGEm/ViGEmClient)[-client](https://github.com/CasualX/vigem-client), [hyper](https://github.com/hyperium/hyper/), [tokio-](https://github.com/snapview/tokio-tungstenite)[tungstenite](https://github.com/snapview/tungstenite-rs), [serialport](https://crates.io/crates/serialport), [dtolnay/cxx](https://github.com/dtolnay/cxx), [wjwwood/serial](https://github.com/wjwwood/serial), [oblitum/Interception](https://github.com/oblitum/Interception) and [bozbez/interception-rs](https://github.com/bozbez/interception-rs)
|
||||
- USB device and serial polling is done on a dedicated thread while everything else is done on a async runtime.
|
||||
|
||||
### Building from Source
|
||||
|
||||
1. Install [Visual Studio Community 2019/2022](https://visualstudio.microsoft.com/vs/) with C++ developer kit
|
||||
2. Install [rustup](https://rustup.rs/) with nightly toolchain
|
||||
3. Install [node.js](https://nodejs.org/en/download/) and [yarn](https://www.npmjs.com/package/yarn)
|
||||
4. (Optional) Setup [VSCode](https://code.visualstudio.com/) with [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer)
|
||||
5. Clone this repository
|
||||
6. (Optional) If using powershell, `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass` to whitelist `yarn` script
|
||||
7. `yarn install`
|
||||
8. `yarn tauri dev` / `yarn tauri build`
|
||||
|
||||
### Repository Layout
|
||||
|
||||
- [`public`](./public) / [`src`](./src): Svelte frontend
|
||||
- [`src-tauri`](./src-tauri): Tauri adapter between frontend and backend
|
||||
- [`src-slider_io`](./src-slider_io): Backend logic for handling usb, brokenithm, output emulation and lighting.
|
||||
- [`src-wwserial`](./src-wwserial): FFI to [wjwwood/serial](https://github.com/wjwwood/serial) using [dtolnay/cxx](https://github.com/dtolnay/cxx). For some reason [serialport](https://crates.io/crates/serialport) does not work well with hardware devices, so we use this as an alternative.
|
||||
- [`src-interception`](./src-interception): Vendored [bozbez/interception-rs](https://github.com/bozbez/interception-rs) that statically links against [oblitum/Interception](https://github.com/oblitum/Interception) for DirectInput keyboard emulation.
|
||||
- [`res`](./res): Miscellaneous tools such as Brokenithm QR parser and keyboard layout visualisation.
|
||||
|
||||
## Planned Features
|
||||
|
||||
- Major:
|
||||
- ✅ DONE: Support AC slider serial protocol
|
||||
- Output and LED websocket adapters when UMIGURI comes out
|
||||
- ✅ DONE: Output and LED websocket adapters when UMIGURI comes out
|
||||
- QOL:
|
||||
- Documentation
|
||||
- Comprehensive logging and error handling
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||
"@rollup/plugin-typescript": "^8.0.0",
|
||||
"@tauri-apps/cli": "^1.0.0-beta.10",
|
||||
"@tauri-apps/cli": "^1.0.4",
|
||||
"@tsconfig/svelte": "^2.0.0",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-css-only": "^3.1.0",
|
||||
@@ -27,7 +27,7 @@
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.0.0-beta.8",
|
||||
"@tauri-apps/api": "^1.0.2",
|
||||
"sharp": "^0.30.0",
|
||||
"sirv-cli": "^2.0.0"
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@ body {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 1rem;
|
||||
@@ -75,10 +71,32 @@ body {
|
||||
|
||||
.main {
|
||||
margin-top: 2rem;
|
||||
height: calc(100% - 2rem);
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.preview-row {
|
||||
flex: 0 1;
|
||||
}
|
||||
|
||||
.options {
|
||||
padding: 0.5rem 0.25rem;
|
||||
|
||||
flex: 1 1;
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.buttons-row {
|
||||
flex: 0 1;
|
||||
}
|
||||
|
||||
.row,
|
||||
@@ -106,6 +124,10 @@ body {
|
||||
flex: 2 2 0;
|
||||
}
|
||||
|
||||
.comment {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.serverlist {
|
||||
width: 100%;
|
||||
max-height: 5rem;
|
||||
@@ -113,6 +135,11 @@ body {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.iplist {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
input,
|
||||
select {
|
||||
width: 100%;
|
||||
@@ -156,19 +183,52 @@ button.primary {
|
||||
|
||||
.air {
|
||||
height: 2rem;
|
||||
position: relative;
|
||||
|
||||
border-radius: 0.5rem 0.5rem 0 0;
|
||||
overflow: clip;
|
||||
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.air-btn, .air-led {
|
||||
height: 2rem;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.air-led {
|
||||
flex-flow: row nowrap;
|
||||
}
|
||||
|
||||
.air-led-left, .air-led-right {
|
||||
display: flex;
|
||||
flex-flow: column-reverse nowrap;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
|
||||
border-radius: 0.5rem 0.5rem 0 0;
|
||||
overflow: clip;
|
||||
flex: 1;
|
||||
}
|
||||
.air-data {
|
||||
.air-led-data {
|
||||
flex: 1 0;
|
||||
}
|
||||
.air-data-0 {
|
||||
background: #000;
|
||||
|
||||
.air-led-space {
|
||||
flex: 14;
|
||||
}
|
||||
|
||||
.air-btn {
|
||||
background: #0008;
|
||||
flex-flow: column-reverse nowrap;
|
||||
}
|
||||
|
||||
.air-data {
|
||||
flex: 1 0;
|
||||
}
|
||||
.air-data-1 {
|
||||
background: #0aa;
|
||||
|
||||
@@ -1,373 +1,528 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
body {
|
||||
max-width: 1200px;
|
||||
margin: 2rem auto;
|
||||
padding: 0 1rem;
|
||||
font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
|
||||
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
color: #444;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
max-width: 1200px;
|
||||
margin: 40px auto;
|
||||
padding: 0 10px;
|
||||
font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
|
||||
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
color: #444;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 20px;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
line-height: 1.2;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
color: #ccc;
|
||||
background: black;
|
||||
}
|
||||
a:link {
|
||||
color: #5bf;
|
||||
}
|
||||
a:visited {
|
||||
color: #ccf;
|
||||
}
|
||||
color: #ccc;
|
||||
background: black;
|
||||
}
|
||||
|
||||
.layout {
|
||||
display: grid;
|
||||
|
||||
width: 36rem;
|
||||
height: 13rem;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
gap: 0.5rem;
|
||||
|
||||
grid: 1.5rem 8.5rem 2rem / 32rem 3.5rem;
|
||||
grid-template-areas:
|
||||
"t a"
|
||||
"b a"
|
||||
"e a";
|
||||
a:link {
|
||||
color: #5bf;
|
||||
}
|
||||
|
||||
.name {
|
||||
display: flex;
|
||||
flex: row nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
|
||||
grid-area: t;
|
||||
a:visited {
|
||||
color: #ccf;
|
||||
}
|
||||
}
|
||||
|
||||
.ground {
|
||||
grid-area: b;
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.layout {
|
||||
display: grid;
|
||||
|
||||
gap: 0.25rem;
|
||||
width: 36rem;
|
||||
height: 13rem;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
font-size: 1.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
gap: 0.5rem;
|
||||
|
||||
.ground div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
grid: 1.5rem 8.5rem 2rem / 32rem 3.5rem;
|
||||
grid-template-areas:
|
||||
"t a"
|
||||
"b a"
|
||||
"e a";
|
||||
}
|
||||
|
||||
background-color: #ff04;
|
||||
}
|
||||
.name {
|
||||
display: flex;
|
||||
flex: row nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
|
||||
.ground.ground-32 {
|
||||
grid: repeat(2, 1fr) / repeat(16, 1fr);
|
||||
}
|
||||
grid-area: t;
|
||||
}
|
||||
|
||||
.ground.ground-16 {
|
||||
grid: repeat(1, 1fr) / repeat(16, 1fr);
|
||||
}
|
||||
.ground {
|
||||
grid-area: b;
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.ground.ground-8 {
|
||||
grid: repeat(1, 1fr) / repeat(8, 1fr);
|
||||
}
|
||||
gap: 0.25rem;
|
||||
|
||||
.ground.ground-voltex {
|
||||
grid: repeat(2, 1fr) / repeat(8, 1fr);
|
||||
grid-template-areas:
|
||||
"ll lr a b c d rl rr"
|
||||
"ll lr fl fl fr fr rl rr";
|
||||
}
|
||||
font-size: 1.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.air {
|
||||
grid-area: a;
|
||||
.ground div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #ff04;
|
||||
}
|
||||
|
||||
grid: repeat(6, 1fr) / repeat(1, 1fr);
|
||||
gap: 0.25rem;
|
||||
.ground.ground-32 {
|
||||
grid: repeat(2, 1fr) / repeat(16, 1fr);
|
||||
}
|
||||
|
||||
font-family: monospace;
|
||||
}
|
||||
.ground.ground-16 {
|
||||
grid: repeat(1, 1fr) / repeat(16, 1fr);
|
||||
}
|
||||
|
||||
.air div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.ground.ground-8 {
|
||||
grid: repeat(1, 1fr) / repeat(8, 1fr);
|
||||
}
|
||||
|
||||
background-color: #0ff4;
|
||||
}
|
||||
.ground.ground-6 {
|
||||
grid: repeat(1, 1fr) / 3fr 2fr 3fr 3fr 2fr 3fr;
|
||||
}
|
||||
|
||||
.air.air-single {
|
||||
grid: repeat(1, 1fr) / repeat(1, 1fr);
|
||||
}
|
||||
.ground.ground-4 {
|
||||
grid: repeat(1, 1fr) / repeat(4, 1fr);
|
||||
}
|
||||
|
||||
.air.air-voltex {
|
||||
grid-template-areas:
|
||||
"rr"
|
||||
"rl"
|
||||
"rl"
|
||||
"lr"
|
||||
"lr"
|
||||
"ll";
|
||||
}
|
||||
.ground.ground-1 {
|
||||
grid: repeat(1, 1fr) / repeat(1, 1fr);
|
||||
}
|
||||
|
||||
.extra {
|
||||
grid-area: e;
|
||||
.ground.ground-voltex {
|
||||
grid: repeat(2, 1fr) / repeat(8, 1fr);
|
||||
grid-template-areas:
|
||||
"ll lr a b c d rl rr"
|
||||
"ll lr fl fl fr fr rl rr";
|
||||
}
|
||||
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.ground.ground-diva {
|
||||
grid: repeat(2, 1fr) / repeat(4, 1fr);
|
||||
grid-template-areas:
|
||||
"sl sl sl sl"
|
||||
"a b c d";
|
||||
}
|
||||
|
||||
grid: repeat(1, 1fr) / repeat(3, 1fr);
|
||||
gap: 0.25rem;
|
||||
.air {
|
||||
grid-area: a;
|
||||
|
||||
font-family: monospace;
|
||||
}
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.extra div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
grid: repeat(6, 1fr) / repeat(1, 1fr);
|
||||
gap: 0.25rem;
|
||||
|
||||
background-color: #f004;
|
||||
}
|
||||
</style>
|
||||
<title>Slidershim Layouts</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 32-zone, Tasoller Layout</div>
|
||||
<div class="ground ground-32">
|
||||
<div>1</div>
|
||||
<div>Q</div>
|
||||
<div>2</div>
|
||||
<div>W</div>
|
||||
<div>3</div>
|
||||
<div>E</div>
|
||||
<div>4</div>
|
||||
<div>R</div>
|
||||
<div>5</div>
|
||||
<div>T</div>
|
||||
<div>6</div>
|
||||
<div>Y</div>
|
||||
<div>7</div>
|
||||
<div>U</div>
|
||||
<div>8</div>
|
||||
<div>I</div>
|
||||
<div>A</div>
|
||||
<div>Z</div>
|
||||
<div>S</div>
|
||||
<div>X</div>
|
||||
<div>D</div>
|
||||
<div>C</div>
|
||||
<div>F</div>
|
||||
<div>V</div>
|
||||
<div>G</div>
|
||||
<div>B</div>
|
||||
<div>H</div>
|
||||
<div>N</div>
|
||||
<div>J</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>,</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>;</div>
|
||||
<div>.</div>
|
||||
<div>'</div>
|
||||
<div>/</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.air div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
background-color: #0ff4;
|
||||
}
|
||||
|
||||
.air.air-single {
|
||||
grid: repeat(1, 1fr) / repeat(1, 1fr);
|
||||
}
|
||||
|
||||
.air.air-voltex {
|
||||
grid-template-areas:
|
||||
"rr"
|
||||
"rl"
|
||||
"rl"
|
||||
"lr"
|
||||
"lr"
|
||||
"ll";
|
||||
}
|
||||
|
||||
.extra {
|
||||
grid-area: e;
|
||||
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
grid: repeat(1, 1fr) / repeat(3, 1fr);
|
||||
gap: 0.25rem;
|
||||
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.extra div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
background-color: #f004;
|
||||
}
|
||||
</style>
|
||||
<title>Slidershim Layouts</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 32-zone, Tasoller Layout</div>
|
||||
<div class="ground ground-32">
|
||||
<div>1</div>
|
||||
<div>Q</div>
|
||||
<div>2</div>
|
||||
<div>W</div>
|
||||
<div>3</div>
|
||||
<div>E</div>
|
||||
<div>4</div>
|
||||
<div>R</div>
|
||||
<div>5</div>
|
||||
<div>T</div>
|
||||
<div>6</div>
|
||||
<div>Y</div>
|
||||
<div>7</div>
|
||||
<div>U</div>
|
||||
<div>8</div>
|
||||
<div>I</div>
|
||||
<div>A</div>
|
||||
<div>Z</div>
|
||||
<div>S</div>
|
||||
<div>X</div>
|
||||
<div>D</div>
|
||||
<div>C</div>
|
||||
<div>F</div>
|
||||
<div>V</div>
|
||||
<div>G</div>
|
||||
<div>B</div>
|
||||
<div>H</div>
|
||||
<div>N</div>
|
||||
<div>J</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>,</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>;</div>
|
||||
<div>.</div>
|
||||
<div>'</div>
|
||||
<div>/</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 32-zone, Yuancon Layout</div>
|
||||
<div class="ground ground-32">
|
||||
<div>5</div>
|
||||
<div>3</div>
|
||||
<div>1</div>
|
||||
<div>Y</div>
|
||||
<div>W</div>
|
||||
<div>U</div>
|
||||
<div>S</div>
|
||||
<div>Q</div>
|
||||
<div>O</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>I</div>
|
||||
<div>G</div>
|
||||
<div>E</div>
|
||||
<div>C</div>
|
||||
<div>A</div>
|
||||
<div>6</div>
|
||||
<div>4</div>
|
||||
<div>2</div>
|
||||
<div>Z</div>
|
||||
<div>X</div>
|
||||
<div>V</div>
|
||||
<div>T</div>
|
||||
<div>R</div>
|
||||
<div>P</div>
|
||||
<div>N</div>
|
||||
<div>L</div>
|
||||
<div>J</div>
|
||||
<div>H</div>
|
||||
<div>F</div>
|
||||
<div>D</div>
|
||||
<div>B</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>;</div>
|
||||
<div>\</div>
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>=</div>
|
||||
<div>-</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 32-zone, UMIGURI Layout</div>
|
||||
<div class="ground ground-32">
|
||||
<div>1</div>
|
||||
<div>Q</div>
|
||||
<div>2</div>
|
||||
<div>W</div>
|
||||
<div>3</div>
|
||||
<div>E</div>
|
||||
<div>4</div>
|
||||
<div>R</div>
|
||||
<div>5</div>
|
||||
<div>T</div>
|
||||
<div>6</div>
|
||||
<div>Y</div>
|
||||
<div>7</div>
|
||||
<div>U</div>
|
||||
<div>8</div>
|
||||
<div>I</div>
|
||||
<div>A</div>
|
||||
<div>Z</div>
|
||||
<div>S</div>
|
||||
<div>X</div>
|
||||
<div>D</div>
|
||||
<div>C</div>
|
||||
<div>F</div>
|
||||
<div>V</div>
|
||||
<div>G</div>
|
||||
<div>B</div>
|
||||
<div>H</div>
|
||||
<div>N</div>
|
||||
<div>J</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>9</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>.</div>
|
||||
<div>,</div>
|
||||
<div>P</div>
|
||||
<div>L</div>
|
||||
<div>O</div>
|
||||
<div>0</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout">
|
||||
</div>
|
||||
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 16-zone, Linear</div>
|
||||
<div class="ground ground-16">
|
||||
<div>A</div>
|
||||
<div>Z</div>
|
||||
<div>S</div>
|
||||
<div>X</div>
|
||||
<div>D</div>
|
||||
<div>C</div>
|
||||
<div>F</div>
|
||||
<div>V</div>
|
||||
<div>G</div>
|
||||
<div>B</div>
|
||||
<div>H</div>
|
||||
<div>N</div>
|
||||
<div>J</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>,</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>;</div>
|
||||
<div>.</div>
|
||||
<div>'</div>
|
||||
<div>/</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 8-zone, Linear</div>
|
||||
<div class="ground ground-8">
|
||||
<div>A</div>
|
||||
<div>S</div>
|
||||
<div>D</div>
|
||||
<div>F</div>
|
||||
<div>J</div>
|
||||
<div>K</div>
|
||||
<div>L</div>
|
||||
<div>;</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[space]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 32-zone, Yuancon Layout</div>
|
||||
<div class="ground ground-32">
|
||||
<div>5</div>
|
||||
<div>3</div>
|
||||
<div>1</div>
|
||||
<div>Y</div>
|
||||
<div>W</div>
|
||||
<div>U</div>
|
||||
<div>S</div>
|
||||
<div>Q</div>
|
||||
<div>O</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>I</div>
|
||||
<div>G</div>
|
||||
<div>E</div>
|
||||
<div>C</div>
|
||||
<div>A</div>
|
||||
<div>6</div>
|
||||
<div>4</div>
|
||||
<div>2</div>
|
||||
<div>Z</div>
|
||||
<div>X</div>
|
||||
<div>V</div>
|
||||
<div>T</div>
|
||||
<div>R</div>
|
||||
<div>P</div>
|
||||
<div>N</div>
|
||||
<div>L</div>
|
||||
<div>J</div>
|
||||
<div>H</div>
|
||||
<div>F</div>
|
||||
<div>D</div>
|
||||
<div>B</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>;</div>
|
||||
<div>\</div>
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>=</div>
|
||||
<div>-</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
<div class="extra">
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 6-zone, Linear</div>
|
||||
<div class="ground ground-6">
|
||||
<div>S</div>
|
||||
<div>D</div>
|
||||
<div>F</div>
|
||||
<div>J</div>
|
||||
<div>K</div>
|
||||
<div>L</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[space]</span>
|
||||
</div>
|
||||
</div>
|
||||
<body>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 16-zone, Tasoller (Bottom Half) Layout</div>
|
||||
<div class="ground ground-16">
|
||||
<div>A</div>
|
||||
<div>Z</div>
|
||||
<div>S</div>
|
||||
<div>X</div>
|
||||
<div>D</div>
|
||||
<div>C</div>
|
||||
<div>F</div>
|
||||
<div>V</div>
|
||||
<div>G</div>
|
||||
<div>B</div>
|
||||
<div>H</div>
|
||||
<div>N</div>
|
||||
<div>J</div>
|
||||
<div>M</div>
|
||||
<div>K</div>
|
||||
<div>,</div>
|
||||
</div>
|
||||
<div class="air">
|
||||
<div>]</div>
|
||||
<div>[</div>
|
||||
<div>;</div>
|
||||
<div>.</div>
|
||||
<div>'</div>
|
||||
<div>/</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[enter]</div>
|
||||
<div>[space]</div>
|
||||
<div>[esc]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 8-zone, Deemo Layout</div>
|
||||
<div class="ground ground-8">
|
||||
<div>A</div>
|
||||
<div>S</div>
|
||||
<div>D</div>
|
||||
<div>F</div>
|
||||
<div>J</div>
|
||||
<div>K</div>
|
||||
<div>L</div>
|
||||
<div>;</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[space]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
<div class="extra">
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 4-zone, Linear</div>
|
||||
<div class="ground ground-4">
|
||||
<div>D</div>
|
||||
<div>F</div>
|
||||
<div>J</div>
|
||||
<div>K</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[space]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 10-zone, Voltex/Neardayo Layout</div>
|
||||
<div class="ground ground-voltex">
|
||||
<div style="grid-area: ll">W</div>
|
||||
<div style="grid-area: lr">E</div>
|
||||
<div style="grid-area: rl">O</div>
|
||||
<div style="grid-area: rr">P</div>
|
||||
<div style="grid-area: a">D</div>
|
||||
<div style="grid-area: b">F</div>
|
||||
<div style="grid-area: c">J</div>
|
||||
<div style="grid-area: d">K</div>
|
||||
<div style="grid-area: fl">C</div>
|
||||
<div style="grid-area: fr">M</div>
|
||||
</div>
|
||||
<div class="air air-voltex">
|
||||
<div style="grid-area: rr">P</div>
|
||||
<div style="grid-area: rl">O</div>
|
||||
<div style="grid-area: lr">E</div>
|
||||
<div style="grid-area: ll">W</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>1</div>
|
||||
<div>[esc]</div>
|
||||
<div>[enter]</div>
|
||||
<div class="extra">
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">Keyboard 10-zone, Voltex/Neardayo Layout</div>
|
||||
<div class="ground ground-voltex">
|
||||
<div style="grid-area: ll">W</div>
|
||||
<div style="grid-area: lr">E</div>
|
||||
<div style="grid-area: rl">O</div>
|
||||
<div style="grid-area: rr">P</div>
|
||||
<div style="grid-area: a">D</div>
|
||||
<div style="grid-area: b">F</div>
|
||||
<div style="grid-area: c">J</div>
|
||||
<div style="grid-area: d">K</div>
|
||||
<div style="grid-area: fl">C</div>
|
||||
<div style="grid-area: fr">M</div>
|
||||
</div>
|
||||
<div class="air air-voltex">
|
||||
<div style="grid-area: rr">P</div>
|
||||
<div style="grid-area: rl">O</div>
|
||||
<div style="grid-area: lr">E</div>
|
||||
<div style="grid-area: ll">W</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>1</div>
|
||||
<div>[esc]</div>
|
||||
<div>[enter]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">XBOX 360 Gamepad, Voltex/Neardayo Layout</div>
|
||||
<div class="ground ground-voltex">
|
||||
<div style="grid-area: ll">LS<br /><<</div>
|
||||
<div style="grid-area: lr">LS<br />>></div>
|
||||
<div style="grid-area: rl">RS<br /><<</div>
|
||||
<div style="grid-area: rr">RS<br />>></div>
|
||||
<div style="grid-area: a">A</div>
|
||||
<div style="grid-area: b">B</div>
|
||||
<div style="grid-area: c">X</div>
|
||||
<div style="grid-area: d">Y</div>
|
||||
<div style="grid-area: fl">LB</div>
|
||||
<div style="grid-area: fr">RB</div>
|
||||
</div>
|
||||
<div class="air air-voltex">
|
||||
<div style="grid-area: rr">RS></div>
|
||||
<div style="grid-area: rl">RS<</div>
|
||||
<div style="grid-area: lr">LS></div>
|
||||
<div style="grid-area: ll">LS<</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[start]</div>
|
||||
<div>[back]</div>
|
||||
<div>[guide]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">DS4, HORI DIVA FT ASC Layout</div>
|
||||
<div class="ground ground-diva">
|
||||
<div style="grid-area: sl">[slider]</div>
|
||||
<div style="grid-area: a">Triangle</div>
|
||||
<div style="grid-area: b">Square</div>
|
||||
<div style="grid-area: c">Cross</div>
|
||||
<div style="grid-area: d">Circle</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[disabled]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">XBOX 360 Gamepad, Voltex/Neardayo Layout</div>
|
||||
<div class="ground ground-voltex">
|
||||
<div style="grid-area: ll">LS<br /><<</div>
|
||||
<div style="grid-area: lr">LS<br />>></div>
|
||||
<div style="grid-area: rl">RS<br /><<</div>
|
||||
<div style="grid-area: rr">RS<br />>></div>
|
||||
<div style="grid-area: a">A</div>
|
||||
<div style="grid-area: b">B</div>
|
||||
<div style="grid-area: c">X</div>
|
||||
<div style="grid-area: d">Y</div>
|
||||
<div style="grid-area: fl">LB</div>
|
||||
<div style="grid-area: fr">RB</div>
|
||||
</div>
|
||||
<div class="air air-voltex">
|
||||
<div style="grid-area: rr">RS></div>
|
||||
<div style="grid-area: rl">RS<</div>
|
||||
<div style="grid-area: lr">LS></div>
|
||||
<div style="grid-area: ll">LS<</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<div>[start]</div>
|
||||
<div>[back]</div>
|
||||
<div>[guide]</div>
|
||||
<div class="extra">
|
||||
<div>[options]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout">
|
||||
<div class="name">DS4, HORI DIVA FT ASC Slider Only Layout</div>
|
||||
<div class="ground ground-1">
|
||||
<div>[slider]</div>
|
||||
</div>
|
||||
<div class="air air-single">
|
||||
<div>
|
||||
<span style="writing-mode: vertical-lr">[disabled]</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<div class="extra">
|
||||
<div>[options]</div>
|
||||
<div>[disabled]</div>
|
||||
<div>[disabled]</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 24 KiB |
@@ -39,25 +39,22 @@
|
||||
<ul class="links"></ul>
|
||||
<script>
|
||||
(function () {
|
||||
const search = window.location.search;
|
||||
if (search.slice(0, 3) !== "?d=" || search.length <= 3) {
|
||||
return;
|
||||
}
|
||||
const ul = document.querySelector(".links");
|
||||
search
|
||||
.slice(3)
|
||||
.split(";")
|
||||
.map((x) => atob(x))
|
||||
.forEach((ip) => {
|
||||
const li = document.createElement("li");
|
||||
const a = document.createElement("a");
|
||||
a.innerText = ip;
|
||||
a.setAttribute("target", "_blank");
|
||||
a.setAttribute("rel", "noopener");
|
||||
a.href = `http://${ip}:1606/`;
|
||||
li.appendChild(a);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
var d = params.get("d") || "";
|
||||
var p = params.get("p") || "1606";
|
||||
var ul = document.querySelector(".links");
|
||||
d.split(";").forEach(function (aip) {
|
||||
var ip = atob(aip);
|
||||
console.log(aip, ip);
|
||||
var li = document.createElement("li");
|
||||
var a = document.createElement("a");
|
||||
a.innerText = "".concat(ip, ":").concat(p);
|
||||
a.setAttribute("target", "_blank");
|
||||
a.setAttribute("rel", "noopener");
|
||||
a.href = "http://".concat(ip, ":").concat(p, "/");
|
||||
li.appendChild(a);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
target/
|
||||
@@ -0,0 +1,140 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"num_enum",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
|
||||
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
num_enum = "0.5.0"
|
||||
serde = { version = "1.0.114", features = ["derive"] }
|
||||
@@ -0,0 +1,173 @@
|
||||
Derived from https://github.com/bozbez/interception-sys and https://github.com/bozbez/interception-rs
|
||||
|
||||
Repackaged to link statically with https://github.com/oblitum/Interception 1.0.1 instead of using dynamic library.
|
||||
|
||||
Interception is licensed under LGPL 3.0 for non-commercial use. Interception-sys and interception-rs according to its Cargo.toml are licensed under LGPL 3.0.
|
||||
|
||||
```
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=include/interception.h");
|
||||
println!("cargo:rerun-if-changed=src/interception.c");
|
||||
cc::Build::new()
|
||||
.define("INTERCEPTION_STATIC", None)
|
||||
.file("src/interception.c")
|
||||
.include("include/")
|
||||
.compile("interception");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=interception");
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
#ifndef _INTERCEPTION_H_
|
||||
#define _INTERCEPTION_H_
|
||||
|
||||
#ifdef INTERCEPTION_STATIC
|
||||
#define INTERCEPTION_API
|
||||
#else
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef INTERCEPTION_EXPORT
|
||||
#ifdef __GNUC__
|
||||
#define INTERCEPTION_API __attribute__((dllexport))
|
||||
#else
|
||||
#define INTERCEPTION_API __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define INTERCEPTION_API __attribute__((dllimport))
|
||||
#else
|
||||
#define INTERCEPTION_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define INTERCEPTION_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define INTERCEPTION_API
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INTERCEPTION_MAX_KEYBOARD 10
|
||||
|
||||
#define INTERCEPTION_MAX_MOUSE 10
|
||||
|
||||
#define INTERCEPTION_MAX_DEVICE ((INTERCEPTION_MAX_KEYBOARD) + (INTERCEPTION_MAX_MOUSE))
|
||||
|
||||
#define INTERCEPTION_KEYBOARD(index) ((index) + 1)
|
||||
|
||||
#define INTERCEPTION_MOUSE(index) ((INTERCEPTION_MAX_KEYBOARD) + (index) + 1)
|
||||
|
||||
typedef void *InterceptionContext;
|
||||
|
||||
typedef int InterceptionDevice;
|
||||
|
||||
typedef int InterceptionPrecedence;
|
||||
|
||||
typedef unsigned short InterceptionFilter;
|
||||
|
||||
typedef int (*InterceptionPredicate)(InterceptionDevice device);
|
||||
|
||||
enum InterceptionKeyState
|
||||
{
|
||||
INTERCEPTION_KEY_DOWN = 0x00,
|
||||
INTERCEPTION_KEY_UP = 0x01,
|
||||
INTERCEPTION_KEY_E0 = 0x02,
|
||||
INTERCEPTION_KEY_E1 = 0x04,
|
||||
INTERCEPTION_KEY_TERMSRV_SET_LED = 0x08,
|
||||
INTERCEPTION_KEY_TERMSRV_SHADOW = 0x10,
|
||||
INTERCEPTION_KEY_TERMSRV_VKPACKET = 0x20
|
||||
};
|
||||
|
||||
enum InterceptionFilterKeyState
|
||||
{
|
||||
INTERCEPTION_FILTER_KEY_NONE = 0x0000,
|
||||
INTERCEPTION_FILTER_KEY_ALL = 0xFFFF,
|
||||
INTERCEPTION_FILTER_KEY_DOWN = INTERCEPTION_KEY_UP,
|
||||
INTERCEPTION_FILTER_KEY_UP = INTERCEPTION_KEY_UP << 1,
|
||||
INTERCEPTION_FILTER_KEY_E0 = INTERCEPTION_KEY_E0 << 1,
|
||||
INTERCEPTION_FILTER_KEY_E1 = INTERCEPTION_KEY_E1 << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_SET_LED = INTERCEPTION_KEY_TERMSRV_SET_LED << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_SHADOW = INTERCEPTION_KEY_TERMSRV_SHADOW << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_VKPACKET = INTERCEPTION_KEY_TERMSRV_VKPACKET << 1
|
||||
};
|
||||
|
||||
enum InterceptionMouseState
|
||||
{
|
||||
INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN = 0x001,
|
||||
INTERCEPTION_MOUSE_LEFT_BUTTON_UP = 0x002,
|
||||
INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN = 0x004,
|
||||
INTERCEPTION_MOUSE_RIGHT_BUTTON_UP = 0x008,
|
||||
INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN = 0x010,
|
||||
INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP = 0x020,
|
||||
|
||||
INTERCEPTION_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
|
||||
INTERCEPTION_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
|
||||
INTERCEPTION_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
|
||||
|
||||
INTERCEPTION_MOUSE_BUTTON_4_DOWN = 0x040,
|
||||
INTERCEPTION_MOUSE_BUTTON_4_UP = 0x080,
|
||||
INTERCEPTION_MOUSE_BUTTON_5_DOWN = 0x100,
|
||||
INTERCEPTION_MOUSE_BUTTON_5_UP = 0x200,
|
||||
|
||||
INTERCEPTION_MOUSE_WHEEL = 0x400,
|
||||
INTERCEPTION_MOUSE_HWHEEL = 0x800
|
||||
};
|
||||
|
||||
enum InterceptionFilterMouseState
|
||||
{
|
||||
INTERCEPTION_FILTER_MOUSE_NONE = 0x0000,
|
||||
INTERCEPTION_FILTER_MOUSE_ALL = 0xFFFF,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_BUTTON_1_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_BUTTON_1_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_BUTTON_2_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_BUTTON_2_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_BUTTON_3_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_BUTTON_3_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_4_DOWN = INTERCEPTION_MOUSE_BUTTON_4_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_4_UP = INTERCEPTION_MOUSE_BUTTON_4_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_5_DOWN = INTERCEPTION_MOUSE_BUTTON_5_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_5_UP = INTERCEPTION_MOUSE_BUTTON_5_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_WHEEL = INTERCEPTION_MOUSE_WHEEL,
|
||||
INTERCEPTION_FILTER_MOUSE_HWHEEL = INTERCEPTION_MOUSE_HWHEEL,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_MOVE = 0x1000
|
||||
};
|
||||
|
||||
enum InterceptionMouseFlag
|
||||
{
|
||||
INTERCEPTION_MOUSE_MOVE_RELATIVE = 0x000,
|
||||
INTERCEPTION_MOUSE_MOVE_ABSOLUTE = 0x001,
|
||||
INTERCEPTION_MOUSE_VIRTUAL_DESKTOP = 0x002,
|
||||
INTERCEPTION_MOUSE_ATTRIBUTES_CHANGED = 0x004,
|
||||
INTERCEPTION_MOUSE_MOVE_NOCOALESCE = 0x008,
|
||||
INTERCEPTION_MOUSE_TERMSRV_SRC_SHADOW = 0x100
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short state;
|
||||
unsigned short flags;
|
||||
short rolling;
|
||||
int x;
|
||||
int y;
|
||||
unsigned int information;
|
||||
} InterceptionMouseStroke;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short code;
|
||||
unsigned short state;
|
||||
unsigned int information;
|
||||
} InterceptionKeyStroke;
|
||||
|
||||
typedef char InterceptionStroke[sizeof(InterceptionMouseStroke)];
|
||||
|
||||
InterceptionContext INTERCEPTION_API interception_create_context(void);
|
||||
|
||||
void INTERCEPTION_API interception_destroy_context(InterceptionContext context);
|
||||
|
||||
InterceptionPrecedence INTERCEPTION_API interception_get_precedence(InterceptionContext context, InterceptionDevice device);
|
||||
|
||||
void INTERCEPTION_API interception_set_precedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence);
|
||||
|
||||
InterceptionFilter INTERCEPTION_API interception_get_filter(InterceptionContext context, InterceptionDevice device);
|
||||
|
||||
void INTERCEPTION_API interception_set_filter(InterceptionContext context, InterceptionPredicate predicate, InterceptionFilter filter);
|
||||
|
||||
InterceptionDevice INTERCEPTION_API interception_wait(InterceptionContext context);
|
||||
|
||||
InterceptionDevice INTERCEPTION_API interception_wait_with_timeout(InterceptionContext context, unsigned long milliseconds);
|
||||
|
||||
int INTERCEPTION_API interception_send(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *stroke, unsigned int nstroke);
|
||||
|
||||
int INTERCEPTION_API interception_receive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *stroke, unsigned int nstroke);
|
||||
|
||||
unsigned int INTERCEPTION_API interception_get_hardware_id(InterceptionContext context, InterceptionDevice device, void *hardware_id_buffer, unsigned int buffer_size);
|
||||
|
||||
int INTERCEPTION_API interception_is_invalid(InterceptionDevice device);
|
||||
|
||||
int INTERCEPTION_API interception_is_keyboard(InterceptionDevice device);
|
||||
|
||||
int INTERCEPTION_API interception_is_mouse(InterceptionDevice device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,317 @@
|
||||
#![ allow( dead_code, unused_imports, non_upper_case_globals, non_snake_case, deref_nullptr ) ]
|
||||
|
||||
/* automatically generated by rust-bindgen 0.54.1 */
|
||||
|
||||
pub const INTERCEPTION_MAX_KEYBOARD: u32 = 10;
|
||||
pub const INTERCEPTION_MAX_MOUSE: u32 = 10;
|
||||
pub const INTERCEPTION_MAX_DEVICE: u32 = 20;
|
||||
pub type InterceptionContext = *mut ::std::os::raw::c_void;
|
||||
pub type InterceptionDevice = ::std::os::raw::c_int;
|
||||
pub type InterceptionPrecedence = ::std::os::raw::c_int;
|
||||
pub type InterceptionFilter = ::std::os::raw::c_ushort;
|
||||
pub type InterceptionPredicate = ::std::option::Option<
|
||||
unsafe extern "C" fn(device: InterceptionDevice) -> ::std::os::raw::c_int,
|
||||
>;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_DOWN: InterceptionKeyState = 0;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_UP: InterceptionKeyState = 1;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_E0: InterceptionKeyState = 2;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_E1: InterceptionKeyState = 4;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_SET_LED: InterceptionKeyState = 8;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_SHADOW: InterceptionKeyState = 16;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_VKPACKET: InterceptionKeyState = 32;
|
||||
pub type InterceptionKeyState = u32;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_NONE: InterceptionFilterKeyState = 0;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_ALL: InterceptionFilterKeyState =
|
||||
65535;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_DOWN: InterceptionFilterKeyState = 1;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_UP: InterceptionFilterKeyState = 2;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_E0: InterceptionFilterKeyState = 4;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_E1: InterceptionFilterKeyState = 8;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_SET_LED:
|
||||
InterceptionFilterKeyState = 16;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_SHADOW:
|
||||
InterceptionFilterKeyState = 32;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_VKPACKET:
|
||||
InterceptionFilterKeyState = 64;
|
||||
pub type InterceptionFilterKeyState = u32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN: InterceptionMouseState = 1;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_LEFT_BUTTON_UP: InterceptionMouseState = 2;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN: InterceptionMouseState = 4;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_RIGHT_BUTTON_UP: InterceptionMouseState = 8;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN: InterceptionMouseState = 16;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP: InterceptionMouseState = 32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_1_DOWN: InterceptionMouseState = 1;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_1_UP: InterceptionMouseState = 2;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_2_DOWN: InterceptionMouseState = 4;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_2_UP: InterceptionMouseState = 8;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_3_DOWN: InterceptionMouseState = 16;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_3_UP: InterceptionMouseState = 32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_4_DOWN: InterceptionMouseState = 64;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_4_UP: InterceptionMouseState = 128;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_5_DOWN: InterceptionMouseState = 256;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_5_UP: InterceptionMouseState = 512;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_WHEEL: InterceptionMouseState = 1024;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_HWHEEL: InterceptionMouseState = 2048;
|
||||
pub type InterceptionMouseState = u32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_NONE:
|
||||
InterceptionFilterMouseState = 0;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_ALL: InterceptionFilterMouseState =
|
||||
65535;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 1;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 2;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 4;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 8;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 16;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_1_DOWN:
|
||||
InterceptionFilterMouseState = 1;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_1_UP:
|
||||
InterceptionFilterMouseState = 2;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_2_DOWN:
|
||||
InterceptionFilterMouseState = 4;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_2_UP:
|
||||
InterceptionFilterMouseState = 8;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_3_DOWN:
|
||||
InterceptionFilterMouseState = 16;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_3_UP:
|
||||
InterceptionFilterMouseState = 32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_4_DOWN:
|
||||
InterceptionFilterMouseState = 64;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_4_UP:
|
||||
InterceptionFilterMouseState = 128;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_5_DOWN:
|
||||
InterceptionFilterMouseState = 256;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_5_UP:
|
||||
InterceptionFilterMouseState = 512;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_WHEEL:
|
||||
InterceptionFilterMouseState = 1024;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_HWHEEL:
|
||||
InterceptionFilterMouseState = 2048;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MOVE:
|
||||
InterceptionFilterMouseState = 4096;
|
||||
pub type InterceptionFilterMouseState = u32;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_RELATIVE: InterceptionMouseFlag = 0;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_ABSOLUTE: InterceptionMouseFlag = 1;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_VIRTUAL_DESKTOP: InterceptionMouseFlag = 2;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_ATTRIBUTES_CHANGED: InterceptionMouseFlag = 4;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_NOCOALESCE: InterceptionMouseFlag = 8;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_TERMSRV_SRC_SHADOW: InterceptionMouseFlag = 256;
|
||||
pub type InterceptionMouseFlag = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct InterceptionMouseStroke {
|
||||
pub state: ::std::os::raw::c_ushort,
|
||||
pub flags: ::std::os::raw::c_ushort,
|
||||
pub rolling: ::std::os::raw::c_short,
|
||||
pub x: ::std::os::raw::c_int,
|
||||
pub y: ::std::os::raw::c_int,
|
||||
pub information: ::std::os::raw::c_uint,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_InterceptionMouseStroke() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<InterceptionMouseStroke>(),
|
||||
20usize,
|
||||
concat!("Size of: ", stringify!(InterceptionMouseStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<InterceptionMouseStroke>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(InterceptionMouseStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).state as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(state)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).flags as *const _ as usize },
|
||||
2usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).rolling as *const _ as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(rolling)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).x as *const _ as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(x)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).y as *const _ as usize },
|
||||
12usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(y)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::std::ptr::null::<InterceptionMouseStroke>())).information as *const _ as usize
|
||||
},
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(information)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct InterceptionKeyStroke {
|
||||
pub code: ::std::os::raw::c_ushort,
|
||||
pub state: ::std::os::raw::c_ushort,
|
||||
pub information: ::std::os::raw::c_uint,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_InterceptionKeyStroke() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<InterceptionKeyStroke>(),
|
||||
8usize,
|
||||
concat!("Size of: ", stringify!(InterceptionKeyStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<InterceptionKeyStroke>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(InterceptionKeyStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionKeyStroke>())).code as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(code)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionKeyStroke>())).state as *const _ as usize },
|
||||
2usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(state)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::std::ptr::null::<InterceptionKeyStroke>())).information as *const _ as usize
|
||||
},
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(information)
|
||||
)
|
||||
);
|
||||
}
|
||||
pub type InterceptionStroke = [::std::os::raw::c_char; 20usize];
|
||||
extern "C" {
|
||||
pub fn interception_create_context() -> InterceptionContext;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_destroy_context(context: InterceptionContext);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_precedence(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
) -> InterceptionPrecedence;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_set_precedence(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
precedence: InterceptionPrecedence,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_filter(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
) -> InterceptionFilter;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_set_filter(
|
||||
context: InterceptionContext,
|
||||
predicate: InterceptionPredicate,
|
||||
filter: InterceptionFilter,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_wait(context: InterceptionContext) -> InterceptionDevice;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_wait_with_timeout(
|
||||
context: InterceptionContext,
|
||||
milliseconds: ::std::os::raw::c_ulong,
|
||||
) -> InterceptionDevice;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_send(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
stroke: *const InterceptionStroke,
|
||||
nstroke: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_receive(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
stroke: *mut InterceptionStroke,
|
||||
nstroke: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_hardware_id(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
hardware_id_buffer: *mut ::std::os::raw::c_void,
|
||||
buffer_size: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_invalid(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_keyboard(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_mouse(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#include "interception.h"
|
||||
|
||||
#define IOCTL_SET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SET_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x820, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_READ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x840, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_HARDWARE_ID CTL_CODE(FILE_DEVICE_UNKNOWN, 0x880, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
typedef struct _KEYBOARD_INPUT_DATA
|
||||
{
|
||||
USHORT UnitId;
|
||||
USHORT MakeCode;
|
||||
USHORT Flags;
|
||||
USHORT Reserved;
|
||||
ULONG ExtraInformation;
|
||||
} KEYBOARD_INPUT_DATA, *PKEYBOARD_INPUT_DATA;
|
||||
|
||||
typedef struct _MOUSE_INPUT_DATA
|
||||
{
|
||||
USHORT UnitId;
|
||||
USHORT Flags;
|
||||
USHORT ButtonFlags;
|
||||
USHORT ButtonData;
|
||||
ULONG RawButtons;
|
||||
LONG LastX;
|
||||
LONG LastY;
|
||||
ULONG ExtraInformation;
|
||||
} MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
void *unempty;
|
||||
} *InterceptionDeviceArray;
|
||||
|
||||
InterceptionContext interception_create_context(void)
|
||||
{
|
||||
InterceptionDeviceArray device_array = 0;
|
||||
char device_name[] = "\\\\.\\interception00";
|
||||
DWORD bytes_returned;
|
||||
InterceptionDevice i;
|
||||
|
||||
device_array = (InterceptionDeviceArray)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, INTERCEPTION_MAX_DEVICE * sizeof(*((InterceptionDeviceArray) 0)));
|
||||
if(!device_array) return 0;
|
||||
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
HANDLE zero_padded_handle[2] = {0};
|
||||
|
||||
sprintf(&device_name[sizeof(device_name) - 3], "%02d", i);
|
||||
|
||||
device_array[i].handle = CreateFileA(device_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if (device_array[i].handle == INVALID_HANDLE_VALUE) {
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
|
||||
device_array[i].unempty = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
if(device_array[i].unempty == NULL)
|
||||
{
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
|
||||
zero_padded_handle[0] = device_array[i].unempty;
|
||||
|
||||
if(!DeviceIoControl(device_array[i].handle, IOCTL_SET_EVENT, zero_padded_handle, sizeof(zero_padded_handle), NULL, 0, &bytes_returned, NULL))
|
||||
{
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return device_array;
|
||||
}
|
||||
|
||||
void interception_destroy_context(InterceptionContext context)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
unsigned int i;
|
||||
|
||||
if(!context) return;
|
||||
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if(device_array[i].handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(device_array[i].handle);
|
||||
|
||||
if(device_array[i].unempty != NULL)
|
||||
CloseHandle(device_array[i].unempty);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, context);
|
||||
}
|
||||
|
||||
InterceptionPrecedence interception_get_precedence(InterceptionContext context, InterceptionDevice device)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionPrecedence precedence = 0;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_PRECEDENCE, NULL, 0, (LPVOID)&precedence, sizeof(InterceptionPrecedence), &bytes_returned, NULL);
|
||||
|
||||
return precedence;
|
||||
}
|
||||
|
||||
void interception_set_precedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_SET_PRECEDENCE, (LPVOID)&precedence, sizeof(InterceptionPrecedence), NULL, 0, &bytes_returned, NULL);
|
||||
}
|
||||
|
||||
InterceptionFilter interception_get_filter(InterceptionContext context, InterceptionDevice device)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionFilter filter = 0;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_FILTER, NULL, 0, (LPVOID)&filter, sizeof(InterceptionFilter), &bytes_returned, NULL);
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
void interception_set_filter(InterceptionContext context, InterceptionPredicate interception_predicate, InterceptionFilter filter)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionDevice i;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context)
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
if(device_array[i].handle && interception_predicate(i + 1))
|
||||
DeviceIoControl(device_array[i].handle, IOCTL_SET_FILTER, (LPVOID)&filter, sizeof(InterceptionFilter), NULL, 0, &bytes_returned, NULL);
|
||||
}
|
||||
|
||||
InterceptionDevice interception_wait(InterceptionContext context)
|
||||
{
|
||||
return interception_wait_with_timeout(context, INFINITE);
|
||||
}
|
||||
|
||||
InterceptionDevice interception_wait_with_timeout(InterceptionContext context, unsigned long milliseconds)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
HANDLE wait_handles[INTERCEPTION_MAX_DEVICE];
|
||||
DWORD i, j, k;
|
||||
|
||||
if(!context) return 0;
|
||||
|
||||
for(i = 0, j = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if (device_array[i].unempty)
|
||||
wait_handles[j++] = device_array[i].unempty;
|
||||
}
|
||||
|
||||
k = WaitForMultipleObjects(j, wait_handles, FALSE, milliseconds);
|
||||
|
||||
if(k == WAIT_FAILED || k == WAIT_TIMEOUT) return 0;
|
||||
|
||||
for(i = 0, j = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if (device_array[i].unempty)
|
||||
if (k == j++)
|
||||
break;
|
||||
}
|
||||
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
int interception_send(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *stroke, unsigned int nstroke)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD strokeswritten = 0;
|
||||
|
||||
if(context == 0 || nstroke == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
if(interception_is_keyboard(device))
|
||||
{
|
||||
PKEYBOARD_INPUT_DATA rawstrokes = (PKEYBOARD_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(KEYBOARD_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
for(i = 0; i < nstroke; ++i)
|
||||
{
|
||||
InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) stroke;
|
||||
|
||||
rawstrokes[i].UnitId = 0;
|
||||
rawstrokes[i].MakeCode = key_stroke[i].code;
|
||||
rawstrokes[i].Flags = key_stroke[i].state;
|
||||
rawstrokes[i].Reserved = 0;
|
||||
rawstrokes[i].ExtraInformation = key_stroke[i].information;
|
||||
}
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_WRITE, rawstrokes,(DWORD)nstroke * sizeof(KEYBOARD_INPUT_DATA), NULL, 0, &strokeswritten, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
|
||||
strokeswritten /= sizeof(KEYBOARD_INPUT_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
PMOUSE_INPUT_DATA rawstrokes = (PMOUSE_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(MOUSE_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
for(i = 0; i < nstroke; ++i)
|
||||
{
|
||||
InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) stroke;
|
||||
|
||||
rawstrokes[i].UnitId = 0;
|
||||
rawstrokes[i].Flags = mouse_stroke[i].flags;
|
||||
rawstrokes[i].ButtonFlags = mouse_stroke[i].state;
|
||||
rawstrokes[i].ButtonData = mouse_stroke[i].rolling;
|
||||
rawstrokes[i].RawButtons = 0;
|
||||
rawstrokes[i].LastX = mouse_stroke[i].x;
|
||||
rawstrokes[i].LastY = mouse_stroke[i].y;
|
||||
rawstrokes[i].ExtraInformation = mouse_stroke[i].information;
|
||||
}
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_WRITE, rawstrokes, (DWORD)nstroke * sizeof(MOUSE_INPUT_DATA), NULL, 0, &strokeswritten, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
|
||||
strokeswritten /= sizeof(MOUSE_INPUT_DATA);
|
||||
}
|
||||
|
||||
return strokeswritten;
|
||||
}
|
||||
|
||||
int interception_receive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *stroke, unsigned int nstroke)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD strokesread = 0;
|
||||
|
||||
if(context == 0 || nstroke == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
if(interception_is_keyboard(device))
|
||||
{
|
||||
PKEYBOARD_INPUT_DATA rawstrokes = (PKEYBOARD_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(KEYBOARD_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_READ, NULL, 0, rawstrokes, (DWORD)nstroke * sizeof(KEYBOARD_INPUT_DATA), &strokesread, NULL);
|
||||
|
||||
strokesread /= sizeof(KEYBOARD_INPUT_DATA);
|
||||
|
||||
for(i = 0; i < (unsigned int)strokesread; ++i)
|
||||
{
|
||||
InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) stroke;
|
||||
|
||||
key_stroke[i].code = rawstrokes[i].MakeCode;
|
||||
key_stroke[i].state = rawstrokes[i].Flags;
|
||||
key_stroke[i].information = rawstrokes[i].ExtraInformation;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
}
|
||||
else
|
||||
{
|
||||
PMOUSE_INPUT_DATA rawstrokes = (PMOUSE_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(MOUSE_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_READ, NULL, 0, rawstrokes, (DWORD)nstroke * sizeof(MOUSE_INPUT_DATA), &strokesread, NULL);
|
||||
|
||||
strokesread /= sizeof(MOUSE_INPUT_DATA);
|
||||
|
||||
for(i = 0; i < (unsigned int)strokesread; ++i)
|
||||
{
|
||||
InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) stroke;
|
||||
|
||||
mouse_stroke[i].flags = rawstrokes[i].Flags;
|
||||
mouse_stroke[i].state = rawstrokes[i].ButtonFlags;
|
||||
mouse_stroke[i].rolling = rawstrokes[i].ButtonData;
|
||||
mouse_stroke[i].x = rawstrokes[i].LastX;
|
||||
mouse_stroke[i].y = rawstrokes[i].LastY;
|
||||
mouse_stroke[i].information = rawstrokes[i].ExtraInformation;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
}
|
||||
|
||||
return strokesread;
|
||||
}
|
||||
|
||||
unsigned int interception_get_hardware_id(InterceptionContext context, InterceptionDevice device, void *hardware_id_buffer, unsigned int buffer_size)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD output_size = 0;
|
||||
|
||||
if(context == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_HARDWARE_ID, NULL, 0, hardware_id_buffer, buffer_size, &output_size, NULL);
|
||||
|
||||
return output_size;
|
||||
}
|
||||
|
||||
int interception_is_invalid(InterceptionDevice device)
|
||||
{
|
||||
return !interception_is_keyboard(device) && !interception_is_mouse(device);
|
||||
}
|
||||
|
||||
int interception_is_keyboard(InterceptionDevice device)
|
||||
{
|
||||
return device >= INTERCEPTION_KEYBOARD(0) && device <= INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD - 1);
|
||||
}
|
||||
|
||||
int interception_is_mouse(InterceptionDevice device)
|
||||
{
|
||||
return device >= INTERCEPTION_MOUSE(0) && device <= INTERCEPTION_MOUSE(INTERCEPTION_MAX_MOUSE - 1);
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
mod bindings;
|
||||
use bindings as raw;
|
||||
pub mod scancode;
|
||||
|
||||
pub use scancode::ScanCode;
|
||||
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::default::Default;
|
||||
use std::time::Duration;
|
||||
use std::vec::Vec;
|
||||
|
||||
pub type Device = i32;
|
||||
pub type Precedence = i32;
|
||||
|
||||
pub enum Filter {
|
||||
MouseFilter(MouseFilter),
|
||||
KeyFilter(KeyFilter),
|
||||
}
|
||||
|
||||
pub type Predicate = extern "C" fn(device: Device) -> bool;
|
||||
|
||||
bitflags! {
|
||||
pub struct MouseState: u16 {
|
||||
const LEFT_BUTTON_DOWN = 1;
|
||||
const LEFT_BUTTON_UP = 2;
|
||||
|
||||
const RIGHT_BUTTON_DOWN = 4;
|
||||
const RIGHT_BUTTON_UP = 8;
|
||||
|
||||
const MIDDLE_BUTTON_DOWN = 16;
|
||||
const MIDDLE_BUTTON_UP = 32;
|
||||
|
||||
const BUTTON_4_DOWN = 64;
|
||||
const BUTTON_4_UP = 128;
|
||||
|
||||
const BUTTON_5_DOWN = 256;
|
||||
const BUTTON_5_UP = 512;
|
||||
|
||||
const WHEEL = 1024;
|
||||
const HWHEEL = 2048;
|
||||
|
||||
// MouseFilter only
|
||||
const MOVE = 4096;
|
||||
}
|
||||
}
|
||||
|
||||
pub type MouseFilter = MouseState;
|
||||
|
||||
bitflags! {
|
||||
pub struct MouseFlags: u16 {
|
||||
const MOVE_RELATIVE = 0;
|
||||
const MOVE_ABSOLUTE = 1;
|
||||
|
||||
const VIRTUAL_DESKTOP = 2;
|
||||
const ATTRIBUTES_CHANGED = 4;
|
||||
|
||||
const MOVE_NO_COALESCE = 8;
|
||||
|
||||
const TERMSRV_SRC_SHADOW = 256;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct KeyState: u16 {
|
||||
const DOWN = 0;
|
||||
const UP = 1;
|
||||
|
||||
const E0 = 2;
|
||||
const E1 = 3;
|
||||
|
||||
const TERMSRV_SET_LED = 8;
|
||||
const TERMSRV_SHADOW = 16;
|
||||
const TERMSRV_VKPACKET = 32;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct KeyFilter: u16 {
|
||||
const DOWN = 1;
|
||||
const UP = 2;
|
||||
|
||||
const E0 = 4;
|
||||
const E1 = 8;
|
||||
|
||||
const TERMSRV_SET_LED = 16;
|
||||
const TERMSRV_SHADOW = 32;
|
||||
const TERMSRV_VKPACKET = 64;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Stroke {
|
||||
Mouse {
|
||||
state: MouseState,
|
||||
flags: MouseFlags,
|
||||
rolling: i16,
|
||||
x: i32,
|
||||
y: i32,
|
||||
information: u32,
|
||||
},
|
||||
|
||||
Keyboard {
|
||||
code: ScanCode,
|
||||
state: KeyState,
|
||||
information: u32,
|
||||
},
|
||||
}
|
||||
|
||||
impl TryFrom<raw::InterceptionMouseStroke> for Stroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(raw_stroke: raw::InterceptionMouseStroke) -> Result<Self, Self::Error> {
|
||||
let state = match MouseState::from_bits(raw_stroke.state) {
|
||||
Some(state) => state,
|
||||
None => return Err("Extra bits in raw mouse state"),
|
||||
};
|
||||
|
||||
let flags = match MouseFlags::from_bits(raw_stroke.flags) {
|
||||
Some(flags) => flags,
|
||||
None => return Err("Extra bits in raw mouse flags"),
|
||||
};
|
||||
|
||||
Ok(Stroke::Mouse {
|
||||
state: state,
|
||||
flags: flags,
|
||||
rolling: raw_stroke.rolling,
|
||||
x: raw_stroke.x,
|
||||
y: raw_stroke.y,
|
||||
information: raw_stroke.information,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<raw::InterceptionKeyStroke> for Stroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(raw_stroke: raw::InterceptionKeyStroke) -> Result<Self, Self::Error> {
|
||||
let state = match KeyState::from_bits(raw_stroke.state) {
|
||||
Some(state) => state,
|
||||
None => return Err("Extra bits in raw keyboard state"),
|
||||
};
|
||||
|
||||
let code = match ScanCode::try_from(raw_stroke.code) {
|
||||
Ok(code) => code,
|
||||
Err(_) => ScanCode::Esc,
|
||||
};
|
||||
|
||||
Ok(Stroke::Keyboard {
|
||||
code: code,
|
||||
state: state,
|
||||
information: raw_stroke.information,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Stroke> for raw::InterceptionMouseStroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(stroke: Stroke) -> Result<Self, Self::Error> {
|
||||
if let Stroke::Mouse {
|
||||
state,
|
||||
flags,
|
||||
rolling,
|
||||
x,
|
||||
y,
|
||||
information,
|
||||
} = stroke
|
||||
{
|
||||
Ok(raw::InterceptionMouseStroke {
|
||||
state: state.bits(),
|
||||
flags: flags.bits(),
|
||||
rolling: rolling,
|
||||
x: x,
|
||||
y: y,
|
||||
information: information,
|
||||
})
|
||||
} else {
|
||||
Err("Stroke must be a mouse stroke")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Stroke> for raw::InterceptionKeyStroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(stroke: Stroke) -> Result<Self, Self::Error> {
|
||||
if let Stroke::Keyboard {
|
||||
code,
|
||||
state,
|
||||
information,
|
||||
} = stroke
|
||||
{
|
||||
Ok(raw::InterceptionKeyStroke {
|
||||
code: code as u16,
|
||||
state: state.bits(),
|
||||
information: information,
|
||||
})
|
||||
} else {
|
||||
Err("Stroke must be a keyboard stroke")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Interception {
|
||||
ctx: raw::InterceptionContext,
|
||||
}
|
||||
|
||||
impl Interception {
|
||||
pub fn new() -> Option<Self> {
|
||||
let ctx = unsafe { raw::interception_create_context() };
|
||||
|
||||
if ctx == std::ptr::null_mut() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(Interception { ctx: ctx })
|
||||
}
|
||||
|
||||
pub fn get_precedence(&self, device: Device) -> Precedence {
|
||||
unsafe { raw::interception_get_precedence(self.ctx, device) }
|
||||
}
|
||||
|
||||
pub fn set_precedence(&self, device: Device, precedence: Precedence) {
|
||||
unsafe { raw::interception_set_precedence(self.ctx, device, precedence) }
|
||||
}
|
||||
|
||||
pub fn get_filter(&self, device: Device) -> Filter {
|
||||
if is_invalid(device) {
|
||||
return Filter::KeyFilter(KeyFilter::empty());
|
||||
}
|
||||
|
||||
let raw_filter = unsafe { raw::interception_get_filter(self.ctx, device) };
|
||||
if is_mouse(device) {
|
||||
let filter = match MouseFilter::from_bits(raw_filter) {
|
||||
Some(filter) => filter,
|
||||
None => MouseFilter::empty(),
|
||||
};
|
||||
|
||||
Filter::MouseFilter(filter)
|
||||
} else {
|
||||
let filter = match KeyFilter::from_bits(raw_filter) {
|
||||
Some(filter) => filter,
|
||||
None => KeyFilter::empty(),
|
||||
};
|
||||
|
||||
Filter::KeyFilter(filter)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_filter(&self, predicate: Predicate, filter: Filter) {
|
||||
let filter = match filter {
|
||||
Filter::MouseFilter(filter) => filter.bits(),
|
||||
Filter::KeyFilter(filter) => filter.bits(),
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let predicate = std::mem::transmute(Some(predicate));
|
||||
raw::interception_set_filter(self.ctx, predicate, filter)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wait(&self) -> Device {
|
||||
unsafe { raw::interception_wait(self.ctx) }
|
||||
}
|
||||
|
||||
pub fn wait_with_timeout(&self, duration: Duration) -> Device {
|
||||
let millis = match u32::try_from(duration.as_millis()) {
|
||||
Ok(m) => m,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe { raw::interception_wait_with_timeout(self.ctx, millis) }
|
||||
}
|
||||
|
||||
pub fn send(&self, device: Device, strokes: &[Stroke]) -> i32 {
|
||||
if is_mouse(device) {
|
||||
self.send_internal::<raw::InterceptionMouseStroke>(device, strokes)
|
||||
} else if is_keyboard(device) {
|
||||
self.send_internal::<raw::InterceptionKeyStroke>(device, strokes)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn send_internal<T: TryFrom<Stroke>>(&self, device: Device, strokes: &[Stroke]) -> i32 {
|
||||
let mut raw_strokes = Vec::new();
|
||||
|
||||
for stroke in strokes {
|
||||
if let Ok(raw_stroke) = T::try_from(*stroke) {
|
||||
raw_strokes.push(raw_stroke)
|
||||
}
|
||||
}
|
||||
|
||||
let ptr = raw_strokes.as_ptr();
|
||||
let len = match u32::try_from(raw_strokes.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe { raw::interception_send(self.ctx, device, std::mem::transmute(ptr), len) }
|
||||
}
|
||||
|
||||
pub fn receive(&self, device: Device, strokes: &mut [Stroke]) -> i32 {
|
||||
if is_mouse(device) {
|
||||
self.receive_internal::<raw::InterceptionMouseStroke>(device, strokes)
|
||||
} else if is_keyboard(device) {
|
||||
self.receive_internal::<raw::InterceptionKeyStroke>(device, strokes)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn receive_internal<T: TryInto<Stroke> + Default + Copy>(
|
||||
&self,
|
||||
device: Device,
|
||||
strokes: &mut [Stroke],
|
||||
) -> i32 {
|
||||
let mut raw_strokes: Vec<T> = Vec::with_capacity(strokes.len());
|
||||
raw_strokes.resize_with(strokes.len(), Default::default);
|
||||
|
||||
let ptr = raw_strokes.as_ptr();
|
||||
let len = match u32::try_from(raw_strokes.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
let num_read =
|
||||
unsafe { raw::interception_receive(self.ctx, device, std::mem::transmute(ptr), len) };
|
||||
|
||||
let mut num_valid: i32 = 0;
|
||||
for i in 0..num_read {
|
||||
if let Ok(stroke) = raw_strokes[i as usize].try_into() {
|
||||
strokes[num_valid as usize] = stroke;
|
||||
num_valid += 1;
|
||||
}
|
||||
}
|
||||
|
||||
num_valid
|
||||
}
|
||||
|
||||
pub fn get_hardware_id(&self, device: Device, buffer: &mut [u8]) -> u32 {
|
||||
let ptr = buffer.as_mut_ptr();
|
||||
let len = match u32::try_from(buffer.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
raw::interception_get_hardware_id(self.ctx, device, std::mem::transmute(ptr), len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Interception {
|
||||
fn drop(&mut self) {
|
||||
unsafe { raw::interception_destroy_context(self.ctx) }
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn is_invalid(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_invalid(device) != 0 }
|
||||
}
|
||||
|
||||
pub extern "C" fn is_keyboard(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_keyboard(device) != 0 }
|
||||
}
|
||||
|
||||
pub extern "C" fn is_mouse(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_mouse(device) != 0 }
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
use num_enum::TryFromPrimitive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// ref: https://handmade.network/wiki/2823-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names
|
||||
#[derive(Serialize, Deserialize, Hash, Debug, Eq, PartialEq, Copy, Clone, TryFromPrimitive)]
|
||||
#[repr(u16)]
|
||||
pub enum ScanCode {
|
||||
Esc = 0x01,
|
||||
|
||||
Num1 = 0x02,
|
||||
Num2 = 0x03,
|
||||
Num3 = 0x04,
|
||||
Num4 = 0x05,
|
||||
Num5 = 0x06,
|
||||
Num6 = 0x07,
|
||||
Num7 = 0x08,
|
||||
Num8 = 0x09,
|
||||
Num9 = 0x0A,
|
||||
Num0 = 0x0B,
|
||||
|
||||
Minus = 0x0C,
|
||||
Equals = 0x0D,
|
||||
Backspace = 0x0E,
|
||||
|
||||
Tab = 0x0F,
|
||||
|
||||
Q = 0x10,
|
||||
W = 0x11,
|
||||
E = 0x12,
|
||||
R = 0x13,
|
||||
T = 0x14,
|
||||
Y = 0x15,
|
||||
U = 0x16,
|
||||
I = 0x17,
|
||||
O = 0x18,
|
||||
P = 0x19,
|
||||
|
||||
LeftBracket = 0x1A,
|
||||
RightBracket = 0x1B,
|
||||
Enter = 0x1C,
|
||||
|
||||
LeftControl = 0x1D,
|
||||
|
||||
A = 0x1E,
|
||||
S = 0x1F,
|
||||
D = 0x20,
|
||||
F = 0x21,
|
||||
G = 0x22,
|
||||
H = 0x23,
|
||||
J = 0x24,
|
||||
K = 0x25,
|
||||
L = 0x26,
|
||||
|
||||
SemiColon = 0x27,
|
||||
Apostrophe = 0x28,
|
||||
Grave = 0x29,
|
||||
LeftShift = 0x2A,
|
||||
BackSlash = 0x2B,
|
||||
|
||||
Z = 0x2C,
|
||||
X = 0x2D,
|
||||
C = 0x2E,
|
||||
V = 0x2F,
|
||||
B = 0x30,
|
||||
N = 0x31,
|
||||
M = 0x32,
|
||||
|
||||
Comma = 0x33,
|
||||
Period = 0x34,
|
||||
Slash = 0x35,
|
||||
RightShift = 0x36,
|
||||
NumpadMultiply = 0x37,
|
||||
LeftAlt = 0x38,
|
||||
Space = 0x39,
|
||||
CapsLock = 0x3A,
|
||||
|
||||
F1 = 0x3B,
|
||||
F2 = 0x3C,
|
||||
F3 = 0x3D,
|
||||
F4 = 0x3E,
|
||||
F5 = 0x3F,
|
||||
F6 = 0x40,
|
||||
F7 = 0x41,
|
||||
F8 = 0x42,
|
||||
F9 = 0x43,
|
||||
F10 = 0x44,
|
||||
|
||||
NumLock = 0x45,
|
||||
ScrollLock = 0x46,
|
||||
|
||||
Numpad7 = 0x47,
|
||||
Numpad8 = 0x48,
|
||||
Numpad9 = 0x49,
|
||||
|
||||
NumpadMinus = 0x4A,
|
||||
|
||||
Numpad4 = 0x4B,
|
||||
Numpad5 = 0x4C,
|
||||
Numpad6 = 0x4D,
|
||||
|
||||
NumpadPlus = 0x4E,
|
||||
|
||||
Numpad1 = 0x4F,
|
||||
Numpad2 = 0x50,
|
||||
Numpad3 = 0x51,
|
||||
Numpad0 = 0x52,
|
||||
|
||||
NumpadPeriod = 0x53,
|
||||
AltPrintScreen = 0x54, /* Alt + print screen. */
|
||||
Int1 = 0x56, /* Key between the left shift and Z. */
|
||||
|
||||
F11 = 0x57,
|
||||
F12 = 0x58,
|
||||
|
||||
Oem1 = 0x5A, /* VK_OEM_WSCTRL */
|
||||
Oem2 = 0x5B, /* VK_OEM_FINISH */
|
||||
Oem3 = 0x5C, /* VK_OEM_JUMP */
|
||||
|
||||
EraseEOF = 0x5D,
|
||||
|
||||
Oem4 = 0x5E, /* VK_OEM_BACKTAB */
|
||||
Oem5 = 0x5F, /* VK_OEM_AUTO */
|
||||
|
||||
Zoom = 0x62,
|
||||
Help = 0x63,
|
||||
|
||||
F13 = 0x64,
|
||||
F14 = 0x65,
|
||||
F15 = 0x66,
|
||||
F16 = 0x67,
|
||||
F17 = 0x68,
|
||||
F18 = 0x69,
|
||||
F19 = 0x6A,
|
||||
F20 = 0x6B,
|
||||
F21 = 0x6C,
|
||||
F22 = 0x6D,
|
||||
F23 = 0x6E,
|
||||
|
||||
Oem6 = 0x6F, /* VK_OEM_PA3 */
|
||||
Katakana = 0x70,
|
||||
Oem7 = 0x71, /* VK_OEM_RESET */
|
||||
F24 = 0x76,
|
||||
|
||||
SBCSChar = 0x77,
|
||||
Convert = 0x79,
|
||||
NonConvert = 0x7B, /* VK_OEM_PA1 */
|
||||
}
|
||||
@@ -613,6 +613,16 @@ dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"num_enum",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipconfig"
|
||||
version = "0.3.0"
|
||||
@@ -864,6 +874,27 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
@@ -1053,6 +1084,16 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.19"
|
||||
@@ -1308,6 +1349,7 @@ dependencies = [
|
||||
"futures-util",
|
||||
"hyper",
|
||||
"image",
|
||||
"interception",
|
||||
"ipconfig",
|
||||
"log",
|
||||
"palette",
|
||||
@@ -1587,9 +1629,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "vigem-client"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "965e349c8ec4eb36c06878b99952f35b9f459e6912419837ecb85fb5502a6de3"
|
||||
checksum = "5d886912e88b1d3b02a97d933df7829db8fb8561920410805794a48680c212d5"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@@ -29,8 +29,9 @@ image = "0.23.14"
|
||||
rusb = "0.9.0"
|
||||
serialport = "4.0.1"
|
||||
wwserial = {path = "../src-wwserial" }
|
||||
vigem-client = "0.1.1"
|
||||
vigem-client = { version = "0.1.2", features = ["unstable"] }
|
||||
winapi = "0.3.9"
|
||||
interception = {path = "../src-interception" }
|
||||
ipconfig = "0.3.0"
|
||||
|
||||
# webserver
|
||||
|
||||
@@ -3,7 +3,9 @@ extern crate slider_io;
|
||||
use std::io;
|
||||
|
||||
use slider_io::{
|
||||
device::brokenithm::BrokenithmJob, shared::worker::AsyncHaltableWorker, state::SliderState,
|
||||
device::{brokenithm::BrokenithmJob, config::BrokenithmSpec},
|
||||
shared::worker::AsyncHaltableWorker,
|
||||
state::SliderState,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -14,7 +16,10 @@ async fn main() {
|
||||
|
||||
let state = SliderState::new();
|
||||
|
||||
let _worker = AsyncHaltableWorker::new("brokenithm", BrokenithmJob::new(&state, &false, &false));
|
||||
let _worker = AsyncHaltableWorker::new(
|
||||
"brokenithm",
|
||||
BrokenithmJob::new(&state, &BrokenithmSpec::Nostalgia, &false, &1606),
|
||||
);
|
||||
let mut input = String::new();
|
||||
io::stdin().read_line(&mut input).unwrap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
extern crate slider_io;
|
||||
|
||||
use std::io;
|
||||
|
||||
use slider_io::{config::Config, context::Context};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::Builder::new()
|
||||
.filter_level(log::LevelFilter::Debug)
|
||||
.init();
|
||||
|
||||
let config = Config::from_str(
|
||||
r##"{
|
||||
"deviceMode": "brokenithm",
|
||||
"outputMode": "kb-32-tasoller",
|
||||
"ledMode": "none",
|
||||
"disableAirStrings": false,
|
||||
"divaSerialPort": "COM1",
|
||||
"divaBrightness": 63,
|
||||
"brokenithmPort": 1606,
|
||||
"keyboardSensitivity": 20,
|
||||
"keyboardDirectInput": true,
|
||||
"outputPolling": "100",
|
||||
"outputWebsocketUrl": "localhost:3000",
|
||||
"ledFaster": false,
|
||||
"ledColorActive": "#ff00ff",
|
||||
"ledColorInactive": "#ffff00",
|
||||
"ledSensitivity": 20,
|
||||
"ledWebsocketUrl": "localhost:3001",
|
||||
"ledSerialPort": "COM5"
|
||||
}"##,
|
||||
)
|
||||
.unwrap();
|
||||
println!("{:?}", config);
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let ctx = Context::new(config);
|
||||
|
||||
println!("Press enter to quit");
|
||||
let mut input = String::new();
|
||||
io::stdin().read_line(&mut input).unwrap();
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
extern crate slider_io;
|
||||
|
||||
use std::{
|
||||
io,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use std::io;
|
||||
|
||||
use slider_io::{device::diva, shared::worker::ThreadJob, state::SliderState};
|
||||
|
||||
|
||||
@@ -28,18 +28,27 @@ impl Config {
|
||||
|
||||
fn default() -> Self {
|
||||
Self::from_str(
|
||||
r#"{
|
||||
r##"{
|
||||
"deviceMode": "none",
|
||||
"devicePolling": "100",
|
||||
"outputMode": "none",
|
||||
"ledMode": "none",
|
||||
"disableAirStrings": false,
|
||||
"divaSerialPort": "COM1",
|
||||
"divaBrightness": 63,
|
||||
"brokenithmPort": 1606,
|
||||
"keyboardSensitivity": 20,
|
||||
"outputWebsocketUrl": "localhost:3000",
|
||||
"keyboardDirectInput": false,
|
||||
"outputPolling": "100",
|
||||
"outputWebsocketUrl": "localhost:3000",
|
||||
"ledFaster": false,
|
||||
"ledColorActive": "#ff00ff",
|
||||
"ledColorInactive": "#ffff00",
|
||||
"ledColorAirActive": "#0086ed",
|
||||
"ledColorAirInactive": "#000000",
|
||||
"ledSensitivity": 20,
|
||||
"ledWebsocketUrl": "localhost:3001",
|
||||
"ledSerialPort": "COM5"
|
||||
}"#,
|
||||
}"##,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
@@ -55,12 +64,13 @@ impl Config {
|
||||
}
|
||||
|
||||
pub fn load() -> Self {
|
||||
Self::load_saved()
|
||||
.or_else(|| {
|
||||
warn!("Config loading from file failed, using default");
|
||||
Some(Self::default())
|
||||
})
|
||||
.unwrap()
|
||||
let t = Self::load_saved();
|
||||
warn!("{:?}", t);
|
||||
t.or_else(|| {
|
||||
warn!("Config loading from file failed, using default");
|
||||
Some(Self::default())
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn save(&self) -> Option<()> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::{atomic::Ordering, Arc};
|
||||
use crate::{
|
||||
config::Config,
|
||||
device::{brokenithm::BrokenithmJob, config::DeviceMode, diva::DivaSliderJob, hid::HidJob},
|
||||
lighting::{config::LightsMode, lighting::LightsJob},
|
||||
lighting::{config::LightsMode, lighting::LightsJob, umgr_websocket::UmgrWebsocketJob},
|
||||
output::{config::OutputMode, output::OutputJob},
|
||||
shared::{
|
||||
utils::LoopTimer,
|
||||
@@ -23,6 +23,7 @@ pub struct Context {
|
||||
device_async_haltable_worker: Option<AsyncHaltableWorker>,
|
||||
output_worker: Option<AsyncWorker>,
|
||||
lights_worker: Option<AsyncWorker>,
|
||||
lights_haltable_worker: Option<AsyncHaltableWorker>,
|
||||
timers: Vec<(&'static str, Arc<AtomicF64>)>,
|
||||
}
|
||||
|
||||
@@ -40,23 +41,24 @@ impl Context {
|
||||
match &config.device_mode {
|
||||
DeviceMode::None => (None, None, None),
|
||||
DeviceMode::Brokenithm {
|
||||
ground_only,
|
||||
spec,
|
||||
lights_enabled,
|
||||
port,
|
||||
} => (
|
||||
None,
|
||||
None,
|
||||
Some(AsyncHaltableWorker::new(
|
||||
"brokenithm",
|
||||
BrokenithmJob::new(&state, ground_only, lights_enabled),
|
||||
BrokenithmJob::new(&state, spec, lights_enabled, port),
|
||||
)),
|
||||
),
|
||||
DeviceMode::Hardware { spec } => (
|
||||
DeviceMode::Hardware { spec, disable_air } => (
|
||||
{
|
||||
let timer = LoopTimer::new();
|
||||
timers.push(("d", timer.fork()));
|
||||
Some(ThreadWorker::new(
|
||||
"device",
|
||||
HidJob::from_config(&state, spec),
|
||||
HidJob::from_config(&state, spec, disable_air),
|
||||
timer,
|
||||
))
|
||||
},
|
||||
@@ -89,16 +91,26 @@ impl Context {
|
||||
))
|
||||
}
|
||||
};
|
||||
let lights_worker = match &config.lights_mode {
|
||||
LightsMode::None => None,
|
||||
let (lights_worker, lights_haltable_worker) = match &config.lights_mode {
|
||||
LightsMode::None => (None, None),
|
||||
LightsMode::UmgrWebsocket { faster, port } => (
|
||||
None,
|
||||
Some(AsyncHaltableWorker::new(
|
||||
"lights",
|
||||
UmgrWebsocketJob::new(&state, faster, port),
|
||||
)),
|
||||
),
|
||||
_ => {
|
||||
let timer = LoopTimer::new();
|
||||
timers.push(("l", timer.fork()));
|
||||
Some(AsyncWorker::new(
|
||||
"lights",
|
||||
LightsJob::new(&state, &config.lights_mode),
|
||||
timer,
|
||||
))
|
||||
(
|
||||
Some(AsyncWorker::new(
|
||||
"lights",
|
||||
LightsJob::new(&state, &config.lights_mode),
|
||||
timer,
|
||||
)),
|
||||
None,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -110,6 +122,7 @@ impl Context {
|
||||
device_async_haltable_worker,
|
||||
output_worker,
|
||||
lights_worker,
|
||||
lights_haltable_worker,
|
||||
timers,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>slidershim-brokenithm</title>
|
||||
<meta charset="utf8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||
/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<link rel="apple-touch-icon" sizes="192x192" href="/icon.png" />
|
||||
<style>
|
||||
#fullscreen {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
background: #000000;
|
||||
color: hotpink;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
touch-action: none;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.air-container {
|
||||
/* display: flex; */
|
||||
display: none;
|
||||
flex-flow: column nowrap;
|
||||
align-items: stretch;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.touch-container {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
align-items: stretch;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.grow > * {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.key {
|
||||
flex: 1;
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
.key[data-active] {
|
||||
background-color: hotpink;
|
||||
}
|
||||
|
||||
.key.air[data-active] {
|
||||
background-color: skyblue;
|
||||
}
|
||||
|
||||
canvas {
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
image-rendering: crisp-edges;
|
||||
image-rendering: pixelated;
|
||||
touch-action: none;
|
||||
margin: 0px -1.5625vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="fullscreen">
|
||||
<!-- Offset for LED display -->
|
||||
<div class="container">
|
||||
<div class="air-container grow"></div>
|
||||
<div class="touch-container grow">
|
||||
<canvas id="canvas" width="33" height="1"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Hitbox Divs -->
|
||||
<div class="container" id="main">
|
||||
<div class="air-container grow">
|
||||
<div class="air key" data-air="1" data-kflag="5"></div>
|
||||
<div class="air key" data-air="1" data-kflag="4"></div>
|
||||
<div class="air key" data-air="1" data-kflag="3"></div>
|
||||
<div class="air key" data-air="1" data-kflag="2"></div>
|
||||
<div class="air key" data-air="1" data-kflag="1"></div>
|
||||
<div class="air key" data-air="1" data-kflag="0"></div>
|
||||
</div>
|
||||
<div class="touch-container grow">
|
||||
<div class="key" data-kflag="0"></div>
|
||||
<div class="key" data-kflag="1"></div>
|
||||
<div class="key" data-kflag="2"></div>
|
||||
<div class="key" data-kflag="3"></div>
|
||||
<div class="key" data-kflag="4"></div>
|
||||
<div class="key" data-kflag="5"></div>
|
||||
<div class="key" data-kflag="6"></div>
|
||||
<div class="key" data-kflag="7"></div>
|
||||
<div class="key" data-kflag="8"></div>
|
||||
<div class="key" data-kflag="9"></div>
|
||||
<div class="key" data-kflag="10"></div>
|
||||
<div class="key" data-kflag="11"></div>
|
||||
<div class="key" data-kflag="12"></div>
|
||||
<div class="key" data-kflag="13"></div>
|
||||
<div class="key" data-kflag="14"></div>
|
||||
<div class="key" data-kflag="15"></div>
|
||||
<div class="key" data-kflag="16"></div>
|
||||
<div class="key" data-kflag="17"></div>
|
||||
<div class="key" data-kflag="18"></div>
|
||||
<div class="key" data-kflag="19"></div>
|
||||
<div class="key" data-kflag="20"></div>
|
||||
<div class="key" data-kflag="21"></div>
|
||||
<div class="key" data-kflag="22"></div>
|
||||
<div class="key" data-kflag="23"></div>
|
||||
<div class="key" data-kflag="24"></div>
|
||||
<div class="key" data-kflag="25"></div>
|
||||
<div class="key" data-kflag="26"></div>
|
||||
<div class="key" data-kflag="27"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/config.js"></script>
|
||||
<script>
|
||||
var allAir = true;
|
||||
</script>
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -46,7 +46,7 @@ const compileKey = (key) => {
|
||||
almostLeft: !!prev ? key.offsetLeft + key.offsetWidth / 4 : -99999,
|
||||
almostRight: !!next ? key.offsetLeft + (key.offsetWidth * 3) / 4 : 99999,
|
||||
kflag: parseInt(key.dataset.kflag) + (parseInt(key.dataset.air) ? 32 : 0),
|
||||
isAir: parseInt(key.dataset.air) ? true : false,
|
||||
isAir: parseInt(key.dataset.air) ? true : window.allAir || false,
|
||||
prevKeyRef: prev,
|
||||
prevKeyKflag: prev
|
||||
? parseInt(prev.dataset.kflag) + (parseInt(prev.dataset.air) ? 32 : 0)
|
||||
@@ -70,9 +70,9 @@ const compileKeys = () => {
|
||||
keys = document.getElementsByClassName("key");
|
||||
airKeys = [];
|
||||
touchKeys = [];
|
||||
for (var i = 0, key; i < keys.length; i++) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
const compiledKey = compileKey(keys[i]);
|
||||
if (!compiledKey.isAir) {
|
||||
if (compiledKey.kflag < 32) {
|
||||
touchKeys.push(compiledKey);
|
||||
} else {
|
||||
airKeys.push(compiledKey);
|
||||
@@ -80,6 +80,38 @@ const compileKeys = () => {
|
||||
allKeys.push(compiledKey);
|
||||
}
|
||||
|
||||
touchKeys.memo = {};
|
||||
airKeys.memo = {};
|
||||
|
||||
touchKeys.getAxis = (x, y) => x;
|
||||
airKeys.getAxis = (x, y) => y;
|
||||
|
||||
var getKey = function (x, y) {
|
||||
var c = this.getAxis(x, y);
|
||||
var res = this.memo[c];
|
||||
if (res === undefined) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (isInside(x, y, this[i])) {
|
||||
res = this[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.memo[c] = res;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
touchKeys.getKey = getKey;
|
||||
airKeys.getKey = getKey;
|
||||
|
||||
for (var i = 0; i < window.outerWidth; i++) {
|
||||
touchKeys.getKey(i, touchKeys[0].top);
|
||||
}
|
||||
|
||||
for (var i = 0; i < window.outerHeight; i++) {
|
||||
airKeys.getKey(airKeys[0].left, i);
|
||||
}
|
||||
|
||||
if (!config.invert) {
|
||||
// Not inverted
|
||||
topKeys = airKeys;
|
||||
@@ -95,15 +127,9 @@ const compileKeys = () => {
|
||||
|
||||
const getKey = (x, y) => {
|
||||
if (y < midline) {
|
||||
for (var i = 0; i < topKeys.length; i++) {
|
||||
if (isInside(x, y, topKeys[i])) return topKeys[i];
|
||||
}
|
||||
return topKeys.getKey(x, y);
|
||||
} else {
|
||||
for (var i = 0; i < bottomKeys.length; i++) {
|
||||
if (isInside(x, y, bottomKeys[i])) {
|
||||
return bottomKeys[i];
|
||||
}
|
||||
}
|
||||
return bottomKeys.getKey(x, y);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@@ -197,7 +223,7 @@ var ws = null;
|
||||
var wsTimeout = 0;
|
||||
var wsConnected = false;
|
||||
const wsConnect = () => {
|
||||
ws = new WebSocket("ws://" + location.host + "/ws");
|
||||
ws = new WebSocket((location.protocol == "https:" ? "wss://" : "ws://") + location.host + "/ws");
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.onopen = () => {
|
||||
ws.send("alive?");
|
||||
@@ -241,9 +267,9 @@ const updateLed = (data) => {
|
||||
canvasData.data[i * 4 + 5] = buf[i * 3 + 1]; // g
|
||||
canvasData.data[i * 4 + 6] = buf[i * 3 + 2]; // b
|
||||
}
|
||||
canvasData.data[0] = buf[0]
|
||||
canvasData.data[1] = buf[1]
|
||||
canvasData.data[2] = buf[2]
|
||||
canvasData.data[0] = buf[0];
|
||||
canvasData.data[1] = buf[1];
|
||||
canvasData.data[2] = buf[2];
|
||||
canvasData.data[128] = buf[90];
|
||||
canvasData.data[129] = buf[91];
|
||||
canvasData.data[130] = buf[92];
|
||||
|
||||
@@ -18,7 +18,7 @@ use tokio::{
|
||||
use tokio_tungstenite::WebSocketStream;
|
||||
use tungstenite::{handshake, Message};
|
||||
|
||||
use crate::{shared::worker::AsyncHaltableJob, state::SliderState};
|
||||
use crate::{device::config::BrokenithmSpec, shared::worker::AsyncHaltableJob, state::SliderState};
|
||||
|
||||
// https://levelup.gitconnected.com/handling-websocket-and-http-on-the-same-port-with-rust-f65b770722c9
|
||||
|
||||
@@ -36,6 +36,7 @@ async fn error_response() -> Result<Response<Body>, Infallible> {
|
||||
static BROKENITHM_STR_FILES: phf::Map<&'static str, (&'static str, &'static str)> = phf_map! {
|
||||
"app.js" => (include_str!("./brokenithm-www/app.js"), "text/javascript"),
|
||||
"config.js" => (include_str!("./brokenithm-www/config.js"), "text/javascript"),
|
||||
"index-ns.html" => (include_str!("./brokenithm-www/index-ns.html"), "text/html"),
|
||||
"index-go.html" => (include_str!("./brokenithm-www/index-go.html"), "text/html"),
|
||||
"index.html" => (include_str!("./brokenithm-www/index.html"), "text/html"),
|
||||
};
|
||||
@@ -115,13 +116,13 @@ async fn handle_brokenithm(
|
||||
39 => {
|
||||
if chars[0] == 'b' {
|
||||
let mut input_handle = state_handle.input.lock();
|
||||
for (idx, c) in chars[0..32].iter().enumerate() {
|
||||
for (idx, c) in chars[1..33].iter().enumerate() {
|
||||
input_handle.ground[idx] = match *c == '1' {
|
||||
false => 0,
|
||||
true => 255,
|
||||
}
|
||||
}
|
||||
for (idx, c) in chars[32..38].iter().enumerate() {
|
||||
for (idx, c) in chars[33..39].iter().enumerate() {
|
||||
input_handle.air[idx] = match *c == '1' {
|
||||
false => 0,
|
||||
true => 1,
|
||||
@@ -136,12 +137,18 @@ async fn handle_brokenithm(
|
||||
}
|
||||
Message::Close(_) => {
|
||||
info!("Websocket connection closed");
|
||||
let mut input_handle = state_handle.input.lock();
|
||||
input_handle.ground.fill(0);
|
||||
input_handle.air.fill(0);
|
||||
break;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Websocket connection error: {}", e);
|
||||
let mut input_handle = state_handle.input.lock();
|
||||
input_handle.ground.fill(0);
|
||||
input_handle.air.fill(0);
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -228,7 +235,7 @@ async fn handle_request(
|
||||
request: Request<Body>,
|
||||
remote_addr: SocketAddr,
|
||||
state: SliderState,
|
||||
ground_only: bool,
|
||||
spec: BrokenithmSpec,
|
||||
lights_enabled: bool,
|
||||
) -> Result<Response<Body>, Infallible> {
|
||||
let method = request.method();
|
||||
@@ -246,9 +253,10 @@ async fn handle_request(
|
||||
request.uri().path(),
|
||||
request.headers().contains_key(header::UPGRADE),
|
||||
) {
|
||||
("/", false) | ("/index.html", false) => match ground_only {
|
||||
false => serve_file("index.html").await,
|
||||
true => serve_file("index-go.html").await,
|
||||
("/", false) | ("/index.html", false) => match spec {
|
||||
BrokenithmSpec::Basic => serve_file("index.html").await,
|
||||
BrokenithmSpec::GroundOnly => serve_file("index-go.html").await,
|
||||
BrokenithmSpec::Nostalgia => serve_file("index-ns.html").await,
|
||||
},
|
||||
(filename, false) => serve_file(&filename[1..]).await,
|
||||
("/ws", true) => handle_websocket(request, state, lights_enabled).await,
|
||||
@@ -258,16 +266,23 @@ async fn handle_request(
|
||||
|
||||
pub struct BrokenithmJob {
|
||||
state: SliderState,
|
||||
ground_only: bool,
|
||||
spec: BrokenithmSpec,
|
||||
lights_enabled: bool,
|
||||
port: u16,
|
||||
}
|
||||
|
||||
impl BrokenithmJob {
|
||||
pub fn new(state: &SliderState, ground_only: &bool, lights_enabled: &bool) -> Self {
|
||||
pub fn new(
|
||||
state: &SliderState,
|
||||
spec: &BrokenithmSpec,
|
||||
lights_enabled: &bool,
|
||||
port: &u16,
|
||||
) -> Self {
|
||||
Self {
|
||||
state: state.clone(),
|
||||
ground_only: *ground_only,
|
||||
spec: spec.clone(),
|
||||
lights_enabled: *lights_enabled,
|
||||
port: *port,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,20 +291,22 @@ impl BrokenithmJob {
|
||||
impl AsyncHaltableJob for BrokenithmJob {
|
||||
async fn run<F: Future<Output = ()> + Send>(self, stop_signal: F) {
|
||||
let state = self.state.clone();
|
||||
let ground_only = self.ground_only;
|
||||
let spec = self.spec.clone();
|
||||
let lights_enabled = self.lights_enabled;
|
||||
let make_svc = make_service_fn(|conn: &AddrStream| {
|
||||
let remote_addr = conn.remote_addr();
|
||||
let make_svc_state = state.clone();
|
||||
let make_spec = spec.clone();
|
||||
async move {
|
||||
Ok::<_, Infallible>(service_fn(move |request: Request<Body>| {
|
||||
let svc_state = make_svc_state.clone();
|
||||
handle_request(request, remote_addr, svc_state, ground_only, lights_enabled)
|
||||
let spec = make_spec.clone();
|
||||
handle_request(request, remote_addr, svc_state, spec, lights_enabled)
|
||||
}))
|
||||
}
|
||||
});
|
||||
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], 1606));
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], self.port));
|
||||
info!("Brokenithm server listening on {}", addr);
|
||||
|
||||
let server = Server::bind(&addr)
|
||||
|
||||
@@ -5,6 +5,16 @@ pub enum HardwareSpec {
|
||||
TasollerOne,
|
||||
TasollerTwo,
|
||||
Yuancon,
|
||||
YuanconThree,
|
||||
Yubideck,
|
||||
YubideckThree,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BrokenithmSpec {
|
||||
Basic,
|
||||
GroundOnly,
|
||||
Nostalgia,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -12,10 +22,12 @@ pub enum DeviceMode {
|
||||
None,
|
||||
Hardware {
|
||||
spec: HardwareSpec,
|
||||
disable_air: bool,
|
||||
},
|
||||
Brokenithm {
|
||||
ground_only: bool,
|
||||
spec: BrokenithmSpec,
|
||||
lights_enabled: bool,
|
||||
port: u16,
|
||||
},
|
||||
DivaSlider {
|
||||
port: String,
|
||||
@@ -29,34 +41,67 @@ impl DeviceMode {
|
||||
"none" => DeviceMode::None,
|
||||
"tasoller-one" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::TasollerOne,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"tasoller-two" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::TasollerTwo,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"yuancon" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::Yuancon,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"yuancon-three" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::YuanconThree,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"yubideck" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::Yubideck,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"yubideck-three" => DeviceMode::Hardware {
|
||||
spec: HardwareSpec::YubideckThree,
|
||||
disable_air: v["disableAirStrings"].as_bool()?,
|
||||
},
|
||||
"diva" => DeviceMode::DivaSlider {
|
||||
port: v["divaSerialPort"].as_str()?.to_string(),
|
||||
brightness: u8::try_from(v["divaBrightness"].as_i64()?).ok()?,
|
||||
},
|
||||
"brokenithm" => DeviceMode::Brokenithm {
|
||||
ground_only: false,
|
||||
spec: match v["disableAirStrings"].as_bool()? {
|
||||
false => BrokenithmSpec::Basic,
|
||||
true => BrokenithmSpec::GroundOnly,
|
||||
},
|
||||
lights_enabled: false,
|
||||
port: u16::try_from(v["brokenithmPort"].as_i64()?)
|
||||
.ok()
|
||||
.or(Some(1606))?,
|
||||
},
|
||||
"brokenithm-led" => DeviceMode::Brokenithm {
|
||||
ground_only: false,
|
||||
spec: match v["disableAirStrings"].as_bool()? {
|
||||
false => BrokenithmSpec::Basic,
|
||||
true => BrokenithmSpec::GroundOnly,
|
||||
},
|
||||
lights_enabled: true,
|
||||
port: u16::try_from(v["brokenithmPort"].as_i64()?)
|
||||
.ok()
|
||||
.or(Some(1606))?,
|
||||
},
|
||||
"brokenithm-ground" => DeviceMode::Brokenithm {
|
||||
ground_only: true,
|
||||
"brokenithm-nostalgia" => DeviceMode::Brokenithm {
|
||||
spec: BrokenithmSpec::Nostalgia,
|
||||
lights_enabled: false,
|
||||
},
|
||||
"brokenithm-ground-led" => DeviceMode::Brokenithm {
|
||||
ground_only: true,
|
||||
lights_enabled: true,
|
||||
port: u16::try_from(v["brokenithmPort"].as_i64()?)
|
||||
.ok()
|
||||
.or(Some(1606))?,
|
||||
},
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_port(&self) -> Option<u16> {
|
||||
match self {
|
||||
DeviceMode::Brokenithm { port, .. } => Some(*port),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,9 +318,9 @@ impl ThreadJob for DivaSliderJob {
|
||||
.take(31)
|
||||
.zip(lights_handle.ground.chunks(3).rev())
|
||||
{
|
||||
buf_chunk[0] = state_chunk[1];
|
||||
buf_chunk[0] = state_chunk[2];
|
||||
buf_chunk[1] = state_chunk[0];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
buf_chunk[2] = state_chunk[1];
|
||||
}
|
||||
lights_handle.dirty = false;
|
||||
}
|
||||
@@ -342,6 +342,7 @@ impl ThreadJob for DivaSliderJob {
|
||||
if bytes_written == 0 {
|
||||
warn!("Serial write timeout");
|
||||
}
|
||||
serial_port.flush();
|
||||
// debug!("Serial write {}/{}", bytes_written, data.len());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::{
|
||||
use super::config::HardwareSpec;
|
||||
|
||||
type HidReadCallback = fn(&Buffer, &mut SliderInput) -> ();
|
||||
type HidLedCallback = fn(&mut Buffer, &SliderLights) -> ();
|
||||
type HidLedCallback = fn(&mut Buffer, &mut Buffer, &SliderLights) -> ();
|
||||
|
||||
enum WriteType {
|
||||
Bulk,
|
||||
@@ -32,6 +32,7 @@ pub struct HidJob {
|
||||
pid: u16,
|
||||
read_endpoint: u8,
|
||||
led_endpoint: u8,
|
||||
disable_air: bool,
|
||||
|
||||
read_callback: HidReadCallback,
|
||||
read_buf: Buffer,
|
||||
@@ -40,6 +41,7 @@ pub struct HidJob {
|
||||
led_write_type: WriteType,
|
||||
led_callback: HidLedCallback,
|
||||
led_buf: Buffer,
|
||||
led_buf_two: Buffer,
|
||||
|
||||
handle: Option<DeviceHandle<GlobalContext>>,
|
||||
}
|
||||
@@ -51,6 +53,7 @@ impl HidJob {
|
||||
pid: u16,
|
||||
read_endpoint: u8,
|
||||
led_endpoint: u8,
|
||||
disable_air: bool,
|
||||
read_callback: HidReadCallback,
|
||||
led_type: WriteType,
|
||||
led_callback: HidLedCallback,
|
||||
@@ -61,17 +64,19 @@ impl HidJob {
|
||||
pid,
|
||||
read_endpoint,
|
||||
led_endpoint,
|
||||
disable_air,
|
||||
read_callback,
|
||||
read_buf: Buffer::new(),
|
||||
last_read_buf: Buffer::new(),
|
||||
led_write_type: led_type,
|
||||
led_callback,
|
||||
led_buf: Buffer::new(),
|
||||
led_buf_two: Buffer::new(),
|
||||
handle: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_config(state: &SliderState, spec: &HardwareSpec) -> Self {
|
||||
pub fn from_config(state: &SliderState, spec: &HardwareSpec, disable_air: &bool) -> Self {
|
||||
match spec {
|
||||
HardwareSpec::TasollerOne => Self::new(
|
||||
state.clone(),
|
||||
@@ -79,6 +84,7 @@ impl HidJob {
|
||||
0x2333,
|
||||
0x84,
|
||||
0x03,
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 11 {
|
||||
return;
|
||||
@@ -98,7 +104,7 @@ impl HidJob {
|
||||
input.extra[0..2].copy_from_slice(&bits[26..28]);
|
||||
},
|
||||
WriteType::Bulk,
|
||||
|buf, lights| {
|
||||
|buf, _, lights| {
|
||||
buf.len = 240;
|
||||
buf.data[0] = 'B' as u8;
|
||||
buf.data[1] = 'L' as u8;
|
||||
@@ -121,6 +127,7 @@ impl HidJob {
|
||||
0x2333,
|
||||
0x84,
|
||||
0x03,
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 36 {
|
||||
return;
|
||||
@@ -134,7 +141,7 @@ impl HidJob {
|
||||
input.extra[0..2].copy_from_slice(&bits[6..8]);
|
||||
},
|
||||
WriteType::Bulk,
|
||||
|buf, lights| {
|
||||
|buf, _, lights| {
|
||||
buf.len = 240;
|
||||
buf.data[0] = 'B' as u8;
|
||||
buf.data[1] = 'L' as u8;
|
||||
@@ -148,7 +155,20 @@ impl HidJob {
|
||||
buf_chunk[1] = state_chunk[0];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
}
|
||||
buf.data[96..240].fill(0);
|
||||
|
||||
for (buf_chunks, state_chunk) in buf.data[96..240].chunks_mut(24).zip(
|
||||
lights
|
||||
.air_left
|
||||
.chunks(3)
|
||||
.rev()
|
||||
.chain(lights.air_right.chunks(3)),
|
||||
) {
|
||||
for idx in 0..8 {
|
||||
buf_chunks[0 + idx * 3] = state_chunk[1];
|
||||
buf_chunks[1 + idx * 3] = state_chunk[0];
|
||||
buf_chunks[2 + idx * 3] = state_chunk[2];
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
HardwareSpec::Yuancon => Self::new(
|
||||
@@ -157,8 +177,9 @@ impl HidJob {
|
||||
0x2001,
|
||||
0x81,
|
||||
0x02,
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 34 {
|
||||
if buf.len != 34 && buf.len != 35 {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -171,7 +192,7 @@ impl HidJob {
|
||||
}
|
||||
},
|
||||
WriteType::Interrupt,
|
||||
|buf, lights| {
|
||||
|buf, _, lights| {
|
||||
buf.len = 31 * 2;
|
||||
for (buf_chunk, state_chunk) in buf
|
||||
.data
|
||||
@@ -184,6 +205,152 @@ impl HidJob {
|
||||
}
|
||||
},
|
||||
),
|
||||
HardwareSpec::YuanconThree => Self::new(
|
||||
state.clone(),
|
||||
0x0518,
|
||||
0x2022,
|
||||
0x83,
|
||||
0x03,
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 46 { // real length is 46 but last 12 bytes are unused
|
||||
return;
|
||||
}
|
||||
|
||||
input.ground.copy_from_slice(&buf.data[2..34]);
|
||||
input.flip_vert();
|
||||
|
||||
let bits: Vec<u8> = (0..8).map(|x| (buf.data[0] >> x) & 1).collect();
|
||||
for i in 0..6 {
|
||||
input.air[i ^ 1] = bits[i];
|
||||
}
|
||||
input.extra[0..2].copy_from_slice(&bits[6..8]);
|
||||
},
|
||||
WriteType::Interrupt,
|
||||
|buf, buf_two, lights| {
|
||||
buf.len = 61;
|
||||
buf.data[0] = 0;
|
||||
buf_two.len = 61;
|
||||
buf_two.data[0] = 1;
|
||||
|
||||
for (buf_chunk, state_chunk) in buf.data[1..61]
|
||||
.chunks_mut(3)
|
||||
.zip(lights.ground.chunks(3).skip(11).take(20).rev())
|
||||
{
|
||||
buf_chunk[0] = state_chunk[0];
|
||||
buf_chunk[1] = state_chunk[1];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
}
|
||||
|
||||
for (buf_chunk, state_chunk) in buf_two.data[1..34]
|
||||
.chunks_mut(3)
|
||||
.zip(lights.ground.chunks(3).take(11).rev())
|
||||
{
|
||||
buf_chunk[0] = state_chunk[0];
|
||||
buf_chunk[1] = state_chunk[1];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
}
|
||||
},
|
||||
),
|
||||
HardwareSpec::Yubideck => Self::new(
|
||||
state.clone(),
|
||||
0x1973,
|
||||
0x2001,
|
||||
0x81, // Need to confirm
|
||||
0x02, // Need to confirm
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 45 && buf.len != 46 {
|
||||
return;
|
||||
}
|
||||
|
||||
input.ground.copy_from_slice(&buf.data[2..34]);
|
||||
input.flip_vert();
|
||||
for i in 0..6 {
|
||||
input.air[i ^ 1] = (buf.data[0] >> i) & 1;
|
||||
}
|
||||
for i in 0..3 {
|
||||
input.extra[2 - i] = (buf.data[1] >> i) & 1;
|
||||
}
|
||||
},
|
||||
WriteType::Interrupt,
|
||||
|buf, _, lights| {
|
||||
buf.len = 62;
|
||||
|
||||
let lights_nibbles: Vec<u8> = lights
|
||||
.ground
|
||||
.chunks(3)
|
||||
.rev()
|
||||
.flat_map(|x| x.iter().map(|y| *y >> 4))
|
||||
.chain([
|
||||
lights.air_left[3] >> 4,
|
||||
lights.air_left[4] >> 4,
|
||||
lights.air_left[5] >> 4,
|
||||
])
|
||||
.collect();
|
||||
|
||||
for (buf_chunk, state_chunk) in buf
|
||||
.data
|
||||
.chunks_mut(3)
|
||||
.take(16)
|
||||
.zip(lights_nibbles.chunks(6))
|
||||
{
|
||||
buf_chunk[0] = (state_chunk[0]) | (state_chunk[1] << 4);
|
||||
buf_chunk[1] = (state_chunk[2]) | (state_chunk[3] << 4);
|
||||
buf_chunk[2] = (state_chunk[4]) | (state_chunk[5] << 4);
|
||||
}
|
||||
},
|
||||
),
|
||||
HardwareSpec::YubideckThree => Self::new(
|
||||
state.clone(),
|
||||
0x1973,
|
||||
0x2001,
|
||||
0x81, // Need to confirm
|
||||
0x02, // Need to confirm
|
||||
*disable_air,
|
||||
|buf, input| {
|
||||
if buf.len != 45 && buf.len != 46 {
|
||||
return;
|
||||
}
|
||||
|
||||
input.ground.copy_from_slice(&buf.data[2..34]);
|
||||
input.flip_vert();
|
||||
for i in 0..6 {
|
||||
input.air[i ^ 1] = (buf.data[0] >> i) & 1;
|
||||
}
|
||||
for i in 0..3 {
|
||||
input.extra[2 - i] = (buf.data[1] >> i) & 1;
|
||||
}
|
||||
},
|
||||
WriteType::Interrupt,
|
||||
|buf, buf_two, lights| {
|
||||
buf.len = 61;
|
||||
buf.data[0] = 0;
|
||||
buf_two.len = 61;
|
||||
buf_two.data[0] = 1;
|
||||
|
||||
for (buf_chunk, state_chunk) in buf.data[1..61]
|
||||
.chunks_mut(3)
|
||||
.zip(lights.ground.chunks(3).skip(11).take(20).rev())
|
||||
{
|
||||
buf_chunk[0] = state_chunk[0];
|
||||
buf_chunk[1] = state_chunk[1];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
}
|
||||
|
||||
for (buf_chunk, state_chunk) in buf_two.data[1..34]
|
||||
.chunks_mut(3)
|
||||
.zip(lights.ground.chunks(3).take(11).rev())
|
||||
{
|
||||
buf_chunk[0] = state_chunk[0];
|
||||
buf_chunk[1] = state_chunk[1];
|
||||
buf_chunk[2] = state_chunk[2];
|
||||
}
|
||||
|
||||
buf_two.data[34..37].copy_from_slice(&lights.air_left[3..6]);
|
||||
buf_two.data[37..40].copy_from_slice(&lights.air_right[3..6]);
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +370,15 @@ impl HidJob {
|
||||
}
|
||||
info!("Device setting configuration");
|
||||
handle.set_active_configuration(1)?;
|
||||
|
||||
// A bit janky but Laverita v3 seems to require interface 3
|
||||
info!("Device claiming interface");
|
||||
handle.claim_interface(0)?;
|
||||
if self.vid == 0x0518 && self.pid == 0x2022 {
|
||||
handle.claim_interface(3)?;
|
||||
} else {
|
||||
handle.claim_interface(0)?;
|
||||
}
|
||||
|
||||
self.handle = Some(handle);
|
||||
Ok(())
|
||||
}
|
||||
@@ -246,6 +420,10 @@ impl ThreadJob for HidJob {
|
||||
work = true;
|
||||
let mut input_handle = self.state.input.lock();
|
||||
(self.read_callback)(&self.read_buf, input_handle.deref_mut());
|
||||
|
||||
if self.disable_air {
|
||||
input_handle.air.fill(0);
|
||||
}
|
||||
swap(&mut self.read_buf, &mut self.last_read_buf);
|
||||
}
|
||||
}
|
||||
@@ -255,7 +433,11 @@ impl ThreadJob for HidJob {
|
||||
{
|
||||
let mut lights_handle = self.state.lights.lock();
|
||||
if lights_handle.dirty {
|
||||
(self.led_callback)(&mut self.led_buf, lights_handle.deref());
|
||||
(self.led_callback)(
|
||||
&mut self.led_buf,
|
||||
&mut self.led_buf_two,
|
||||
lights_handle.deref(),
|
||||
);
|
||||
lights_handle.dirty = false;
|
||||
}
|
||||
}
|
||||
@@ -277,6 +459,26 @@ impl ThreadJob for HidJob {
|
||||
self.led_buf.len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if self.led_buf_two.len != 0 {
|
||||
let res = (match self.led_write_type {
|
||||
WriteType::Bulk => {
|
||||
handle.write_bulk(self.led_endpoint, self.led_buf_two.slice(), TIMEOUT)
|
||||
}
|
||||
WriteType::Interrupt => {
|
||||
handle.write_interrupt(self.led_endpoint, &self.led_buf_two.slice(), TIMEOUT)
|
||||
}
|
||||
})
|
||||
.map_err(|e| {
|
||||
// debug!("Device write error {}", e);
|
||||
e
|
||||
})
|
||||
.unwrap_or(0);
|
||||
if res == self.led_buf_two.len + 1 {
|
||||
// work = true;
|
||||
self.led_buf_two.len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
work
|
||||
|
||||
@@ -3,22 +3,89 @@ use serde_json::Value;
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ReactiveLayout {
|
||||
Even { splits: usize },
|
||||
Six,
|
||||
Voltex,
|
||||
Hori,
|
||||
Rainbow,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ColorScheme {
|
||||
pub active: [u8; 3],
|
||||
pub inactive: [u8; 3],
|
||||
pub air_active: [u8; 3],
|
||||
pub air_inactive: [u8; 3],
|
||||
}
|
||||
|
||||
impl ColorScheme {
|
||||
pub fn from_serde_value(v: &Value) -> Option<Self> {
|
||||
Some(Self {
|
||||
active: [
|
||||
u8::from_str_radix(&v["ledColorActive"].as_str()?[1..3], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorActive"].as_str()?[3..5], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorActive"].as_str()?[5..7], 16).ok()?,
|
||||
],
|
||||
inactive: [
|
||||
u8::from_str_radix(&v["ledColorInactive"].as_str()?[1..3], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorInactive"].as_str()?[3..5], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorInactive"].as_str()?[5..7], 16).ok()?,
|
||||
],
|
||||
air_active: [
|
||||
u8::from_str_radix(&v["ledColorAirActive"].as_str()?[1..3], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorAirActive"].as_str()?[3..5], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorAirActive"].as_str()?[5..7], 16).ok()?,
|
||||
],
|
||||
air_inactive: [
|
||||
u8::from_str_radix(&v["ledColorAirInactive"].as_str()?[1..3], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorAirInactive"].as_str()?[3..5], 16).ok()?,
|
||||
u8::from_str_radix(&v["ledColorAirInactive"].as_str()?[5..7], 16).ok()?,
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
active: [255, 0, 255],
|
||||
inactive: [255, 255, 0],
|
||||
air_active: [0, 134, 237],
|
||||
air_inactive: [0, 0, 0],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_serde_value_or_default(v: &Value) -> Self {
|
||||
Self::from_serde_value(v)
|
||||
.or(Some(Self {
|
||||
active: [255, 0, 255],
|
||||
inactive: [255, 255, 0],
|
||||
air_active: [0, 134, 237],
|
||||
air_inactive: [0, 0, 0],
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LightsMode {
|
||||
None,
|
||||
Reactive {
|
||||
faster: bool,
|
||||
layout: ReactiveLayout,
|
||||
sensitivity: u8,
|
||||
color: ColorScheme,
|
||||
},
|
||||
Attract {
|
||||
faster: bool,
|
||||
},
|
||||
Attract,
|
||||
Test,
|
||||
Websocket {
|
||||
faster: bool,
|
||||
url: String,
|
||||
},
|
||||
UmgrWebsocket {
|
||||
faster: bool,
|
||||
port: u16,
|
||||
},
|
||||
Serial {
|
||||
faster: bool,
|
||||
port: String,
|
||||
},
|
||||
}
|
||||
@@ -27,28 +94,61 @@ impl LightsMode {
|
||||
pub fn from_serde_value(v: &Value) -> Option<Self> {
|
||||
Some(match v["ledMode"].as_str()? {
|
||||
"none" => LightsMode::None,
|
||||
"reactive-4" => LightsMode::Reactive {
|
||||
layout: ReactiveLayout::Even { splits: 4 },
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
},
|
||||
"reactive-8" => LightsMode::Reactive {
|
||||
layout: ReactiveLayout::Even { splits: 8 },
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
},
|
||||
"reactive-16" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Even { splits: 16 },
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::from_serde_value_or_default(v),
|
||||
},
|
||||
"reactive-8" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Even { splits: 8 },
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::from_serde_value_or_default(v),
|
||||
},
|
||||
"reactive-6" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Six,
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::from_serde_value_or_default(v),
|
||||
},
|
||||
"reactive-4" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Even { splits: 4 },
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::from_serde_value_or_default(v),
|
||||
},
|
||||
"reactive-rainbow" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Rainbow,
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::default(),
|
||||
},
|
||||
"reactive-voltex" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Voltex,
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::default(),
|
||||
},
|
||||
"reactive-hori" => LightsMode::Reactive {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
layout: ReactiveLayout::Hori,
|
||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||
color: ColorScheme::default(),
|
||||
},
|
||||
"attract" => LightsMode::Attract {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
},
|
||||
"attract" => LightsMode::Attract,
|
||||
"test" => LightsMode::Test,
|
||||
"websocket" => LightsMode::Websocket {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
url: v["ledWebsocketUrl"].as_str()?.to_string(),
|
||||
},
|
||||
"umgr-websocket" => LightsMode::UmgrWebsocket {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
port: u16::try_from(v["ledUmgrWebsocketPort"].as_i64()?).ok()?,
|
||||
},
|
||||
"serial" => LightsMode::Serial {
|
||||
faster: v["ledFaster"].as_bool()?,
|
||||
port: v["ledSerialPort"].as_str()?.to_string(),
|
||||
},
|
||||
_ => return None,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use async_trait::async_trait;
|
||||
use log::{error, info};
|
||||
use palette::{FromColor, Hsv, Srgb};
|
||||
use palette::{encoding::Srgb as SrgbEncoding, rgb::Rgb, FromColor, Hsv, Srgb};
|
||||
use serialport::{ClearBuffer, SerialPort};
|
||||
use std::{
|
||||
ops::DerefMut,
|
||||
@@ -9,12 +9,27 @@ use std::{
|
||||
use tokio::time::{interval, Interval};
|
||||
|
||||
use crate::{
|
||||
shared::{utils::Buffer, voltex::VoltexState, worker::AsyncJob},
|
||||
shared::{hori::HoriState, utils::Buffer, voltex::VoltexState, worker::AsyncJob},
|
||||
state::{SliderLights, SliderState},
|
||||
};
|
||||
|
||||
use super::config::{LightsMode, ReactiveLayout};
|
||||
|
||||
fn get_rainbow(phase: f64, desaturate: bool) -> Rgb<SrgbEncoding, u8> {
|
||||
let phase = ((phase % 1.0) + 1.0) % 1.0;
|
||||
let color = Srgb::from_color(Hsv::new(
|
||||
phase * 360.0,
|
||||
match desaturate {
|
||||
false => 1.0,
|
||||
true => 0.2,
|
||||
},
|
||||
1.0,
|
||||
))
|
||||
.into_format::<u8>();
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
pub struct LightsJob {
|
||||
state: SliderState,
|
||||
mode: LightsMode,
|
||||
@@ -30,7 +45,15 @@ impl LightsJob {
|
||||
mode: mode.clone(),
|
||||
serial_port: None,
|
||||
started: Instant::now(),
|
||||
timer: interval(Duration::from_micros(33333)),
|
||||
timer: match match mode {
|
||||
LightsMode::Attract { faster, .. } => *faster,
|
||||
LightsMode::Websocket { faster, .. } => *faster,
|
||||
LightsMode::Serial { faster, .. } => *faster,
|
||||
_ => false,
|
||||
} {
|
||||
false => interval(Duration::from_micros(66666)),
|
||||
true => interval(Duration::from_micros(33333)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +63,8 @@ impl LightsJob {
|
||||
serial_buffer: Option<&Buffer>,
|
||||
lights: &mut SliderLights,
|
||||
) {
|
||||
match self.mode {
|
||||
LightsMode::Reactive { layout, .. } => {
|
||||
match &self.mode {
|
||||
LightsMode::Reactive { layout, color, .. } => {
|
||||
let flat_input = flat_input.unwrap();
|
||||
|
||||
match layout {
|
||||
@@ -50,22 +73,74 @@ impl LightsJob {
|
||||
|
||||
let banks: Vec<bool> = flat_input
|
||||
.chunks(32 / splits)
|
||||
.take(splits)
|
||||
.take(*splits)
|
||||
.map(|x| x.contains(&true))
|
||||
.collect();
|
||||
|
||||
for idx in 0..31 {
|
||||
lights.paint(
|
||||
idx,
|
||||
match (idx + 1) % buttons_per_split {
|
||||
0 => &[255, 0, 255],
|
||||
match ((idx + 1) % buttons_per_split, (idx + 1) % 2) {
|
||||
(0, _) => &color.active,
|
||||
(_, 0) => &color.inactive,
|
||||
_ => match banks[idx / buttons_per_split] {
|
||||
true => &[255, 0, 255],
|
||||
false => &[255, 255, 0],
|
||||
true => &color.active,
|
||||
false => &color.inactive,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for idx in 0..3 {
|
||||
lights.paint_air(
|
||||
idx,
|
||||
match flat_input[32 + idx * 2] || flat_input[33 + idx * 2] {
|
||||
true => &color.air_active,
|
||||
false => &color.air_inactive,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
ReactiveLayout::Six => {
|
||||
let banks: Vec<bool> = [0..6, 6..10, 10..16, 16..22, 22..26, 26..32]
|
||||
.into_iter()
|
||||
.map(|x| flat_input[x].contains(&true))
|
||||
.collect();
|
||||
|
||||
for idx in (1..31).step_by(2) {
|
||||
lights.paint(
|
||||
idx,
|
||||
match idx {
|
||||
5 | 9 | 15 | 21 | 25 => &color.active,
|
||||
_ => &color.inactive,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for (bank_idxs, bank_val) in [0..6, 6..10, 10..16, 16..22, 22..26, 26..32]
|
||||
.into_iter()
|
||||
.zip(banks)
|
||||
{
|
||||
for idx in bank_idxs.step_by(2) {
|
||||
lights.paint(
|
||||
idx,
|
||||
match bank_val {
|
||||
true => &color.active,
|
||||
false => &color.inactive,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
for idx in 0..3 {
|
||||
lights.paint_air(
|
||||
idx,
|
||||
match flat_input[32 + idx * 2] || flat_input[33 + idx * 2] {
|
||||
true => &color.air_active,
|
||||
false => &color.air_inactive,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
ReactiveLayout::Voltex => {
|
||||
lights.ground.fill(0);
|
||||
@@ -114,19 +189,114 @@ impl LightsJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
ReactiveLayout::Hori => {
|
||||
lights.ground.fill(0);
|
||||
|
||||
// Fixed
|
||||
for idx in [7, 15, 23] {
|
||||
lights.paint(idx, &[64, 64, 64]);
|
||||
}
|
||||
|
||||
let hori_state = HoriState::from_flat(flat_input);
|
||||
|
||||
for (idx, (bt, color)) in hori_state
|
||||
.bt
|
||||
.iter()
|
||||
.zip([
|
||||
&[64, 226, 160],
|
||||
&[255, 105, 248],
|
||||
&[124, 178, 232],
|
||||
&[255, 102, 102],
|
||||
])
|
||||
.enumerate()
|
||||
{
|
||||
let color_f = match bt {
|
||||
true => 1,
|
||||
false => 4,
|
||||
};
|
||||
let adjcolor = [color[0] / color_f, color[1] / color_f, color[2] / color_f];
|
||||
for i in 0..4 {
|
||||
lights.paint(idx * 8 + i * 2, &adjcolor);
|
||||
}
|
||||
}
|
||||
|
||||
for (idx, (a, b)) in hori_state
|
||||
.slider
|
||||
.iter()
|
||||
.zip(hori_state.slider.iter().skip(1))
|
||||
.enumerate()
|
||||
{
|
||||
if *a || *b {
|
||||
lights.paint(1 + idx * 2, &[200, 200, 200]);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReactiveLayout::Rainbow => {
|
||||
let banks: Vec<bool> = flat_input
|
||||
.chunks(2)
|
||||
.take(16)
|
||||
.map(|x| x.contains(&true))
|
||||
.collect();
|
||||
let theta = self
|
||||
.started
|
||||
.elapsed()
|
||||
.div_duration_f64(Duration::from_secs(4))
|
||||
% 1.0;
|
||||
|
||||
for idx in 0..31 {
|
||||
let slice_theta = theta + (idx as f64) / 32.0;
|
||||
let color = get_rainbow(slice_theta, ((idx % 2) == 0) && banks[idx / 2]);
|
||||
lights.paint(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
|
||||
// left
|
||||
for idx in 0..3 {
|
||||
let slice_theta = theta - ((idx + 1) as f64) / 32.0;
|
||||
let color = get_rainbow(
|
||||
slice_theta,
|
||||
flat_input[32 + idx * 2] || flat_input[33 + idx * 2],
|
||||
);
|
||||
lights.paint_air_left(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
|
||||
// right
|
||||
for idx in 0..3 {
|
||||
let slice_theta = theta + (idx as f64) / 32.0;
|
||||
let color = get_rainbow(
|
||||
slice_theta,
|
||||
flat_input[32 + idx * 2] || flat_input[33 + idx * 2],
|
||||
);
|
||||
lights.paint_air_right(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LightsMode::Attract => {
|
||||
LightsMode::Attract { .. } => {
|
||||
let theta = self
|
||||
.started
|
||||
.elapsed()
|
||||
.div_duration_f64(Duration::from_secs(4))
|
||||
% 1.0;
|
||||
|
||||
for idx in 0..31 {
|
||||
let slice_theta = (&theta + (idx as f64) / 32.0) % 1.0;
|
||||
let color = Srgb::from_color(Hsv::new(slice_theta * 360.0, 1.0, 1.0)).into_format::<u8>();
|
||||
let slice_theta = theta + (idx as f64) / 32.0;
|
||||
let color = get_rainbow(slice_theta, false);
|
||||
lights.paint(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
|
||||
// left
|
||||
for idx in 0..3 {
|
||||
let slice_theta = theta - ((idx + 1) as f64) / 32.0;
|
||||
let color = get_rainbow(slice_theta, false);
|
||||
lights.paint_air_left(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
|
||||
// right
|
||||
for idx in 0..3 {
|
||||
let slice_theta = theta + (idx as f64) / 32.0;
|
||||
let color = get_rainbow(slice_theta, false);
|
||||
lights.paint_air_right(idx, &[color.red, color.green, color.blue]);
|
||||
}
|
||||
}
|
||||
LightsMode::Serial { .. } => {
|
||||
// https://github.com/jmontineri/OpeNITHM/blob/89e9a43f7484e8949cd31bbff79c32f21ea3ec1d/Firmware/OpeNITHM/SerialProcessor.h
|
||||
@@ -158,7 +328,7 @@ impl LightsJob {
|
||||
impl AsyncJob for LightsJob {
|
||||
async fn setup(&mut self) -> bool {
|
||||
match &self.mode {
|
||||
LightsMode::Serial { port } => {
|
||||
LightsMode::Serial { port, .. } => {
|
||||
info!(
|
||||
"Serial port for led opening at {} {:?}",
|
||||
port.as_str(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod config;
|
||||
|
||||
pub mod lighting;
|
||||
pub mod umgr_websocket;
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
use async_trait::async_trait;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use hyper::{
|
||||
header,
|
||||
server::conn::AddrStream,
|
||||
service::{make_service_fn, service_fn},
|
||||
upgrade::{self, Upgraded},
|
||||
Body, Method, Request, Response, Server, StatusCode,
|
||||
};
|
||||
use log::{error, info};
|
||||
use std::{convert::Infallible, future::Future, net::SocketAddr};
|
||||
use tokio::{
|
||||
select,
|
||||
sync::mpsc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tokio_tungstenite::WebSocketStream;
|
||||
use tungstenite::{handshake, Message};
|
||||
|
||||
use crate::{shared::worker::AsyncHaltableJob, state::SliderState};
|
||||
|
||||
async fn error_response() -> Result<Response<Body>, Infallible> {
|
||||
Ok(
|
||||
Response::builder()
|
||||
.status(StatusCode::NOT_FOUND)
|
||||
.body(Body::from(format!("Not found")))
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn handle_umgr_leds(ws_stream: WebSocketStream<Upgraded>, state: SliderState, faster: bool) {
|
||||
let (mut ws_write, mut ws_read) = ws_stream.split();
|
||||
|
||||
let (msg_write, mut msg_read) = mpsc::unbounded_channel::<Message>();
|
||||
|
||||
let write_task = async move {
|
||||
// info!("UMGR LED write task started");
|
||||
loop {
|
||||
let message = msg_read.recv().await;
|
||||
// info!("UMGR LED Sending {:?}", message);
|
||||
match message {
|
||||
Some(msg) => match ws_write.send(msg).await.ok() {
|
||||
Some(_) => {}
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// info!("Websocket write task done");
|
||||
};
|
||||
|
||||
let msg_write_handle = msg_write.clone();
|
||||
let state_handle = state.clone();
|
||||
let read_task = async move {
|
||||
// info!("UMGR LED read task started");
|
||||
let mut latest_lights = Instant::now();
|
||||
let delay = match faster {
|
||||
true => Duration::from_micros(33333),
|
||||
false => Duration::from_micros(66666),
|
||||
};
|
||||
|
||||
loop {
|
||||
match ws_read.next().await {
|
||||
Some(msg) => match msg {
|
||||
Ok(msg) => match msg {
|
||||
Message::Binary(msg) => {
|
||||
// Full protocol at
|
||||
// https://gist.github.com/inonote/00251fed881a82c9df1e505eef1722bc
|
||||
// https://gist.github.com/4yn/a6737a33fbce51a8c7d64a8045cb2bee
|
||||
|
||||
// info!("UMGR Packet {:?}", msg);
|
||||
|
||||
if msg.len() < 3 {
|
||||
error!("Unexpected length of UMGR led packet");
|
||||
break;
|
||||
}
|
||||
|
||||
let version = msg[0];
|
||||
let opcode = msg[1];
|
||||
let payload_len = msg[2];
|
||||
let payload = &msg[3..];
|
||||
|
||||
if payload_len as usize != payload.len() {
|
||||
error!("Unexpected length of UMGR led packet");
|
||||
break;
|
||||
}
|
||||
|
||||
match (version, opcode, payload_len) {
|
||||
(0x01, 0x10, 103) => {
|
||||
// SetLED
|
||||
let mut lights_handle = state_handle.lights.lock();
|
||||
|
||||
for i in 0..16 {
|
||||
// Copy lights
|
||||
let pos = 1 + i * 3;
|
||||
lights_handle.paint(i * 2, &[payload[pos], payload[pos + 1], payload[pos + 2]]);
|
||||
}
|
||||
|
||||
for i in 0..15 {
|
||||
let pos = 49 + i * 3;
|
||||
lights_handle.paint(
|
||||
1 + i * 2,
|
||||
&[payload[pos], payload[pos + 1], payload[pos + 2]],
|
||||
);
|
||||
}
|
||||
|
||||
for i in 0..3 {
|
||||
let pos = 94 + i * 3;
|
||||
lights_handle
|
||||
.paint_air(2 - i, &[payload[pos], payload[pos + 1], payload[pos + 2]]);
|
||||
}
|
||||
|
||||
if latest_lights.elapsed() > delay {
|
||||
lights_handle.dirty = true;
|
||||
latest_lights = Instant::now();
|
||||
}
|
||||
}
|
||||
(0x01, 0x11, 0) => {
|
||||
// Initialize
|
||||
info!("UMGR LED Initialize");
|
||||
// Reply with Ready
|
||||
msg_write_handle
|
||||
.send(Message::Binary(vec![0x01, 0x19, 0x00]))
|
||||
.ok();
|
||||
}
|
||||
(0x01, 0x12, 4) => {
|
||||
// Client Ping
|
||||
info!("UMGR LED Ping");
|
||||
// Reply with Pong and extra server magic
|
||||
msg_write_handle
|
||||
.send(Message::Binary(vec![
|
||||
0x01, 0x1a, 6, payload[0], payload[1], payload[2], payload[3], 0x51, 0xed,
|
||||
]))
|
||||
.ok();
|
||||
}
|
||||
(0x01, 0xD0, 0) => {
|
||||
// Client RequestServerInfo
|
||||
info!("UMGR LED Info");
|
||||
// Reply with ReportServerInfo
|
||||
let server_major: u16 = env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap();
|
||||
let server_minor: u16 = env!("CARGO_PKG_VERSION_MINOR").parse().unwrap();
|
||||
let response = [
|
||||
// Command
|
||||
vec![0x01, 0xd8, 44],
|
||||
// Server name
|
||||
b"slider-io\x00\x00\x00\x00\x00\x00\x00".to_vec(),
|
||||
// Server version
|
||||
vec![
|
||||
(server_major >> 8) as u8,
|
||||
(server_major & 0xff) as u8,
|
||||
(server_minor >> 8) as u8,
|
||||
(server_minor & 0xff) as u8,
|
||||
],
|
||||
// Reserved
|
||||
vec![0x00, 0x00],
|
||||
// Hardware name
|
||||
b"generic-slider\x00\x00".to_vec(),
|
||||
// Hardware version
|
||||
vec![0x00, 0x01, 0x00, 0x01],
|
||||
// Reserved
|
||||
vec![0x00, 0x00],
|
||||
]
|
||||
.concat();
|
||||
|
||||
msg_write_handle.send(Message::Binary(response)).ok();
|
||||
}
|
||||
_ => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::Close(_) => {
|
||||
info!("Websocket connection closed");
|
||||
let mut lights_handle = state_handle.lights.lock();
|
||||
lights_handle.reset();
|
||||
break;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Websocket connection error: {}", e);
|
||||
let mut lights_handle = state_handle.lights.lock();
|
||||
lights_handle.reset();
|
||||
break;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// info!("Websocket read task done");
|
||||
};
|
||||
|
||||
select! {
|
||||
_ = read_task => {}
|
||||
_ = write_task => {}
|
||||
};
|
||||
}
|
||||
|
||||
async fn handle_websocket(
|
||||
mut request: Request<Body>,
|
||||
state: SliderState,
|
||||
faster: bool,
|
||||
) -> Result<Response<Body>, Infallible> {
|
||||
let res = match handshake::server::create_response_with_body(&request, || Body::empty()) {
|
||||
Ok(res) => {
|
||||
tokio::spawn(async move {
|
||||
match upgrade::on(&mut request).await {
|
||||
Ok(upgraded) => {
|
||||
let ws_stream = WebSocketStream::from_raw_socket(
|
||||
upgraded,
|
||||
tokio_tungstenite::tungstenite::protocol::Role::Server,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
handle_umgr_leds(ws_stream, state, faster).await;
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
error!("Websocket upgrade error: {}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
res
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Websocket creation error: {}", e);
|
||||
Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Failed to create websocket: {}", e)))
|
||||
.unwrap()
|
||||
}
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
async fn handle_request(
|
||||
request: Request<Body>,
|
||||
remote_addr: SocketAddr,
|
||||
state: SliderState,
|
||||
faster: bool,
|
||||
) -> Result<Response<Body>, Infallible> {
|
||||
let method = request.method();
|
||||
let path = request.uri().path();
|
||||
if method != Method::GET {
|
||||
error!(
|
||||
"Server unknown method {} -> {} {}",
|
||||
remote_addr, method, path
|
||||
);
|
||||
return error_response().await;
|
||||
}
|
||||
info!("Server {} -> {} {}", remote_addr, method, path);
|
||||
|
||||
match (
|
||||
request.uri().path(),
|
||||
request.headers().contains_key(header::UPGRADE),
|
||||
) {
|
||||
("/", true) => handle_websocket(request, state, faster).await,
|
||||
_ => error_response().await,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UmgrWebsocketJob {
|
||||
state: SliderState,
|
||||
faster: bool,
|
||||
port: u16,
|
||||
}
|
||||
|
||||
impl UmgrWebsocketJob {
|
||||
pub fn new(state: &SliderState, faster: &bool, port: &u16) -> Self {
|
||||
Self {
|
||||
state: state.clone(),
|
||||
faster: *faster,
|
||||
port: *port,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl AsyncHaltableJob for UmgrWebsocketJob {
|
||||
async fn run<F: Future<Output = ()> + Send>(self, stop_signal: F) {
|
||||
let state = self.state.clone();
|
||||
let faster = self.faster;
|
||||
let make_svc = make_service_fn(|conn: &AddrStream| {
|
||||
let remote_addr = conn.remote_addr();
|
||||
let make_svc_state = state.clone();
|
||||
async move {
|
||||
Ok::<_, Infallible>(service_fn(move |request: Request<Body>| {
|
||||
let svc_state = make_svc_state.clone();
|
||||
handle_request(request, remote_addr, svc_state, faster)
|
||||
}))
|
||||
}
|
||||
});
|
||||
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], self.port));
|
||||
info!("UMGR LED websocket server listening on {}", addr);
|
||||
|
||||
let server = Server::bind(&addr)
|
||||
.serve(make_svc)
|
||||
.with_graceful_shutdown(stop_signal);
|
||||
|
||||
if let Err(e) = server.await {
|
||||
info!("UMGR LED websocket server stopped: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,11 @@ pub enum PollingRate {
|
||||
pub enum KeyboardLayout {
|
||||
Tasoller,
|
||||
Yuancon,
|
||||
Umiguri,
|
||||
TasollerHalf,
|
||||
Deemo,
|
||||
EightK,
|
||||
SixK,
|
||||
FourK,
|
||||
Voltex,
|
||||
Neardayo,
|
||||
}
|
||||
@@ -25,6 +28,12 @@ pub enum GamepadLayout {
|
||||
Neardayo,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum HoriLayout {
|
||||
Full,
|
||||
SliderOnly,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OutputMode {
|
||||
None,
|
||||
@@ -32,12 +41,18 @@ pub enum OutputMode {
|
||||
layout: KeyboardLayout,
|
||||
polling: PollingRate,
|
||||
sensitivity: u8,
|
||||
direct_input: bool,
|
||||
},
|
||||
Gamepad {
|
||||
layout: GamepadLayout,
|
||||
polling: PollingRate,
|
||||
sensitivity: u8,
|
||||
},
|
||||
Hori {
|
||||
layout: HoriLayout,
|
||||
polling: PollingRate,
|
||||
sensitivity: u8,
|
||||
},
|
||||
Websocket {
|
||||
url: String,
|
||||
polling: PollingRate,
|
||||
@@ -75,31 +90,55 @@ impl OutputMode {
|
||||
layout: KeyboardLayout::Tasoller,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-32-yuancon" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::Yuancon,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-16-tasoller" => OutputMode::Keyboard {
|
||||
"kb-32-umiguri" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::Umiguri,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-16" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::TasollerHalf,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-8-deemo" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::Deemo,
|
||||
"kb-8" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::EightK,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-6" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::SixK,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-4" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::FourK,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-voltex" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::Voltex,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"kb-neardayo" => OutputMode::Keyboard {
|
||||
layout: KeyboardLayout::Neardayo,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
direct_input: v["keyboardDirectInput"].as_bool()?,
|
||||
},
|
||||
"gamepad-voltex" => OutputMode::Gamepad {
|
||||
layout: GamepadLayout::Voltex,
|
||||
@@ -111,6 +150,16 @@ impl OutputMode {
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
},
|
||||
"gamepad-hori" => OutputMode::Hori {
|
||||
layout: HoriLayout::Full,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
},
|
||||
"gamepad-hori-wide" => OutputMode::Hori {
|
||||
layout: HoriLayout::SliderOnly,
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
|
||||
},
|
||||
"websocket" => OutputMode::Websocket {
|
||||
url: v["outputWebsocketUrl"].as_str()?.to_string(),
|
||||
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
use log::error;
|
||||
use std::error::Error;
|
||||
use vigem_client::{Client, DS4Report, DualShock4Wired, TargetId};
|
||||
|
||||
use crate::shared::hori::HoriState;
|
||||
|
||||
use super::{config::HoriLayout, output::OutputHandler};
|
||||
|
||||
pub struct HoriOutput {
|
||||
target: DualShock4Wired<Client>,
|
||||
slider_only: bool,
|
||||
gamepad: DS4Report,
|
||||
}
|
||||
|
||||
impl HoriOutput {
|
||||
pub fn new(layout: HoriLayout) -> Option<Self> {
|
||||
let target = Self::get_target();
|
||||
|
||||
let slider_only = match layout {
|
||||
HoriLayout::Full => false,
|
||||
HoriLayout::SliderOnly => true,
|
||||
};
|
||||
|
||||
match target {
|
||||
Ok(target) => Some(Self {
|
||||
target,
|
||||
slider_only,
|
||||
gamepad: DS4Report::default(),
|
||||
}),
|
||||
Err(e) => {
|
||||
error!("Gamepad connection error: {}", e);
|
||||
error!("Gamepad connection error: Is ViGEMBus missing?");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_target() -> Result<DualShock4Wired<Client>, Box<dyn Error>> {
|
||||
let client = Client::connect()?;
|
||||
|
||||
let mut target = DualShock4Wired::new(client, TargetId::DUALSHOCK4_WIRED);
|
||||
target.plugin()?;
|
||||
target.wait_ready()?;
|
||||
Ok(target)
|
||||
}
|
||||
|
||||
fn update(&mut self) -> bool {
|
||||
match self.target.update(&self.gamepad) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
error!("Gamepad update error: {}", e);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl OutputHandler for HoriOutput {
|
||||
fn tick(&mut self, flat_input: &Vec<bool>) -> bool {
|
||||
let hori_state = match self.slider_only {
|
||||
false => HoriState::from_flat(flat_input),
|
||||
true => HoriState::from_flat_to_wide(flat_input),
|
||||
};
|
||||
|
||||
let buttons: u16 = hori_state
|
||||
.bt
|
||||
.iter()
|
||||
.zip([
|
||||
// https://github.com/ViGEm/ViGEmClient/blob/master/include/ViGEm/Common.h#L117
|
||||
1 << 7, // triangle
|
||||
1 << 4, // square
|
||||
1 << 5, // cross
|
||||
1 << 6, // circle
|
||||
])
|
||||
.fold(0x8, |buttons, (state, code)| {
|
||||
buttons
|
||||
| match state {
|
||||
true => code,
|
||||
false => 0,
|
||||
}
|
||||
})
|
||||
| match hori_state.extra[0] {
|
||||
true => 1 << 13, // options
|
||||
false => 0,
|
||||
};
|
||||
|
||||
let axis: u32 = hori_state
|
||||
.slider
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(0, |axis, (idx, state)| {
|
||||
axis
|
||||
| match state {
|
||||
true => 0b11 << ((idx ^ 3) * 2),
|
||||
false => 0,
|
||||
}
|
||||
})
|
||||
^ 0x80808080;
|
||||
|
||||
let mut dirty = false;
|
||||
if self.gamepad.buttons != buttons {
|
||||
self.gamepad.buttons = buttons;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
for (idx, state) in [
|
||||
&mut self.gamepad.thumb_lx,
|
||||
&mut self.gamepad.thumb_ly,
|
||||
&mut self.gamepad.thumb_rx,
|
||||
&mut self.gamepad.thumb_ry,
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let slice: u8 = ((axis >> ((3 - idx) * 8)) & 0xff) as u8;
|
||||
if *state != slice {
|
||||
*state = slice;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
match dirty {
|
||||
true => self.update(),
|
||||
false => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
self.gamepad = DS4Report::default();
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for HoriOutput {
|
||||
fn drop(&mut self) {
|
||||
match self.target.unplug() {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
error!("Gamepad unplug error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dammit vigem_client::Event
|
||||
unsafe impl Send for HoriOutput {}
|
||||
@@ -1,13 +1,14 @@
|
||||
use interception::{Interception, KeyState, ScanCode, Stroke};
|
||||
use log::{error, info};
|
||||
use std::mem;
|
||||
use winapi::{
|
||||
ctypes::c_int,
|
||||
um::winuser::{SendInput, INPUT, INPUT_KEYBOARD, KEYBDINPUT, KEYEVENTF_KEYUP},
|
||||
um::winuser::{
|
||||
MapVirtualKeyA, SendInput, INPUT, INPUT_KEYBOARD, KEYBDINPUT, KEYEVENTF_KEYUP, MAPVK_VK_TO_VSC,
|
||||
},
|
||||
};
|
||||
|
||||
use super::{
|
||||
config::KeyboardLayout,
|
||||
output::OutputHandler
|
||||
};
|
||||
use super::{config::KeyboardLayout, output::OutputHandler};
|
||||
|
||||
#[rustfmt::skip]
|
||||
const TASOLLER_KB_MAP: [usize; 41] = [
|
||||
@@ -31,6 +32,17 @@ const YUANCON_KB_MAP: [usize; 41] = [
|
||||
0x0d, 0x20, 0x1b, // VK_RETURN, VK_SPACE, VK_ESCAPE
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const UMIGURI_KB_MAP: [usize; 41] = [
|
||||
0x41 /* A */, 0x31 /* 1 */, 0x5a /* Z */, 0x51 /* Q */, 0x53 /* S */, 0x32 /* 2 */, 0x58 /* X */, 0x57 /* W */,
|
||||
0x44 /* D */, 0x33 /* 3 */, 0x43 /* C */, 0x45 /* E */, 0x46 /* F */, 0x34 /* 4 */, 0x56 /* V */, 0x52 /* R */,
|
||||
0x47 /* G */, 0x35 /* 5 */, 0x42 /* B */, 0x54 /* T */, 0x48 /* H */, 0x36 /* 6 */, 0x4e /* N */, 0x59 /* Y */,
|
||||
0x4a /* J */, 0x37 /* 7 */, 0x4d /* M */, 0x55 /* U */, 0x4b /* K */, 0x38 /* 8 */, 0x39 /* 9 */, 0x49 /* I */,
|
||||
0x30, 0x4f, 0x4c, // 0, O, L
|
||||
0x50, 0xbc, 0xbe, // P, VK_OEM_COMMA, VK_OEM_PERIOD,
|
||||
0x0d, 0x20, 0x1b // VK_RETURN, VK_SPACE, VK_ESCAPE
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const TASOLLER_HALF_KB_MAP: [usize; 41] = [
|
||||
0x41, 0x41 /* A */, 0x5a, 0x5a /* Z */, 0x53, 0x53 /* S */, 0x58, 0x58 /* X */,
|
||||
@@ -43,7 +55,7 @@ const TASOLLER_HALF_KB_MAP: [usize; 41] = [
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const DEEMO_KB_MAP: [usize; 41] = [
|
||||
const EIGHT_K_MAP: [usize; 41] = [
|
||||
0x41, 0x41, 0x41, 0x41, // A
|
||||
0x53, 0x53, 0x53, 0x53, // S
|
||||
0x44, 0x44, 0x44, 0x44, // D
|
||||
@@ -56,6 +68,28 @@ const DEEMO_KB_MAP: [usize; 41] = [
|
||||
0x00, 0x00, 0x00, // Disabled
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const SIX_K_MAP: [usize; 41] = [
|
||||
0x53, 0x53, 0x53, 0x53, 0x53, 0x53, // S
|
||||
0x44, 0x44, 0x44, 0x44, // D
|
||||
0x46, 0x46, 0x46, 0x46, 0x46, 0x46, // F
|
||||
0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, // J
|
||||
0x4b, 0x4b, 0x4b, 0x4b, // K
|
||||
0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, // L
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // VK_SPACE
|
||||
0x00, 0x00, 0x00, // Disabled
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const FOUR_K_MAP: [usize; 41] = [
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, // D
|
||||
0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, // F
|
||||
0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, // J
|
||||
0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, // K
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // VK_SPACE
|
||||
0x00, 0x00, 0x00, // Disabled
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const VOLTEX_KB_MAP: [usize; 41] = [
|
||||
0x57, 0x57, 0x57, 0x57, // W
|
||||
@@ -93,41 +127,74 @@ const VOLTEX_KB_MAP_NEARDAYO: [usize; 41] = [
|
||||
];
|
||||
|
||||
pub struct KeyboardOutput {
|
||||
ground_to_idx: [usize; 41],
|
||||
idx_to_keycode: [u16; 41],
|
||||
// keycode_to_idx: [usize; 256],
|
||||
input_to_idx: [usize; 41],
|
||||
key_idx_to_keycode: [u16; 41],
|
||||
key_idx_to_scancode: [Option<ScanCode>; 41],
|
||||
next_keys: [bool; 41],
|
||||
last_keys: [bool; 41],
|
||||
|
||||
direct_input: bool,
|
||||
interception_handle: Option<Interception>,
|
||||
|
||||
kb_buf: [INPUT; 41],
|
||||
kb_direct_buf: [Stroke; 41],
|
||||
n_kb_buf: u32,
|
||||
}
|
||||
|
||||
// interception isn't send, but lazy to wrap
|
||||
unsafe impl Send for KeyboardOutput {}
|
||||
|
||||
impl KeyboardOutput {
|
||||
pub fn new(layout: KeyboardLayout) -> Self {
|
||||
pub fn new(layout: KeyboardLayout, direct_input: bool) -> Self {
|
||||
let kb_map = match layout {
|
||||
KeyboardLayout::Tasoller => &TASOLLER_KB_MAP,
|
||||
KeyboardLayout::Yuancon => &YUANCON_KB_MAP,
|
||||
KeyboardLayout::Umiguri => &UMIGURI_KB_MAP,
|
||||
KeyboardLayout::TasollerHalf => &TASOLLER_HALF_KB_MAP,
|
||||
KeyboardLayout::Deemo => &DEEMO_KB_MAP,
|
||||
KeyboardLayout::EightK => &EIGHT_K_MAP,
|
||||
KeyboardLayout::SixK => &SIX_K_MAP,
|
||||
KeyboardLayout::FourK => &FOUR_K_MAP,
|
||||
KeyboardLayout::Voltex => &VOLTEX_KB_MAP,
|
||||
KeyboardLayout::Neardayo => &VOLTEX_KB_MAP_NEARDAYO,
|
||||
};
|
||||
|
||||
let mut ground_to_idx = [0 as usize; 41];
|
||||
let mut idx_to_keycode = [0 as u16; 41];
|
||||
let mut input_to_key_idx = [0 as usize; 41];
|
||||
let mut key_idx_to_keycode = [0 as u16; 41];
|
||||
let mut key_idx_to_scancode = [None as Option<ScanCode>; 41];
|
||||
let mut keycode_to_idx = [0xffff as usize; 256];
|
||||
let mut keycode_count: usize = 0;
|
||||
|
||||
for (ground, keycode) in kb_map.iter().enumerate() {
|
||||
if keycode_to_idx[*keycode] == 0xffff {
|
||||
keycode_to_idx[*keycode] = keycode_count;
|
||||
idx_to_keycode[keycode_count] = *keycode as u16;
|
||||
key_idx_to_keycode[keycode_count] = *keycode as u16;
|
||||
key_idx_to_scancode[keycode_count] =
|
||||
ScanCode::try_from(unsafe { MapVirtualKeyA((*keycode) as u32, MAPVK_VK_TO_VSC) as u16 })
|
||||
.ok();
|
||||
// info!(
|
||||
// "mapped {:?} to {:?}",
|
||||
// key_idx_to_keycode[keycode_count], key_idx_to_scancode[keycode_count]
|
||||
// );
|
||||
keycode_count += 1;
|
||||
}
|
||||
ground_to_idx[ground] = keycode_to_idx[*keycode]
|
||||
input_to_key_idx[ground] = keycode_to_idx[*keycode]
|
||||
}
|
||||
|
||||
let interception_handle = match direct_input {
|
||||
true => {
|
||||
let inner_handle = Interception::new();
|
||||
|
||||
if inner_handle.is_some() {
|
||||
info!("Keyboard emulation with interception loaded");
|
||||
} else {
|
||||
error!("Keyboard emulation cannot load interception, falling back to SendKeys()");
|
||||
}
|
||||
inner_handle
|
||||
}
|
||||
false => None,
|
||||
};
|
||||
let direct_input = interception_handle.is_some();
|
||||
|
||||
let mut kb_buf = [INPUT {
|
||||
type_: INPUT_KEYBOARD,
|
||||
u: unsafe { mem::zeroed() },
|
||||
@@ -142,13 +209,24 @@ impl KeyboardOutput {
|
||||
inner.dwExtraInfo = 0;
|
||||
}
|
||||
|
||||
let kb_direct_buf = [Stroke::Keyboard {
|
||||
code: ScanCode::Esc,
|
||||
state: KeyState::UP,
|
||||
information: 0,
|
||||
}; 41];
|
||||
|
||||
Self {
|
||||
ground_to_idx,
|
||||
idx_to_keycode,
|
||||
// keycode_to_idx,
|
||||
input_to_idx: input_to_key_idx,
|
||||
key_idx_to_keycode,
|
||||
key_idx_to_scancode,
|
||||
next_keys: [false; 41],
|
||||
last_keys: [false; 41],
|
||||
|
||||
direct_input,
|
||||
interception_handle,
|
||||
|
||||
kb_buf,
|
||||
kb_direct_buf,
|
||||
n_kb_buf: 0,
|
||||
}
|
||||
}
|
||||
@@ -162,24 +240,52 @@ impl KeyboardOutput {
|
||||
.zip(self.last_keys.iter_mut())
|
||||
.enumerate()
|
||||
{
|
||||
let keycode = self.idx_to_keycode[i];
|
||||
if keycode == 0 {
|
||||
let keycode = self.key_idx_to_keycode[i];
|
||||
let scancode = self.key_idx_to_scancode[i];
|
||||
|
||||
if (!self.direct_input && keycode == 0) || (self.direct_input && scancode.is_none()) {
|
||||
continue;
|
||||
}
|
||||
match (*n, *l) {
|
||||
(true, false) => {
|
||||
match (self.direct_input, *n, *l) {
|
||||
(false, true, false) => {
|
||||
let inner: &mut KEYBDINPUT = unsafe { self.kb_buf[self.n_kb_buf as usize].u.ki_mut() };
|
||||
inner.wVk = keycode;
|
||||
inner.dwFlags = 0;
|
||||
self.n_kb_buf += 1;
|
||||
// println!("{} down", keycode);
|
||||
}
|
||||
(false, true) => {
|
||||
(false, false, true) => {
|
||||
let inner: &mut KEYBDINPUT = unsafe { self.kb_buf[self.n_kb_buf as usize].u.ki_mut() };
|
||||
inner.wVk = keycode;
|
||||
inner.dwFlags = KEYEVENTF_KEYUP;
|
||||
self.n_kb_buf += 1;
|
||||
// println!("{} up", keycode);
|
||||
}
|
||||
(true, true, false) => {
|
||||
// info!("keydown {:?}", scancode);
|
||||
let inner: &mut Stroke = &mut self.kb_direct_buf[self.n_kb_buf as usize];
|
||||
if let Stroke::Keyboard {
|
||||
code,
|
||||
state,
|
||||
information: _,
|
||||
} = inner
|
||||
{
|
||||
*code = scancode.unwrap();
|
||||
*state = KeyState::DOWN;
|
||||
self.n_kb_buf += 1;
|
||||
}
|
||||
}
|
||||
(true, false, true) => {
|
||||
// info!("keyup {:?}", scancode);
|
||||
let inner: &mut Stroke = &mut self.kb_direct_buf[self.n_kb_buf as usize];
|
||||
if let Stroke::Keyboard {
|
||||
code,
|
||||
state,
|
||||
information: _,
|
||||
} = inner
|
||||
{
|
||||
*code = scancode.unwrap();
|
||||
*state = KeyState::UP;
|
||||
self.n_kb_buf += 1;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -187,12 +293,19 @@ impl KeyboardOutput {
|
||||
}
|
||||
|
||||
if self.n_kb_buf != 0 {
|
||||
unsafe {
|
||||
SendInput(
|
||||
self.n_kb_buf,
|
||||
self.kb_buf.as_mut_ptr(),
|
||||
mem::size_of::<INPUT>() as c_int,
|
||||
);
|
||||
match self.direct_input {
|
||||
false => unsafe {
|
||||
SendInput(
|
||||
self.n_kb_buf,
|
||||
self.kb_buf.as_mut_ptr(),
|
||||
mem::size_of::<INPUT>() as c_int,
|
||||
);
|
||||
},
|
||||
true => {
|
||||
if let Some(handle) = self.interception_handle.as_mut() {
|
||||
handle.send(1, &self.kb_direct_buf[0..self.n_kb_buf as usize]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +316,7 @@ impl OutputHandler for KeyboardOutput {
|
||||
self.next_keys.fill(false);
|
||||
for (idx, x) in flat_input.iter().enumerate() {
|
||||
if *x {
|
||||
self.next_keys[self.ground_to_idx[idx]] = true;
|
||||
self.next_keys[self.input_to_idx[idx]] = true;
|
||||
}
|
||||
}
|
||||
self.send();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod config;
|
||||
|
||||
mod gamepad;
|
||||
mod hori;
|
||||
mod keyboard;
|
||||
|
||||
pub mod output;
|
||||
|
||||
@@ -5,7 +5,9 @@ use tokio::time::{interval, Interval};
|
||||
|
||||
use crate::{shared::worker::AsyncJob, state::SliderState};
|
||||
|
||||
use super::{config::OutputMode, gamepad::GamepadOutput, keyboard::KeyboardOutput};
|
||||
use super::{
|
||||
config::OutputMode, gamepad::GamepadOutput, hori::HoriOutput, keyboard::KeyboardOutput,
|
||||
};
|
||||
|
||||
pub trait OutputHandler: Send {
|
||||
fn tick(&mut self, flat_input: &Vec<bool>) -> bool;
|
||||
@@ -40,9 +42,10 @@ impl AsyncJob for OutputJob {
|
||||
layout,
|
||||
polling,
|
||||
sensitivity,
|
||||
direct_input,
|
||||
} => {
|
||||
self.sensitivity = sensitivity;
|
||||
self.handler = Some(Box::new(KeyboardOutput::new(layout.clone())));
|
||||
self.handler = Some(Box::new(KeyboardOutput::new(layout.clone(), direct_input)));
|
||||
self.timer = interval(Duration::from_micros(polling.to_t_u64()));
|
||||
|
||||
true
|
||||
@@ -64,6 +67,23 @@ impl AsyncJob for OutputJob {
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
OutputMode::Hori {
|
||||
layout,
|
||||
polling,
|
||||
sensitivity,
|
||||
} => {
|
||||
self.sensitivity = sensitivity;
|
||||
let handler = HoriOutput::new(layout.clone());
|
||||
self.timer = interval(Duration::from_micros(polling.to_t_u64()));
|
||||
|
||||
match handler {
|
||||
Some(handler) => {
|
||||
self.handler = Some(Box::new(handler));
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("Not implemented");
|
||||
false
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
pub struct HoriState {
|
||||
pub slider: [bool; 16],
|
||||
pub bt: [bool; 4],
|
||||
pub extra: [bool; 1],
|
||||
}
|
||||
|
||||
impl HoriState {
|
||||
pub fn from_flat(flat_input: &Vec<bool>) -> Self {
|
||||
let mut hori_state = Self {
|
||||
slider: [false; 16],
|
||||
bt: [false; 4],
|
||||
extra: [false; 1],
|
||||
};
|
||||
|
||||
for (idx, i) in flat_input[0..32].iter().enumerate() {
|
||||
match idx % 2 {
|
||||
0 => {
|
||||
hori_state.bt[idx / 8] |= *i;
|
||||
}
|
||||
1 => {
|
||||
hori_state.slider[idx / 2] |= *i;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
hori_state.extra[0] = flat_input[38];
|
||||
|
||||
hori_state
|
||||
}
|
||||
|
||||
pub fn from_flat_to_wide(flat_input: &Vec<bool>) -> Self {
|
||||
let mut hori_state = Self {
|
||||
slider: [false; 16],
|
||||
bt: [false; 4],
|
||||
extra: [false; 1],
|
||||
};
|
||||
|
||||
for (idx, i) in flat_input[0..32].iter().enumerate() {
|
||||
hori_state.slider[idx / 2] |= *i;
|
||||
}
|
||||
|
||||
hori_state.extra[0] = flat_input[38];
|
||||
|
||||
hori_state
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod hori;
|
||||
pub mod serial;
|
||||
pub mod utils;
|
||||
pub mod voltex;
|
||||
|
||||
@@ -43,6 +43,7 @@ impl Error for ShimError {
|
||||
pub struct LoopTimer {
|
||||
cap: usize,
|
||||
cur: usize,
|
||||
init: usize,
|
||||
buf: Vec<Instant>,
|
||||
freq: Arc<AtomicF64>,
|
||||
}
|
||||
@@ -52,16 +53,22 @@ impl LoopTimer {
|
||||
Self {
|
||||
cap: 100,
|
||||
cur: 0,
|
||||
buf: vec![Instant::now() - Duration::from_secs(10_000); 100],
|
||||
init: 0,
|
||||
buf: vec![Instant::now(); 100],
|
||||
freq: Arc::new(AtomicF64::new(0.0)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) {
|
||||
let last = self.buf[self.cur];
|
||||
let now = Instant::now();
|
||||
if self.init < 100 {
|
||||
self.init += 1;
|
||||
}
|
||||
|
||||
self.buf[self.cur] = now;
|
||||
|
||||
let delta = (now - last) / 100 + Duration::from_micros(1);
|
||||
let delta = (now - last) / (self.init as u32) + Duration::from_micros(1);
|
||||
let freq = Duration::from_millis(1000)
|
||||
.div_duration_f64(delta)
|
||||
.clamp(0.0, 9999.0);
|
||||
@@ -75,7 +82,8 @@ impl LoopTimer {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn reset(&mut self) {
|
||||
self.buf = vec![Instant::now() - Duration::from_secs(10); 100];
|
||||
self.init = 0;
|
||||
self.buf = vec![Instant::now(); 100];
|
||||
self.cur = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ pub struct SliderLights {
|
||||
/// right. Alternates between 16 touch pad pixels and 15 divider pixels.
|
||||
pub ground: [u8; 3 * 31],
|
||||
|
||||
// RGB light values for left and right air sensors, bottom to top
|
||||
pub air_left: [u8; 3 * 3],
|
||||
pub air_right: [u8; 3 * 3],
|
||||
|
||||
/// Internal dirty flag used to indicate that new lighting data is available.
|
||||
pub dirty: bool,
|
||||
|
||||
@@ -73,6 +77,8 @@ impl SliderLights {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
ground: [0; 3 * 31],
|
||||
air_left: [0; 3 * 3],
|
||||
air_right: [0; 3 * 3],
|
||||
dirty: false,
|
||||
start: Instant::now(),
|
||||
}
|
||||
@@ -82,6 +88,34 @@ impl SliderLights {
|
||||
pub fn paint(&mut self, idx: usize, color: &[u8; 3]) {
|
||||
self.ground[3 * idx..3 * (idx + 1)].copy_from_slice(color);
|
||||
}
|
||||
|
||||
pub fn paint_air(&mut self, idx: usize, color: &[u8; 3]) {
|
||||
self.air_left[3 * idx..3 * (idx + 1)].copy_from_slice(color);
|
||||
self.air_right[3 * idx..3 * (idx + 1)].copy_from_slice(color);
|
||||
}
|
||||
|
||||
pub fn paint_air_left(&mut self, idx: usize, color: &[u8; 3]) {
|
||||
self.air_left[3 * idx..3 * (idx + 1)].copy_from_slice(color);
|
||||
}
|
||||
|
||||
pub fn paint_air_right(&mut self, idx: usize, color: &[u8; 3]) {
|
||||
self.air_right[3 * idx..3 * (idx + 1)].copy_from_slice(color);
|
||||
}
|
||||
|
||||
pub fn get_air_middle(&self) -> [u8; 3] {
|
||||
return [
|
||||
((self.air_left[3] as u16 + self.air_right[3] as u16) / 2) as u8,
|
||||
((self.air_left[4] as u16 + self.air_right[4] as u16) / 2) as u8,
|
||||
((self.air_left[5] as u16 + self.air_right[5] as u16) / 2) as u8,
|
||||
];
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.ground.fill(0);
|
||||
self.air_left.fill(0);
|
||||
self.air_right.fill(0);
|
||||
self.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Stores data required for a single slider controller. Data and lighting
|
||||
@@ -117,6 +151,8 @@ impl SliderState {
|
||||
{
|
||||
let lights_handle = self.lights.lock();
|
||||
buf.extend(lights_handle.ground);
|
||||
buf.extend(lights_handle.air_left);
|
||||
buf.extend(lights_handle.air_right);
|
||||
};
|
||||
|
||||
buf
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use directories::ProjectDirs;
|
||||
use image::Luma;
|
||||
use log::info;
|
||||
use qrcode::QrCode;
|
||||
use std::{error::Error, fs, path::PathBuf};
|
||||
|
||||
@@ -25,7 +26,7 @@ fn get_config_dir() -> Option<Box<PathBuf>> {
|
||||
}
|
||||
|
||||
/// Generates a helper QR for connecting with brokenithm
|
||||
pub fn get_brokenithm_qr_path() -> Option<Box<PathBuf>> {
|
||||
pub fn get_brokenithm_qr_path(port: Option<u16>) -> Option<Box<PathBuf>> {
|
||||
let config_dir = get_config_dir()?;
|
||||
let brokenithm_qr_path = config_dir.join("brokenithm.png");
|
||||
|
||||
@@ -36,7 +37,10 @@ pub fn get_brokenithm_qr_path() -> Option<Box<PathBuf>> {
|
||||
.filter(|s| s.as_str().chars().filter(|x| *x == '.').count() == 3)
|
||||
.map(|s| base64::encode_config(s, base64::URL_SAFE_NO_PAD))
|
||||
.collect::<Vec<String>>()
|
||||
.join(";");
|
||||
.join(";")
|
||||
+ "&p="
|
||||
+ port.or(Some(1606)).unwrap().to_string().as_str();
|
||||
info!("Url generated {}", link);
|
||||
let qr = QrCode::new(link).ok()?;
|
||||
let image = qr.render::<Luma<u8>>().build();
|
||||
image.save(brokenithm_qr_path.as_path()).ok()?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "slidershim"
|
||||
version = "0.2.0"
|
||||
version = "0.6.0"
|
||||
description = "slidershim"
|
||||
authors = ["4yn"]
|
||||
license = ""
|
||||
@@ -10,7 +10,7 @@ edition = "2018"
|
||||
build = "src/build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1.0.0-beta.4" }
|
||||
tauri-build = { version = "1.0.4", features = [] }
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.14"
|
||||
@@ -19,7 +19,7 @@ env_logger = "0.9.0"
|
||||
|
||||
parking_lot = "0.12.0"
|
||||
|
||||
tauri = { version = "1.0.0-beta.8", features = ["shell-open", "system-tray"] }
|
||||
tauri = { version = "1.0.4", features = ["shell-open", "system-tray", "window-start-dragging"] }
|
||||
open = "2.0.2"
|
||||
|
||||
slider_io = {path = "../src-slider_io" }
|
||||
|
||||
@@ -2,15 +2,62 @@
|
||||
___| (_) __| | ___ _ __ ___| |__ (_)_ __ ___
|
||||
/ __| | |/ _` |/ _ \ '__/ __| '_ \| | '_ ` _ \
|
||||
\__ \ | | (_| | __/ | \__ \ | | | | | | | | |
|
||||
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| v0.2.0
|
||||
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| v0.6.1
|
||||
===============================================
|
||||
|
||||
https://github.com/4yn/slidershim
|
||||
|
||||
# Changelog
|
||||
|
||||
- v0.6.0
|
||||
- Support Laverita v3. Thanks @sr1canskhsia
|
||||
- v0.5.1
|
||||
- Support SSL/wss if brokenithm used with tunnelling. Thanks @kokarare1212
|
||||
- v0.5.0
|
||||
- Support for Yubideck 3.0 firmware
|
||||
- v0.4.3
|
||||
- Make Yubideck USB reports more flexible when reading data
|
||||
- v0.4.2
|
||||
- Fix HORI Project Diva gamepad slider output order
|
||||
- v0.4.1
|
||||
- Fix misplaced checkbox label (clicking on "use DirectInput" would check "disable air" instead)
|
||||
- Make Yuancon USB reports more flexible when reading data
|
||||
- v0.4.0
|
||||
- Add DirectInput keyboard emulation using oblitum/Interception
|
||||
- Add slide LED support for some controllers
|
||||
- v0.3.1
|
||||
- Fix wrong key in UMIGURI keyboard layout
|
||||
- v0.3.0
|
||||
- Add UMIGURI LED controller server support
|
||||
- Add UMIGURI default keyboard layout
|
||||
- v0.2.8
|
||||
- Add slider only layout (no buttons) for Project Diva gamepad output
|
||||
- Add options button to Project Diva gamepad output
|
||||
- v0.2.7
|
||||
- Add HORI Project Diva gamepad output and lighting mode
|
||||
- v0.2.6
|
||||
- Add Yubideck controller support
|
||||
- Add option to change Brokenithm sever port
|
||||
- v0.2.5
|
||||
- Add 6k and 4k keyboard output options
|
||||
- Add settings for reactive LED colors
|
||||
- v0.2.4
|
||||
- Restore support for older tablet devices for brokenithm by compiling brokenithm JS with older babel preset
|
||||
- Fix keys staying pressed even after brokenithm controller is closed
|
||||
- New Brokestalgia 28k web touch controller option
|
||||
- v0.2.3
|
||||
- Fix first and last buttons not working with brokenithm
|
||||
- Add option to disable air strings for controllers
|
||||
- Add option to slow down lighting updates
|
||||
- v0.2.2
|
||||
- Retcon serial slider name
|
||||
- Fix crash on some systems due to time math
|
||||
- Add link to repo
|
||||
- v0.2.1
|
||||
- Reactive + Rainbow mode
|
||||
- Fixed byte order for serial slider lights
|
||||
- v0.2.0
|
||||
- Added support for Hori Project DIVA slider protocol
|
||||
- Added support for serial slider protocol
|
||||
- Added 16 key keyboard layout
|
||||
- v0.1.4
|
||||
- Initial public release
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 918 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1023 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -13,7 +13,8 @@ use std::sync::Arc;
|
||||
use log::info;
|
||||
|
||||
use tauri::{
|
||||
AppHandle, CustomMenuItem, Event, Manager, Runtime, SystemTray, SystemTrayEvent, SystemTrayMenu,
|
||||
AppHandle, CustomMenuItem, Manager, RunEvent, Runtime, SystemTray, SystemTrayEvent,
|
||||
SystemTrayMenu,
|
||||
};
|
||||
|
||||
fn show_window<R: Runtime>(handle: &AppHandle<R>) {
|
||||
@@ -37,6 +38,7 @@ fn main() {
|
||||
env_logger::Builder::new()
|
||||
.filter_level(log::LevelFilter::Debug)
|
||||
.init();
|
||||
info!("Starting slidershim");
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
@@ -44,7 +46,9 @@ fn main() {
|
||||
simple_logging::log_to_file(log_file_path.as_path(), log::LevelFilter::Debug).unwrap();
|
||||
}
|
||||
|
||||
info!("Loading config");
|
||||
let config = Arc::new(Mutex::new(Some(slider_io::Config::load())));
|
||||
info!("Loading manager");
|
||||
let manager = Arc::new(Mutex::new(slider_io::Manager::new()));
|
||||
{
|
||||
let config_handle = config.lock();
|
||||
@@ -54,6 +58,7 @@ fn main() {
|
||||
manager_handle.update_config(config_handle_ref.clone());
|
||||
}
|
||||
|
||||
info!("Running tauri");
|
||||
tauri::Builder::default()
|
||||
.system_tray(
|
||||
// System tray content
|
||||
@@ -109,13 +114,25 @@ fn main() {
|
||||
});
|
||||
|
||||
// Show brokenithm qr
|
||||
app.listen_global("openBrokenithmQr", |_| {
|
||||
let brokenithm_qr_path = slider_io::get_brokenithm_qr_path();
|
||||
let config_clone = Arc::clone(&config);
|
||||
app.listen_global("openBrokenithmQr", move |_| {
|
||||
let config_handle = config_clone.lock();
|
||||
let brokenithm_qr_path = slider_io::get_brokenithm_qr_path(
|
||||
config_handle
|
||||
.as_ref()
|
||||
.map(|c| c.device_mode.get_port())
|
||||
.unwrap_or(None),
|
||||
);
|
||||
if let Some(brokenithm_qr_path) = brokenithm_qr_path {
|
||||
open::that(brokenithm_qr_path.as_path()).ok();
|
||||
}
|
||||
});
|
||||
|
||||
// Show repo
|
||||
app.listen_global("openRepo", |_| {
|
||||
open::that("https://github.com/4yn/slidershim").ok();
|
||||
});
|
||||
|
||||
// UI ready event
|
||||
let app_handle = app.handle();
|
||||
let config_clone = Arc::clone(&config);
|
||||
@@ -180,8 +197,8 @@ fn main() {
|
||||
.expect("error while running tauri application")
|
||||
.run(|app_handle, event| match event {
|
||||
// After app starts
|
||||
Event::CloseRequested { label, api, .. } if label.as_str() == "main" => {
|
||||
api.prevent_close();
|
||||
RunEvent::ExitRequested { api, .. } => {
|
||||
api.prevent_exit();
|
||||
hide_window(app_handle);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"package": {
|
||||
"productName": "slidershim",
|
||||
"version": "0.2.0"
|
||||
"version": "0.6.0"
|
||||
},
|
||||
"build": {
|
||||
"distDir": "../public",
|
||||
@@ -30,13 +30,11 @@
|
||||
"shortDescription": "slidershim",
|
||||
"longDescription": "slidershim",
|
||||
"deb": {
|
||||
"depends": [],
|
||||
"useBootstrapper": false
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "",
|
||||
"useBootstrapper": false,
|
||||
"exceptionDomain": "",
|
||||
"signingIdentity": null,
|
||||
"entitlements": null
|
||||
@@ -51,13 +49,19 @@
|
||||
"active": false
|
||||
},
|
||||
"allowlist": {
|
||||
"all": false
|
||||
"all": false,
|
||||
"window": {
|
||||
"startDragging": true
|
||||
},
|
||||
"shell": {
|
||||
"open": true
|
||||
}
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "slidershim",
|
||||
"width": 500,
|
||||
"height": 550,
|
||||
"height": 600,
|
||||
"resizable": false,
|
||||
"fullscreen": false,
|
||||
"decorations": false,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Derived from https://github.com/wjwwood/serial
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2012 William Woodall, John Harrison
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -10,13 +10,22 @@
|
||||
let outputMode = "none";
|
||||
let ledMode = "none";
|
||||
|
||||
let disableAirStrings = false;
|
||||
let divaSerialPort = "COM1";
|
||||
let divaBrightness = 63;
|
||||
let brokenithmPort = 1606;
|
||||
let keyboardSensitivity = 20;
|
||||
let keyboardDirectInput = false;
|
||||
let outputPolling = "100";
|
||||
let outputWebsocketUrl = "http://localhost:3000";
|
||||
let ledFaster = false;
|
||||
let ledColorActive = "#ff00ff";
|
||||
let ledColorInactive = "#ffff00";
|
||||
let ledColorAirActive = "#0086ed";
|
||||
let ledColorAirInactive = "#000000";
|
||||
let ledSensitivity = 20;
|
||||
let ledWebsocketUrl = "http://localhost:3001";
|
||||
let ledUmgrWebsocketPort = 7124;
|
||||
let ledSerialPort = "COM5";
|
||||
|
||||
let dirty = false;
|
||||
@@ -58,14 +67,23 @@
|
||||
outputMode = payload.outputMode || "none";
|
||||
ledMode = payload.ledMode || "none";
|
||||
|
||||
disableAirStrings = payload.disableAirStrings || false;
|
||||
divaSerialPort = payload.divaSerialPort || "COM1";
|
||||
divaBrightness = payload.divaBrightness || 63;
|
||||
brokenithmPort = payload.brokenithmPort || 1606;
|
||||
keyboardSensitivity = payload.keyboardSensitivity || 20;
|
||||
keyboardDirectInput = payload.keyboardDirectInput || false;
|
||||
outputPolling = payload.outputPolling || "100";
|
||||
outputWebsocketUrl =
|
||||
payload.outputWebsocketUrl || "http://localhost:3000/";
|
||||
ledFaster = payload.ledFaster || false;
|
||||
ledColorActive = payload.ledColorActive || "#ff00ff";
|
||||
ledColorInactive = payload.ledColorInactive || "#ffff00";
|
||||
ledColorAirActive = payload.ledColorAirActive || "#0086ed";
|
||||
ledColorAirInactive = payload.ledColorAirInactive || "#000000";
|
||||
ledSensitivity = payload.ledSensitivity || 20;
|
||||
ledWebsocketUrl = payload.ledWebsocketUrl || "http://localhost:3001";
|
||||
ledUmgrWebsocketPort = payload.ledUmgrWebsocketPort || 7124;
|
||||
ledSerialPort = payload.ledSerialPort || "COM5";
|
||||
});
|
||||
|
||||
@@ -101,19 +119,29 @@
|
||||
|
||||
async function setConfig() {
|
||||
console.log("Updating config");
|
||||
console.log(disableAirStrings);
|
||||
await emit(
|
||||
"setConfig",
|
||||
JSON.stringify({
|
||||
deviceMode,
|
||||
outputMode,
|
||||
ledMode,
|
||||
disableAirStrings,
|
||||
divaSerialPort,
|
||||
divaBrightness,
|
||||
brokenithmPort,
|
||||
keyboardSensitivity,
|
||||
keyboardDirectInput,
|
||||
outputPolling,
|
||||
outputWebsocketUrl,
|
||||
ledFaster,
|
||||
ledColorActive,
|
||||
ledColorInactive,
|
||||
ledColorAirActive,
|
||||
ledColorAirInactive,
|
||||
ledSensitivity,
|
||||
ledWebsocketUrl,
|
||||
ledUmgrWebsocketPort,
|
||||
ledSerialPort,
|
||||
})
|
||||
);
|
||||
@@ -136,6 +164,10 @@
|
||||
async function brokenithmQr() {
|
||||
await emit("openBrokenithmQr");
|
||||
}
|
||||
|
||||
async function repo() {
|
||||
await emit("openRepo");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="titlebar">
|
||||
@@ -152,259 +184,436 @@
|
||||
</div>
|
||||
<div data-tauri-drag-region class="titlebar titlebar-front" />
|
||||
<main class="main">
|
||||
<div class="row">
|
||||
<div class="preview-row">
|
||||
<Preview data={previewData} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Input Device</div>
|
||||
<div class="input">
|
||||
<select bind:value={deviceMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="tasoller-one">GAMO2 Tasoller, 1.0 HID Firmware</option>
|
||||
<option value="tasoller-two">GAMO2 Tasoller, 2.0 HID Firmware</option>
|
||||
<option value="yuancon">Yuancon Laverita, HID Firmware</option>
|
||||
<option value="diva">Diva Slider over Serial</option>
|
||||
<option value="brokenithm">Brokenithm</option>
|
||||
<option value="brokenithm-led">Brokenithm + Led</option>
|
||||
<option value="brokenithm-ground">Brokenithm, Ground only</option>
|
||||
<option value="brokenithm-ground-led"
|
||||
>Brokenithm + Led, Ground only</option
|
||||
>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{#if deviceMode.slice(0, 10) === "brokenithm"}
|
||||
<div class="options">
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="label">Input Device</div>
|
||||
<div class="input">
|
||||
<div class="serverlist">
|
||||
Brokenithm server running, access at one of:
|
||||
<pre>
|
||||
{ips.map((x) => `http://${x}:1606/`).join("\n")}
|
||||
</pre>
|
||||
<select bind:value={deviceMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="tasoller-one">GAMO2 Tasoller, 1.0 HID Firmware</option>
|
||||
<option value="tasoller-two">GAMO2 Tasoller, 2.0 HID Firmware</option>
|
||||
<option value="yuancon">Yuancon Laverita, HID Firmware</option>
|
||||
<option value="yuancon-three">Yuancon Laverita v3, HID Firmware</option>
|
||||
<option value="yubideck">大四 / Yubideck, HID Firmware 1.0</option>
|
||||
<option value="yubideck-three">大四 / Yubideck, HID Firmware 3.0</option>
|
||||
<option value="diva">Slider over Serial</option>
|
||||
<option value="brokenithm">Brokenithm</option>
|
||||
<option value="brokenithm-led">Brokenithm + Led</option>
|
||||
<option value="brokenithm-nostalgia">Brokestalgia (28k)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{#if deviceMode.slice(0, 8) === "tasoller" || deviceMode.slice(0, 7) === "yuancon" || deviceMode.slice(0, 8) === "yubideck" || (deviceMode.slice(0, 10) === "brokenithm" && deviceMode !== "brokenithm-nostalgia")}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<span>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="disable-air"
|
||||
style="width: unset;"
|
||||
bind:checked={disableAirStrings}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="disable-air">Disable Air Strings</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if deviceMode === "diva"}
|
||||
<div class="row">
|
||||
<div class="label">Diva Serial Port</div>
|
||||
<div class="input">
|
||||
<select bind:value={divaSerialPort} on:change={markDirty}>
|
||||
<option value="COM1">COM1</option>
|
||||
<option value="COM2">COM2</option>
|
||||
<option value="COM3">COM3</option>
|
||||
<option value="COM4">COM4</option>
|
||||
<option value="COM5">COM5</option>
|
||||
<option value="COM6">COM6</option>
|
||||
<option value="COM7">COM7</option>
|
||||
<option value="COM8">COM8</option>
|
||||
<option value="COM9">COM9</option>
|
||||
</select>
|
||||
{/if}
|
||||
{#if deviceMode.slice(0, 10) === "brokenithm"}
|
||||
<div class="row">
|
||||
<div class="label">Brokenithm Port</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1024"
|
||||
max="65535"
|
||||
step="1"
|
||||
bind:value={brokenithmPort}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Brightness</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={divaBrightness}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<div class="serverlist">
|
||||
Brokenithm will be running at one of:
|
||||
<div class="iplist">
|
||||
{ips
|
||||
.map((x) => `http://${x}:${brokenithmPort || 1606}/`)
|
||||
.join("\n")
|
||||
.trim()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={divaBrightness}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
{/if}
|
||||
{#if deviceMode === "diva"}
|
||||
<div class="row">
|
||||
<div class="label">Slider Serial Port</div>
|
||||
<div class="input">
|
||||
<select bind:value={divaSerialPort} on:change={markDirty}>
|
||||
<option value="COM1">COM1</option>
|
||||
<option value="COM2">COM2</option>
|
||||
<option value="COM3">COM3</option>
|
||||
<option value="COM4">COM4</option>
|
||||
<option value="COM5">COM5</option>
|
||||
<option value="COM6">COM6</option>
|
||||
<option value="COM7">COM7</option>
|
||||
<option value="COM8">COM8</option>
|
||||
<option value="COM9">COM9</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="row">
|
||||
<div class="label">Brightness</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={divaBrightness}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={divaBrightness}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="label">Output Mode</div>
|
||||
<div class="input">
|
||||
<select bind:value={outputMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="kb-32-tasoller">Keyboard 32-zone, Tasoller Layout</option
|
||||
>
|
||||
<option value="kb-32-yuancon">Keyboard 32-zone, Yuancon Layout</option>
|
||||
<option value="kb-16-tasoller"
|
||||
>Keyboard 16-zone, Tasoller (Bottom Half) Layout</option
|
||||
>
|
||||
<option value="kb-8-deemo">Keyboard 8-zone, Deemo Layout</option>
|
||||
<option value="kb-voltex">Keyboard 10-zone, Voltex Layout</option>
|
||||
<option value="kb-neardayo">Keyboard 10-zone, Neardayo Layout</option>
|
||||
<option value="gamepad-voltex">XBOX 360 Gamepad, Voltex Layout</option>
|
||||
<option value="gamepad-neardayo"
|
||||
>XBOX 360 Gamepad, Neardayo Layout</option
|
||||
>
|
||||
<!-- <option value="websocket">Websocket</option> -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{#if outputMode !== "none"}
|
||||
<div class="row">
|
||||
<div class="label">Output Polling</div>
|
||||
<div class="label">Output Mode</div>
|
||||
<div class="input">
|
||||
<select bind:value={outputPolling} on:change={markDirty}>
|
||||
<option value="60">60 Hz</option>
|
||||
<option value="100">100 Hz</option>
|
||||
<option value="250">250 Hz</option>
|
||||
<option value="500">500 Hz</option>
|
||||
<option value="1000">1000 Hz</option>
|
||||
<select bind:value={outputMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="kb-32-tasoller"
|
||||
>Keyboard 32-zone, Tasoller Layout</option
|
||||
>
|
||||
<option value="kb-32-yuancon">Keyboard 32-zone, Yuancon Layout</option
|
||||
>
|
||||
<option value="kb-32-umiguri">Keyboard 32-zone, UMIGURI Layout</option
|
||||
>
|
||||
<option value="kb-16">Keyboard 16-zone, Linear</option>
|
||||
<option value="kb-8">Keyboard 8-zone, Linear</option>
|
||||
<option value="kb-6">Keyboard 6-zone, Linear</option>
|
||||
<option value="kb-4">Keyboard 4-zone, Linear</option>
|
||||
<option value="kb-voltex">Keyboard 10-zone, Voltex Layout</option>
|
||||
<option value="kb-neardayo">Keyboard 10-zone, Neardayo Layout</option>
|
||||
<option value="gamepad-voltex">XBOX 360 Gamepad, Voltex Layout</option
|
||||
>
|
||||
<option value="gamepad-neardayo"
|
||||
>XBOX 360 Gamepad, Neardayo Layout</option
|
||||
>
|
||||
<option value="gamepad-hori">DS4, HORI DIVA FT ASC Layout</option>
|
||||
<option value="gamepad-hori-wide"
|
||||
>DS4, HORI DIVA FT ASC Slider Only Layout</option
|
||||
>
|
||||
<!-- <option value="websocket">Websocket</option> -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if outputMode.slice(0, 7) === "gamepad"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
Gamepad emulation requires <Link
|
||||
href="https://github.com/ViGEm/ViGEmBus/releases">ViGEMBus</Link
|
||||
>
|
||||
{#if deviceMode === "brokenithm-nostalgia" && outputMode !== "none" && outputMode.slice(0, 5) !== "kb-32"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input comment">
|
||||
32 key layout is recommended for Brokestalgia controllers
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if outputMode.slice(0, 2) === "kb" && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||
<div class="row">
|
||||
<div class="label" title="Larger means harder to trigger">
|
||||
Sensitivity
|
||||
{:else if deviceMode.slice(0, 10) === "brokenithm" && ["kb-voltex", "kb-neardayo", "gamepad-voltex", "gamepad-neardayo", "gamepad-hori"].includes(outputMode)}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input comment">
|
||||
Gamepad layouts are not recommended for Brokenithm controllers
|
||||
</div>
|
||||
</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={keyboardSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
{/if}
|
||||
{#if outputMode.slice(0, 7) === "gamepad"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input comment">
|
||||
Gamepad emulation requires <Link
|
||||
href="https://github.com/ViGEm/ViGEmBus/releases">ViGEMBus</Link
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={keyboardSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
{/if}
|
||||
{#if outputMode !== "none"}
|
||||
<div class="row">
|
||||
<div class="label">Output Polling</div>
|
||||
<div class="input">
|
||||
<select bind:value={outputPolling} on:change={markDirty}>
|
||||
<option value="60">60 Hz</option>
|
||||
<option value="100">100 Hz</option>
|
||||
<option value="250">250 Hz</option>
|
||||
<option value="500">500 Hz</option>
|
||||
<option value="1000">1000 Hz</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if outputMode === "websocket"}
|
||||
<div class="row">
|
||||
<div class="label">Output URL</div>
|
||||
<div class="input">
|
||||
<input
|
||||
placeholder="URL"
|
||||
bind:value={outputWebsocketUrl}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
{/if}
|
||||
{#if (outputMode.slice(0, 2) === "kb" || outputMode.slice(0, 7) === "gamepad") && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||
<div class="row">
|
||||
<div class="label" title="Larger means harder to trigger">
|
||||
Sensitivity
|
||||
</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={keyboardSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={keyboardSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if outputMode.slice(0, 2) === "kb"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<span>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="direct-input"
|
||||
style="width: unset;"
|
||||
bind:checked={keyboardDirectInput}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="direct-input">Use DirectInput</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{#if keyboardDirectInput}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input comment">
|
||||
DirectInput emulation requires <Link
|
||||
href="https://github.com/oblitum/Interception/releases/tag/v1.0.1"
|
||||
>Interception</Link
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if outputMode === "websocket"}
|
||||
<div class="row">
|
||||
<div class="label">Output URL</div>
|
||||
<div class="input">
|
||||
<input
|
||||
placeholder="URL"
|
||||
bind:value={outputWebsocketUrl}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="label">LED Mode</div>
|
||||
<div class="input">
|
||||
<select bind:value={ledMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="reactive-4">Reactive, 4-Zone</option>
|
||||
<option value="reactive-8">Reactive, 8-Zone</option>
|
||||
<option value="reactive-16">Reactive, 16-Zone</option>
|
||||
<option value="reactive-voltex">Reactive, Voltex Layout</option>
|
||||
<option value="attract">Rainbow Attract Mode</option>
|
||||
<!-- <option value="websocket">Websocket</option> -->
|
||||
<option value="serial">Serial</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{#if ledMode.slice(0, 8) === "reactive" && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||
<div class="row">
|
||||
<div class="label" title="Larger means harder to trigger">
|
||||
Sensitivity
|
||||
</div>
|
||||
<div class="label">LED Mode</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={ledSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={ledSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode === "websocket"}
|
||||
<div class="row">
|
||||
<div class="label">LED URL</div>
|
||||
<div class="input">
|
||||
<input
|
||||
placeholder="URL"
|
||||
bind:value={ledWebsocketUrl}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode === "serial"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
Serial LED may require <Link
|
||||
href="https://sourceforge.net/projects/com0com/files/com0com/2.2.2.0/com0com-2.2.2.0-x64-fre-signed.zip/download"
|
||||
>com0com</Link
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">LED Serial Port</div>
|
||||
<div class="input">
|
||||
<select bind:value={ledSerialPort} on:change={markDirty}>
|
||||
<option value="COM1">COM1</option>
|
||||
<option value="COM2">COM2</option>
|
||||
<option value="COM3">COM3</option>
|
||||
<option value="COM4">COM4</option>
|
||||
<option value="COM5">COM5</option>
|
||||
<option value="COM6">COM6</option>
|
||||
<option value="COM7">COM7</option>
|
||||
<option value="COM8">COM8</option>
|
||||
<option value="COM9">COM9</option>
|
||||
<select bind:value={ledMode} on:change={markDirty}>
|
||||
<option value="none">None</option>
|
||||
<option value="reactive-16">Reactive, 16-Zone</option>
|
||||
<option value="reactive-8">Reactive, 8-Zone</option>
|
||||
<option value="reactive-6">Reactive, 6-Zone</option>
|
||||
<option value="reactive-4">Reactive, 4-Zone</option>
|
||||
<option value="reactive-rainbow">Reactive, 16-Zone Rainbow</option>
|
||||
<option value="reactive-voltex">Reactive, Voltex Layout</option>
|
||||
<option value="reactive-hori"
|
||||
>Reactive, DIVA Future Tone Layout</option
|
||||
>
|
||||
<option value="attract">Rainbow Attract Mode</option>
|
||||
<!-- <option value="websocket">Websocket</option> -->
|
||||
<option value="umgr-websocket">UMIGURI Websocket</option>
|
||||
<option value="serial">Serial</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="row">
|
||||
{#if ledMode !== "none"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<span>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="led-faster"
|
||||
style="width: unset;"
|
||||
bind:checked={ledFaster}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="led-faster">Update LED data faster</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode.slice(0, 8) === "reactive" && ["16", "8", "6", "4"].includes(ledMode.slice(9))}
|
||||
<div class="row">
|
||||
<div class="label">Slider Color</div>
|
||||
<div class="input">
|
||||
<span>
|
||||
<input
|
||||
type="color"
|
||||
id="color-active"
|
||||
style="width: 3rem;"
|
||||
bind:value={ledColorActive}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="color-active">Active</label>
|
||||
</span>
|
||||
<span>
|
||||
<input
|
||||
type="color"
|
||||
id="color-base"
|
||||
style="width: 3rem;"
|
||||
bind:value={ledColorInactive}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="color-base">Inactive</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Air Color</div>
|
||||
<div class="input">
|
||||
<span>
|
||||
<input
|
||||
type="color"
|
||||
id="color-active"
|
||||
style="width: 3rem;"
|
||||
bind:value={ledColorAirActive}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="color-active">Active</label>
|
||||
</span>
|
||||
<span>
|
||||
<input
|
||||
type="color"
|
||||
id="color-base"
|
||||
style="width: 3rem;"
|
||||
bind:value={ledColorAirInactive}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
<label for="color-base">Inactive</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode.slice(0, 8) === "reactive" && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||
<div class="row">
|
||||
<div class="label" title="Larger means harder to trigger">
|
||||
Sensitivity
|
||||
</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={ledSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input">
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max="255"
|
||||
step="1"
|
||||
bind:value={ledSensitivity}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode === "websocket"}
|
||||
<div class="row">
|
||||
<div class="label">LED URL</div>
|
||||
<div class="input">
|
||||
<input
|
||||
placeholder="URL"
|
||||
bind:value={ledWebsocketUrl}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode === "umgr-websocket"}
|
||||
<div class="row">
|
||||
<div class="label">UMIGURI Port</div>
|
||||
<div class="input">
|
||||
<input
|
||||
type="number"
|
||||
min="1024"
|
||||
max="65535"
|
||||
step="1"
|
||||
bind:value={ledUmgrWebsocketPort}
|
||||
on:change={markDirty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ledMode === "serial"}
|
||||
<div class="row">
|
||||
<div class="label" />
|
||||
<div class="input comment">
|
||||
Serial LED may require <Link
|
||||
href="https://sourceforge.net/projects/com0com/files/com0com/2.2.2.0/com0com-2.2.2.0-x64-fre-signed.zip/download"
|
||||
>com0com</Link
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">LED Serial Port</div>
|
||||
<div class="input">
|
||||
<select bind:value={ledSerialPort} on:change={markDirty}>
|
||||
<option value="COM1">COM1</option>
|
||||
<option value="COM2">COM2</option>
|
||||
<option value="COM3">COM3</option>
|
||||
<option value="COM4">COM4</option>
|
||||
<option value="COM5">COM5</option>
|
||||
<option value="COM6">COM6</option>
|
||||
<option value="COM7">COM7</option>
|
||||
<option value="COM8">COM8</option>
|
||||
<option value="COM9">COM9</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="buttons-row">
|
||||
<button
|
||||
on:click={async () => await setConfig()}
|
||||
class={`${dirty && "primary"}`}>Apply</button
|
||||
@@ -415,6 +624,7 @@
|
||||
{#if deviceMode.slice(0, 10) === "brokenithm"}
|
||||
<button on:click={async () => await brokenithmQr()}>Brokenithm QR</button>
|
||||
{/if}
|
||||
<button on:click={async () => await repo()}>About</button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
let ledDatas = Array(16).fill("#ff0");
|
||||
let ledDividerDatas = Array(15).fill("#ff0");
|
||||
let airLedLeftDatas = Array(3).fill(0);
|
||||
let airLedRightDatas = Array(3).fill(0);
|
||||
|
||||
$: {
|
||||
if (data.length === 134) {
|
||||
if (data.length === 152) {
|
||||
// console.log(data);
|
||||
for (let i = 0; i < 16; i++) {
|
||||
topDatas[i] = data[i * 2 + 1];
|
||||
@@ -33,15 +35,42 @@
|
||||
ledDividerDatas[(i - 1) / 2] = rgbstr;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let rgbstr = `rgb(${data[134 + i * 3]}, ${data[135 + i * 3]}, ${
|
||||
data[136 + i * 3]
|
||||
})`;
|
||||
airLedLeftDatas[i] = rgbstr;
|
||||
}
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let rgbstr = `rgb(${data[143 + i * 3]}, ${data[144 + i * 3]}, ${
|
||||
data[145 + i * 3]
|
||||
})`;
|
||||
airLedRightDatas[i] = rgbstr;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<main class="preview">
|
||||
<div class="air">
|
||||
{#each airDatas as airData, idx (idx)}
|
||||
<div class={`air-data air-data-${airData}`} />
|
||||
{/each}
|
||||
<div class="air-led">
|
||||
<div class="air-led-left">
|
||||
{#each airLedLeftDatas as airLedData, idx (idx)}
|
||||
<div class="air-led-data" style={`background-color: ${airLedData}`} />
|
||||
{/each}
|
||||
</div>
|
||||
<div class="air-led-space" />
|
||||
<div class="air-led-right">
|
||||
{#each airLedRightDatas as airLedData, idx (idx)}
|
||||
<div class="air-led-data" style={`background-color: ${airLedData}`} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="air-btn">
|
||||
{#each airDatas as airData, idx (idx)}
|
||||
<div class={`air-data air-data-${airData}`} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ground">
|
||||
<div class="ground-led">
|
||||
|
||||