ngx-gamepad
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ngx-gamepad

Angular gamecontroller.js wrapper service.

Demo

Getting Started

1. Install packages

npm i ngx-gamepad

2. Import Module

import { NgxGamepadModule } from 'ngx-gamepad';
 
@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxGamepadModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

3. Include the service

 
import { GamepadService } from 'ngx-gamepad';
 
export class AppComponent {
 
  constructor(
    private gamepad: GamepadService
  ){}
 
  ngOnInit() {
    this.listenToGamepad();
  }
 
  private listenToGamepad() {
    this.gamepad.connect()
      .subscribe(() => {
 
        this.gamepad.after('button0')
          .subscribe(() => ...);
 
        this.gamepad.after('select')
          .subscribe(() => ...);
 
        this.gamepad.after('start')
          .subscribe(() => ...);
 
        this.gamepad.on('right')
          .pipe(bufferCount(10))
          .subscribe(() => ...);
 
        this.gamepad.on('right0')
          .pipe(bufferCount(10))
          .subscribe(() => ...);
 
        this.gamepad.on('right1')
          .pipe(bufferCount(10))
          .subscribe(() => ...);
      })
  }
 
}
 

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-gamepad

Weekly Downloads

12

Version

1.0.0

License

MIT

Unpacked Size

322 kB

Total Files

35

Last publish

Collaborators

  • aitorllj93