# core/gamepadmanager (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/gamepadmanager/

Gamepad manager.
- A port of the original core/gamepadmanager.js. The public names (GamepadButtonCode, GamepadAnalogStickCode, GamepadTriggerCode,
  connect, disconnect, set_callback, update_all_gamepads, is_button_pressed, get_button_value, get_axis_value,
  get_all_connected_gamepads, get_connected_gamepad_count, get_connected_gamepad) and the update rules are the same as the original.
  (values are rounded to two decimal places, axes are taken only when they change by more than 0.01, analog values are reported only when greater than 0, log messages)
- The original reads navigator.getGamepads(). The web (wasm32) reads navigator.getGamepads() directly like the original and takes all buttons and axes the browser gives,
  and takes connection and disconnection through gamepadconnected / gamepaddisconnected like the original engine.js.
  On desktop, gilrs reads OS input (Windows.Gaming.Input on Windows), converts it to a Gamepad list in the same W3C Standard Gamepad form as the original
  (buttons 0~16, axes 0~3, axis Y is positive downward), then runs the same rules.
- Differences from the original:
  - The gilrs default filters (deadzone, jitter filtering) are turned off. Raw values are taken like a browser, and the game applies the deadzone like the original.
  - An analog button (trigger) counts as pressed when its value exceeds 30/255, as in Chromium. (gilrs default presses at 0.75 and releases at 0.65)
  - A D-pad coming in as an axis (hat switch) is converted to buttons 12~15. (what the browser does)
  - On desktop, buttons that gilrs could not map to standard buttons (buttons missing from the mapping, gilrs C, Z) are appended after the 17 standard buttons, and axes missing from the mapping
    after the 4 standard axes, in the order they first move. gilrs does not give the device's button list and reports only buttons that have moved at least once, so such a button appears only after it is first pressed.
    When the number of buttons or axes grows, that pad's state slots grow too.
  - PlayStation pads (Sony 054c DualShock 4 05c4, 09cc, 0ba0 and DualSense 0ce6, 0df2, 0e5f) have 18 buttons like Chrome (MapperDualshock4, MapperDualSense in device/gamepad),
    and raw button 13 (HID button 14) is TOUCHPAD (17). It is always there even before being pressed, and other buttons (the DualSense mic button) and axes are not appended.
    gilrs only maps touchpad:b13 of the SDL mapping to an unnamed button (Button::Unknown, the same name as misc1), so the raw code of that button is found per platform.
    (usage 14 on the macOS IOKit button page, button 13 on Windows Windows.Gaming.Input, BTN_GAMEPAD + 13 on Linux hid-generic)
    The Linux hid-sony (from kernel 4.10) and hid-playstation (from 5.12) drivers expose the touchpad as a separate device and add 0x8000 to bcdHID.
    In that case it has 17 buttons like Chrome (MapperPs4Ps5). (the 13th and 14th bytes of the gilrs uuid are that version number)
    macOS GameController also has GCDualSenseGamepad.touchpadButton, but GameController does not give the pad's vendor and product numbers so it cannot be paired with a gilrs pad, and it is not used.
  - Gamepad.index on desktop is the gilrs GamepadId number. (from 0 in the order first connected, used like the browser index) On the web it is the browser index.
  - Gamepad.id on the web is the browser id as is, and on desktop it is built in Chrome form "name (STANDARD GAMEPAD Vendor: 054c Product: 0ce6)".
  - The button value of the callback is 1.0 (pressed) / 0.0 (released) instead of bool.
  - gilrs (on the web, the connection listeners) is created on the first call (update, vibration, pad list read). (engines and tests that never call it do not open devices)
