Thread: HELP! Need mouse to act like it does in FP Shooters!

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    27

    HELP! Need mouse to act like it does in FP Shooters!

    I'm trying to make a FPS. When you move the mouse, you look in a different direction. (Like Counterstrike, or Quake) Problem is, when the cursor moves off the window, I can no longer get any WM_MOUSEMOVE messages. I've tried using SetCursorPos to keep the mouse in the window, but that isn't going to well.

    So, is there anyway to have the mouse be tracked when it is off a window. (And I don't just mean the client area either. That's why CaptureCursor won't work either.)

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Instead of capturing the absolute position, capture it's movement (ie, it's dx and dy). Dunno how easy this is in pure winapi, but using DirectInput it is easy.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I think DirectInput is the way to go - although I don't know how....<wink, wink, nudge, nudge......Magos>

    gg

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    You can use DirectInput in other winaps than games too, no problem. I mainly learned from the examples that followed the DX SDK. Can be confusing sometimes, but some examples are decent. Other than that, GameDev.net or google.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    if you arent concerned about running other applications with this program, try putting the mouse in the center of the screen. then, when the mouse is moved, check the distance it has moved, make some sort of ratio of amount moved in the X and amount moved in the Y, multiply by some sensitivity factor, and then move the cursor back to the center of the screen.

    or, as was mentioned before, just learn direct input.
    I came up with a cool phrase to put down here, but i forgot it...

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    27
    Ah.... I figured out why I couldn't get it to work in Win API: WM_MOUSEMOVE returns the mouse coordinates relative to the Window while SetCursorPos sets coordinates in screen coordinates.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 04:19 PM
  4. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 10:33 PM
  5. Mouse in 800x600 24Bit Mode?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 11-11-2001, 01:38 AM