From 7523758afd1081a78f499e91000b2f811b544c9b Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Wed, 7 Apr 2021 08:53:05 +0200 Subject: [PATCH] chore: fix examples --- examples/basic-log-all-events.js | 4 +-- examples/manually-connect.js | 2 +- examples/xkeys.ts | 52 -------------------------------- 3 files changed, 3 insertions(+), 55 deletions(-) delete mode 100644 examples/xkeys.ts diff --git a/examples/basic-log-all-events.js b/examples/basic-log-all-events.js index 1dacc5d..7bd125a 100644 --- a/examples/basic-log-all-events.js +++ b/examples/basic-log-all-events.js @@ -1,7 +1,7 @@ -const { XKeysWatcher } = require('../dist') // require('xkeys') +const { XKeysWatcher } = require('xkeys') /* - This example connects to any conncted x-keys panel and logs + This example connects to any conncted x-keys panels and logs whenever a button is pressed or analog thing is moved */ diff --git a/examples/manually-connect.js b/examples/manually-connect.js index 702628b..5048b26 100644 --- a/examples/manually-connect.js +++ b/examples/manually-connect.js @@ -1,4 +1,4 @@ -import { XKeys } from 'xkeys' +const { XKeys } = require('xkeys') /* This example shows how to use XKeys.setupXkeysPanel() diff --git a/examples/xkeys.ts b/examples/xkeys.ts deleted file mode 100644 index 77be6d2..0000000 --- a/examples/xkeys.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { XKeys, XKeysWatcher } from '../' - -// Set up the watcher for xkeys -const watcher = new XKeysWatcher() - -watcher.on('connected', (xkeysPanel: XKeys) => { - console.log(`X-keys panel of type ${xkeysPanel.info.name} connected`) - - xkeysPanel.on('disconnected', () => { - console.log(`X-keys panel of type ${xkeysPanel.info.name} was disconnected`) - // Clean up stuff - xkeysPanel.removeAllListeners() - }) - xkeysPanel.on('error', (...errs) => { - console.log('X-keys error:', ...errs) - }) - - // Listen to pressed buttons: - xkeysPanel.on('down', (btnIndex, metadata) => { - console.log('Button pressed ', btnIndex, metadata) - - // Light up a button when pressed: - xkeysPanel.setBacklight(btnIndex, 'red') - }) - // Listen to released buttons: - xkeysPanel.on('up', (btnIndex, metadata) => { - console.log('Button released', btnIndex, metadata) - - // Turn off button light when released: - xkeysPanel.setBacklight(btnIndex, false) - }) - - // Listen to jog wheel changes: - xkeysPanel.on('jog', (index, deltaPos, metadata) => { - console.log(`Jog ${index} position has changed`, deltaPos, metadata) - }) - // Listen to shuttle changes: - xkeysPanel.on('shuttle', (index, shuttlePos, metadata) => { - console.log(`Shuttle ${index} position has changed`, shuttlePos, metadata) - }) - // Listen to joystick changes: - xkeysPanel.on('joystick', (index, position, metadata) => { - console.log(`Joystick ${index} position has changed`, position, metadata) // {x, y, z} - }) - // Listen to t-bar changes: - xkeysPanel.on('tbar', (index, position, metadata) => { - console.log(`T-bar ${index} position has changed`, position, metadata) - }) -}) - -// To stop watching, call -// watcher.stop()