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