Skip to content

Commit

Permalink
Axis mapping fixes. Device clean-up function added for dev purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
EJocys committed Apr 4, 2018
1 parent dd74e7e commit a5ac300
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 185 deletions.
3 changes: 3 additions & 0 deletions ClearCache_VS.bat
Expand Up @@ -53,6 +53,9 @@ CALL:DEL "%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Fi
:: Tools -> Options -> Projects and Solutions -> Build and Run
:: Set "On Run, when build or deployment errors occur:" Prompt to Launch

:: .EditorConfig file.
:: "charset=utf-8" option can trigger "The source file is different from when the module was built." warning when debugging.

GOTO:EOF

:DEL
Expand Down
Expand Up @@ -206,13 +206,6 @@ void UpdateXiStates()
//var min = short.MinValue; // -32768;
//var max = short.MaxValue; // 32767;

// If value is inverted (I) then...
if (map.IsInverted)
{
// Convert [0;65535] range to [65535;0] range.
v = (ushort)(ushort.MaxValue - v);
}

/// If half value (H) then...
//else if (!map.IsInverted && map.IsHalf)
//{
Expand All @@ -239,7 +232,12 @@ void UpdateXiStates()
// --------------------------------------------------------
if (map.Target == TargetType.Button)
{

// If value is inverted (I) then...
if (map.IsInverted)
{
// Convert [0;65535] range to [65535;0] range.
v = (ushort)(ushort.MaxValue - v);
}
// If value is inverted (I) then...
if (map.IsHalf)
{
Expand Down
22 changes: 10 additions & 12 deletions x360ce.App.Beta/Common/TestDeviceHelper.cs
Expand Up @@ -111,13 +111,14 @@ public static JoystickState GetCurrentState(UserDevice ud)
// Enable button during its index.
state.Buttons[i] = currentLocation == i;
}
var busy = 4000;
var half = busy / 2;
var idle = 2000;
// Do action for 4 seconds, then stay for 2 seconds idle.
// Do action for 4 seconds [0-3999] ms.
var busy = 4000;
var half = busy / 2;
// then stay for 2 seconds idle [4000-5999] ms.
var idle = 2000;
// 6 = 4 + 2.
var time = tm % (busy + idle);
var invert = tm % ((busy + idle) * 2) > (busy + idle);
var invert = tm % ((busy + idle) * 2) > (busy + idle);
// Set POVs.
for (int i = 0; i < ud.CapPovCount; i++)
{
Expand All @@ -140,7 +141,6 @@ public static JoystickState GetCurrentState(UserDevice ud)
}
state.PointOfViewControllers[i] = degree;
}

// Set Axis.
var axis = CustomDiState.GetAxisFromState(state);
// Get information about axis.
Expand All @@ -149,9 +149,7 @@ public static JoystickState GetCurrentState(UserDevice ud)
for (int i = 0; i < axisObjects.Count(); i++)
{
var ao = axisObjects[i];
//var axisMask = CustomDiState.GetAxisMask();
//

// If axis index is even.
var isEven = i % 2 == 0;
var position = isEven
// Default position is in the center.
Expand All @@ -174,10 +172,10 @@ public static JoystickState GetCurrentState(UserDevice ud)
else
{
position = time < half
// Move up.
// Move up [0-1999].
? ConvertHelper.ConvertRange(0, half - 1, ushort.MinValue, ushort.MaxValue, time)
// Move down.
: ConvertHelper.ConvertRange(half, busy - 1, ushort.MaxValue, ushort.MinValue, time);
// Move down [2000-3999].
: ConvertHelper.ConvertRange(half, busy - 1, ushort.MaxValue, ushort.MinValue, time);
}
}
axis[i] = position;
Expand Down
286 changes: 155 additions & 131 deletions x360ce.App.Beta/Controls/PerformanceTestUserControl.Designer.cs

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

0 comments on commit a5ac300

Please sign in to comment.