Modified my translate program to take a parameter of the keyboard path to open and also to press ESC to quit translating and exit.

Code
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/uinput.h>
#include <stdlib.h>

#define msleep(ms) usleep((ms)*1000)

// Translate a keyboard opened in exclusive mode into virtual button presses with uinput
// by Golden Child
//
// using examples from
//
// https://gist.github.com/matthewaveryusa/a721aad80ae89a5c69f7c964fa20fec1
// https://github.com/GrantEdwards/uinput-joystick-demo
// https://www.kernel.org/doc/html/v4.12/input/uinput.html
// https://blog.marekkraus.sk/c/linuxs-uinput-usage-tutorial-virtual-gamepad/

// hard code the keyboard to open in keyboard_to_open
// you can pass the path of the keyboard to open on the command line

 char keyboard_to_open[256] = "/dev/input/by-id/usb-0461_USB_Wired_Keyboard-event-kbd";


static void setup_abs(int fd, unsigned chan, int min, int max);  

// demo showing how to provide a joystick/gamepad instance from
// userspace.

int main(int argc, char* argv[])
{ sleep(1); // wait for a second
  int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
  
  if (fd < 0)
    {
      perror("open /dev/uinput");
      return 1;
    }

  ioctl(fd, UI_SET_EVBIT, EV_KEY); // enable button/key handling

int translatetable[] = { 

KEY_LEFTSHIFT, BTN_0,
KEY_Z, BTN_1,
KEY_X, BTN_2,
KEY_C, BTN_3,
KEY_V, BTN_4,
KEY_B, BTN_5,
KEY_N, BTN_6,
KEY_M, BTN_7,
KEY_COMMA, BTN_8,
KEY_DOT, BTN_9,
KEY_SLASH, BTN_TRIGGER_HAPPY1,
KEY_RIGHTSHIFT, BTN_TRIGGER_HAPPY2,
KEY_UP, BTN_DPAD_UP,
KEY_LEFT, BTN_DPAD_LEFT,
KEY_DOWN, BTN_DPAD_DOWN,
KEY_RIGHT, BTN_DPAD_RIGHT };

int translatetablelen = sizeof(translatetable) / sizeof (int);

int rcode; 


// tell uinput which BTN events we will generate
for (int i=0;i<translatetablelen;i+=2)     ioctl(fd, UI_SET_KEYBIT, translatetable[i+1]);

 char keyboard_name[256] = "Unknown";
 
 int keyboard_fd;

printf ("\nparameters %d\n",argc);
for (int i=0;i<argc;i++) printf("parameter %d = %s\n",i,argv[i]);
 if (argc > 1)
 	keyboard_fd = open(argv[1], O_RDONLY | O_NONBLOCK);  
else
    keyboard_fd = open(keyboard_to_open, O_RDONLY | O_NONBLOCK);  


  if ( keyboard_fd == -1 ) {
    printf("Failed to open keyboard.\n");
    exit(1);
  }
  rcode = ioctl(keyboard_fd, EVIOCGNAME(sizeof(keyboard_name)), keyboard_name);
  printf("Reading From : %s \n", keyboard_name);

  printf("Getting exclusive access: ");
  rcode = ioctl(keyboard_fd, EVIOCGRAB, 1);
  printf("%s\n", (rcode == 0) ? "SUCCESS" : "FAILURE");
  printf("Translating codes: \n\
KEY_LEFTSHIFT, BTN_0,\n\
KEY_Z, BTN_1,\n\
KEY_X, BTN_2,\n\
KEY_C, BTN_3,\n\
KEY_V, BTN_4,\n\
KEY_B, BTN_5,\n\
KEY_N, BTN_6,\n\
KEY_M, BTN_7,\n\
KEY_COMMA, BTN_8,\n\
KEY_DOT, BTN_9,\n\
KEY_SLASH, BTN_TRIGGER_HAPPY1,\n\
KEY_RIGHTSHIFT, BTN_TRIGGER_HAPPY2,\n\
KEY_UP, BTN_DPAD_UP,\n\
KEY_LEFT, BTN_DPAD_LEFT,\n\
KEY_DOWN, BTN_DPAD_DOWN,\n\
KEY_RIGHT, BTN_DPAD_RIGHT\n\n");

for (int i=0;i<translatetablelen;i+=2)  printf("%d => %d\n",translatetable[i],translatetable[i+1]);

  printf("Press ESC to exit\n");
  struct input_event keyboard_event;


  ioctl(fd, UI_SET_EVBIT, EV_ABS); // enable analog absolute position handling
  
  setup_abs(fd, ABS_X,  -512, 512);
  setup_abs(fd, ABS_Y,  -512, 512);
  setup_abs(fd, ABS_Z,  -32767, 32767);
  
  struct uinput_setup setup =
    {
     .name = "Userspace Joystick",
     .id =
     {
      .bustype = BUS_USB,
      .vendor  = 0x3,
      .product = 0x3,
      .version = 2,
     }
    };

  if (ioctl(fd, UI_DEV_SETUP, &setup))
    {
      perror("UI_DEV_SETUP");
      return 1;
    }
  
  if (ioctl(fd, UI_DEV_CREATE))
    {
      perror("UI_DEV_CREATE");
      return 1;
    }


int doquit=0; // must initialize variable or else it's nonzero
struct input_event button_event;
while (1) {      
      int readval;
      
      if ( readval = read(keyboard_fd, &keyboard_event, sizeof(keyboard_event)), readval != -1 ) 
        {
        if (keyboard_event.code == KEY_ESC && keyboard_event.type == EV_KEY) 
        {
        	doquit = 1;
        	printf("ESC pressed, exiting\n");
        }
      	if (keyboard_event.type == EV_KEY)
      		for (int i=0;i<translatetablelen;i+=2) if (keyboard_event.code == translatetable[i]) 
      					{
      					
      					if (keyboard_event.value != 2) {  // skip key repeat events
      					
						button_event.type = EV_KEY;
						button_event.code = translatetable[i+1];
						button_event.value = keyboard_event.value;
						
						  printf("ev type=%d  key in=%d  => button out=%d value=%d\n",
						  	button_event.type,
						  	keyboard_event.code,
							button_event.code,
							button_event.value);
		
					  if(write(fd, &button_event, sizeof button_event) < 0)
							{
							  perror("write");
							  return 1;
							}
						
						// send SYNC event
						
						button_event.type = EV_SYN;
						button_event.code = 0;
						button_event.value = 0;

	
					  if(write(fd, &button_event, sizeof button_event) < 0)
							{
							  perror("write");
							  return 1;
							}
	
					  if(write(fd, &button_event, sizeof button_event) < 0)
							{
							  perror("write");
							  return 1;
							}
						break;
					}    						
					}								
 	// if (readval <= 0) msleep(50); 
 	if (doquit) break;
    }
 	if (readval <= 0) msleep(50); // keep from taking a lot of cpu by going to sleep
}


  if(ioctl(fd, UI_DEV_DESTROY))
    {
      printf("UI_DEV_DESTROY");
      return 1;
    }

  close(fd);
  return 0;
}

