refactor
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Services.Console;
|
||||
using RebootKit.Engine.Services.Input;
|
||||
using Unity.Mathematics;
|
||||
@@ -12,7 +13,6 @@ using UnityEngine.InputSystem;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace RebootKit.FPPKit {
|
||||
|
||||
public static class FPPConfig {
|
||||
[ConfigVar("fpp.mouse.sens", 0.25f, "Mouse look sensitivity")] public static ConfigVar s_MouseSensitivity;
|
||||
[ConfigVar("fpp.mouse.invert.y", 0, "Invert mouse look")] public static ConfigVar s_MouseInvertY;
|
||||
@@ -21,20 +21,28 @@ namespace RebootKit.FPPKit {
|
||||
|
||||
public static class SensitivityReader {
|
||||
public static float2 Read(InputAction action) {
|
||||
if (action == null || action.activeControl == null) {
|
||||
return float2.zero;
|
||||
}
|
||||
|
||||
float2 sensitivity = action.ReadValue<Vector2>();
|
||||
|
||||
// @TODO: differentiate between gamepad and mouse
|
||||
|
||||
sensitivity *= FPPConfig.s_MouseSensitivity.FloatValue;
|
||||
bool isGamepad = action.activeControl.device is Gamepad;
|
||||
|
||||
if (FPPConfig.s_MouseInvertY.IndexValue == 1) {
|
||||
sensitivity.y *= -1;
|
||||
if (isGamepad) {
|
||||
sensitivity *= FPPConfig.s_GamepadSensitivity.FloatValue;
|
||||
} else {
|
||||
sensitivity *= FPPConfig.s_MouseSensitivity.FloatValue;
|
||||
|
||||
if (FPPConfig.s_MouseInvertY.IndexValue == 1) {
|
||||
sensitivity.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
return sensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class FPPPlayerController : IController {
|
||||
readonly Config m_Config;
|
||||
FPPActor m_FPPActor;
|
||||
|
||||
Reference in New Issue
Block a user