Recently I just bought a Thrustmaster TCA airbus throttle.
You can buy it here.
I want to use this throttle to control the fan speed of the server in my data center.
Super easy.
Install SharpDX.DirectInput
first.
dotnet add package SharpDX.DirectInput
Run the following code to read from GameControl
. You can also read from other types like Joystick
.
var directInput = new DirectInput();
var device = directInput
.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AllDevices)
.First();
var joystickGuid = device.InstanceGuid;
var joystick = new Joystick(directInput, joystickGuid);
joystick.Properties.BufferSize = 128;
joystick.Acquire();
while (true)
{
joystick.Poll();
var datas = joystick.GetBufferedData();
foreach (var state in datas)
{
Console.WriteLine("Event" + state);
}
}
I recently came across your blog post about reading joystick output based on C# and using it to control the fan speed of the server in your data center. I must say, it's an interesting and creative idea to utilize a gaming peripheral for managing server cooling. Your choice of the Thrustmaster TCA Airbus throttle is also quite unique.
Your post provided a clear overview of the process, starting with the installation of the
SharpDX.DirectInput
package and followed by the code snippet to read fromGameControl
. It's impressive how you managed to achieve this with just a few lines of code. The embedded video also helps in visualizing the concept, which is a great addition to the post.However, there are a few areas where I believe the post could be improved:
Explanation of the code: While the code snippet is concise, it would be helpful to have a brief explanation of what each line does, especially for readers who may not be familiar with C# or the DirectInput library.
Fan speed control: It would be great if you could elaborate on how the joystick's input is translated to control the fan speed of the server. Readers would be interested in understanding the logic behind this translation and how it can be customized for their own use cases.
Error handling: The current code snippet does not include any error handling. It would be beneficial to show how to handle potential issues, such as the joystick being disconnected or the DirectInput library failing to initialize.
Alternative devices: While you mentioned that other device types like
Joystick
can be used, it would be helpful to provide examples or discuss the compatibility of different devices with your approach.In conclusion, I appreciate your effort in sharing this innovative idea with the community. With some improvements in the explanation and additional details, I believe this post can be even more valuable to readers who are interested in exploring unconventional ways to manage their server cooling systems. Keep up the great work!
安度因,日你牙