Skip to content

Commit 648e5f5

Browse files
potentially fix misinput issues
1 parent fa79d33 commit 648e5f5

2 files changed

Lines changed: 26 additions & 209 deletions

File tree

AuthFix/AndroidKeyboardGuard.cs

Lines changed: 0 additions & 180 deletions
This file was deleted.

AuthFix/AuthPlugin.cs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BepInEx;
1+
using AmongUs.Data;
2+
using BepInEx;
23
using BepInEx.Configuration;
34
using BepInEx.Unity.IL2CPP;
45
using BepInEx.Unity.IL2CPP.Utils.Collections;
@@ -42,6 +43,8 @@ public partial class AuthPlugin : BasePlugin
4243
private static bool _ranLobbyJoin;
4344
private static bool _useKeyboard;
4445

46+
internal static bool UseKeyboardMode => Instance?.KeyboardMode?.Value ?? _useKeyboard;
47+
4548
public static string GetLobby()
4649
{
4750
return Marshal.PtrToStringUTF8(get_lobby()) ?? string.Empty;
@@ -204,54 +207,48 @@ static class ActiveInputManager_LastControllerPatch
204207
{
205208
public static bool Prefix()
206209
{
207-
if (!_useKeyboard)
210+
if (!UseKeyboardMode)
208211
{
209212
return true;
210213
}
211214

212-
if (ActiveInputManager.Instance.lastUsedController != null)
213-
{
214-
ActiveInputManager.Instance.lastUsedController = null;
215-
}
216-
AndroidKeyboardGuard.ForceKeyboardMode();
217215
return false;
218216
}
219217
}
220218

221219
[HarmonyPatch(typeof(ActiveInputManager), nameof(ActiveInputManager.UpdateActiveControlType))]
222220
static class ActiveInputManager_UpdatePatch
223221
{
224-
public static void Postfix()
222+
public static bool Prefix()
225223
{
226-
if (!_useKeyboard)
224+
if (!UseKeyboardMode)
227225
{
228-
return;
226+
return true;
229227
}
230228

231-
if (AndroidKeyboardGuard.ShouldUseKeyboardControls())
229+
ActiveInputManager.InputType inputType = ActiveInputManager.InputType.Keyboard;
230+
if (inputType != ActiveInputManager.currentControlType)
232231
{
233-
if (ActiveInputManager.Instance.lastUsedController != null)
232+
ActiveInputManager.CurrentInputSourceChanged?.Invoke();
233+
if (HudManager.InstanceExists)
234234
{
235-
ActiveInputManager.Instance.lastUsedController = null;
235+
HudManager.Instance.SetTouchType(ControlTypes.Keyboard);
236236
}
237-
238-
AndroidKeyboardGuard.ForceKeyboardMode();
239237
}
238+
return false;
240239
}
241240
}
242241

243-
[HarmonyPatch(typeof(ActiveInputManager), "ShouldEnableTouch")]
242+
[HarmonyPatch(typeof(ActiveInputManager), nameof(ActiveInputManager.ShouldEnableTouch))]
244243
static class ActiveInputManager_ShouldEnableTouchPatch
245244
{
246245
public static bool Prefix(ref bool __result)
247246
{
248-
if (!_useKeyboard)
247+
if (!UseKeyboardMode)
249248
{
250249
return true;
251250
}
252251

253-
if (!AndroidKeyboardGuard.ShouldUseKeyboardControls()) return true;
254-
255252
__result = false;
256253
return false;
257254
}
@@ -262,12 +259,12 @@ static class HudManager_SetTouchTypePatch
262259
{
263260
public static void Prefix(ref ControlTypes type)
264261
{
265-
if (!_useKeyboard)
262+
if (!UseKeyboardMode)
266263
{
267264
return;
268265
}
269266

270-
if (AndroidKeyboardGuard.ShouldUseKeyboardControls() && type != ControlTypes.Keyboard)
267+
if (type != ControlTypes.Keyboard)
271268
type = ControlTypes.Keyboard;
272269
}
273270
}
@@ -277,12 +274,12 @@ static class ConsoleJoystick_SetMapEnabledPatch
277274
{
278275
public static bool Prefix()
279276
{
280-
if (!_useKeyboard)
277+
if (!UseKeyboardMode)
281278
{
282279
return true;
283280
}
284281

285-
return !AndroidKeyboardGuard.IsKeyboardController();
282+
return false;
286283
}
287284
}
288285

@@ -291,12 +288,12 @@ static class ConsoleJoystick_UpdatePatch
291288
{
292289
public static bool Prefix()
293290
{
294-
if (!_useKeyboard)
291+
if (!UseKeyboardMode)
295292
{
296293
return true;
297294
}
298295

299-
return !AndroidKeyboardGuard.ShouldUseKeyboardControls();
296+
return false;
300297
}
301298
}
302299

@@ -305,12 +302,12 @@ static class ControllerManager_UpdatePatch
305302
{
306303
public static bool Prefix()
307304
{
308-
if (!_useKeyboard)
305+
if (!UseKeyboardMode)
309306
{
310307
return true;
311308
}
312309

313-
return !AndroidKeyboardGuard.ShouldUseKeyboardControls();
310+
return false;
314311
}
315312
}
316313

@@ -319,12 +316,12 @@ static class VirtualCursor_UpdatePatch
319316
{
320317
public static bool Prefix()
321318
{
322-
if (!_useKeyboard)
319+
if (!UseKeyboardMode)
323320
{
324321
return true;
325322
}
326323

327-
return !AndroidKeyboardGuard.ShouldUseKeyboardControls();
324+
return false;
328325
}
329326
}
330327

0 commit comments

Comments
 (0)