Compare commits
25 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
4f0db8e66e | |
![]() |
7cc6e46afe | |
![]() |
7b63ff3a1a | |
![]() |
6124dee2db | |
![]() |
cbbfcdc99e | |
![]() |
b77f5f105f | |
![]() |
743424dc01 | |
![]() |
1b131d7ea7 | |
![]() |
df9ee3b57f | |
![]() |
3bd7ee8586 | |
![]() |
828f480424 | |
![]() |
e285bdb999 | |
![]() |
0b75d1c62e | |
![]() |
b02e14ecdf | |
![]() |
f135c31904 | |
![]() |
396e77ac38 | |
![]() |
17cd942148 | |
![]() |
1a44443c41 | |
![]() |
89e8545d80 | |
![]() |
f4d12e0b7a | |
![]() |
9bb2f9da74 | |
![]() |
121aeadbd8 | |
![]() |
e0046ede81 | |
![]() |
571eec24d3 | |
![]() |
0e75256520 |
30
README.md
|
@ -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,27 @@ 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
|
||||
|
@ -49,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)
|
||||
|
@ -162,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
|
||||
|
@ -182,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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
target/
|
|
@ -0,0 +1,140 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"num_enum",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
num_enum = "0.5.0"
|
||||
serde = { version = "1.0.114", features = ["derive"] }
|
|
@ -0,0 +1,173 @@
|
|||
Derived from https://github.com/bozbez/interception-sys and https://github.com/bozbez/interception-rs
|
||||
|
||||
Repackaged to link statically with https://github.com/oblitum/Interception 1.0.1 instead of using dynamic library.
|
||||
|
||||
Interception is licensed under LGPL 3.0 for non-commercial use. Interception-sys and interception-rs according to its Cargo.toml are licensed under LGPL 3.0.
|
||||
|
||||
```
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=include/interception.h");
|
||||
println!("cargo:rerun-if-changed=src/interception.c");
|
||||
cc::Build::new()
|
||||
.define("INTERCEPTION_STATIC", None)
|
||||
.file("src/interception.c")
|
||||
.include("include/")
|
||||
.compile("interception");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=interception");
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
#ifndef _INTERCEPTION_H_
|
||||
#define _INTERCEPTION_H_
|
||||
|
||||
#ifdef INTERCEPTION_STATIC
|
||||
#define INTERCEPTION_API
|
||||
#else
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef INTERCEPTION_EXPORT
|
||||
#ifdef __GNUC__
|
||||
#define INTERCEPTION_API __attribute__((dllexport))
|
||||
#else
|
||||
#define INTERCEPTION_API __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define INTERCEPTION_API __attribute__((dllimport))
|
||||
#else
|
||||
#define INTERCEPTION_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define INTERCEPTION_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define INTERCEPTION_API
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INTERCEPTION_MAX_KEYBOARD 10
|
||||
|
||||
#define INTERCEPTION_MAX_MOUSE 10
|
||||
|
||||
#define INTERCEPTION_MAX_DEVICE ((INTERCEPTION_MAX_KEYBOARD) + (INTERCEPTION_MAX_MOUSE))
|
||||
|
||||
#define INTERCEPTION_KEYBOARD(index) ((index) + 1)
|
||||
|
||||
#define INTERCEPTION_MOUSE(index) ((INTERCEPTION_MAX_KEYBOARD) + (index) + 1)
|
||||
|
||||
typedef void *InterceptionContext;
|
||||
|
||||
typedef int InterceptionDevice;
|
||||
|
||||
typedef int InterceptionPrecedence;
|
||||
|
||||
typedef unsigned short InterceptionFilter;
|
||||
|
||||
typedef int (*InterceptionPredicate)(InterceptionDevice device);
|
||||
|
||||
enum InterceptionKeyState
|
||||
{
|
||||
INTERCEPTION_KEY_DOWN = 0x00,
|
||||
INTERCEPTION_KEY_UP = 0x01,
|
||||
INTERCEPTION_KEY_E0 = 0x02,
|
||||
INTERCEPTION_KEY_E1 = 0x04,
|
||||
INTERCEPTION_KEY_TERMSRV_SET_LED = 0x08,
|
||||
INTERCEPTION_KEY_TERMSRV_SHADOW = 0x10,
|
||||
INTERCEPTION_KEY_TERMSRV_VKPACKET = 0x20
|
||||
};
|
||||
|
||||
enum InterceptionFilterKeyState
|
||||
{
|
||||
INTERCEPTION_FILTER_KEY_NONE = 0x0000,
|
||||
INTERCEPTION_FILTER_KEY_ALL = 0xFFFF,
|
||||
INTERCEPTION_FILTER_KEY_DOWN = INTERCEPTION_KEY_UP,
|
||||
INTERCEPTION_FILTER_KEY_UP = INTERCEPTION_KEY_UP << 1,
|
||||
INTERCEPTION_FILTER_KEY_E0 = INTERCEPTION_KEY_E0 << 1,
|
||||
INTERCEPTION_FILTER_KEY_E1 = INTERCEPTION_KEY_E1 << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_SET_LED = INTERCEPTION_KEY_TERMSRV_SET_LED << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_SHADOW = INTERCEPTION_KEY_TERMSRV_SHADOW << 1,
|
||||
INTERCEPTION_FILTER_KEY_TERMSRV_VKPACKET = INTERCEPTION_KEY_TERMSRV_VKPACKET << 1
|
||||
};
|
||||
|
||||
enum InterceptionMouseState
|
||||
{
|
||||
INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN = 0x001,
|
||||
INTERCEPTION_MOUSE_LEFT_BUTTON_UP = 0x002,
|
||||
INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN = 0x004,
|
||||
INTERCEPTION_MOUSE_RIGHT_BUTTON_UP = 0x008,
|
||||
INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN = 0x010,
|
||||
INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP = 0x020,
|
||||
|
||||
INTERCEPTION_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
|
||||
INTERCEPTION_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
|
||||
INTERCEPTION_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
|
||||
INTERCEPTION_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
|
||||
|
||||
INTERCEPTION_MOUSE_BUTTON_4_DOWN = 0x040,
|
||||
INTERCEPTION_MOUSE_BUTTON_4_UP = 0x080,
|
||||
INTERCEPTION_MOUSE_BUTTON_5_DOWN = 0x100,
|
||||
INTERCEPTION_MOUSE_BUTTON_5_UP = 0x200,
|
||||
|
||||
INTERCEPTION_MOUSE_WHEEL = 0x400,
|
||||
INTERCEPTION_MOUSE_HWHEEL = 0x800
|
||||
};
|
||||
|
||||
enum InterceptionFilterMouseState
|
||||
{
|
||||
INTERCEPTION_FILTER_MOUSE_NONE = 0x0000,
|
||||
INTERCEPTION_FILTER_MOUSE_ALL = 0xFFFF,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_BUTTON_1_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_BUTTON_1_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_BUTTON_2_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_BUTTON_2_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_BUTTON_3_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_BUTTON_3_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_4_DOWN = INTERCEPTION_MOUSE_BUTTON_4_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_4_UP = INTERCEPTION_MOUSE_BUTTON_4_UP,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_5_DOWN = INTERCEPTION_MOUSE_BUTTON_5_DOWN,
|
||||
INTERCEPTION_FILTER_MOUSE_BUTTON_5_UP = INTERCEPTION_MOUSE_BUTTON_5_UP,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_WHEEL = INTERCEPTION_MOUSE_WHEEL,
|
||||
INTERCEPTION_FILTER_MOUSE_HWHEEL = INTERCEPTION_MOUSE_HWHEEL,
|
||||
|
||||
INTERCEPTION_FILTER_MOUSE_MOVE = 0x1000
|
||||
};
|
||||
|
||||
enum InterceptionMouseFlag
|
||||
{
|
||||
INTERCEPTION_MOUSE_MOVE_RELATIVE = 0x000,
|
||||
INTERCEPTION_MOUSE_MOVE_ABSOLUTE = 0x001,
|
||||
INTERCEPTION_MOUSE_VIRTUAL_DESKTOP = 0x002,
|
||||
INTERCEPTION_MOUSE_ATTRIBUTES_CHANGED = 0x004,
|
||||
INTERCEPTION_MOUSE_MOVE_NOCOALESCE = 0x008,
|
||||
INTERCEPTION_MOUSE_TERMSRV_SRC_SHADOW = 0x100
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short state;
|
||||
unsigned short flags;
|
||||
short rolling;
|
||||
int x;
|
||||
int y;
|
||||
unsigned int information;
|
||||
} InterceptionMouseStroke;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short code;
|
||||
unsigned short state;
|
||||
unsigned int information;
|
||||
} InterceptionKeyStroke;
|
||||
|
||||
typedef char InterceptionStroke[sizeof(InterceptionMouseStroke)];
|
||||
|
||||
InterceptionContext INTERCEPTION_API interception_create_context(void);
|
||||
|
||||
void INTERCEPTION_API interception_destroy_context(InterceptionContext context);
|
||||
|
||||
InterceptionPrecedence INTERCEPTION_API interception_get_precedence(InterceptionContext context, InterceptionDevice device);
|
||||
|
||||
void INTERCEPTION_API interception_set_precedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence);
|
||||
|
||||
InterceptionFilter INTERCEPTION_API interception_get_filter(InterceptionContext context, InterceptionDevice device);
|
||||
|
||||
void INTERCEPTION_API interception_set_filter(InterceptionContext context, InterceptionPredicate predicate, InterceptionFilter filter);
|
||||
|
||||
InterceptionDevice INTERCEPTION_API interception_wait(InterceptionContext context);
|
||||
|
||||
InterceptionDevice INTERCEPTION_API interception_wait_with_timeout(InterceptionContext context, unsigned long milliseconds);
|
||||
|
||||
int INTERCEPTION_API interception_send(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *stroke, unsigned int nstroke);
|
||||
|
||||
int INTERCEPTION_API interception_receive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *stroke, unsigned int nstroke);
|
||||
|
||||
unsigned int INTERCEPTION_API interception_get_hardware_id(InterceptionContext context, InterceptionDevice device, void *hardware_id_buffer, unsigned int buffer_size);
|
||||
|
||||
int INTERCEPTION_API interception_is_invalid(InterceptionDevice device);
|
||||
|
||||
int INTERCEPTION_API interception_is_keyboard(InterceptionDevice device);
|
||||
|
||||
int INTERCEPTION_API interception_is_mouse(InterceptionDevice device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,317 @@
|
|||
#![ allow( dead_code, unused_imports, non_upper_case_globals, non_snake_case, deref_nullptr ) ]
|
||||
|
||||
/* automatically generated by rust-bindgen 0.54.1 */
|
||||
|
||||
pub const INTERCEPTION_MAX_KEYBOARD: u32 = 10;
|
||||
pub const INTERCEPTION_MAX_MOUSE: u32 = 10;
|
||||
pub const INTERCEPTION_MAX_DEVICE: u32 = 20;
|
||||
pub type InterceptionContext = *mut ::std::os::raw::c_void;
|
||||
pub type InterceptionDevice = ::std::os::raw::c_int;
|
||||
pub type InterceptionPrecedence = ::std::os::raw::c_int;
|
||||
pub type InterceptionFilter = ::std::os::raw::c_ushort;
|
||||
pub type InterceptionPredicate = ::std::option::Option<
|
||||
unsafe extern "C" fn(device: InterceptionDevice) -> ::std::os::raw::c_int,
|
||||
>;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_DOWN: InterceptionKeyState = 0;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_UP: InterceptionKeyState = 1;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_E0: InterceptionKeyState = 2;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_E1: InterceptionKeyState = 4;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_SET_LED: InterceptionKeyState = 8;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_SHADOW: InterceptionKeyState = 16;
|
||||
pub const InterceptionKeyState_INTERCEPTION_KEY_TERMSRV_VKPACKET: InterceptionKeyState = 32;
|
||||
pub type InterceptionKeyState = u32;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_NONE: InterceptionFilterKeyState = 0;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_ALL: InterceptionFilterKeyState =
|
||||
65535;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_DOWN: InterceptionFilterKeyState = 1;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_UP: InterceptionFilterKeyState = 2;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_E0: InterceptionFilterKeyState = 4;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_E1: InterceptionFilterKeyState = 8;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_SET_LED:
|
||||
InterceptionFilterKeyState = 16;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_SHADOW:
|
||||
InterceptionFilterKeyState = 32;
|
||||
pub const InterceptionFilterKeyState_INTERCEPTION_FILTER_KEY_TERMSRV_VKPACKET:
|
||||
InterceptionFilterKeyState = 64;
|
||||
pub type InterceptionFilterKeyState = u32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN: InterceptionMouseState = 1;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_LEFT_BUTTON_UP: InterceptionMouseState = 2;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN: InterceptionMouseState = 4;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_RIGHT_BUTTON_UP: InterceptionMouseState = 8;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN: InterceptionMouseState = 16;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP: InterceptionMouseState = 32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_1_DOWN: InterceptionMouseState = 1;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_1_UP: InterceptionMouseState = 2;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_2_DOWN: InterceptionMouseState = 4;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_2_UP: InterceptionMouseState = 8;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_3_DOWN: InterceptionMouseState = 16;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_3_UP: InterceptionMouseState = 32;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_4_DOWN: InterceptionMouseState = 64;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_4_UP: InterceptionMouseState = 128;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_5_DOWN: InterceptionMouseState = 256;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_BUTTON_5_UP: InterceptionMouseState = 512;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_WHEEL: InterceptionMouseState = 1024;
|
||||
pub const InterceptionMouseState_INTERCEPTION_MOUSE_HWHEEL: InterceptionMouseState = 2048;
|
||||
pub type InterceptionMouseState = u32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_NONE:
|
||||
InterceptionFilterMouseState = 0;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_ALL: InterceptionFilterMouseState =
|
||||
65535;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 1;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 2;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 4;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 8;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
InterceptionFilterMouseState = 16;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_UP:
|
||||
InterceptionFilterMouseState = 32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_1_DOWN:
|
||||
InterceptionFilterMouseState = 1;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_1_UP:
|
||||
InterceptionFilterMouseState = 2;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_2_DOWN:
|
||||
InterceptionFilterMouseState = 4;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_2_UP:
|
||||
InterceptionFilterMouseState = 8;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_3_DOWN:
|
||||
InterceptionFilterMouseState = 16;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_3_UP:
|
||||
InterceptionFilterMouseState = 32;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_4_DOWN:
|
||||
InterceptionFilterMouseState = 64;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_4_UP:
|
||||
InterceptionFilterMouseState = 128;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_5_DOWN:
|
||||
InterceptionFilterMouseState = 256;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_BUTTON_5_UP:
|
||||
InterceptionFilterMouseState = 512;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_WHEEL:
|
||||
InterceptionFilterMouseState = 1024;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_HWHEEL:
|
||||
InterceptionFilterMouseState = 2048;
|
||||
pub const InterceptionFilterMouseState_INTERCEPTION_FILTER_MOUSE_MOVE:
|
||||
InterceptionFilterMouseState = 4096;
|
||||
pub type InterceptionFilterMouseState = u32;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_RELATIVE: InterceptionMouseFlag = 0;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_ABSOLUTE: InterceptionMouseFlag = 1;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_VIRTUAL_DESKTOP: InterceptionMouseFlag = 2;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_ATTRIBUTES_CHANGED: InterceptionMouseFlag = 4;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_MOVE_NOCOALESCE: InterceptionMouseFlag = 8;
|
||||
pub const InterceptionMouseFlag_INTERCEPTION_MOUSE_TERMSRV_SRC_SHADOW: InterceptionMouseFlag = 256;
|
||||
pub type InterceptionMouseFlag = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct InterceptionMouseStroke {
|
||||
pub state: ::std::os::raw::c_ushort,
|
||||
pub flags: ::std::os::raw::c_ushort,
|
||||
pub rolling: ::std::os::raw::c_short,
|
||||
pub x: ::std::os::raw::c_int,
|
||||
pub y: ::std::os::raw::c_int,
|
||||
pub information: ::std::os::raw::c_uint,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_InterceptionMouseStroke() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<InterceptionMouseStroke>(),
|
||||
20usize,
|
||||
concat!("Size of: ", stringify!(InterceptionMouseStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<InterceptionMouseStroke>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(InterceptionMouseStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).state as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(state)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).flags as *const _ as usize },
|
||||
2usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).rolling as *const _ as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(rolling)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).x as *const _ as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(x)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionMouseStroke>())).y as *const _ as usize },
|
||||
12usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(y)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::std::ptr::null::<InterceptionMouseStroke>())).information as *const _ as usize
|
||||
},
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionMouseStroke),
|
||||
"::",
|
||||
stringify!(information)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct InterceptionKeyStroke {
|
||||
pub code: ::std::os::raw::c_ushort,
|
||||
pub state: ::std::os::raw::c_ushort,
|
||||
pub information: ::std::os::raw::c_uint,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_InterceptionKeyStroke() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<InterceptionKeyStroke>(),
|
||||
8usize,
|
||||
concat!("Size of: ", stringify!(InterceptionKeyStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<InterceptionKeyStroke>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(InterceptionKeyStroke))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionKeyStroke>())).code as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(code)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<InterceptionKeyStroke>())).state as *const _ as usize },
|
||||
2usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(state)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::std::ptr::null::<InterceptionKeyStroke>())).information as *const _ as usize
|
||||
},
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(InterceptionKeyStroke),
|
||||
"::",
|
||||
stringify!(information)
|
||||
)
|
||||
);
|
||||
}
|
||||
pub type InterceptionStroke = [::std::os::raw::c_char; 20usize];
|
||||
extern "C" {
|
||||
pub fn interception_create_context() -> InterceptionContext;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_destroy_context(context: InterceptionContext);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_precedence(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
) -> InterceptionPrecedence;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_set_precedence(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
precedence: InterceptionPrecedence,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_filter(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
) -> InterceptionFilter;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_set_filter(
|
||||
context: InterceptionContext,
|
||||
predicate: InterceptionPredicate,
|
||||
filter: InterceptionFilter,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_wait(context: InterceptionContext) -> InterceptionDevice;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_wait_with_timeout(
|
||||
context: InterceptionContext,
|
||||
milliseconds: ::std::os::raw::c_ulong,
|
||||
) -> InterceptionDevice;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_send(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
stroke: *const InterceptionStroke,
|
||||
nstroke: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_receive(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
stroke: *mut InterceptionStroke,
|
||||
nstroke: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_get_hardware_id(
|
||||
context: InterceptionContext,
|
||||
device: InterceptionDevice,
|
||||
hardware_id_buffer: *mut ::std::os::raw::c_void,
|
||||
buffer_size: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_invalid(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_keyboard(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn interception_is_mouse(device: InterceptionDevice) -> ::std::os::raw::c_int;
|
||||
}
|
|
@ -0,0 +1,328 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#include "interception.h"
|
||||
|
||||
#define IOCTL_SET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SET_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x820, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_READ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x840, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_GET_HARDWARE_ID CTL_CODE(FILE_DEVICE_UNKNOWN, 0x880, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
typedef struct _KEYBOARD_INPUT_DATA
|
||||
{
|
||||
USHORT UnitId;
|
||||
USHORT MakeCode;
|
||||
USHORT Flags;
|
||||
USHORT Reserved;
|
||||
ULONG ExtraInformation;
|
||||
} KEYBOARD_INPUT_DATA, *PKEYBOARD_INPUT_DATA;
|
||||
|
||||
typedef struct _MOUSE_INPUT_DATA
|
||||
{
|
||||
USHORT UnitId;
|
||||
USHORT Flags;
|
||||
USHORT ButtonFlags;
|
||||
USHORT ButtonData;
|
||||
ULONG RawButtons;
|
||||
LONG LastX;
|
||||
LONG LastY;
|
||||
ULONG ExtraInformation;
|
||||
} MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
void *unempty;
|
||||
} *InterceptionDeviceArray;
|
||||
|
||||
InterceptionContext interception_create_context(void)
|
||||
{
|
||||
InterceptionDeviceArray device_array = 0;
|
||||
char device_name[] = "\\\\.\\interception00";
|
||||
DWORD bytes_returned;
|
||||
InterceptionDevice i;
|
||||
|
||||
device_array = (InterceptionDeviceArray)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, INTERCEPTION_MAX_DEVICE * sizeof(*((InterceptionDeviceArray) 0)));
|
||||
if(!device_array) return 0;
|
||||
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
HANDLE zero_padded_handle[2] = {0};
|
||||
|
||||
sprintf(&device_name[sizeof(device_name) - 3], "%02d", i);
|
||||
|
||||
device_array[i].handle = CreateFileA(device_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if (device_array[i].handle == INVALID_HANDLE_VALUE) {
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
|
||||
device_array[i].unempty = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
if(device_array[i].unempty == NULL)
|
||||
{
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
|
||||
zero_padded_handle[0] = device_array[i].unempty;
|
||||
|
||||
if(!DeviceIoControl(device_array[i].handle, IOCTL_SET_EVENT, zero_padded_handle, sizeof(zero_padded_handle), NULL, 0, &bytes_returned, NULL))
|
||||
{
|
||||
interception_destroy_context(device_array);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return device_array;
|
||||
}
|
||||
|
||||
void interception_destroy_context(InterceptionContext context)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
unsigned int i;
|
||||
|
||||
if(!context) return;
|
||||
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if(device_array[i].handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(device_array[i].handle);
|
||||
|
||||
if(device_array[i].unempty != NULL)
|
||||
CloseHandle(device_array[i].unempty);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, context);
|
||||
}
|
||||
|
||||
InterceptionPrecedence interception_get_precedence(InterceptionContext context, InterceptionDevice device)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionPrecedence precedence = 0;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_PRECEDENCE, NULL, 0, (LPVOID)&precedence, sizeof(InterceptionPrecedence), &bytes_returned, NULL);
|
||||
|
||||
return precedence;
|
||||
}
|
||||
|
||||
void interception_set_precedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_SET_PRECEDENCE, (LPVOID)&precedence, sizeof(InterceptionPrecedence), NULL, 0, &bytes_returned, NULL);
|
||||
}
|
||||
|
||||
InterceptionFilter interception_get_filter(InterceptionContext context, InterceptionDevice device)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionFilter filter = 0;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context && device_array[device - 1].handle)
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_FILTER, NULL, 0, (LPVOID)&filter, sizeof(InterceptionFilter), &bytes_returned, NULL);
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
void interception_set_filter(InterceptionContext context, InterceptionPredicate interception_predicate, InterceptionFilter filter)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
InterceptionDevice i;
|
||||
DWORD bytes_returned;
|
||||
|
||||
if(context)
|
||||
for(i = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
if(device_array[i].handle && interception_predicate(i + 1))
|
||||
DeviceIoControl(device_array[i].handle, IOCTL_SET_FILTER, (LPVOID)&filter, sizeof(InterceptionFilter), NULL, 0, &bytes_returned, NULL);
|
||||
}
|
||||
|
||||
InterceptionDevice interception_wait(InterceptionContext context)
|
||||
{
|
||||
return interception_wait_with_timeout(context, INFINITE);
|
||||
}
|
||||
|
||||
InterceptionDevice interception_wait_with_timeout(InterceptionContext context, unsigned long milliseconds)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
HANDLE wait_handles[INTERCEPTION_MAX_DEVICE];
|
||||
DWORD i, j, k;
|
||||
|
||||
if(!context) return 0;
|
||||
|
||||
for(i = 0, j = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if (device_array[i].unempty)
|
||||
wait_handles[j++] = device_array[i].unempty;
|
||||
}
|
||||
|
||||
k = WaitForMultipleObjects(j, wait_handles, FALSE, milliseconds);
|
||||
|
||||
if(k == WAIT_FAILED || k == WAIT_TIMEOUT) return 0;
|
||||
|
||||
for(i = 0, j = 0; i < INTERCEPTION_MAX_DEVICE; ++i)
|
||||
{
|
||||
if (device_array[i].unempty)
|
||||
if (k == j++)
|
||||
break;
|
||||
}
|
||||
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
int interception_send(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *stroke, unsigned int nstroke)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD strokeswritten = 0;
|
||||
|
||||
if(context == 0 || nstroke == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
if(interception_is_keyboard(device))
|
||||
{
|
||||
PKEYBOARD_INPUT_DATA rawstrokes = (PKEYBOARD_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(KEYBOARD_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
for(i = 0; i < nstroke; ++i)
|
||||
{
|
||||
InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) stroke;
|
||||
|
||||
rawstrokes[i].UnitId = 0;
|
||||
rawstrokes[i].MakeCode = key_stroke[i].code;
|
||||
rawstrokes[i].Flags = key_stroke[i].state;
|
||||
rawstrokes[i].Reserved = 0;
|
||||
rawstrokes[i].ExtraInformation = key_stroke[i].information;
|
||||
}
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_WRITE, rawstrokes,(DWORD)nstroke * sizeof(KEYBOARD_INPUT_DATA), NULL, 0, &strokeswritten, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
|
||||
strokeswritten /= sizeof(KEYBOARD_INPUT_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
PMOUSE_INPUT_DATA rawstrokes = (PMOUSE_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(MOUSE_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
for(i = 0; i < nstroke; ++i)
|
||||
{
|
||||
InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) stroke;
|
||||
|
||||
rawstrokes[i].UnitId = 0;
|
||||
rawstrokes[i].Flags = mouse_stroke[i].flags;
|
||||
rawstrokes[i].ButtonFlags = mouse_stroke[i].state;
|
||||
rawstrokes[i].ButtonData = mouse_stroke[i].rolling;
|
||||
rawstrokes[i].RawButtons = 0;
|
||||
rawstrokes[i].LastX = mouse_stroke[i].x;
|
||||
rawstrokes[i].LastY = mouse_stroke[i].y;
|
||||
rawstrokes[i].ExtraInformation = mouse_stroke[i].information;
|
||||
}
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_WRITE, rawstrokes, (DWORD)nstroke * sizeof(MOUSE_INPUT_DATA), NULL, 0, &strokeswritten, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
|
||||
strokeswritten /= sizeof(MOUSE_INPUT_DATA);
|
||||
}
|
||||
|
||||
return strokeswritten;
|
||||
}
|
||||
|
||||
int interception_receive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *stroke, unsigned int nstroke)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD strokesread = 0;
|
||||
|
||||
if(context == 0 || nstroke == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
if(interception_is_keyboard(device))
|
||||
{
|
||||
PKEYBOARD_INPUT_DATA rawstrokes = (PKEYBOARD_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(KEYBOARD_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_READ, NULL, 0, rawstrokes, (DWORD)nstroke * sizeof(KEYBOARD_INPUT_DATA), &strokesread, NULL);
|
||||
|
||||
strokesread /= sizeof(KEYBOARD_INPUT_DATA);
|
||||
|
||||
for(i = 0; i < (unsigned int)strokesread; ++i)
|
||||
{
|
||||
InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) stroke;
|
||||
|
||||
key_stroke[i].code = rawstrokes[i].MakeCode;
|
||||
key_stroke[i].state = rawstrokes[i].Flags;
|
||||
key_stroke[i].information = rawstrokes[i].ExtraInformation;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
}
|
||||
else
|
||||
{
|
||||
PMOUSE_INPUT_DATA rawstrokes = (PMOUSE_INPUT_DATA)HeapAlloc(GetProcessHeap(), 0, nstroke * sizeof(MOUSE_INPUT_DATA));
|
||||
unsigned int i;
|
||||
|
||||
if(!rawstrokes) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_READ, NULL, 0, rawstrokes, (DWORD)nstroke * sizeof(MOUSE_INPUT_DATA), &strokesread, NULL);
|
||||
|
||||
strokesread /= sizeof(MOUSE_INPUT_DATA);
|
||||
|
||||
for(i = 0; i < (unsigned int)strokesread; ++i)
|
||||
{
|
||||
InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) stroke;
|
||||
|
||||
mouse_stroke[i].flags = rawstrokes[i].Flags;
|
||||
mouse_stroke[i].state = rawstrokes[i].ButtonFlags;
|
||||
mouse_stroke[i].rolling = rawstrokes[i].ButtonData;
|
||||
mouse_stroke[i].x = rawstrokes[i].LastX;
|
||||
mouse_stroke[i].y = rawstrokes[i].LastY;
|
||||
mouse_stroke[i].information = rawstrokes[i].ExtraInformation;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, rawstrokes);
|
||||
}
|
||||
|
||||
return strokesread;
|
||||
}
|
||||
|
||||
unsigned int interception_get_hardware_id(InterceptionContext context, InterceptionDevice device, void *hardware_id_buffer, unsigned int buffer_size)
|
||||
{
|
||||
InterceptionDeviceArray device_array = (InterceptionDeviceArray)context;
|
||||
DWORD output_size = 0;
|
||||
|
||||
if(context == 0 || interception_is_invalid(device) || !device_array[device - 1].handle) return 0;
|
||||
|
||||
DeviceIoControl(device_array[device - 1].handle, IOCTL_GET_HARDWARE_ID, NULL, 0, hardware_id_buffer, buffer_size, &output_size, NULL);
|
||||
|
||||
return output_size;
|
||||
}
|
||||
|
||||
int interception_is_invalid(InterceptionDevice device)
|
||||
{
|
||||
return !interception_is_keyboard(device) && !interception_is_mouse(device);
|
||||
}
|
||||
|
||||
int interception_is_keyboard(InterceptionDevice device)
|
||||
{
|
||||
return device >= INTERCEPTION_KEYBOARD(0) && device <= INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD - 1);
|
||||
}
|
||||
|
||||
int interception_is_mouse(InterceptionDevice device)
|
||||
{
|
||||
return device >= INTERCEPTION_MOUSE(0) && device <= INTERCEPTION_MOUSE(INTERCEPTION_MAX_MOUSE - 1);
|
||||
}
|
|
@ -0,0 +1,373 @@
|
|||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
mod bindings;
|
||||
use bindings as raw;
|
||||
pub mod scancode;
|
||||
|
||||
pub use scancode::ScanCode;
|
||||
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::default::Default;
|
||||
use std::time::Duration;
|
||||
use std::vec::Vec;
|
||||
|
||||
pub type Device = i32;
|
||||
pub type Precedence = i32;
|
||||
|
||||
pub enum Filter {
|
||||
MouseFilter(MouseFilter),
|
||||
KeyFilter(KeyFilter),
|
||||
}
|
||||
|
||||
pub type Predicate = extern "C" fn(device: Device) -> bool;
|
||||
|
||||
bitflags! {
|
||||
pub struct MouseState: u16 {
|
||||
const LEFT_BUTTON_DOWN = 1;
|
||||
const LEFT_BUTTON_UP = 2;
|
||||
|
||||
const RIGHT_BUTTON_DOWN = 4;
|
||||
const RIGHT_BUTTON_UP = 8;
|
||||
|
||||
const MIDDLE_BUTTON_DOWN = 16;
|
||||
const MIDDLE_BUTTON_UP = 32;
|
||||
|
||||
const BUTTON_4_DOWN = 64;
|
||||
const BUTTON_4_UP = 128;
|
||||
|
||||
const BUTTON_5_DOWN = 256;
|
||||
const BUTTON_5_UP = 512;
|
||||
|
||||
const WHEEL = 1024;
|
||||
const HWHEEL = 2048;
|
||||
|
||||
// MouseFilter only
|
||||
const MOVE = 4096;
|
||||
}
|
||||
}
|
||||
|
||||
pub type MouseFilter = MouseState;
|
||||
|
||||
bitflags! {
|
||||
pub struct MouseFlags: u16 {
|
||||
const MOVE_RELATIVE = 0;
|
||||
const MOVE_ABSOLUTE = 1;
|
||||
|
||||
const VIRTUAL_DESKTOP = 2;
|
||||
const ATTRIBUTES_CHANGED = 4;
|
||||
|
||||
const MOVE_NO_COALESCE = 8;
|
||||
|
||||
const TERMSRV_SRC_SHADOW = 256;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct KeyState: u16 {
|
||||
const DOWN = 0;
|
||||
const UP = 1;
|
||||
|
||||
const E0 = 2;
|
||||
const E1 = 3;
|
||||
|
||||
const TERMSRV_SET_LED = 8;
|
||||
const TERMSRV_SHADOW = 16;
|
||||
const TERMSRV_VKPACKET = 32;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct KeyFilter: u16 {
|
||||
const DOWN = 1;
|
||||
const UP = 2;
|
||||
|
||||
const E0 = 4;
|
||||
const E1 = 8;
|
||||
|
||||
const TERMSRV_SET_LED = 16;
|
||||
const TERMSRV_SHADOW = 32;
|
||||
const TERMSRV_VKPACKET = 64;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Stroke {
|
||||
Mouse {
|
||||
state: MouseState,
|
||||
flags: MouseFlags,
|
||||
rolling: i16,
|
||||
x: i32,
|
||||
y: i32,
|
||||
information: u32,
|
||||
},
|
||||
|
||||
Keyboard {
|
||||
code: ScanCode,
|
||||
state: KeyState,
|
||||
information: u32,
|
||||
},
|
||||
}
|
||||
|
||||
impl TryFrom<raw::InterceptionMouseStroke> for Stroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(raw_stroke: raw::InterceptionMouseStroke) -> Result<Self, Self::Error> {
|
||||
let state = match MouseState::from_bits(raw_stroke.state) {
|
||||
Some(state) => state,
|
||||
None => return Err("Extra bits in raw mouse state"),
|
||||
};
|
||||
|
||||
let flags = match MouseFlags::from_bits(raw_stroke.flags) {
|
||||
Some(flags) => flags,
|
||||
None => return Err("Extra bits in raw mouse flags"),
|
||||
};
|
||||
|
||||
Ok(Stroke::Mouse {
|
||||
state: state,
|
||||
flags: flags,
|
||||
rolling: raw_stroke.rolling,
|
||||
x: raw_stroke.x,
|
||||
y: raw_stroke.y,
|
||||
information: raw_stroke.information,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<raw::InterceptionKeyStroke> for Stroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(raw_stroke: raw::InterceptionKeyStroke) -> Result<Self, Self::Error> {
|
||||
let state = match KeyState::from_bits(raw_stroke.state) {
|
||||
Some(state) => state,
|
||||
None => return Err("Extra bits in raw keyboard state"),
|
||||
};
|
||||
|
||||
let code = match ScanCode::try_from(raw_stroke.code) {
|
||||
Ok(code) => code,
|
||||
Err(_) => ScanCode::Esc,
|
||||
};
|
||||
|
||||
Ok(Stroke::Keyboard {
|
||||
code: code,
|
||||
state: state,
|
||||
information: raw_stroke.information,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Stroke> for raw::InterceptionMouseStroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(stroke: Stroke) -> Result<Self, Self::Error> {
|
||||
if let Stroke::Mouse {
|
||||
state,
|
||||
flags,
|
||||
rolling,
|
||||
x,
|
||||
y,
|
||||
information,
|
||||
} = stroke
|
||||
{
|
||||
Ok(raw::InterceptionMouseStroke {
|
||||
state: state.bits(),
|
||||
flags: flags.bits(),
|
||||
rolling: rolling,
|
||||
x: x,
|
||||
y: y,
|
||||
information: information,
|
||||
})
|
||||
} else {
|
||||
Err("Stroke must be a mouse stroke")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Stroke> for raw::InterceptionKeyStroke {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(stroke: Stroke) -> Result<Self, Self::Error> {
|
||||
if let Stroke::Keyboard {
|
||||
code,
|
||||
state,
|
||||
information,
|
||||
} = stroke
|
||||
{
|
||||
Ok(raw::InterceptionKeyStroke {
|
||||
code: code as u16,
|
||||
state: state.bits(),
|
||||
information: information,
|
||||
})
|
||||
} else {
|
||||
Err("Stroke must be a keyboard stroke")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Interception {
|
||||
ctx: raw::InterceptionContext,
|
||||
}
|
||||
|
||||
impl Interception {
|
||||
pub fn new() -> Option<Self> {
|
||||
let ctx = unsafe { raw::interception_create_context() };
|
||||
|
||||
if ctx == std::ptr::null_mut() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(Interception { ctx: ctx })
|
||||
}
|
||||
|
||||
pub fn get_precedence(&self, device: Device) -> Precedence {
|
||||
unsafe { raw::interception_get_precedence(self.ctx, device) }
|
||||
}
|
||||
|
||||
pub fn set_precedence(&self, device: Device, precedence: Precedence) {
|
||||
unsafe { raw::interception_set_precedence(self.ctx, device, precedence) }
|
||||
}
|
||||
|
||||
pub fn get_filter(&self, device: Device) -> Filter {
|
||||
if is_invalid(device) {
|
||||
return Filter::KeyFilter(KeyFilter::empty());
|
||||
}
|
||||
|
||||
let raw_filter = unsafe { raw::interception_get_filter(self.ctx, device) };
|
||||
if is_mouse(device) {
|
||||
let filter = match MouseFilter::from_bits(raw_filter) {
|
||||
Some(filter) => filter,
|
||||
None => MouseFilter::empty(),
|
||||
};
|
||||
|
||||
Filter::MouseFilter(filter)
|
||||
} else {
|
||||
let filter = match KeyFilter::from_bits(raw_filter) {
|
||||
Some(filter) => filter,
|
||||
None => KeyFilter::empty(),
|
||||
};
|
||||
|
||||
Filter::KeyFilter(filter)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_filter(&self, predicate: Predicate, filter: Filter) {
|
||||
let filter = match filter {
|
||||
Filter::MouseFilter(filter) => filter.bits(),
|
||||
Filter::KeyFilter(filter) => filter.bits(),
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let predicate = std::mem::transmute(Some(predicate));
|
||||
raw::interception_set_filter(self.ctx, predicate, filter)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wait(&self) -> Device {
|
||||
unsafe { raw::interception_wait(self.ctx) }
|
||||
}
|
||||
|
||||
pub fn wait_with_timeout(&self, duration: Duration) -> Device {
|
||||
let millis = match u32::try_from(duration.as_millis()) {
|
||||
Ok(m) => m,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe { raw::interception_wait_with_timeout(self.ctx, millis) }
|
||||
}
|
||||
|
||||
pub fn send(&self, device: Device, strokes: &[Stroke]) -> i32 {
|
||||
if is_mouse(device) {
|
||||
self.send_internal::<raw::InterceptionMouseStroke>(device, strokes)
|
||||
} else if is_keyboard(device) {
|
||||
self.send_internal::<raw::InterceptionKeyStroke>(device, strokes)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn send_internal<T: TryFrom<Stroke>>(&self, device: Device, strokes: &[Stroke]) -> i32 {
|
||||
let mut raw_strokes = Vec::new();
|
||||
|
||||
for stroke in strokes {
|
||||
if let Ok(raw_stroke) = T::try_from(*stroke) {
|
||||
raw_strokes.push(raw_stroke)
|
||||
}
|
||||
}
|
||||
|
||||
let ptr = raw_strokes.as_ptr();
|
||||
let len = match u32::try_from(raw_strokes.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe { raw::interception_send(self.ctx, device, std::mem::transmute(ptr), len) }
|
||||
}
|
||||
|
||||
pub fn receive(&self, device: Device, strokes: &mut [Stroke]) -> i32 {
|
||||
if is_mouse(device) {
|
||||
self.receive_internal::<raw::InterceptionMouseStroke>(device, strokes)
|
||||
} else if is_keyboard(device) {
|
||||
self.receive_internal::<raw::InterceptionKeyStroke>(device, strokes)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn receive_internal<T: TryInto<Stroke> + Default + Copy>(
|
||||
&self,
|
||||
device: Device,
|
||||
strokes: &mut [Stroke],
|
||||
) -> i32 {
|
||||
let mut raw_strokes: Vec<T> = Vec::with_capacity(strokes.len());
|
||||
raw_strokes.resize_with(strokes.len(), Default::default);
|
||||
|
||||
let ptr = raw_strokes.as_ptr();
|
||||
let len = match u32::try_from(raw_strokes.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
let num_read =
|
||||
unsafe { raw::interception_receive(self.ctx, device, std::mem::transmute(ptr), len) };
|
||||
|
||||
let mut num_valid: i32 = 0;
|
||||
for i in 0..num_read {
|
||||
if let Ok(stroke) = raw_strokes[i as usize].try_into() {
|
||||
strokes[num_valid as usize] = stroke;
|
||||
num_valid += 1;
|
||||
}
|
||||
}
|
||||
|
||||
num_valid
|
||||
}
|
||||
|
||||
pub fn get_hardware_id(&self, device: Device, buffer: &mut [u8]) -> u32 {
|
||||
let ptr = buffer.as_mut_ptr();
|
||||
let len = match u32::try_from(buffer.len()) {
|
||||
Ok(l) => l,
|
||||
Err(_) => u32::MAX,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
raw::interception_get_hardware_id(self.ctx, device, std::mem::transmute(ptr), len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Interception {
|
||||
fn drop(&mut self) {
|
||||
unsafe { raw::interception_destroy_context(self.ctx) }
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn is_invalid(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_invalid(device) != 0 }
|
||||
}
|
||||
|
||||
pub extern "C" fn is_keyboard(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_keyboard(device) != 0 }
|
||||
}
|
||||
|
||||
pub extern "C" fn is_mouse(device: Device) -> bool {
|
||||
unsafe { raw::interception_is_mouse(device) != 0 }
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
use num_enum::TryFromPrimitive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// ref: https://handmade.network/wiki/2823-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names
|
||||
#[derive(Serialize, Deserialize, Hash, Debug, Eq, PartialEq, Copy, Clone, TryFromPrimitive)]
|
||||
#[repr(u16)]
|
||||
pub enum ScanCode {
|
||||
Esc = 0x01,
|
||||
|
||||
Num1 = 0x02,
|
||||
Num2 = 0x03,
|
||||
Num3 = 0x04,
|
||||
Num4 = 0x05,
|
||||
Num5 = 0x06,
|
||||
Num6 = 0x07,
|
||||
Num7 = 0x08,
|
||||
Num8 = 0x09,
|
||||
Num9 = 0x0A,
|
||||
Num0 = 0x0B,
|
||||
|
||||
Minus = 0x0C,
|
||||
Equals = 0x0D,
|
||||
Backspace = 0x0E,
|
||||
|
||||
Tab = 0x0F,
|
||||
|
||||
Q = 0x10,
|
||||
W = 0x11,
|
||||
E = 0x12,
|
||||
R = 0x13,
|
||||
T = 0x14,
|
||||
Y = 0x15,
|
||||
U = 0x16,
|
||||
I = 0x17,
|
||||
O = 0x18,
|
||||
P = 0x19,
|
||||
|
||||
LeftBracket = 0x1A,
|
||||
RightBracket = 0x1B,
|
||||
Enter = 0x1C,
|
||||
|
||||
LeftControl = 0x1D,
|
||||
|
||||
A = 0x1E,
|
||||
S = 0x1F,
|
||||
D = 0x20,
|
||||
F = 0x21,
|
||||
G = 0x22,
|
||||
H = 0x23,
|
||||
J = 0x24,
|
||||
K = 0x25,
|
||||
L = 0x26,
|
||||
|
||||
SemiColon = 0x27,
|
||||
Apostrophe = 0x28,
|
||||
Grave = 0x29,
|
||||
LeftShift = 0x2A,
|
||||
BackSlash = 0x2B,
|
||||
|
||||
Z = 0x2C,
|
||||
X = 0x2D,
|
||||
C = 0x2E,
|
||||
V = 0x2F,
|
||||
B = 0x30,
|
||||
N = 0x31,
|
||||
M = 0x32,
|
||||
|
||||
Comma = 0x33,
|
||||
Period = 0x34,
|
||||
Slash = 0x35,
|
||||
RightShift = 0x36,
|
||||
NumpadMultiply = 0x37,
|
||||
LeftAlt = 0x38,
|
||||
Space = 0x39,
|
||||
CapsLock = 0x3A,
|
||||
|
||||
F1 = 0x3B,
|
||||
F2 = 0x3C,
|
||||
F3 = 0x3D,
|
||||
F4 = 0x3E,
|
||||
F5 = 0x3F,
|
||||
F6 = 0x40,
|
||||
F7 = 0x41,
|
||||
F8 = 0x42,
|
||||
F9 = 0x43,
|
||||
F10 = 0x44,
|
||||
|
||||
NumLock = 0x45,
|
||||
ScrollLock = 0x46,
|
||||
|
||||
Numpad7 = 0x47,
|
||||
Numpad8 = 0x48,
|
||||
Numpad9 = 0x49,
|
||||
|
||||
NumpadMinus = 0x4A,
|
||||
|
||||
Numpad4 = 0x4B,
|
||||
Numpad5 = 0x4C,
|
||||
Numpad6 = 0x4D,
|
||||
|
||||
NumpadPlus = 0x4E,
|
||||
|
||||
Numpad1 = 0x4F,
|
||||
Numpad2 = 0x50,
|
||||
Numpad3 = 0x51,
|
||||
Numpad0 = 0x52,
|
||||
|
||||
NumpadPeriod = 0x53,
|
||||
AltPrintScreen = 0x54, /* Alt + print screen. */
|
||||
Int1 = 0x56, /* Key between the left shift and Z. */
|
||||
|
||||
F11 = 0x57,
|
||||
F12 = 0x58,
|
||||
|
||||
Oem1 = 0x5A, /* VK_OEM_WSCTRL */
|
||||
Oem2 = 0x5B, /* VK_OEM_FINISH */
|
||||
Oem3 = 0x5C, /* VK_OEM_JUMP */
|
||||
|
||||
EraseEOF = 0x5D,
|
||||
|
||||
Oem4 = 0x5E, /* VK_OEM_BACKTAB */
|
||||
Oem5 = 0x5F, /* VK_OEM_AUTO */
|
||||
|
||||
Zoom = 0x62,
|
||||
Help = 0x63,
|
||||
|
||||
F13 = 0x64,
|
||||
F14 = 0x65,
|
||||
F15 = 0x66,
|
||||
F16 = 0x67,
|
||||
F17 = 0x68,
|
||||
F18 = 0x69,
|
||||
F19 = 0x6A,
|
||||
F20 = 0x6B,
|
||||
F21 = 0x6C,
|
||||
F22 = 0x6D,
|
||||
F23 = 0x6E,
|
||||
|
||||
Oem6 = 0x6F, /* VK_OEM_PA3 */
|
||||
Katakana = 0x70,
|
||||
Oem7 = 0x71, /* VK_OEM_RESET */
|
||||
F24 = 0x76,
|
||||
|
||||
SBCSChar = 0x77,
|
||||
Convert = 0x79,
|
||||
NonConvert = 0x7B, /* VK_OEM_PA1 */
|
||||
}
|
|
@ -613,6 +613,16 @@ dependencies = [
|
|||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interception"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"num_enum",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipconfig"
|
||||
version = "0.3.0"
|
||||
|
@ -864,6 +874,27 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
|
@ -1053,6 +1084,16 @@ version = "0.2.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.19"
|
||||
|
@ -1308,6 +1349,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"hyper",
|
||||
"image",
|
||||
"interception",
|
||||
"ipconfig",
|
||||
"log",
|
||||
"palette",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -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?");
|
||||
|
|
|
@ -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()?,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -108,6 +108,12 @@ async fn handle_umgr_leds(ws_stream: WebSocketStream<Upgraded>, state: SliderSta
|
|||
);
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -41,6 +41,7 @@ pub enum OutputMode {
|
|||
layout: KeyboardLayout,
|
||||
polling: PollingRate,
|
||||
sensitivity: u8,
|
||||
direct_input: bool,
|
||||
},
|
||||
Gamepad {
|
||||
layout: GamepadLayout,
|
||||
|
@ -89,46 +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,
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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] = [
|
||||
|
@ -126,18 +127,25 @@ 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,
|
||||
|
@ -150,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() },
|
||||
|
@ -178,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,
|
||||
}
|
||||
}
|
||||
|
@ -198,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;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -223,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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
@ -83,8 +89,31 @@ impl SliderLights {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +151,8 @@ impl SliderState {
|
|||
{
|
||||
let lights_handle = self.lights.lock();
|
||||
buf.extend(lights_handle.ground);
|
||||
buf.extend(lights_handle.air_left);
|
||||
buf.extend(lights_handle.air_right);
|
||||
};
|
||||
|
||||
buf
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "slidershim"
|
||||
version = "0.3.1"
|
||||
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" }
|
||||
|
|
|
@ -2,13 +2,29 @@
|
|||
___| (_) __| | ___ _ __ ___| |__ (_)_ __ ___
|
||||
/ __| | |/ _` |/ _ \ '__/ __| '_ \| | '_ ` _ \
|
||||
\__ \ | | (_| | __/ | \__ \ | | | | | | | | |
|
||||
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| v0.3.1 UMIGURI UPDATE
|
||||
|___/_|_|\__,_|\___|_| |___/_| |_|_|_| |_| |_| 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
|
||||
|
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 918 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1023 B |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.8 KiB |
|
@ -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);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"package": {
|
||||
"productName": "slidershim",
|
||||
"version": "0.3.1"
|
||||
"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": [
|
||||
|
|
|
@ -15,11 +15,14 @@
|
|||
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;
|
||||
|
@ -69,12 +72,15 @@
|
|||
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;
|
||||
|
@ -125,11 +131,14 @@
|
|||
divaBrightness,
|
||||
brokenithmPort,
|
||||
keyboardSensitivity,
|
||||
keyboardDirectInput,
|
||||
outputPolling,
|
||||
outputWebsocketUrl,
|
||||
ledFaster,
|
||||
ledColorActive,
|
||||
ledColorInactive,
|
||||
ledColorAirActive,
|
||||
ledColorAirInactive,
|
||||
ledSensitivity,
|
||||
ledWebsocketUrl,
|
||||
ledUmgrWebsocketPort,
|
||||
|
@ -187,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>
|
||||
|
@ -386,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>
|
||||
|
@ -439,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}
|
||||
|
@ -519,7 +588,7 @@
|
|||
{#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
|
||||
|
|
|
@ -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
|
@ -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"
|
||||
|
|