- get_all_connected_gamepads / get_connected_gamepad return copies read in place when called (&self), like the original navigator.getGamepads(). (desktop drains the gilrs events for the current state,
  and the next update receives the connects and disconnects in between) A manager fed with update_all_gamepads_with_list (tests, other input sources) returns the list it was given.
  - Added: set_log_enabled (turns logs on and off),
    update_all_gamepads_with_list (a way to feed a list without gilrs. For tests or other input sources)
  - Battery info is not in the original, so it is not ported.
  - The log printed whenever buttons and axes change is turned on with set_input_log_enabled like the original, and is off by default. set_log_enabled is the master switch for all logs including connection and disconnection.
  - GamepadKind, read_gamepad_kind: tells the kind (Xbox, PlayStation, Nintendo, other) from the pad name. get_active_gamepad_id is the pad that pressed a button or tilted an axis far at the last update.
  - vibrate(strong_magnitude, weak_magnitude, seconds): vibrates all connected pads.
    On desktop it vibrates with gilrs force feedback (Linux evdev, Windows XInput and Windows.Gaming.Input), and on macOS, where gilrs does not support rumble,
    the platform layer (platform/desktop/gamepadhaptics.rs) vibrates the controller paired with the gilrs pad using GameController and CoreHaptics. (on macOS, a duration or strength of 0 stops the previous vibration)
    So gilrs is created with rumble enabled. (one gilrs rumble thread runs on desktop) On the web, like the original, it applies dual-rumble to the vibrationActuator of navigator.getGamepads().
    Called before the first update (tick), it creates gilrs on the spot and rumbles. (as in the original)

## GamepadAnalogStickCode (struct)

Gamepad analog stick identifier. (W3C Standard Gamepad mapping spec)
- The value is an index into Gamepad.axes and is used as axis_index of get_axis_value.

Example: Reading the left stick axes

```rust
use vanilla::{Gamepad, GamepadAnalogStickCode, GamepadManager};

let mut gamepad_manager = GamepadManager::new();
gamepad_manager.set_log_enabled(false);
let mut gamepad = Gamepad::create(0, "Test Pad");
gamepad.axes[GamepadAnalogStickCode::LEFT_X] = 0.75;
gamepad.axes[GamepadAnalogStickCode::LEFT_Y] = -1.0;
gamepad_manager.update_all_gamepads_with_list(vec![Some(gamepad)]);
assert_eq!(gamepad_manager.get_axis_value(0, GamepadAnalogStickCode::LEFT_X), 0.75);
assert_eq!(gamepad_manager.get_axis_value(0, GamepadAnalogStickCode::LEFT_Y), -1.0);
assert_eq!(gamepad_manager.get_axis_value(0, GamepadAnalogStickCode::RIGHT_X), 0.0);
```

- `pub const LEFT_X: usize = 0` (static, since 0.3.2): Left stick horizontal axis. (-1 left ~ 1 right)
  - returns usize
- `pub const LEFT_Y: usize = 1` (static, since 0.3.2): Left stick vertical axis. (-1 up ~ 1 down)
  - returns usize
- `pub const RIGHT_X: usize = 2` (static, since 0.3.2): Right stick horizontal axis. (-1 left ~ 1 right)
  - returns usize
- `pub const RIGHT_Y: usize = 3` (static, since 0.3.2): Right stick vertical axis. (-1 up ~ 1 down)
  - returns usize

## GamepadTriggerCode (struct)

Gamepad trigger identifier. (W3C Standard Gamepad mapping spec)
- The value is a button index. (same as GamepadButtonCode::L2, R2) The analog value is read with get_button_value.

Example: Reading the right trigger pulled halfway

```rust
use vanilla::{Gamepad, GamepadButton, GamepadButtonCode, GamepadManager, GamepadTriggerCode};

let mut gamepad_manager = GamepadManager::new();
gamepad_manager.set_log_enabled(false);
let mut gamepad = Gamepad::create(0, "Test Pad");
gamepad.buttons[GamepadTriggerCode::R2] = GamepadButton { pressed: true, value: 0.5 };
gamepad_manager.update_all_gamepads_with_list(vec![Some(gamepad)]);
assert!(gamepad_manager.is_button_pressed(0, GamepadTriggerCode::R2));
assert_eq!(gamepad_manager.get_button_value(0, GamepadTriggerCode::R2), 0.5);
assert_eq!(GamepadTriggerCode::L2, GamepadButtonCode::L2);
```

