Compare commits

...

2 Commits

Author SHA1 Message Date
paring 82ecaea730 fix: freeze on stop 2022-11-04 22:29:12 +09:00
paring c98e1400a2 feat: add macos libraries 2022-11-03 22:10:08 +09:00
9 changed files with 161 additions and 49 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

View File

@ -1,3 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
@ -54,8 +57,10 @@ namespace SkyHook
KeyUpdated.Invoke(ev); KeyUpdated.Invoke(ev);
} }
private void StartHook() private void _StartHook()
{ {
if (_started) return;
var result = SkyHookNative.StartHook(HookCallback); var result = SkyHookNative.StartHook(HookCallback);
if (result != null) if (result != null)
@ -66,7 +71,7 @@ namespace SkyHook
_started = true; _started = true;
} }
private void StopHook() private void _StopHook()
{ {
if (!_started) return; if (!_started) return;
@ -78,22 +83,23 @@ namespace SkyHook
} }
_started = false; _started = false;
_started = false;
} }
public static void Start() public static void StartHook()
{ {
Instance.StartHook(); Instance._StartHook();
} }
public static void Stop() public static void StopHook()
{ {
Instance.StopHook(); Instance._StopHook();
} }
private void OnDestroy() private void OnDestroy()
{ {
Debug.Log("Destroy"); _StopHook();
StopHook();
} }
private void Update() private void Update()

View File

@ -2,16 +2,16 @@ using System.Runtime.InteropServices;
namespace SkyHook namespace SkyHook
{ {
internal class SkyHookNative internal static class SkyHookNative
{ {
public delegate void Callback(SkyHookEvent ev); public delegate void Callback(SkyHookEvent ev);
private const string LIB = "skyhook"; private const string Lib = "skyhook";
[DllImport(LIB, EntryPoint = "start_hook", CallingConvention = CallingConvention.Cdecl)] [DllImport(Lib, EntryPoint = "start_hook", CallingConvention = CallingConvention.Cdecl)]
public static extern string StartHook(Callback callback); public static extern string StartHook(Callback callback);
[DllImport(LIB, EntryPoint = "stop_hook", CallingConvention = CallingConvention.Cdecl)] [DllImport(Lib, EntryPoint = "stop_hook", CallingConvention = CallingConvention.Cdecl)]
public static extern string StopHook(); public static extern string StopHook();
} }
} }

8
plugins/aarch64.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d364b220d4f544d8d8f84c8a15d27269
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
plugins/aarch64/libskyhook.dylib Executable file

Binary file not shown.

View File

@ -0,0 +1,64 @@
fileFormatVersion: 2
guid: 6ec8e172783fb4da5815df3c8c450a1a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 0
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: ARM64
DefaultValueInitialized: true
OS: OSX
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: ARM64
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,53 +11,17 @@ PluginImporter:
isExplicitlyReferenced: 0 isExplicitlyReferenced: 0
validateReferences: 1 validateReferences: 1
platformData: platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 1
- first: - first:
Any: Any:
second: second:
enabled: 0 enabled: 1
settings: {} settings: {}
- first: - first:
Editor: Editor Editor: Editor
second: second:
enabled: 0 enabled: 0
settings: settings:
CPU: AnyCPU
DefaultValueInitialized: true DefaultValueInitialized: true
OS: Windows
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

BIN
plugins/x86_64/libskyhook.dylib Executable file

Binary file not shown.

View File

@ -0,0 +1,69 @@
fileFormatVersion: 2
guid: 64e8137adce094429a9428464a954f6a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude WebGL: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: x86_64
DefaultValueInitialized: true
OS: OSX
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: x86_64
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant: