Compare commits

...

30 Commits
v0.2.8 ... main

Author SHA1 Message Date
4yn 4f0db8e66e bump version 2025-03-22 21:43:16 +08:00
4yn 7cc6e46afe Merge branch 'sr1canskhsia-main' 2025-03-22 15:01:14 +08:00
sr1canskhsia 7b63ff3a1a Add Laverita v3 support 2025-03-22 00:27:46 -04:00
4yn 6124dee2db bump version number 2023-10-05 21:05:11 +08:00
4yn cbbfcdc99e Merge branch 'main' of github.com:4yn/slidershim 2023-10-05 20:27:31 +08:00
si yuan b77f5f105f
Merge pull request #13 from kokarare1212/main
WebSocket SSL Support
2023-10-05 20:26:07 +08:00
4yn 743424dc01 bump proc-macro2 dependency to work with latest nightly 2023-10-05 20:09:17 +08:00
碧舞すみほ 1b131d7ea7
Update src.js 2023-10-05 20:31:15 +09:00
碧舞すみほ df9ee3b57f
Update app.js 2023-10-05 20:30:47 +09:00
4yn 3bd7ee8586 yubideck v3 firmware support 2022-11-18 01:42:05 +08:00
4yn 828f480424 bump version and add readme 2022-08-08 23:00:53 +08:00
4yn e285bdb999 fix hid regression on yubideck 2022-08-08 22:58:24 +08:00
4yn 0b75d1c62e update readme and bump version 2022-07-29 19:49:04 +08:00
4yn b02e14ecdf fix hori slider output order 2022-07-29 19:46:34 +08:00
4yn f135c31904 bump version and update readme 2022-07-28 02:16:06 +08:00
4yn 396e77ac38 add tolerance to yuancon usb report 2022-07-28 02:12:28 +08:00
4yn 17cd942148 fix misplaced checkbox label 2022-07-28 02:11:58 +08:00
4yn 1a44443c41 add video tutorial link 2022-07-24 23:59:01 +08:00
4yn 89e8545d80 bump version number 2022-07-24 23:54:20 +08:00
4yn f4d12e0b7a fix some warning and adjust yubideck lights 2022-07-24 23:32:34 +08:00
4yn 9bb2f9da74 tasoller and dasi side leds 2022-07-24 23:24:36 +08:00
4yn 121aeadbd8 air leds 2022-07-24 23:11:29 +08:00
4yn e0046ede81 update ui 2022-07-24 21:13:00 +08:00
4yn 571eec24d3 use statically linked interception library for directinput emulation 2022-07-24 21:12:40 +08:00
4yn 0e75256520 bump tauri version 2022-07-24 13:15:35 +08:00
4yn 882d7d0b5b fix wrong key in umiguri layout 2022-06-26 15:12:13 +08:00
4yn 486120d9c0 update readme 2022-06-26 01:16:09 +08:00
4yn d81664ba7c bump version and readme 2022-06-26 01:15:58 +08:00
4yn 3e36cc551f add umiguri keyboard layout 2022-06-26 01:04:24 +08:00
4yn 7e387ea541 UMIGURI LED is here! 2022-06-26 00:56:18 +08:00
56 changed files with 4260 additions and 1474 deletions

View File

@ -4,7 +4,7 @@
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) | [Demo Video (Brokestalgia)](https://youtu.be/1PEtBP3cOew)
[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,6 +12,32 @@ 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
@ -44,6 +70,8 @@ Software adapter for various Chunithm slider controllers with a built-in Brokeni
- v0.1.4
- Initial public release
</details>
## Setup Instructions
1. [Download here](https://github.com/4yn/slidershim/releases/latest)
@ -157,7 +185,7 @@ Voltex layout disables air tower, Neardayo layout enables air tower.
## 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
@ -177,13 +205,14 @@ Voltex layout disables air tower, Neardayo layout enables air tower.
- [`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

View File

@ -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"
}

View File

@ -183,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;

View File

@ -1,468 +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: 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 {
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: 1rem;
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-6 {
grid: repeat(1, 1fr) / 3fr 2fr 3fr 3fr 2fr 3fr;
}
font-size: 1.5rem;
font-family: monospace;
}
.ground.ground-4 {
grid: repeat(1, 1fr) / repeat(4, 1fr);
}
.ground div {
display: flex;
align-items: center;
justify-content: center;
.ground.ground-1 {
grid: repeat(1, 1fr) / repeat(1, 1fr);
}
background-color: #ff04;
}
.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";
}
.ground.ground-32 {
grid: repeat(2, 1fr) / repeat(16, 1fr);
}
.ground.ground-diva {
grid: repeat(2, 1fr) / repeat(4, 1fr);
grid-template-areas:
"sl sl sl sl"
"a b c d";
}
.ground.ground-16 {
grid: repeat(1, 1fr) / repeat(16, 1fr);
}
.air {
grid-area: a;
.ground.ground-8 {
grid: repeat(1, 1fr) / repeat(8, 1fr);
}
display: grid;
width: 100%;
height: 100%;
.ground.ground-6 {
grid: repeat(1, 1fr) / 3fr 2fr 3fr 3fr 2fr 3fr;
}
grid: repeat(6, 1fr) / repeat(1, 1fr);
gap: 0.25rem;
.ground.ground-4 {
grid: repeat(1, 1fr) / repeat(4, 1fr);
}
font-family: monospace;
}
.ground.ground-1 {
grid: repeat(1, 1fr) / repeat(1, 1fr);
}
.air div {
display: flex;
align-items: center;
justify-content: center;
.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";
}
background-color: #0ff4;
}
.ground.ground-diva {
grid: repeat(2, 1fr) / repeat(4, 1fr);
grid-template-areas:
"sl sl sl sl"
"a b c d";
}
.air.air-single {
grid: repeat(1, 1fr) / repeat(1, 1fr);
}
.air {
grid-area: a;
.air.air-voltex {
grid-template-areas:
"rr"
"rl"
"rl"
"lr"
"lr"
"ll";
}
display: grid;
width: 100%;
height: 100%;
.extra {
grid-area: e;
grid: repeat(6, 1fr) / repeat(1, 1fr);
gap: 0.25rem;
display: grid;
width: 100%;
height: 100%;
font-family: monospace;
}
grid: repeat(1, 1fr) / repeat(3, 1fr);
gap: 0.25rem;
.air div {
display: flex;
align-items: center;
justify-content: center;
font-family: monospace;
}
background-color: #0ff4;
}
.extra div {
display: flex;
align-items: center;
justify-content: center;
.air.air-single {
grid: repeat(1, 1fr) / repeat(1, 1fr);
}
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>
.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, 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="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 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>
<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 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 />&lt;&lt;</div>
<div style="grid-area: lr">LS<br />&gt;&gt;</div>
<div style="grid-area: rl">RS<br />&lt;&lt;</div>
<div style="grid-area: rr">RS<br />&gt;&gt;</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&gt;</div>
<div style="grid-area: rl">RS&lt;</div>
<div style="grid-area: lr">LS&gt;</div>
<div style="grid-area: ll">LS&lt;</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">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="extra">
<div>[disabled]</div>
<div>[disabled]</div>
<div>[disabled]</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>
<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 class="extra">
<div>[options]</div>
<div>[disabled]</div>
<div>[disabled]</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 />&lt;&lt;</div>
<div style="grid-area: lr">LS<br />&gt;&gt;</div>
<div style="grid-area: rl">RS<br />&lt;&lt;</div>
<div style="grid-area: rr">RS<br />&gt;&gt;</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&gt;</div>
<div style="grid-area: rl">RS&lt;</div>
<div style="grid-area: lr">LS&gt;</div>
<div style="grid-area: ll">LS&lt;</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="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>
<div class="extra">
<div>[options]</div>
<div>[disabled]</div>
<div>[disabled]</div>
</div>
</div>
</body>
</html>
</div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 24 KiB

1
src-interception/.gitignore vendored 100644
View File

@ -0,0 +1 @@
target/

140
src-interception/Cargo.lock generated 100644
View File

@ -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"

View File

@ -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"] }

View File

@ -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.
```

View File

@ -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");
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 }
}

View File

@ -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 */
}

View File

@ -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",

View File

@ -31,6 +31,7 @@ serialport = "4.0.1"
wwserial = {path = "../src-wwserial" }
vigem-client = { version = "0.1.2", features = ["unstable"] }
winapi = "0.3.9"
interception = {path = "../src-interception" }
ipconfig = "0.3.0"
# webserver

View File

@ -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();
}

View File

@ -37,11 +37,14 @@ impl Config {
"divaBrightness": 63,
"brokenithmPort": 1606,
"keyboardSensitivity": 20,
"keyboardDirectInput": false,
"outputPolling": "100",
"outputWebsocketUrl": "localhost:3000",
"ledFaster": false,
"ledColorActive": "#ff00ff",
"ledColorInactive": "#ffff00",
"ledColorAirActive": "#0086ed",
"ledColorAirInactive": "#000000",
"ledSensitivity": 20,
"ledWebsocketUrl": "localhost:3001",
"ledSerialPort": "COM5"

View File

@ -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>)>,
}
@ -90,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,
)
}
};
@ -111,6 +122,7 @@ impl Context {
device_async_haltable_worker,
output_worker,
lights_worker,
lights_haltable_worker,
timers,
}
}

File diff suppressed because one or more lines are too long

View File

@ -223,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?");

View File

@ -5,7 +5,9 @@ pub enum HardwareSpec {
TasollerOne,
TasollerTwo,
Yuancon,
YuanconThree,
Yubideck,
YubideckThree,
}
#[derive(Debug, Clone)]
@ -49,10 +51,18 @@ impl DeviceMode {
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()?,

View File

@ -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,
@ -41,6 +41,7 @@ pub struct HidJob {
led_write_type: WriteType,
led_callback: HidLedCallback,
led_buf: Buffer,
led_buf_two: Buffer,
handle: Option<DeviceHandle<GlobalContext>>,
}
@ -70,6 +71,7 @@ impl HidJob {
led_write_type: led_type,
led_callback,
led_buf: Buffer::new(),
led_buf_two: Buffer::new(),
handle: None,
}
}
@ -102,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;
@ -139,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;
@ -153,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(
@ -164,7 +179,7 @@ impl HidJob {
0x02,
*disable_air,
|buf, input| {
if buf.len != 34 {
if buf.len != 34 && buf.len != 35 {
return;
}
@ -177,7 +192,7 @@ impl HidJob {
}
},
WriteType::Interrupt,
|buf, lights| {
|buf, _, lights| {
buf.len = 31 * 2;
for (buf_chunk, state_chunk) in buf
.data
@ -190,6 +205,53 @@ 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,
@ -198,11 +260,12 @@ impl HidJob {
0x02, // Need to confirm
*disable_air,
|buf, input| {
if buf.len != 45 {
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;
}
@ -211,14 +274,19 @@ impl HidJob {
}
},
WriteType::Interrupt,
|buf, lights| {
|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([0, 0, 0])
.chain([
lights.air_left[3] >> 4,
lights.air_left[4] >> 4,
lights.air_left[5] >> 4,
])
.collect();
for (buf_chunk, state_chunk) in buf
@ -233,6 +301,56 @@ impl HidJob {
}
},
),
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]);
},
),
}
}
@ -252,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(())
}
@ -308,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;
}
}
@ -330,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

View File

@ -13,6 +13,8 @@ pub enum ReactiveLayout {
pub struct ColorScheme {
pub active: [u8; 3],
pub inactive: [u8; 3],
pub air_active: [u8; 3],
pub air_inactive: [u8; 3],
}
impl ColorScheme {
@ -28,6 +30,16 @@ impl ColorScheme {
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()?,
],
})
}
@ -35,6 +47,8 @@ impl ColorScheme {
Self {
active: [255, 0, 255],
inactive: [255, 255, 0],
air_active: [0, 134, 237],
air_inactive: [0, 0, 0],
}
}
@ -43,6 +57,8 @@ impl ColorScheme {
.or(Some(Self {
active: [255, 0, 255],
inactive: [255, 255, 0],
air_active: [0, 134, 237],
air_inactive: [0, 0, 0],
}))
.unwrap()
}
@ -64,6 +80,10 @@ pub enum LightsMode {
faster: bool,
url: String,
},
UmgrWebsocket {
faster: bool,
port: u16,
},
Serial {
faster: bool,
port: String,
@ -123,6 +143,10 @@ impl LightsMode {
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(),

View File

@ -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,
@ -15,6 +15,21 @@ use crate::{
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,
@ -75,6 +90,16 @@ impl LightsJob {
},
);
}
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]
@ -106,6 +131,16 @@ impl LightsJob {
)
}
}
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);
@ -207,23 +242,32 @@ impl LightsJob {
.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,
match idx % 2 {
0 => match banks[idx / 2] {
true => 0.2,
false => 1.0,
},
1 => 1.0,
_ => unreachable!(),
},
1.0,
))
.into_format::<u8>();
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]);
}
}
}
}
@ -233,11 +277,26 @@ impl LightsJob {
.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

View File

@ -1,3 +1,4 @@
pub mod config;
pub mod lighting;
pub mod umgr_websocket;

View File

@ -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);
}
}
}

View File

@ -13,6 +13,7 @@ pub enum PollingRate {
pub enum KeyboardLayout {
Tasoller,
Yuancon,
Umiguri,
TasollerHalf,
EightK,
SixK,
@ -40,6 +41,7 @@ pub enum OutputMode {
layout: KeyboardLayout,
polling: PollingRate,
sensitivity: u8,
direct_input: bool,
},
Gamepad {
layout: GamepadLayout,
@ -88,41 +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-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" => 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,

View File

@ -91,7 +91,7 @@ impl OutputHandler for HoriOutput {
.fold(0, |axis, (idx, state)| {
axis
| match state {
true => 0b11 << ((15 - idx) * 2),
true => 0b11 << ((idx ^ 3) * 2),
false => 0,
}
})

View File

@ -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 */,
@ -115,21 +127,29 @@ 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::EightK => &EIGHT_K_MAP,
KeyboardLayout::SixK => &SIX_K_MAP,
@ -138,20 +158,43 @@ impl KeyboardOutput {
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() },
@ -166,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,
}
}
@ -186,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;
}
}
_ => {}
}
@ -211,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]);
}
}
}
}
}
@ -227,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();

View File

@ -42,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

View File

@ -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

1796
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "slidershim"
version = "0.2.8"
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-rc.4", features = [] }
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-rc.4", features = ["system-tray", "window-start-dragging"] }
tauri = { version = "1.0.4", features = ["shell-open", "system-tray", "window-start-dragging"] }
open = "2.0.2"
slider_io = {path = "../src-slider_io" }

View File