- `pub const L2: usize = 6` (static, since 0.3.2): Left trigger. (button 6, value 0 ~ 1)
  - returns usize
- `pub const R2: usize = 7` (static, since 0.3.2): Right trigger. (button 7, value 0 ~ 1)
  - returns usize

## GamepadButtonCode (struct)

Gamepad button identifier. (W3C Standard Gamepad mapping spec)
- The value is an index into Gamepad.buttons and is used as button_index of the is_button_pressed functions. Face buttons are defined by position. (bottom 0, right 1, left 2, top 3)

Example: Updating twice to tell just pressed from held

```rust
use vanilla::{Gamepad, GamepadButton, GamepadButtonCode, GamepadManager};

let mut gamepad_manager = GamepadManager::new();
gamepad_manager.set_log_enabled(false);
let mut gamepad = Gamepad::create(0, "Test Pad");
gamepad.buttons[GamepadButtonCode::A_CROSS] = GamepadButton { pressed: true, value: 1.0 };
gamepad_manager.update_all_gamepads_with_list(vec![Some(gamepad.clone())]);
assert!(gamepad_manager.is_button_just_pressed(0, GamepadButtonCode::A_CROSS));
gamepad_manager.update_all_gamepads_with_list(vec![Some(gamepad)]);
assert!(gamepad_manager.is_button_pressed(0, GamepadButtonCode::A_CROSS));
assert!(!gamepad_manager.is_button_just_pressed(0, GamepadButtonCode::A_CROSS));
assert!(!gamepad_manager.is_button_pressed(0, GamepadButtonCode::B_CIRCLE));
```

- `pub const A_CROSS: usize = 0` (static, since 0.3.2): Face buttons.
  - returns usize
- `pub const B_CIRCLE: usize = 1` (static, since 0.3.2): Right face button. (Xbox B, PlayStation circle)
  - returns usize
- `pub const X_SQUARE: usize = 2` (static, since 0.3.2): Left face button. (Xbox X, PlayStation square)
  - returns usize
- `pub const Y_TRIANGLE: usize = 3` (static, since 0.3.2): Top face button. (Xbox Y, PlayStation triangle)
  - returns usize
- `pub const L1: usize = 4` (static, since 0.3.2): Bumpers.
  - returns usize
- `pub const R1: usize = 5` (static, since 0.3.2): Right bumper.
  - returns usize
- `pub const L2: usize = 6` (static, since 0.3.2): Triggers. (also recognized as buttons)
  - returns usize
- `pub const R2: usize = 7` (static, since 0.3.2): Right trigger. (value 0 ~ 1)
  - returns usize
- `pub const SHARE_VIEW: usize = 8` (static, since 0.3.2): System.
  - returns usize
- `pub const OPTIONS_MENU: usize = 9` (static, since 0.3.2): Right system button. (Xbox Menu, PlayStation Options)
  - returns usize
- `pub const L3: usize = 10` (static, since 0.3.2): Stick press.
  - returns usize
- `pub const R3: usize = 11` (static, since 0.3.2): Right stick press.
  - returns usize
- `pub const DPAD_UP: usize = 12` (static, since 0.3.2): D-pad.
  - returns usize
- `pub const DPAD_DOWN: usize = 13` (static, since 0.3.2): D-pad down.
  - returns usize
- `pub const DPAD_LEFT: usize = 14` (static, since 0.3.2): D-pad left.
  - returns usize
- `pub const DPAD_RIGHT: usize = 15` (static, since 0.3.2): D-pad right.
  - returns usize
- `pub const HOME_PS: usize = 16` (static, since 0.3.2): Center.
  - returns usize
- `pub const TOUCHPAD: usize = 17` (static, since 0.3.2): PlayStation touchpad press. (a button after the 17 standard ones, DualShock 4 and DualSense only)
  - returns usize

