Drifting Mouse in Y Axis

#1

I think this is a bug, but I could be wrong.

On Linux, (of_v0.10.1_linux64gcc6_release) I get mouse drift in the Y axis. E.g. if I move my mouse up and down on the spot, the cursor gradually rises up the Y axis, relative to the operating system cursor.

I am getting mouse coordinates by calling

ofVec2f pos;
pos.set(ofGetMouseX(), ofGetMouseY());

And then using that pos to draw the cursor. If am doing some transforms on the pos coordinate, but nothing cumulative, and and I log the value of pos before doing any transforms, I can see that the value is drifting upwards.

Before I log this on github, Is this a known issue? Or is there anything dumb I might be doing that’s causing it.
Also are there any obvious fixes or workarounds?
I’ve been stuck on this for hours, and I need to run a study with this software on Mon. - any help appreciated

#2

not sure what you mean, if i do:

ofDrawCircle({ofGetMouseX(), ofGetMouseY()}, 50.f);

The mouse cursor is always in the circle center no?

#3

Thanks Arturo - I could have been clearer.
To use your example, if I call

ofDrawCircle({ofGetMouseX(), ofGetMouseY()}, 50.f);

In Draw(), and move the mouse up and down on the spot (up 1cm, down 1cm, over and again, so that the mouse never moves up or down more than 1 cm from its original position) the circle on screen nonetheless drifts upwards over time.

I have just now isolated the problem more precisely. This only happens when the OS cursor is hidden, and fullscreen is set.

This is my minimal example:
In app.h

int counter{0};

In app.c

void ofApp::setup(){
    // Open Mouse
    ofSetFrameRate(50);
    ofToggleFullscreen();
}

//--------------------------------------------------------------
void ofApp::update(){
    if(counter++ % 1000 ==1){
        ofHideCursor();
    } else if (counter % 1000 ==0) {
        ofShowCursor();
    }
}

//--------------------------------------------------------------
void ofApp::draw(){
    ofSetColor(0,0,0);
    ofFill();
    ofSetColor(1,1,1);
    ofDrawCircle({ofGetMouseX(), ofGetMouseY()}, 5.f);
}

With this code, if you move your mouse up and down on the spot repeatedly, the cursor will rise up the screen, until every 1000th frame, when ofShowCursor() is called - at that point the cursor position resets to match the OS cursor position.

#4

I’m working around this by not using fullscreen mode (which actually doesn’t launch into fullscreen on linux I think, but does hide the OS cursor), by using this fullscreen mode in linux with glut!! to launch into fullscreen.

The issue for me was that OS cursor would appear when you moved over the top info bar, which would be distracting in my study. This removes that specific problem.

I’ll raise the issue on github anyway. So far as I can see this behaviour is down to the call to

glfwSetInputMode(windowP,GLFW_CURSOR,GLFW_CURSOR_DISABLED);
#5

you can use OF_GAME_MODE instead of OF_FULLSCREEN for “real” fullscreen

#6

Thanks Arturo, but OF_GAME_MODE has the same problem.
I just tested this to be sure, but it makes sense given how hideCursor is implemented for GLFW:

void ofAppGLFWWindow::hideCursor(){
	if(settings.windowMode == OF_FULLSCREEN || settings.windowMode == OF_GAME_MODE){
		glfwSetInputMode(windowP,GLFW_CURSOR,GLFW_CURSOR_DISABLED);
	}else{
		glfwSetInputMode(windowP,GLFW_CURSOR,GLFW_CURSOR_HIDDEN);
	}
};

What I have is fine as a workaround for my own purposes.