Prefix the name of UhkBuffer write methods with "write".
This commit is contained in:
@@ -20,7 +20,7 @@ class KeystrokeAction implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toBinary(buffer: UhkBuffer) {
|
toBinary(buffer: UhkBuffer) {
|
||||||
buffer.uint8(this.scancode);
|
buffer.writeUint8(this.scancode);
|
||||||
buffer.uint8(this.modifierMask);
|
buffer.writeUint8(this.modifierMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -7,39 +7,39 @@ class UhkBuffer {
|
|||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8(value) {
|
writeInt8(value) {
|
||||||
this.buffer.writeInt8(value, this.offset);
|
this.buffer.writeInt8(value, this.offset);
|
||||||
this.offset += 1;
|
this.offset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8(value) {
|
writeUint8(value) {
|
||||||
this.buffer.writeUInt8(value, this.offset);
|
this.buffer.writeUInt8(value, this.offset);
|
||||||
this.offset += 1;
|
this.offset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16(value) {
|
writeInt16(value) {
|
||||||
this.buffer.writeInt16LE(value, this.offset);
|
this.buffer.writeInt16LE(value, this.offset);
|
||||||
this.offset += 2;
|
this.offset += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16(value) {
|
writeUint16(value) {
|
||||||
this.buffer.writeUInt16LE(value, this.offset);
|
this.buffer.writeUInt16LE(value, this.offset);
|
||||||
this.offset += 2;
|
this.offset += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32(value) {
|
writeInt32(value) {
|
||||||
this.buffer.writeInt32LE(value, this.offset);
|
this.buffer.writeInt32LE(value, this.offset);
|
||||||
this.offset += 4;
|
this.offset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32(value) {
|
writeUint32(value) {
|
||||||
this.buffer.writeUInt32LE(value, this.offset);
|
this.buffer.writeUInt32LE(value, this.offset);
|
||||||
this.offset += 4;
|
this.offset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
string(string) {
|
writeString(string) {
|
||||||
this.buffer.write(string, this.offset, string.length, 'ascii');
|
this.buffer.write(string, this.offset, string.length, 'ascii');
|
||||||
this.offset += string.length;
|
this.offset += string.length;
|
||||||
this.uint8(0);
|
this.writeUint8(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -2,7 +2,7 @@
|
|||||||
/// <reference path="KeystrokeAction.ts" />
|
/// <reference path="KeystrokeAction.ts" />
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var buffer = new Buffer(1000);
|
var buffer:Buffer = new Buffer(1000);
|
||||||
buffer.fill(0);
|
buffer.fill(0);
|
||||||
var writer = new UhkBuffer(buffer);
|
var writer = new UhkBuffer(buffer);
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ function serializeKeyActions(keyActions) {
|
|||||||
keyActions.forEach(function(keyAction) {
|
keyActions.forEach(function(keyAction) {
|
||||||
serializeKeyAction(keyAction);
|
serializeKeyAction(keyAction);
|
||||||
});
|
});
|
||||||
writer.uint8(ARRAY_LAST_ELEMENT_ID);
|
writer.writeUint8(ARRAY_LAST_ELEMENT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeKeyAction(keyAction) {
|
function serializeKeyAction(keyAction) {
|
||||||
@@ -87,17 +87,17 @@ function serializeKeyAction(keyAction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function serializeNoneAction() {
|
function serializeNoneAction() {
|
||||||
writer.uint8(KEY_ACTION_ID_NONE);
|
writer.writeUint8(KEY_ACTION_ID_NONE);
|
||||||
writer.uint8(NONE_ACTION_PADDING);
|
writer.writeUint8(NONE_ACTION_PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeKeystrokeAction(keystrokeAction) {
|
function serializeKeystrokeAction(keystrokeAction) {
|
||||||
writer.uint8(keystrokeAction.scancode);
|
writer.writeUint8(keystrokeAction.scancode);
|
||||||
writer.uint8(keystrokeAction.modifiers);
|
writer.writeUint8(keystrokeAction.modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
||||||
writer.uint8({
|
writer.writeUint8({
|
||||||
mod : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOD,
|
mod : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOD,
|
||||||
fn : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_FN,
|
fn : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_FN,
|
||||||
mouse : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOUSE,
|
mouse : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOUSE,
|
||||||
@@ -110,12 +110,12 @@ function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
|||||||
rightAlt : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_ALT,
|
rightAlt : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_ALT,
|
||||||
rightSuper : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_SUPER
|
rightSuper : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_SUPER
|
||||||
}[dualRoleKeyAction.longPressAction]);
|
}[dualRoleKeyAction.longPressAction]);
|
||||||
writer.uint8(dualRoleKeyAction.scancode);
|
writer.writeUint8(dualRoleKeyAction.scancode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeMouseAction(mouseAction) {
|
function serializeMouseAction(mouseAction) {
|
||||||
writer.uint8(KEY_ACTION_ID_MOUSE);
|
writer.writeUint8(KEY_ACTION_ID_MOUSE);
|
||||||
writer.uint8({
|
writer.writeUint8({
|
||||||
leftClick : MOUSE_ACTION_ID_LEFT_CLICK,
|
leftClick : MOUSE_ACTION_ID_LEFT_CLICK,
|
||||||
middleClick: MOUSE_ACTION_ID_MIDDLE_CLICK,
|
middleClick: MOUSE_ACTION_ID_MIDDLE_CLICK,
|
||||||
rightClick : MOUSE_ACTION_ID_RIGHT_CLICK,
|
rightClick : MOUSE_ACTION_ID_RIGHT_CLICK,
|
||||||
@@ -133,18 +133,18 @@ function serializeMouseAction(mouseAction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function serializeMacroAction(macroAction) {
|
function serializeMacroAction(macroAction) {
|
||||||
writer.uint8(KEY_ACTION_ID_PLAY_MACRO);
|
writer.writeUint8(KEY_ACTION_ID_PLAY_MACRO);
|
||||||
writer.uint8(macroAction.macroId);
|
writer.writeUint8(macroAction.macroId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeSwitchKeymapAction(switchKeymapAction) {
|
function serializeSwitchKeymapAction(switchKeymapAction) {
|
||||||
writer.uint8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
writer.writeUint8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
||||||
writer.uint8(switchKeymapAction.keymapId);
|
writer.writeUint8(switchKeymapAction.keymapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeSwitchLayerAction(switchLayerAction) {
|
function serializeSwitchLayerAction(switchLayerAction) {
|
||||||
writer.uint8(KEY_ACTION_ID_SWITCH_LAYER);
|
writer.writeUint8(KEY_ACTION_ID_SWITCH_LAYER);
|
||||||
writer.uint8({
|
writer.writeUint8({
|
||||||
mod : SWITCH_LAYER_MOD,
|
mod : SWITCH_LAYER_MOD,
|
||||||
fn : SWITCH_LAYER_FN,
|
fn : SWITCH_LAYER_FN,
|
||||||
mouse: SWITCH_LAYER_MOD
|
mouse: SWITCH_LAYER_MOD
|
||||||
|
|||||||
Reference in New Issue
Block a user