## GamepadInputCallback (type)

Input callback. (gamepad_index, input_type, input_index, value)

```rust
pub type GamepadInputCallback = Box<dyn FnMut(usize, GamepadInputType, usize, f64)>
```

## GamepadButton (struct) (Clone, Copy, Debug, PartialEq)

One gamepad button. (W3C GamepadButton)

Example: Changing a button of a pad copy

```rust
use vanilla::{Gamepad, GamepadButton, GamepadButtonCode};

let mut gamepad = Gamepad::create(0, "Test Pad");
assert!(!gamepad.buttons[GamepadButtonCode::L2].pressed);
gamepad.buttons[GamepadButtonCode::L2] = GamepadButton { pressed: true, value: 0.4 };
assert_eq!(gamepad.buttons[GamepadButtonCode::L2].value, 0.4);
```

- `pub pressed: bool` (field, since 0.3.2): Whether pressed.
  - returns bool
- `pub value: f64` (field, since 0.3.2): Value. (0.0 ~ 1.0, analog for triggers)
  - returns f64

## Gamepad (struct) (Clone, Debug, PartialEq, GamepadElementReader)

Copy of one gamepad. (W3C Gamepad, the same form navigator.getGamepads() gives)

Example: Creating a pad and reading it from the connected pad list

```rust
use vanilla::{read_gamepad_kind, Gamepad, GamepadKind, GamepadManager};

let gamepad = Gamepad::create(1, "Xbox Wireless Controller");
assert_eq!(gamepad.buttons.len(), 17);
assert_eq!(gamepad.axes.len(), 4);
assert!(gamepad.connected);
assert_eq!(read_gamepad_kind(&gamepad.id), GamepadKind::Xbox);

let mut gamepad_manager = GamepadManager::new();
gamepad_manager.set_log_enabled(false);
gamepad_manager.update_all_gamepads_with_list(vec![None, Some(gamepad)]);
let connected_gamepad = gamepad_manager.get_connected_gamepad(0);
assert_eq!(connected_gamepad.map(|gamepad| gamepad.index), Some(1));
```

- `pub index: usize` (field, since 0.3.2): Hardware identifier number. (gamepad_index of the is_button_pressed functions)
  - returns usize
- `pub id: String` (field, since 0.3.2): Device name.
  - returns String
- `pub connected: bool` (field, since 0.3.2): Whether connected.
  - returns bool
- `pub buttons: Vec<GamepadButton>` (field, since 0.3.2): Button list. (GamepadButtonCode order)
  - returns Vec<GamepadButton>
- `pub axes: Vec<f64>` (field, since 0.3.2): Axis list. (GamepadAnalogStickCode order, -1.0 ~ 1.0)
  - returns Vec<f64>
- `pub fn create(index: usize, id: &str) -> Gamepad` (static, since 0.3.2): Constructor. (17 buttons released, 4 axes at 0)
  - `index` usize: Hardware identifier number. (same as the index in the list passed to update_all_gamepads_with_list)
  - `id` &str: Device name.
  - returns Gamepad: Connected (connected is true) pad copy.

## GamepadManager (struct) (Default)

Gamepad manager.
- InputManager holds one and polls it in tick. Scenes read it with engine.get_input_manager().get_gamepad_manager(). (reading the pad list reads in place, so use get_gamepad_manager_mut)

Example: Receiving button changes through the callback

