Skip to content

Commit

Permalink
rokid max の anyhow を thiserror に変更 (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitoma authored Dec 27, 2024
1 parent 6df7d6c commit f3b7d14
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 49 deletions.
65 changes: 43 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
resolver = "2"

[workspace.dependencies]
thiserror = "2.0"
anyhow = "1.0"
wgpu = "23.0.0"
# fork元は winit = "0.29.x" ブランチ。いくつかのパッチを当てたものを使っている。
Expand Down
2 changes: 1 addition & 1 deletion kashikishi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl KashikishiCallback {
let _ = self
.rokid_max_action
.lock()
.map(|mut rokid_max_action| rokid_max_action.reset());
.map(|rokid_max_action| rokid_max_action.reset());
world.look_current(CameraAdjustment::FitBothAndCentering)
}
_ => {}
Expand Down
10 changes: 6 additions & 4 deletions kashikishi/src/rokid_max_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ impl RokidMaxAction {
}
}

pub fn reset(&mut self) {
let _ = self.rokid_max.as_mut().and_then(|r| r.reset().ok());
pub fn reset(&self) {
if let Some(max) = self.rokid_max.as_ref() {
max.reset()
};
}

pub fn quaternion(&self) -> Option<Quaternion<f32>> {
Expand Down Expand Up @@ -55,12 +57,12 @@ impl NamespaceActionProcessors for RokidMaxAction {
match command_name.as_str() {
"reset" => {
if let Some(rokid_max) = self.rokid_max.as_mut() {
let _ = rokid_max.reset();
rokid_max.reset();
}
}
"toggle-mode" => {
if let Some(rokid_max) = self.rokid_max.as_mut() {
let _ = rokid_max.reset();
rokid_max.reset();
world.camera_operation(CameraOperation::UpdateEyeQuaternion(Some(
rokid_max.quaternion(),
)));
Expand Down
3 changes: 2 additions & 1 deletion rokid_3dof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow.workspace = true
thiserror.workspace = true
bytemuck.workspace = true
cgmath.workspace = true
hidapi = "2.6.1"
Expand All @@ -16,6 +16,7 @@ font_rasterizer = { path = "../font_rasterizer" }
font_collector = { path = "../font_collector" }
stroke_parser = { path = "../stroke_parser" }
ui_support = { path = "../ui_support" }
anyhow.workspace = true
log.workspace = true
instant.workspace = true
winit.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion rokid_3dof/examples/rokid_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl SimpleStateCallback for SingleCharCallback {
button: MouseButton::Right,
..
} => {
self.rokid_max.reset().unwrap();
self.rokid_max.reset();
InputResult::InputConsumed
}
WindowEvent::MouseInput {
Expand Down
2 changes: 0 additions & 2 deletions rokid_3dof/src/main.rs → rokid_3dof/examples/sensor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ use rokid_3dof::RokidMax;

fn main() -> anyhow::Result<()> {
let rokid_max = RokidMax::new()?;

loop {
println!("{:?}", rokid_max.quaternion());

thread::sleep(Duration::from_millis(1000));
}
//Ok(())
}
Loading

0 comments on commit f3b7d14

Please sign in to comment.