mirror of https://github.com/4yn/slidershim
static include
parent
98509250d6
commit
3acf511da8
|
@ -68,6 +68,7 @@ body {
|
||||||
|
|
||||||
.header-timer {
|
.header-timer {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* main */
|
/* main */
|
||||||
|
|
|
@ -2955,6 +2955,7 @@ dependencies = [
|
||||||
"open",
|
"open",
|
||||||
"palette",
|
"palette",
|
||||||
"path-clean",
|
"path-clean",
|
||||||
|
"phf 0.10.1",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
"rusb",
|
"rusb",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -25,7 +25,6 @@ atomic_float = "0.1.0"
|
||||||
spin_sleep = "1.0.0"
|
spin_sleep = "1.0.0"
|
||||||
tauri = { version = "1.0.0-beta.8", features = ["shell-open", "system-tray"] }
|
tauri = { version = "1.0.0-beta.8", features = ["shell-open", "system-tray"] }
|
||||||
|
|
||||||
|
|
||||||
futures = "0.3.19"
|
futures = "0.3.19"
|
||||||
futures-util = "0.3.19"
|
futures-util = "0.3.19"
|
||||||
async-trait = "0.1.52"
|
async-trait = "0.1.52"
|
||||||
|
@ -41,6 +40,7 @@ winapi = "0.3.9"
|
||||||
ipconfig = "0.3.0"
|
ipconfig = "0.3.0"
|
||||||
|
|
||||||
hyper = { version="0.14.16", features= ["server", "http1", "http2", "tcp", "stream", "runtime"] }
|
hyper = { version="0.14.16", features= ["server", "http1", "http2", "tcp", "stream", "runtime"] }
|
||||||
|
phf = { version = "0.10.1", features = ["macros"] }
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
image = "0.23.14"
|
image = "0.23.14"
|
||||||
qrcode = { version="0.12.0", features= ["image"] }
|
qrcode = { version="0.12.0", features= ["image"] }
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
_ _ _ _ _
|
||||||
|
___| (_) __| | ___ _ __| |__ ___(_)_ __ ___
|
||||||
|
/ __| | |/ _` |/ _ \ '__| '_ \/ __| | '_ ` _ \
|
||||||
|
\__ \ | | (_| | __/ | | | | \__ \ | | | | | |
|
||||||
|
|___/_|_|\__,_|\___|_| |_| |_|___/_|_| |_| |_|
|
||||||
|
===============================================
|
|
@ -13,20 +13,25 @@ where
|
||||||
// https://stackoverflow.com/a/68950006
|
// https://stackoverflow.com/a/68950006
|
||||||
let to = to.as_ref().to_path_buf();
|
let to = to.as_ref().to_path_buf();
|
||||||
|
|
||||||
for path in fs::read_dir(from).unwrap() {
|
match fs::read_dir(from) {
|
||||||
let path = path.unwrap().path();
|
Ok(paths) => {
|
||||||
let to = to.clone().join(path.file_name().unwrap());
|
for path in paths {
|
||||||
|
let path = path.unwrap().path();
|
||||||
|
let to = to.clone().join(path.file_name().unwrap());
|
||||||
|
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
fs::copy(&path, to).unwrap();
|
fs::copy(&path, to).unwrap();
|
||||||
} else if path.is_dir() {
|
} else if path.is_dir() {
|
||||||
if !to.exists() {
|
if !to.exists() {
|
||||||
fs::create_dir(&to).unwrap();
|
fs::create_dir(&to).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_dir(&path, to);
|
||||||
|
} else { /* Skip other content */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_dir(&path, to);
|
|
||||||
} else { /* Skip other content */
|
|
||||||
}
|
}
|
||||||
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
@ -8,16 +8,14 @@ use hyper::{
|
||||||
Body, Method, Request, Response, Server, StatusCode,
|
Body, Method, Request, Response, Server, StatusCode,
|
||||||
};
|
};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use path_clean::PathClean;
|
use phf::phf_map;
|
||||||
use std::{convert::Infallible, env::current_exe, future::Future, net::SocketAddr};
|
use std::{convert::Infallible, future::Future, net::SocketAddr};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs::File,
|
|
||||||
select,
|
select,
|
||||||
sync::mpsc,
|
sync::mpsc,
|
||||||
time::{sleep, Duration},
|
time::{sleep, Duration},
|
||||||
};
|
};
|
||||||
use tokio_tungstenite::WebSocketStream;
|
use tokio_tungstenite::WebSocketStream;
|
||||||
use tokio_util::codec::{BytesCodec, FramedRead};
|
|
||||||
use tungstenite::{handshake, Message};
|
use tungstenite::{handshake, Message};
|
||||||
|
|
||||||
use crate::slider_io::{controller_state::FullState, worker::AsyncJob};
|
use crate::slider_io::{controller_state::FullState, worker::AsyncJob};
|
||||||
|
@ -33,23 +31,37 @@ async fn error_response() -> Result<Response<Body>, Infallible> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static x: &'static [u8] = include_bytes!("./brokenithm-www/favicon.ico");
|
||||||
|
|
||||||
|
static BROKENITHM_FILES: phf::Map<&'static str, &'static [u8]> = phf_map! {
|
||||||
|
"app.js" => include_bytes!("./brokenithm-www/app.js"),
|
||||||
|
"config.js" => include_bytes!("./brokenithm-www/config.js"),
|
||||||
|
"favicon.ico" => include_bytes!("./brokenithm-www/favicon.ico"),
|
||||||
|
"index-go.html" => include_bytes!("./brokenithm-www/index-go.html"),
|
||||||
|
"index.html" => include_bytes!("./brokenithm-www/index.html"),
|
||||||
|
};
|
||||||
|
|
||||||
async fn serve_file(path: &str) -> Result<Response<Body>, Infallible> {
|
async fn serve_file(path: &str) -> Result<Response<Body>, Infallible> {
|
||||||
let mut pb = current_exe().unwrap();
|
// let mut pb = current_exe().unwrap();
|
||||||
pb.pop();
|
// pb.pop();
|
||||||
pb.push("res/www");
|
// pb.push("res/www");
|
||||||
pb.push(path);
|
// pb.push(path);
|
||||||
pb.clean();
|
// pb.clean();
|
||||||
|
|
||||||
// println!("CWD {:?}", std::env::current_dir());
|
// // println!("CWD {:?}", std::env::current_dir());
|
||||||
|
|
||||||
match File::open(&pb).await {
|
// match File::open(&pb).await {
|
||||||
Ok(f) => {
|
// Ok(f) => {
|
||||||
info!("Serving file {:?}", pb);
|
// info!("Serving file {:?}", pb);
|
||||||
let stream = FramedRead::new(f, BytesCodec::new());
|
// let stream = FramedRead::new(f, BytesCodec::new());
|
||||||
let body = Body::wrap_stream(stream);
|
// let body = Body::wrap_stream(stream);
|
||||||
Ok(Response::new(body))
|
// Ok(Response::new(body))
|
||||||
}
|
// }
|
||||||
Err(_) => error_response().await,
|
// Err(_) => error_response().await,
|
||||||
|
// }
|
||||||
|
match BROKENITHM_FILES.get(path) {
|
||||||
|
Some(x) => Ok(Response::new(Body::from(*x))),
|
||||||
|
None => error_response().await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum DeviceMode {
|
||||||
pub enum OutputPolling {
|
pub enum OutputPolling {
|
||||||
Sixty,
|
Sixty,
|
||||||
Hundred,
|
Hundred,
|
||||||
ThreeHundred,
|
TwoHundredFifty,
|
||||||
FiveHundred,
|
FiveHundred,
|
||||||
Thousand,
|
Thousand,
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ impl OutputPolling {
|
||||||
match s {
|
match s {
|
||||||
"60" => Some(OutputPolling::Sixty),
|
"60" => Some(OutputPolling::Sixty),
|
||||||
"100" => Some(OutputPolling::Hundred),
|
"100" => Some(OutputPolling::Hundred),
|
||||||
"330" => Some(OutputPolling::ThreeHundred),
|
"250" => Some(OutputPolling::TwoHundredFifty),
|
||||||
"500" => Some(OutputPolling::FiveHundred),
|
"500" => Some(OutputPolling::FiveHundred),
|
||||||
"1000" => Some(OutputPolling::Thousand),
|
"1000" => Some(OutputPolling::Thousand),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -42,11 +42,11 @@ impl OutputPolling {
|
||||||
|
|
||||||
pub fn to_t_u64(&self) -> u64 {
|
pub fn to_t_u64(&self) -> u64 {
|
||||||
match self {
|
match self {
|
||||||
OutputPolling::Sixty => 16,
|
OutputPolling::Sixty => 16666,
|
||||||
OutputPolling::Hundred => 10,
|
OutputPolling::Hundred => 10000,
|
||||||
OutputPolling::ThreeHundred => 3,
|
OutputPolling::TwoHundredFifty => 4000,
|
||||||
OutputPolling::FiveHundred => 2,
|
OutputPolling::FiveHundred => 2000,
|
||||||
OutputPolling::Thousand => 1,
|
OutputPolling::Thousand => 1000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use palette::{FromColor, Hsv, Srgb};
|
||||||
use serialport::{ClearBuffer, SerialPort};
|
use serialport::{ClearBuffer, SerialPort};
|
||||||
use std::{
|
use std::{
|
||||||
ops::DerefMut,
|
ops::DerefMut,
|
||||||
thread,
|
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,7 +217,7 @@ impl ThreadJob for LedJob {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// thread::sleep(Duration::from_millis(30));
|
// thread::sleep(Duration::from_millis(30));
|
||||||
spin_sleep::sleep(Duration::from_millis(30));
|
spin_sleep::sleep(Duration::from_micros(33333));
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{thread, time::Duration};
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::slider_io::{
|
use crate::slider_io::{
|
||||||
config::OutputMode, controller_state::FullState, gamepad::GamepadOutput,
|
config::OutputMode, controller_state::FullState, gamepad::GamepadOutput,
|
||||||
|
@ -59,7 +59,7 @@ impl ThreadJob for OutputJob {
|
||||||
|
|
||||||
self.handler.tick(&flat_controller_state);
|
self.handler.tick(&flat_controller_state);
|
||||||
// thread::sleep(Duration::from_millis(self.t));
|
// thread::sleep(Duration::from_millis(self.t));
|
||||||
spin_sleep::sleep(Duration::from_millis(self.t));
|
spin_sleep::sleep(Duration::from_micros(self.t));
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"resources": [
|
"resources": [
|
||||||
"res/*"
|
"./README.txt"
|
||||||
],
|
],
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"copyright": "© 4yn 2022",
|
"copyright": "© 4yn 2022",
|
||||||
|
|
|
@ -202,7 +202,7 @@
|
||||||
<select bind:value={outputPolling} on:change={markDirty}>
|
<select bind:value={outputPolling} on:change={markDirty}>
|
||||||
<option value="60">60 Hz</option>
|
<option value="60">60 Hz</option>
|
||||||
<option value="100">100 Hz</option>
|
<option value="100">100 Hz</option>
|
||||||
<option value="330">330 Hz</option>
|
<option value="250">250 Hz</option>
|
||||||
<option value="500">500 Hz</option>
|
<option value="500">500 Hz</option>
|
||||||
<option value="1000">1000 Hz (Unstable, may use a lot of CPU)</option>
|
<option value="1000">1000 Hz (Unstable, may use a lot of CPU)</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue