Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nefarius/ScpToolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizonix committed May 26, 2017
2 parents d4859a0 + 3d1e926 commit 07ddcc7
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 33 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Windows Driver and XInput Wrapper for Sony DualShock 3/4 Controllers

Follow development progress on [Twitter](https://twitter.com/CNefarius) and [YouTube](https://www.youtube.com/user/nefarius2k8)! Like my stuff? [Support me on Patreon](https://www.patreon.com/nefarius)!

[<img src="https://img.shields.io/badge/rating-4%2B%20stars-brightgreen.svg">](https://recordnotfound.com/ScpServer-nefarius-597)

## Credits
### Community
* Major props to [original author Scarlet.Crush](http://forums.pcsx2.net/User-Scarlet-Crush) for developing this awesome toolkit!
Expand Down
6 changes: 3 additions & 3 deletions ScpControl/Properties/Settings.Designer.cs

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

2 changes: 1 addition & 1 deletion ScpControl/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Setting Name="DisableSecureSimplePairing" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="IdleTimout" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Int32" Scope="User">
<Setting Name="IdleTimeout" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Int32" Scope="User">
<Value Profile="(Default)">600000</Value>
</Setting>
<Setting Name="Ds3RumbleLatency" Provider="ScpControl.Utilities.PortableSettingsProvider" Type="System.Int32" Scope="User">
Expand Down
6 changes: 3 additions & 3 deletions ScpControl/ScpCore/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ public bool IsLightBarDisabled

public bool IdleDisconnect
{
get { return Settings.Default.IdleTimout != 0; }
get { return Settings.Default.IdleTimeout != 0; }
}

public int IdleTimeout
{
get { return Settings.Default.IdleTimout; }
set { Settings.Default.IdleTimout = value; }
get { return Settings.Default.IdleTimeout; }
set { Settings.Default.IdleTimeout = value; }
}

public int Latency
Expand Down
8 changes: 6 additions & 2 deletions ScpControl/Usb/Gamepads/UsbGenericGamepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@ public static UsbDevice DeviceFactory(string devicePath)

public override bool Open(string devicePath)
{
short vid, pid;

GetHardwareId(devicePath, out vid, out pid);

var loader = new HidDeviceLoader();

// search for HID
_currentHidDevice = loader.GetDevices(VendorId, ProductId).FirstOrDefault();
_currentHidDevice = loader.GetDevices(vid, pid).FirstOrDefault();

if (_currentHidDevice == null)
{
Log.ErrorFormat("Couldn't find device with VID: {0}, PID: {1}",
VendorId, ProductId);
vid, pid);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion ScpControl/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<setting name="DisableSecureSimplePairing" serializeAs="String">
<value>False</value>
</setting>
<setting name="IdleTimout" serializeAs="String">
<setting name="IdleTimeout" serializeAs="String">
<value>600000</value>
</setting>
<setting name="Ds3RumbleLatency" serializeAs="String">
Expand Down
10 changes: 9 additions & 1 deletion ScpProfiler/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ private void Window_Initialized(object sender, EventArgs e)

MainGrid.DataContext = _vm;

_vm.Profiles = _proxy.GetProfiles().ToList();
var list = _proxy.GetProfiles();
if (list == null)
{
list = new List<DualShockProfile>();
}
else
{
_vm.Profiles = list.ToList();
}
}

private void ProxyOnNativeFeedReceived(object sender, ScpHidReport report)
Expand Down
2 changes: 1 addition & 1 deletion ScpServer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<setting name="DisableSecureSimplePairing" serializeAs="String">
<value>False</value>
</setting>
<setting name="IdleTimout" serializeAs="String">
<setting name="IdleTimeout" serializeAs="String">
<value>600000</value>
</setting>
<setting name="Ds3RumbleLatency" serializeAs="String">
Expand Down
19 changes: 10 additions & 9 deletions ScpSettings/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@

<!-- Idle Timeout -->
<GroupBox Header="Idle Timeout: 10 minutes"
x:Name="IdleTimoutGroupBox"
x:Name="IdleTimeoutGroupBox"
Grid.Row="2">
<StackPanel>
<TextBlock>
Defines the timespan after the controller gets shut off automatically if no input changes are received.
</TextBlock>
<Slider Maximum="30"
x:Name="IdleTimoutSlider"
Value="{Binding Path=IdleTimeout}"
ValueChanged="IdleTimoutSlider_ValueChanged"
ValueChanged="IdleTimeoutSlider_ValueChanged"
Name= "IdleTimeoutSlider"
LargeChange="5" SmallChange="1" />
</StackPanel>
</GroupBox>
Expand Down Expand Up @@ -185,8 +185,9 @@
Defines the minimal duration the rumble request will be sent to the controller until it stops.
</TextBlock>
<Slider LargeChange="1" Maximum="16"
x:Name="RumbleLatencySlider"
Value="{Binding Path=Latency}" ValueChanged="Slider_ValueChanged" />
Value="{Binding Path=Latency}"
ValueChanged="RumbleLatencySlider_ValueChanged"
Name= "RumbleLatencySlider" />
</StackPanel>
</GroupBox>

Expand All @@ -213,12 +214,12 @@

<!-- Adjustment slider -->
<Slider Grid.Column="1"
x:Name="LEDsFlashingPeriodSlider"
TickFrequency="100" Maximum="2000" Minimum="300"
IsSnapToTickEnabled="True"
VerticalAlignment="Center"
Value="{Binding Path=Ds3LEDsPeriod}"
ValueChanged="Slider_LEDsPeriodChanged" />
ValueChanged="LEDsFlashingPeriodSlider_ValueChanged"
Name= "LEDsFlashingPeriodSlider" />

<!-- Maximum value -->
<Label Grid.Column="2">
Expand Down Expand Up @@ -339,9 +340,9 @@
Grid.Row="1">
<StackPanel>
<Slider Maximum="255"
x:Name="BrightnessSlider"
Value="{Binding Path=Brightness}" LargeChange="16"
ValueChanged="BrightnessSlider_ValueChanged" SmallChange="1" />
ValueChanged="BrightnessSlider_ValueChanged" SmallChange="1"
Name="BrightnessSlider" />
<TextBlock>
Hint: move the slider all the way to the left to disable the Light Bar entirely.
</TextBlock>
Expand Down
30 changes: 18 additions & 12 deletions ScpSettings/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,29 @@ private void LoadConfig()

DataContext = null;
DataContext = _config;

// Invoke Slider EventHandlers To Correctly Display GroupBox Headers
IdleTimeoutSlider_ValueChanged(null, new RoutedPropertyChangedEventArgs<double> (0, IdleTimeoutSlider.Value));
RumbleLatencySlider_ValueChanged(null, new RoutedPropertyChangedEventArgs<double>(0, RumbleLatencySlider.Value));
LEDsFlashingPeriodSlider_ValueChanged(null, new RoutedPropertyChangedEventArgs<double>(0, LEDsFlashingPeriodSlider.Value));
BrightnessSlider_ValueChanged(null, new RoutedPropertyChangedEventArgs<double>(0, BrightnessSlider.Value));
}

private void IdleTimoutSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
private void IdleTimeoutSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var value = e.NewValue;

if (value == 0)
{
IdleTimoutGroupBox.Header = "Idle Timeout: Disabled";
IdleTimeoutGroupBox.Header = "Idle Timeout: Disabled";
}
else if (value == 1)
{
IdleTimoutGroupBox.Header = "Idle Timeout: 1 minute";
IdleTimeoutGroupBox.Header = "Idle Timeout: 1 minute";
}
else
{
IdleTimoutGroupBox.Header = string.Format("Idle Timeout: {0} minutes", value);
IdleTimeoutGroupBox.Header = string.Format("Idle Timeout: {0} minutes", value);
}
}

Expand All @@ -111,14 +117,14 @@ private void BrightnessSlider_ValueChanged(object sender, RoutedPropertyChangedE
: string.Format("Light Bar Brightness: {0}%", (int)((value * 100) / 255));
}

private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
private void RumbleLatencySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var value = ((int)e.NewValue) << 4;

RumbleLatencyGroupBox.Header = string.Format("Rumble Latency: {0} ms", value);
}

