Yinteger / Jiggy.io

GNU General Public License v3.0
1 stars 1 forks source link

Inputs #15

Closed Yinteger closed 6 years ago

Yinteger commented 6 years ago

This refactor to the Inputs module introduces a modified version of the latest Inputs design.

Inputs now contains 6 primary objects, Mouse, Keyboard, GamePadListener, GamePad, TouchListener, Touch. GamePad and Touch are primarily used through their respective listeners as they can be added/removed from the window at the whim of the user. Keyboard/Mouse are static on the window, and JS only supports one of them at a time, thus no listener object necessary.

GamePads work generically, simply storing an array of axes, and an array of buttons, with the values. In the future, we may create new objects to identify and map different popular controlls to these arrays (Such as PS4, Xbox1).

Touch is simpler, where each Touch object simply represents a finger of the user and the position.

All of the InputDevices emit events to signal that the user has 'input' something with that device. Previously, they did all extend an InputDevice abstract class, but that was ditched as there was really no common functionality between them in the end. I suggest we re-add that abstraction in the future if we find common functionality.

This pull request also introduces a new test_app for testing touch interaction, where it simply displays blocks under each of your fingers when you touch the screen.

Pallet Demo was also updated to use the new Keyboard singleton, as well as the Mouse Singleton (Which is used to Display a Custom game cursor & Drop Pokeballs into the map). Pallet Demo also supports a PS4 controller to some degree.