@ -2,13 +2,34 @@
___| (_) __| | ___ _ __ ___| |__ (_)_ __ ___
/ __| | |/ _` |/ _ \ '__/ __| '_ \| | '_ ` _ \
\__ \ | | (_| | __/ | \__ \ | | | | | | | | |
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| v0.2.8
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -38,6 +38,7 @@ fn main() {
env_logger::Builder::new()
.filter_level(log::LevelFilter::Debug)
.init();
info!("Starting slidershim");
#[cfg(not(debug_assertions))]
{
@ -45,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();
@ -55,6 +58,7 @@ fn main() {
manager_handle.update_config(config_handle_ref.clone());
}
info!("Running tauri");
tauri::Builder::default()
.system_tray(
// System tray content
@ -193,8 +197,8 @@ fn main() {
.expect("error while running tauri application")
.run(|app_handle, event| match event {
// After app starts
RunEvent::CloseRequested { label, api, .. } if label.as_str() == "main" => {
api.prevent_close();
RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
hide_window(app_handle);
}
_ => {}

View File

@ -1,7 +1,7 @@
{
"package": {
"productName": "slidershim",
"version": "0.2.8"
"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
@ -54,6 +52,9 @@
"all": false,
"window": {
"startDragging": true
},
"shell": {
"open": true
}
},
"windows": [

View File

@ -15,13 +15,17 @@
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;
@ -68,14 +72,18 @@
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";
});
@ -123,13 +131,17 @@
divaBrightness,
brokenithmPort,
keyboardSensitivity,
keyboardDirectInput,
outputPolling,
outputWebsocketUrl,
ledFaster,
ledColorActive,
ledColorInactive,
ledColorAirActive,
ledColorAirInactive,
ledSensitivity,
ledWebsocketUrl,
ledUmgrWebsocketPort,
ledSerialPort,
})
);
@ -184,7 +196,9 @@
<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="yubideck">大四 / Yubideck, 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>
@ -293,6 +307,8 @@
>
<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>
@ -381,6 +397,34 @@
</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>
@ -410,6 +454,7 @@
>
<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>
@ -433,23 +478,53 @@
{/if}
{#if ledMode.slice(0, 8) === "reactive" && ["16", "8", "6", "4"].includes(ledMode.slice(9))}
<div class="row">
<div class="label">Active Color</div>
<div class="label">Slider Color</div>
<div class="input">
<input
type="color"
bind:value={ledColorActive}
on:change={markDirty}
/>
<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">Base Color</div>
<div class="label">Air Color</div>
<div class="input">
<input
type="color"
bind:value={ledColorInactive}
on:change={markDirty}
/>
<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}
@ -495,10 +570,25 @@
</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">
<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

View File

@ -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">

113
yarn.lock
View File

@ -99,72 +99,70 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"
"@tauri-apps/api@^1.0.0-beta.8":
version "1.0.0-rc.2"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.0-rc.2.tgz#bac494a6b8868e05f86184d2ee1ccc8477470363"
integrity sha512-JhUDCJpfxmf/S1R+yHmJGsher4CGi07Qv4fYeucB7naeFZ7yTQe7S1CHKUZaRYpurGSdwOF3my9k0LyGmpAGYw==
dependencies:
type-fest "2.12.0"
"@tauri-apps/api@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.2.tgz#5228720e35d50fd08df87067dc29e7306c1f7a10"
integrity sha512-yuNW0oeJ1/ZA7wNF1KgxhHrSu5viPVzY/UgUczzN5ptLM8dH15Juy5rEGkoHfeXGju90Y/l22hi3BtIrp/za+w==
"@tauri-apps/cli-darwin-arm64@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.7.tgz#c7d190ea7496381bf456494e93dd8b35005a0e78"
integrity sha512-fb1plxZZHDG0KwZOoAl6tuisFU+oZFtNtqK3V2KL+4hz75DyH6BfsrgjyYSecJrtQejL2cHi8q7vUsU+EeLopw==
"@tauri-apps/cli-darwin-arm64@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.4.tgz#fd63fad851c8c899233618af0a9dc2d1a29a8c41"
integrity sha512-hMVTPoinjKYV8fgviQ871ZnVipAVXJV3ZwfiK9FcE9/dkUCUtKtetfwnicRV6YDSFbWY9qAg+Sm0INrLT5Ky+A==
"@tauri-apps/cli-darwin-x64@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.7.tgz#b152f333ea081674e8e6c45d1c3ff1850bff854c"
integrity sha512-FOFPNsYUgCDaxEK+9oQ3vv9bMD3XVcOKdh1vo/DImzZNO6fQkcsDC8zlmA+Q4axd+X8kvu0iti1fK8Vl7HIUEA==
"@tauri-apps/cli-darwin-x64@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.4.tgz#52e7a4151a26e9333375a82a0cb15614f01cf3e0"
integrity sha512-6bR8WIqJdcutLLcmv4S+bkCRbLAwjl80zPL97vs7Zgum01aeygjUTaZS46fpeDgqF8nR8piFAZkz8Bnco6fbzw==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.7.tgz#14fb37a337526200dbbe9b49dabd221b81682b02"
integrity sha512-tFzcJtNHy5AInU3E7kKDyhg4Qb7csu3uZ3FhGfORmGvQAiNQFpGV3ypC230RQYa3sxxRMbn8vjUAZMlU6JArbA==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.4.tgz#8889ce864dba0763290fa3f05af99f8cd2f574bf"
integrity sha512-NNhz8Nh/CQvAPzR5bj1sC2CgpkUOjZg8Eg1i/Ta/pbrjgT0E/reD+12TGdkNuQNEOUQ1klWcdeHfAptWPicRgQ==
"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.7.tgz#43e7a38018258ad2bf665bb61e0328688b345355"
integrity sha512-QAoNUJMmoCv/mDZsfEZOOTeEPYuxtMgCgqTDqMd0H8S0Y3Cu2D/Q2fwVl0s9pMb6wLD2GJ2FEneySEMhMxt7Pg==
"@tauri-apps/cli-linux-arm64-gnu@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.4.tgz#27ae14f15d5fef76dcb70b4d7dac7bbb9e13ea81"
integrity sha512-chzpMgkZyu0MWF75DDiEV06XyI8LM7q0NMxRx7esJwZpypj4AG0Pj4+9Di38zYWZrfYqz/bWrCMPIV30vty1Gg==
"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.7.tgz#37ebcfc7d1431dd698f529fa57248adadd94b3b4"
integrity sha512-ieLyACtbY7ezReTnjWLw/kKDXRCbnbrUjQ+hltSmHaRuV51nX+I2rmFO5e7VPdj406jvyKwfSPuBC34bHxt3Og==
"@tauri-apps/cli-linux-arm64-musl@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.4.tgz#118a44226c3e0c324b9c842718548b22fcfbd3d2"
integrity sha512-w+wbNoIOdHoV65Q/z29EK4KtFiNXfV+2lIsML/Hw0VEJEzl9FsqGelu1zAycq8hkoQhf0yPlD/m4FfAWnFzg6Q==
"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.7.tgz#b47239c4f10b3fe8e1e2f031f639125ededc6d79"
integrity sha512-wPAZctuFpurACxdCrjw+aaSuFReuIvv1nalVezfqA78AlsCk785yF2YVjoZr5bT8a9+6F+t8uNi3l6Vp5oNqwQ==
"@tauri-apps/cli-linux-x64-gnu@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.4.tgz#1724345de55a597a7fbd363f3af33ebf4eaaad4d"
integrity sha512-TiVRk+VBYA2mE4DqwLu/WD6wTHewHVbdMUtfeXdwe/kabLqbJTWuswUv5T8JUp3mYFZKqlPhyi+qWSJOc0Ianw==
"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.7.tgz#9e62494cf80aed170f389d84b2b23f354e8ce748"
integrity sha512-/AxuXFC2d1V8KpZJ6cFDcD5QqPFIZFXC/tAJlnTW75VnHgjat9TYP3BdSOuEA81ZLs9tV4PQF40tNnUSzfRYMg==
"@tauri-apps/cli-linux-x64-musl@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.4.tgz#b36904c42be4bdab21cefdd052c8c85f9913f6be"
integrity sha512-TKdncZ6aFu9PfHakrrqg3XIoxgl510rN0tOTJuZ1WQT2nDD5zlP3Mo++FNIt6/TfjqayLcubIZp3dG9pU383dA==
"@tauri-apps/cli-win32-ia32-msvc@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.0-rc.7.tgz#71c2f9498f4d03fd2c0ca6137a2be7db95a006f3"
integrity sha512-C4M2rHXlYVPSHGl2Iax1rfiNM5GPSRP1JHxW7/4jH9FfW6mVFcjULZAyVMRfOMQEQ9bYXbVnSTPbhG2Fm0jPxQ==
"@tauri-apps/cli-win32-ia32-msvc@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.4.tgz#6db7d26050f15fca0ad067119001e566085990f5"
integrity sha512-KedA4LB/PsePE3BLm2gg/IIA4rLjbyBUzV2FTdpWqx8ws3OzL6BLDGRVJ+zXe/b9SddhhZk7Rqss6y+gtsWKsA==
"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.7.tgz#6d719f70a0789f2a179d160c302996ce81194099"
integrity sha512-lpstJKOtP+ahhjbutapA02TpvfNTZqXwhmA1fvqxDu6BYVezFn7ZiGG5HwdXlkiRDfbwZwBd1evdkV3MxwY1NQ==
"@tauri-apps/cli-win32-x64-msvc@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.4.tgz#bf14bb0cfa2c0e74a981c6424dc36f68dbfd4b5c"
integrity sha512-6m1Ie7+YeKdOY7aXZCw/Py30DeMEAukE2+WWuZgfxZTTG9QrnZO+DbaKtjuEG0A8HKHCz63+ZNxOTshS1ognEw==
"@tauri-apps/cli@^1.0.0-beta.10":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.7.tgz#0eb73718f6ebddc159b0b54f6fd6dfc26d110b36"
integrity sha512-g7lUsI2iFiB2JuPFr209vWNqOnxCOGXN6yBttMRY+94UUXZOeWlKxYYpSabyjSr7EbfAUNzjITYmE4urdtmB+A==
"@tauri-apps/cli@^1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.4.tgz#4a943d10ff022ae6ad9fb33e94cc5c25509bcfb9"
integrity sha512-AqfbQUFU2jDYmkjiowl+Yv1yNkey/e+N23sKyDtXQQNvxE6ieR4voY4i6bShY97F+DbRVdjWcjGiLkWS3i4DHw==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.7"
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.7"
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.7"
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.7"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.0-rc.7"
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.7"
"@tauri-apps/cli-darwin-arm64" "1.0.4"
"@tauri-apps/cli-darwin-x64" "1.0.4"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.4"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.4"
"@tauri-apps/cli-linux-arm64-musl" "1.0.4"
"@tauri-apps/cli-linux-x64-gnu" "1.0.4"
"@tauri-apps/cli-linux-x64-musl" "1.0.4"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.4"
"@tauri-apps/cli-win32-x64-msvc" "1.0.4"
"@tsconfig/svelte@^2.0.0":
version "2.0.1"
@ -1383,11 +1381,6 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"
type-fest@2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.12.0.tgz#ce342f58cab9114912f54b493d60ab39c3fc82b6"
integrity sha512-Qe5GRT+n/4GoqCNGGVp5Snapg1Omq3V7irBJB3EaKsp7HWDo5Gv2d/67gfNyV+d5EXD+x/RF5l1h4yJ7qNkcGA==
typescript@*, typescript@^4.0.0:
version "4.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"