Permalink
Browse files

New button setup

  • Loading branch information...
sGerli committed Feb 3, 2017
1 parent 118cc91 commit 5277c6fb7eb3cee889f47fa407961550ee6e892a
Showing with 34 additions and 32 deletions.
  1. +2 −2 Dockerfile.template
  2. +32 −30 app/main.js
View
@@ -28,9 +28,9 @@ RUN apt-get update && apt-get install -y \
libsmbclient \
libssh-4 \
fbset \
- libexpat-dev && rm -rf /var/lib/apt/lists/* \
+ libexpat-dev\
libxtst-dev \
- libpng-dev
+ libpng-dev && rm -rf /var/lib/apt/lists/*
# Set Xorg and FLUXBOX preferences
RUN mkdir ~/.fluxbox
View
@@ -85,57 +85,59 @@ app.on('ready', () => {
/////////////*/
// PiPins
-var piPins = require("pi-pins");
-var robot = require("robotjs");
+const piPins = require('pi-pins');
+const robot = require('robotjs');
const navButtonPins = {
- upButton = 16,
- downButton = 17,
- backButton = 27,
- selectButton = 22,
+ upButton: 16,
+ downButton: 17,
+ backButton: 27,
+ selectButton: 22,
};
-var navButtons = {
- upButton = piPins.connect(navButtonPins.upButton),
- downButton = piPins.connect(navButtonPins.downButton),
- backButton = piPins.connect(navButtonPins.backButton),
- selectButton = piPins.connect(navButtonPins.selectButton)
+const navButtons = {
+ upButton: piPins.connect(navButtonPins.upButton),
+ downButton: piPins.connect(navButtonPins.downButton),
+ backButton: piPins.connect(navButtonPins.backButton),
+ selectButton: piPins.connect(navButtonPins.selectButton),
};
-for (var key in navButtons) {
+for (const key in navButtons) {
// Loopthrough navButtons
if (navButtons.hasOwnProperty(key)) {
navButtons[key].mode('in');
-
switch (key) {
- case upButton:
+ case 'upButton':
// Tab
- navButtons[key].on('rise', function () {
- robot.keyTap("tab");
- }
+ navButtons[key].on('rise', () => {
+ robot.keyTap('tab', 'shift');
+ console.log('upButton Pressed');
+ });
break;
- case downButton:
+ case 'downButton':
// Shift+tab
- navButtons[key].on('rise', function () {
- robot.keyTap("tab", "shift");
- }
+ navButtons[key].on('rise', () => {
+ robot.keyTap('tab');
+ console.log('downButton Pressed');
+ });
break;
- case backButton:
+ case 'backButton':
// History back
- navButtons[key].on('rise', function () {
- console.log("Back");
- }
+ navButtons[key].on('rise', () => {
+ console.log('Back');
+ });
break;
- case selectButton:
+ case 'selectButton':
// Enter
- navButtons[key].on('rise', function () {
- robot.keyTap("enter");
- }
+ navButtons[key].on('rise', () => {
+ robot.keyTap('enter');
+ console.log('selectButton Pressed');
+ });
break;
default:
-
+ console.log('Button Pressed');
}
}
}

0 comments on commit 5277c6f

Please sign in to comment.