formatting
This commit is contained in:
parent
eeb5727f55
commit
708980b6f8
|
@ -6,6 +6,7 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/chuniio-tasoller-chusan/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/chuniio-tasoller-common/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/chuniio-tasoller-chuni/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/vendor/shared_memory/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/vendor/shared_memory/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/vendor/shared_memory/tests" isTestSource="true" />
|
||||
|
|
14
Cargo.toml
14
Cargo.toml
|
@ -1,7 +1,19 @@
|
|||
[workspace]
|
||||
members = ["chuniio-tasoller-amdaemon", "chuniio-tasoller-chusan", "chuniio-tasoller-common", "vendor/shared_memory"]
|
||||
members = [
|
||||
"chuniio-tasoller-amdaemon",
|
||||
"chuniio-tasoller-chuni",
|
||||
"chuniio-tasoller-chusan",
|
||||
"chuniio-tasoller-common"
|
||||
]
|
||||
exclude = ["vendor"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0.75"
|
||||
log = "0.4.20"
|
||||
rusb = "0.9.3"
|
||||
winapi = "0.3.9"
|
||||
|
||||
[profile.release]
|
||||
strip = true # Automatically strip symbols from the binary.
|
||||
opt-level = "z" # Optimize for size.
|
||||
|
|
|
@ -8,9 +8,9 @@ edition = "2021"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
anyhow = { workspace = true }
|
||||
chuniio-tasoller-common = { path = "../chuniio-tasoller-common" }
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.20"
|
||||
rusb = "0.9.3"
|
||||
winapi = { version = "0.3.9", features = ["ntdef", "winbase", "winerror", "minwindef", "winuser"] }
|
||||
log = { workspace = true }
|
||||
rusb = { workspace = true }
|
||||
winapi = { workspace = true, features = ["ntdef", "winbase", "winerror", "minwindef", "winuser"] }
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
mod configuration;
|
||||
|
||||
use crate::configuration::Configuration;
|
||||
use chuniio_tasoller_common::create_input_shared_memory;
|
||||
use chuniio_tasoller_common::log::init_logger;
|
||||
use std::{
|
||||
ffi::{c_int, c_void, CString},
|
||||
sync::atomic::{AtomicBool, AtomicU16, Ordering},
|
||||
};
|
||||
|
||||
use chuniio_tasoller_common::{create_input_shared_memory, log::init_logger};
|
||||
use lazy_static::lazy_static;
|
||||
use std::ffi::{c_int, c_void, CString};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU16, Ordering};
|
||||
use winapi::shared::minwindef::{BOOL, DWORD, HINSTANCE, LPVOID, TRUE};
|
||||
use winapi::shared::ntdef::HRESULT;
|
||||
use winapi::shared::winerror::S_OK;
|
||||
use winapi::um::winbase::GetPrivateProfileIntA;
|
||||
use winapi::um::winnt::DLL_PROCESS_ATTACH;
|
||||
use winapi::um::winuser::GetAsyncKeyState;
|
||||
use winapi::{
|
||||
shared::{
|
||||
minwindef::{BOOL, DWORD, HINSTANCE, LPVOID, TRUE},
|
||||
winerror::{HRESULT, S_OK},
|
||||
},
|
||||
um::{winbase::GetPrivateProfileIntA, winnt::DLL_PROCESS_ATTACH, winuser::GetAsyncKeyState},
|
||||
};
|
||||
|
||||
use crate::configuration::Configuration;
|
||||
|
||||
static COIN_COUNT: AtomicU16 = AtomicU16::new(0);
|
||||
static COIN_PRESSED: AtomicBool = AtomicBool::new(false);
|
||||
|
|
|
@ -8,8 +8,8 @@ edition = "2021"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
anyhow = { workspace = true }
|
||||
chuniio-tasoller-common = { path = "../chuniio-tasoller-common" }
|
||||
log = "0.4.20"
|
||||
rusb = "0.9.3"
|
||||
winapi = { version = "0.3.9", features = ["ntdef", "winerror", "minwindef"] }
|
||||
log = { workspace = true }
|
||||
rusb = { workspace = true }
|
||||
winapi = { workspace = true, features = ["ntdef", "winerror", "minwindef", "winnt"] }
|
|
@ -1,25 +1,26 @@
|
|||
use std::ffi::c_void;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
use std::thread;
|
||||
use std::thread::JoinHandle;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
ffi::c_void,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
OnceLock,
|
||||
},
|
||||
thread::{self, JoinHandle},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use chuniio_tasoller_common::{create_input_shared_memory, log::init_logger};
|
||||
use log::{error, info, warn};
|
||||
use rusb::{DeviceHandle, GlobalContext};
|
||||
use winapi::{
|
||||
shared::{
|
||||
minwindef::{BOOL, DWORD, HINSTANCE, LPVOID, TRUE},
|
||||
ntdef::HRESULT,
|
||||
winerror::S_OK,
|
||||
winerror::{E_FAIL, S_OK},
|
||||
},
|
||||
um::winnt::DLL_PROCESS_ATTACH,
|
||||
};
|
||||
|
||||
use chuniio_tasoller_common::{create_input_shared_memory, log::init_logger};
|
||||
use log::{error, info, warn};
|
||||
use winapi::shared::winerror::E_FAIL;
|
||||
|
||||
type SliderCallbackFn = unsafe extern "C" fn(data: *const u8);
|
||||
|
||||
static TASOLLER: OnceLock<DeviceHandle<GlobalContext>> = OnceLock::new();
|
||||
|
|
|
@ -6,9 +6,8 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
anyhow = { workspace = true }
|
||||
env_logger = { version = "0.10.1", default-features = false }
|
||||
log = "0.4.20"
|
||||
rusb = "0.9.3"
|
||||
log = { workspace = true }
|
||||
shared_memory = { path = "../vendor/shared_memory" }
|
||||
winapi = { version = "0.3.9", features = ["debugapi"] }
|
||||
winapi = { workspace = true, features = ["debugapi"] }
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
use std::ffi::CString;
|
||||
use std::io::Write;
|
||||
use winapi::um::debugapi::OutputDebugStringA;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Logger {}
|
||||
|
||||
impl Write for Logger {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
if let Ok(c_str) = CString::new(buf) {
|
||||
unsafe { OutputDebugStringA(c_str.as_ptr()) }
|
||||
}
|
||||
|
||||
std::io::stdout().write(buf)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
std::io::stdout().flush()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_logger() {
|
||||
env_logger::builder()
|
||||
.filter_level(::log::LevelFilter::Error)
|
||||
.filter_module(
|
||||
"chuniio-tasoller",
|
||||
if cfg!(debug_assertions) {
|
||||
::log::LevelFilter::Debug
|
||||
} else {
|
||||
::log::LevelFilter::Info
|
||||
},
|
||||
)
|
||||
.parse_default_env()
|
||||
.target(env_logger::Target::Pipe(Box::new(Logger {})))
|
||||
.format(|f, record| {
|
||||
let target = record.target();
|
||||
let level = record.level();
|
||||
|
||||
writeln!(f, "{} {} -> {}", level, target, record.args())
|
||||
})
|
||||
.init();
|
||||
}
|
||||
use std::{ffi::CString, io::Write};
|
||||
|
||||
use winapi::um::debugapi::OutputDebugStringA;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Logger {}
|
||||
|
||||
impl Write for Logger {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
if let Ok(c_str) = CString::new(buf) {
|
||||
unsafe { OutputDebugStringA(c_str.as_ptr()) }
|
||||
}
|
||||
|
||||
std::io::stdout().write(buf)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
std::io::stdout().flush()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_logger() {
|
||||
env_logger::builder()
|
||||
.filter_level(::log::LevelFilter::Error)
|
||||
.filter_module(
|
||||
"chuniio-tasoller",
|
||||
if cfg!(debug_assertions) {
|
||||
::log::LevelFilter::Debug
|
||||
} else {
|
||||
::log::LevelFilter::Info
|
||||
},
|
||||
)
|
||||
.parse_default_env()
|
||||
.target(env_logger::Target::Pipe(Box::new(Logger {})))
|
||||
.format(|f, record| {
|
||||
let target = record.target();
|
||||
let level = record.level();
|
||||
|
||||
writeln!(f, "{} {} -> {}", level, target, record.args())
|
||||
})
|
||||
.init();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
imports_granularity = "Crate"
|
||||
reorder_imports = true
|
||||
group_imports = "StdExternalCrate"
|
Reference in New Issue