I am trying to write a Linux kernel module to work similar to a 'MouseKeys' application - to grab certain keys and then output mouse events. I'm currently struggling trying to grab input in such a way that I can discard or passthrough keys based on some internal state of my module - what I want is something like:
int keyboard_callback(event) {
if (active) {
processKey(event); // this would output mouse events
return BLOCK_KEY_EVENT; // input is not visible to any applications
}
// input would be processed downstream as normal
return PASSTHROUGH_KEY_EVENT;
}
....
register_input_handler(keyboard_callback);