event.mouse_x and event.mouse_prev_x don't give consistent results across all tablets/mouse API as they used to in blender 2.91 #84912

Closed
opened 2021-01-20 21:33:08 +01:00 by Adrian Rutkowski · 11 comments

System Information
Operating system: win10

Blender Version
Broken: (example: 2.92.0-c2e6969c56ef-windows64 and 2.93.0-6290091bace2-windows64 )
Worked: (2.91.2)

Short description of error

changing tablet API no longer gives consistent results for python scripts when event.mouse_x and event.mouse_prev_x are used

AZzNtnWtai.mp4

here is the script I used in a video

import bpy
from bpy.props import IntProperty, FloatProperty


class ModalOperator(bpy.types.Operator):
    """Move an object with the mouse, example"""
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

    first_value: FloatProperty()

    def modal(self, context, event):
        if event.type == 'MOUSEMOVE':
            context.object.location.x += (event.mouse_x - event.mouse_prev_x) / 10

        elif event.type == 'LEFTMOUSE':
            return {'FINISHED'}

        elif event.type in {'RIGHTMOUSE', 'ESC'}:
            context.object.location.x = self.first_value
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.object:
            self.first_value = context.object.location.x

            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "No active object, could not finish")
            return {'CANCELLED'}


def register():
    bpy.utils.register_class(ModalOperator)


def unregister():
    bpy.utils.unregister_class(ModalOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.modal_operator('INVOKE_DEFAULT')

**System Information** Operating system: win10 **Blender Version** Broken: (example: 2.92.0-c2e6969c56ef-windows64 and 2.93.0-6290091bace2-windows64 ) Worked: (2.91.2) **Short description of error** changing tablet API no longer gives consistent results for python scripts when event.mouse_x and event.mouse_prev_x are used [AZzNtnWtai.mp4](https://archive.blender.org/developer/F9590022/AZzNtnWtai.mp4) here is the script I used in a video ``` import bpy from bpy.props import IntProperty, FloatProperty class ModalOperator(bpy.types.Operator): """Move an object with the mouse, example""" bl_idname = "object.modal_operator" bl_label = "Simple Modal Operator" first_value: FloatProperty() def modal(self, context, event): if event.type == 'MOUSEMOVE': context.object.location.x += (event.mouse_x - event.mouse_prev_x) / 10 elif event.type == 'LEFTMOUSE': return {'FINISHED'} elif event.type in {'RIGHTMOUSE', 'ESC'}: context.object.location.x = self.first_value return {'CANCELLED'} return {'RUNNING_MODAL'} def invoke(self, context, event): if context.object: self.first_value = context.object.location.x context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "No active object, could not finish") return {'CANCELLED'} def register(): bpy.utils.register_class(ModalOperator) def unregister(): bpy.utils.unregister_class(ModalOperator) if __name__ == "__main__": register() # test call bpy.ops.object.modal_operator('INVOKE_DEFAULT') ```

Added subscriber: @niewinny

Added subscriber: @niewinny

Added subscriber: @PrototypeNM1

Added subscriber: @PrototypeNM1

This is probably a result of tablets and mice now receiving high frequency input on Windows.

Someone else would need to comment on how that would impact mouse_* and mouse_prev_* and whether this is a bug in the script or a bug in how events are generated. I'd be concerned with how cursor input coalescing interacts with what is reported as the previous cursor position.

This is probably a result of tablets and mice now receiving high frequency input on Windows. Someone else would need to comment on how that would impact mouse_* and mouse_prev_* and whether this is a bug in the script or a bug in how events are generated. I'd be concerned with how cursor input coalescing interacts with what is reported as the previous cursor position.

Just to make it clearer, I included the script so it's easier to test, but in general (mouse_* - mouse_prev_*) is giving different results for wintab and windows ink APIs.

since there were some changes to input and the mouse is giving the same input as Wintab I assume windows ink was not updated.
unless it is not possible to do it for windows ink API

Just to make it clearer, I included the script so it's easier to test, but in general (mouse_* - mouse_prev_*) is giving different results for wintab and windows ink APIs. since there were some changes to input and the mouse is giving the same input as Wintab I assume windows ink was not updated. unless it is not possible to do it for windows ink API

I'm just adding context for whoever ends up addressing this issue. Windows Ink and Wintab both feed into the same system (from Ghost to the Window Manager), and what they feed into that system doesn't include the idea of a mouse_prev_*. Thus the issue is likely exposed by recent changes to Windows Ink and Wintab, but unlikely to be contained in the changes to Windows Ink and Wintab.

I suspect the issue is the Window Manager and how it coalesces mouse input, and how that interacts with saving mouse_prev_. I don't think mouse_prev_ is updated taking into account whether the operator is receiving all mouse input or just the most recent mouse input. Assuming that is the case it would result in different behavior when many more mouse events are generated and when they're fed to the Window Manager in different "clumps" (e.g. 2 at a time vs. 7 at a time), which is a probable source of the bug given Windows Ink, Wintab, and Windows mouse events are read in different ways.

I'm just adding context for whoever ends up addressing this issue. Windows Ink and Wintab both feed into the same system (from Ghost to the Window Manager), and what they feed into that system doesn't include the idea of a mouse_prev_*. Thus the issue is likely exposed by recent changes to Windows Ink and Wintab, but unlikely to be contained in the changes to Windows Ink and Wintab. I suspect the issue is the Window Manager and how it coalesces mouse input, and how that interacts with saving mouse_prev_*. I don't think mouse_prev_* is updated taking into account whether the operator is receiving all mouse input or just the most recent mouse input. Assuming that is the case it would result in different behavior when many more mouse events are generated and when they're fed to the Window Manager in different "clumps" (e.g. 2 at a time vs. 7 at a time), which is a probable source of the bug given Windows Ink, Wintab, and Windows mouse events are read in different ways.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Does this also happen when checking INBETWEEN_MOUSEMOVE events too?

Removing Python project, since this isn't spesific to Python (it will impact C code too).

Does this also happen when checking `INBETWEEN_MOUSEMOVE` events too? Removing Python project, since this isn't spesific to Python (it will impact C code too).

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'
Member

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed. Thanks again for the report. If the problem persists please open a new report with the required information.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#84912
No description provided.