Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/gameinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
GameInputSchema.Hedgehog,
'xboxone',
'045e-0000-Microsoft Device'
),
// Sony PlayStation devices (vendor ID 054c) get 'Ragdoll' theme
// Product ID 0000 is a placeholder - only the vendor ID is used for matching
// Note: Using Ragdoll (newer) instead of RagdollOld. DualShock 4 and DualSense use Ragdoll
// while DualShock 3 uses RagdollOld, but the newer schema is more appropriate as default
new GameInputModel(
GameInputSchema.Ragdoll,
'generic',
'054c-0000-Sony Device'
)
],

Expand Down Expand Up @@ -158,7 +167,7 @@

/**
* Gamepad event handler function type.
* @typedef {function(GamepadEvent):any} GamepadEventHandler

Check warning on line 170 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `any`
*/

/**
Expand Down Expand Up @@ -186,7 +195,7 @@

/**
* Actions to perform after players reshuffled.
* @type {Array<Function>}

Check warning on line 198 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `Function`
*/
reinitializeActions = []

Expand Down Expand Up @@ -265,8 +274,8 @@

/**
* Add action to "reinitialized" events.
* @param {Function} action Action to add.

Check warning on line 277 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `Function`
* @returns {Function} Unsubscribe function to remove this action.

Check warning on line 278 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `Function`
*/
onReinitialize (action) {
if (typeof (action) !== 'function')
Expand All @@ -281,7 +290,7 @@
/**
* Add an action to "button down" events.
* @param {ButtonActionFunc} action Action to add.
* @returns {Function} Unsubscribe function to remove this action.

Check warning on line 293 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `Function`
*/
onButtonDown (action) {
if (typeof (action) !== 'function')
Expand All @@ -296,7 +305,7 @@
/**
* Add an action to "button down" events.
* @param {ButtonActionFunc} action Action to add.
* @returns {Function} Unsubscribe function to remove this action.

Check warning on line 308 in src/gameinput.js

View workflow job for this annotation

GitHub Actions / build

Prefer a more specific type to `Function`
*/
onButtonUp (action) {
if (typeof (action) !== 'function')
Expand Down
12 changes: 12 additions & 0 deletions src/vendor-theme-matching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ test('VendorThemes should match Microsoft devices to Hedgehog theme', () => {
expect(microsoftModel.matchesVendor('Xbox One Controller (Vendor: 045e Product: 0b13)')).toBeTruthy()
})

test('VendorThemes should match Sony devices to Ragdoll theme', () => {
const sonyModel = GameInput.Models.VendorThemes.find(m => m.VendorId === '054c')
expect(sonyModel).toBeDefined()
expect(sonyModel.schema.name).toBe('Ragdoll')

// Test different Sony device formats
expect(sonyModel.matchesVendor('054c-0ce6-DualSense Wireless Controller')).toBeTruthy()
expect(sonyModel.matchesVendor('054c-05c4-Wireless Controller')).toBeTruthy()
expect(sonyModel.matchesVendor('DualSense Wireless Controller (Vendor: 054c Product: 0ce6)')).toBeTruthy()
expect(sonyModel.matchesVendor('DualSense Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 0ce6)')).toBeTruthy()
})

test('VendorThemes should not match devices from different vendors', () => {
const nintendoModel = GameInput.Models.VendorThemes.find(m => m.VendorId === '057e')

Expand Down
Loading