diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a30d25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/LICENSE b/LICENSE index a4e0732..a8fe6c6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2022 Sayamame-beans +Copyright (c) 2023 Spokeek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 30266c0..e308efa 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,33 @@ -# VRC_AFK_AutoMuter -"VRChat"にて、AFK移行時に自動でミュートするOSCツールです。 +# VRC AFK AutoMuter -## 開発環境と動作確認済み環境について +## Description -- Windows 10 -- Python 3.9.2 - - python-osc 1.8.0 +This is an OSC tool that automatically mutes when AFK in VRChat. -## OSCの有効化 -![OSC_Check](https://user-images.githubusercontent.com/61457993/156496589-605564a4-7db0-4e05-9d25-763fbffce67e.png) +## References -## 使い方 -Releasesページ、またはBoothにてexeファイルを配布しています。 -これを実行することで、VRChat標準の設定を基準に動作を開始します。 -(IP:127.0.0.1, VRChat側受信ポート:9000, VRChat側送信ポート9001) +This project only exists thanks to the previous work of [Sayamame-beans](https://github.com/Sayamame-beans) on their own project at -起動後は自動的に動作し、AFK移行時にミュートします。 -あくまでAFK移行時にミュートするので、AFK移行後にミュートを外しても、自動でミュートされる事はありません。 +If you need a dedicated app instead of a VRC OSC Integration, go check out their project. -注意点として、**VRC起動後に本ツールを起動した場合、ミュートの初期状態が不明なため、誤ってミュートが外されてしまう場合があります**。 -この場合については、数秒後に自動的にミュートされるはずです。 +## Integration -なお、初回実行時にセキュリティの警告が出るかもしれません。信頼出来ないなと思った場合は使用しないことをお勧めします。 -(信頼出来ないexeファイルは無闇に実行するべきではありませんので…) +This project is developped as a module for VRC_OSC project, an aggregator of OSC projects to be run easily from one place. -## オプションについて -`-h`オプションを付けて実行すると、他のオプションについての説明が得られます。ここではその説明文を引用します。 -``` -usage: VRC_AFK_AutoMuter.exe [-h] [--tx_ip TX_IP] [--tx_port TX_PORT] [--rx_ip RX_IP] [--rx_port RX_PORT] +Please refer to the project page to install the application. -This is an OSC tool that automatically mutes when AFK in VRChat. +For now the app needs to be added manually but my be available from the app list in the future. + +## Manual installation + +Please dowload the latest build from the release page and add the file to the VRC OSC Data folder `%appdata%\Roaming\VRCOSC\assemblies` (after installing VRCOSC of course) + +## Manual Build / Modification + +This project is under MIT Liscence, so you can always modify it yourself, but try to refer to previous creators work if needed. + +The project is configured to add the binary after a local build, so no need do extra work on that part. + +## Feedback -optional arguments: - -h, --help show this help message and exit - --tx_ip TX_IP Destination IP address. (Default: "127.0.0.1") - --tx_port TX_PORT Destination Port. (Default: 9000) - --rx_ip RX_IP Source IP address. (Default: "127.0.0.1") - --rx_port RX_PORT Source IP address. (Default: 9001) -``` - -## ライセンスについて -MITライセンスです。 -大雑把に言うと、使用用途自由で、商用利用も可能、改造も可能。 -ただし、改造の有無にかかわらず、再配布する場合はライセンスファイルの同梱と著作権表示(`Copyright (c) 2022 Sayamame-beans`)をしてください、という感じです。 +If you have some feedback or require some additional features on that, feel free to create issues or suggest modifications through PRs. diff --git a/VRC_AFK_AutoMuter.sln b/VRC_AFK_AutoMuter.sln new file mode 100644 index 0000000..2e1058b --- /dev/null +++ b/VRC_AFK_AutoMuter.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29409.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VRC_AFK_AutoMuterModule", "VRC_AFK_AutoMuterModule\VRC_AFK_AutoMuterModule.csproj", "{AEB3FC89-DC3E-4BC9-9EC7-03B72FC5D849}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AEB3FC89-DC3E-4BC9-9EC7-03B72FC5D849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEB3FC89-DC3E-4BC9-9EC7-03B72FC5D849}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEB3FC89-DC3E-4BC9-9EC7-03B72FC5D849}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEB3FC89-DC3E-4BC9-9EC7-03B72FC5D849}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.cs b/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.cs new file mode 100644 index 0000000..cc11d18 --- /dev/null +++ b/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.cs @@ -0,0 +1,23 @@ +using VRCOSC.Game.Modules; +using VRCOSC.Game.Modules.Avatar; + +namespace VRC_AFK_AutoMuterModule +{ + [ModuleTitle("VRC AFK AutoMuter")] + [ModuleDescription("An OSC tool that automatically mutes when AFK in VRChat.")] + [ModuleAuthor("Spokeek", "https://shelter.moe/@spokeek", "https://avatars.githubusercontent.com/u/4519853")] + [ModuleGroup(ModuleType.General)] + [ModuleInfo("This project is OpenSource and available on Github.", "https://github.com/Spokeek/VRC_AFK_AutoMuter")] + [ModuleInfo("It is based on an existing project by Sayamame-beans also on Github.", "https://github.com/Sayamame-beans/VRC_AFK_AutoMuter")] + public partial class VRC_AFK_AutoMuterModule : AvatarModule + { + protected override void OnPlayerUpdate() + { + // Enable MuteSelf if Player goes in AFK state + if (Player.AFK.GetValueOrDefault(false)) + { + SendParameter("MuteSelf", 1); + } + } + } +} diff --git a/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.csproj b/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.csproj new file mode 100644 index 0000000..24ab7e8 --- /dev/null +++ b/VRC_AFK_AutoMuterModule/VRC_AFK_AutoMuterModule.csproj @@ -0,0 +1,17 @@ + + + + net6.0-windows10.0.22621.0 + enable + enable + + + + + + + + + + + diff --git a/auto_muter.py b/auto_muter.py deleted file mode 100644 index 52da3e0..0000000 --- a/auto_muter.py +++ /dev/null @@ -1,87 +0,0 @@ -import argparse -import threading -import time -from pythonosc import osc_server -from pythonosc import udp_client -from pythonosc.dispatcher import Dispatcher - -class AutoMuter: - VERSION = "0.1.1" - DEFAULT_OSC_TX_IP = "127.0.0.1" - DEFAULT_OSC_TX_PORT = 9000 - DEFAULT_OSC_RX_IP = "127.0.0.1" - DEFAULT_OSC_RX_PORT = 9001 - - def __init__(self, tx_ip:str, tx_port:int, rx_ip:str, rx_port:int) -> None: - self._event = threading.Event() - self._event.set() - - self.tx_ip = tx_ip if tx_ip else self.DEFAULT_OSC_TX_IP - self.tx_port = tx_port if tx_port else self.DEFAULT_OSC_TX_PORT - self.rx_ip = rx_ip if rx_ip else self.DEFAULT_OSC_RX_IP - self.rx_port = rx_port if rx_port else self.DEFAULT_OSC_RX_PORT - self.last_afk = False - self.last_muteself = False - self.first_mute = True - - #OSC Client Initialization - self.client = udp_client.SimpleUDPClient(self.tx_ip, self.tx_port) - - #OSC Server Initialization - self.dispatcher = Dispatcher() - self.dispatcher.map("/avatar/parameters/AFK", self.update_afk) - self.dispatcher.map("/avatar/parameters/MuteSelf", self.update_muteself) - self.server = osc_server.BlockingOSCUDPServer((self.rx_ip, self.rx_port), self.dispatcher) - - def run(self) -> None: - self.server.serve_forever() - - def update_afk(self, path: str, value: bool) -> None: - self.last_afk = value - if value: - thread = threading.Thread(target=self.mute) - thread.setDaemon(True) - thread.start() - - def update_muteself(self, path: str, value: bool) -> None: - self.last_muteself = value - if(self.first_mute): - if(self.last_afk and not value): - self.update_afk("/avatar/parameters/AFK", True) - self.first_mute = False - -# Q: Why does time.sleep(1) exist? -# A: Because of the input lag of VRChat. -# If you know the FPS value that basically never falls in your environment, you can reduce the wait time. - def mute(self) -> None: - if not self._event.is_set: - self._event.wait() - self._event.clear() - if not self.last_muteself: - self.client.send_message("/input/Voice", 0) - time.sleep(1) - self.client.send_message("/input/Voice", 1) - time.sleep(1) - self.client.send_message("/input/Voice", 0) - self._event.set() - -if __name__ == "__main__": - print(f"VRC AFK AutoMuter v{AutoMuter.VERSION}") - print("Created by Sayamame(https://github.com/Sayamame-beans)") - - parser = argparse.ArgumentParser(description="This is an OSC tool that automatically mutes when AFK in VRChat.") - parser.add_argument("--tx_ip", type=str, help="Destination IP address. (Default: \"127.0.0.1\")") - parser.add_argument("--tx_port", type=int, help="Destination Port. (Default: 9000)") - parser.add_argument("--rx_ip", type=str, help="Source IP address. (Default: \"127.0.0.1\")") - parser.add_argument("--rx_port", type=int, help="Source IP address. (Default: 9001)") - - args = parser.parse_args() - if(not any((args.tx_ip, args.tx_port, args.rx_ip, args.rx_port))): - print("Run with the default settings. (See \"-h\" option for available options.)") - - automuter = AutoMuter(args.tx_ip, args.tx_port, args.rx_ip, args.rx_port) - print(f"Send to \"{automuter.tx_ip}:{automuter.tx_port}\", Receive at \"{automuter.rx_ip}:{automuter.rx_port}\"") - try: - automuter.run() - except KeyboardInterrupt: - print("Shutdown VRC AFK AutoMuter.") \ No newline at end of file