OK, so it's far from being an ACTUAL StreamDeck, but here's what I did to make a old external 10-key Numpad with PS/2 plug into a keypad that can do macro's over USB HID.
That is, until I started learning how some Arduino boards can be setup to be recognized as a HID device. Basically, when you plug it into a computer, it will recognize it as an interface device, and not an arduino board.
Well, no...not exactly
But what about translating the keypresses to something else?... Maybe?
I dug into the device to see what I could find. A bunch of pcb and a chip that has no datasheet filed anywhere online.
Welp, there went that idea of maybe tapping some pins to use the standard matrix style key project that can be found in many arduino starter packs.
I went on to a couple Discord servers to chat/prod for help on this crazy lil idea I had, and someone suggested "Why not just have it use some extended keys?"
Yeah... Why not?
I already knew that keyboard standards accepted things like media hot keys and what have you, as well as function keys beyond the F12 of the standard keyboard. Why not have this do F13-F24? That's plenty of keys for using as macro hotkeys. I broke out my Arduino Leoardo, which I found can do HID nativly, and started looking up coding examples.
With the help of 'chaosfool' from Syd Heresy's crew on discord, I was able to put together a Arduino sketch that was able to take the scan code of the key press, then add a set number of however many keys above that was to make it equal to the scancode of the higher function keys. Wired up the PS/2 wires VC to 5V, GND to GND, Clock to SCL, and DATA to an open data pin on a Arduino Leonardo breakout board, then pushed the sketch over.
In comes the DFRobot Beetle!
This lil thing is a bit bigger than a quarter and is basically a stripped down Leonardo. Perfect for what I am needing it for!
The numpad thankfully used a header to connect to the PS/2 cable, so I was able to unplug the cable, snip the end with the header connection, and then strip some wires back to solder to the Beetle. PS/2 Vcc and GND went to 5V out and GND pads respectivly. Clock wire went to the SCL pad (ie, IRQ pin 3) and DATA wire went to Digital Data pin/pad 11.
Electrical taped it sealed, folded the wires over that and it fits perectly in the space above the PCB of the numpad! Had a super long MicroUSB so that fit in the wire hole and under the board of the keypad to the Beetle
//NUMPAD to extended function keys (f13-f24) //Converts PS/2 numpad to function as extended function keys over USB HID #include <PS2KeyAdvanced.h> //required for higher function keys #include <Keyboard.h> PS2KeyAdvanced ps2kb; #define DATAPIN 11 #define IRQPIN 3 //SCL pin on Beetle uint16_t c; void setup( ) { ps2kb.begin( DATAPIN, IRQPIN ); ps2kb.setNoBreak(1); ps2kb.setNoRepeat(1); if ( ps2kb.available ( ) ) { c = ps2kb.read(); } } void loop( ) { if ( ps2kb.available( ) ) { c = ps2kb.read( ); if ( c > 0 ) { uint16_t fkey = c + (PS2_KEY_F13 - PS2_KEY_KP0); // translate number key to function key char hidkey = KEY_F13 + (fkey - PS2_KEY_F13); // convert to hid key code if((c>>8)!=80);{ // send to computer Keyboard.press(hidkey); delay(50); Keyboard.release(hidkey); } } } }
No comments:
Post a Comment
Don't be a dingus