Hi to everyone!
I'm new of this forum so if i posted in the wrong section please let me know!
Now, my objective is to build a gaming keypad to use it for gaming (of course) and productivity by managing it through any of the various macro programs aviable. But since it's my first attempt i started small: a 5 button keypad, directly wired to the digispark, and using the DigiJoystick library.
The example script gives no problems and windows 10 pro sees the digispark as a joypad.
The problem came when i added the buttons. The code compile but the device it's not acknowledged as a joypad anymore and gives "unknown USB device".

Here my code:
#include "DigiJoystick.h"
byte bStateL = 0x00;
byte bStateH = 0x00;
void setup() {
// put your setup code here, to run once:
byte bStateL = 0x00;
byte bStateH = 0x00;
for (int i =0; i < 5; ++i ){
pinMode(i, INPUT_PULLUP);
}
//DigiJoystick.delay(100);
}
void loop() {
// put your main code here, to run repeatedly:
for (int j=0; j<5; j++){
byte bVar = readButton(j);
bStateL |= (bVar<<j);
}
DigiJoystick.setButtons(bStateL, bStateH);
DigiJoystick.delay(10);
}
byte readButton(int pin){
if(digitalRead(pin) == HIGH){
DigiJoystick.delay(10);
if(digitalRead(pin) == HIGH){
return 0x01;
}
}
return 0x00;
}
Is it a problem of timing(delay)? I can't find answers anywhere, so i'm asking to you gurus
