javascript video_board.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript video_board.js相关的知识,希望对你有一定的参考价值。

var HID = require("node-hid");
var exec = require("child_process").exec;

console.log("\u0007");
// var devices = HID.devices();
// var device = new HID.HID(1452, 632);
var device = new HID.HID(
  "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS02@14100000/USB 2.0 Hub@14100000/AppleUSB20Hub@14100000/AppleUSB20HubPort@14130000/Generic   USB  Joystick  @14130000/IOUSBHostInterface@0/IOUSBHostHIDDevice@14130000,0"
);

var state;
device.on("data", function(data) {
  //   console.log(data.slice(5, 6));
  console.log(JSON.stringify(data.slice(5, 6)[0]));
  if (data.slice(5, 6)[0] == 47 && state != 47) {
    state = data.slice(5, 6)[0];
    console.log("it works");
    exec("say I hate you");
  }

  if (data.slice(5, 6)[0] == 15 && state != 15) {
    state = data.slice(5, 6)[0];
  }
  if (data.slice(5, 6)[0] == 31 && state != 31) {
    state = data.slice(5, 6)[0];
    console.log("other button");
    exec("say Go die...");
    // console.log(button);
  }
  if (data.slice(5, 6)[0] == 79 && state != 79) {
    state = data.slice(5, 6)[0];
    exec("say FUck off");
    // console.log(button);
  }
});

device.on("error", function(err) {
  console.log(err);
  return;
});

以上是关于javascript video_board.js的主要内容,如果未能解决你的问题,请参考以下文章

javascript的题。

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript