-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extra-natives): add a way to disable raw keys
This also merges the two implementations into one file since the only thing that differs between them is the hooking.
- Loading branch information
1 parent
0ec3c8f
commit 73bb067
Showing
12 changed files
with
211 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 0 additions & 100 deletions
100
code/components/extra-natives-rdr3/src/InputNatives.cpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## DISABLE_RAW_KEY_THIS_FRAME | ||
|
||
```c | ||
BOOL DISABLE_RAW_KEY_THIS_FRAME(int rawKeyIndex); | ||
``` | ||
Disables the specified `rawKeyIndex`, making it not trigger the regular `IS_RAW_KEY_*` natives. | ||
Virtual key codes can be found [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) | ||
## Parameters | ||
* **rawKeyIndex**: Index of raw key from keyboard. | ||
## Return value | ||
Returns bool value of down state. | ||
## Examples | ||
```lua | ||
local KEY_SPACE = 32 | ||
DisableRawKeyThisFrame(KEY_SPACE) | ||
-- This will not get triggered this frame | ||
if IsRawKeyDown(KEY_SPACE) then | ||
print("unreachable :(") | ||
end | ||
-- this will get triggered | ||
if IsDisabledRawKeyDown(KEY_SPACE) then | ||
print("Spacebar is down") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## IS_DISABLED_RAW_KEY_DOWN | ||
|
||
```c | ||
BOOL IS_DISABLED_RAW_KEY_DOWN(int rawKeyIndex); | ||
``` | ||
Gets if the specified `rawKeyIndex` is pressed down, even if the key is disabled with [DISABLE_RAW_KEY_THIS_FRAME](#_0x8BCF0014). | ||
Virtual key codes can be found [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) | ||
## Parameters | ||
* **rawKeyIndex**: Index of raw key from keyboard. | ||
## Return value | ||
Returns bool value of down state. | ||
## Examples | ||
```lua | ||
if IsDisabledRawKeyDown(32) then -- KEY_SPACE | ||
print("Spacebar is down") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## IS_DISABLED_RAW_KEY_PRESSED | ||
|
||
```c | ||
BOOL IS_DISABLED_RAW_KEY_PRESSED(int rawKeyIndex); | ||
``` | ||
Gets if the specified `rawKeyIndex` is pressed, even if the key is disabled with [DISABLE_RAW_KEY_THIS_FRAME](#_0x8BCF0014). | ||
Virtual key codes can be found [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) | ||
## Parameters | ||
* **rawKeyIndex**: Index of raw key from keyboard. | ||
## Return value | ||
Returns bool value of pressed state. | ||
## Examples | ||
```lua | ||
if IsDisabledRawKeyPressed(32) then -- KEY_SPACE | ||
print("Spacebar pressed") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## IS_DISABLED_RAW_KEY_RELEASED | ||
|
||
```c | ||
BOOL IS_DISABLED_RAW_KEY_RELEASED(int rawKeyIndex); | ||
``` | ||
Gets if the specified `rawKeyIndex` was released, even if the key is disabled with [DISABLE_RAW_KEY_THIS_FRAME](#_0x8BCF0014). | ||
Virtual key codes can be found [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) | ||
## Parameters | ||
* **rawKeyIndex**: Index of raw key from keyboard. | ||
## Return value | ||
Returns bool value of released state. | ||
## Examples | ||
```lua | ||
if IsDisabledRawKeyReleased(32) then -- KEY_SPACE | ||
print("Spacebar released") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## IS_DISABLED_RAW_KEY_UP | ||
|
||
```c | ||
BOOL IS_DISABLED_RAW_KEY_UP(int rawKeyIndex); | ||
``` | ||
Gets if the specified `rawKeyIndex` is up, even if the key is disabled with [DISABLE_RAW_KEY_THIS_FRAME](#_0x8BCF0014). | ||
Virtual key codes can be found [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) | ||
## Parameters | ||
* **rawKeyIndex**: Index of raw key from keyboard. | ||
## Return value | ||
Returns bool value of up state. | ||
## Examples | ||
```lua | ||
if IsDisabledRawKeyUp(32) then -- KEY_SPACE | ||
print("Spacebar is up") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.