Reply to thread

The problem is that the hook gets disabled even when Windows is not low on resources. I've done some more testing; I actually already implemented the faster key mapping lookup and temporarily disabled actually executing the action. This results in the keyboard hook being disabled less frequently, although still quite often. It looks as if the hook gets disabled whenever a key is pressed while MediaPortal is doing 'something' (for example while loading a new screen).


According to LowLevelKeyboardProc callback function, the hook is called in the context of the thread that created it by sending a message to that thread. As I don't do any thread management myself in the plug-in, I guess the hook is installed in the main MediaPortal UI thread. Could it be that MediaPortal blocks the message queue while 'doing' something, resulting in the hook not being called in time?


Maybe we could install the hook in a separate thread, with its own message loop? However, I'm not sure on how to implement that, and whether that would actually work. For example, maybe each thread will then handle key presses independent from the other, resulting in a situation that MediaPortal still sees the key press on the main thread even when it was handled by the hook in the second thread?


I'm no Windows expert (usually I only do Java development), so I'm just guessing here...


Top Bottom