keysensors/mousesensors - missed input with lower framerate #4096

Closed
opened 2006-04-13 09:12:01 +02:00 by Patrick Mullen · 9 comments

Category: Logic

%%%In my online rpg we have a chat system, so you can type messages to one another. It seems that, on lower framerates, sub30 fps, you will type something and some of the keys aren't registered at all. For instance, you will type "Hello, how are you?" and you KNOW you hit all the keys, and in the chat window you see "Hel howae yu".

I did further testing to make sure it wasn't just my python code, and sure enough, the problem is traced right back to the sensors.

In the test blend, wait until the framerate is below about 20 fps, and then press the d keya few times, watching the debug prop "press". Every once in a while, you will press the key and the number won't rise. I have been running tests of 50 presses, and depending on framerate get different results. I get somewhere between 40-45 presses out of 50 tries if the framerate is between 20 and 30; about 35 at 15 fps, and if the framerate is really low, hardly any keypresses ever count.

Not sure if this is a fixable problem or not, but blender definately seems to have more of a problem with keypresses than other applications. In a word processing program for instance, if my computer is running really slow, I can usually type out a whole word and it just takes a lot longer for what I type to show up. But it remains accurate to what keys I actually pressed.

I have tried to bypass the problem by using pygame to detect keypresses, but as that has to have its own window to detect keys its not a very workable solution.%%%

**Category**: Logic %%%In my online rpg we have a chat system, so you can type messages to one another. It seems that, on lower framerates, sub30 fps, you will type something and some of the keys aren't registered at all. For instance, you will type "Hello, how are you?" and you KNOW you hit all the keys, and in the chat window you see "Hel howae yu". I did further testing to make sure it wasn't just my python code, and sure enough, the problem is traced right back to the sensors. In the test blend, wait until the framerate is below about 20 fps, and then press the d keya few times, watching the debug prop "press". Every once in a while, you will press the key and the number won't rise. I have been running tests of 50 presses, and depending on framerate get different results. I get somewhere between 40-45 presses out of 50 tries if the framerate is between 20 and 30; about 35 at 15 fps, and if the framerate is really low, hardly any keypresses ever count. Not sure if this is a fixable problem or not, but blender definately seems to have more of a problem with keypresses than other applications. In a word processing program for instance, if my computer is running really slow, I can usually type out a whole word and it just takes a lot longer for what I type to show up. But it remains accurate to what keys I actually pressed. I have tried to bypass the problem by using pygame to detect keypresses, but as that has to have its own window to detect keys its not a very workable solution.%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

#43732 was marked as duplicate of this issue

#43732 was marked as duplicate of this issue

%%%This should ticket should be closed--the problem doesn't occur until much lower framerates (< 10).%%%

%%%This should ticket should be closed--the problem doesn't occur until much lower framerates (< 10).%%%
Member

%%%@mauriziolrosa W, I disagree; this is a serious problem. It should be possible to get a list of key presses that occurred since the last frame, and in the right order.%%%

%%%@mauriziolrosa W, I disagree; this is a serious problem. It should be possible to get a list of key presses that occurred since the last frame, and in the right order.%%%

%%%Same here. This is a serious, pestering issue absolutely beneath the power of the BGE that we have come to expect, and it severely impacts the quality of BGE based games.

The problem can already between 30 and 10 fps rates and is absolutely unpredictable; it needs only a slight 1 frame drop to eat keys randomly. Players starting the game for the first time learning that their graphics card is not suited for it e.g. try hitting escape to leave, but nothing happens until they keep pressing it - these are problems from 20-30 years ago. We can do better.

The proper fix for this is to use the respective OS facilities to buffer all input that can be buffered in a queue, and work off this queue per frame, as it is advised in e.g. SDL or pygame apps, to mention some engines closer to what we are doing. The game API then should expose a facility to query for buffered input manually, primarily for the purpose of handling chat or text box input - this is an often needed special case. Additionally, the game API needs a function to flush input buffering, for e.g. selectively discarding player input that has accumulated during e.g. loading a scene.

The queued input should also be used to feed the event map, so that currently overlooked issues can be mended, e.g. in the corner case where one has to handle a key press / release event within the same frame: in this case, the state of the key could be set to both bit flags: (KX_INPUT_JUST_ACTIVATED | KX_INPUT_JUST_RELEASED).%%%

%%%Same here. This is a serious, pestering issue absolutely beneath the power of the BGE that we have come to expect, and it severely impacts the quality of BGE based games. The problem can already between 30 and 10 fps rates and is absolutely unpredictable; it needs only a slight 1 frame drop to eat keys randomly. Players starting the game for the first time learning that their graphics card is not suited for it e.g. try hitting escape to leave, but nothing happens until they keep pressing it - these are problems from 20-30 years ago. We can do better. The proper fix for this is to use the respective OS facilities to buffer all input that can be buffered in a queue, and work off this queue per frame, as it is advised in e.g. SDL or pygame apps, to mention some engines closer to what we are doing. The game API then should expose a facility to query for buffered input manually, primarily for the purpose of handling chat or text box input - this is an often needed special case. Additionally, the game API needs a function to flush input buffering, for e.g. selectively discarding player input that has accumulated during e.g. loading a scene. The queued input should also be used to feed the event map, so that currently overlooked issues can be mended, e.g. in the corner case where one has to handle a key press / release event within the same frame: in this case, the state of the key could be set to both bit flags: (KX_INPUT_JUST_ACTIVATED | KX_INPUT_JUST_RELEASED).%%%
Member

Added subscribers: @MikePan, @dfelinto, @JorgeBernalMartinez

Added subscribers: @MikePan, @dfelinto, @JorgeBernalMartinez
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Member

This task is being closed because the BGE has been removed in Blender 2.8.

This task is being closed because the BGE has been removed in Blender 2.8.
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
7 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#4096
No description provided.