Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So in my FPS camera look code, I have something like this:

window->camera->stepYaw( getMouseDx()*speed ) ; // mouseDx is mouse change since last frame
window->camera->stepPitch( getMouseDy()*speed ) ;

This works fine on a normal mouse. But with pen input, its very very janky and radical.

How should one control an FPS camera from pen tablet input instead of traditional mouse?

share|improve this question

3 Answers 3

Typically an FPS gets the relative mouse movement by locking the mouse to the center of the screen (put the cursor on center, wait a frame, get mouse position and repeat) with a tablet however you set the absolute position of the mouse and as such you can't lock the mouse.

What I would do is not lock the mouse cursor but calculate the difference between the current absolute position and the previous absolute position. One caveat however is if you take the pen off and move it somewhere else (for example if you reach the edge of the tablet) this is fixable by not returning any movement if the movement is larger than some number.

Something like this (pseudocode):

deltaX = currentX - previousX
previousX = currentX
if deltaX > 20 deltaX = 0
share|improve this answer

In essence PenTablet provides absolute coordinates for X and Y, not a relative like Mouse does. This means you can perform SetCursor(x,y) in your code - Mouse will not know a difference, and PenTablet will "ignore" it.

Now it depends on how you compute your mouseDx. If you stick the mouse on buttonDown or just hide it? Please provide more code and I will expand my answer according to it.

share|improve this answer
up vote -1 down vote accepted

On Windows from C++

// usFlags is ALWAYS ABSOLUTE, see 
if( raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE )
{
  // its a 0 flag so
  // this is am real mouse

  // lLastX and lLastY are relative to last pos
}
else if( raw->data.mouse.usFlags | MOUSE_MOVE_ABSOLUTE )
{
  // its a tablet or positioning device
  // 1 .. 65537, ACROSS THE DESKTOP

  // get the relative change in position
  // to turn it into a pixel count,
  // you have to have the old values of lLastX
  // and lLastY (in the last call to this fcn).
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.