Using mouse to freelook

I, too, am trying to lock the cursor to the window. I tried this code and looked at AirBlade but it doesn’t do anything.

def checkMousePos(self):
    #if (self.ship.getZ() > 6):
    #  self.ship.setZ(6)
    if (base.mouseWatcherNode.hasMouse()):
      x=base.mouseWatcherNode.getMouseX()
      y=base.mouseWatcherNode.getMouseY() 
      self.ship.setX(x)
      self.ship.setY(y)
    else:
      print "No mouse!"
      # Put the mouse in the center
      bTR = base.win.movePointer(0, base.win.getXSize()/2, base.win.getXSize()/2)
      print str(bTR)
      #print str(x)+" is mouse X"
      #print str(y)+" is mouse Y"

Any ideas?