CTRL + ...

Hi,

I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.
No code is generated from kbhit().

Any idea ?

Thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.

Ctrl-what? I don’t see anything between the brackets…

No code is generated from kbhit().

Does it work in text mode? The qansi terminal protocol only defines a
certain number of Ctrl combinations, and there are a lot of key
combinations that don’t generate any characters.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Wojtek Lerch a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.

Ctrl-what? I don’t see anything between the brackets…

CTRL-anything!

No code is generated from kbhit().

Does it work in text mode? The qansi terminal protocol only defines a
certain number of Ctrl combinations, and there are a lot of key
combinations that don’t generate any characters.

My problem is to receive any CTRL- combinaison. I was supposed to receive a
key code for any CTRL-key pressed.


Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Wojtek Lerch a écrit :
Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.

Does it work in text mode? The qansi terminal protocol only defines a
certain number of Ctrl combinations, and there are a lot of key
combinations that don’t generate any characters.

My problem is to receive any CTRL- combinaison. I was supposed to receive a
key code for any CTRL-key pressed.

What about function keys and cursor keys without Ctrl – do those work
for you?

How are you trying to read them? You must switch your terminal to raw
mode before you can see all the cursor and control keys. Otherwise, the
driver will use the ones it understands for line editing, and throw away
anything else…


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Wojtek Lerch a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Wojtek Lerch a écrit :
Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.

Does it work in text mode? The qansi terminal protocol only defines a
certain number of Ctrl combinations, and there are a lot of key
combinations that don’t generate any characters.

My problem is to receive any CTRL- combinaison. I was supposed to receive a
key code for any CTRL-key pressed.

What about function keys and cursor keys without Ctrl – do those work
for you?

Yes, cursors, function keys, work fine.

How are you trying to read them? You must switch your terminal to raw
mode before you can see all the cursor and control keys. Otherwise, the
driver will use the ones it understands for line editing, and throw away
anything else…

I read the keys with the following function:
inline char getch()
{
char ch;
struct timespec rqtp;

struct termios raw_tios =
{
/* c_iflag / 0,
/
c_oflag / 0,
#ifdef QNXNTO
/
c_cflag / (CREAD|HUPCL),
#else
/
c_cflag / (CREAD),
#endif
#ifdef QNXNTO
/
c_lflag / 0,
#else
/
c_lflag */ (IEXTEN),
#endif
};
struct termios tios;

rqtp.tv_sec = 0;
rqtp.tv_nsec = 5000000;
tcgetattr(0, &tios);
while (tcischars(0) == 0) {nanosleep(&rqtp, NULL);}
tcsetattr(0, TCSANOW, &raw_tios);
read (0, &ch, 1);
tcsetattr(0, TCSANOW, &tios);
return ch;
}

Thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Wojtek Lerch a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Wojtek Lerch a écrit :
Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I cannot intercept [CTRL]+[] key sequence from an application running in
a pterm.

Does it work in text mode? The qansi terminal protocol only defines a
certain number of Ctrl combinations, and there are a lot of key
combinations that don’t generate any characters.

My problem is to receive any CTRL- combinaison. I was supposed to receive a
key code for any CTRL-key pressed.

Does it work any better in text mode?

I read the keys with the following function:
inline char getch()

I hate to say this, but your code works for me… I tried Ctrl-arrows
and a few letters and they all generated some data. But Ctrl-C killed
my test program.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.