```rust
use std::cell::RefCell;
use std::rc::Rc;
use vanilla::{Gamepad, GamepadButton, GamepadButtonCode, GamepadInputType, GamepadManager};

let event_list = Rc::new(RefCell::new(Vec::new()));
let callback_event_list = event_list.clone();
let mut gamepad_manager = GamepadManager::new();
gamepad_manager.set_log_enabled(false);
gamepad_manager.set_callback(Some(Box::new(move |gamepad_index, input_type, input_index, value| {
	callback_event_list.borrow_mut().push((gamepad_index, input_type, input_index, value));
})));
let mut gamepad = Gamepad::create(0, "Test Pad");
gamepad.buttons[GamepadButtonCode::A_CROSS] = GamepadButton { pressed: true, value: 1.0 };
gamepad_manager.update_all_gamepads_with_list(vec![Some(gamepad)]);
assert_eq!(gamepad_manager.get_connected_gamepad_count(), 1);
assert_eq!(event_list.borrow()[0], (0, GamepadInputType::Button, GamepadButtonCode::A_CROSS, 1.0));
```

Example: Reading the first pad's buttons and sticks in a scene

```rust
use vanilla::{Engine, GamepadAnalogStickCode, GamepadButtonCode};

fn read_first_gamepad(engine: &Engine) {
	let mut input_manager = engine.get_input_manager_mut();
	let mut gamepad_manager = input_manager.get_gamepad_manager_mut();
	let gamepad_index = match gamepad_manager.get_connected_gamepad(0) {
		Some(gamepad) => {
			gamepad.index
		}
		None => {
			return;
		}
	};
	if gamepad_manager.is_button_just_pressed(gamepad_index, GamepadButtonCode::A_CROSS) {
		println!("confirm");
	}
	let stick_x = gamepad_manager.get_axis_value(gamepad_index, GamepadAnalogStickCode::LEFT_X);
	println!("{}", stick_x);
}
```

- `pub fn new() -> GamepadManager` (constructor, since 0.3.2): Constructor.
  - Starts with logging on and input logging off. The device (gilrs) is opened on the first call.
  - returns GamepadManager: Manager with no connected pads.
- `pub fn tick(&mut self, _time_delta: f64)` (method, since 0.3.2): Update.
  - Calls update_all_gamepads.
  - `_time_delta` f64: Seconds elapsed since the last frame. (unused)
- `pub fn connect(&mut self, gamepad: &Gamepad)` (method, since 0.3.2): Connects a gamepad.
  - Creates state slots for that pad's buttons and axes, released and 0. Prints a connection log if logging is on.
  - `gamepad` &Gamepad: Pad to attach. (skipped if the same index is already attached)
- `pub fn disconnect(&mut self, gamepad: &Gamepad)` (method, since 0.3.2): Gamepad disconnected.
  - `gamepad` &Gamepad: Pad to detach. (found by index, skipped if not attached)
- `pub fn set_callback(&mut self, callback: Option<GamepadInputCallback>)` (method, since 0.3.2): Sets the callback. (off if None)
  - `callback` Option<GamepadInputCallback>: Function called whenever input changes during an update. (gamepad_index is Gamepad.index, button presses are Button with 1.0 / 0.0, analog values are Value, axes are Axis)
- `pub fn set_log_enabled(&mut self, is_enabled: bool)` (method, since 0.3.2): Turns logs on and off. (added in the Rust version. On by default like the original)
  - `is_enabled` bool: true to print all connection, disconnection and input logs.
- `pub fn set_input_log_enabled(&mut self, is_enabled: bool)` (method, since 0.4.0): Whether to print a log whenever buttons and axes change. (off by default, prints nothing even when on if set_log_enabled is off)
  - `is_enabled` bool: true to print input logs.
- `pub fn is_input_log_enabled(&self) -> bool` (method, since 0.4.0): Whether a log is printed whenever buttons and axes change.
  - returns bool: true if input logs are on. (does not look at set_log_enabled)
- `pub fn get_active_gamepad_id(&self) -> Option<&str>` (method, since 0.4.0): Name of the pad that pressed a button or tilted an axis past 0.5 at the last update. (None if none, for telling the last used device)
  - returns Option<&str>: Gamepad.id of that pad. None if no button was newly pressed and no axis newly crossed 0.5 at the last update. (None at the next update if held)
