input: rearrange code to avoid forward declarations
The diff may look a bit wild but this mostly fixes coding style issues:
- sort includes alphabetically
- add missing includes
- rearrange structures/functions to avoid forward declarations
- adding "data" user-defineable field to input structure (for callbacks)
- correctly handle errors in device_data_arrived
- remove device_added/device_removed
- merge input_init into constructor
- add some log messages for debugging
- remove devices when wake-up fails
- set cb/data fields on eloop connection, not on initialization
- remove all devices when disconnecting eloop so the eloop is guaranteed to be
not used by the input subsystem after disconnection.
- some error handling fixes
- remove some TODOs which are correctly implemented
- Add O_NONBLOCK when opening the device node (I don't know how it actually
worked without it in the data_arrived callback)
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>