# Use Gamepad
# Installation of the module
You must have a gamepad module installed on your project:
npm install @rpgjs/gamepad
- In
src/modules/index.ts
file, add:
import gamepad from '@rpgjs/gamepad'
export default [
gamepad
]
# Customize the gamepad notification
Put gamepad
property in the configuration object in src/config/index.ts
:
export default {
gamepad: {
connect: {
message: 'Your gamepad is connected !',
time: 2000,
icon: 'icon_id',
sound: 'sound_id'
},
disconnect: {
message: 'Your gamepad is disconnected !',
time: 2000,
icon: 'icon_id',
sound: 'sound_id'
}
}
}
- The class has two static methods, connect and disconnect.
- Each of these methods has a message, time, icon and sound property.
- The connect and disconnect methods are called when the gamepad is connected and disconnected.
- The message property is the message that will be displayed in the notification.
- The time property is the time in milliseconds that the notification will be displayed.
- The icon property is the icon that will be displayed in the notification. Remember to create the client-side spritesheet before
- The sound property is the sound that will be played when the notification is displayed. Remember to create the client-side sound before. If you don't want to put any sound, put the
null
value