I had idea of project using mouse/keyboard and sending data from PC to Spark
Spark can handle only mouse or keyboard by default
Also usb-hid-suport branch is broken and needs reverting few last commits to actually work
So I digged in and finally made it work. Now sharing project code:
Hilights:
void HID_Data_Received_Callback()
{
if (HID_Rx_length > 0)
{
current_profile = HID_Rx_Buffer[1];
}
}
Callback for receiving data from PC. Can receive 8 bytes max, can be reconfigured to 64 bytes max
Keyboard.press(KEY_LEFT_SHIFT);
delay(KEY_PRESS_DELAY);
Keyboard.press(KEY_LEFT_CTRL);
delay(KEY_PRESS_DELAY);
for (uint8_t i = 0; i < count; i++)
{
Mouse.move(0, 0, direction);
delay(MOUSE_MOVE_DELAY);
}
Keyboard.release(KEY_LEFT_CTRL);
delay(KEY_RELEASE_DELAY);
Keyboard.release(KEY_LEFT_SHIFT);
delay(KEY_RELEASE_DELAY);
Using mouse and keyboard in same time
Windows detects this as 3 devices under one USB port
Unfortunately I’m not C++/SMT32 expert. This code could be much better written.
I really hope mouse+keyboad+2way HID communication setup will be available from Spark itself in future
@zachary @Dave 
Source code: https://www.dropbox.com/s/giuw3j3pcb0lr69/core-firmware-hid.zip?dl=0
A bit of tech details:
Instead of using mouse OR keyboard HID descriptors I always declare both under same endpoint. But I use 2 different hid report descriptors with different REPORT_ID Both reports can be sent at a same time or one after one(i use this approach)
For sending data back to core (I use it for setting device profiles) I use C# library HidSharp
HidDeviceLoader loader = new HidDeviceLoader();
allHidDevices = loader.GetDevices(0x1D50, 0x807D);
device = allHidDevices.FirstOrDefault(d => d.MaxOutputReportLength == 9);
if (!device.TryOpen(out stream))
{
return;
}
using (stream)
{
{
var bytes = new byte[device.MaxOutputReportLength];
bytes[0] = 3; //REPORT ID 3
bytes[1] = profile;
try
{
stream.Write(bytes);
}
catch (TimeoutException)
{
}
catch (Exception ex)
{
}
finally
{
stream.Close();
}
}

