As far as i know, a text file is treated similar to binary file except that some os's do some linefeed, carriage return translations. Text files are sometimes parsed by reading line-by-line, which, in c++, is straightforward to do (std::getline()). You have the filesize, you know when you've reached the end of file, and you can read line-by-line if you want. Thinking from a text file point of view, i don't even think '\0' is valid in it (does getline() stop at the '\0'). I guess what i'm trying to say, a text file is basically a binary file except it generally contains printable text rather than some sort of binary data and a '\0' would be considered binary data.
//We are in non blocking mode - we just read once, and try to fill up buffer
int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
if( ret < 0 )
It may just be me, but that looks like a buffer overflow.
Don't think so. read reads bytes and the array size is specified correctly.