I am trying DigiMouse library for attiny85 Digispark board.
It allows to emulate the mouse quite well. However, I also need to know the current cursor position. Is there a way to get it?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
There is no way for a mouse of any kind (especially not one as minimal as DigiMouse.h) to know the current cursor position - USB just doesn't provide that kind of facility.
Instead you need to implement an "absolute" mouse (aka a "tablet"). However DigiMouse doesn't implement such a facility. So you would have to implement your own tablet driver.
A normal mouse sends a "delta" for the position. That is, a difference in position from whatever the current position is. An absolute mouse, or tablet, sends the position on the screen as a proportion of some maximum set of dimensions. Ideally that would be the same dimensions as your screen, but doesn't have to be.
The main differences between DigiMouse and whatever you would implement for a DigiTablet would be the "HID Report Descriptor". This defines what the data that is sent means and how the computer should interpret it.