Common Organization of Controls Kit Input devices

To simplify handling all the variety of input devices, and simplify binding them, every device is represented with a numerical and literal value.

Basics

Following input devices are defined:

  • "keyboard" (1)
  • "mouse button" (2)
  • "mouse axis" (3)
  • "joystick button" (4)
  • "joystick axis" (5)
  • "joystick hat" / "joystick hat 1" (6)
  • "joystick hat 2" (7)
  • "joystick hat 3" (8), etc.

Additionally, every joystick is represented with internal number that may differ from LÖVE number, and internal name that will differ from LÖVE name. Name modification is really simple though, just a joystick number appended to the end of the joystick name. But that already allows for distinguishing joysticks with same names.

Details

When using any function that accepts an input device, you can either provide a numerical value, which is useful for programmatical input, or literal value, which is useful for user interaction. You shouldn't use numerical values for hard-coding data, because 1) that will make your code messier with all of these magic numbers and 2) internal conversion is an effecient and optimized operation, and it won't save execution time. Even if the libary didn't employed internal conversion and required to use numerical values, any performance difference would be completely neglectible. For lovers of the "Big O" notation: search time is O(1) average case and O(1+K) worst case. Every failed lookup creates programmatically generated data and stores for later use, thus once failed, the lookup will always be successful.

See also