Hello, I have a pro micro card and a keypad. My goal is to assign keys that do not normally have a function on the keyboard to this keypad, such as the function keys between F13-F24. The reason I do this is that I will assign these keys in the games I play and I will have plenty of extra keys. But I cannot find any non-functional keys that I can send other than F13-F24 and I need them. I found a piece of code from this forum that modifies the Keyboard.h library and allows sending Raw codes, and I integrated it into the library. In other words, I can send Raw codes.
I also use an app and the game's keybinding options to try and observe the operation of the keys sent.
Here is my Arduino code (The HID codes in the code snippet I sent as Raw code are only for testing purposes, I don't know which buttons they correspond to).
#include <Keypad.h>
#include <Keyboard.h>
const byte ROWS = 4;
const byte COLS = 4;
char key;
char changeMode;
char keyMaps[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '#', '0', '*', 'D' }
};
byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad(makeKeymap(keyMaps), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
Keyboard.begin();
}
void loop() {
modeControl();
}
//mod kontrol
void modeControl() {
key = keypad.getKey();
if (key == 'A' || key == 'B' || key == 'C' || key == 'D') changeMode = key;
if (changeMode == 'A') {
modeA();
} else if (changeMode == 'B') {
modeB();
} else if (changeMode == 'C') {
modeC();
} else if (changeMode == 'D') {
modeD();
}
}
//spotify kısayolları
void modeA() {
if (key == '1') {
Serial.println("A");
}
else if (key == '2') {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_UP_ARROW);
delay(100);
Keyboard.releaseAll();
}
else if (key == '3') {
}
else if (key == '4') {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_ARROW);
delay(100);
Keyboard.releaseAll();
}
else if (key == '5') {
Keyboard.press(' ');
delay(100);
Keyboard.releaseAll();
}
else if (key == '6') {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_RIGHT_ARROW);
delay(100);
Keyboard.releaseAll();
}
else if (key == '7') {
}
else if (key == '8') {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_DOWN_ARROW);
delay(100);
Keyboard.releaseAll();
}
else if (key == '9') {
}
else if (key == '#') {
}
else if (key == '0') {
}
else if (key == '*') {
}
else {
}
Keyboard.end();
}
// raw kodları deneme
void modeB() {
if (key == '1') {
Keyboard.writeRaw(0xE9);
delay(100);
// //Keyboard.release(KEY_F1);
}
else if (key == '2') {
Keyboard.write(0xCD);
delay(100);
}
else if (key == '3') {
}
else if (key == '4') {
}
else if (key == '5') {
}
else if (key == '6') {
}
else if (key == '7') {
}
else if (key == '8') {
}
else if (key == '9') {
}
else if (key == '#') {
}
else if (key == '0') {
}
else if (key == '*') {
}
else {
}
}
//fonksiyon tuşları f13-f24
void modeC() {
if (key == '1') {
Keyboard.press(KEY_F13);
delay(100);
Keyboard.release(KEY_F13);
}
else if (key == '2') {
Keyboard.press(KEY_F14);
delay(100);
Keyboard.release(KEY_F14);
}
else if (key == '3') {
Keyboard.press(KEY_F15);
delay(100);
Keyboard.release(KEY_F15);
}
else if (key == '4') {
Keyboard.press(KEY_F16);
delay(100);
Keyboard.release(KEY_F16);
}
else if (key == '5') {
Keyboard.press(KEY_F17);
delay(100);
Keyboard.release(KEY_F17);
}
else if (key == '6') {
Keyboard.press(KEY_F18);
delay(100);
Keyboard.release(KEY_F18);
}
else if (key == '7') {
Keyboard.press(KEY_F19);
delay(100);
Keyboard.release(KEY_F19);
}
else if (key == '8') {
Keyboard.press(KEY_F20);
delay(100);
Keyboard.release(KEY_F20);
}
else if (key == '9') {
Keyboard.press(KEY_F21);
delay(100);
Keyboard.release(KEY_F21);
}
else if (key == '#') {
Keyboard.press(KEY_F22);
delay(100);
Keyboard.release(KEY_F22);
}
else if (key == '0') {
Keyboard.press(KEY_F23);
delay(100);
Keyboard.release(KEY_F23);
}
else if (key == '*') {
Keyboard.press(KEY_F24);
delay(100);
Keyboard.release(KEY_F24);
}
else {
}
}
void modeD() {
if (key == '1') {
}
else if (key == '2') {
}
else if (key == '3') {
}
else if (key == '4') {
}
else if (key == '5') {
}
else if (key == '6') {
}
else if (key == '7') {
}
else if (key == '8') {
}
else if (key == '9') {
}
else if (key == '#') {
}
else if (key == '0') {
}
else if (key == '*') {
}
else {
}
}
