Skip to content

Commit

Permalink
VibeCheck 0.4.0 merge - Toy support / Input processors / Multi param …
Browse files Browse the repository at this point in the history
…/ etc (#54)

* SPS processing

* strum enum string

* clippy

* dedent handling, create inline functions

* Fix early toy thread exit bug

* Rename OSC MSG processor routine

* Progress SPS Input Processor

* SPS logic for length calculation and feature level calculation.

* Mapping module

* simplify some logic

* Length calculation and debugging/testing

* Sps processing UI (#52)

* move input processor out of advanced

* change tooltip to enable/disable app

* change idle to idle speed

* fix feature option alignment

* normalize osc_parameter for backend

* use key for featureform instead of useEffect

* Length calculation

* Random cleanup

* Implement SPS Touch support

* Fix rate level slider

* Basic TPS processing

* use const object for enum

* add debounce on osc_param input

* Version 0.4.0 Beta

* SPS Touch/Frot/Legacy support

* Add check in case of possible OOB

* fix spacing, add inset around config/features

* fix as const

* re-fix rate level slider

* Advanced config options (#53)

* refactor featureform into context, modular components

* add advanced config options

* refactor core events into context

* add advanced option hide/show

* scrollbar visible on hover parent

* Input processor tooltip

* use tooltip enum, add wiki links

* show level tweaks only when mode is selected

* slider gutters

* Sutekh likes binary oops

---------

Co-authored-by: SutekhVRC <sutekhvrc@gmail.com>
Co-authored-by: TuTiDore <tutidore@gmail.com>
Co-authored-by: TuTiDore <113271459+TuTiDore@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 3, 2024
1 parent bd248d0 commit ed672e6
Show file tree
Hide file tree
Showing 40 changed files with 1,979 additions and 1,189 deletions.
6 changes: 5 additions & 1 deletion src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vibecheck"
version = "0.3.2"
version = "0.4.0"
edition = "2021"
authors = ["SutekhVRC"]
rust-version = "1.57"
Expand Down Expand Up @@ -33,7 +33,7 @@ env_logger = "0.10.0"
open = "3.2.0"
dyn-clone = "1.0.16"
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }

strum = { version="0.25.0", features = ["derive"] }
# Tauri dependencies
tauri = { version = "1.5.2", features = ["api-all", "system-tray", "updater"] }
[features]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type FeSocialLink = "Github" | "VRChatGroup" | "Discord";
export type FeBrowserLink = "Github" | "VRChatGroup" | "Discord" | "ToyOptions" | "FeatureOptions";
2 changes: 1 addition & 1 deletion src-tauri/bindings/FeVibeCheckConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeOSCNetworking } from "./FeOSCNetworking";

export interface FeVibeCheckConfig { networking: FeOSCNetworking, scan_on_disconnect: boolean, minimize_on_exit: boolean, desktop_notifications: boolean, lc_override: string | null, }
export interface FeVibeCheckConfig { networking: FeOSCNetworking, scan_on_disconnect: boolean, minimize_on_exit: boolean, desktop_notifications: boolean, lc_override: string | null, show_toy_advanced: boolean, show_feature_advanced: boolean, }
22 changes: 16 additions & 6 deletions src-tauri/src/frontend/frontend_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
config::toy::VCToyConfig,
frontend::{
frontend_types::{
FeSocialLink, FeToyAlter, FeToyEvent, FeVCFeatureType, FeVCToy, FeVibeCheckConfig,
FeBrowserLink, FeToyAlter, FeToyEvent, FeVCFeatureType, FeVCToy, FeVibeCheckConfig,
},
FromFrontend, ToFrontend,
},
Expand All @@ -27,7 +27,7 @@ use tauri::Manager;
*/
#[tauri::command]
pub fn vibecheck_version(app_handle: tauri::AppHandle) -> String {
format!("{} windows", app_handle.package_info().version)
format!("{}-beta windows", app_handle.package_info().version)
}

/*
Expand Down Expand Up @@ -246,17 +246,27 @@ pub fn alter_toy(
* Opens the social link specified
*/
#[tauri::command(async)]
pub fn open_default_browser(link: FeSocialLink) {
pub fn open_default_browser(link: FeBrowserLink) {
match link {
FeSocialLink::Discord => {
FeBrowserLink::Discord => {
let _ = open::that("https://discord.gg/g6kUFtMtpw");
}
FeSocialLink::Github => {
FeBrowserLink::Github => {
let _ = open::that("https://github.com/SutekhVRC/VibeCheck");
}
FeSocialLink::VRChatGroup => {
FeBrowserLink::VRChatGroup => {
let _ = open::that("https://vrc.group/VIBE.9503");
}
FeBrowserLink::ToyOptions => {
let _ = open::that(
"https://github.com/SutekhVRC/VibeCheck/wiki/Toy-Options-List#toy-options",
);
}
FeBrowserLink::FeatureOptions => {
let _ = open::that(
"https://github.com/SutekhVRC/VibeCheck/wiki/Toy-Options-List#toy-feature-options",
);
}
};
}

Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/frontend/frontend_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct FeVibeCheckConfig {
pub minimize_on_exit: bool,
pub desktop_notifications: bool,
pub lc_override: Option<String>,
pub show_toy_advanced: bool,
pub show_feature_advanced: bool,
}

#[derive(Deserialize, Serialize, Debug, Clone, TS)]
Expand Down Expand Up @@ -64,10 +66,12 @@ pub enum FeCoreEvent {

#[derive(Deserialize, Clone, TS)]
#[ts(export)]
pub enum FeSocialLink {
pub enum FeBrowserLink {
Github,
VRChatGroup,
Discord,
ToyOptions,
FeatureOptions,
}

#[derive(Serialize, Deserialize, Clone, TS, Debug)]
Expand Down Expand Up @@ -229,8 +233,4 @@ impl PartialEq<VCFeatureType> for FeVCFeatureType {
fn eq(&self, other: &VCFeatureType) -> bool {
*self as u32 == *other as u32
}

fn ne(&self, other: &VCFeatureType) -> bool {
!self.eq(other)
}
}
43 changes: 21 additions & 22 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,27 @@ fn main() {

app.run(|_app_handle, event| {
match event {
tauri::RunEvent::WindowEvent { label, event, .. } => {
match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
let minimize_on_exit = {
_app_handle
.state::<vcore::core::VCStateMutex>()
.0
.lock()
.config
.minimize_on_exit
};

if minimize_on_exit {
let window = _app_handle.get_window(&label).unwrap();
trace!("Closing window: {}", window.label());
window.hide().unwrap();
api.prevent_close();
} else {
// Let exit
}
}
_ => {}
tauri::RunEvent::WindowEvent {
label,
event: tauri::WindowEvent::CloseRequested { api, .. },
..
} => {
let minimize_on_exit = {
_app_handle
.state::<vcore::core::VCStateMutex>()
.0
.lock()
.config
.minimize_on_exit
};

if minimize_on_exit {
let window = _app_handle.get_window(&label).unwrap();
trace!("Closing window: {}", window.label());
window.hide().unwrap();
api.prevent_close();
} else {
// Let exit
}
}
tauri::RunEvent::ExitRequested { .. } => {
Expand Down
29 changes: 8 additions & 21 deletions src-tauri/src/osc/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ pub fn toy_input_routine(
// Send address and arg to broadcast channel
// Die when channel disconnects

if vibecheck_osc_api(&bind_sock, &app_handle, &toy_bcst_tx) {
continue;
} else {
if !vibecheck_osc_api(&bind_sock, &app_handle, &toy_bcst_tx) {
return;
}
}
Expand Down Expand Up @@ -111,7 +109,7 @@ pub async fn vc_disabled_osc_command_listen(app_handle: AppHandle, vc_config: OS
}
};

if br <= 0 {
if br == 0 {
continue;
} else {
let pkt = match rosc::decoder::decode_udp(&buf) {
Expand Down Expand Up @@ -152,24 +150,13 @@ pub fn recv_osc_cmd(sock: &UdpSocket) -> Option<OscMessage> {
}
};

if br <= 0 {
if br == 0 {
return None;
} else {
let pkt = match rosc::decoder::decode_udp(&buf) {
Ok(pkt) => pkt,
Err(_e) => {
return None;
}
};

match pkt.1 {
OscPacket::Message(msg) => {
return Some(msg);
}
_ => {
return None;
}
}
}
let pkt = rosc::decoder::decode_udp(&buf).ok()?;
match pkt.1 {
OscPacket::Message(msg) => Some(msg),
_ => None,
}
}

Expand Down
108 changes: 52 additions & 56 deletions src-tauri/src/osc_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,69 +12,65 @@ impl APIProcessor {
pub fn parse(mut endpoint: OscMessage, app_handle: &AppHandle) {
let mut api_tokenize = endpoint
.addr
.split("/")
.split('/')
.map(|t| t.to_string())
.collect::<Vec<String>>();
api_tokenize.retain(|token| token.len() > 0);
api_tokenize.retain(|token| !token.is_empty());
debug!("[*] API tokenization: {:?}", api_tokenize);
if api_tokenize.len() == 5 {
if api_tokenize[2] == "vibecheck" && api_tokenize[3] == "api" {
if api_tokenize[4] == "state" {
// /avatar/parameters/vibecheck/api/state
if let Some(state_bool) = endpoint.args.pop().unwrap().bool() {
if !state_bool {
info!("State false: Sending Disable event");
let _ = app_handle.emit_all(
"fe_core_event",
FeCoreEvent::State(
crate::frontend::frontend_types::FeStateEvent::Disable,
),
if api_tokenize.len() == 5
&& api_tokenize[2] == "vibecheck"
&& api_tokenize[3] == "api"
&& api_tokenize[4] == "state"
{
// /avatar/parameters/vibecheck/api/state
let Some(false) = endpoint.args.pop().unwrap().bool() else {
return;
};
info!("State false: Sending Disable event");
let _ = app_handle.emit_all(
"fe_core_event",
FeCoreEvent::State(crate::frontend::frontend_types::FeStateEvent::Disable),
);
} else if api_tokenize.len() == 7
&& api_tokenize[4] == "anatomy"
&& api_tokenize[6] == "enabled"
{
// /avatar/parameters/vibecheck/api/anatomy/Anal/enabled
trace!("[*] Checking anatomy token: {}", api_tokenize[5]);
let anatomy = VCToyAnatomy::get_anatomy(&api_tokenize[5]);
let mut altered_toys = Vec::new();

if let Some(state_bool) = endpoint.args.pop().unwrap().bool() {
let vc_pointer = app_handle
.state::<crate::vcore::core::VCStateMutex>()
.0
.clone();
let mut vc_lock = vc_pointer.lock();

vc_lock
.core_toy_manager
.as_mut()
.unwrap()
.online_toys
.iter_mut()
.for_each(|toy| {
if toy.1.mutate_state_by_anatomy(&anatomy, state_bool) {
trace!(
"[*] Mutating feature state from anatomy for toy: {}",
toy.1.toy_name
);
altered_toys.push(toy.1.clone());
}
}
}
});
}
} else if api_tokenize.len() == 7 {
if api_tokenize[4] == "anatomy" && api_tokenize[6] == "enabled" {
// /avatar/parameters/vibecheck/api/anatomy/Anal/enabled

trace!("[*] Checking anatomy token: {}", api_tokenize[5]);

let anatomy = VCToyAnatomy::get_anatomy(&api_tokenize[5]);
let mut altered_toys = Vec::new();

if let Some(state_bool) = endpoint.args.pop().unwrap().bool() {
let vc_pointer = app_handle
.state::<crate::vcore::core::VCStateMutex>()
.0
.clone();
let mut vc_lock = vc_pointer.lock();

vc_lock
.core_toy_manager
.as_mut()
.unwrap()
.online_toys
.iter_mut()
.for_each(|toy| {
if toy.1.mutate_state_by_anatomy(&anatomy, state_bool) {
trace!(
"[*] Mutating feature state from anatomy for toy: {}",
toy.1.toy_name
);
altered_toys.push(toy.1.clone());
}
});
}

altered_toys.iter().for_each(|toy| {
let _ = vcore::core::native_alter_toy(
app_handle.state::<crate::vcore::core::VCStateMutex>(),
app_handle.clone(),
toy.clone(),
);
});
}
altered_toys.iter().for_each(|toy| {
let _ = vcore::core::native_alter_toy(
app_handle.state::<crate::vcore::core::VCStateMutex>(),
app_handle.clone(),
toy.clone(),
);
});
}
}
}
Loading

0 comments on commit ed672e6

Please sign in to comment.