mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 13:57:39 +00:00
Add SteamController implementation
This adds a Steam Shortcuts, Desktop Mode, and X360 Emulation - Supports all Steam Shortcuts (including on-screen keyboard, and brightness) - Supports Desktop mode (with a scroll on left pad and left stick), and trackpoint (on right stick) - Supports X360 mode: hold Options for 1s to switch between Desktop and X360 - Holding Steam button enables Desktop like controls and stops passing all inputs to X360
This commit is contained in:
parent
203338b669
commit
ecbd0407c0
41 changed files with 2486 additions and 34 deletions
65
SteamController/Devices/SteamController.cs
Normal file
65
SteamController/Devices/SteamController.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using hidapi;
|
||||
using PowerControl.External;
|
||||
using static CommonHelpers.Log;
|
||||
|
||||
namespace SteamController.Devices
|
||||
{
|
||||
public partial class SteamController : IDisposable
|
||||
{
|
||||
public const ushort SteamVendorID = 0x28DE;
|
||||
public const ushort SteamProductID = 0x1205;
|
||||
public const int ReadTimeout = 50;
|
||||
|
||||
private hidapi.HidDevice neptuneDevice;
|
||||
|
||||
public SteamController()
|
||||
{
|
||||
InitializeButtons();
|
||||
InitializeActions();
|
||||
|
||||
neptuneDevice = new hidapi.HidDevice(SteamVendorID, SteamProductID, 64);
|
||||
neptuneDevice.OpenDevice();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Updated { get; private set; }
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
foreach (var action in AllActions)
|
||||
action.Reset();
|
||||
}
|
||||
|
||||
private void BeforeUpdate(byte[] buffer)
|
||||
{
|
||||
foreach (var action in AllActions)
|
||||
action.BeforeUpdate(buffer, this);
|
||||
}
|
||||
|
||||
internal void BeforeUpdate()
|
||||
{
|
||||
byte[] data = neptuneDevice.Read(ReadTimeout);
|
||||
if (data == null)
|
||||
{
|
||||
Reset();
|
||||
Updated = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BeforeUpdate(data);
|
||||
Updated = true;
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
foreach (var action in AllActions)
|
||||
action.Update();
|
||||
|
||||
UpdateLizardButtons();
|
||||
UpdateLizardMouse();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue