Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
evilC authored Dec 15, 2019
1 parent 98e39a9 commit 3bc7901
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,34 @@ Subscription Mode overrides Context Mode - that is, if a key on a keyboard has b
Each Subscribe endpont also has a corresponding Unsubscribe endpoint, which removes the subscription and any block associated with it.

#### Subscribing to Keyboard keys
Subscribe to a key on a specific keyboard
##### Subscribe to a specific key on a specific keyboard
`SubscribeKey(<deviceId>, <scanCode>, <block>, <callback>, <concurrent>)`
`UnsubscribeKey(<deviceId>, <scanCode>)`
```
AHI.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent"))
return
```
eg
`AHI.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent"))`

Callback function is passed state `0` (released) or `1` (pressed)
```
KeyEvent(state){
ToolTip % "State: " state
}
```

Parameter `<concurrent>` is optional and is <b>false</b> by default meaning that all the events raised for that key will be handled sequentially (i.e. callback function will be called on a single thread). If set to <b>true</b>, a new thread will be created for each event and the callback function will be called on it.

##### Subscribe to all keys on a specific keyboard
`SubscribeKeyboard(<deviceId>, <block>, <callback>, <concurrent>)`
eg
`AHI.SubscribeKeyboard(keyboardId, true, Func("KeyEvent"))`

Callback function is passed scancode of pressed key and state
```
KeyEvent(code, state){
ToolTip % "Keyboard Key - Code: " code ", State: " state
}
```

#### Subscribing to Mouse Buttons
##### Subscribing to a specific button on a specific mouse
`SubscribeMouseButton(<deviceId>, <button>, <block>, <callback>, <concurrent>)`
`UnsubscribeMouseButton(<deviceId>, <button>)`
Where `button` is one of:
Expand All @@ -234,6 +245,18 @@ For Mouse Wheel events, the `<state>` parameter will be `1` for Wheel Up / Right

Otherwise, usage is identical to `SubscribeKey`

##### Subscribing to all buttons on a specific mouse
`SubscribeMouseButtons(<deviceId>, <block>, <callback>, <concurrent>)`
eg
`AHI.SubscribeMouseButtons(mouseId, true, Func("MouseButtonEvent"))`

Callback function is passed ID (See above) of pressed button and state
```
MouseButtonEvent(code, state){
ToolTip % "Mouse Button - Code: " code ", State: " state
}
```

#### Subscribing to Mouse Movement
**Warning!** When Subscribing to mouse movement, you will get **LOTS** of callbacks.
Note the CPU usage of the demo Monitor app.
Expand Down

0 comments on commit 3bc7901

Please sign in to comment.