Closed diejozef closed 8 years ago
I'm sorry but I've never found this issue, my bet is that you're making some mistake in your code.
Here is my code, it has the same structure as one of your examples.
interception_set_filter(context, interception_is_keyboard, INTERCEPTION_FILTER_KEY_DOWN | INTERCEPTION_FILTER_KEY_UP);
interception_set_filter(context, interception_is_mouse, INTERCEPTION_FILTER_MOUSE_ALL);
while (interception_receive(context, device = interception_wait(context), (InterceptionStroke *)&stroke, 1) > 0)
{
if (interception_is_mouse(device))
{
InterceptionMouseStroke &mstroke = *(InterceptionMouseStroke *)&stroke;
bool b = (mstroke.state == INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN);
std::cout << b << std::endl;
interception_send(context, device, &stroke, 1);
}
if (interception_is_keyboard(device))
{
InterceptionKeyStroke &kstroke = *(InterceptionKeyStroke *)&stroke;
interception_send(context, device, &stroke, 1);
if (kstroke.code == SCANCODE_ESC) break;
}
}
When I hold the LMB, it prints 1 in the console one time. My goal would be to run the code inside the while loop the whole time LMB is being held down(so basically it would spam 1s in the console).
The mouse device is stateful, it means you will have to handle when it goes down and when it goes up, you have to detect this change of state yourself. When the button changes to down you start something that you request to stop when the button changes to up.
You may "start something" in another thread. And you will have to use some synchronization to ask the thread to finish.
Thank you very much for your help and fast answers!
Hey,
First of all, thanks for this amazing library you made.
I wanto to ask if it's possible to detect a mouse button that is held down? I've added a filter for mouse down/up events but it only registers one time(when the button is pressed) and it won't register anything until I release that specific button.
Thanks in advance!