Add UhkBuffer read methods and rename Uint to UInt in its other methods.
This commit is contained in:
@@ -20,7 +20,7 @@ class KeystrokeAction implements Serializable {
|
||||
}
|
||||
|
||||
toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUint8(this.scancode);
|
||||
buffer.writeUint8(this.modifierMask);
|
||||
buffer.writeUInt8(this.scancode);
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,39 +7,79 @@ class UhkBuffer {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
readInt8():number {
|
||||
let value = this.buffer.readInt8(this.offset);
|
||||
this.offset += 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeInt8(value:number):void {
|
||||
this.buffer.writeInt8(value, this.offset);
|
||||
this.offset += 1;
|
||||
}
|
||||
|
||||
writeUint8(value:number):void {
|
||||
readUInt8():number {
|
||||
let value = this.buffer.readUInt8(this.offset);
|
||||
this.offset += 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeUInt8(value:number):void {
|
||||
this.buffer.writeUInt8(value, this.offset);
|
||||
this.offset += 1;
|
||||
}
|
||||
|
||||
readInt16():number {
|
||||
let value = this.buffer.readInt16LE(this.offset);
|
||||
this.offset += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeInt16(value:number):void {
|
||||
this.buffer.writeInt16LE(value, this.offset);
|
||||
this.offset += 2;
|
||||
}
|
||||
|
||||
writeUint16(value:number):void {
|
||||
readUInt16():number {
|
||||
let value = this.buffer.readUInt16LE(this.offset);
|
||||
this.offset += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeUInt16(value:number):void {
|
||||
this.buffer.writeUInt16LE(value, this.offset);
|
||||
this.offset += 2;
|
||||
}
|
||||
|
||||
readInt32():number {
|
||||
let value = this.buffer.readInt32LE(this.offset);
|
||||
this.offset += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeInt32(value:number):void {
|
||||
this.buffer.writeInt32LE(value, this.offset);
|
||||
this.offset += 4;
|
||||
}
|
||||
|
||||
writeUint32(value:number):void {
|
||||
readUInt32():number {
|
||||
let value = this.buffer.readUInt32LE(this.offset);
|
||||
this.offset += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
writeUInt32(value:number):void {
|
||||
this.buffer.writeUInt32LE(value, this.offset);
|
||||
this.offset += 4;
|
||||
}
|
||||
|
||||
readString(string:string):void {
|
||||
// to be implemented
|
||||
}
|
||||
|
||||
writeString(string:string):void {
|
||||
this.buffer.write(string, this.offset, string.length, 'ascii');
|
||||
this.offset += string.length;
|
||||
this.writeUint8(0);
|
||||
this.writeUInt8(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ function serializeKeyActions(keyActions) {
|
||||
keyActions.forEach(function(keyAction) {
|
||||
serializeKeyAction(keyAction);
|
||||
});
|
||||
writer.writeUint8(ARRAY_LAST_ELEMENT_ID);
|
||||
writer.writeUInt8(ARRAY_LAST_ELEMENT_ID);
|
||||
}
|
||||
|
||||
function serializeKeyAction(keyAction) {
|
||||
@@ -87,17 +87,17 @@ function serializeKeyAction(keyAction) {
|
||||
}
|
||||
|
||||
function serializeNoneAction() {
|
||||
writer.writeUint8(KEY_ACTION_ID_NONE);
|
||||
writer.writeUint8(NONE_ACTION_PADDING);
|
||||
writer.writeUInt8(KEY_ACTION_ID_NONE);
|
||||
writer.writeUInt8(NONE_ACTION_PADDING);
|
||||
}
|
||||
|
||||
function serializeKeystrokeAction(keystrokeAction) {
|
||||
writer.writeUint8(keystrokeAction.scancode);
|
||||
writer.writeUint8(keystrokeAction.modifiers);
|
||||
writer.writeUInt8(keystrokeAction.scancode);
|
||||
writer.writeUInt8(keystrokeAction.modifiers);
|
||||
}
|
||||
|
||||
function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
||||
writer.writeUint8({
|
||||
writer.writeUInt8({
|
||||
mod : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOD,
|
||||
fn : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_FN,
|
||||
mouse : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_MOUSE,
|
||||
@@ -110,12 +110,12 @@ function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
||||
rightAlt : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_ALT,
|
||||
rightSuper : KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_SUPER
|
||||
}[dualRoleKeyAction.longPressAction]);
|
||||
writer.writeUint8(dualRoleKeyAction.scancode);
|
||||
writer.writeUInt8(dualRoleKeyAction.scancode);
|
||||
}
|
||||
|
||||
function serializeMouseAction(mouseAction) {
|
||||
writer.writeUint8(KEY_ACTION_ID_MOUSE);
|
||||
writer.writeUint8({
|
||||
writer.writeUInt8(KEY_ACTION_ID_MOUSE);
|
||||
writer.writeUInt8({
|
||||
leftClick : MOUSE_ACTION_ID_LEFT_CLICK,
|
||||
middleClick: MOUSE_ACTION_ID_MIDDLE_CLICK,
|
||||
rightClick : MOUSE_ACTION_ID_RIGHT_CLICK,
|
||||
@@ -133,18 +133,18 @@ function serializeMouseAction(mouseAction) {
|
||||
}
|
||||
|
||||
function serializeMacroAction(macroAction) {
|
||||
writer.writeUint8(KEY_ACTION_ID_PLAY_MACRO);
|
||||
writer.writeUint8(macroAction.macroId);
|
||||
writer.writeUInt8(KEY_ACTION_ID_PLAY_MACRO);
|
||||
writer.writeUInt8(macroAction.macroId);
|
||||
}
|
||||
|
||||
function serializeSwitchKeymapAction(switchKeymapAction) {
|
||||
writer.writeUint8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
||||
writer.writeUint8(switchKeymapAction.keymapId);
|
||||
writer.writeUInt8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
||||
writer.writeUInt8(switchKeymapAction.keymapId);
|
||||
}
|
||||
|
||||
function serializeSwitchLayerAction(switchLayerAction) {
|
||||
writer.writeUint8(KEY_ACTION_ID_SWITCH_LAYER);
|
||||
writer.writeUint8({
|
||||
writer.writeUInt8(KEY_ACTION_ID_SWITCH_LAYER);
|
||||
writer.writeUInt8({
|
||||
mod : SWITCH_LAYER_MOD,
|
||||
fn : SWITCH_LAYER_FN,
|
||||
mouse: SWITCH_LAYER_MOD
|
||||
|
||||
Reference in New Issue
Block a user