Let's sort out some stuff first.
If I understand you correctly, OpenWRT is running on the MPU (MT7688). The MPU sees the MCU (ATmega) behind the UART, and the MPU has an USB controller to which a generic USB HID keyboard is connected.
In the kernel, key presses then travel through the following layers:
keyboard -> USB -> HID -> input
So the keyboard sends USB packets as "interrupts", which contain HID report data. The HID data is described in the HID descriptor, and for keyboards, usually you have the one modifier byte and up to six simultaneous keypresses. But other formats are possible. You can read raw hid reports from
/dev/hidrawX. The HID reports are converted by to kernel input layer events, which contain a single keypress/release, and those are the ones you read from
Nothing of this has anything to do with the UART, or the ATmega behind it.
Now there are ways to connect a HID device via other busses to the kernel layer, instead of via USB. For example over I2C, or over the UART.
Is that what you want? This again has nothing to do with the presence of the USB-keyboard events on
Another option is to invent your own private protocol, whatever you fancy, run one side on the the ATmega, and run a little C program that registers a new input-layer device via uinput, reads the UART, and then sends the input layer event.
Is that what you want? Again it has nothing to do with the presence of USB-keyboard events on
/dev/input/event0, or with forwarding those events to the UART.
Or do you want to take the keyboard events from the MPU, send them to the ATmega, process them there, then send them back and have them act as real input events? That's of course possible, though then you have to ask yourself why you don't do this processing on the MPU in the first place.
So please describe your actual goal. At the moment, it's a bit unclear. You can fiddle with the Linux input layer, you can fiddle with the Linux HID layer, you can inject events into both layers, and do everything you want. The formats are not particularly difficult. You just must be specific about what you want.
Modify the Arduino keyboard class to be able to send KeyReports the way I want with the raw data received from OpenWRT
doesn't make a lot of sense. There is no "Arduino keyboard class" in the kernel layer. If you are using a an "Arduino keyboard class" as part of your development system, please link to it. And it probably won't help you a lot, you'll need to understand the other formats (HID report, input layer event) as well.
So to recap (the next time you ask a problem, please describe it in a similar way. Also have a look at the problem with XY questions):
You want to have an intermediary device between a USB keyboard and some other computer, where the other computer should just see an ordinary keyboard, and on the device you can do keylogging, trigger other events etc. (You still haven't specified if it is necessary that this intermediary device is actual hardware, or if it is also possible to install something on the PC that will either help with the task, or do the extra processing of the keyboard events.)
For that, you wanted to use a Linkit board. The MPU on the Linkit board acts as USB host to the keyboard. It is connected via an UART to the MCU (an ATmega), which itself can act as a USB HID device, which in turn can be connected to the other PC.
To act as a USB HID device, the MCU needs to do three things: It has to have a HID descriptor which describes the reports, it needs to send out HID keyboard press reports, and it needs to react to HID reports from the PC to set keyboard LEDs etc. I'll assume you have a library for the ATmega which handles all that for you.
The simplest approach is to just copy the HID descriptor from the real USB keyboard. You can find the HID descriptor in human-readable form in
/sys/kernel/debug/hid/DEVICE_ID/rdesc, where DEVICE_ID identifies your keyboard. Either parse the hexadecimal at the beginning of it, or find out if there are ioctl's where you can get this information directly.
Then you need small program on the MPU which uses an ad-hoc protocol to communicate with the ATmega. It has to do the following: (1) If an USB hid device connects, read and parse the HID descriptor, send HID descriptor to ATmega. (2) Now enter a loop and forward HID reports from
N is the number for the keyboard via UART, and also write HID reports received from the UART to
/dev/hidrawN. (3) Send an "exit" message if the USB keyboard disconnects.
On the ATmega, you need a small program which that implements the other side, using the available HID library.
You can choose on which side to implement the key logging etc.
Simultaneous keypresses, caps lock etc. are all automatically handled by forwarding the HID reports.