- `pub fn vibrate(&mut self, strong_magnitude: f64, weak_magnitude: f64, seconds: f64)` (method, since 0.4.0): Vibrates all connected pads. (strengths 0 ~ 1, heavy motor and light motor, seconds)
  - On desktop gilrs force feedback (GameController and CoreHaptics on macOS), on the web dual-rumble of Gamepad.vibrationActuator. Pads without rumble support are skipped.
  - `strong_magnitude` f64: Heavy (low frequency) motor strength. (clamped to 0 ~ 1, 0 if not a number)
  - `weak_magnitude` f64: Light (high frequency) motor strength. (clamped to 0 ~ 1, 0 if not a number)
  - `seconds` f64: Vibration duration. (seconds, 0 if negative or not a number, rounded to milliseconds)

  Example: Vibrating for 0.2 seconds when hit

  ```rust
  use vanilla::Engine;
  
  fn shake_on_hit(engine: &Engine) {
  	let mut input_manager = engine.get_input_manager_mut();
  	let mut gamepad_manager = input_manager.get_gamepad_manager_mut();
  	gamepad_manager.vibrate(1.0, 0.5, 0.2);
  }
  ```

- `pub fn update_all_gamepads(&mut self)` (method, since 0.3.2): Updates all gamepads. (reads gilrs and passes the list to update_all_gamepads_with_list)
- `pub fn update_all_gamepads_with_list(&mut self, gamepad_list: Vec<Option<Gamepad>>)` (method, since 0.3.2): Updates all gamepads from the given list. (the body of the original updateAllGamepads, the list position is the index)
  - Used to feed state without gilrs. (tests, other input sources)
  - Pads newly appearing in the list are attached and pads that disappear are released. Values are rounded to two decimal places and only changes are reported to the callback.
  - `gamepad_list` Vec<Option<Gamepad>>: Pad list. (the index is Gamepad.index, empty slots are None, the same form as navigator.getGamepads())

  Example: Putting a pad in the second slot and taking it out

  ```rust
  use vanilla::{Gamepad, GamepadManager};
  
  let mut gamepad_manager = GamepadManager::new();
  gamepad_manager.set_log_enabled(false);
  let gamepad = Gamepad::create(1, "Second Pad");
  gamepad_manager.update_all_gamepads_with_list(vec![None, Some(gamepad)]);
  assert_eq!(gamepad_manager.get_connected_gamepad_count(), 1);
  assert_eq!(gamepad_manager.get_all_connected_gamepads()[0].id, "Second Pad");
  gamepad_manager.update_all_gamepads_with_list(Vec::new());
  assert_eq!(gamepad_manager.get_connected_gamepad_count(), 0);
  ```

- `pub fn is_button_pressed(&self, gamepad_index: usize, button_index: usize) -> bool` (method, since 0.3.2): Returns the button pressed state.
  - `gamepad_index` usize: Hardware identifier number of the pad. (Gamepad.index, not the position in the connected list)
  - `button_index` usize: Button index. (GamepadButtonCode)
  - returns bool: true if held. false if the pad is not attached or the button index does not exist.
- `pub fn is_button_just_pressed(&self, gamepad_index: usize, button_index: usize) -> bool` (method, since 0.3.2): Whether the button was just pressed this update. (the original isButtonJustPressed, used like keyboard is_key_just_pressed)
  - `gamepad_index` usize: Hardware identifier number of the pad. (Gamepad.index, not the position in the connected list)
  - `button_index` usize: Button index. (GamepadButtonCode)
  - returns bool: true if released at the last update and pressed this update. false if the pad or button does not exist.
- `pub fn is_button_just_released(&self, gamepad_index: usize, button_index: usize) -> bool` (method, since 0.3.2): Whether the button was just released this update. (the original isButtonJustReleased)
  - `gamepad_index` usize: Hardware identifier number of the pad. (Gamepad.index, not the position in the connected list)
  - `button_index` usize: Button index. (GamepadButtonCode)
  - returns bool: true if pressed at the last update and released this update. false if the pad or button does not exist.
