chore: edit content for clarity

fix/data-structure
CrackThrough 2022-11-06 23:33:45 +09:00
parent fb3c7bc175
commit 5f60640709
1 changed files with 20 additions and 13 deletions

View File

@ -1,51 +1,58 @@
# SkyHook-Native # SkyHook-Native
dynamic library of SkyHook for use with other languages Dynamic library of SkyHook for use with other languages.
## Usage ## Usage
The following examples are all in C# The following examples are all in C#.
### Functions ### Functions
The exported functions are simple. Just `start_hook` and `stop_hook` The extern functions that you should run are simple.
### start_hook There are just two; [`start_hook`](#starthook) and [`stop_hook`](#stophook).
### `start_hook`
```cs ```cs
// Here, we assign a callback along with starting a hook.
// The NativeEvent type is declared below "Types" header.
public static delegate void HookCallback(NativeEvent ev); public static delegate void HookCallback(NativeEvent ev);
// Here, we have an extern method to invoke.
[DllImport("skyhook", EntryPoint = "start_hook")] [DllImport("skyhook", EntryPoint = "start_hook")]
public static extern void StartHook(HookCallback callback); public static extern void StartHook(HookCallback callback);
``` ```
### stop_hook ### `stop_hook`
```cs ```cs
// No additional information required to provide when stopping the hook.
[DllImport("skyhook", EntryPoint = "stop_hook")] [DllImport("skyhook", EntryPoint = "stop_hook")]
public static extern void StopHook(); public static extern void StopHook();
``` ```
### Types ### Types
### NativeEventType ### `NativeEventType`
```cs ```cs
public enum NativeEventType { public enum NativeEventType {
KeyPressed, KeyPressed,
KeyReleased KeyReleased
} }
``` ```
### NativeEvent ### `NativeEvent`
```cs ```cs
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct NativeEvent public struct NativeEvent
{ {
public readonly ulong Time; public readonly ulong Time; // This is the key state update time.
public readonly EventType Type; public readonly NativeEventType Type; // Whether the key is up or down.
public readonly uint Key; public readonly ushort Label; // Unified label for keys, such as ESC or F11.
public readonly ushort Key; // Actual key code from native level.
} }
``` ```
@ -55,4 +62,4 @@ public struct NativeEvent
git clone https://git.pikokr.dev/SkyHook/SkyHook-Native #Clone git clone https://git.pikokr.dev/SkyHook/SkyHook-Native #Clone
``` ```
to build, just run `build.sh` on Linux of MacOS, `build.ps1` on Windows To build, just run [`build.sh`](build.sh) on Linux of MacOS, [`build.ps1`](build.ps1) on Windows.