terminal-joystick
🎮 A joystick for your terminal.
⚠️ Highly experimental
Install
npm i -S terminal-joystick
Usage
const TerminalJoystick ON_DRAG = ; const joystick = title : 'Joystick - Example'; joystick; joystick;
Using with blessed
To add terminal-joystick
to an existing blessed application, you just need to provide a reference to the blessed.screen
object and a parent
container :
const TerminalJoystick ON_DRAG = ; const screen = blessed;const container = left : 'center' top : 'center' width : '100%' height : '100%'; const joystick = parent : container title : 'Joystick - Example' screen; joystick;
API
new TerminalJoystick(opts)
screen
: reference to an existingblessed
screen (optional)container
:size
: pad's size (default : 100)- All
blessed.Element
properties
joystick
:size
: joystick's size (default : 15)- All
blessed.Element
properties
title
: terminal tab title (optional) / Only used ifscreen
is not providednoReturnToOrigin
: A flag to disable the joystick return to its initial position when mouse click is released.
on(event, handler)
:TerminalJoystick
extendsEventEmitter
.ON_DRAG
: emitted when the joystick is dragged.angle
: angle in degress (0-360) between the joystick and the x-axis.intensity
: distance from the center (0-1)x
: coordinate along the x-axis between -1 and 1y
: coordinate along the y-axis between -1 and 1
ON_DRAG_END
: emitted when the mouse click is released.