- `pub fn get_button_value(&self, gamepad_index: usize, button_index: usize) -> f64` (method, since 0.3.2): Returns the button/trigger analog value. (0.0 ~ 1.0)
  - `gamepad_index` usize: Hardware identifier number of the pad. (Gamepad.index, not the position in the connected list)
  - `button_index` usize: Button index. (GamepadButtonCode)
  - returns f64: Value rounded to two decimal places. 0.0 if the pad or button does not exist.
- `pub fn get_axis_value(&self, gamepad_index: usize, axis_index: usize) -> f64` (method, since 0.3.2): Returns the analog stick axis value. (-1.0 ~ 1.0)
  - Takes a new value only when it changes by more than 0.01. The dead zone is not removed. (InputActions removes it)
  - `gamepad_index` usize: Hardware identifier number of the pad. (Gamepad.index)
  - `axis_index` usize: Axis index. (GamepadAnalogStickCode, vertical axes are positive downward)
  - returns f64: Value rounded to two decimal places. 0.0 if the pad or axis does not exist or it is NaN.
- `pub fn get_all_connected_gamepads(&self) -> Vec<Gamepad>` (method, since 0.3.2): Returns all connected gamepads. (a copy of the current state read in place, like the original navigator.getGamepads())
  - returns Vec<Gamepad>: List of pad copies in connection order. An empty list if there are none.
- `pub fn get_connected_gamepad_count(&self) -> usize` (method, since 0.3.2): Returns the number of connected gamepads.
  - returns usize: Number of attached pads.
- `pub fn get_connected_gamepad(&self, gamepad_index: usize) -> Option<Gamepad>` (method, since 0.3.2): Returns a connected gamepad. (gamepad_index is the position in the connected list, 0 ~ get_connected_gamepad_count() - 1)
  - `gamepad_index` usize: Position in the connected list. (attach order, not Gamepad.index)
  - returns Option<Gamepad>: A copy of the pad read in place. None if the number is out of range or that pad is not in the current list.

## Functions and constants

- `pub fn read_gamepad_kind(gamepad_id: &str) -> GamepadKind` (method, since 0.4.0): Tells the kind from the pad name. (PlayStation 054c, Nintendo 057e, Xbox 045e and names, Other if unknown)
  - Checks PlayStation, Nintendo, Xbox in that order, case-insensitively.
  - `gamepad_id` &str: Pad name. (Gamepad.id)
  - returns GamepadKind: Kind told from a vendor number or common name in the name. Other if nothing matches.

  Example: Telling browser and desktop style names apart

  ```rust
  use vanilla::{read_gamepad_kind, GamepadKind};
  
  let dual_sense_id = "DualSense Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 0ce6)";
  assert_eq!(read_gamepad_kind(dual_sense_id), GamepadKind::PlayStation);
  assert_eq!(read_gamepad_kind("Xbox 360 Controller (XInput STANDARD GAMEPAD)"), GamepadKind::Xbox);
  assert_eq!(read_gamepad_kind("Steam Virtual Gamepad"), GamepadKind::Other);
  ```

## GamepadKind (enum) (Clone, Copy, Debug, PartialEq, Eq, Hash)

Gamepad type. (used to show button hints in that pad's notation)

- `Xbox`: Xbox pad. (045e, xbox, xinput, microsoft in the name)
- `PlayStation`: PlayStation pad. (054c, playstation, dualshock, dualsense, sony in the name)
- `Nintendo`: Nintendo pad. (057e, nintendo, joy-con, pro controller in the name)
- `Other`: Other. (a pad that could not be told by name)

## GamepadInputType (enum) (Clone, Copy, Debug, PartialEq, Eq)

Input kind. (input_type string "button" / "value" / "axis" of the original callback)

- `Button`: Press change. (value is 1.0 pressed, 0.0 released)
- `Value`: Button analog value change. (comes only when greater than 0)
- `Axis`: Stick axis value change.
