With lua + autohotkey scripts in windows this is definitely possible the last time I checked. You run a luascript on another keyboard mapped to a generic key, luascript inputs that as the proper text-based language
Mac, I can only assume its something you would write in applescript. But maybe you find some interesting ideas there. I found something called "http://www.orderedbytes.com/controllermate/" that might be of interest to you
You could use Karabiner[1]. No need to do the “different language” hack, just make a big pile of key remappings that only affect that particular keyboard. It’s pretty easy to target just one input device with that.
There's a tomscott video on it
https://www.youtube.com/watch?v=lIFE7h3m40U
Checkout Teran van Hemert (linustechtips editor) for some potential ideas too. He's got crazy macro schemas, I've used a couple of his and there great. All windows based as well though. https://www.youtube.com/playlist?list=PLH1gH0v9E3ruYrNyRbHhD...
Mac, I can only assume its something you would write in applescript. But maybe you find some interesting ideas there. I found something called "http://www.orderedbytes.com/controllermate/" that might be of interest to you