Pages: 1 [2]   Go Down
Author Topic: USB keyboard, difficulty passing decimal key arguments to a function  (Read 687 times)
0 Members and 1 Guest are viewing this topic.
Manchester NH
Offline Offline
Full Member
***
Karma: 1
Posts: 132
Like to build typing devices, and heard unicorns
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I got lost here. What do you mean by "and press takes decimals"? decimals is not a type. Or a meaningful description of a numeric value, either.
basically unsigned byte 1100001 goes through but unsigned byte 10000010 gets ignored and I am not really sure why because if the latter value didn't get ignored my program would work the way I expect it to.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50045
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
basically unsigned byte 1100001 goes through but unsigned byte 10000010 gets ignored and I am not really sure why because if the latter value didn't get ignored my program would work the way I expect it to.
Goes through what? How do you know that it goes through whatever?
Logged

Manchester NH
Offline Offline
Full Member
***
Karma: 1
Posts: 132
Like to build typing devices, and heard unicorns
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

solution... embarrassingly enough the answer was pulled from my first sketch from a couple of weeks ago... real simple, assign the key definitions to chars. Why this works or why I did this to begin with and forgot, I couldn't tell you.
Code:
char super= KEY_LEFT_GUI;
char ctrl= KEY_LEFT_CTRL;
char alt= KEY_LEFT_ALT;
char f4= KEY_F4;
char f2= KEY_F2;
char tab= KEY_TAB;

void setup()
{
  Keyboard.begin();
  delay(500);
  combo(alt, f2);
  delay(200);
  Keyboard.println("mate-terminal");
  delay(200);
}

void loop()
{
}

void combo(char key1, char key2)
{
  Keyboard.press(key1);
  Keyboard.press(key2);
  delay(100);
  Keyboard.releaseAll();
}
passing char shift=129 must be blocked by magic smoke, because this is the only thing that I could get to work.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50045
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
passing char shift=129 must be blocked by magic smoke, because this is the only thing that I could get to work.
Possibly because char is a signed type, with a valid range of values from -128 to 127.
Logged

Manchester NH
Offline Offline
Full Member
***
Karma: 1
Posts: 132
Like to build typing devices, and heard unicorns
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Possibly because char is a signed type, with a valid range of values from -128 to 127.
good point, i'm kinda all over all over the place in how I misuse and understand terminology. However tested with the byte data type the same results occur   
Logged

Pages: 1 [2]   Go Up
Jump to: