Skip to content

Commit

Permalink
New patch fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRobinOfficial authored Apr 8, 2022
1 parent d5a4d89 commit 8bcc432
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
13 changes: 6 additions & 7 deletions Inputter/Runtime/LogitechG29.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using UnityEngine.Scripting;
using UnityEngine.Events;
using UnityEngine;
using System.Threading.Tasks;

#if UNITY_EDITOR
using UnityEditor;
Expand Down Expand Up @@ -83,7 +82,7 @@ public struct LogitechG29State : IInputStateTypeInfo
[InputControl(name = "clutchAxis", displayName = "Clutch", layout = "Button", parameters = "normalize,normalizeMin=1,normalizeMax=-1,normalizeZero=0")]
public short clutch;

public static FourCC Format => new('G', '2', '9');
public static FourCC Format => new('H', 'I', 'D');

public FourCC format => Format;

Expand Down Expand Up @@ -692,13 +691,13 @@ public bool PlayLeds(float currentRPM, float rpmMin, float rpmMax)
#if UNITY_EDITOR

private const string DEBUG_PATH = "Tools/Inputter/Enable Debug Mode";
private static bool debugMode = false;

[MenuItem(DEBUG_PATH)]
private static void EnableDebugMode()
{
debugMode = !debugMode;
Menu.SetChecked(DEBUG_PATH, debugMode);
var value = !EditorPrefs.GetBool(DEBUG_PATH);
EditorPrefs.SetBool(DEBUG_PATH, value);
Menu.SetChecked(DEBUG_PATH, value);
}

#endif
Expand Down Expand Up @@ -796,7 +795,7 @@ private static void Init()
Application.quitting += OnQuit;

#if UNITY_EDITOR
if (debugMode)
if (EditorPrefs.GetBool(DEBUG_PATH))
Debug.Log($"Logitech G29 {(init ? "has" : "has not")} been initialized");
#endif

Expand All @@ -813,7 +812,7 @@ private static void OnQuit()
LogitechGSDK.LogiSteeringShutdown();

#if UNITY_EDITOR
if (debugMode)
if (EditorPrefs.GetBool(DEBUG_PATH))
Debug.Log("Logitech G29 has been shutdown");
#endif

Expand Down
25 changes: 5 additions & 20 deletions Inputter/Runtime/LogitechSDK/LogitechGSDK.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text;
using System.Runtime.InteropServices;

public class LogitechGSDK
{
//STEERING WHEEL SDK
public const int LOGI_MAX_CONTROLLERS = 4;

//Force types

public const int LOGI_FORCE_NONE = -1;
public const int LOGI_FORCE_SPRING = 0;
public const int LOGI_FORCE_CONSTANT = 1;
Expand All @@ -26,35 +20,27 @@ public class LogitechGSDK
public const int LOGI_FORCE_SOFTSTOP = 10;
public const int LOGI_FORCE_CAR_AIRBORNE = 11;


//Periodic types for surface effect

public const int LOGI_PERIODICTYPE_NONE = -1;
public const int LOGI_PERIODICTYPE_SINE = 0;
public const int LOGI_PERIODICTYPE_SQUARE = 1;
public const int LOGI_PERIODICTYPE_TRIANGLE = 2;


//Devices types

public const int LOGI_DEVICE_TYPE_NONE = -1;
public const int LOGI_DEVICE_TYPE_WHEEL = 0;
public const int LOGI_DEVICE_TYPE_JOYSTICK = 1;
public const int LOGI_DEVICE_TYPE_GAMEPAD = 2;
public const int LOGI_DEVICE_TYPE_OTHER = 3;
public const int LOGI_NUMBER_DEVICE_TYPES = 4;


//Manufacturer types

public const int LOGI_MANUFACTURER_NONE = -1;
public const int LOGI_MANUFACTURER_LOGITECH = 0;
public const int LOGI_MANUFACTURER_MICROSOFT = 1;
public const int LOGI_MANUFACTURER_OTHER = 2;


//Model types

public const int LOGI_MODEL_G27 = 0;
public const int LOGI_MODEL_DRIVING_FORCE_GT = 1;
public const int LOGI_MODEL_G25 = 2;
Expand Down Expand Up @@ -101,7 +87,7 @@ public struct LogiControllerPropertiesData

public override string ToString()
{
var builder = new StringBuilder();
var builder = new System.Text.StringBuilder();
builder.AppendLine($"Properties Data");
builder.AppendLine($"Force Enable: {forceEnable}");
builder.AppendLine($"Overall Gain: {overallGain}%");
Expand All @@ -117,7 +103,6 @@ public override string ToString()
}
}


[StructLayout(LayoutKind.Sequential, Pack = 2)]
public struct DIJOYSTATE2ENGINES
{
Expand Down Expand Up @@ -166,7 +151,7 @@ public struct DIJOYSTATE2ENGINES
public static extern bool LogiUpdate();

[DllImport("LogitechSteeringWheelEnginesWrapper", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr LogiGetStateENGINES(int index);
public static extern System.IntPtr LogiGetStateENGINES(int index);

public static DIJOYSTATE2ENGINES LogiGetStateCSharp(int index)
{
Expand All @@ -193,10 +178,10 @@ public static DIJOYSTATE2ENGINES LogiGetStateCSharp(int index)
}

[DllImport("LogitechSteeringWheelEnginesWrapper", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiGetDevicePath(int index, StringBuilder str, int size);
public static extern bool LogiGetDevicePath(int index, System.Text.StringBuilder str, int size);

[DllImport("LogitechSteeringWheelEnginesWrapper", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiGetFriendlyProductName(int index, StringBuilder str, int size);
public static extern bool LogiGetFriendlyProductName(int index, System.Text.StringBuilder str, int size);

[DllImport("LogitechSteeringWheelEnginesWrapper", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiIsConnected(int index);
Expand Down
4 changes: 3 additions & 1 deletion Inputter/Samples/InputterTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public override void OnInspectorGUI()
}
#endif

[AddComponentMenu("Inputter/Samples/Inputter Tester"), DisallowMultipleComponent]
[RequireComponent(typeof(PlayerInput))]
public class InputterTester : MonoBehaviour
{
public float Steering { get; private set; }
Expand Down Expand Up @@ -79,7 +81,7 @@ private void Update()
LogitechG29.current[LogitechG29.G29Button.RightBumper].wasReleasedThisFrame)
Debug.Log("Button!");

Dpad = LogitechG29.current.dpad.ReadValue();
//Dpad = LogitechG29.current.dpad.ReadValue();
}
}
}

0 comments on commit 8bcc432

Please sign in to comment.