Author Topic: Keyboard non-ASCII characters command  (Read 9681 times)

yo2ldk

  • Newbie
  • *
  • Posts: 6
Keyboard non-ASCII characters command
« on: November 29, 2015, 12:16:21 pm »
 Hi all,

 I need to make a sketch for Two buttons, who send via USB commands like KEYSTROKES CTRL + LEFT GUI or CTRL + ALT + DELETE.
   this is what I try but no luck to compile, please some advice

#include <DigiKeyboard.h>
#include <oddebug.h>
#include <osccal.h>
#include <osctune.h>
#include <scancode-ascii-table.h>
#include <usbconfig-prototype.h>
#include <usbconfig.h>
#include <usbdrv.h>
#include <usbportability.h>

#define KEYCODE_MOD_LEFT_CONTROL    0x01
#define KEYCODE_MOD_LEFT_SHIFT      0x02
#define KEYCODE_MOD_LEFT_ALT        0x04
#define KEYCODE_MOD_LEFT_GUI        0x08   
#define KEYCODE_MOD_RIGHT_CONTROL   0x10
#define KEYCODE_MOD_RIGHT_SHIFT     0x20
#define KEYCODE_MOD_RIGHT_ALT       0x40
#define KEYCODE_MOD_RIGHT_GUI       0x80


uint8_t button1 = 0;
uint8_t button2 = 2;

// We'll assume that your button inputs are normally LOW, and go to HIGH when pressed
uint8_t value1 = HIGH;
uint8_t value2 = HIGH;

void setup() {
 
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
}

void loop() {
 
  value1 = digitalRead(button1);
  value2 = digitalRead(button2);

  if (value1 == LOW) {
    DigiKeyboard.sendKeyStroke (KEYCODE_MOD_LEFT_CONTROL,KEYCODE_RIGHT_GUI)
   ;
  }

  if (value2 == LOW) {
    DigiKeyboard.sendKeyStroke(KEYCODE_MOD_LEFT_ALT|KEYCODE_MOD_LEFT_CONTROL,KEYCODE_DELETE);
  }
 
  DigiKeyboard.delay(10);
   }

yo2ldk

  • Newbie
  • *
  • Posts: 6
Re: Keyboard non-ASCII characters command
« Reply #1 on: December 02, 2015, 12:30:22 am »
 Thank you Ralph for reply and help,

  I tried that with Hex and Dec.and I receive error "...was not declared in this scope"
can we modify the .h file to declare some key ?
but also there is:

#define MOD_CONTROL_LEFT    (1<<0)
#define MOD_SHIFT_LEFT      (1<<1)
#define MOD_ALT_LEFT        (1<<2)
#define MOD_GUI_LEFT        (1<<3)
#define MOD_CONTROL_RIGHT   (1<<4)
#define MOD_SHIFT_RIGHT     (1<<5)
#define MOD_ALT_RIGHT       (1<<6)
#define MOD_GUI_RIGHT       (1<<7)

and I don't know how to declare it becaus is not a valu hex or dec, is  (1<<0)...  what that means   :-\


yo2ldk

  • Newbie
  • *
  • Posts: 6
Re: Keyboard non-ASCII characters command
« Reply #2 on: December 02, 2015, 10:10:42 am »
not work with that, I use Trinket library now, is really good, but it seems is some problem with windows 10 and driver
 I manage only one command, CTRL +V for test and now compiles without problems,
but when i act over button, this not execute,instead that, somehow my laptop keyboard was "lock" with ALT taste
( and that is not mentioned at all in sketch..)
very strange anyway, i keep digging.

 me best regards and 73 Ralph !

yo2ldk

  • Newbie
  • *
  • Posts: 6
Re: Keyboard non-ASCII characters command
« Reply #3 on: December 02, 2015, 02:04:30 pm »
I use external pull up 10k resistor, I think now I am on a good way,
making some changes to  Digikeyboard h file to recognize modifier keys
thank you for your time and support!
 when all is done, coming back with news :)