Compare commits
5 Commits
8d3287c36c
...
a22bd2ba7e
Author | SHA1 | Date |
---|---|---|
paring | a22bd2ba7e | |
paring | 8fd4c05a2f | |
paring | 56672b497f | |
paring | b91d8cc4f4 | |
paring | 09e6a18b6f |
|
@ -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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "SkyHook.Unity",
|
"name": "SkyHook.Unity",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "SkyHook",
|
||||||
"references": [],
|
"references": [],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor",
|
"Editor",
|
||||||
|
|
|
@ -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.
Reference in New Issue