A way to get higher resolution mouse callbacks


#1

Hi, I would like to know if anybody has any recommended methods for getting higher resolution mouse move/drag data.

I am trying to implement a drawing function that can trace drawn pathways at a slow rate, but of course the mouse drag coordinates are very course, and the tracing is very jumpy. I am doing interpolation currently, and though it works, it’s not perfect.

I’d rather just get higher density of mouse data. Could anybody give me advice or a general strategy? Is there something simple I’m missing?


#2

I believe that if you want a higher sampling rate for the mouse position, you will need to do something platform-specific.


#3

Yes - juce will give you all the mouse-events that arrive, but it’s really up to the OS how many events are generated…


#4

Is there a way to set up my own timer function and poll the mouse as fast as I want? i.e. can I sort of reverse the observer pattern? Could I say, “mouse, where are you now?” rather than wait for the mouse to tell me? I can’t find any classes in juce that do this, so is it possible at all?


#5

The Desktop class lets you get the mouse position, but obviously you’d have to use a thread rather than a timer, because you’d need to get away from the event thread.

(But of course, the mouse position that the OS gives you get when you poll it might just be the position of the last mouse event that was dispatched, so you might write all this code and still find that it’s no better than just using the events…)