// enable and configure an absolute "position" analog channel

static void setup_abs(int fd, unsigned chan, int min, int max)
{
  if (ioctl(fd, UI_SET_ABSBIT, chan))
    perror("UI_SET_ABSBIT");
  
  struct uinput_abs_setup s =
    {
     .code = chan,
     .absinfo = { .minimum = min,  .maximum = max },
    };

  if (ioctl(fd, UI_ABS_SETUP, &s))
    perror("UI_ABS_SETUP");
}


So here's a sample run:

Code
sudo ./translate /dev/input/by-id/usb-USB_USB_Keyboard-event-kbd 

parameters 2
parameter 0 = ./translateverify2
parameter 1 = /dev/input/by-id/usb-USB_USB_Keyboard-event-kbd
Reading From : USB USB Keyboard 
Getting exclusive access: SUCCESS
Translating codes: 
KEY_LEFTSHIFT, BTN_0,
KEY_Z, BTN_1,
KEY_X, BTN_2,
KEY_C, BTN_3,
KEY_V, BTN_4,
KEY_B, BTN_5,
KEY_N, BTN_6,
KEY_M, BTN_7,
KEY_COMMA, BTN_8,
KEY_DOT, BTN_9,
KEY_SLASH, BTN_TRIGGER_HAPPY1,
KEY_RIGHTSHIFT, BTN_TRIGGER_HAPPY2,
KEY_UP, BTN_DPAD_UP,
KEY_LEFT, BTN_DPAD_LEFT,
KEY_DOWN, BTN_DPAD_DOWN,
KEY_RIGHT, BTN_DPAD_RIGHT

42 => 256
44 => 257
45 => 258
46 => 259
47 => 260
48 => 261
49 => 262
50 => 263
51 => 264
52 => 265
53 => 704
54 => 705
103 => 544
105 => 546
108 => 545
106 => 547
Press ESC to exit
ev type=1  key in=42  => button out=256 value=1
ev type=1  key in=42  => button out=256 value=0
ev type=1  key in=46  => button out=259 value=1
ev type=1  key in=44  => button out=257 value=1
ev type=1  key in=46  => button out=259 value=0
ev type=1  key in=45  => button out=258 value=1
ev type=1  key in=46  => button out=259 value=1
ev type=1  key in=44  => button out=257 value=0
ev type=1  key in=45  => button out=258 value=0
ev type=1  key in=46  => button out=259 value=0
ev type=1  key in=44  => button out=257 value=1
ev type=1  key in=45  => button out=258 value=1
ev type=1  key in=46  => button out=259 value=1
ev type=1  key in=44  => button out=257 value=0
ev type=1  key in=47  => button out=260 value=1
ev type=1  key in=45  => button out=258 value=0
ev type=1  key in=46  => button out=259 value=0
ev type=1  key in=47  => button out=260 value=0
ev type=1  key in=42  => button out=256 value=1
ev type=1  key in=42  => button out=256 value=0
ev type=1  key in=42  => button out=256 value=1
ev type=1  key in=44  => button out=257 value=1
ev type=1  key in=44  => button out=257 value=0
ev type=1  key in=42  => button out=256 value=0
ESC pressed, exiting

Noticed it was consuming a lot of cpu, I put the msleep in the wrong place of the loop.


Once you launch this, you can now see a new entry in /proc/bus/input/devices

Code
cat /proc/bus/input/devices
...
I: Bus=0003 Vendor=0003 Product=0003 Version=0002
N: Name="Userspace Joystick"
P: Phys=
S: Sysfs=/devices/virtual/input/input143
U: Uniq=
H: Handlers=event22 js1 
B: PROP=0
B: EV=b
B: KEY=3 0 0 f00000000 0 0 0 3ff 0 0 0 0
B: ABS=7