12

It seems to me that it could be useful in some cases to read higher precision values from the mouse, rather than just a range of discrete pixel coordinates over the current screen resolution. Obviously there is no need for this in GUIs, but for some games it might not even make any sense to associate it with screen resolution at all.

Why are we forced to read it as pixel coordinates instead of just raw analog values?

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Steve Vermeulen
  • 1,406
  • 1
  • 19
  • 25

4 Answers4

6

Under Windows at least, you can retrieve higher resolution coordinates, from 0 to 0xffff, rather than the mouse position translated to screen coordinates, for devices that support high-resolution reporting

Retrieves high resolution points. Points can range from zero to 65,535 (0xFFFF) in both x- and y-coordinates. This is the resolution provided by absolute coordinate pointing devices such as drawing tablets.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646259(v=vs.85).aspx

One can use non-standard scaling to achieve sub-pixel resolution on the Mac according to one answer here:

High resolution and high framerate mouse coordinates on OSX? (Or other solution?)

Neither answer to that question was accepted, but it may be worth further investigation.

Community
  • 1
  • 1
Eric J.
  • 147,927
  • 63
  • 340
  • 553
6

Windows uses WM_INPUT and WM_MOUSEMOVE, as well as DirectInput and XInput;

By default, it only supports WM_MOUSEMOVE for the main Windows GUI, which is entirely integer-based, but if you were to simultaneously implement WM_INPUT and WM_MOUSEMOVE, you could move the mouse cursor with Subpixel precision.

Some programs would obviously take a lot of advantage of this, such as 1st-person shooters, web browsers (zoomed pages and scrollbars), and image editing programs (such as GIMP, Adobe Photoshop/Illustrator, Paint.NET, etc...)

Plus, having the mouse simultaneously send WM_INPUT and WM_MOUSEMOVE, and having the Windows shell support it natively, would make mouse movement appear smoother in general; to make the most of this, you'd probably want to modify way mouse cursors work in Windows so that a variant of ClearType font rendering can be implemented, using Signed Distance Fields and/or Scalable Vector Graphics to determine the edges of the cursor (This may allow other visual effects as well, like a proper motion blur, lighting, etc).


Edit: I just found out, nearly two years after the fact, that somebody updated the formatting of my post on my birthday. Awesome, thanks dude.

1

This depends on the language and environment used.
For example Morphic GUI running under Pharo or Squeak smalltalk uses floats as its coordinates

This is listed in the accepted answer here.

Morphic was orignally implemented in self

Community
  • 1
  • 1
mmmmmm
  • 32,227
  • 27
  • 88
  • 117
-5

Because the mouse does not provide analog, or floating point, values. That's already a translation.

[edit] anyone care to comment on the -1?

Stephan Eggermont
  • 15,847
  • 1
  • 38
  • 65
  • 2
    The mouse provides data at a greater density than the screen. In order to make full use of the mouse's precision, while rendering it on the screen, the mouse's coordinates need to be scaled down. This either leads to floating point numbers, or truncation / rounding. The OP and I are in favour of floats. Still, it seems pretty harsh that this got all the way to -3 without a comment... – Dan Ross Jan 27 '17 at 22:23