LiveSplit / livesplit-core

livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.

Home Page:https://livesplit.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a way to get the next hotkey pressed

Hurricane996 opened this issue · comments

In certain contexts, when implementing a timer using this lib, the implementor will want to provide the user with a way to press a key which will then be set as a hotkey. However, if the implementor is using an input system which doesn't map surjectively (ie if two keypresses are the same according to the implementor's input system, they are the same according to livesplit-hotkey) to livesplit (eg winit/glutin), this becomes impossible to actually do without registering and then deregistering a hook for every single hotkey.

My proposal to fix this is to add a register_global_hook function that will call a callback whenever livesplit-hotkey recieves any keypress and provide that callback with the key that was pressed.

I'm a bit hesitant adding this API (I considered it before) because some backends might not support listening to all keys and instead only to specific ones. But all current APIs do, so I guess we can try implementing this.