Skip to content

Single-header cross-platform hooked-input-state-to-memory binding library

License

Notifications You must be signed in to change notification settings

GeeTwentyFive/InputMonitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Binds state of target input key/click to passed *OUT_state address. Inputs are hooked so state will update even if application is not in focus.

Target types:

  • INPUTMONITOR__TARGET_KEYBOARD
  • INPUTMONITOR__TARGET_MOUSE

Binding:

int InputMonitor__Bind(InputMonitor__target_type targetType, unsigned short target, int *OUT_state)

target is one of libuiohook's key/click definitions.

^ Ex.: VC_A, MOUSE_BUTTON1, etc.

Returns 1 upon success, & 0 upon failure.


All bindings can be cleared via:

InputMonitor__ClearBindings()

Maximum number of possible bindings can be changed by changing the constant: INPUTMONITOR__MAX_BINDINGS (default: 256) in InputMonitor.h.

Example:

int stateA = 0;
if (!InputMonitor__Bind(INPUTMONITOR__TARGET_KEYBOARD, VC_A, &stateA)) {
        puts("ERROR: Failed to register 'A'");
        return 1;
}

int stateLMB = 0;
if (!InputMonitor__Bind(INPUTMONITOR__TARGET_MOUSE, MOUSE_BUTTON1, &stateLMB)) {
        puts("ERROR: Failed to register LMB");
        return 1;
}



for(;;) { printf("A: %d\nLMB: %d\n", stateA, stateLMB); Sleep(10); }

Building:

cc main.c -Lexternal/libuiohook -luiohook

About

Single-header cross-platform hooked-input-state-to-memory binding library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages