-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement patterns (constant and sine wave)
- Loading branch information
1 parent
c48d25a
commit 92454f1
Showing
9 changed files
with
1,785 additions
and
201 deletions.
There are no files selected for viewing
1,795 changes: 1,648 additions & 147 deletions
1,795
ButtplugOfLegendsUnity/Assets/Scenes/MainScene.unity
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
29 changes: 29 additions & 0 deletions
29
ButtplugOfLegendsUnity/Assets/Scripts/Buttplug/ButtplugController.cs
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,29 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public abstract class ButtplugController : MonoBehaviour | ||
{ | ||
[SerializeField] protected ButtplugClient client; | ||
[SerializeField] float transmissionTimerPeriod = .2f; | ||
float transmissionTimer = 0; | ||
protected float value; | ||
|
||
protected abstract void SendValueToClient(); | ||
|
||
public virtual void SetValue(float _value) | ||
{ | ||
value = _value; | ||
value = Mathf.Clamp(value, 0f, 1f); | ||
} | ||
|
||
private void Update() | ||
{ | ||
transmissionTimer += Time.deltaTime; | ||
if (transmissionTimer > transmissionTimerPeriod) | ||
{ | ||
transmissionTimer = 0; | ||
SendValueToClient(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ButtplugOfLegendsUnity/Assets/Scripts/Buttplug/ButtplugController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
32 changes: 32 additions & 0 deletions
32
ButtplugOfLegendsUnity/Assets/Scripts/Buttplug/ButtplugVibrationController.cs
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,32 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class ButtplugVibrationController : ButtplugController | ||
{ | ||
[SerializeField] InputField maxDeviceStrength; | ||
int pattern = 0; | ||
[SerializeField] InputField frequencyBPM; | ||
const float BPM_TO_RADS = 0.10471975499997f; | ||
|
||
protected override void SendValueToClient() | ||
{ | ||
var sendValue = value * float.Parse(maxDeviceStrength.text) / 100; | ||
switch (pattern) | ||
{ | ||
case 1: | ||
sendValue *= .5f + .5f * Mathf.Sin(float.Parse(frequencyBPM.text) * Time.realtimeSinceStartup * BPM_TO_RADS); | ||
break; | ||
default: | ||
break; | ||
} | ||
Debug.Log(sendValue); | ||
client.SendValue(sendValue, Buttplug.ServerMessage.Types.MessageAttributeType.VibrateCmd); | ||
} | ||
|
||
public void OnChangePattern(int newPattern) | ||
{ | ||
pattern = newPattern; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ButtplugOfLegendsUnity/Assets/Scripts/Buttplug/ButtplugVibrationController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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