writing game using QNX

Hi everyone, I am a student studying Computer Engineering in the
Chinese University in Hong Kong.

I am now doing a Final Year Project based on QNX. I have to write a
big game using QNX 's special feature : Message passing. (fun?)

We have to write a 3D game. However, seems no openGL library for
QNX…( I can’t search for it…). Then today I found that “photon
3D” which has the description : “Photon 3d Runtime and Developement”


is it useful to me…? if so, can anyone tell me how it can be used?

at the same time, I need to write a program which gets the keyboard
input from users. After getting the input, a message will be sent to
another process. However, I get no idea on how to detect what keys
are being pressed.

Actually, we have used the SDL library to due with the GUI. SDL also
provide us a way to get input from users. However, no multiuple key
is allowed if we use SDL. So it will be very stupid if we use it for
the input of the game.

Can anyone kindly help us on the above problems?? Thx!!!

Can anyone kindly help us on the above problems?? Thx!!!

Check the helpviewer notes for “getch” and “kbhit” functions.

  • GF

i find that my QNX doesn’t have getch and kbhit functions
my QNX version is QNX NC 6.2.1
i have googled before and found that these two functions required
conio.h
however, i don;t have it too…

can anyone help me to solve the problem?
thx!

stanleyfok <stanleyfok@cuhk.edu-dot-hk.no-spam.invalid> wrote:

i find that my QNX doesn’t have getch and kbhit functions
my QNX version is QNX NC 6.2.1
i have googled before and found that these two functions required
conio.h
however, i don;t have it too…

can anyone help me to solve the problem?
thx!

Instead of getch(), use read() in raw mode. Instead of kbhit(), use
tcischars().


Steve Reid stever@qnx.com
Technical Editor
QNX Software Systems

thx steve!
i have used the function u porvided for me and i have written a simple
segment of code

\

#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/uio.h>

int main()
{
int size_read;
char buffer[100];

printf( “Program looping. Press any key.\n” );
while(1)
{
if( tcischars(fileno(stdin)) != -1 )
{
size_read = read(fileno(stdin),buffer,sizeof(buffer));
printf(“see!! %d\n”,size_read);
}
else
{
printf(“error\n”);
}
}

return 0;
}


um…however this cant do what i want…

in the code now, things will be only be printed out when i press
enter

but since i am writing a game
i require events to be happen after just pressing a key (without press
enter of cos…~)

how can i do??

thx steve!
i have used the function u porvided for me and i have written a simple
segment of code

\

#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/uio.h>

int main()
{
int size_read;
char buffer[100];

printf( “Program looping. Press any key.\n” );
while(1)
{
if( tcischars(fileno(stdin)) != -1 )
{
size_read = read(fileno(stdin),buffer,sizeof(buffer));
printf(“see!! %d\n”,size_read);
}
else
{
printf(“error\n”);
}
}

return 0;
}


um…however this cant do what i want…

in the code now, things will be only be printed out when i press
enter

but since i am writing a game
i require events to be happen after just pressing a key (without press
enter of cos…~)

how can i do??

You need to set the terminal to raw mode. check the docs for tcsetattr I think it has an example.
Make sure to set it back to the original settings before exiting…

stanleyfok wrote:

thx steve!
i have used the function u porvided for me and i have written a simple
segment of code

\

#include <stdio.h
#include <stdlib.h
#include <termios.h
#include <unistd.h
#include <sys/uio.h

int main()
{
int size_read;
char buffer[100];

printf( “Program looping. Press any key.\n” );
while(1)
{
if( tcischars(fileno(stdin)) != -1 )
{
size_read = read(fileno(stdin),buffer,sizeof(buffer));
printf(“see!! %d\n”,size_read);
}
else
{
printf(“error\n”);
}
}

return 0;
}


um…however this cant do what i want…

in the code now, things will be only be printed out when i press
enter

but since i am writing a game
i require events to be happen after just pressing a key (without press
enter of cos…~)

how can i do??


cburgess@qnx.com

Hello, stanleyfok!

s> but since i am writing a game

Do you writing console game ? No ? So why you are using console ???

s> i require events to be happen after just pressing a key (without press
s> enter of cos…~)

Maybe better to use SDL or native Photon then ?

With best regards, Mike Gorchak. E-mail: mike@malva.com.ua

actually i know how to do this using SDL~ (extremely easy…)
but i find that if use SDL, it can’t handle the moment that 2 keys are
being pressed
(for example, i want to move the character to the top right…)

so i dun know is there any better method
and professor event suggest us to see see the keyboard’s code in the
kernel…!

“stanleyfok” <stanleyfok@cuhk.edu-dot-hk.no-spam.invalid> wrote in message
news:dc8a7u$abl$1@inn.qnx.com

actually i know how to do this using SDL~ (extremely easy…)
but i find that if use SDL, it can’t handle the moment that 2 keys are
being pressed
(for example, i want to move the character to the top right…)

so i dun know is there any better method

and professor event suggest us to see see the keyboard’s code in the
kernel…!

Huh! Then I guess the professor doesn’t really know what he is talking
about :wink:

not really
becos this topic has also been done by students few years ago

he knows how the students do previously

Hello, stanleyfok!

s> actually i know how to do this using SDL~ (extremely easy…)
s> but i find that if use SDL, it can’t handle the moment that 2 keys are
s> being pressed (for example, i want to move the character to the top
right…)

Really ? So why then I can strife and shoot the monsters simultaneously in
Quake ? :slight_smile:
http://mike.qnx.org.ru/screenshots/

s> so i dun know is there any better method
s> and professor event suggest us to see see the keyboard’s code in the
s> kernel…!

Don’t make me laugh, please. Did you ever have tryied any third-party SDL
game under QNX ? Try any before disassembling the kernel, to retrieve
keyboard’s codes :slight_smile:

With best regards, Mike Gorchak. E-mail: mike@malva.com.ua

stanleyfok wrote:

not really
becos this topic has also been done by students few years ago

he knows how the students do previously

I’m pretty sure that they didn’t found the code for the keyboard in the
kernel. The keyboard support is part of the IO system, but that isn’t
part of the (micro) kernel.

–Armin

If your game is a photon application I wouldn’t use these two functions
anyway. Look at attaching hotkey callbacks to a window for instance.


“stanleyfok” <stanleyfok@cuhk.edu-dot-hk.no-spam.invalid> wrote in message
news:dc5sta$g45$1@inn.qnx.com

i find that my QNX doesn’t have getch and kbhit functions
my QNX version is QNX NC 6.2.1
i have googled before and found that these two functions required
conio.h
however, i don;t have it too…

can anyone help me to solve the problem?
thx!