| 228 | } |
| 229 | |
| 230 | GamepadGuid CreateGUIDFromIdentity(uint16_t bus, const GamepadIdentity& identity, const char* fallback_name, const char** axis_keys, uint32_t axis_count, const char** button_keys, uint32_t button_count, uint16_t button_mask) |
| 231 | { |
| 232 | const char* name_for_guid = GetSDLCompatibleControllerName(identity, fallback_name); |
| 233 | uint16_t signature = 0; |
| 234 | |
| 235 | if (axis_count > 0 || button_count > 0) |
| 236 | { |
| 237 | signature = UpdateCRC16(signature, name_for_guid); |
| 238 | |
| 239 | for (uint32_t i = 0; i < axis_count; ++i) |
| 240 | { |
| 241 | signature = UpdateCRC16(signature, axis_keys[i]); |
| 242 | } |
| 243 | |
| 244 | for (uint32_t i = 0; i < button_count; ++i) |
| 245 | { |
| 246 | signature = UpdateCRC16(signature, button_keys[i]); |
| 247 | } |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | signature = button_mask; |
| 252 | } |
| 253 | |
| 254 | return CreateGUID(bus, identity.m_Vendor, identity.m_Product, signature, 0, name_for_guid, 0, 0); |
| 255 | } |
| 256 | |
| 257 | void GetGamepadDeviceNameSDL(HContext context, HGamepad gamepad, char device_name[MAX_GAMEPAD_NAME_LENGTH]) |
| 258 | { |