Skip to content

Commit

Permalink
Had the 8 byte sequence backwards for Chell, realized it's bits a rel…
Browse files Browse the repository at this point in the history
…ease controller sets but SteamInput ignores. Added a fork based on the PID to be 100% sure both are set at the right times.
  • Loading branch information
Nielk1 committed Jun 11, 2019
1 parent e7568be commit 9001d58
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions VSCView/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.1.8")]
[assembly: AssemblyFileVersion("0.3.1.8")]
[assembly: AssemblyVersion("0.3.1.9")]
[assembly: AssemblyFileVersion("0.3.1.9")]
41 changes: 27 additions & 14 deletions VSCView/SteamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public enum Melody : UInt32
The_Mann = 0x0d,
}

public enum EControllerType
{
Chell,
ReleaseV1,
ReleaseV2,
}

public class SteamControllerButtons : ICloneable
{
public bool A { get; set; }
Expand Down Expand Up @@ -210,6 +217,7 @@ public enum EConnectionType
bool Initalized;

public EConnectionType ConnectionType { get; private set; }
public EControllerType ControllerType { get; private set; }

public delegate void StateUpdatedEventHandler(object sender, SteamControllerState e);
public event StateUpdatedEventHandler StateUpdated;
Expand All @@ -218,12 +226,13 @@ protected virtual void OnStateUpdated(SteamControllerState e)
StateUpdated?.Invoke(this, e);
}

public SteamController(HidDevice device, EConnectionType connection = SteamController.EConnectionType.Unknown)
public SteamController(HidDevice device, EConnectionType connection = SteamController.EConnectionType.Unknown, EControllerType type = EControllerType.ReleaseV1)
{
State.Buttons = new SteamControllerButtons();

_device = device;
ConnectionType = connection;
ControllerType = type;

Initalized = false;
}
Expand Down Expand Up @@ -352,22 +361,22 @@ public static SteamController[] GetControllers()

if (devicePath.Contains(wired_m))
{
ControllerList.Add(new SteamController(_device, EConnectionType.USB));
ControllerList.Add(new SteamController(_device, EConnectionType.USB, EControllerType.ReleaseV1));
}
else if (devicePath.Contains(dongle_m1)
|| devicePath.Contains(dongle_m2)
|| devicePath.Contains(dongle_m3)
|| devicePath.Contains(dongle_m4))
{
ControllerList.Add(new SteamController(_device, EConnectionType.Wireless));
ControllerList.Add(new SteamController(_device, EConnectionType.Wireless, EControllerType.ReleaseV1));
}
//else// if (devicePath.Contains(bt_m))
//{
// ControllerList.Add(new SteamController(_device, EConnectionType.BT));
//}
else if (devicePath.Contains(chell_m))
{
ControllerList.Add(new SteamController(_device, EConnectionType.Chell));
ControllerList.Add(new SteamController(_device, EConnectionType.Chell, EControllerType.Chell));
}
}
}
Expand Down Expand Up @@ -424,11 +433,20 @@ private void OnReport(HidReport report)
State.Buttons.Steam = (report.Data[9] & 32) == 32;
State.Buttons.Select = (report.Data[9] & 16) == 16;

State.Buttons.Down = (report.Data[9] & 8) == 8;
State.Buttons.Left = (report.Data[9] & 4) == 4;
State.Buttons.Right = (report.Data[9] & 2) == 2;
State.Buttons.Up = (report.Data[9] & 1) == 1;

if (ControllerType == EControllerType.Chell)
{
State.Buttons.Touch0 = (report.Data[9] & 0x01) == 0x01;
State.Buttons.Touch1 = (report.Data[9] & 0x02) == 0x02;
State.Buttons.Touch2 = (report.Data[9] & 0x04) == 0x04;
State.Buttons.Touch3 = (report.Data[9] & 0x08) == 0x08;
}
else
{
State.Buttons.Down = (report.Data[9] & 8) == 8;
State.Buttons.Left = (report.Data[9] & 4) == 4;
State.Buttons.Right = (report.Data[9] & 2) == 2;
State.Buttons.Up = (report.Data[9] & 1) == 1;
}
bool LeftAnalogMultiplexMode = (report.Data[10] & 128) == 128;
State.Buttons.StickClick = (report.Data[10] & 64) == 64;
bool Unknown = (report.Data[10] & 32) == 32; // what is this?
Expand All @@ -441,11 +459,6 @@ private void OnReport(HidReport report)
State.LeftTrigger = report.Data[11];
State.RightTrigger = report.Data[12];

State.Buttons.Touch0 = (report.Data[14] & 0x01) == 0x01;
State.Buttons.Touch1 = (report.Data[14] & 0x02) == 0x02;
State.Buttons.Touch2 = (report.Data[14] & 0x04) == 0x04;
State.Buttons.Touch3 = (report.Data[14] & 0x08) == 0x08;

if (LeftAnalogMultiplexMode)
{
if (LeftPadTouch)
Expand Down

0 comments on commit 9001d58

Please sign in to comment.