Hello,

My config:
Windows 7 Pro 64 bits
python 3.6 64 bits and python 3.4 32 bits
pyglet 1.2.4

I tried the following code:

import pyglet

window = pyglet.window.Window()

@window.event
def on_mouse_motion(x, y, dx, dy):
    print("Move x: {x}, y:{y}, dx:{dx}, dy:{dy}".format(x=x, y=y, dx=dx, 
dy=dy))

@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
    print("Drag x: {x}, y:{y}, dx:{dx}, dy:{dy}".format(x=x, y=y, dx=dx, 
dy=dy))

window.set_exclusive_mouse(True)
pyglet.app.run()

I don't see the problem you describe. I only get negative dx when I move to 
the left and positive when moving to the right.
Left movements:
Move x: 319, y:240, dx:-1, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:241, dx:-2, dy:1
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 318, y:241, dx:-2, dy:1
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:241, dx:-1, dy:1
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 317, y:240, dx:-3, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 317, y:240, dx:-3, dy:0
Move x: 318, y:241, dx:-2, dy:1
Move x: 317, y:240, dx:-3, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, *dx:1*, dy:0
Move x: 318, y:241, dx:-2, dy:1
Move x: 318, y:240, dx:-2, dy:0
Move x: 317, y:240, dx:-3, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 319, y:240, dx:-1, dy:0
Move x: 318, y:240, dx:-2, dy:0
Move x: 319, y:240, dx:-1, dy:0

You'll notice one occurence of a right dx but in general I'm getting my 
movement to the left as expected.

Looking at the code, I can see that in exclusive mode, the WM_MOUSEMOVE is 
specifically ignored. In pyglet/window/win32/__init__.py line 711

    @ViewEventHandler
    @Win32EventHandler(WM_MOUSEMOVE)
    def _event_mousemove(self, msg, wParam, lParam):
        x, y = self._get_location(lParam)

        if (x, y) == self._exclusive_mouse_client:
            # Ignore the event caused by SetCursorPos
            self._mouse_x = x
            self._mouse_y = y
            return 0

        y = self._height - y

        if self._exclusive_mouse and self._has_focus:
            # Reset mouse position (so we don't hit the edge of the screen).
            _x, _y = self._exclusive_mouse_screen
            self.set_mouse_position(_x, _y, absolute=True)

        dx = x - self._mouse_x
        dy = y - self._mouse_y

        if not self._tracking:
            # There is no WM_MOUSEENTER message (!), so fake it from the
            # first WM_MOUSEMOVE event after leaving.  Use self._tracking
            # to determine when to recreate the tracking structure after
            # re-entering (to track the next WM_MOUSELEAVE).
            self._mouse_in_window = True
            self.set_mouse_platform_visible()
            self.dispatch_event('on_mouse_enter', x, y)
            self._tracking = True
            track = TRACKMOUSEEVENT()
            track.cbSize = sizeof(track)
            track.dwFlags = TME_LEAVE
            track.hwndTrack = self._view_hwnd
            _user32.TrackMouseEvent(byref(track))

        # Don't generate motion/drag events when mouse hasn't moved. (Issue
        # 305)
        if self._mouse_x == x and self._mouse_y == y:
            return 0

        self._mouse_x = x
        self._mouse_y = y

        buttons = 0
        if wParam & MK_LBUTTON:
            buttons |= mouse.LEFT
        if wParam & MK_MBUTTON:
            buttons |= mouse.MIDDLE
        if wParam & MK_RBUTTON:
            buttons |= mouse.RIGHT

        if buttons:
            # Drag event
            modifiers = self._get_modifiers()
            self.dispatch_event('on_mouse_drag',
                x, y, dx, dy, buttons, modifiers)
        else:
            # Motion event
            self.dispatch_event('on_mouse_motion', x, y, dx, dy)
        return 0

I've highlighted in blue the code relevant to ignoring SetCursorPos. 

Obviously this does not seem to work on your machine. It would be 
interesting to add some print statements in that part of the code to check 
if indeed the SetCursorPos is ignored.

Maybe using my little test code above would prove useful.

Let us know how this goes.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to