you'd need to have a PS2Keyboard2.h and PS2Keyboard2.cpp
the .h should start with
#ifndef PS2Keyboard2_h
#define PS2Keyboard2_h
#include "Arduino.h"
#include "utility/int_pins.h"
...
#endif
...
the #define should not be a real issue since they have the same values and will be pre-processed separately
the .cpp should start with
#include "PS2Keyboard2.h"
#define BUFFER_SIZE 45
static volatile uint8_t buffer2[BUFFER_SIZE];
static volatile uint8_t head2, tail2;
static uint8_t DataPin2;
static uint8_t CharBuffer2=0;
static uint8_t UTF8next2=0;
static const PS2Keymap_t *keymap2=NULL;
...
as you need to rename the global variables otherwise the compiler will bark at you
and in your code do something like this:
#include <PS2Keyboard.h>
PS2Keyboard keyboard1; // that's creating an instance of the class PS2Keyboard
const byte DataPin = 4;
const byte IRQpin = 7;
#include <PS2Keyboard2.h>
PS2Keyboard2 keyboard2; // that's creating an instance of the class PS2Keyboard2
const byte DataPin2 = 3;
const byte IRQpin2 = 2;
void setup()
{
Serial.begin(115200); // why go slow?
keyboard1.begin(DataPin, IRQpin);
keyboard2.begin(DataPin2, IRQpin2);
}
loop()
{
}
and ensure this compiles without any warning or errors - I've not looked into details