Browse Source

Prepare to implement alternative force feedback methods for other controllers.

pull/826/head
Evaldas Jocys 7 years ago
parent
commit
0411ba0a37
  1. 5
      x360ce.App.Beta/Common/AutoMapHelper.cs
  2. 6
      x360ce.App.Beta/Controls/PadControl.cs
  3. 2592
      x360ce.App/Controls/PadControl.cs
  4. 12
      x360ce.Engine/Common/Enum/EffectType.cs
  5. 27
      x360ce.Engine/Common/Enum/ForceEffectType.cs
  6. 12
      x360ce.Engine/Common/Enum/ForceFeedBackType.cs
  7. 31
      x360ce.Engine/Common/ForceFeedbackState.cs
  8. 23
      x360ce.Engine/JocysCom/Files/Zip.cs
  9. 3
      x360ce.Engine/x360ce.Engine.csproj
  10. 11
      x360ce.sln
  11. 11
      x360ce.sln.vsspell

5
x360ce.App.Beta/Common/AutoMapHelper.cs

@ -11,11 +11,10 @@ namespace x360ce.App
{
public static PadSetting GetAutoPreset(DeviceObjectItem[] objects)
{
var ps = new PadSetting();
var list = objects.ToList();
if (list == null)
if (objects == null)
return ps;
var list = objects.ToList();
// Get information about device.
var o = list.FirstOrDefault(x => x.Type == ObjectGuid.RxAxis);
// If Right thumb triggers are missing then...

6
x360ce.App.Beta/Controls/PadControl.cs

@ -167,9 +167,9 @@ namespace x360ce.App.Controls
// Add GamePad typed to ComboBox.
var types = (SharpDX.XInput.DeviceSubType[])Enum.GetValues(typeof(SharpDX.XInput.DeviceSubType));
foreach (var item in types) DeviceSubTypeComboBox.Items.Add(item);
// Add force feedback typed to ComboBox.
var effectsTypes = (ForceEffectType[])Enum.GetValues(typeof(ForceEffectType));
foreach (var item in effectsTypes) ForceTypeComboBox.Items.Add(item);
// Add force feedback typed to ComboBox.
var effectsTypes = Enum.GetValues(typeof(ForceEffectType)).Cast<ForceEffectType>().Distinct().ToArray();
foreach (var item in effectsTypes) ForceTypeComboBox.Items.Add(item);
var effectDirections = (ForceEffectDirection[])Enum.GetValues(typeof(ForceEffectDirection));
foreach (var item in effectDirections) LeftMotorDirectionComboBox.Items.Add(item);

2592
x360ce.App/Controls/PadControl.cs
File diff suppressed because it is too large
View File

12
x360ce.Engine/Common/Enum/EffectType.cs

@ -1,12 +0,0 @@
namespace x360ce.App
{
public enum ForceEffectType
{
/// <summary>Old constant force (like in 3.1.4.1)</summary>
Constant = 0,
/// <summary>EJocys method (from rev 150)</summary>
PeriodicSine = 1,
/// <summary>New force</summary>
PeriodicSawtooth = 2,
}
}

27
x360ce.Engine/Common/Enum/ForceEffectType.cs

@ -0,0 +1,27 @@
using System;
namespace x360ce.Engine
{
/// <summary>
/// Forces for vibrating motors (Game pads):
/// 0 - Constant. Good for vibrating motors.
/// Forces for torque motors (Wheels):
/// 1 - Periodic 'Sine Wave'. Good for car/plane engine vibration.
/// 2 - Periodic 'Sawtooth Down Wave'. Good for gun recoil.
/// </summary>
[Flags]
public enum ForceEffectType
{
// Default Implementation (one motor/actuator per effect).
Constant = 0,
PeriodicSine = 1,
PeriodicSawtooth = 2,
// Alternative implementations (two motors/actuators per effect).
// Used by SpeedLink.
_Type2 = 0x10000,
Constant2 = Constant | _Type2,
PeriodicSine2 = PeriodicSine | _Type2,
PeriodicSawtooth2 = PeriodicSawtooth | _Type2,
}
}

12
x360ce.Engine/Common/Enum/ForceFeedBackType.cs

@ -1,12 +0,0 @@
namespace x360ce.Engine
{
public enum ForceFeedBackType
{
/// <summary>Old constant force (like in 3.1.4.1)</summary>
Constant = 0,
/// <summary>EJocys method (from rev 150)</summary>
PeriodicSine = 1,
/// <summary>New force</summary>
PeriodicSawtooth = 2,
}
}

31
x360ce.Engine/Common/ForceFeedbackState.cs

@ -121,24 +121,18 @@ namespace x360ce.Engine
if (device.CreatedEffects.Count > 1)
effectR = device.CreatedEffects[1];
// Effect type changed.
// Effect type changed.
bool forceChanged = Changed(ref old_ForceType, ps.ForceType);
if (forceChanged)
{
// Update values.
var forceType = (ForceFeedBackType)TryParse(ps.ForceType);
// Forces for vibrating motors (Game pads).
// 0 - Constant. Good for vibrating motors.
// Forces for torque motors (Wheels).
// 1 - Periodic 'Sine Wave'. Good for car/plane engine vibration.
// 2 - Periodic 'Sawtooth Down Wave'. Good for gun recoil.
switch (forceType)
{
case ForceFeedBackType.PeriodicSine: GUID_Force = EffectGuid.Sine; break;
case ForceFeedBackType.PeriodicSawtooth: GUID_Force = EffectGuid.SawtoothDown; break;
default: GUID_Force = EffectGuid.ConstantForce; break;
}
var forceType = (ForceEffectType)TryParse(ps.ForceType);
if (forceType.HasFlag(ForceEffectType.PeriodicSine))
GUID_Force = EffectGuid.Sine;
else if (forceType.HasFlag(ForceEffectType.PeriodicSawtooth))
GUID_Force = EffectGuid.SawtoothDown;
else
GUID_Force = EffectGuid.ConstantForce;
// Force change requires to dispose old effects.
// Stop old effects.
if (effectL != null)
@ -360,7 +354,14 @@ namespace x360ce.Engine
return i;
}
bool Changed(ref string oldValue, string newValue)
bool Changed(ref ForceEffectType? oldValue, ForceEffectType newValue)
{
var changed = oldValue != newValue;
oldValue = newValue;
return changed;
}
bool Changed(ref string oldValue, string newValue)
{
var changed = oldValue != newValue;
oldValue = newValue;

23
x360ce.Engine/JocysCom/Files/Zip.cs

@ -100,7 +100,28 @@ namespace JocysCom.ClassLibrary.Files
}
/// <summary>
/// Extract file from the ZIP archive.
/// Compress files into the ZIP archive.
/// </summary>
/// <param name="sourceFolder">The name of the file to compress.</param>
/// <param name="zipFileName">A relative or absolute path of the ZIP file.</param>
public static void ZipFiles(string sourceFolder, string zipFileName)
{
// Create zip file for writing.
var zip = ZipStorer.Create(zipFileName, string.Empty);
var di = new DirectoryInfo(sourceFolder);
var files = di.GetFiles("*.*", SearchOption.AllDirectories);
foreach (var file in files)
{
var fileNameInZip = file.FullName.Substring(di.FullName.Length);
// Add file to the zip.
zip.AddFile(ZipStorer.Compression.Store, file.FullName, fileNameInZip, string.Empty);
}
zip.Close();
}
/// <summary>
/// Extract files from the ZIP archive.
/// </summary>
/// <param name="zipFileName">A relative or absolute path of the ZIP file.</param>
/// <param name="destinationFolder">Destination folder.</param>

3
x360ce.Engine/x360ce.Engine.csproj

@ -130,8 +130,7 @@
<Compile Include="Common\Enum\EffectDirection.cs" />
<Compile Include="Common\Enum\EmulationType.cs" />
<Compile Include="Common\Enum\EnabledState.cs" />
<Compile Include="Common\Enum\EffectType.cs" />
<Compile Include="Common\Enum\ForceFeedBackType.cs" />
<Compile Include="Common\Enum\ForceEffectType.cs" />
<Compile Include="Common\Enum\GameRefreshStatus.cs" />
<Compile Include="Common\Enum\HookMask.cs" />
<Compile Include="Common\Enum\MapTo.cs" />

11
x360ce.sln

@ -39,10 +39,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "x360ce.App.Beta", "x360ce.A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "x360ce.App.WPF", "x360ce.App.WPF\x360ce.App.WPF.csproj", "{405E630F-AEBB-45CB-BD53-4B8B4DFA139E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2C4AA67E-A4C0-41CC-BEA1-FEF3BDD4BE0B}"
ProjectSection(SolutionItems) = preProject
x360ce.sln.vsspell = x360ce.sln.vsspell
EndProjectSection
EndProject
Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Win32 = Debug|Win32
@ -282,4 +284,7 @@ Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

11
x360ce.sln.vsspell

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Visual Studio Spell Checker configuration file - [https://github.com/EWSoftware/VSSpellChecker]
Do not edit the XML. Use the configuration file editor in Visual Studio to modify the settings. -->
<SpellCheckerConfiguration Format="2016.3.10.0">
<InheritAdditionalDictionaryFolders>True</InheritAdditionalDictionaryFolders>
<SelectedLanguages />
<InheritIgnoredWords>True</InheritIgnoredWords>
<InheritExclusionExpressions>True</InheritExclusionExpressions>
<InheritIgnoredFilePatterns>True</InheritIgnoredFilePatterns>
<InheritXmlSettings>True</InheritXmlSettings>
</SpellCheckerConfiguration>
Loading…
Cancel
Save