-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputDirectorPatches.cs
39 lines (33 loc) · 1.48 KB
/
InputDirectorPatches.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using HarmonyLib;
using InControl;
using Steamworks;
using UnityEngine;
namespace SteamInputFixMod
{
[HarmonyPatch(typeof(InputDirector))]
[HarmonyPatch("GetSteamDeviceIcon")]
internal class GetSteamDeviceIconPatch
{
private static Dictionary<int, Sprite> additionalIconSprites = new Dictionary<int, Sprite>();
private static string currentActionStr;
private static bool currentIsPauseAction;
private static void Prefix(string actionStr, bool isPauseAction)
{
currentActionStr = actionStr;
currentIsPauseAction = isPauseAction;
}
private static void Postfix(ref Sprite __result)
{
var uiTemplates = SRSingleton<GameContext>.Instance.UITemplates;
var activeSteamInputDevice = (SteamInputDevice)InputManager.ActiveDevice;
var handle = activeSteamInputDevice.GetController();
var inputType = SteamController.GetInputTypeForHandle(handle);
var origin = activeSteamInputDevice.GetOrigin(currentActionStr, currentIsPauseAction);
var translatedOrigin = SteamController.TranslateActionOrigin(ESteamInputType.k_ESteamInputType_Unknown,
(EControllerActionOrigin)origin);
if (__result == uiTemplates.unknownButtonIcon || ModConfig.GeneralConfig.useAlways)
__result = ButtonStyleHandler.Get().GetSprite(currentActionStr, currentIsPauseAction);
}
}
}