MovingBlocks / TeraNUI

Terasology's New User Interface
https://terasology.org/TeraNUI/
Apache License 2.0
4 stars 10 forks source link

feat: Add multiple pointer logic #60

Closed BenjaminAmos closed 3 years ago

BenjaminAmos commented 3 years ago

Description

This pull request adapts MouseDevice to optionally expose multiple pointers, making use of default interface methods to avoid breaking compatibility with existing backends.. These pointers are handled by a CanvasControl instance (CanvasImpl usually) to handle interactions such as pointer hovers and clicks. The CanvasControl additions though are an API breaking change but shouldn't affect either Terasology or DestinationSol, as they both use CanvasImpl anyway.

The main reason for multiple pointers is for touch-screen devices, which can have multiple touches on the screen at a time. Without these changes, only the first touch is handled. Multiple simulantious touches are used in Destination Sol for its mobile controls, where you might, for example, use both "Gun 1" and "Gun 2" simultaniously, or turn left/right whilst thrusting.

Testing

I've been testing this both with MovingBlocks/DestinationSol#588 and with a separate environment in my NUISamples repository. This should not change anything when used with Terasology but it should still be tested for any new issues that might occur.

It is probably easiest to test this using the demo screens in my NUISamples repository, especially the "Multiple Pointers" screen. It can be found by clicking on the "Previous" button in the top-left corner twice.

MultiplePointersDemo

Cervator commented 3 years ago

NUI conversion