eduku-hid
v1.2.6
Published
eduku usb hid device sdk
Readme
eduku-hid - Access EDUKU USB HID devices from Node.js
Platform Support
eduku-hid supports Node.js v6 and upwards. For versions before that,
you will need to build from source. The platforms, architectures and node versions eduku-hid supports are the following.
In general we try to provide pre-built native library binaries for the most common platforms, Node and Electron versions.
We strive to make eduku-hid cross-platform so there's a good chance any
combination not listed here will compile and work.
Installation
For most "standard" use cases (macOS, Windows, Linux x86), eduku-hid will install like a standard npm package:
npm install eduku-hidUsage
Config eduku client listener
var eduku = require("eduku-hid");
eduku.config({
//初始化
TouchSensorAngle: "0", // 书写框摆放角度, 0: 0度,1: 180度,2: 90度,3: 270度
template: {}, // 模板详情
on: {
DeviceInfo: function (device) {
// 设备信息
//console.log("DeviceInfo:", data);
},
TouchData: function (touch) {
//触摸数据
//console.log("TouchData:", touch);
},
data: function () {}, // hid data
error: function (type, error) {}, // hid error
},
});Sample config:
var eduku = require('eduku-hid');
eduku.config({ //初始化
TouchSensorAngle: "0",// 书写框摆放角度, 0: 0度,1: 180度,2: 90度,3: 270度
template: {
rubWidth: "",//该值不能为数字0
rubHeight: "",//该值不能为数字0
button_width: 30,
button_height: 90,
clear_x: 10,
clear_y: -45,
save_x: 50,
save_y: -45,
switch_x: 90,
switch_y: -45,
pageup_x: 130,
pageup_y: -45,
pagedown_x: 170,
pagedown_y: -45,
red_x: 210,
red_y: -45,
blue_x: 250,
blue_y: -45,
black_x: 290,
black_y: -45,
share_x: 330,
share_y: -45,
},
on: {
DeviceInfo: function(device){ // 设备信息
//console.log("DeviceInfo:", data);
},
TouchData: function(touch){ //触摸数据
console.log("TouchData:", touch);
},
data: function(){} // hid data
error: function(type, error){} // hid error
}
});
// or config listeners via "on" function
eduku.on('TouchData', function(touchdata){
//
})
eduku.on('error', function(err){
//err.code
})Event:
DeviceInfo:设备信息;
TouchData:触摸数据;
data:HID hid;
error:HID 错误信息;
Error codes:
| 编号 | 描述 | 操作 | | :--: | :------------------: | :------------------: | | 6 | 正在扫描设备 | 检查设备是否正确接入 | | 7 | config 参数缺失 | 检查 config 参数 | | 8 | 设备断开连接 | 检查设备是否正确接入 | | 9 | 无法扫描本机设备列表 | 检查程序是否有权限 |
Template explanation
| 键名\解释 | 例如\键值 | 类型 | | :--------------------------: | :-------: | :--: | | rubWidth\板擦宽度 | 111 | 数字 | | rubHeight\板擦高度 | 111 | 数字 | | button_width\按钮宽度 | 111 | 数字 | | button_height\按钮高度 | 111 | 数字 | | clear_x\清除按钮 x 坐标 | 111 | 数字 | | clear_y\清除按钮 y 坐标 | 111 | 数字 | | save_x\保存按钮 x 坐标 | 111 | 数字 | | save_y\保存按钮 y 坐标 | 111 | 数字 | | switch_x\切换按钮 x 坐标 | 111 | 数字 | | switch_y\切换按钮 y 坐标 | 111 | 数字 | | pageup_x\前一页按钮 x 坐标 | 111 | 数字 | | pageup_y\前一页按钮 y 坐标 | 111 | 数字 | | pagedown_x\后一页按钮 x 坐标 | 111 | 数字 | | pagedown_y\后一页按钮 y 坐标 | 111 | 数字 | | red_x\红色按钮 x 坐标 | 111 | 数字 | | red_y\红色按钮 y 坐标 | 111 | 数字 | | blue_x\蓝色按钮 x 坐标 | 111 | 数字 | | blue_y\蓝色按钮 y 坐标 | 111 | 数字 | | black_x\黑色按钮 x 坐标 | 111 | 数字 | | black_y\黑色按钮 y 坐标 | 111 | 数字 | | share_x\功能键按钮 x 坐标 | 111 | 数字 | | share_y\功能键按钮 y 坐标 | 111 | 数字 |
Returned data
Data Format:
{
_UsbTouchPoint: {
tipSwitch: 0,
contact_ID: 0,
x: 135.783,
y: 105.71934375,
width: 31.147031249999998,
height: 12.368531249999998,
},
JudgePointTypeType: { type: 0, x: 201.05634375, y: 146.79731249999998 },
buttonClickData: { name: 'clear', x: 10.02121875, y: 24.28565625 },
};
Explanation:
_UsbTouchPoint:usb 点数据;
tipSwitch:手指抬起放下 0是无效点数据,7是有效数据;
contact_ID:多点触摸 ID;
x:x 点坐标;
y:y 点坐标;
width:触点宽度;
height:触点高度;
JudgePointTypeType:板擦数据;
type:0是板擦;
x:板擦 x 坐标;
y:板擦 y 坐标;
btnName:按钮名称;
x:按钮 x 坐标;
y:按钮 y 坐标;
DeviceInfo
Data Format:
DeviceInfo: {
boardDimension: '21',
longLightNum: '64',
shortLightNum: '64',
hardwareVersion: '4.9.C06b',
maxSupportPointNum: '10',
scanCycle: '5',
lightSplitNum: '64',
lightWidth: 5.778,
boardWidthMM: 370.432,
boardHeightMM: 370.432,
serialNumber: '2C0028001557345734363020',
valid: true,
state: true
}Explanation:
DeviceInfo:书写框初始化数据;
boardDimension:框尺寸;
longLightNum:长边灯灯管数;
shortLightNum:短边灯管数;
hardwareVersion:硬件版本;
maxSupportPointNum:最大支持点数;
scanCycle:扫描周期;
lightSplitNum:灯管分割数;
lightWidth:灯管宽度;
boardWidthMM:框的宽\毫米;
boardHeightMM:框的高\毫米;
serialNumber:序列号;
valid:无用;
state:无用;
