Compare commits

..

5 Commits

Author SHA1 Message Date
paring a22bd2ba7e
chore: comments for event struct 2022-11-03 21:18:15 +09:00
paring 8fd4c05a2f
fix: isFocused is always false 2022-11-03 21:17:18 +09:00
paring 56672b497f
chore: set root namespace 2022-11-03 21:16:58 +09:00
paring b91d8cc4f4
chore: update native binary 2022-11-03 21:16:50 +09:00
paring 09e6a18b6f
fix: compile error 2022-11-03 21:00:12 +09:00
4 changed files with 20 additions and 9 deletions

View File

@ -1,13 +1,24 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace SkyHook namespace SkyHook
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public struct SkyHookEvent public struct SkyHookEvent
{ {
public ulong Time; /// <summary>
public short Type; /// When the key was pressed
public uint Key; /// </summary>
public readonly ulong Time;
/// <summary>
/// The key is pressed or released
/// </summary>
public readonly EventType Type;
/// <summary>
/// The key number that was pressed or released
/// </summary>
public readonly uint Key;
} }
public enum EventType public enum EventType

View File

@ -1,6 +1,6 @@
{ {
"name": "SkyHook.Unity", "name": "SkyHook.Unity",
"rootNamespace": "", "rootNamespace": "SkyHook",
"references": [], "references": [],
"includePlatforms": [ "includePlatforms": [
"Editor", "Editor",

View File

@ -7,7 +7,7 @@ namespace SkyHook
{ {
private static SkyHookManager _instance; private static SkyHookManager _instance;
private static bool IsFocused; private static bool _isFocused;
/// <summary> /// <summary>
/// Whether or not the event will be received only if the game window is focused. /// Whether or not the event will be received only if the game window is focused.
@ -46,7 +46,7 @@ namespace SkyHook
private void HookCallback(SkyHookEvent ev) private void HookCallback(SkyHookEvent ev)
{ {
if (RequireFocus && !IsFocused) if (RequireFocus && !_isFocused)
{ {
return; return;
} }
@ -96,11 +96,11 @@ namespace SkyHook
StopHook(); StopHook();
} }
private void Run() private void Update()
{ {
if (requireFocus) if (RequireFocus)
{ {
IsFocused = Application.isFocused; _isFocused = Application.isFocused;
} }
} }
} }

Binary file not shown.