Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

negative mouse coordinates returned as 2^64 #15

Closed
danyshaanan opened this issue Feb 24, 2015 · 6 comments
Closed

negative mouse coordinates returned as 2^64 #15

danyshaanan opened this issue Feb 24, 2015 · 6 comments
Labels

Comments

@danyshaanan
Copy link

When using multiple screens, zero is defined as top left of the main screen, which means that everything to it's left/top should have negative x/y coordinates accordingly. However, those are returned as 2^64.

This image shows the output of the script below as I move the mouse to the left-most screen, and then to the top of it. (node index.js >> data.txt and tail -f data.txt)

Could this simply be a problem with integers becoming unsigned in the C code?

robotjsnegativemouse

'use strict'

var robot = require('robotjs')

function encodeMouse(mouse) {
  return '[' + mouse.x + ',' + mouse.y + ']'
}

var mouse
var prevCode

setInterval(function() {
  var code = encodeMouse(robot.getMousePos())
  if (code !== prevCode) {
    console.log(code)
  }
  prevCode = code
}, 100)
@octalmage
Copy link
Owner

Good find! I actually never tested in a multi-monitor set up. I'll check it out and let you know what I figure out!

@ryanramage
Copy link

yup, I see this as well.

On one external monitor:

Mouse is at x:18446744073709550000 y:18446744073709552000

and on the other external monitor:

Mouse is at x:1171 y:18446744073709552000

@OverZealous
Copy link

I think related to this, I'm getting a SEGFAULT trying to extract the color from a far-left monitor (using the example code, but I added a loop in to collect 10 samples).

$ node index.js
#e8e8e8 at x:18446744073709552000 y:310
Segmentation fault: 11

@Deltatiger
Copy link
Collaborator

Seems js doesn't have signed and unsigned numbers. Converting all numbers to a uniform 64 bit format will help I guess. Will have to check it out

Deltatiger added a commit to Deltatiger/robotjs that referenced this issue Jul 25, 2015
This should fix the getMousePos returning negative values in extended
displays
Deltatiger added a commit to Deltatiger/robotjs that referenced this issue Jul 25, 2015
This reverts commit c9b3e9b.
Deltatiger added a commit to Deltatiger/robotjs that referenced this issue Jul 25, 2015
This fixes the issue where negative values were being returned from
getMousePos. This seems to be an issue with the Number format.
Deltatiger added a commit to Deltatiger/robotjs that referenced this issue Jul 27, 2015
This should fix the issue of getting negative values in extended
displays.
Deltatiger added a commit to Deltatiger/robotjs that referenced this issue Jul 27, 2015
This should fix the issue of negative values being returned when calling
getMousePos on extended displays
octalmage added a commit that referenced this issue Jul 28, 2015
@octalmage
Copy link
Owner

This has been fixed in #48 which has been merged. I'll publish to npm later today.

@danyshaanan
Copy link
Author

Thanks! :]

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants