Skip to content

Angular gamecontroller.js wrapper service.

License

Notifications You must be signed in to change notification settings

Beyond-Robotics/ngx-gamepad

 
 

Repository files navigation

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(() => ...);
      })
  }

}

About

Angular gamecontroller.js wrapper service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 52.5%
  • TypeScript 41.5%
  • JavaScript 5.8%
  • SCSS 0.2%