How would you write a linux program to read data from a joystick, and turn that data into a command that is pushed onto the queue?

linux is not a programming language. A simple perl program might be

my @queue;
open JS,"/dev/joystick";
while (<JS>) {
push @queue, cmd($_);
}
close JS;

sub cmd {
my $js = shift;
my $cmd;
... code to form command ...
return $cmd;
}