PistonDevelopers / input

DEPRECATED - moved into the piston repo
MIT License
7 stars 11 forks source link

Separate PnP devices from input structure #56

Closed bvssvni closed 9 years ago

bvssvni commented 9 years ago

PnP = Plug and Play

I think some devices belong naturally to the input structure because they are standard devices and have a logical relationship to the window which sends the events:

If you think of the input structure in this term it is not user centric, it is simply information from the outside world reacting to the rendered window. There is no information whether the source is coming from one user or more users. The only relationship preserved is that the screen is showing some piece of information which partially causes the input events.

bvssvni commented 9 years ago

Perhaps the most important point here is: What kind of information in the window interacts with the user input? If there is no such interaction, or if the relationship between this information and input is ambiguous, then that piece of information does not belong in the input structure.

bvssvni commented 9 years ago

The optimal structure is depending on

  1. What kind of information exists in the rendered window
  2. What way the user responds to the information in the rendered window
  3. How the application structure model the changed in information to render
bvssvni commented 9 years ago

One solution is to require the application to pay attention to information about connected devices and later interpret the signals in that context. This has some drawbacks:

bvssvni commented 9 years ago

Another solution is to pass Connect(Box<Device>) for each device and use channels to map input from GLFW or SDL2. This has some drawbacks:

bvssvni commented 9 years ago

It is obvious that devices are not just read-only, but read and write. This makes them different from keyboard, mouse and multitouch.

bvssvni commented 9 years ago

There is also a distinction between events where order matters, such as button presses, and a continuous signal such as a joystick axis.

bvssvni commented 9 years ago

If we send the whole state on each update, the identity of a device must be preserved between read and write. For every event we receive from a device there must be a way to map back to the identity in the window back-end.

bvssvni commented 9 years ago

This could mean either one of following solutions:

bvssvni commented 9 years ago

We could add an event where we tell the devices are updated but now how to access them. This could work safely because you can only borrow .window from EventIterator while reading the state from the devices.

bvssvni commented 9 years ago

If we are mapping id of a device, we might as well use a user aware identity. See https://github.com/PistonDevelopers/input/issues/57

bvssvni commented 9 years ago

Closing this since we got GenericEvent in the piston-event library.