From 1f26bd3034d33659588be0ebdb9497bf4fa1a50a Mon Sep 17 00:00:00 2001 From: Arpad Csanyi Date: Thu, 14 Apr 2016 23:50:02 +0200 Subject: [PATCH 1/3] Try mouse icon instead of mouse cursor icon on the given layer. #27 --- examples/uhk.key-design.mouse-layer.svg | 293 +++++++------- ...key-design.mouse-layer.with_alignments.svg | 377 ++++++++---------- 2 files changed, 314 insertions(+), 356 deletions(-) diff --git a/examples/uhk.key-design.mouse-layer.svg b/examples/uhk.key-design.mouse-layer.svg index d4ec77cd..185eb750 100644 --- a/examples/uhk.key-design.mouse-layer.svg +++ b/examples/uhk.key-design.mouse-layer.svg @@ -51,7 +51,7 @@ showgrid="false" inkscape:zoom="1.4585257" inkscape:cx="512.161" - inkscape:cy="290.51895" + inkscape:cy="235.66905" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" @@ -618,8 +618,8 @@ style="fill:#333333;stroke:none" rx="3.5433071" ry="3.5433071" - x="395.1778" - y="160.27048" + x="395.80423" + y="159.85286" height="63.779526" width="63.779526" id="b6" /> @@ -863,30 +863,6 @@ x="340.14719" y="133.07333" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19px;font-family:Helvetica;-inkscape-font-specification:Helvetica;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /> - - - - - Move - - - - - - - - Scroll - - - - - - - - Scroll - - - - - - - - Click - - - Right - - - - - Click - - - Middle - - - - - Click - - - Btn 5 + + + + Scroll + + + + y="339.72635" /> + + + Scroll + + + + + + Move + + + + + + Click + + + + + + Click + + + + + + Click + + + diff --git a/examples/uhk.key-design.mouse-layer.with_alignments.svg b/examples/uhk.key-design.mouse-layer.with_alignments.svg index 847917ed..5d96f0da 100644 --- a/examples/uhk.key-design.mouse-layer.with_alignments.svg +++ b/examples/uhk.key-design.mouse-layer.with_alignments.svg @@ -51,11 +51,11 @@ showgrid="false" inkscape:zoom="1.4585257" inkscape:cx="512.161" - inkscape:cy="290.51895" + inkscape:cy="235.66905" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="g4336-9-1-6" + inkscape:current-layer="g4336-9-1-3" units="mm" inkscape:document-units="mm" inkscape:snap-bbox="true" @@ -815,8 +815,8 @@ style="fill:#333333;stroke:none" rx="3.5433071" ry="3.5433071" - x="395.1778" - y="160.27048" + x="395.80423" + y="159.85286" height="63.779526" width="63.779526" id="b6" /> @@ -1060,30 +1060,6 @@ x="340.14719" y="133.07333" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19px;font-family:Helvetica;-inkscape-font-specification:Helvetica;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /> - - - - - Move - - - - - - - - Scroll - - - - - - - - Scroll - - - - - - - - Click - - - - - - - - Click - - - - - - - - Click - - - Btn 5 + + + + + - - - - + id="g4555" + transform="translate(1.7599488,0.08481185)"> + style="font-size:14.13553333px;font-family:Helvetica;text-anchor:middle;overflow:visible;fill:#ffffff;stroke:none" + id="SvgjsText1172-6-0-2" + font-size="19" + x="481.92413" + y="186.52104"> + Scroll + + + y="339.72635" /> + + + Scroll + + + + + + Move + + + + + + Click + + + + + + Click + + + + + + Click + + + From 96c56c808165aaf0a64d22c5a98292659cb25619 Mon Sep 17 00:00:00 2001 From: Arpad Csanyi Date: Fri, 15 Apr 2016 00:21:16 +0200 Subject: [PATCH 2/3] Unify mouse icons + fix text size on some click action buttons. #27 --- examples/uhk.key-design.mouse-layer.svg | 422 +++++++-------- ...key-design.mouse-layer.with_alignments.svg | 499 +++++++++--------- 2 files changed, 430 insertions(+), 491 deletions(-) diff --git a/examples/uhk.key-design.mouse-layer.svg b/examples/uhk.key-design.mouse-layer.svg index 185eb750..4e902ec3 100644 --- a/examples/uhk.key-design.mouse-layer.svg +++ b/examples/uhk.key-design.mouse-layer.svg @@ -869,93 +869,18 @@ id="path4917" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccccccccccc" /> - - - - - Move - - - - - - - - Move - - - - - - - - Move - - - - - - - - Scroll - - - - - - - - Scroll - - - Left - - - - - Click - - - Button 4 - - - - - Click - - - - Btn 5 + x="250.27643" + y="341.86749">Button 4 - - - - - Click - - - - Btn 6 + + + Scroll + + + + + + Scroll + + + + + + Move + + + + + + Move + + + + + + Move + + + + + + Click + + + + + + Click + + + + + + Click + + + + Button 5 + Button 6 diff --git a/examples/uhk.key-design.mouse-layer.with_alignments.svg b/examples/uhk.key-design.mouse-layer.with_alignments.svg index 5d96f0da..e769f8cf 100644 --- a/examples/uhk.key-design.mouse-layer.with_alignments.svg +++ b/examples/uhk.key-design.mouse-layer.with_alignments.svg @@ -23,7 +23,7 @@ image/svg+xml - + @@ -55,7 +55,7 @@ inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="g4336-9-1-3" + inkscape:current-layer="g4471" units="mm" inkscape:document-units="mm" inkscape:snap-bbox="true" @@ -184,7 +184,7 @@ width="63.779526" height="21.259842" x="613.95819" - y="238.22409" + y="238.22406" rx="3.5433099" ry="3.5433097" /> - - - - - Move - - - - - - - - Move - - - - - - - - Move - - - - - - - - Scroll - - - - - - - - Scroll - - - - - - - - Click - - - Button 4 + x="250.27643" + y="341.86749">Button 4 - - - - Click - - + id="g4471"> + + + + - Btn 5 - - - - - - - - - Click - - - - Btn 6 + + + Scroll + + + + + + Scroll + + + + + + Move + + + + + + Move + + + + + + Move + + + + + + Click + + + + + + Click + + + + + + Click + + + + Button 5 + Button 6 From 97c025d19bb5774217922fc8c976a7e2f8bb59bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 15 Apr 2016 01:49:01 +0200 Subject: [PATCH 3/3] Ease debugging by making the dump much easier to read for deeper object hierarchies. --- config-serializer/ClassArray.ts | 2 -- config-serializer/Serializable.ts | 38 ++++++++-------------------- config-serializer/UhkBuffer.ts | 27 ++++++++++++-------- config-serializer/test-serializer.ts | 3 +++ 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/config-serializer/ClassArray.ts b/config-serializer/ClassArray.ts index 73420141..af514ec8 100644 --- a/config-serializer/ClassArray.ts +++ b/config-serializer/ClassArray.ts @@ -13,7 +13,6 @@ abstract class ClassArray extends Serializable { let arrayLength = buffer.readCompactLength(); if (buffer.enableDump) { - process.stdout.write(']\n'); buffer.enableDump = false; } @@ -35,7 +34,6 @@ abstract class ClassArray extends Serializable { buffer.writeCompactLength(this.elements.length); if (buffer.enableDump) { - process.stdout.write(']\n'); buffer.enableDump = false; } diff --git a/config-serializer/Serializable.ts b/config-serializer/Serializable.ts index c7b0b50a..f108db94 100644 --- a/config-serializer/Serializable.ts +++ b/config-serializer/Serializable.ts @@ -5,58 +5,43 @@ abstract class Serializable { private static enableDump = true; fromJsObject(jsObject: any): Serializable { - let isArray = this instanceof ClassArray; - this.dumpMethodName('fromJsObject'); - this.dump(`${this.strintifyJsObject(jsObject)}` + (isArray ? '\n' : ` => `)); + this.dump(`${this.getIndentation()}${this.constructor.name}.fromJsObject: ` + + `${this.strintifyJsObject(jsObject)}\n`); Serializable.depth++; let value = this._fromJsObject(jsObject); Serializable.depth--; - if (!isArray) { - this.dump(`${value}\n`); - } + this.dump(`${this.getIndentation()}=> ${value}\n`); return value; } fromBinary(buffer: UhkBuffer): Serializable { - let isArray = this instanceof ClassArray; - this.dumpMethodName('fromBinary'); - this.dump('['); + this.dump(`\n${this.getIndentation()}${this.constructor.name}.fromBinary: [`); Serializable.depth++; buffer.enableDump = Serializable.enableDump; let value = this._fromBinary(buffer); buffer.enableDump = false; Serializable.depth--; - if (!isArray) { - this.dump(`] => ${value}\n`); - } + this.dump(`]\n${this.getIndentation()}=> ${value}`); return value; } toJsObject(): any { - let isArray = this instanceof ClassArray; - this.dumpMethodName('toJsObject'); - this.dump(`${this}` + (isArray ? '\n' : ` => `)); + this.dump(`${this.getIndentation()}${this.constructor.name}.toJsObject: ${this}\n`); Serializable.depth++; let value = this._toJsObject(); Serializable.depth--; - if (!isArray) { - this.dump(`${this.strintifyJsObject(value)}\n`); - } + this.dump(`${this.getIndentation()}=> ${this.strintifyJsObject(value)}\n`); return value; } toBinary(buffer: UhkBuffer): void { - let isArray = this instanceof ClassArray; - this.dumpMethodName('toBinary'); - this.dump(`${this} => ['`); + this.dump(`\n${this.getIndentation()}${this.constructor.name}.toBinary: ${this} [`); Serializable.depth++; buffer.enableDump = Serializable.enableDump; let value = this._toBinary(buffer); buffer.enableDump = false; Serializable.depth--; - if (!isArray) { - this.dump(`]\n`); - } + this.dump(`]`); return value; } @@ -71,9 +56,8 @@ abstract class Serializable { } } - private dumpMethodName(methodName: string) { - let indentation = new Array(Serializable.depth + 1).join(' '); - this.dump(`${indentation}${this.constructor.name}.${methodName}: `); + private getIndentation() { + return new Array(Serializable.depth + 1).join(' '); } private strintifyJsObject(jsObject: any): string { diff --git a/config-serializer/UhkBuffer.ts b/config-serializer/UhkBuffer.ts index d7e66db3..85f1204f 100644 --- a/config-serializer/UhkBuffer.ts +++ b/config-serializer/UhkBuffer.ts @@ -1,4 +1,5 @@ class UhkBuffer { + private static eepromSize = 32 * 1024; private static maxCompactLength = 0xFFFF; private static longCompactLengthPrefix = 0xFF; @@ -156,21 +157,25 @@ class UhkBuffer { } set enableDump(value) { - UhkBuffer.isFirstElementToDump = true; + if (value) { + UhkBuffer.isFirstElementToDump = true; + } this._enableDump = value; } dump(value) { - if (this.enableDump) { - if (!UhkBuffer.isFirstElementToDump) { - process.stdout.write(', '); - } - process.stdout.write(value); - if (UhkBuffer.isFirstElementToDump) { - UhkBuffer.isFirstElementToDump = false; - } - } else { - UhkBuffer.isFirstElementToDump = true; + if (!this.enableDump) { + return; + } + + if (!UhkBuffer.isFirstElementToDump) { + process.stdout.write(', '); + } + + process.stdout.write(value); + + if (UhkBuffer.isFirstElementToDump) { + UhkBuffer.isFirstElementToDump = false; } } } diff --git a/config-serializer/test-serializer.ts b/config-serializer/test-serializer.ts index f2cf8f69..1730d593 100644 --- a/config-serializer/test-serializer.ts +++ b/config-serializer/test-serializer.ts @@ -18,7 +18,9 @@ let keyActions1BufferContent = keyActions1Buffer.getBufferContent(); fs.writeFileSync('uhk-config.bin', keyActions1BufferContent); keyActions1Buffer.offset = 0; +console.log(); let keyActions2Ts = new KeyActions().fromBinary(keyActions1Buffer); +console.log('\n'); let keyActions2Js = keyActions2Ts.toJsObject(); let keyActions2Buffer = new UhkBuffer(); keyActions2Ts.toBinary(keyActions2Buffer); @@ -26,6 +28,7 @@ fs.writeFileSync('uhk-config-serialized.json', JSON.stringify(keyActions2Js, und let keyActions2BufferContent = keyActions1Buffer.getBufferContent(); fs.writeFileSync('uhk-config-serialized.bin', keyActions2BufferContent); +console.log('\n'); try { assert.deepEqual(keyActions1Js, keyActions2Js); console.log('JSON configurations are identical.');