private void Slider_LEDsPeriodChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
private void LEDsFlashingPeriodSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var value = (int)e.NewValue;

Expand Down Expand Up @@ -195,23 +201,23 @@ private void XInputModToggleButton_Unchecked(object sender, RoutedEventArgs e)

private void DisableEvents()
{
IdleTimoutSlider.ValueChanged -= IdleTimoutSlider_ValueChanged;
IdleTimeoutSlider.ValueChanged -= IdleTimeoutSlider_ValueChanged;
BrightnessSlider.ValueChanged -= BrightnessSlider_ValueChanged;

RumbleLatencySlider.ValueChanged -= Slider_ValueChanged;
LEDsFlashingPeriodSlider.ValueChanged -= Slider_LEDsPeriodChanged;
RumbleLatencySlider.ValueChanged -= RumbleLatencySlider_ValueChanged;
LEDsFlashingPeriodSlider.ValueChanged -= LEDsFlashingPeriodSlider_ValueChanged;

XInputModToggleButton.Checked -= XInputModToggleButton_OnChecked;
XInputModToggleButton.Unchecked -= XInputModToggleButton_Unchecked;
}

private void EnableEvents()
{
IdleTimoutSlider.ValueChanged += IdleTimoutSlider_ValueChanged;
IdleTimeoutSlider.ValueChanged += IdleTimeoutSlider_ValueChanged;
BrightnessSlider.ValueChanged += BrightnessSlider_ValueChanged;

RumbleLatencySlider.ValueChanged += Slider_ValueChanged;
LEDsFlashingPeriodSlider.ValueChanged += Slider_LEDsPeriodChanged;
RumbleLatencySlider.ValueChanged += RumbleLatencySlider_ValueChanged;
LEDsFlashingPeriodSlider.ValueChanged += LEDsFlashingPeriodSlider_ValueChanged;

XInputModToggleButton.Checked += XInputModToggleButton_OnChecked;
XInputModToggleButton.Unchecked += XInputModToggleButton_Unchecked;
Expand Down

0 comments on commit 07ddcc7

Please sign in to comment.