mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-20 05:33:50 +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
60
ExternalHelpers/OnScreenKeyboard.cs
Normal file
60
ExternalHelpers/OnScreenKeyboard.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace ExternalHelpers
|
||||
{
|
||||
public static class OnScreenKeyboard
|
||||
{
|
||||
public const String TabTipPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
|
||||
public static bool Toggle()
|
||||
{
|
||||
StartTabTip();
|
||||
|
||||
var type = Type.GetTypeFromCLSID(Guid.Parse("4ce576fa-83dc-4F88-951c-9d0782b4e376"));
|
||||
if (type is null)
|
||||
return false;
|
||||
var instance = (ITipInvocation?)Activator.CreateInstance(type);
|
||||
if (instance is null)
|
||||
return false;
|
||||
instance?.Toggle(GetDesktopWindow());
|
||||
Marshal.ReleaseComObject(instance);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void StartTabTip()
|
||||
{
|
||||
if (FindWindow("IPTIP_Main_Window", "") != IntPtr.Zero)
|
||||
return;
|
||||
|
||||
Process.Start(TabTipPath);
|
||||
|
||||
for (int i = 0; i < 10 && FindWindow("IPTIP_Main_Window", "") == IntPtr.Zero; i++)
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
[ComImport, Guid("4ce576fa-83dc-4F88-951c-9d0782b4e376")]
|
||||
class UIHostNoLaunch
|
||||
{
|
||||
}
|
||||
|
||||
[ComImport, Guid("37c994e7-432b-4834-a2f7-dce1f13b834b")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface ITipInvocation
|
||||
{
|
||||
void Toggle(IntPtr hwnd);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = false)]
|
||||
static extern IntPtr GetDesktopWindow();
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "FindWindow")]
|
||||
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,8 @@ namespace PowerControl.External
|
|||
CONFIGURE_BT = 0x18,
|
||||
}
|
||||
|
||||
public enum SDCButton0
|
||||
[Flags]
|
||||
public enum SDCButton0 : ushort
|
||||
{
|
||||
BTN_L5 = 0b1000000000000000,
|
||||
BTN_OPTIONS = 0b0100000000000000,
|
||||
|
|
@ -65,22 +66,25 @@ namespace PowerControl.External
|
|||
BTN_R2 = 0b0000000000000001,
|
||||
}
|
||||
|
||||
public enum SDCButton1
|
||||
[Flags]
|
||||
public enum SDCButton1 : byte
|
||||
{
|
||||
BTN_LSTICK_PRESS = 0b01000000,
|
||||
BTN_RPAD_TOUCH = 0b00010000,
|
||||
BTN_LPAD_TOUCH = 0b00001000,
|
||||
BTN_RPAD_PRESS = 0b00000100,
|
||||
BTN_LPAD_PRESS = 0b00000010,
|
||||
BTN_RPAD_PRESS = 0b00010000,
|
||||
BTN_RPAD_TOUCH = 0b00000100,
|
||||
BTN_R5 = 0b00000001,
|
||||
}
|
||||
|
||||
public enum SDCButton2
|
||||
[Flags]
|
||||
public enum SDCButton2 : byte
|
||||
{
|
||||
BTN_RSTICK_PRESS = 0b00000100,
|
||||
}
|
||||
|
||||
public enum SDCButton4
|
||||
[Flags]
|
||||
public enum SDCButton4 : byte
|
||||
{
|
||||
BTN_LSTICK_TOUCH = 0b01000000,
|
||||
BTN_RSTICK_TOUCH = 0b10000000,
|
||||
|
|
@ -88,29 +92,30 @@ namespace PowerControl.External
|
|||
BTN_L4 = 0b00000010,
|
||||
}
|
||||
|
||||
public enum SDCButton5
|
||||
[Flags]
|
||||
public enum SDCButton5 : byte
|
||||
{
|
||||
BTN_QUICK_ACCESS = 0b00000100,
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SDCInput
|
||||
{
|
||||
public byte ptype; //0x00
|
||||
public byte _a1; //0x01
|
||||
public byte _a2; //0x02
|
||||
public byte _a1; //0x01
|
||||
public byte _a2; //0x02
|
||||
public byte _a3; //0x03
|
||||
public uint seq; //0x04
|
||||
public ushort buttons0; //0x09
|
||||
public byte buttons1; //0x0A
|
||||
public byte buttons2; //0x0C
|
||||
public byte buttons3; //0x0D
|
||||
public byte buttons4; //0x0E
|
||||
public byte buttons5; //0x0E
|
||||
public uint seq; //0x04
|
||||
public SDCButton0 buttons0; //0x08
|
||||
public SDCButton1 buttons1; //0x0A
|
||||
public SDCButton2 buttons2; //0x0B
|
||||
public byte buttons3; //0x0C
|
||||
public SDCButton4 buttons4; //0x0D
|
||||
public SDCButton5 buttons5; //0x0E
|
||||
public byte buttons6; //0x0F
|
||||
public short lpad_x; //0x10
|
||||
public short lpad_y; //0x12
|
||||
public short rpad_x; //0x13
|
||||
public short rpad_x; //0x14
|
||||
public short rpad_y; //0x16
|
||||
public short accel_x; //0x18
|
||||
public short accel_y; //0x1A
|
||||
|
|
@ -136,7 +141,7 @@ namespace PowerControl.External
|
|||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
try
|
||||
{
|
||||
return (SDCInput)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SDCInput));
|
||||
return Marshal.PtrToStructure<SDCInput>(handle.AddrOfPinnedObject());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ namespace PowerControl.Helpers
|
|||
/// </summary>
|
||||
public static class WindowsSettingsBrightnessController
|
||||
{
|
||||
public static void Increase(int brightness)
|
||||
{
|
||||
var current = Get();
|
||||
current += brightness;
|
||||
current = Math.Clamp(current, 0, 100);
|
||||
Set(current);
|
||||
}
|
||||
|
||||
public static int Get(double roundValue = 10.0)
|
||||
{
|
||||
return (int)(Math.Round(Get() / roundValue) * roundValue);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue