Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 2 LINES BELOW HAVE TO BE PASTED INTO MALDUINO LITE CODE RECEIVED FROM CONVERTER */
- void Print(String s);
- bool use_alt_numpad_method = false;
- /*
- Copyright (c) 2017 Seytonic, Spacehuhn (Licensed under MIT)
- For more information see: github.com/seytonic/malduino
- */
- #include "Keyboard.h"
- #include "Mouse.h"
- #define blinkInterval 50
- #define ledPin 3
- #define buttonPin 6
- int defaultDelay = 4;
- int defaultCharDelay = 5;
- int rMin = 0;
- int rMax = 100;
- bool ledOn = true;
- void typeKey(int key){
- Keyboard.press(key);
- delay(defaultCharDelay);
- Keyboard.release(key);
- }
- void setup(){
- pinMode(buttonPin, INPUT_PULLUP);
- pinMode(ledPin, OUTPUT);
- digitalWrite(ledPin, HIGH);
- Keyboard.begin();
- Mouse.begin();
- /* ----- Begin-Script -----*/
- /* [Parsed By Duckuino (Licensed under MIT) - for more information visit: https://github.com/Nurrl/Dckuino.js] */
- delay(1000);
- delay(defaultDelay);
- Print("hello \\\\\\ world"); // replace all Keyboard.print("") with Print("")
- /* ----- End-Script -----*/
- Keyboard.end();
- }
- void loop(){
- ledOn = !ledOn;
- digitalWrite(ledPin, ledOn);
- delay(blinkInterval);
- }
- /* COPY/PASTE ALL OF THE CODE BELOW AT THE END OF THE MALDUINO LITE CODE RECEIVED FROM CONVERTER */
- byte KEYPAD[10] = {234, 225, 226, 227, 228, 229, 230, 231, 232, 233};
- #define ENCODING_BYTE_DESIRED 0
- #define ENCODING_BYTE_USED 1
- #define ENCODING_BYTE_MODIFIER 2
- //dk.properties exact length: 69 (encoding generated using: https://github.com/hak5darren/USB-Rubber-Ducky/tree/master/Encoder/resources)
- byte Encoding[3][70] = {
- {0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x4D, 0x51, 0x57, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5F, 0x61, 0x69, 0x6D, 0x71, 0x77, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0xA0, 0xA3, 0xA4, 0xA7, 0xAB, 0xB5, 0xBD, 0xC5, 0xC6, 0xD8, 0xDF, 0xE5, 0xE6, 0xF0, 0xF8, 0xFE},
- {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x5C, 0x38, 0x39, 0x5C, 0x2D, 0x2C, 0x2F, 0x2E, 0x37, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2E, 0x2C, 0xEC, 0x30, 0xEC, 0x2D, 0x32, 0x61, 0x6D, 0x71, 0x77, 0x79, 0x7A, 0x38, 0xEC, 0x39, 0x2F, 0x61, 0x69, 0x6D, 0x71, 0x77, 0x79, 0x7A, 0x37, 0x3D, 0x30, 0x5D, 0x20, 0x33, 0x34, 0x7E, 0x34, 0x6D, 0x7E, 0x5B, 0x3B, 0x22, 0x73, 0x5B, 0x3B, 0x64, 0x22, 0x74},
- {0x81, 0x81, 0x81, 0x86, 0x81, 0x81, 0x00, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x00, 0x81, 0x81, 0x81, 0x86, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x86, 0x86, 0x86, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x86, 0x86, 0x86, 0x00, 0x86, 0x81, 0x81, 0x00, 0x86, 0x00, 0x81, 0x81, 0x81, 0x86, 0x00, 0x00, 0x86, 0x00, 0x86}
- };
- int GetKeyIndex(byte c, byte* char_array)
- {
- for(byte i=0;i<strlen(char_array);i++)
- {
- if(c == char_array[i])
- {
- return i;
- }
- }
- return 256;
- }
- void Print(String inStr)
- {
- int enc_index;
- for(byte i=0; i< inStr.length(); i++)
- {
- if(use_alt_numpad_method && ((!isalnum(inStr[i]) && inStr[i] != ' ') || IsException(inStr[i]))) //if character is punctuation or requires different button to be pressed in different keyboard language settings then use alt+numpad method
- {
- /* ALT + NUMPAD METHOD */
- byte hundreds = (byte)inStr[i] / 100;
- byte dozens = ((byte)inStr[i] - (hundreds*100)) / 10;
- byte singles = (byte)inStr[i] - (hundreds*100) - (dozens*10);
- Keyboard.press(KEY_LEFT_ALT);
- PressRelease((char)KEYPAD[hundreds], 5);
- PressRelease((char)KEYPAD[dozens], 5);
- PressRelease((char)KEYPAD[singles], 5);
- Keyboard.releaseAll();
- continue;
- }
- /* SUBSTITUTION METHOD */
- enc_index = GetKeyIndex(inStr.charAt(i), Encoding[ENCODING_BYTE_DESIRED]);
- if(enc_index < 256)
- {
- if(Encoding[ENCODING_BYTE_MODIFIER][enc_index] > 0)
- {
- Keyboard.press(Encoding[ENCODING_BYTE_MODIFIER][enc_index]);
- delay(defaultCharDelay);
- }
- Keyboard.press(Encoding[ENCODING_BYTE_USED][enc_index]);
- delay(defaultCharDelay);
- }
- else
- {
- Keyboard.press(inStr.charAt(i));
- delay(defaultCharDelay);
- }
- Keyboard.releaseAll();
- }
- }
- void PressRelease(char c, byte timeDelay)
- {
- Keyboard.press(c);
- delay(timeDelay);
- Keyboard.release(c);
- }
- /*
- Exceptions are the letters that require different button being pressed in different lang settings
- (so if letter == exception then use alt+numpad method, otherwise use the normal typing because it's faster to press 1 instead of 4 buttons)
- these exceptions are listed to make the typing process faster because using alt+numpad method for all the characters appears to be too slow
- german - yz
- french - qamwz
- dutch - qamwz
- turkish - i
- azerbaijani - totally uncompatible
- */
- #define EXCEPTIONS_SIZE 24
- char exceptions[EXCEPTIONS_SIZE] = {
- 'y','Y',
- 'z','Z',
- 'q','Q',
- 'a','A',
- 'm','M',
- 'w','W',
- 'i','I',
- '0','1','2','3','4','5','6','7','8','9',
- };
- bool IsException(char c) // check whether this character is one of these that have to be typed differently using other language settings
- {
- for(byte i=0; i<EXCEPTIONS_SIZE; i++)
- {
- if(c == exceptions[i])
- {
- return true;
- }
- }
- return false;
- }
- bool IsModifier(char c) // is key like shift, alt, "GUI" key, etc.
- {
- byte b = (byte)c;
- if((b >= 128 && b <=135) || (b >= 176 && b <=179) || (b >= 193 && b <=205) || (b >= 209 && b <=218))
- {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement