Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
- Fix up persistent sfx in live send mode, hopefully fr this time nocap rn (why)
- Add setting for disabling character limit, in use case for other applications non vrchat

Clarification on how live send works:
It will continuously send whatever is being typed every 2~ish seconds until you press enter or otherwise clear the input.
The sound is supposed to ONLY play once at the start of typing until cleared again, not after every update. If you notice the "pop" sound effect after every text update on this version cover your ears and then tell me (i will scream and then probably remove it lol)
  • Loading branch information
nyakowint committed May 5, 2024
1 parent e1d841c commit ff1f5cb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

37 changes: 23 additions & 14 deletions KeyboardOSC/ChatMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class ChatMode
private static readonly ManualLogSource Logger = Plugin.PluginLogger;
private static TextMeshProUGUI _oscBarText;
private static TextMeshProUGUI _charCounter;
private static List<KeyboardKey> _currentlyDownStickyKeys = new();
private static List<KeyboardKey> _currentlyDownStickyKeys = [];
private static Timer _eventsTimer = new(1300);

public static void HandleKey(KeyboardKey.VirtualKeyEventData eventData)
Expand Down Expand Up @@ -106,11 +106,10 @@ private static void ProcessKey(VirtualKeyCode key, KeyboardKey.VirtualKeyEventDa
_currentText += GUIUtility.systemCopyBuffer;
UpdateChatText(_currentText);
return;
// Send message (or clear for continuous)
case VirtualKeyCode.RETURN:
if (liveSendMode)
{
Logger.LogInfo($"Sending message: {_currentText.ReplaceShortcodes()} [ls]");
Logger.LogInfo($"Sending message (live send enabled): {_currentText.ReplaceShortcodes()}");
_lastMsg = _currentText;
if (Core.IsTwitchSendingEnabled && !_isSilentMsg)
{
Expand Down Expand Up @@ -140,12 +139,7 @@ private static void ProcessKey(VirtualKeyCode key, KeyboardKey.VirtualKeyEventDa

// Normal character inputs
if (sendTyping) SendTyping(_currentText.Length != 0);
if (liveSendMode)
{
_eventsTimer.Start();
if (_currentText.IsNullOrWhiteSpace())
_isFirstMsg = true;
}
if (liveSendMode) _eventsTimer.Start();

_currentText += character;
UpdateChatText(_currentText);
Expand All @@ -157,7 +151,7 @@ private static void TimerElapsed(object sender, ElapsedEventArgs e)
Logger.LogInfo("Timer elapsed, sending message");
if (_currentText.IsNullOrWhiteSpace())
{
Tools.SendOsc("/chatbox/input", string.Empty, true, false);
InputToChatbox(string.Empty, false);
SendTyping(false);
}

Expand All @@ -168,16 +162,18 @@ private static void TimerElapsed(object sender, ElapsedEventArgs e)

private static void SendMessage(bool liveSend = false)
{
var triggerSfx = !_isSilentMsg && _isFirstMsg;

if (liveSend)
{
_eventsTimer.Stop();
Tools.SendOsc("/chatbox/input", _currentText.ReplaceShortcodes(), true, !_isSilentMsg);
if (_isFirstMsg) _isFirstMsg = false;
InputToChatbox(_currentText.ReplaceShortcodes(), triggerSfx);
SendTyping(false);
_isFirstMsg = false;
}
else
{
Tools.SendOsc("/chatbox/input", _currentText.ReplaceShortcodes(), true, !_isSilentMsg);
InputToChatbox(_currentText.ReplaceShortcodes(), !_isSilentMsg);
SendTyping(false);
if (Core.IsTwitchSendingEnabled && !_isSilentMsg)
{
Expand All @@ -191,12 +187,24 @@ private static void SendMessage(bool liveSend = false)
ClearInput();
}
}

/// <summary>
/// Since i keep forgetting:
/// /chatbox/input s b n Input text into the chatbox.
/// If B is True, send the text in S immediately, bypassing the keyboard. If b is False, open the keyboard and populate it with the provided text.
/// N is an additional bool parameter that when set to False will not trigger the notification SFX (defaults to True if not specified).
/// </summary>
private static void InputToChatbox(string text, bool triggerSfx = true)
{
Tools.SendOsc("/chatbox/input", text, true, triggerSfx);
}

private static void ClearInput()
{
UpdateChatText(string.Empty);
_currentText = string.Empty;
_isSilentMsg = false;
_isFirstMsg = true;
UpdateChatColor();
Plugin.ReleaseStickyKeys.Invoke(Plugin.Instance.inputHandler, null);
}
Expand Down Expand Up @@ -230,7 +238,8 @@ private static void UpdateChatColor()

private static void UpdateChatText(string text)
{
if (text.Length > 144 && !Core.IsTwitchSendingEnabled)
var disableMaxLength = Core.IsTwitchSendingEnabled || PluginSettings.GetSetting<bool>("DisableMaxLength").Value;
if (text.Length > 144 && !disableMaxLength)
{
text = text.Substring(0, 144);
}
Expand Down
1 change: 1 addition & 0 deletions KeyboardOSC/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public static void RequestSettingsPatch(string sender, string data)
KBCheckForUpdates = PluginSettings.GetSetting<bool>("CheckForUpdates").Value,
KBLiveSend = PluginSettings.GetSetting<bool>("LiveSend").Value,
KBTypingIndicator = PluginSettings.GetSetting<bool>("TypingIndicator").Value,
KBDisableMaxLength = PluginSettings.GetSetting<bool>("DisableMaxLength").Value,
KBTwitchSending = PluginSettings.GetSetting<bool>("TwitchSending").Value,
KBDisableAffixes = PluginSettings.GetSetting<bool>("DisableAffixes").Value,
KBVersion = pluginVersion,
Expand Down
22 changes: 14 additions & 8 deletions KeyboardOSC/PluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ public abstract class PluginSettings
internal static void Init()
{
ConfigFile.Bind(sectionId, "HasSeenHint", false, "Has user seen osc hint");
ConfigFile.Bind(sectionId, "CheckForUpdates", false, "Notify user of updates on init?");
ConfigFile.Bind(sectionId, "CheckForUpdates", true, "Notify user of updates on init?");
ConfigFile.Bind(sectionId, "LiveSend", false, "Send messages as you're typing them");
ConfigFile.Bind(sectionId, "TypingIndicator", true, "Whether to send typing indicator");


ConfigFile.Bind(sectionId, "DisableMaxLength", false,
"Dont limit keybar input to 144 characters (chatbox character limit)");


ConfigFile.Bind(sectionId, "TwitchSending", false, "Send messages to your twitch chat? (requires setup)");
ConfigFile.Bind(sectionId, "MsgPrefix", "[ ", "Message prefix sent with each message");
ConfigFile.Bind(sectionId, "MsgSuffix", "] ", "Message suffix sent with each message");
ConfigFile.Bind(sectionId, "DisableAffixes", true, "Disable both prefix and suffix (e.g. playing a vr game other than vrchat)");
ConfigFile.Bind(sectionId, "DisableAffixes", true,
"Disable both prefix and suffix (e.g. playing a vr game other than vrchat)");
ConfigFile.Bind(sectionId, "TwitchUserId", "", "Your twitch ID");
var tClient = ConfigFile.Bind(sectionId, "TwitchClientId", "", "Your twitch app client ID used for chat sending. Don't set these manually");
var tClient = ConfigFile.Bind(sectionId, "TwitchClientId", "",
"Your twitch app client ID used for chat sending. Don't set these manually");
var tSecret = ConfigFile.Bind(sectionId, "TwitchClientSecret", "", "Twitch client secret");
var tRefresh = ConfigFile.Bind(sectionId, "TwitchRefreshToken", "", "Twitch refresh token");

if (!string.IsNullOrEmpty(tClient.Value) && !string.IsNullOrEmpty(tSecret.Value) && !string.IsNullOrEmpty(tRefresh.Value))

if (!string.IsNullOrEmpty(tClient.Value) && !string.IsNullOrEmpty(tSecret.Value) &&
!string.IsNullOrEmpty(tRefresh.Value))
{
Task.Run(Helix.RefreshTokens);
}
Expand All @@ -50,9 +55,10 @@ public static void SetSetting<T>(string settingName, string value)
public class UiSettings
{
public string KBVersion = Plugin.AssemblyVersion;
public bool KBCheckForUpdates = false;
public bool KBCheckForUpdates = true;
public bool KBLiveSend = false;
public bool KBTypingIndicator = true;
public bool KBDisableMaxLength = false;
public bool KBTwitchSending = false;
public bool KBDisableAffixes = false;
}
3 changes: 2 additions & 1 deletion settingsKO.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ const SettingsLayout = {
},
Keyboard_OSC: {
_: {
KBCheckForUpdates: new Ui.Setting(Ui.ComponentType.Toggle, 'Notify about updates', "The plugin will notify you if there's an update available :D", false),
KBCheckForUpdates: new Ui.Setting(Ui.ComponentType.Toggle, 'Notify about updates', "The plugin will notify you if there's an update available :D", true),
KBLiveSend: new Ui.Setting(Ui.ComponentType.Toggle, 'Live send mode', "Messages will be sent to the chatbox as you type.", false),
KBTypingIndicator: new Ui.Setting(Ui.ComponentType.Toggle, 'Send typing indicator', "Some people prefer to not let people know when they are typing. If this is you here ya go!", true),
KBDisableMaxLength: new Ui.Setting(Ui.ComponentType.Toggle, 'Disable max length', "Disable the character limit on the keyboard bar. This is pointless to enable for VRChat uses", false),
KBVersionCheck: new Ui.Setting(Ui.ComponentType.Button, 'Check for updates', "Check for updates rn!!!!!", null, null, null),
KBOpenRepo: new Ui.Setting(Ui.ComponentType.Button, 'Plugin Repo', "View this plugin's repo on GitHub", null, null, null),
OpenPluginList: new Ui.Setting(Ui.ComponentType.Button, 'xso plugin app list', "testing stuff requires extra dll", null, null, null),
Expand Down

0 comments on commit ff1f5cb

Please sign in to comment.