Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Ds3 leds config #21

Merged
merged 14 commits into from
Sep 29, 2015
77 changes: 65 additions & 12 deletions ScpControl/Bluetooth/BthDs3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public BthDs3(IBthDevice device, byte[] master, byte lsb, byte msb)

#endregion

private byte ledStatus = 0;
private byte counterForLeds = 0;

public override DsPadId PadId
{
get { return (DsPadId)m_ControllerId; }
Expand All @@ -95,7 +98,7 @@ public override DsPadId PadId
m_ControllerId = (byte)value;
m_ReportArgs.Pad = PadId;

_hidReport[11] = _ledOffsets[m_ControllerId];
_hidReport[11] = ledStatus;
}
}

Expand Down Expand Up @@ -256,19 +259,69 @@ protected override void Process(DateTime now)
{
m_Tick = now;

if (m_Queued == 0) m_Queued = 1;
if (m_Queued == 0) m_Queued = 1;

ledStatus = 0;

switch (GlobalConfiguration.Instance.Ds3LEDsFunc)
{
case 0:
ledStatus = 0;
break;
case 1:
if (GlobalConfiguration.Instance.Ds3PadIDLEDsFlashCharging)
{
counterForLeds++;
counterForLeds %= 2;
if (counterForLeds == 1)
ledStatus = _ledOffsets[m_ControllerId];
}
else ledStatus = _ledOffsets[m_ControllerId];
break;
case 2:
switch (Battery)
{
case DsBattery.None:
ledStatus = (byte)(_ledOffsets[0] | _ledOffsets[3]);
break;
case DsBattery.Dieing:
ledStatus = (byte)(_ledOffsets[1] | _ledOffsets[2]);
break;
case DsBattery.Low:
counterForLeds++;
counterForLeds %= 2;
if (counterForLeds == 1)
ledStatus = _ledOffsets[0];
break;
case DsBattery.Medium:
ledStatus = (byte)(_ledOffsets[0] | _ledOffsets[1]);
break;
case DsBattery.High:
ledStatus = (byte)(_ledOffsets[0] | _ledOffsets[1] | _ledOffsets[2]);
break;
case DsBattery.Full:
ledStatus = (byte)(_ledOffsets[0] | _ledOffsets[1] | _ledOffsets[2] | _ledOffsets[3]);
break;
default: ;
break;
}
break;
case 3:
if (GlobalConfiguration.Instance.Ds3LEDsCustom1) ledStatus |= _ledOffsets[0];
if (GlobalConfiguration.Instance.Ds3LEDsCustom2) ledStatus |= _ledOffsets[1];
if (GlobalConfiguration.Instance.Ds3LEDsCustom3) ledStatus |= _ledOffsets[2];
if (GlobalConfiguration.Instance.Ds3LEDsCustom4) ledStatus |= _ledOffsets[3];
break;
default:
ledStatus = 0;
break;
}

_hidReport[11] = ledStatus;

if (Battery < DsBattery.Medium)
{
_hidReport[11] ^= _ledOffsets[m_ControllerId];
}
else
{
_hidReport[11] |= _ledOffsets[m_ControllerId];
}
}

if (GlobalConfiguration.Instance.DisableLED) _hidReport[11] = 0;
}

#region Fake DS3 workaround

Expand All @@ -290,7 +343,7 @@ protected override void Process(DateTime now)
m_Queued--;

m_Device.HID_Command(HciHandle.Bytes, Get_SCID(L2CAP.PSM.HID_Command), _hidReport);
}

}
}
}
97 changes: 84 additions & 13 deletions ScpControl/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions ScpControl/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
<Setting Name="FlipAxisRy" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DisableLed" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DisableRumble" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
Expand Down Expand Up @@ -89,5 +86,26 @@
<Setting Name="BluetoothDisconnectSoundFile" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.String" Scope="User">
<Value Profile="(Default)">Media\disconnect.flac</Value>
</Setting>
<Setting Name="Ds3LEDsFlashingPeriod" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1500</Value>
</Setting>
<Setting Name="Ds3LEDsFunction" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="Ds3PadIDLEDsFlashCharging" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="Ds3LEDsCustom1" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Ds3LEDsCustom2" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Ds3LEDsCustom3" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Ds3LEDsCustom4" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
45 changes: 39 additions & 6 deletions ScpControl/ScpCore/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public bool FlipRY
set { Settings.Default.FlipAxisRy = value; }
}

public bool DisableLED
{
get { return Settings.Default.DisableLed; }
set { Settings.Default.DisableLed = value; }
}

public bool DisableRumble
{
get { return Settings.Default.DisableRumble; }
Expand Down Expand Up @@ -272,6 +266,45 @@ public string BluetoothDisconnectSoundFile
set { Settings.Default.BluetoothDisconnectSoundFile = value; }
}

public int Ds3LEDsPeriod
{
get { return Settings.Default.Ds3LEDsFlashingPeriod; }
set { Settings.Default.Ds3LEDsFlashingPeriod = value; }
}

public int Ds3LEDsFunc
{
get { return Settings.Default.Ds3LEDsFunction; }
set { Settings.Default.Ds3LEDsFunction = value; }
}

public bool Ds3PadIDLEDsFlashCharging
{
get { return Settings.Default.Ds3PadIDLEDsFlashCharging; }
set { Settings.Default.Ds3PadIDLEDsFlashCharging = value; }
}

public bool Ds3LEDsCustom1
{
get { return Settings.Default.Ds3LEDsCustom1; }
set { Settings.Default.Ds3LEDsCustom1 = value; }
}
public bool Ds3LEDsCustom2
{
get { return Settings.Default.Ds3LEDsCustom2; }
set { Settings.Default.Ds3LEDsCustom2 = value; }
}
public bool Ds3LEDsCustom3
{
get { return Settings.Default.Ds3LEDsCustom3; }
set { Settings.Default.Ds3LEDsCustom3 = value; }
}
public bool Ds3LEDsCustom4
{
get { return Settings.Default.Ds3LEDsCustom4; }
set { Settings.Default.Ds3LEDsCustom4 = value; }
}

#endregion
}
}
Loading