While there are a few good ways to make a standard controller be seen as a keyboard, I don't know of anything that would do the reverse. There's a proposed way to do it with xboxdrv, but the project hasn't been touched since late 2015. However, seeing as how all these emulators and ports are first and foremost computer software, they all have keyboard support that can even be a bit more versatile in many cases.
Using RetroArch as a jumping off point, if you can determine which keys are assigned to which buttons, the controls can be added manually to /opt/retropie/configs/all/retroarch.cfg. Below is an example of my setup that you can use as a reference.
input_player1_a = "a" input_player1_b = "b" input_player1_y = "y" input_player1_x = "x" input_player1_start = "t" input_player1_select = "e" input_player1_l = "l" input_player1_r = "r" input_player1_left = "left" input_player1_right = "right" input_player1_up = "up" input_player1_down = "down" input_player1_l2 = "d" input_player1_r2 = "f" input_player1_l3 = "c" input_player1_r3 = "v" input_player2_a = "k" input_player2_b = "m" input_player2_y = "o" input_player2_x = "n" input_player2_start = "num9" input_player2_select = "num0" input_player2_l = "p" input_player2_r = "q" input_player2_left = "g" input_player2_right = "h" input_player2_up = "i" input_player2_down = "j" input_player2_l2 = "s" input_player2_r2 = "u" input_player2_l3 = "w" input_player2_r3 = "z"