From 437a9e9fd1f1d5e1d7e9f65812145394742182ef Mon Sep 17 00:00:00 2001 From: Mattijs van Ommeren Date: Mon, 30 Oct 2017 14:09:16 +0100 Subject: [PATCH 1/8] Added define for KEY_CAPS_LOCK --- modules/Digispark.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/Digispark.js b/modules/Digispark.js index 27dcb28..85711c9 100644 --- a/modules/Digispark.js +++ b/modules/Digispark.js @@ -269,7 +269,8 @@ new Object({ + '#define KEY_HOME 0x4A\n' + '#define KEY_INSERT 0x49\n' + '#define KEY_NUM_LOCK 0x53\n' - + '#define KEY_SCROLL_LOCK 0x47\n' + + '#define KEY_SCROLL_LOCK 0x47\n' + + '#define KEY_CAPSi_LOCK 0x39\n' + '#define KEY_TAB 0x2B\n\n' + 'void digiBegin() {\n' + ' DigiKeyboard.sendKeyStroke(0,0);\n' From d9bec00387f303aefe3ae63f8907e2f3d8529220 Mon Sep 17 00:00:00 2001 From: Mattijs van Ommeren Date: Mon, 30 Oct 2017 17:22:14 +0100 Subject: [PATCH 2/8] Fixed typo --- modules/Digispark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Digispark.js b/modules/Digispark.js index 85711c9..e7d2007 100644 --- a/modules/Digispark.js +++ b/modules/Digispark.js @@ -270,7 +270,7 @@ new Object({ + '#define KEY_INSERT 0x49\n' + '#define KEY_NUM_LOCK 0x53\n' + '#define KEY_SCROLL_LOCK 0x47\n' - + '#define KEY_CAPSi_LOCK 0x39\n' + + '#define KEY_CAPS_LOCK 0x39\n' + '#define KEY_TAB 0x2B\n\n' + 'void digiBegin() {\n' + ' DigiKeyboard.sendKeyStroke(0,0);\n' From 3cd1df661673a123d940b24ff4c7b75a83a75489 Mon Sep 17 00:00:00 2001 From: Nurrl Date: Sun, 19 Aug 2018 13:10:23 +0200 Subject: [PATCH 3/8] Reviewed issues requirements and added per module locales --- .github/ISSUE_TEMPLATE.md | 38 ++-- Duckuino.js | 120 ++++++------- assets/css/style.css | 4 + assets/js/main.js | 85 +++++---- index.html | 5 - modules/arduino/lib/Keyboard.h | 99 +++++++++++ modules/arduino/lib/Keyboard@1.cpp | 84 +++++++++ modules/arduino/lib/Keyboard@2.cpp | 114 ++++++++++++ modules/arduino/lib/readme | 15 ++ modules/arduino/locales/be.lang | 152 ++++++++++++++++ modules/arduino/locales/cz.lang | 155 +++++++++++++++++ modules/arduino/locales/czqwertz.lang | 155 +++++++++++++++++ modules/arduino/locales/dk.lang | 159 +++++++++++++++++ modules/arduino/locales/es.lang | 159 +++++++++++++++++ modules/arduino/locales/fr.lang | 162 ++++++++++++++++++ modules/arduino/locales/gr.lang | 159 +++++++++++++++++ modules/arduino/locales/it.lang | 158 +++++++++++++++++ modules/arduino/locales/po.lang | 154 +++++++++++++++++ modules/arduino/locales/pobr.lang | 148 ++++++++++++++++ modules/arduino/locales/sample.lang | 157 +++++++++++++++++ modules/arduino/locales/su.lang | 157 +++++++++++++++++ modules/arduino/locales/sv.lang | 160 +++++++++++++++++ modules/arduino/locales/tr.lang | 156 +++++++++++++++++ modules/arduino/locales/uk.lang | 144 ++++++++++++++++ modules/arduino/locales/us.lang | 144 ++++++++++++++++ modules/{Arduino.js => arduino/module.js} | 62 +++---- modules/arduino/module.meta | 106 ++++++++++++ modules/{Digispark.js => digispark/module.js} | 18 +- modules/digispark/module.meta | 6 + modules/modules | 3 - modules/modules.json | 17 ++ .../{MuKeyboard.js => mukeyboard/module.js} | 60 +++---- modules/mukeyboard/module.meta | 6 + readme.default | 2 +- 34 files changed, 3134 insertions(+), 189 deletions(-) create mode 100644 modules/arduino/lib/Keyboard.h create mode 100644 modules/arduino/lib/Keyboard@1.cpp create mode 100644 modules/arduino/lib/Keyboard@2.cpp create mode 100644 modules/arduino/lib/readme create mode 100644 modules/arduino/locales/be.lang create mode 100644 modules/arduino/locales/cz.lang create mode 100644 modules/arduino/locales/czqwertz.lang create mode 100644 modules/arduino/locales/dk.lang create mode 100644 modules/arduino/locales/es.lang create mode 100644 modules/arduino/locales/fr.lang create mode 100644 modules/arduino/locales/gr.lang create mode 100644 modules/arduino/locales/it.lang create mode 100644 modules/arduino/locales/po.lang create mode 100644 modules/arduino/locales/pobr.lang create mode 100644 modules/arduino/locales/sample.lang create mode 100644 modules/arduino/locales/su.lang create mode 100644 modules/arduino/locales/sv.lang create mode 100644 modules/arduino/locales/tr.lang create mode 100644 modules/arduino/locales/uk.lang create mode 100644 modules/arduino/locales/us.lang rename modules/{Arduino.js => arduino/module.js} (91%) create mode 100644 modules/arduino/module.meta rename modules/{Digispark.js => digispark/module.js} (96%) create mode 100644 modules/digispark/module.meta delete mode 100644 modules/modules create mode 100644 modules/modules.json rename modules/{MuKeyboard.js => mukeyboard/module.js} (91%) create mode 100644 modules/mukeyboard/module.meta diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 4afa997..1597371 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,16 +1,30 @@ -*Short introduction to your problem.* + -__Input code:__ -```vb -REM The code your entered in the input text area -``` +Are you using the live version that could be found [here](https://nurrl.github.io/Duckuino/) ? + - [ ] Yes, absolutely + - [ ] No, I might try it out + -__Output code:__ -```arduino -/* The code outputted by the script, 'none' otherwise */ +What type of issue is it ? + - [ ] Graphical issue (UX, UI, Graphical Glitch) + - [ ] Feature issue (Command not/bad implemented, Non functionnal feature) + - [ ] Crash (The buttons clicks does nothing at all, Error in console) + - [ ] Question (Any type about the project :D) + ``` - -__Error:__ -```js -/* Any error outputted by the page or the console, 'none' otherwise */ +Here are relevant errors/infos outputed by the code ! ``` + +_Describe your problem here :D_ diff --git a/Duckuino.js b/Duckuino.js index fc7b703..f63f92b 100644 --- a/Duckuino.js +++ b/Duckuino.js @@ -9,7 +9,8 @@ /* Function to request files */ function getFile(sUrl) { /* Init request */ - var oReq = new XMLHttpRequest(); + let oReq = new XMLHttpRequest(); + //console.log("@<- " + sUrl); /* Sending request */ oReq.open("get", sUrl, false); @@ -24,41 +25,44 @@ function getFile(sUrl) { } } -class Duckuino { - constructor() {} - - listModules() { - /* List all modules in the moduleList file */ - if (!this.moduleArray) { - this.moduleArray = getFile("modules/modules").split('\n'); - this.moduleArray.pop(); - } - - /* Return the list */ - return this.moduleArray; - } - - loadModule(moduleName) { - /* Check if module exists */ - if (this.listModules().indexOf(moduleName) == -1) { - console.error("Error: This module doesn't exist !"); - - /* Module is not loaded */ - this.loadedModule = undefined; - } else { - /* Load module *//* jshint evil:true */ - this.loadedModule = eval(getFile("modules/" + moduleName + ".js")); +class Modules { + constructor() { + /* Load modules *//* jshint evil:true */ + let modules = JSON.parse(getFile("modules/modules.json")); + for (let x in modules) { + let m = modules[x]; + m.meta = JSON.parse(getFile("modules/" + m.path + m.meta)); + m.module = eval(getFile("modules/" + m.path + m.module)); + if (Object.keys(m.meta.locales).length > 0) { + let ls = m.meta.locales; + for (let y in ls) { + let l = ls[y]; + if (y == "_meta") + continue; + l.data = getFile("modules/" + m.path + l.path); + } + ls._meta.header = getFile("modules/" + m.path + ls._meta.header); + for (let y in ls._meta.parts) { + let f = ls._meta.parts[y]; + if (f == "_locale_") + continue; + ls._meta.parts[y] = getFile("modules/" + m.path + f); + } + } } + this.list = modules; } +} - /* TO-DO: getModuleInfos() {} */ +class Duckuino { + constructor() {} - compileCode(compileStr) { + compileCode(compileStr, withModule) { /* Init timer */ - var timerStart = window.performance.now(); + let timerStart = window.performance.now(); /* Check if module loaded */ - if (this.loadedModule === undefined) { + if (withModule === undefined) { return { compiledCode: undefined, compileTime: -1, @@ -92,32 +96,32 @@ class Duckuino { this.dataStorage = new Object(); this.compiledCode = ''; - var commandKnown; - var lineStr; - var lastLine = ''; var lastLineCount = 0; + let commandKnown; + let lineStr; + let lastLine = ''; let lastLineCount = 0; /* Cut the input in lines */ - var lineArray = compileStr.split('\n'); + let lineArray = compileStr.split('\n'); /* Loop every line */ - for (var i = 0; i < lineArray.length; i++) + for (let i = 0; i < lineArray.length; i++) { /* Line empty, skip */ if (lineArray[i] === '' || lineArray[i] === '\n') continue; - /* Reset vars */ + /* Reset lets */ commandKnown = false; lineStr = ''; /* Split lines in words */ - var argList = lineArray[i].split(' '); - var argOne = argList[0]; + let argList = lineArray[i].split(' '); + let argOne = argList[0]; /* Parse commands */ - if (this.loadedModule.functionMap[argOne] !== undefined) { - var µ = new Object({ - keyMap: this.loadedModule.keyMap, + if (withModule.functionMap[argOne] !== undefined) { + let µ = new Object({ + keyMap: withModule.keyMap, /** * Pushes the error to the global error list. */ @@ -136,10 +140,10 @@ class Duckuino { */ trimLast: function(thisPtr, lastLine, lastLineCount) { return function() { - var tmpVar = thisPtr.compiledCode.split('\n'); + let tmplet = thisPtr.compiledCode.split('\n'); - tmpVar.splice(-lastLineCount, lastLineCount - 1); - thisPtr.compiledCode = tmpVar.join('\n'); + tmplet.splice(-lastLineCount, lastLineCount - 1); + thisPtr.compiledCode = tmplet.join('\n'); return lastLine; }; @@ -161,24 +165,24 @@ class Duckuino { }); /* Execute the function and add the returned string to the current string */ - lineStr += this.loadedModule.functionMap[argOne](argList, µ); + lineStr += withModule.functionMap[argOne](argList, µ); /* Post process the line */ - lineStr = this.loadedModule.postLine(lineStr, µ); + lineStr = withModule.postLine(lineStr, µ); } else { /* Parse keystokes */ - var strokeArray = Array(); + let strokeArray = Array(); - for(var y = 0; y < argList.length; y++) { + for(let y = 0; y < argList.length; y++) { - if(this.loadedModule.commandMap[argList[y]] !== undefined) { + if(withModule.commandMap[argList[y]] !== undefined) { /* Push key to Array */ - strokeArray.push(this.loadedModule.commandMap[argList[y]]); - } else if(this.loadedModule.comboMap[argList[y]] !== undefined) { + strokeArray.push(withModule.commandMap[argList[y]]); + } else if(withModule.comboMap[argList[y]] !== undefined) { /* Push key to Array */ - strokeArray.push(this.loadedModule.comboMap[argList[y]]); - } else if(this.loadedModule.keyMap[argList[y]] !== undefined && y != 0) { + strokeArray.push(withModule.comboMap[argList[y]]); + } else if(withModule.keyMap[argList[y]] !== undefined && y != 0) { /* Push key to Array */ - strokeArray.push('"' + this.loadedModule.keyMap[argList[y]] + '"'); + strokeArray.push(withModule.keyMap[argList[y]]); } else { /* If command unknown, throw error */ this.errorList.push({ @@ -189,7 +193,7 @@ class Duckuino { } /* Transform key array to string */ - lineStr += this.loadedModule.computeKeys(strokeArray); + lineStr += withModule.computeKeys(strokeArray); } /* Calculate line count */ @@ -201,8 +205,8 @@ class Duckuino { } /* Stop timer */ - var timerEnd = window.performance.now(); - var timeElapsed = (timerEnd - timerStart).toFixed(2); + let timerEnd = window.performance.now(); + let timeElapsed = (timerEnd - timerStart).toFixed(2); /* Return error if error and code if not */ if (this.errorList.length > 0) { @@ -213,7 +217,7 @@ class Duckuino { returnCode: 1, returnMessage: function(errorList) { - var errorString; + let errorString; if(errorList.length > 1) { errorString = "The compiler returned some errors:\n"; @@ -232,7 +236,7 @@ class Duckuino { } else { /* Return the compiled code */ return { - compiledCode: this.loadedModule.getFinalCode(this.compiledCode), + compiledCode: withModule.getFinalCode(this.compiledCode), compileTime: timeElapsed, returnCode: 0, diff --git a/assets/css/style.css b/assets/css/style.css index 7198794..0124fc3 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -213,6 +213,10 @@ button:disabled { width: 16px; height: 32px; } +.combined-but > select option { + /* Style */ + color: black; +} .combined-but > select:disabled { /* Postion */ opacity: .5; diff --git a/assets/js/main.js b/assets/js/main.js index 505974a..a6e729f 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,12 +1,12 @@ $(function() { /* Wait for jQuery */ - /* Init vars */ - var isCodeCompiled = false; - var LocKey = new LocaleKeyboard(); - var Duck = new Duckuino(); + /* Init lets */ + let isCodeCompiled = false; + let Duck = new Duckuino(); + let mods = new Modules().list; try { - var isFileSaverSupported = !!new Blob(); + let isFileSaverSupported = !!new Blob(); } catch (e) {} /* Compile button enable/disable */ @@ -20,14 +20,19 @@ $(function() { /* Wait for jQuery */ } }); + /* Reset buttons */ + $(".copy-but").prop("disabled", true); + $(".export .copy-but").text("Copy !"); + $(".dl-but button").prop("disabled", true); + $(".dl-but select").prop("disabled", true); + /* Compile button click */ $(".process-but button").click(function() { - var duckyScript = $(".input > textarea").val(); - var selectedModule = $(".process-but select").find(":selected").text(); + let duckyScript = $(".input > textarea").val(); + let selectedModule = mods[$(".process-but select").find(":selected").val()]; /* Load Duckuino & Compile */ - Duck.loadModule(selectedModule); - var compilerOut = Duck.compileCode(duckyScript); + let compilerOut = Duck.compileCode(duckyScript, selectedModule.module); /* Check for error */ if(compilerOut.returnCode === 0) { @@ -35,11 +40,23 @@ $(function() { /* Wait for jQuery */ $(".export > textarea").val(compilerOut.compiledCode); /* Enable buttons */ - $(".dl-but button").prop("disabled", false); - $(".dl-but select").prop("disabled", false); $(".copy-but").prop("disabled", false); $(".export .copy-but").text("Copy !"); + /* Reset & (Re)Populate locales */ + $(".dl-but select").empty(); + $(".dl-but button").prop("disabled", true); + $(".dl-but select").prop("disabled", true); + for (let y in selectedModule.meta.locales) { + let l = selectedModule.meta.locales[y]; + if (y == "_meta") + continue; + $(".dl-but select").append(""); + /* Enable button only if there is one locale */ + $(".dl-but button").prop("disabled", false); + $(".dl-but select").prop("disabled", false); + } + /* Show compilation infos */ $(".process .tooltip > span").text(compilerOut.returnMessage); $(".process .tooltip").removeClass("error"); $(".process .tooltip").addClass("info"); @@ -57,22 +74,19 @@ $(function() { /* Wait for jQuery */ } }); - /* List locales */ - LocKey.listLocales().forEach(function (localeName) { - $(".dl-but select").append(""); - }); - /* List modules */ - Duck.listModules().forEach(function (moduleName) { - $(".process-but select").append(""); - }); + for (let x in mods) { + let m = mods[x]; + $(".process-but select") + .append(""); + } /* Download button */ $(".dl-but button").click(function() { - var compilerOut = $(".export > textarea").val(); + let compilerOut = $(".export > textarea").val(); - var sketchName = "Sketch"; - var zipHandler = new JSZip(); + let sketchName = "Sketch"; + let zipHandler = new JSZip(); // Add the payload as .ino zipHandler.file(sketchName + "/" + sketchName + ".ino", compilerOut); @@ -85,16 +99,25 @@ $(function() { /* Wait for jQuery */ success: function(data) {return data;} })); - // Add custom version of Keyboard lib if needed - if ($(".export-but select").find(":selected").text() !== "en_US") { - // Set the locale - LocKey.setLocale($(".dl-but select").find(":selected").text()); - - // Append all to the zip - zipHandler.file(sketchName + "/Keyboard.cpp", LocKey.getSource()); - zipHandler.file(sketchName + "/Keyboard.h", LocKey.getHeader()); + // Craft the lib + let lib = ""; + let selectedModule = mods[$(".process-but select").find(":selected").val()]; + let selectedLocale = selectedModule.meta.locales[$(".dl-but select").find(":selected").val()]; + for (let x in selectedModule.meta.locales._meta.parts) { + let p = selectedModule.meta.locales._meta.parts[x]; + if (p == '_locale_') + lib += selectedLocale.data; + else + lib += p; } + // Append all to the zip + zipHandler.file( + sketchName + "/" + selectedModule.meta.locales._meta.name + ".cpp", lib); + zipHandler.file( + sketchName + "/" + selectedModule.meta.locales._meta.name + ".h", + selectedModule.meta.locales._meta.header); + // Download zipHandler.generateAsync({type:"blob"}) .then(function(content) { @@ -105,7 +128,7 @@ $(function() { /* Wait for jQuery */ /* Copy to clipboard button */ $(".copy-but").click(function() { - var copyTextarea = $(".export > textarea"); + let copyTextarea = $(".export > textarea"); copyTextarea.select(); try { diff --git a/index.html b/index.html index 5fbb4e8..50fd1a6 100644 --- a/index.html +++ b/index.html @@ -57,16 +57,11 @@

Option 2: Copy/Paste

- - - - - diff --git a/modules/arduino/lib/Keyboard.h b/modules/arduino/lib/Keyboard.h new file mode 100644 index 0000000..8f173f3 --- /dev/null +++ b/modules/arduino/lib/Keyboard.h @@ -0,0 +1,99 @@ +/* + Keyboard.h + + Copyright (c) 2015, Arduino LLC + Original code (pre-library): Copyright (c) 2011, Peter Barrett + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef KEYBOARD_h +#define KEYBOARD_h + +#include "HID.h" + +#if !defined(_USING_HID) + +#warning "Using legacy HID core (non pluggable)" + +#else + +//================================================================================ +//================================================================================ +// Keyboard + +#define KEY_LEFT_CTRL 0x80 +#define KEY_LEFT_SHIFT 0x81 +#define KEY_LEFT_ALT 0x82 +#define KEY_LEFT_GUI 0x83 +#define KEY_RIGHT_CTRL 0x84 +#define KEY_RIGHT_SHIFT 0x85 +#define KEY_RIGHT_ALT 0x86 +#define KEY_RIGHT_GUI 0x87 + +#define KEY_UP_ARROW 0xDA +#define KEY_DOWN_ARROW 0xD9 +#define KEY_LEFT_ARROW 0xD8 +#define KEY_RIGHT_ARROW 0xD7 +#define KEY_BACKSPACE 0xB2 +#define KEY_TAB 0xB3 +#define KEY_RETURN 0xB0 +#define KEY_ESC 0xB1 +#define KEY_INSERT 0xD1 +#define KEY_DELETE 0xD4 +#define KEY_PAGE_UP 0xD3 +#define KEY_PAGE_DOWN 0xD6 +#define KEY_HOME 0xD2 +#define KEY_END 0xD5 +#define KEY_CAPS_LOCK 0xC1 +#define KEY_F1 0xC2 +#define KEY_F2 0xC3 +#define KEY_F3 0xC4 +#define KEY_F4 0xC5 +#define KEY_F5 0xC6 +#define KEY_F6 0xC7 +#define KEY_F7 0xC8 +#define KEY_F8 0xC9 +#define KEY_F9 0xCA +#define KEY_F10 0xCB +#define KEY_F11 0xCC +#define KEY_F12 0xCD + +// Low level key report: up to 6 keys and shift, ctrl etc at once +typedef struct +{ + uint8_t modifiers; + uint8_t reserved; + uint8_t keys[6]; +} KeyReport; + +class Keyboard_ : public Print +{ +private: + KeyReport _keyReport; + void sendReport(KeyReport* keys); +public: + Keyboard_(void); + void begin(void); + void end(void); + size_t write(uint8_t k); + size_t press(uint8_t k); + size_t release(uint8_t k); + void releaseAll(void); +}; +extern Keyboard_ Keyboard; + +#endif +#endif diff --git a/modules/arduino/lib/Keyboard@1.cpp b/modules/arduino/lib/Keyboard@1.cpp new file mode 100644 index 0000000..7af95b5 --- /dev/null +++ b/modules/arduino/lib/Keyboard@1.cpp @@ -0,0 +1,84 @@ +/* + Keyboard.cpp + + Copyright (c) 2015, Arduino LLC + Original code (pre-library): Copyright (c) 2011, Peter Barrett + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Keyboard.h" + +#if defined(_USING_HID) + +//================================================================================ +//================================================================================ +// Keyboard + +static const uint8_t _hidReportDescriptor[] PROGMEM = { + + // Keyboard + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 + 0x09, 0x06, // USAGE (Keyboard) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, 0x02, // REPORT_ID (2) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + + 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) + 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + + 0x95, 0x08, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x01, // REPORT_COUNT (1) + 0x75, 0x08, // REPORT_SIZE (8) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) + + 0x95, 0x06, // REPORT_COUNT (6) + 0x75, 0x08, // REPORT_SIZE (8) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x81, 0x00, // INPUT (Data,Ary,Abs) + 0xc0, // END_COLLECTION +}; + +Keyboard_::Keyboard_(void) +{ + static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor)); + HID().AppendDescriptor(&node); +} + +void Keyboard_::begin(void) +{ +} + +void Keyboard_::end(void) +{ +} + +void Keyboard_::sendReport(KeyReport* keys) +{ + HID().SendReport(2,keys,sizeof(KeyReport)); +} + +extern +const uint8_t _asciimap[128] PROGMEM; +/*- ---Start of generated lib--- -*/ diff --git a/modules/arduino/lib/Keyboard@2.cpp b/modules/arduino/lib/Keyboard@2.cpp new file mode 100644 index 0000000..d9f5ee1 --- /dev/null +++ b/modules/arduino/lib/Keyboard@2.cpp @@ -0,0 +1,114 @@ +/*- ---End of generated lib--- -*/ +uint8_t USBPutChar(uint8_t c); + +// press() adds the specified key (printing, non-printing, or modifier) +// to the persistent key report and sends the report. Because of the way +// USB HID works, the host acts like the key remains pressed until we +// call release(), releaseAll(), or otherwise clear the report and resend. +size_t Keyboard_::press(uint8_t k) +{ + uint8_t i; + if (k >= 136) { // it's a non-printing key (not a modifier) + k = k - 136; + } else if (k >= 128) { // it's a modifier key + _keyReport.modifiers |= (1<<(k-128)); + k = 0; + } else { // it's a printing key + int oldKey = k; + k = pgm_read_byte(_asciimap + k); + if (!k) { + setWriteError(); + return 0; + } + if (k & 0x80) { // it's a capital letter or other character reached with shift + _keyReport.modifiers |= 0x02; // the left shift modifier + k &= 0x7F; + } + + if (!_altFine) + initAltGr(); + if (_altGrMap[oldKey]) + _keyReport.modifiers |= 0x40; + } + + // Add k to the key report only if it's not already present + // and if there is an empty slot. + if (_keyReport.keys[0] != k && _keyReport.keys[1] != k && + _keyReport.keys[2] != k && _keyReport.keys[3] != k && + _keyReport.keys[4] != k && _keyReport.keys[5] != k) { + + for (i=0; i<6; i++) { + if (_keyReport.keys[i] == 0x00) { + _keyReport.keys[i] = k; + break; + } + } + if (i == 6) { + setWriteError(); + return 0; + } + } + sendReport(&_keyReport); + return 1; +} + +// release() takes the specified key out of the persistent key report and +// sends the report. This tells the OS the key is no longer pressed and that +// it shouldn't be repeated any more. +size_t Keyboard_::release(uint8_t k) +{ + uint8_t i; + if (k >= 136) { // it's a non-printing key (not a modifier) + k = k - 136; + } else if (k >= 128) { // it's a modifier key + _keyReport.modifiers &= ~(1<<(k-128)); + k = 0; + } else { // it's a printing key + int oldKey = k; + k = pgm_read_byte(_asciimap + k); + if (!k) { + return 0; + } + if (k & 0x80) { // it's a capital letter or other character reached with shift + _keyReport.modifiers &= ~(0x02); // the left shift modifier + k &= 0x7F; + } + + if (_altGrMap[oldKey]) + _keyReport.modifiers &= ~(0x40); + } + + // Test the key report to see if k is present. Clear it if it exists. + // Check all positions in case the key is present more than once (which it shouldn't be) + for (i=0; i<6; i++) { + if (0 != k && _keyReport.keys[i] == k) { + _keyReport.keys[i] = 0x00; + } + } + + sendReport(&_keyReport); + return 1; +} + +void Keyboard_::releaseAll(void) +{ + _keyReport.keys[0] = 0; + _keyReport.keys[1] = 0; + _keyReport.keys[2] = 0; + _keyReport.keys[3] = 0; + _keyReport.keys[4] = 0; + _keyReport.keys[5] = 0; + _keyReport.modifiers = 0; + sendReport(&_keyReport); +} + +size_t Keyboard_::write(uint8_t c) +{ + uint8_t p = press(c); // Keydown + release(c); // Keyup + return p; // just return the result of press() since release() almost always returns 1 +} + +Keyboard_ Keyboard; + +#endif diff --git a/modules/arduino/lib/readme b/modules/arduino/lib/readme new file mode 100644 index 0000000..45b02ed --- /dev/null +++ b/modules/arduino/lib/readme @@ -0,0 +1,15 @@ +Copyright (c) Arduino LLC. All right reserved. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/modules/arduino/locales/be.lang b/modules/arduino/locales/be.lang new file mode 100644 index 0000000..9dbb3a2 --- /dev/null +++ b/modules/arduino/locales/be.lang @@ -0,0 +1,152 @@ +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + 0x2c, // ' ' + 0x25, // ! + 0x20, // " + 0x20, // # + 0x30, // $ + 0x34|SHIFT, // % + 0x1e, // & + 0x21, // ' + 0x22, // ( + 0x2d, // ) + 0x30|SHIFT, // * + 0x38|SHIFT, // + + 0x10, // , + 0x2e, // - + 0x36|SHIFT, // . + 0x37|SHIFT, // / + 0x27|SHIFT, // 0 + 0x1e|SHIFT, // 1 + 0x1f|SHIFT, // 2 + 0x20|SHIFT, // 3 + 0x21|SHIFT, // 4 + 0x22|SHIFT, // 5 + 0x23|SHIFT, // 6 + 0x24|SHIFT, // 7 + 0x25|SHIFT, // 8 + 0x26|SHIFT, // 9 + 0x37, // : + 0x36, // ; + 0x64, // < + 0x38, // = + 0x64|SHIFT, // > + 0x10|SHIFT, // ? + 0x27, // @ + 0x14|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x33|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x04|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1d|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1a|SHIFT, // Z + 0x22, // [ + 0x64, // bslash + 0x30, // ] + 0x22, // ^ + 0x2e|SHIFT, // _ + 0x24, // ` + 0x14, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x33, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x04, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1d, // w + 0x1b, // x + 0x1c, // y + 0x1a, // z + 0x21, // { + 0x1e, // | + 0x27, // } + 0x38, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[35] = true; // # + _altGrMap[64] = true; // @ + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash fixed + _altGrMap[93] = true; // ] + _altGrMap[96] = true; // ` + _altGrMap[123] = true; // { + _altGrMap[124] = true; // | fixed + _altGrMap[125] = true; // } fixed + _altGrMap[127] = true; // ~ +} diff --git a/modules/arduino/locales/cz.lang b/modules/arduino/locales/cz.lang new file mode 100644 index 0000000..ed8b6a8 --- /dev/null +++ b/modules/arduino/locales/cz.lang @@ -0,0 +1,155 @@ +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL 0 + 0x00, // SOH 1 + 0x00, // STX 2 + 0x00, // ETX 3 + 0x00, // EOT 4 + 0x00, // ENQ 5 + 0x00, // ACK 6 + 0x00, // BEL 7 + 0x2a, // BS 8 + 0x2b, // TAB 9 + 0x28, // LF 10 + 0x00, // VT 11 + 0x00, // FF 12 + 0x00, // CR 13 + 0x00, // SO 14 + 0x00, // SI 15 + 0x00, // DEL 16 + 0x00, // DC1 17 + 0x00, // DC2 18 + 0x00, // DC3 19 + 0x00, // DC4 20 + 0x00, // NAK 21 + 0x00, // SYN 22 + 0x00, // ETB 23 + 0x00, // CAN 24 + 0x00, // EM 25 + 0x00, // SUB 26 + 0x00, // ESC 27 + 0x00, // FS 28 + 0x00, // GS 29 + 0x00, // RS 30 + 0x00, // US 31 + 0x2c, // ' ' 32 + 0x34 | SHIFT, // ! 33 + 0x33 | SHIFT, // " 34 + 0x20, // # 35 + AltGr + 0x21, // $ 36 + AltGr + 0x2d | SHIFT, // % 37 + 0x24, // & 38 + AltGr + 0x31 | SHIFT, // ' 39 + 0x30 | SHIFT, // ( 40 + 0x30, // ) 41 + 0x25, // * 42 + AltGr + 0x1e, // + 43 + 0x36, // , 44 + 0x38, // - 45 + 0x37, // . 46 + 0x2f | SHIFT, // / 47 + 0x27 | SHIFT, // 0 48 + 0x1e | SHIFT, // 1 49 + 0x1f | SHIFT, // 2 50 + 0x20 | SHIFT, // 3 51 + 0x21 | SHIFT, // 4 52 + 0x22 | SHIFT, // 5 53 + 0x23 | SHIFT, // 6 54 + 0x24 | SHIFT, // 7 55 + 0x25 | SHIFT, // 8 56 + 0x26 | SHIFT, // 9 57 + 0x37 | SHIFT, // : 58 + 0x35, // ; 59 + 0x36, // < 60 + AltGr + 0x2d, // = 61 + 0x37, // > 62 + AltGr + 0x36 | SHIFT, // ? 63 + 0x1f, // @ 64 + AltGr + 0x04 | SHIFT, // A 65 + 0x05 | SHIFT, // B 66 + 0x06 | SHIFT, // C 67 + 0x07 | SHIFT, // D 68 + 0x08 | SHIFT, // E 69 + 0x09 | SHIFT, // F 70 + 0x0a | SHIFT, // G 71 + 0x0b | SHIFT, // H 72 + 0x0c | SHIFT, // I 73 + 0x0d | SHIFT, // J 74 + 0x0e | SHIFT, // K 75 + 0x0f | SHIFT, // L 76 + 0x10 | SHIFT, // M 77 + 0x11 | SHIFT, // N 78 + 0x12 | SHIFT, // O 79 + 0x13 | SHIFT, // P 80 + 0x14 | SHIFT, // Q 81 + 0x15 | SHIFT, // R 82 + 0x16 | SHIFT, // S 83 + 0x17 | SHIFT, // T 84 + 0x18 | SHIFT, // U 85 + 0x19 | SHIFT, // V 86 + 0x1a | SHIFT, // W 87 + 0x1b | SHIFT, // X 88 + 0x1c | SHIFT, // Y 89 + 0x1d | SHIFT, // Z 90 + 0x2f, // [ 91 + AltGr + 0x31, // bsl 92 + AltGr + 0x30, // ] 93 + AltGr + 0x23, // ^ 94 + AltGr + 0x38 | SHIFT, // _ 95 + 0x35, // ` 96 + AltGr + 0x04, // a 97 + 0x05, // b 98 + 0x06, // c 99 + 0x07, // d 100 + 0x08, // e 101 + 0x09, // f 102 + 0x0a, // g 103 + 0x0b, // h 104 + 0x0c, // i 105 + 0x0d, // j 106 + 0x0e, // k 107 + 0x0f, // l 108 + 0x10, // m 109 + 0x11, // n 110 + 0x12, // o 111 + 0x13, // p 112 + 0x14, // q 113 + 0x15, // r 114 + 0x16, // s 115 + 0x17, // t 116 + 0x18, // u 117 + 0x19, // v 118 + 0x1a, // w 119 + 0x1b, // x 120 + 0x1c, // y 121 + 0x1d, // z 122 + 0x2f | SHIFT, // { 123 + AltGr + 0x31 | SHIFT, // | 124 + AltGr + 0x30 | SHIFT, // } 125 + AltGr + 0x35 | SHIFT, // ~ 126 + AltGr + 0x00 // DEL 127 +}; +bool _altGrMap[128]; +bool _altFine = false; + +void initAltGr() { + _altFine = true; + + _altGrMap[35] = true; + _altGrMap[36] = true; + _altGrMap[38] = true; + _altGrMap[42] = true; + _altGrMap[60] = true; + _altGrMap[62] = true; + _altGrMap[64] = true; + _altGrMap[91] = true; + _altGrMap[92] = true; + _altGrMap[93] = true; + _altGrMap[94] = true; + _altGrMap[96] = true; + _altGrMap[123] = true; + _altGrMap[124] = true; + _altGrMap[125] = true; + _altGrMap[126] = true; +} diff --git a/modules/arduino/locales/czqwertz.lang b/modules/arduino/locales/czqwertz.lang new file mode 100644 index 0000000..1d5e506 --- /dev/null +++ b/modules/arduino/locales/czqwertz.lang @@ -0,0 +1,155 @@ +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL 0 + 0x00, // SOH 1 + 0x00, // STX 2 + 0x00, // ETX 3 + 0x00, // EOT 4 + 0x00, // ENQ 5 + 0x00, // ACK 6 + 0x00, // BEL 7 + 0x2a, // BS 8 + 0x2b, // TAB 9 + 0x28, // LF 10 + 0x00, // VT 11 + 0x00, // FF 12 + 0x00, // CR 13 + 0x00, // SO 14 + 0x00, // SI 15 + 0x00, // DEL 16 + 0x00, // DC1 17 + 0x00, // DC2 18 + 0x00, // DC3 19 + 0x00, // DC4 20 + 0x00, // NAK 21 + 0x00, // SYN 22 + 0x00, // ETB 23 + 0x00, // CAN 24 + 0x00, // EM 25 + 0x00, // SUB 26 + 0x00, // ESC 27 + 0x00, // FS 28 + 0x00, // GS 29 + 0x00, // RS 30 + 0x00, // US 31 + 0x2c, // ' ' 32 + 0x34 | SHIFT, // ! 33 + 0x33 | SHIFT, // " 34 + 0x1b, // # 35 + AltGr + 0x33, // $ 36 + AltGr + 0x2d | SHIFT, // % 37 + 0x06, // & 38 + AltGr + 0x31 | SHIFT, // ' 39 + 0x30 | SHIFT, // ( 40 + 0x30, // ) 41 + 0x38, // * 42 + AltGr + 0x1e, // + 43 + 0x36, // , 44 + 0x38, // - 45 + 0x37, // . 46 + 0x2f | SHIFT, // / 47 + 0x27 | SHIFT, // 0 48 + 0x1e | SHIFT, // 1 49 + 0x1f | SHIFT, // 2 50 + 0x20 | SHIFT, // 3 51 + 0x21 | SHIFT, // 4 52 + 0x22 | SHIFT, // 5 53 + 0x23 | SHIFT, // 6 54 + 0x24 | SHIFT, // 7 55 + 0x25 | SHIFT, // 8 56 + 0x26 | SHIFT, // 9 57 + 0x37 | SHIFT, // : 58 + 0x35, // ; 59 + 0x36, // < 60 + AltGr + 0x2d, // = 61 + 0x37, // > 62 + AltGr + 0x36 | SHIFT, // ? 63 + 0x19, // @ 64 + AltGr + 0x04 | SHIFT, // A 65 + 0x05 | SHIFT, // B 66 + 0x06 | SHIFT, // C 67 + 0x07 | SHIFT, // D 68 + 0x08 | SHIFT, // E 69 + 0x09 | SHIFT, // F 70 + 0x0a | SHIFT, // G 71 + 0x0b | SHIFT, // H 72 + 0x0c | SHIFT, // I 73 + 0x0d | SHIFT, // J 74 + 0x0e | SHIFT, // K 75 + 0x0f | SHIFT, // L 76 + 0x10 | SHIFT, // M 77 + 0x11 | SHIFT, // N 78 + 0x12 | SHIFT, // O 79 + 0x13 | SHIFT, // P 80 + 0x14 | SHIFT, // Q 81 + 0x15 | SHIFT, // R 82 + 0x16 | SHIFT, // S 83 + 0x17 | SHIFT, // T 84 + 0x18 | SHIFT, // U 85 + 0x19 | SHIFT, // V 86 + 0x1a | SHIFT, // W 87 + 0x1b | SHIFT, // X 88 + 0x1d | SHIFT, // Y 89 + 0x1c | SHIFT, // Z 90 + 0x09, // [ 91 + AltGr + 0x14, // bsl 92 + AltGr + 0x0a, // ] 93 + AltGr + 0x20, // ^ 94 + AltGr + 0x38 | SHIFT, // _ 95 + 0x24, // ` 96 + AltGr + 0x04, // a 97 + 0x05, // b 98 + 0x06, // c 99 + 0x07, // d 100 + 0x08, // e 101 + 0x09, // f 102 + 0x0a, // g 103 + 0x0b, // h 104 + 0x0c, // i 105 + 0x0d, // j 106 + 0x0e, // k 107 + 0x0f, // l 108 + 0x10, // m 109 + 0x11, // n 110 + 0x12, // o 111 + 0x13, // p 112 + 0x14, // q 113 + 0x15, // r 114 + 0x16, // s 115 + 0x17, // t 116 + 0x18, // u 117 + 0x19, // v 118 + 0x1a, // w 119 + 0x1b, // x 120 + 0x1d, // y 121 + 0x1c, // z 122 + 0x05, // { 123 + AltGr + 0x1a, // | 124 + AltGr + 0x11, // } 125 + AltGr + 0x1e, // ~ 126 + AltGr + 0x00 // DEL 127 +}; +bool _altGrMap[128]; +bool _altFine = false; + +void initAltGr() { + _altFine = true; + + _altGrMap[35] = true; + _altGrMap[36] = true; + _altGrMap[38] = true; + _altGrMap[42] = true; + _altGrMap[60] = true; + _altGrMap[62] = true; + _altGrMap[64] = true; + _altGrMap[91] = true; + _altGrMap[92] = true; + _altGrMap[93] = true; + _altGrMap[94] = true; + _altGrMap[96] = true; + _altGrMap[123] = true; + _altGrMap[124] = true; + _altGrMap[125] = true; + _altGrMap[126] = true; +} diff --git a/modules/arduino/locales/dk.lang b/modules/arduino/locales/dk.lang new file mode 100644 index 0000000..b0c599c --- /dev/null +++ b/modules/arduino/locales/dk.lang @@ -0,0 +1,159 @@ +/* + * Due to how the danish keyboard works some characters (~, ^, `) have to be pressed twice, on ubuntu two presses creates one character, on windows one press creates no charater and two presses creates two. + * + * This means that the required test string is "!\"#$%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^^``_abcdefghijklmnopqrstuvwxyz{|}~~ @" + * Note that the two backslashes are just escaping the backslash. Backslashes don't have to be pressed twice on danish keyboards. + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x20|SHIFT, // # + 0x21, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x31, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x31|SHIFT, // * + 0x2d, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x1f, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x25, // [ + 0x64, // bslash + 0x26, // ] + 0x30|SHIFT, // ^ + 0x38|SHIFT, // _ + 0x2e|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x24, // { + 0x2e, // | + 0x27, // } + 0x30, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[36] = true; // $ + _altGrMap[64] = true; // @ + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash + _altGrMap[93] = true; // ] + _altGrMap[123] = true; // { + _altGrMap[124] = true; // | + _altGrMap[125] = true; // } + _altGrMap[126] = true; // ~ +} diff --git a/modules/arduino/locales/es.lang b/modules/arduino/locales/es.lang new file mode 100644 index 0000000..848bd80 --- /dev/null +++ b/modules/arduino/locales/es.lang @@ -0,0 +1,159 @@ +/* + * _asciimap took from Keyboard.cpp, + * Updated by Borja Garduño with the correct keys, + * and ~, ^ and `, fixed by BlueArduino20. + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x20, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x2d, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x30|SHIFT, // * + 0x30, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x1f, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x35, // bslash + 0x30, // ] + 0x2f|SHIFT, // ^ + 0x38|SHIFT, // _ + 0x2f, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x34, // { + 0x1e, // | + 0x32, // } + 0x21, // ^ + 0 // DEL + +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[126] = true; // ~ + _altGrMap[123] = true; // { + _altGrMap[91] = true; // [ + _altGrMap[93] = true; // ] + _altGrMap[125] = true; // } + _altGrMap[92] = true; // bslash + _altGrMap[124] = true; // | + _altGrMap[64] = true; // @ + _altGrMap[35] = true; // # +} diff --git a/modules/arduino/locales/fr.lang b/modules/arduino/locales/fr.lang new file mode 100644 index 0000000..58f6981 --- /dev/null +++ b/modules/arduino/locales/fr.lang @@ -0,0 +1,162 @@ +/* + * _asciimap took from internet, fixed by Thecakeisgit + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x38, // ! + 0x20, // " + 0x20, // # + 0x30, // $ + 0x34|SHIFT, // % + 0x1e, // & + 0x21, // ' + 0x22, // ( + 0x2d, // ) + 0x31, // * + 0x2e|SHIFT, // + + 0x10, // , + 0x23, // - + 0x36|SHIFT, // . + 0x37|SHIFT, // / + 0x27|SHIFT, // 0 + 0x1e|SHIFT, // 1 + 0x1f|SHIFT, // 2 + 0x20|SHIFT, // 3 + 0x21|SHIFT, // 4 + 0x22|SHIFT, // 5 + 0x23|SHIFT, // 6 + 0x24|SHIFT, // 7 + 0x25|SHIFT, // 8 + 0x26|SHIFT, // 9 + 0x37, // : + 0x36, // ; + 0x64, // < + 0x2e, // = + 0x64|SHIFT, // > + 0x10|SHIFT, // ? + 0x27, // @ + 0x14|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x33|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x04|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1d|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1a|SHIFT, // Z + 0x22, // [ + 0x25, // bslash + 0x2d, // ] + 0x26, // ^ + 0x25, // _ + 0x24, // ` + 0x14, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x33, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x04, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1d, // w + 0x1b, // x + 0x1c, // y + 0x1a, // z + 0x21, // { + 0x23, // | + 0x2e, // } + 0x1f, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[35] = true; // # + _altGrMap[64] = true; // @ + + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash + _altGrMap[93] = true; // ] + _altGrMap[94] = true; // ^ + + _altGrMap[96] = true; // ` + + _altGrMap[123] = true; // { + _altGrMap[124] = true; // | + _altGrMap[125] = true; // } + _altGrMap[126] = true; // ~ +} + diff --git a/modules/arduino/locales/gr.lang b/modules/arduino/locales/gr.lang new file mode 100644 index 0000000..0c970f1 --- /dev/null +++ b/modules/arduino/locales/gr.lang @@ -0,0 +1,159 @@ +/* +* The following character can't be typed: +* "ß´üöä°§ÜÖIJ³€µ" +* If you try to type these you get this result: ('"' can be typed) +* "t ä´z qk 2 " +* As you see you get the wrong character. Spaces mean you get nothing or the script crashes. +*/ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL 0 + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter 10 + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 20 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS 30 + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x31, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x31|SHIFT, // ' + 0x25|SHIFT, // ( 40 + 0x26|SHIFT, // ) + 0x30|SHIFT, // * + 0x30, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 50 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < 60 + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x14, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F 70 + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P 80 + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1d|SHIFT, // Y + 0x1c|SHIFT, // Z 90 + 0x25, // [ + 0x2d, // bslash + 0x26, // ] + 0x35, // ^ + 0x38|SHIFT, // _ + 0x2e|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d 100 + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n 110 + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x 120 + 0x1d, // y + 0x1c, // z + 0x24, // { + 0x64, // | + 0x27, // } + 0x30, // ~ + 0 // DEL 127 +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[126] = true; // ~ + _altGrMap[123] = true; // { + _altGrMap[91] = true; // [ + _altGrMap[93] = true; // ] + _altGrMap[125] = true; // } + _altGrMap[92] = true; // bslash + _altGrMap[124] = true; // | + _altGrMap[64] = true; // | + } diff --git a/modules/arduino/locales/it.lang b/modules/arduino/locales/it.lang new file mode 100644 index 0000000..863aada --- /dev/null +++ b/modules/arduino/locales/it.lang @@ -0,0 +1,158 @@ +/* +* The following character can't be typed: +* "èéòçà°ù§ì£5€`~" +* As you see you get the wrong character. Spaces mean you get nothing or the script crashes. +*/ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x34, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x2d, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x30|SHIFT, // * + 0x30, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x33, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x35, // bslash + 0x30, // ] + 0x2e|SHIFT, // ^ + 0x38|SHIFT, // _ + 0x39, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f|SHIFT, // { + 0x35|SHIFT, // | + 0x30|SHIFT, // } + 0x34, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[35] = true; // # + _altGrMap[64] = true; // @ + + _altGrMap[91] = true; // [ + _altGrMap[93] = true; // ] + + _altGrMap[123] = true; // { + _altGrMap[125] = true; // } + _altGrMap[126] = true; // ~ +} diff --git a/modules/arduino/locales/po.lang b/modules/arduino/locales/po.lang new file mode 100644 index 0000000..691a229 --- /dev/null +++ b/modules/arduino/locales/po.lang @@ -0,0 +1,154 @@ +/* + * _asciimap took from Keyboard.cpp, + * Updated by brigadinhos with the correct keys for pt_PT keyboard + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x20|SHIFT, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x2d, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x2f|SHIFT, // * + 0x2f, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x1f, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x25, // [ + 0x35, // bslash + 0x26, // ] + 0x31|SHIFT, // ^ + 0x38|SHIFT, // _ + 0x30|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x24, // { + 0x35|SHIFT, // | + 0x27, // } + 0x31, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[91] = true; // [ + _altGrMap[93] = true; // ] + + _altGrMap[123] = true; // { + _altGrMap[125] = true; // } + + _altGrMap[64] = true; // @ +} diff --git a/modules/arduino/locales/pobr.lang b/modules/arduino/locales/pobr.lang new file mode 100644 index 0000000..92c90ca --- /dev/null +++ b/modules/arduino/locales/pobr.lang @@ -0,0 +1,148 @@ +/* + * _asciimap took from Keyboard.cpp, + * Updated by diegochaves with the correct keys for pt_BR keyboard + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x35|SHIFT, // " + 0x20|SHIFT, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x24|SHIFT, // & + 0x35, // ' + 0x26|SHIFT, // ( + 0x27|SHIFT, // ) + 0x25|SHIFT, // * + 0x2e|SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x14, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x38|SHIFT, // : + 0x38, // ; + 0x36|SHIFT, // < + 0x2e, // = + 0x37|SHIFT, // > + 0x1a, // ? + 0x1f|SHIFT, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x30, // [ + 0x30, // bslash + 0x31, // ] + 0x34|SHIFT, // ^ + 0x2d|SHIFT, // _ + 0x2f|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x30|SHIFT, // { + 0x2f|SHIFT, // | + 0x31|SHIFT, // } + 0x34, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + _altGrMap[47] = true; // / + _altGrMap[63] = true; // ? +} \ No newline at end of file diff --git a/modules/arduino/locales/sample.lang b/modules/arduino/locales/sample.lang new file mode 100644 index 0000000..50acc35 --- /dev/null +++ b/modules/arduino/locales/sample.lang @@ -0,0 +1,157 @@ +/* + * This is the sample _asciimap that you need to modify + * to make it work with your locale. + * This file is organized in 2 modifiable parts : + * - The _asciimap var. + * - The initAltGr() function (with the _altGrMap var). + * + * The modification are made on the _asciimap to fit with + * the commented char when tested, and _altGrMap is optional, + * you need to use it only if this is needed by you keyMap. + * + * Example : to make '@' you need to do 'AltGR' + '0', so + * you add _altGrMap[n] = true; in function intAltGr(), where + * n is the rank of the key (in this case the key is '0' so + * n=64). + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x34|SHIFT, // " + 0x20|SHIFT, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x24|SHIFT, // & + 0x34, // ' + 0x26|SHIFT, // ( + 0x27|SHIFT, // ) + 0x25|SHIFT, // * + 0x2e|SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x38, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x33|SHIFT, // : + 0x33, // ; + 0x36|SHIFT, // < + 0x2e, // = + 0x37|SHIFT, // > + 0x38|SHIFT, // ? + 0x1f|SHIFT, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x31, // bslash + 0x30, // ] + 0x23|SHIFT, // ^ + 0x2d|SHIFT, // _ + 0x35, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f|SHIFT, // { + 0x31|SHIFT, // | + 0x30|SHIFT, // } + 0x35|SHIFT, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() {_altFine = true;} diff --git a/modules/arduino/locales/su.lang b/modules/arduino/locales/su.lang new file mode 100644 index 0000000..54836c7 --- /dev/null +++ b/modules/arduino/locales/su.lang @@ -0,0 +1,157 @@ +/* + * Characters produced by dead keys (^ ~ `) do not work + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x20|SHIFT, // # + 0x21, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x31, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x31|SHIFT, // * + 0x2d, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x1f, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x25, // [ + 0x2d, // bslash + 0x26, // ] + 0x23, // ^ + 0x38|SHIFT, // _ + 0x2d|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x24, // { + 0x36, // | + 0x27, // } + 0x2d, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + _altGrMap[36] = true; // $ + _altGrMap[64] = true; // @ + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash + _altGrMap[93] = true; // ] + _altGrMap[94] = true; // ^ + _altGrMap[96] = true; // ` + _altGrMap[123] = true; // { + _altGrMap[124] = true; // | + _altGrMap[125] = true; // } + _altGrMap[126] = true; // ~ +} diff --git a/modules/arduino/locales/sv.lang b/modules/arduino/locales/sv.lang new file mode 100644 index 0000000..4a43112 --- /dev/null +++ b/modules/arduino/locales/sv.lang @@ -0,0 +1,160 @@ +/* + * This is based off of the Danish locale. + * Due to how the Swedish keyboard works, some characters (~, ^, `) have to be pressed twice. On ubuntu two presses creates one character, + * on Windows one press creates no charater and two presses creates two. + * + * This means that the required test string is "!"#$%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^``_abcdefghijklmnopqrstuvwxyz{|}~~ @" + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " + 0x20|SHIFT, // # + 0x21, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x31, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x31|SHIFT, // * + 0x2d, // + + 0x36, // , + 0x38, // - + 0x37, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x37|SHIFT, // : + 0x36|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x1f, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x25, // [ + 0x2d, // bslash + 0x26, // ] + 0x30|SHIFT, // ^ + 0x38|SHIFT, // _ + 0x2e|SHIFT, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x24, // { + 0x64, // | + 0x27, // } + 0x30, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[36] = true; // $ + _altGrMap[64] = true; // @ + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash + _altGrMap[93] = true; // ] + _altGrMap[123] = true; // { + _altGrMap[124] = true; // | + _altGrMap[125] = true; // } + _altGrMap[126] = true; // ~ +} diff --git a/modules/arduino/locales/tr.lang b/modules/arduino/locales/tr.lang new file mode 100644 index 0000000..c9ef04e --- /dev/null +++ b/modules/arduino/locales/tr.lang @@ -0,0 +1,156 @@ +/* Grave Accent(`) not working yet. AltGr + , combination work only from keyboard. */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x35, // " + 0x20, // # + 0x21, // $ + 0x22|SHIFT, // % + 0x23|SHIFT, // & + 0x1f|SHIFT, // ' + 0x25|SHIFT, // ( + 0x26|SHIFT, // ) + 0x2d, // * + 0x21|SHIFT, // + + 0x31, // , + 0x2e, // - + 0x38, // . + 0x24|SHIFT, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x38|SHIFT, // : + 0x31|SHIFT, // ; + 0x64, // < + 0x27|SHIFT, // = + 0x64|SHIFT, // > + 0x2d|SHIFT, // ? + 0x14, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x25, // [ + 0x2d, // bslash + 0x26, // ] + 0x20|SHIFT, // ^ + 0x2e|SHIFT, // _ + 0x35, // ` //DOES NOT WORK + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x34, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x24, // { + 0x64, // | + 0x27, // } + 0x30, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() { + _altFine = true; + + _altGrMap[126] = true; // ~ + _altGrMap[123] = true; // { + _altGrMap[64] = true; // @ + _altGrMap[91] = true; // [ + _altGrMap[92] = true; // bslash + _altGrMap[93] = true; // ] + //_altGrMap[96] = true; // ` DOES NOT WORK YET. + _altGrMap[124] = true; // | + _altGrMap[35] = true; // # + _altGrMap[36] = true; // $ + _altGrMap[125] = true; // } +} diff --git a/modules/arduino/locales/uk.lang b/modules/arduino/locales/uk.lang new file mode 100644 index 0000000..536d85d --- /dev/null +++ b/modules/arduino/locales/uk.lang @@ -0,0 +1,144 @@ +/* + * Local generated by Matthew Milan. https://devleaf.com + */ + + #define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x1f|SHIFT, // " , + 0x31, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x24|SHIFT, // & + 0x34, // ' + 0x26|SHIFT, // ( + 0x27|SHIFT, // ) + 0x25|SHIFT, // * + 0x2e|SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x38, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x33|SHIFT, // : + 0x33, // ; + 0x36|SHIFT, // < + 0x2e, // = + 0x37|SHIFT, // > + 0x38|SHIFT, // ? + 0x34|SHIFT, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x64, // bslash + 0x30, // ] + 0x23|SHIFT, // ^ + 0x2d|SHIFT, // _ + 0x35, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f|SHIFT, // { + 0x64|SHIFT, // | + 0x30|SHIFT, // } + 0x31|SHIFT, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() {_altFine = true;} diff --git a/modules/arduino/locales/us.lang b/modules/arduino/locales/us.lang new file mode 100644 index 0000000..2209fdf --- /dev/null +++ b/modules/arduino/locales/us.lang @@ -0,0 +1,144 @@ +/* + * _asciimap took from Keyboard.cpp, don't need to be modified + */ + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x34|SHIFT, // " + 0x20|SHIFT, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x24|SHIFT, // & + 0x34, // ' + 0x26|SHIFT, // ( + 0x27|SHIFT, // ) + 0x25|SHIFT, // * + 0x2e|SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x38, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x33|SHIFT, // : + 0x33, // ; + 0x36|SHIFT, // < + 0x2e, // = + 0x37|SHIFT, // > + 0x38|SHIFT, // ? + 0x1f|SHIFT, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x31, // bslash + 0x30, // ] + 0x23|SHIFT, // ^ + 0x2d|SHIFT, // _ + 0x35, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f|SHIFT, // { + 0x31|SHIFT, // | + 0x30|SHIFT, // } + 0x35|SHIFT, // ~ + 0 // DEL +}; + +// Init var +bool _altGrMap[128]; +bool _altFine = false; + +// Individually define all needed char +void initAltGr() {_altFine = true;} diff --git a/modules/Arduino.js b/modules/arduino/module.js similarity index 91% rename from modules/Arduino.js rename to modules/arduino/module.js index 5d30a1d..f3e8175 100644 --- a/modules/Arduino.js +++ b/modules/arduino/module.js @@ -1,12 +1,6 @@ /* jshint laxbreak: true */ new Object({ - moduleMeta: { /* Module infos */ - displayName: 'Arduino', - version: 1.0, - author: 'Nurrl' - }, - functionMap: { /* Functions */ REM: function(argList, µ) { argList.shift(); @@ -165,32 +159,32 @@ new Object({ }, keyMap: { /* Normal keys */ - a:'a', - b:'b', - c:'c', - d:'d', - e:'e', - f:'f', - g:'g', - h:'h', - i:'i', - j:'j', - k:'k', - l:'l', - m:'m', - n:'n', - o:'o', - p:'p', - q:'q', - r:'r', - s:'s', - t:'t', - u:'u', - v:'v', - w:'w', - x:'x', - y:'y', - z:'z' + a:'\'a\'', + b:'\'b\'', + c:'\'c\'', + d:'\'d\'', + e:'\'e\'', + f:'\'f\'', + g:'\'g\'', + h:'\'h\'', + i:'\'i\'', + j:'\'j\'', + k:'\'k\'', + l:'\'l\'', + m:'\'m\'', + n:'\'n\'', + o:'\'o\'', + p:'\'p\'', + q:'\'q\'', + r:'\'r\'', + s:'\'s\'', + t:'\'t\'', + u:'\'u\'', + v:'\'v\'', + w:'\'w\'', + x:'\'x\'', + y:'\'y\'', + z:'\'z\'' }, postLine: function(lineStr, µ) { @@ -221,7 +215,7 @@ new Object({ return toReturn; }, - getFinalCode: function(compiledCode) { /* Function who returns the usable code */ + getFinalCode: function(code) { /* Function who returns the usable code */ return '/**\n' + ' * Made with Duckuino, an open-source project.\n' + ' * Check the license at \'https://github.com/Nurrl/Duckuino/blob/master/LICENSE\'\n' @@ -241,7 +235,7 @@ new Object({ + ' // Wait 500ms\n' + ' delay(500);\n' + '\n' - + compiledCode + + code + ' // Ending stream\n' + ' Keyboard.end();\n' + '}\n\n' diff --git a/modules/arduino/module.meta b/modules/arduino/module.meta new file mode 100644 index 0000000..c93b7a3 --- /dev/null +++ b/modules/arduino/module.meta @@ -0,0 +1,106 @@ +{ + "displayname":"Arduino", + "version":"1.0", + "author":"Nurrl", + "locales":{ + "_meta": { + "header": "lib/Keyboard.h", + "name": "Keyboard", + "parts": [ + "lib/Keyboard@1.cpp", + "_locale_", + "lib/Keyboard@2.cpp" + ] + }, + "us": { + "name":"United States - Default", + "path": "locales/us.lang", + "version":"1.0", + "author":"Arduino Team" + }, + "uk": { + "name":"United Kingdom", + "path": "locales/uk.lang", + "version":"1.0", + "author":"" + }, + "fr": { + "name":"France", + "path": "locales/fr.lang", + "version":"1.1", + "author":"Nurrl" + }, + "be": { + "name":"Belgium", + "path": "locales/be.lang", + "version":"1.0", + "author":"" + }, + "sv": { + "name":"Sweden", + "path": "locales/sv.lang", + "version":"1.0", + "author":"" + }, + "es": { + "name":"Spain", + "path": "locales/es.lang", + "version":"1.0", + "author":"" + }, + "it": { + "name":"Italy", + "path": "locales/it.lang", + "version":"1.0", + "author":"" + }, + "po": { + "name":"Portugal", + "path": "locales/po.lang", + "version":"1.0", + "author":"" + }, + "pobr": { + "name":"Portugal(BR)", + "path": "locales/pobr.lang", + "version":"1.0", + "author":"" + }, + "gr": { + "name":"Germany", + "path": "locales/gr.lang", + "version":"1.0", + "author":"" + }, + "su": { + "name":"Finland", + "path": "locales/su.lang", + "version":"1.0", + "author":"" + }, + "cz": { + "name":"Czech Republic(Qwerty)", + "path": "locales/cz.lang", + "version":"1.0", + "author":"" + }, + "czqwertz": { + "name":"Czech Republic(Qwertz)", + "path": "locales/czqwertz.lang", + "version":"1.0", + "author":"" + }, + "dk": { + "name":"Danmark", + "path": "locales/dk.lang", + "version":"1.0", + "author":"" + }, + "tr": { + "name":"Turkey", + "path": "locales/tr.lang", + "version":"1.0", + "author":"" + } + } +} diff --git a/modules/Digispark.js b/modules/digispark/module.js similarity index 96% rename from modules/Digispark.js rename to modules/digispark/module.js index e7d2007..4f51781 100644 --- a/modules/Digispark.js +++ b/modules/digispark/module.js @@ -1,12 +1,6 @@ /* jshint laxbreak: true */ new Object({ - moduleMeta: { /* Module infos */ - displayName: 'Digispark', - version: 1.0, - author: '@alcyonsecurity / NIXU' - }, - functionMap: { /* Functions */ REM: function(argList, µ) { argList.shift(); @@ -234,7 +228,7 @@ new Object({ } for (var i = 0; i < keys.length; i++) { - + var combis = ['KEY_LEFT_GUI','MOD_ALT_LEFT','MOD_SHIFT_LEFT','MOD_CONTROL_LEFT']; if (keys.length > 1 && combis.indexOf(keys[i]) > -1) { @@ -247,14 +241,14 @@ new Object({ normalkeys.push(keys[i]); } } - + if (modifiers.length > 0 && normalkeys.length == 1) return ' DigiKeyboard.sendKeyStroke(' + normalkeys[0] + ', ' + modifiers.join('|') + ');\n'; if (keys.length == 1) return ' DigiKeyboard.sendKeyStroke(' + normalkeys[0] + ');\n'; - - return ' // Unexpected key combination: ' + keyArray.join(', ') + '\n'; + + return ' // Unexpected key combination: ' + keyArray.join(', ') + '\n'; }, getFinalCode: function(compiledCode) { /* Function who returns the usable code */ @@ -271,7 +265,7 @@ new Object({ + '#define KEY_NUM_LOCK 0x53\n' + '#define KEY_SCROLL_LOCK 0x47\n' + '#define KEY_CAPS_LOCK 0x39\n' - + '#define KEY_TAB 0x2B\n\n' + + '#define KEY_TAB 0x2B\n\n' + 'void digiBegin() {\n' + ' DigiKeyboard.sendKeyStroke(0,0);\n' + ' DigiKeyboard.delay(50);\n' @@ -286,7 +280,7 @@ new Object({ + '}\n\n' + 'void printText(fstr_t *txt) {\n' + ' DigiKeyboard.print(txt);\n' - + ' DigiKeyboard.update();\n' + + ' DigiKeyboard.update();\n' + '}\n\n' + 'void setup() {\n' + ' digiBegin();\n' diff --git a/modules/digispark/module.meta b/modules/digispark/module.meta new file mode 100644 index 0000000..3078dde --- /dev/null +++ b/modules/digispark/module.meta @@ -0,0 +1,6 @@ +{ + "displayname":"Digispark", + "version":"1.0", + "author":"@alcyonsecurity / NIXU", + "locales": {} +} diff --git a/modules/modules b/modules/modules deleted file mode 100644 index 3c6fe13..0000000 --- a/modules/modules +++ /dev/null @@ -1,3 +0,0 @@ -Arduino -Digispark -MuKeyboard diff --git a/modules/modules.json b/modules/modules.json new file mode 100644 index 0000000..0b23ee5 --- /dev/null +++ b/modules/modules.json @@ -0,0 +1,17 @@ +{ + "arduino": { + "module": "module.js", + "meta": "module.meta", + "path": "arduino/" + }, + "digispark": { + "module": "module.js", + "meta": "module.meta", + "path": "digispark/" + }, + "mukeyboard": { + "module": "module.js", + "meta": "module.meta", + "path": "mukeyboard/" + } +} diff --git a/modules/MuKeyboard.js b/modules/mukeyboard/module.js similarity index 91% rename from modules/MuKeyboard.js rename to modules/mukeyboard/module.js index e5e8bc4..1cb9476 100644 --- a/modules/MuKeyboard.js +++ b/modules/mukeyboard/module.js @@ -1,12 +1,6 @@ /* jshint laxbreak: true */ new Object({ - moduleMeta: { /* Module infos */ - displayName: 'MuKeyboard', - version: 1.0, - author: 'MrMoDDoM' - }, - functionMap: { /* Functions */ REM: function(argList, µ) { argList.shift(); @@ -165,32 +159,32 @@ new Object({ }, keyMap: { /* Normal keys */ - a:'a', - b:'b', - c:'c', - d:'d', - e:'e', - f:'f', - g:'g', - h:'h', - i:'i', - j:'j', - k:'k', - l:'l', - m:'m', - n:'n', - o:'o', - p:'p', - q:'q', - r:'r', - s:'s', - t:'t', - u:'u', - v:'v', - w:'w', - x:'x', - y:'y', - z:'z' + a:'\'a\'', + b:'\'b\'', + c:'\'c\'', + d:'\'d\'', + e:'\'e\'', + f:'\'f\'', + g:'\'g\'', + h:'\'h\'', + i:'\'i\'', + j:'\'j\'', + k:'\'k\'', + l:'\'l\'', + m:'\'m\'', + n:'\'n\'', + o:'\'o\'', + p:'\'p\'', + q:'\'q\'', + r:'\'r\'', + s:'\'s\'', + t:'\'t\'', + u:'\'u\'', + v:'\'v\'', + w:'\'w\'', + x:'\'x\'', + y:'\'y\'', + z:'\'z\'' }, postLine: function(lineStr, µ) { @@ -224,7 +218,7 @@ new Object({ getFinalCode: function(compiledCode) { /* Function who returns the usable code */ return '/**\n' + ' * Made for Duckuino with MuKeyboard.\n' - + ' * Check the Duckuino's license at \'https://github.com/Nurrl/Duckuino/blob/master/LICENSE\'\n' + + ' * Check the Duckuino\'s license at \'https://github.com/Nurrl/Duckuino/blob/master/LICENSE\'\n' + ' * Check the MuKeyboard project at \'https://github.com/MrMoDDoM/MuKeyboard\'\n' + ' */\n\n' + '#include "MuKeyboard.h"\n\n' diff --git a/modules/mukeyboard/module.meta b/modules/mukeyboard/module.meta new file mode 100644 index 0000000..7e35830 --- /dev/null +++ b/modules/mukeyboard/module.meta @@ -0,0 +1,6 @@ +{ + "displayname":"MuKeyboard", + "version":"1.0", + "author":"MrMoDDoM", + "locales": {} +} diff --git a/readme.default b/readme.default index 1ead681..18c1d3e 100644 --- a/readme.default +++ b/readme.default @@ -7,4 +7,4 @@ https://github.com/Nurrl/Duckuino And the licence: https://github.com/Nurrl/Duckuino/blob/master/LICENSE -(c) 2016-2017 Nurrl +(c) 2016-2018 Nurrl & Plazmaz From 689f603a68ed5f9c09ae1a07f0b57a4a85b6b44c Mon Sep 17 00:00:00 2001 From: Nurrl Date: Sun, 19 Aug 2018 13:42:59 +0200 Subject: [PATCH 4/8] Added responsive UI for smartphones :D --- assets/css/style.css | 36 +++++++++++++++--------------------- index.html | 5 +++-- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 0124fc3..0dc073b 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -10,32 +10,15 @@ html, body { font-family: Lato, sans-serif; font-size: 16px; - /* Disable Scroll */ - overflow: hidden; - - /* Size */ - height: 100%; width: 100%; -} - -/* Background blured image */ -body::before { - /* Position */ - position: absolute; - top: 0; left: 0; - - /* Size */ - height: 100%; width: 100%; - /* Background */ background-size: cover; background-image: url(../imgs/background.jpg); background-repeat: no-repeat; background-position: center; + background-attachment: fixed; - /* Misc */ - /*filter: blur(1px);*/ - content: ""; - z-index: -1; + /* Size */ + height: 100%; width: 100%; } /* Text */ @@ -126,6 +109,7 @@ button:disabled { /* Center parts */ display: flex; + flex-wrap: wrap; } .part { @@ -139,12 +123,22 @@ button:disabled { border-radius: 4px; /* Separation */ - /*box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);*/ + /*box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);*/ /* Text */ color: white; } +@media (max-width: 640px) { + .part { + width: 100%; + } + + .input { + margin-top: 28px; + } +} + /* Elements */ .process { /* Center text */ diff --git a/index.html b/index.html index 50fd1a6..cec43d2 100644 --- a/index.html +++ b/index.html @@ -2,6 +2,7 @@ + @@ -43,8 +44,8 @@

Export

Time to use !
- - +

Option 1: Download (Recommended)

From fe4110940ee3e1e55a89299e9e6721165b6c6832 Mon Sep 17 00:00:00 2001 From: Nurrl Date: Sun, 19 Aug 2018 18:29:03 +0200 Subject: [PATCH 5/8] Added line number to the input textarea. --- assets/css/style.css | 3 + assets/js/lib/jquery-linenumbers.js | 87 +++++++++++++++++++++++++++++ assets/js/main.js | 14 ++++- index.html | 3 +- 4 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 assets/js/lib/jquery-linenumbers.js diff --git a/assets/css/style.css b/assets/css/style.css index 0dc073b..b455649 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -36,6 +36,8 @@ textarea { border: none; border-radius: 4px; padding: 8px; + word-wrap: break-word; + word-break: break-all; box-sizing: border-box; resize: none; } @@ -151,6 +153,7 @@ button:disabled { width: 100%; display: none; + z-index: 2; } .tooltip > span { /* Size */ diff --git a/assets/js/lib/jquery-linenumbers.js b/assets/js/lib/jquery-linenumbers.js new file mode 100644 index 0000000..c4a06dd --- /dev/null +++ b/assets/js/lib/jquery-linenumbers.js @@ -0,0 +1,87 @@ + + let textWidth = function (elem, text) { + $body = $('body'); + $this = elem; + $text = text; + var calc = '
' + $text + '
'; + $body.append(calc); + var width = $('body').find('span:last').width(); + $body.find('span:last').parent().remove(); + return width; + }; +(function($){ + $.fn.linenumbers = function(inopts){ + let opts = $.extend({ + width: 32, + padding: 8, + start: 1, + digits: 4 + }, inopts); + $('[data-name="linenumbers"]').remove(); + + return this.each(function(){ + let self = this; + let width = $(this).width(); + let height = $(this).height(); + let newwidth = width - opts.width; + + $(this).before(''); + $(this).css({'width': newwidth + 'px', 'height': height + 'px', + 'padding': opts.padding + 'px', 'float': 'right'}); + $(this).after('
'); + + let lnbox = $(this).parent().find('textarea[data-name="linenumbers"]'); + + // Determine textarea len with chars + let charlen = -1; + for (let i = 0; charlen == -1; i++) + if (textWidth($(this), "*".repeat(i)) >= newwidth - opts.padding * 2) + charlen = i - 2; + $(this).bind('blur focus change keyup keydown', function() { + // Break apart and regex the lines, everything to spaces sans linebreaks + let lines = $(this).val().split('\n'); + + // declare output var + let output=''; + // declare spacers and max_spacers vars, and set defaults + let max_spacers = ''; + for(i=0; i < opts.digits; i++) + max_spacers += ' '; + // Loop through and process each line + $.each(lines,function(k, v) { + // Add a line if not blank + if (k != 0) + output += '\n'; + // Determine the appropriate number of leading spaces + let lencheck = k + opts.start + '!'; + let spacers = max_spacers.substr(lencheck.length - 1); + // Add the line with out line number, to the output variable + if (k >= Math.pow(10, opts.digits) - 1) + output += "\n" + else { + output += spacers + (k + opts.start) + ':'; + output += "\n---".repeat((v.length - 1) / charlen); + } + }); + // Give the text area out modified content. + $(lnbox).val(output); + // Change scroll position as they type, makes sure they stay in sync + $(lnbox).scrollTop($(this).scrollTop()); + }); + // Lock scrolling together, for mouse-wheel scrolling + $(this).scroll(function(){ + $(lnbox).scrollTop($(this).scrollTop()); + }); + // Fire it off once to get things started + $(this).trigger('keydown'); + }); + }; +})(jQuery); diff --git a/assets/js/main.js b/assets/js/main.js index a6e729f..452cf74 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,5 +1,9 @@ $(function() { /* Wait for jQuery */ + + /* Textarea */ + $(".input > #input").linenumbers(); + /* Init lets */ let isCodeCompiled = false; let Duck = new Duckuino(); @@ -10,7 +14,13 @@ $(function() { /* Wait for jQuery */ } catch (e) {} /* Compile button enable/disable */ - $(".input > textarea").keyup(function() { + $(".input > #input").keyup(function() { + // Disable export when input is changed + $(".copy-but").prop("disabled", true); + $(".export .copy-but").text("Copy !"); + $(".dl-but button").prop("disabled", true); + $(".dl-but select").prop("disabled", true); + if($(this).val() !== "") { $(".process-but button").prop("disabled", false); $(".process-but select").prop("disabled", false); @@ -28,7 +38,7 @@ $(function() { /* Wait for jQuery */ /* Compile button click */ $(".process-but button").click(function() { - let duckyScript = $(".input > textarea").val(); + let duckyScript = $(".input > #input").val(); let selectedModule = mods[$(".process-but select").find(":selected").val()]; /* Load Duckuino & Compile */ diff --git a/index.html b/index.html index cec43d2..2091bbd 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@
This is where you put the DuckyScript

- +
@@ -62,6 +62,7 @@

Option 2: Copy/Paste

+ From b6cd9e291a515df5248436e040b9fef7ed6607ea Mon Sep 17 00:00:00 2001 From: Nurrl Date: Sun, 19 Aug 2018 20:42:03 +0200 Subject: [PATCH 6/8] Fixed performance and wrapping issues of line numbers --- assets/js/lib/jquery-linenumbers.js | 58 ++++++++++++++++++----------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/assets/js/lib/jquery-linenumbers.js b/assets/js/lib/jquery-linenumbers.js index c4a06dd..62bebc5 100644 --- a/assets/js/lib/jquery-linenumbers.js +++ b/assets/js/lib/jquery-linenumbers.js @@ -1,15 +1,27 @@ +function getCharByRow(e) { + let name = Math.random().toString(36).substr(2, 12); + let span = ''; + $('body').append(span); - let textWidth = function (elem, text) { - $body = $('body'); - $this = elem; - $text = text; - var calc = '
' + $text + '
'; - $body.append(calc); - var width = $('body').find('span:last').width(); - $body.find('span:last').parent().remove(); - return width; - }; -(function($){ + $('#' + name).text('*'); + let inith = $('#' + name).height(); + + let chars; + for (chars = 1; $('#' + name).height() <= inith; chars++) + $('#' + name).text("*".repeat(chars)); + + //$('#' + name).remove(); + return chars - 2; +} + +(function($) { $.fn.linenumbers = function(inopts){ let opts = $.extend({ width: 32, @@ -35,20 +47,21 @@ white-space: pre; overflow: hidden;\ " disabled>'); $(this).css({'width': newwidth + 'px', 'height': height + 'px', - 'padding': opts.padding + 'px', 'float': 'right'}); + 'padding': opts.padding + 'px', 'float': 'right', 'overflow-y': 'hidden'}); $(this).after('
'); let lnbox = $(this).parent().find('textarea[data-name="linenumbers"]'); + let charbr = getCharByRow($(this)); - // Determine textarea len with chars - let charlen = -1; - for (let i = 0; charlen == -1; i++) - if (textWidth($(this), "*".repeat(i)) >= newwidth - opts.padding * 2) - charlen = i - 2; - $(this).bind('blur focus change keyup keydown', function() { - // Break apart and regex the lines, everything to spaces sans linebreaks - let lines = $(this).val().split('\n'); + $(this).on('keydown keyup change', function(ev) { + // Make change directly + if (ev.type == 'keydown') { + setTimeout(() => $(this).trigger('change'), 0); + return; + } + // Split value into lines + let lines = $(this).val().split('\n'); // declare output var let output=''; // declare spacers and max_spacers vars, and set defaults @@ -68,7 +81,8 @@ output += "\n" else { output += spacers + (k + opts.start) + ':'; - output += "\n---".repeat((v.length - 1) / charlen); + if (v != "") + output += "\n---".repeat((v.length - 1) / charbr); } }); // Give the text area out modified content. @@ -81,7 +95,7 @@ $(lnbox).scrollTop($(this).scrollTop()); }); // Fire it off once to get things started - $(this).trigger('keydown'); + $(this).trigger('change'); }); }; })(jQuery); From c28f0f0650bb312c28b04bb9d878e81f780ad31a Mon Sep 17 00:00:00 2001 From: Leon ROUX Date: Sat, 20 Apr 2019 18:02:52 +0200 Subject: [PATCH 7/8] Fixed responsiveness of the line number addon --- assets/css/style.css | 2 +- assets/js/lib/jquery-linenumbers.js | 148 ++++++++++++++++------------ modules/arduino/module.meta | 2 +- 3 files changed, 85 insertions(+), 67 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index b455649..ac2db7a 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -131,7 +131,7 @@ button:disabled { color: white; } -@media (max-width: 640px) { +@media (max-width: 860px) { .part { width: 100%; } diff --git a/assets/js/lib/jquery-linenumbers.js b/assets/js/lib/jquery-linenumbers.js index e223209..45fd9ed 100644 --- a/assets/js/lib/jquery-linenumbers.js +++ b/assets/js/lib/jquery-linenumbers.js @@ -21,80 +21,98 @@ function getCharByRow(e) { return chars - 2; } +function update(ev, self, opts, linebox) { + /* Interpret keydown as change */ + if (ev.type == 'keydown') { + setTimeout(() => $(self).trigger('change'), 0); + return; + } + + /* Make sure height is right */ + $(linebox).css('height', + ($(self).height() + + parseInt($(self).css('padding-top')) + + parseInt($(self).css('padding-bottom'))) + 'px'); + + /* Get the number of printable char in line */ + let charbr = getCharByRow($(self)); + + // Split value into lines + let lines = $(self).val().split('\n'); + // declare output var + let output=''; + // declare spacers and max_spacers vars, and set defaults + let max_spacers = ''; + for(i=0; i < opts.digits; i++) + max_spacers += ' '; + // Loop through and process each line + $.each(lines, function(k, v) { + // Add a line if not blank + if (k != 0) + output += '\n'; + // Determine the appropriate number of leading spaces + let lencheck = k + opts.start + '!'; + let spacers = max_spacers.substr(lencheck.length - 1); + // Add the line with out line number, to the output variable + if (k >= Math.pow(10, opts.digits) - 1) + output += "\n" + else { + output += spacers + (k + opts.start) + ':'; + if (v != "") + output += "\n--".repeat((v.length - 1) / charbr); + } + }); + + // Give the text area out modified content. + $(linebox).val(output); + // Change scroll position as they type, makes sure they stay in sync + $(linebox).scrollTop($(self).scrollTop()); + +} + +/* On JQuery ready */ (function($) { $.fn.linenumbers = function(inopts){ let opts = $.extend({ - width: 32, - padding: 8, + width: 42, start: 1, - digits: 4 + digits: 3 }, inopts); $('[data-name="linenumbers"]').remove(); - return this.each(function(){ + return this.each(function() { let self = this; - let width = $(this).width(); - let height = $(this).height(); - let newwidth = width - opts.width; - - $(this).before(''); - $(this).css({'width': newwidth + 'px', 'height': height + 'px', - 'padding': opts.padding + 'px', 'float': 'right', 'overflow-y': 'hidden'}); - $(this).after('
'); - - let lnbox = $(this).parent().find('textarea[data-name="linenumbers"]'); - let charbr = getCharByRow($(this)); - - $(this).on('keydown keyup change', function(ev) { - // Make change directly - if (ev.type == 'keydown') { - setTimeout(() => $(this).trigger('change'), 0); - return; - } - - // Split value into lines - let lines = $(this).val().split('\n'); - // declare output var - let output=''; - // declare spacers and max_spacers vars, and set defaults - let max_spacers = ''; - for(i=0; i < opts.digits; i++) - max_spacers += ' '; - // Loop through and process each line - $.each(lines,function(k, v) { - // Add a line if not blank - if (k != 0) - output += '\n'; - // Determine the appropriate number of leading spaces - let lencheck = k + opts.start + '!'; - let spacers = max_spacers.substr(lencheck.length - 1); - // Add the line with out line number, to the output variable - if (k >= Math.pow(10, opts.digits) - 1) - output += "\n" - else { - output += spacers + (k + opts.start) + ':'; - if (v != "") - output += "\n---".repeat((v.length - 1) / charbr); - } - }); - // Give the text area out modified content. - $(lnbox).val(output); - // Change scroll position as they type, makes sure they stay in sync - $(lnbox).scrollTop($(this).scrollTop()); - }); - // Lock scrolling together, for mouse-wheel scrolling - $(this).scroll(function(){ - $(lnbox).scrollTop($(this).scrollTop()); + + /* Generate the line number text-area */ + $(this).before(''); + + /* Get the generated text-area and style it */ + let linebox = $(self).parent().find('textarea[data-name="linenumbers"]'); + $(linebox).css('width', opts.width + 'px'); + $(linebox).css('height', + ($(this).height() + + parseInt($(this).css('padding-top')) + + parseInt($(this).css('padding-bottom'))) + 'px'); + $(linebox).css('padding-right', '0'); + $(linebox).css('position', 'absolute'); + $(linebox).css('overflow', 'hidden'); + $(linebox).css('border-top-right-radius', '0'); + $(linebox).css('border-bottom-right-radius', '0'); + + $(this).css({'padding-left': + (opts.width + parseInt($(self).css('padding-left'))) + 'px', + 'overflow': 'hidden'}); + + /* Update on events */ + $(this).on('keydown keyup change', (ev) => update(ev, self, opts, linebox)); + $(window).resize((ev) => update(ev, self, opts, linebox)); + + /* Scroll with the base text-area */ + $(this).scroll(function() { + $(linebox).scrollTop($(this).scrollTop()); }); - // Fire it off once to get things started + + /* Fire it off once to get things started */ $(this).trigger('change'); }); }; diff --git a/modules/arduino/module.meta b/modules/arduino/module.meta index c93b7a3..8200164 100644 --- a/modules/arduino/module.meta +++ b/modules/arduino/module.meta @@ -28,7 +28,7 @@ "name":"France", "path": "locales/fr.lang", "version":"1.1", - "author":"Nurrl" + "author":"Leon ROUX @Nurrl" }, "be": { "name":"Belgium", From 47299bdcdc37dbb190c597885b7230ecb0360dec Mon Sep 17 00:00:00 2001 From: Leon ROUX Date: Mon, 29 Apr 2019 15:23:04 +0200 Subject: [PATCH 8/8] Updated readme :) --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f867c19..5cdc208 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,17 @@ https://nurrl.github.io/Duckuino/ ## Why Duckuino ? You can compile **Duckyscript** to **Arduino** code directly through the [live](https://nurrl.github.io/Duckuino/ "Duckuino Live") version, or reuse `Duckuino.js` for standalone use : ```javascript -/* Need to fill */ -``` -Output: +let Duck = new Duckuino(); +let mods = new Modules().list; -```c -/* Need to fill */ +let output = Duck.compileCode("STRING This is a test string !", mods[0].module); +/* ^- Here will be the final compiled code | +** and errors if applicable. | +** Here is the selected module -/ +** +** Note: You can iterate through the list and find the desired one, +** by default, `0` will be the first module. +*/ ``` # Members - [Plazmaz](https://github.com/Plazmaz)