Key messages affecting mouse?

Hi,

I’m trying to use the space bar as a modifier key, and from what I can tell the repeated “KeyDown” messages are preventing the “MouseDown” messages from coming through. I tried using

set_key_repeat_rate(2)

to keep the key rate down to 2 per second (that seems to be the minimum) but the mouse events still don’t seem to get through often enough. (I also tried set_key_repeat_delay with no luck). Is there a better way to do this, or is it just not a good idea to use a non-modifier key as a key that a user might hold down while moving the mouse?

Thanks,
Dale

I’m not able to give any helpful answers (of course)…
But maybe the code of another graphics app can give hints. See WonderBrush’s CanvasView.cpp#L466.

Thanks, I didn’t see anything super obvious there.

BUT - WonderBrush experiences the exact same issue as I do - so it’s either:

a) we both have the same bug
b) a bug in Haiku
c) my mouse / keyboard / VirtualBox / sunspots

I don’t know how the issue presents, but my guess would be VirtualBox trouble. I just installed Beta3 in VirtulBox under Linux. The panning in WonderBrush doesn’t work at all when VBox is set to “PS/2 mouse” and only a bit stuttering when set to “USB Tablet”.

Maybe Qemu behaves better in thiat case, I haven’t tried yet.

On PS/2 keyboards the key repeat rate is handled by the hardware. So it all depends in wether the keyboard (emulated in virtualbox case) implements this correctly. I would say it is not a great idea for an application to change the keyboard configuration (that’s a global setting so at least you have to be very careful to restore it when you’re done with the dragging operation).

However I don’t see how that would interfere with MouseDown messages.

I’m not sure what you want to do, as you are talking about “often enough” for mouse down messages. That message is sent only once when the mouse button is pressed. If you want to track a drag or something like that, it can be done using SetMouseEventMask (The Be Book - Classes And Methods - The Interface Kit) to continue receiving events while the mouse button is pressed.

Thanks @PulkoMandy. I didn’t explain very well. Basically I want to do a click-drag but using space bar instead of a modifier. Changing the repeat rate worked to slow down the rate of incoming key messages, and I did restore the repeat rate immediately after releasing space bar.

However I changed the code to use a B_SKIP_MESSAGE within an input filter which felt like a much more proper solution, and it works perfectly to simply skip all the repeats while the key is held down.

But here’s a clearer explanation of what I see:

  1. Press and hold space bar → B_KEY_DOWN
  2. Click left mouse button → B_MOUSE_DOWN
  3. Release mouse button → B_MOUSE_UP
  4. Click left mouse button → no message
  5. Release mouse button → B_MOUSE_UP

Basically only B_MOUSE_DOWN messages go missing, and only when a non modifier key is held down.

In any case @humdinger doesn’t experience this on real hardware so I suspect it’s a virtualization issue. I should get a real box for Haiku!

Not really sure they are related but…

Are you using “Tablet USB” instead of a “PS/2 mouse” as a pointing device on VirtualBox?

I wonder because there are some issues with drag-and-drop in Qt based apps, that only happen when using that setting on VBox (Drag and drop broken in VM with absolute positioned pointer device · Issue #20 · threedeyes/qthaikuplugins · GitHub).