Created
October 19, 2018 04:48
-
-
Save Enichan/de1618d2c481523bd0c1123800bfe747 to your computer and use it in GitHub Desktop.
Gamepad id output for various controllers/gamepads across browsers, with regexes for how to get name, vendor id, and product id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is output from the gamepad API's id property tested across a variety of browsers, along with regular expressions to | |
find the name, vendor id, and product id. | |
Chrome: Logitech Dual Action (STANDARD GAMEPAD Vendor: 046d Product: c216) | |
Xbox 360 Controller (XInput STANDARD GAMEPAD) | |
Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 05c4) | |
Sony PLAYSTATION(R)3 Controller (STANDARD GAMEPAD Vendor: 054c Product: 0268) | |
Pro Controller (Vendor: 057e Product: 2009) | |
8Bitdo SF30 Pro (Vendor: 2dc8 Product: 6000) | |
Firefox: 046d-c216-Logitech Dual Action | |
xinput | |
Edge*: Xbox 360 Controller (XInput STANDARD GAMEPAD) | |
Safari: 46d-c216-Logicool Dual Action | |
Opera: USB JOYSTICK PS3 (Vendor: 1f4f Product: 0008) | |
*when Edge's gamepad support works at all it always reports the gamepad as an Xbox 360 Controller with this exact string | |
Regular expressions: | |
Firefox / Safari | |
/^([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)-([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)-\s*(.*)\s*$/i | |
Chrome / Opera | |
/^(.*)\s*\(.*vendor:?\s*([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)\s+product:?\s*([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)\s*\)\s*$/i | |
Vendor and product | |
/vendor:?\s*([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)(?:[^0-9a-f]|$)/i | |
/product:?\s*([0-9a-f][0-9a-f]?[0-9a-f]?[0-9a-f]?)(?:[^0-9a-f]|$)/i | |
Standard xinput if either of these match | |
/^\s*xinput\s*$/i | |
/\(xinput standard gamepad\)\s*$/i | |
Remove parentheses (produces a 'best guess' name) | |
/\s*\(.*\)/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment