-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
3,159 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"rust.target": "i686-pc-windows-msvc" | ||
"rust.target": "i686-pc-windows-msvc", | ||
"[html]": { | ||
"editor.formatOnSave": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
[package] | ||
name = "sbzdeck" | ||
version = "0.1.0" | ||
authors = ["Matthew Donoughe <mdonoughe@gmail.com>"] | ||
description = "Steam Deck plugin for Sound Blaster devices" | ||
repository = "https://github.com/mdonoughe/sbzdeck/" | ||
readme = "README.md" | ||
keywords = ["stream-deck", "sound-blaster"] | ||
license = "MIT/Apache-2.0" | ||
edition = "2018" | ||
[workspace] | ||
|
||
[badges] | ||
travis-ci = { repository = "mdonoughe/sbzdeck" } | ||
|
||
[dependencies] | ||
futures = "0.1.25" | ||
indexmap = "1.0" | ||
sbz-switch = "3.1" | ||
serde = "1.0" | ||
serde_derive = "1.0" | ||
serde_json = "1.0" | ||
slog = { version = "2.4", features = ["max_level_trace", "release_max_level_info"] } | ||
sloggers = "0.3" | ||
streamdeck-rs = { git = "https://github.com/mdonoughe/streamdeck-rs", branch = "sdk2" } | ||
tokio = "0.1.14" | ||
members = [ | ||
"common", | ||
"inspector", | ||
"plugin" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "common" | ||
version = "0.1.0" | ||
authors = ["Matthew Donoughe <mdonoughe@gmail.com>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
indexmap = { version = "1", features = ["serde-1"] } | ||
serde = "1" | ||
serde_derive = "1" | ||
serde_json = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use indexmap::{IndexMap, IndexSet}; | ||
use serde_derive::{Deserialize, Serialize}; | ||
use std::collections::{BTreeMap, BTreeSet}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(tag = "event", rename_all = "camelCase")] | ||
pub enum FromInspector { | ||
GetFeatures, | ||
#[serde(rename_all = "camelCase")] | ||
SetFeatures { | ||
selected_parameters: BTreeMap<String, BTreeSet<String>>, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(tag = "event", rename_all = "camelCase")] | ||
pub enum ToInspector { | ||
#[serde(rename_all = "camelCase")] | ||
SetFeatures { | ||
selected_parameters: IndexMap<String, IndexMap<String, bool>>, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize, Serialize)] | ||
pub struct SerdeProfile { | ||
pub volume: Option<f32>, | ||
#[serde(default)] | ||
pub parameters: BTreeMap<String, BTreeMap<String, serde_json::Value>>, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize, Serialize)] | ||
pub struct SerdeProfiles { | ||
#[serde(default)] | ||
pub headphones: SerdeProfile, | ||
#[serde(default)] | ||
pub speakers: SerdeProfile, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize, Serialize)] | ||
pub struct SerdeCardSettings { | ||
#[serde(default)] | ||
pub selected_parameters: IndexMap<String, IndexSet<String>>, | ||
#[serde(default)] | ||
pub profiles: SerdeProfiles, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize, Serialize)] | ||
pub struct Empty {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "inspector" | ||
version = "0.1.0" | ||
authors = ["Matthew Donoughe <mdonoughe@gmail.com>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
common = { path = "../common" } | ||
indexmap = "1.0" | ||
serde = "1" | ||
serde_derive = "1" | ||
serde_json = "1" | ||
stdweb = "0.4" | ||
yew = "0.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use super::parameter::Parameter; | ||
use indexmap::IndexMap; | ||
use stdweb::traits::IEvent; | ||
use yew::prelude::*; | ||
use yew::virtual_dom::VNode; | ||
|
||
#[derive(Clone, Default, PartialEq)] | ||
pub struct Properties { | ||
pub name: String, | ||
pub is_expanded: bool, | ||
pub parameters: IndexMap<String, bool>, | ||
pub onexpandchange: Option<Callback<bool>>, | ||
pub onchange: Option<Callback<(String, bool)>>, | ||
} | ||
|
||
pub struct Feature { | ||
name: String, | ||
is_expanded: bool, | ||
parameters: IndexMap<String, bool>, | ||
onexpandchange: Option<Callback<bool>>, | ||
onchange: Option<Callback<(String, bool)>>, | ||
} | ||
|
||
pub enum Message { | ||
Toggle, | ||
SetParameter { name: String, is_selected: bool }, | ||
} | ||
|
||
impl Component for Feature { | ||
type Message = Message; | ||
type Properties = Properties; | ||
|
||
fn create(properties: Self::Properties, _link: ComponentLink<Self>) -> Self { | ||
Self { | ||
name: properties.name, | ||
is_expanded: properties.is_expanded, | ||
parameters: properties.parameters, | ||
onexpandchange: properties.onexpandchange, | ||
onchange: properties.onchange, | ||
} | ||
} | ||
|
||
fn update(&mut self, message: Self::Message) -> ShouldRender { | ||
match message { | ||
Message::Toggle => { | ||
if let Some(ref mut callback) = self.onexpandchange { | ||
callback.emit(!self.is_expanded); | ||
} | ||
} | ||
Message::SetParameter { name, is_selected } => { | ||
if let Some(ref mut callback) = self.onchange { | ||
callback.emit((name, is_selected)); | ||
} | ||
} | ||
} | ||
false | ||
} | ||
|
||
fn change(&mut self, properties: Self::Properties) -> ShouldRender { | ||
let changed = self.name != properties.name | ||
|| self.is_expanded != properties.is_expanded | ||
|| self.parameters != properties.parameters; | ||
self.name = properties.name; | ||
self.is_expanded = properties.is_expanded; | ||
self.parameters = properties.parameters; | ||
self.onchange = properties.onchange; | ||
self.onexpandchange = properties.onexpandchange; | ||
changed | ||
} | ||
} | ||
|
||
impl Renderable<Feature> for Feature { | ||
fn view(&self) -> Html<Self> { | ||
let mut tag = html! { | ||
<details> | ||
<summary onclick=|e| { e.prevent_default(); Message::Toggle },>{ &self.name }</summary> | ||
// capitalize `type` because otherwise yew eats it | ||
<div Type="checkbox", class="sdpi-item",> | ||
<div class="sdpi-item-value min100",> | ||
{ for self.parameters.iter().map(|(name, is_selected)| { | ||
let cb_name = name.clone(); | ||
html! { | ||
<Parameter: name=name, is_selected=is_selected, onchange=move |is_selected| { Message::SetParameter { name: cb_name.clone(), is_selected } }, /> | ||
} | ||
}) } | ||
</div> | ||
</div> | ||
</details> | ||
}; | ||
if self.is_expanded { | ||
if let VNode::VTag(ref mut vtag) = tag { | ||
vtag.add_attribute("open", &""); | ||
} | ||
} | ||
tag | ||
} | ||
} |
Oops, something went wrong.