internal/gamepad: fix a typo that caused oddly cut off gamepad names. (#2300)

This change allows gamepad names up to 256 characters, which is usually
enough. Before, names were cut off after 7 characters, matching the string
"Unknown" that is used if querying the name fails.

Closes #2300
This commit is contained in:
divVerent 2022-09-03 07:44:03 -04:00 committed by GitHub
parent 7ca1ba2648
commit 9bc571af5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,7 @@ func (*nativeGamepadsImpl) openGamepad(gamepads *gamepads, path string) (err err
cname := make([]byte, 256) cname := make([]byte, 256)
name := "Unknown" name := "Unknown"
// TODO: Is it OK to ignore the error here? // TODO: Is it OK to ignore the error here?
if err := ioctl(fd, uint(_EVIOCGNAME(uint(len(name)))), unsafe.Pointer(&cname[0])); err == nil { if err := ioctl(fd, uint(_EVIOCGNAME(uint(len(cname)))), unsafe.Pointer(&cname[0])); err == nil {
name = unix.ByteSliceToString(cname) name = unix.ByteSliceToString(cname)
} }