Topic List |
Page List:
1 |
---|---|
HashtagTartarus 02/18/20 7:44:04 AM #1: |
using System; using SharpDX.XInput; using System.Threading.Tasks; using System.Threading; namespace Rumbler { class Program { private static Vibration FormatVibration(UInt16 intensity) => new Vibration() { LeftMotorSpeed = intensity, RightMotorSpeed = intensity }; private static Vibration NO_VIBRATION = new Vibration() { LeftMotorSpeed = 0, RightMotorSpeed = 0 }; static async Task<int> Main(string[] args) { var controllers = new[] { new Controller(UserIndex.One), new Controller(UserIndex.Two), new Controller(UserIndex.Three), new Controller(UserIndex.Four) }; Controller selectedController = null; var controllerIdx = 1; foreach (var controller in controllers) { var isConnected = controller.IsConnected; Console.WriteLine($"Controller {controllerIdx} connected: {controller.IsConnected}"); controllerIdx++; if (isConnected) { selectedController = controller; break; } } if (selectedController == null) { Console.WriteLine("No controllers found! Aborting!"); Console.ReadLine(); return 0; } UInt16 intensity = 30000; const UInt16 INTENSITY_UPDATE_MAGNITUDE = 5000; const UInt16 MAX_INTENSITY = UInt16.MaxValue; const UInt16 MIN_INTENSITY = 20000; const int DELAY_UPDATE_MAGNITUDE = 1; const int MIN_DELAY = 1; const int MAX_DELAY = 50; int pulseSpeed = MAX_DELAY; bool isPulsing = false; bool pulseAscending = true; void IncreaseIntensity() { float percentIntensity = (float)intensity / (float)MAX_INTENSITY; if (percentIntensity > 0.98f) { intensity = MAX_INTENSITY; return; } intensity = (ushort)Math.Min((intensity + (INTENSITY_UPDATE_MAGNITUDE * (1.0 - percentIntensity))), MAX_INTENSITY); } void DecreaseIntensity() { intensity = (ushort)Math.Max(intensity - INTENSITY_UPDATE_MAGNITUDE, MIN_INTENSITY); } void IncreaseDelay() { pulseSpeed = Math.Min(pulseSpeed + DELAY_UPDATE_MAGNITUDE, MAX_DELAY); } void DecreaseDelay() { pulseSpeed = Math.Max(pulseSpeed - DELAY_UPDATE_MAGNITUDE, MIN_DELAY); } var vibrateTask = new Task(async () => { while(true) { if (isPulsing) { if (pulseAscending) { IncreaseIntensity(); if (intensity == MAX_INTENSITY) { pulseAscending = false; } } else { DecreaseIntensity(); if (intensity == MIN_INTENSITY) { pulseAscending = true; } } } selectedController.SetVibration(Program.FormatVibration(intensity)); await Task.Delay(pulseSpeed); } }); vibrateTask.Start(); bool shouldExit = false; while (true) { var key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.UpArrow: if (isPulsing) { IncreaseDelay(); } else { IncreaseIntensity(); } break; case ConsoleKey.DownArrow: if (isPulsing) { DecreaseDelay(); } else { DecreaseIntensity(); } break; case ConsoleKey.P: isPulsing = !isPulsing; break; case ConsoleKey.Escape: sh ... Copied to Clipboard!
|
Shelhamer92 02/18/20 7:45:01 AM #2: |
mah keys
--- "It's a sunny night in Oakland" -Phil Simms *Camera pans to full moon ... Copied to Clipboard!
|
Alteres 02/18/20 7:48:28 AM #3: |
Not a lot of ladies around here.
--- ........the ghost in the machine... IGN: Fox, FC: 5344-2646-0982 ... Copied to Clipboard!
|
HashtagTartarus 02/18/20 7:49:16 AM #4: |
Alteres posted...
Not a lot of ladies around here. We all have buttholes --- ... Copied to Clipboard!
|
AloofHermit 02/18/20 8:44:47 AM #5: |
... Copied to Clipboard!
|
HashtagTartarus 02/18/20 11:11:58 PM #6: |
AloofHermit posted...
is this how u bypass VAC? No --- ... Copied to Clipboard!
|
sylverlolol 02/18/20 11:23:16 PM #7: |
surprise buttsecks
--- This is my signature. There are many like it, but this one is mine. ... Copied to Clipboard!
|
HBOSS 02/18/20 11:54:35 PM #8: |
? what happened.
https://youtu.be/vpIduDaggVA --- You don't stop playing because you grow old, You grow old because you stop playing ... Copied to Clipboard!
|
Topic List |
Page List:
1 |