这些博客可能对你有帮助:
https://blog.csdn.net/m0_38143858/article/details/79855923
https://blog.csdn.net/baozaodedianxiaoer/article/details/80134658
https://blog.csdn.net/wuyf88/article/details/68942196
1、在罗技官网下载最新的罗技游戏软件。https://www.logitechg.com/en-us/partnerdeveloperlab/sdk-resource-list/steering-wheel-sdk.html
2、在assetstore中下载Logitech Gaming SDK,导入 Logitech SDK 。把官网下载的LogitechSteeringWheelEnginesWrapper.dll替换Unity3D中的。
直接把Script Sample中的LogitechSteeringWheel.cs挂载空物体中,运行。
- 使用LogitechGSDK.cs脚本需要先初始化,LogiSteeringInitialize();
- 要在代码中调用来自罗技SDK的任何函数,请导入LogitechGSDK.cs脚本并静态调用函数。
- 函数LogiSteeringInitialize()会试图获得你的应用程序/游戏主窗口句柄。它可能会失败,因为当你调用该函数时的主窗口可能不会在最前面的界面。
- 如果LogiSteeringInitialize()返回false,初始化将会接受任何尝试下一个LogiUpdate()函数的调用。当窗口在最前界面时和SDK可以初始化,LogiUpdate()将返回true。
- 【但我曾经出现过一个状况是:在Start()里LogiSteeringInitialize()返回是false,然后就算当前窗口已经是最前界面了,Update()里LogiUpdate()还是一直返回false,后来试着在Start()里加一个循环,一直循环LogiSteeringInitialize()直到返回true就完美解决问题了。】
- 如果连接成功(函数LogiSteeringInitialize和LogiUpdate,返回true),但只能获取方向盘的按钮,获取不了方向盘旋转的数据可能是线没插紧的原因。
我用了下LogiIsDeviceConnected()去获取方向盘、脚踏板、档位器的状态,但只有LOGI_DEVICE_TYPE_WHEEL返回true,其他(LOGI_DEVICE_TYPE_JOYSTICK、LOGI_DEVICE_TYPE_GAMEPAD、LOGI_DEVICE_TYPE_OTHER)都是返回false,不知道为什么获取不到连接状态,如果知道的,望告知 QAQ
public class LogitechControllerController : MonoBehaviour {
private static LogitechControllerController instance = null;
public static LogitechControllerController GetInstance()
{
if (instance == null)
{
instance = new GameObject("LogitechControllerCtrl").AddComponent<LogitechControllerController>();
//1、初始化,看需求初始化。
bool flag = false;
while (flag == false)
{
//Debug.Log("SteeringInit:" + LogitechGSDK.LogiLedInit());
//Debug.Log("SteeringInit2:" + LogitechGSDK.LogiSteeringInitialize(false));
flag = LogitechGSDK.LogiSteeringInitialize(false);
Debug.Log("SteeringInit:" + flag);
}
}
return instance;
}
//2、更新
private void Update()
{
if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
{
//。。。。。。
}
}
//3、退出前
void OnApplicationQuit()
{
Debug.Log("SteeringShutdown:" + LogitechGSDK.LogiSteeringShutdown());
}
}
【因为我不肯定机翻的误差多大,但大部分都是能看懂的,不过最好还是一边官方文档一边我这文哈哈哈】
1、LogiSteeringInitialize 主窗口初始化
bool LogiSteeringInitialize(bool ignoreXInputControllers);
ignoreXInputControllers:忽略X输入控制器
【只允许一个用户在任何给定时间来控制,如果两个应用程序同时初始化SDK设备,只有第一个获取成功,第二个应用程序获取失败。】
函数LogiSteeringInitialize()会试图获得你的应用程序/游戏主窗口句柄。它可能会失败,因为当你调用该函数时的主窗口可能不会在最前面的界面。
如果LogiSteeringInitialize()返回false,初始化将会接受任何尝试下一个LogiUpdate()函数的调用。当窗口在最前界面时和SDK可以初始化,LogiUpdate()将返回true。
2、获取设备数据前,要判断设备是否连接和更新【LogiUpdate()和LogiIsConnected(0)】
(1)LogiUpdate 主窗口设备更新
Bool LogiUpdate()
该LogiUpdate()查找主窗口处理程序,如果已经发现力和控制器 保持连接最新的。它被称为应用程序的每一帧。
返回false,可能是LogiSteeringInitialize()没有被调用/已无法找到主窗口句柄。
(2)LogiIsConnected 设备是否已连接
Bool LogiIsConnected(const int index)
该LogiIsConnected()函数检查游戏控制器是否连接在指定索引处
Index:游戏控制器的索引。0对应连接的第一个游戏控制器。1对应第二个游戏控制器。
(3)LogiGetStateUnity 获取设备状态
DIJOYSTATE2ENGINES LogiGetStateUnity(int index)
LogiGetStateUnity()返回结构体DIJOYSTATE2控制器的状态。
Index:游戏控制器的索引。0对应连接的第一个游戏控制器。1对应第二个游戏控制器。
(4)LogiGetFriendlyProductName 获取设备名
Bool LogiGetFriendlyProductName(int index, StringBuilder buffer, int bufferSize);
Index:游戏控制器的索引。0对应连接的第一个游戏控制器。1对应第二个游戏控制器。
Buffer:设备名
bufferSize:buffer长度
(5)DIJOYSTATE2结构体 包含设备的在坐标系中的位置信息,和POVs和按钮设备信息。
【大部分方向盘、脚踏、排挡杆数据可在这里获取】
public struct DIJOYSTATE2ENGINES
{
public int lX; /* x-axis position 【方向盘】 */
public int lY; /* y-axis position 【油门】 */
public int lZ; /* z-axis position */
public int lRx; /* x-axis rotation */
public int lRy; /* y-axis rotation */
public int lRz; /* z-axis rotation 【刹车】 */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] rglSlider; /* extra axes positions 【rglSlider[0]离合】 */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] rgdwPOV; /* POV directions */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] rgbButtons; /* 128 buttons */
public int lVX; /* x-axis velocity */
public int lVY; /* y-axis velocity */
public int lVZ; /* z-axis velocity */
public int lVRx; /* x-axis angular velocity */
public int lVRy; /* y-axis angular velocity */
public int lVRz; /* z-axis angular velocity */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] rglVSlider; /* extra axes velocities */
public int lAX; /* x-axis acceleration */
public int lAY; /* y-axis acceleration */
public int lAZ; /* z-axis acceleration */
public int lARx; /* x-axis angular acceleration */
public int lARy; /* y-axis angular acceleration */
public int lARz; /* z-axis angular acceleration */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] rglASlider; /* extra axes accelerations */
public int lFX; /* x-axis force */
public int lFY; /* y-axis force */
public int lFZ; /* z-axis force */
public int lFRx; /* x-axis torque */
public int lFRy; /* y-axis torque */
public int lFRz; /* z-axis torque */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] rglFSlider; /* extra axes forces */
};
//例子: 可在void Update()中写,获取方向盘数据。
if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
{
LogitechGSDK.DIJOYSTATE2ENGINES wheel;
wheel = LogitechGSDK.LogiGetStateUnity(0);
Debug.Log(wheel.lX);
}
3、LogiButton 方向盘按键
//例子:
//可在void Update()中写,获取按键信息
if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
{
if (LogitechGSDK.LogiButtonTriggered(0, 0))
Debug.Log("KeyCode.Joystick1Button0 方向盘 X 键");
if (LogitechGSDK.LogiButtonTriggered(0, 1))
Debug.Log("KeyCode.Joystick1Button1 方向盘 □ 键");
}
//或:
//(这种方法是根据参考官方的演示脚本中写的。
//如果只需要监听几个按钮,推荐上面的方法,且作用类似LogiButtonIsPressed,只要按下,wheel.rgbButtons[i]就返回true)
//但最推荐就是写一个脚本,把所有输入信息包装一下,用事件的形式触发。
if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
{
LogitechGSDK.DIJOYSTATE2ENGINES wheel;
wheel = LogitechGSDK.LogiGetStateUnity(0);
for (int i = 0; i < 128; i++)
{
if (wheel.rgbButtons[i] == 128)
{
switch (i)
{
case 0:
Debug.Log("KeyCode.Joystick1Button0 方向盘 X 键");
break;
case 1:
Debug.Log("KeyCode.Joystick1Button1 方向盘 □ 键");
break;
//。。。。。。。。。。
}
}
}
}
4、LogiControllerPropertiesData 控制器属性
public struct LogiControllerPropertiesData
{
public bool forceEnable; 使能力
public int overallGain; 整体
public int springGain; 弹簧力
public int damperGain; 阻尼力
public bool defaultSpringEnabled;默认弹簧力状态
public int defaultSpringGain; 默认弹簧力的大小
public bool combinePedals;
public int wheelRange; 轮范围
public bool gameSettingsEnabled;
public bool allowGameSettings;
}
5、LogiIsPlaying 力反馈是否发挥作用
bool LogiIsPlaying(const int index, const int forceType)检查是否有某个力正在发挥作用。
Force types:
public const int LOGI_FORCE_NONE = -1;
public const int LOGI_FORCE_SPRING = 0;
public const int LOGI_FORCE_CONSTANT = 1;
public const int LOGI_FORCE_DAMPER = 2;
public const int LOGI_FORCE_SIDE_COLLISION = 3;
public const int LOGI_FORCE_FRONTAL_COLLISION = 4;
public const int LOGI_FORCE_DIRT_ROAD = 5;
public const int LOGI_FORCE_BUMPY_ROAD = 6;
public const int LOGI_FORCE_SLIPPERY_ROAD = 7;
public const int LOGI_FORCE_SURFACE_EFFECT = 8;
public const int LOGI_NUMBER_FORCE_EFFECTS = 9;
public const int LOGI_FORCE_SOFTSTOP = 10;
public const int LOGI_FORCE_CAR_AIRBORNE = 11;
6、SpringForce 弹簧力
7、ConstantForce 恒力
8、DamperForce 阻尼力
9、LogiPlaySideCollisionForce 侧向碰撞力
10、LogiPlayFrontalCollisionForce 正向碰撞力
11、DirtRoadEffect土路效果
12、BumpyRoadEffect 颠簸路面效果
13、SlipperyRoadEffect 平滑路面效果
14、SurfaceEffect 路面响应效果
//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;
magnitudePercentage:指路面影响的程度。[0,100],超出范围的任何值将不起作用。
period:表示周期力作用的期限,值是毫秒为测量单位。
15、CarAirborne 模拟汽车在路面上腾空的效果
16、SoftstopForce 软停力
17、LogiPlayLeds 开启方向盘的LED灯
最后我做了一个辣鸡插件,如何使用在test里,供大家参考吧。
功能如下:
监控了方向盘 + 脚踏板 + 档位器中的如下数据
- 方向盘:
15 个按钮的触发事件(包括:刚点击触发一次,维持点击一直触发,松开时触发一次)
7 个按钮(pov)的触发事件(点击按钮时一直触发)
旋转红色旋钮的触发事件(每旋转一档旋钮时触发一次)
转动方向盘的数据事件- 脚踏板:
离合、刹车、油门的数据事件- 档位器:
7个档位的触发事件(包括:刚进入新档位时触发一次,维持档位一直触发,离开档位触发一次)
using System;
using System.Collections;
using UnityEngine;
namespace Sakura
{
///
/// Logitech输入设备
///
public enum LogitechSteeringWheelButtonType
{
///
/// 方向盘 X 键(按钮1)
///
x,
///
/// 方向盘 □ 键(按钮2)
///
rect,
///
/// 方向盘 ○ 键(按钮3)
///
circle,
///
/// 方向盘 △ 键(按钮4)
///
triangle,
///
/// 方向盘 右拨片 键(按钮5)
///
rightDialSlice,
///
/// 方向盘 左拨片 键(按钮6)
///
leftDialSlice,
///
/// 方向盘 R2 键(按钮7)
///
R2,
///
/// 方向盘 L2 键(按钮8)
///
L2,
///
/// 方向盘 SHARE 键(按钮9)
///
share,
///
/// 方向盘 OPTION 键(按钮10)
///
option,
///
/// 方向盘 R3 键(按钮11)
///
R3,
///
/// 方向盘 L3 键(按钮12)
///
L3,
///
/// 方向盘 + 键(按钮20)
///
plus,
///
/// 方向盘 - 键(按钮21)
///
subtract,
///
/// 方向盘 回车 键(按钮24)
///
enter,
///
/// 方向盘 logo 键(按钮25)
///
logoBtn
}
public enum CursorType
{
///
/// Up
/// rec.rgdwPOV[0] = 0
///
up,
///
/// UP-RIGHT
/// rec.rgdwPOV[0] = 4500
///
up_right,
///
/// right
/// rec.rgdwPOV[0] = 9000
///
right,
///
/// DOWN-RIGHT
/// rec.rgdwPOV[0] = 13500
///
down_right,
///
/// down
/// rec.rgdwPOV[0] = 18000
///
down,
///
/// DOWN-LEFT
/// rec.rgdwPOV[0] = 22500
///
down_left,
///
/// left
/// rec.rgdwPOV[0] = 27000
///
left,
///
/// UP-LEFT
/// rec.rgdwPOV[0] = 31500
///
up_left
}
public class LogitechController : MonoBehaviour
{
public GearShifter gearShifter;
public Pedals pedals;
public SteeringWheel steeringWheel;
private LogitechGSDK.DIJOYSTATE2ENGINES rec;
///
/// 方向盘
///
public class SteeringWheel
{
///
/// 刚点击按钮时触发一次
/// LogitechWheelButtonType:按钮类型
///
public Action<LogitechSteeringWheelButtonType> OnTriggered;
///
/// 维持点击按钮时一直触发
/// LogitechWheelButtonType:按钮类型
///
public Action<LogitechSteeringWheelButtonType> OnPressed;
///
/// 松开按钮时触发一次
/// LogitechWheelButtonType:按钮类型
///
public Action<LogitechSteeringWheelButtonType> OnReleased;
///
/// 点击按钮时触发一次,按住按钮一直触发
/// CursorType:方向类型
///
public Action<CursorType> OnCursor;
///
/// 每旋转一档旋钮时触发一次
/// bool:返回true,顺时针旋转;返回flase,逆时针旋转
///
public Action<bool> OnKnob;
///
/// 转动方向盘触发
/// float:不触碰方向盘,值一直为0,触碰后左扭到尽:-32768,右扭到尽为32767
///
public Action<float> OnSteeringWheel;
}
///
/// 脚踏板
///
public class Pedals
{
///
/// 离合
/// float:不触碰脚踏板,值一直为0,触碰后踩尽:-32768,松开为32767
///
public Action<float> Clutch;
///
/// 刹车
/// float:不触碰脚踏板,值一直为0,触碰后踩尽:-32768,松开为32767
///
public Action<float> Brake;
///
/// 油门
/// float:不触碰脚踏板,值一直为0,触碰后踩尽:-32768,松开为32767
///
public Action<float> Throttle;
}
///
/// 档位器
///
public class GearShifter
{
///
/// 刚进入新档位时触发一次
/// int:档位数(0:R档,1:1档,2:2档,以此类推)
///
public Action<int> OnTriggered;
///
/// 维持档位时一直触发
/// int:档位数(0:R档,1:1档,2:2档,以此类推)
///
public Action<int> OnPressed;
///
/// 离开档位时触发一次
/// int:档位数(0:R档,1:1档,2:2档,以此类推)
///
public Action<int> OnReleased;
}
private void Awake()
{
gearShifter = new GearShifter();
pedals = new Pedals();
steeringWheel = new SteeringWheel();
#region test
//gearShifter.OnTriggered += (index) => { Debug.Log(index + " OnTriggered"); };
//gearShifter.OnPressed += (index) => { Debug.Log(index + " OnPressed"); };
//gearShifter.OnReleased += (index) => { Debug.Log(index + "OnReleased "); };
//pedals.Clutch += (xx) => { Debug.Log(xx + "Clutch"); };
//pedals.Brake += (xx) => { Debug.Log(xx + "Brake"); };
//pedals.Throttle += (xx) => { Debug.Log(xx + "Throttle"); };
//steeringWheel.OnTriggered += (index) => { Debug.Log(index + " OnTriggered"); };
//steeringWheel.OnPressed += (index) => { Debug.Log(index + " OnPressed"); };
//steeringWheel.OnReleased += (index) => { Debug.Log(index + "OnReleased "); };
//steeringWheel.OnCursor += (inx) => { Debug.Log(inx + "OnReleased "); };
//steeringWheel.OnKnob += (inx) => { Debug.Log(inx + "OnReleased "); };
//steeringWheel.OnSteeringWheel += (inx) => { Debug.Log(inx + " "); };
#endregion
bool x = false;
while (x == false)
{
x = LogitechGSDK.LogiSteeringInitialize(false);
Debug.Log("SteeringInit:" + x);
}
//
}
private void Update()
{
if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
{
#region 档位器
//挡位 1 挡
if (LogitechGSDK.LogiButtonTriggered(0, 12))
{
if(gearShifter.OnTriggered != null) gearShifter.OnTriggered(1);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 12))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(1);
}
else if (LogitechGSDK.LogiButtonReleased(0, 12))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(1);
}
//挡位 2 挡
if (LogitechGSDK.LogiButtonTriggered(0, 13))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(2);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 13))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(2);
}
else if (LogitechGSDK.LogiButtonReleased(0, 13))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(2);
}
//挡位 3 挡
if (LogitechGSDK.LogiButtonTriggered(0, 14))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(3);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 14))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(3);
}
else if (LogitechGSDK.LogiButtonReleased(0, 14))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(3);
}
//挡位 4 挡
if (LogitechGSDK.LogiButtonTriggered(0, 15))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(4);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 15))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(4);
}
else if (LogitechGSDK.LogiButtonReleased(0, 15))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(4);
}
//挡位 5 挡
if (LogitechGSDK.LogiButtonTriggered(0, 16))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(5);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 16))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(5);
}
else if (LogitechGSDK.LogiButtonReleased(0, 16))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(5);
}
//挡位 6 挡
if (LogitechGSDK.LogiButtonTriggered(0, 17))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(6);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 17))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(6);
}
else if (LogitechGSDK.LogiButtonReleased(0, 17))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(6);
}
//挡位 R 挡
if (LogitechGSDK.LogiButtonTriggered(0, 18))
{
if (gearShifter.OnTriggered != null) gearShifter.OnTriggered(0);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 18))
{
if (gearShifter.OnPressed != null) gearShifter.OnPressed(0);
}
else if (LogitechGSDK.LogiButtonReleased(0, 18))
{
if (gearShifter.OnReleased != null) gearShifter.OnReleased(0);
}
#endregion
#region 脚踏板
rec = LogitechGSDK.LogiGetStateUnity(0);
//离合
if (pedals.Clutch != null) pedals.Clutch(rec.rglSlider[0]);
//刹车
if (pedals.Brake != null) pedals.Brake(rec.lRz);
//油门
if (pedals.Throttle != null) pedals.Throttle(rec.lY);
#endregion
#region 方向盘
rec = LogitechGSDK.LogiGetStateUnity(0);
if (steeringWheel.OnSteeringWheel != null) steeringWheel.OnSteeringWheel(rec.lX);
//方向盘 X 键
if (LogitechGSDK.LogiButtonTriggered(0, 0))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.x);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 0))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.x);
}
else if (LogitechGSDK.LogiButtonReleased(0, 0))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.x);
}
//方向盘 □ 键
if (LogitechGSDK.LogiButtonTriggered(0, 1))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.rect);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 1))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.rect);
}
else if (LogitechGSDK.LogiButtonReleased(0, 1))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.rect);
}
//方向盘 ○ 键
if (LogitechGSDK.LogiButtonTriggered(0, 2))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.circle);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 2))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.circle);
}
else if (LogitechGSDK.LogiButtonReleased(0, 2))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.circle);
}
//方向盘 △ 键
if (LogitechGSDK.LogiButtonTriggered(0, 3))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.triangle);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 3))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.triangle);
}
else if (LogitechGSDK.LogiButtonReleased(0, 3))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.triangle);
}
//方向盘 右拨片 键
if (LogitechGSDK.LogiButtonTriggered(0, 4))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.rightDialSlice);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 4))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.rightDialSlice);
}
else if (LogitechGSDK.LogiButtonReleased(0, 4))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.rightDialSlice);
}
//方向盘 左拨片 键
if (LogitechGSDK.LogiButtonTriggered(0, 5))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.leftDialSlice);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 5))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.leftDialSlice);
}
else if (LogitechGSDK.LogiButtonReleased(0, 5))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.leftDialSlice);
}
//方向盘 R2 键
if (LogitechGSDK.LogiButtonTriggered(0, 6))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.R2);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 6))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.R2);
}
else if (LogitechGSDK.LogiButtonReleased(0, 6))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.R2);
}
//方向盘 L2 键
if (LogitechGSDK.LogiButtonTriggered(0, 7))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.L2);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 7))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.L2);
}
else if (LogitechGSDK.LogiButtonReleased(0, 7))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.L2);
}
//方向盘 SHARE 键
if (LogitechGSDK.LogiButtonTriggered(0, 8))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.share);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 8))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.share);
}
else if (LogitechGSDK.LogiButtonReleased(0, 8))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.share);
}
//方向盘 OPTION 键
if (LogitechGSDK.LogiButtonTriggered(0, 9))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.option);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 9))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.option);
}
else if (LogitechGSDK.LogiButtonReleased(0, 9))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.option);
}
//方向盘 R3 键
if (LogitechGSDK.LogiButtonTriggered(0, 10))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.R3);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 10))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.R3);
}
else if (LogitechGSDK.LogiButtonReleased(0, 10))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.R3);
}
//方向盘 L3 键
if (LogitechGSDK.LogiButtonTriggered(0, 11))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.L3);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 11))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.L3);
}
else if (LogitechGSDK.LogiButtonReleased(0, 11))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.L3);
}
//方向盘 + 键
if (LogitechGSDK.LogiButtonTriggered(0, 19))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.plus);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 19))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.plus);
}
else if (LogitechGSDK.LogiButtonReleased(0, 19))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.plus);
}
//方向盘 - 键
if (LogitechGSDK.LogiButtonTriggered(0, 20))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.subtract);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 20))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.subtract);
}
else if (LogitechGSDK.LogiButtonReleased(0, 20))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.subtract);
}
//方向盘 回车 键
if (LogitechGSDK.LogiButtonTriggered(0, 23))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.enter);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 23))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.enter);
}
else if (LogitechGSDK.LogiButtonReleased(0, 23))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.enter);
}
//方向盘 logo 键
if (LogitechGSDK.LogiButtonTriggered(0, 24))
{
if (steeringWheel.OnTriggered != null) steeringWheel.OnTriggered(LogitechSteeringWheelButtonType.logoBtn);
}
else if (LogitechGSDK.LogiButtonIsPressed(0, 24))
{
if (steeringWheel.OnPressed != null) steeringWheel.OnPressed(LogitechSteeringWheelButtonType.logoBtn);
}
else if (LogitechGSDK.LogiButtonReleased(0, 24))
{
if (steeringWheel.OnReleased != null) steeringWheel.OnReleased(LogitechSteeringWheelButtonType.logoBtn);
}
//方向盘 红色滚轮右滚 键
if (LogitechGSDK.LogiButtonTriggered(0, 21))
{
if (steeringWheel.OnKnob != null) steeringWheel.OnKnob(true);
}
//方向盘 红色滚轮左滚 键
if (LogitechGSDK.LogiButtonTriggered(0, 22))
{
if (steeringWheel.OnKnob != null) steeringWheel.OnKnob(false);
}
switch (rec.rgdwPOV[0])
{
case (0): //Up
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.up);
break;
case (4500): // UP-RIGHT
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.up_left);
break;
case (9000): //right
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.right);
break;
case (13500): //DOWN-RIGHT
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.down_right);
break;
case (18000): //down
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.down);
break;
case (22500): //DOWN-LEFT
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.down_left);
break;
case (27000): //left
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.left);
break;
case (31500): //UP-LEFT
if (steeringWheel.OnCursor != null) steeringWheel.OnCursor(CursorType.up_left);
break;
}
#endregion
}
}
void OnApplicationQuit()
{
Debug.Log("SteeringShutdown:" + LogitechGSDK.LogiSteeringShutdown());
}
}
}