Skip to content

charliewilco/bndr-js

 
 

Repository files navigation

Bndr.js

🖱️ ⌇ ⌨️ ⌇ 🎹 ⌇ 🎮 ⌇ 🖊️ ⌇ 👆

DemoAPIBecome a Sponsor

npm version npm licence

Bndr.js /ˈbaɪndɚ/ is a library designed to compose events from various user inputs and chain filters in a monadic manner, integrating them into a single event object. It accommodates input devices such as mice🖱️, styluses🖊️, touch inputs👆, keyboards⌨️, MIDI controllers🎹, and gamepads🎮. Developed and maintained by Baku Hashimoto.

Potential use cases for this library include:

  • Associating user inputs with arbitrary triggers for VJing
  • Introducing manual operations in generative art.

To get a feel for how it works, please try out this demo.

Supported Parameters

  • Pointer (mouse, stylus, touch)
    • All parameters supported in PointerEvent. (pressure, tilt, multi-touch)
  • MIDI
    • CC and velocity
  • Gamepad
    • Vendor-specific button name support: JoyCon, PS5 Controller

How to use

Installation

npm install bndr-js

Example

import {Bndr} from 'bndr-js'

Bndr.pointer(window).on(pressed =>
	console.log('Pointer %s', pressed ? 'pressed' : 'released')
)

Bndr.pointer(window)
	.position()
	.lerp(vec2.lerp, 0.1)
	.on(([x, y]) => console.log('Pointer moved: [%f, %f]', x, y))

Bndr.keyboard(window)
	.keydown('shift+c')
	.on(() => console.log('Hotkey shift+c pressed'))

Bndr.midi()
	.note(0, 50)
	.on(velocity => console.log('MIDI slider #50 moved: %d', velocity))

Bndr.gamepad()
	.axis(0)
	.on(([x, y]) => console.log('Gamepad axis #0 tilted: [%f, %f]', x, y))

License

This repository is published under an MIT License. See the included LICENSE file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.7%
  • JavaScript 1.3%