www.digitalmars.com         C & C++   DMDScript  

c++.chat - Re: Kbd and mouse events handling in Linux

reply "Nic Tiger" <nictiger progtech.ru> writes:
Hi guys,
I know some of you have worked enough with Linux, so I decided to ask you.

I want event handler for keyboard and mouse in console mode (at least the
notification that mouse move or key pressed/released).

Is it possible? If so, how can I do that?

I know I can poll devices for data, but this doesn't suit me (at least in
case of mouse, because I should redraw graphical cursor for it).

Desperately looking forward for an answer,
Nic Tiger.
Dec 16 2002
next sibling parent reply "Walter" <walter digitalmars.com> writes:
Check out the sources to linux Microemacs (on the web site). You get the
events by enabling raw mode, and then reading escape sequences. I never did
bother to get the mouse events, but it's the same idea. See tcap.c and
termio.c.


"Nic Tiger" <nictiger progtech.ru> wrote in message
news:atlfig$29bs$1 digitaldaemon.com...
 Hi guys,
 I know some of you have worked enough with Linux, so I decided to ask you.

 I want event handler for keyboard and mouse in console mode (at least the
 notification that mouse move or key pressed/released).

 Is it possible? If so, how can I do that?

 I know I can poll devices for data, but this doesn't suit me (at least in
 case of mouse, because I should redraw graphical cursor for it).

 Desperately looking forward for an answer,
 Nic Tiger.
Dec 16 2002
parent "Nic Tiger" <nictiger progtech.ru> writes:
Thanks for the point, but MicroEmacs uses the same way I already
investigated in svgalib sources. MicroEmacs relies on internal system
keyboard buffer and really polls it whenever it wants key.

There is no interrupt or event that it gets when key is pressed/released or
mouse moved.

The reading keyboard and mouse in raw mode is helpful, but I really need
event (interrupt) at the time when I should read them.

The problem remains, the help is appreciated.

Sincerely yours,
Nic Tiger.

"Walter" <walter digitalmars.com> сообщил/сообщила в новостях следующее:
news:atlkel$2d7b$1 digitaldaemon.com...
 Check out the sources to linux Microemacs (on the web site). You get the
 events by enabling raw mode, and then reading escape sequences. I never
did
 bother to get the mouse events, but it's the same idea. See tcap.c and
 termio.c.


 "Nic Tiger" <nictiger progtech.ru> wrote in message
 news:atlfig$29bs$1 digitaldaemon.com...
 Hi guys,
 I know some of you have worked enough with Linux, so I decided to ask
you.
 I want event handler for keyboard and mouse in console mode (at least
the
 notification that mouse move or key pressed/released).

 Is it possible? If so, how can I do that?

 I know I can poll devices for data, but this doesn't suit me (at least
in
 case of mouse, because I should redraw graphical cursor for it).

 Desperately looking forward for an answer,
 Nic Tiger.
Dec 16 2002
prev sibling next sibling parent "Nic Tiger" <nictiger progtech.ru> writes:
Now I enlarge the field of investigations.

In case if I can't do my task in console, I decided to look into X also.

Is there something like DirectX in XWindow?

The things I exactly want are:

1) Exclusive full screen mode. Full access to primary surface (video frame
buffer) without restrictions on lock/unlock times. I mean that I should be
able to lock surface on the start and unlock it in the end. If task switch
occurs, I can unlock/lock it again.

2) Access to keyboard and mouse raw data with event notification. May be it
can be done with primary thread receiving mouse/keyboard events from X, or
in DirectInput manner, doesn't matter.

Looking forward for your help,
Nic Tiger.

"Nic Tiger" <nictiger progtech.ru> said:
news:atlfig$29bs$1 digitaldaemon.com...
 Hi guys,
 I know some of you have worked enough with Linux, so I decided to ask you.

 I want event handler for keyboard and mouse in console mode (at least the
 notification that mouse move or key pressed/released).

 Is it possible? If so, how can I do that?

 I know I can poll devices for data, but this doesn't suit me (at least in
 case of mouse, because I should redraw graphical cursor for it).

 Desperately looking forward for an answer,
 Nic Tiger.
Dec 16 2002
prev sibling next sibling parent roland <--nancyetroland free.fr> writes:
Nic Tiger a Иcrit:
 Hi guys,
 I know some of you have worked enough with Linux, so I decided to ask you.
 
 I want event handler for keyboard and mouse in console mode (at least the
 notification that mouse move or key pressed/released).
 
 Is it possible? If so, how can I do that?
 
 I know I can poll devices for data, but this doesn't suit me (at least in
 case of mouse, because I should redraw graphical cursor for it).
 
 Desperately looking forward for an answer,
 Nic Tiger.
 
 
Allegro or AllegroGL see http://www.talula.demon.co.uk/allegro/ multi platform: DOS (Vesa), Linux (X or Frame Buffer), ... don't know, don't use just read the spec. in my dream i'm porting it on DOSX .. roland
Dec 16 2002
prev sibling parent reply "Nic Tiger" <nictiger progtech.ru> writes:
Excuse me for talking to myself, but I think I found the way to implement
the things (events) I want.

But I really want to know if they are performance optimal.
Is it right solution, if I create the second thread which will poll keyboard
and mouse devices every 5 ms (estimated)? Is there undesired overhead when
doing this under Linux? Or it is the usual technique?

Your qualified option is greatly appreciated.
Nic Tiger.

"Nic Tiger" <nictiger progtech.ru> сообщил/сообщила в новостях следующее:
news:atlfig$29bs$1 digitaldaemon.com...
 Hi guys,
 I know some of you have worked enough with Linux, so I decided to ask you.

 I want event handler for keyboard and mouse in console mode (at least the
 notification that mouse move or key pressed/released).

 Is it possible? If so, how can I do that?

 I know I can poll devices for data, but this doesn't suit me (at least in
 case of mouse, because I should redraw graphical cursor for it).

 Desperately looking forward for an answer,
 Nic Tiger.
Dec 17 2002
parent reply user domain.invalid writes:
Well I don't really know linux but I gues it's almost the same as 
FreeBSD, use the ioctl's to get raw-keyboard input and you should 
be able to read in blocking mode from the 
keyboard-input-file-descriptor in blocking mode (see 'termios' 
for more info) for the mouse, if I recall correctly, you just 
open the device with open and start reading event's in blocking 
mode. I possible do not poll on key/mouse events but put both 
'readers' in seperated threads and use a some eventsystem to 
process them.


Nic Tiger wrote:
 Excuse me for talking to myself, but I think I found the way to implement
 the things (events) I want.
 
 But I really want to know if they are performance optimal.
 Is it right solution, if I create the second thread which will poll keyboard
 and mouse devices every 5 ms (estimated)? Is there undesired overhead when
 doing this under Linux? Or it is the usual technique?
 
 Your qualified option is greatly appreciated.
 Nic Tiger.
 
 "Nic Tiger" <nictiger progtech.ru> сообщил/сообщила в новостях следующее:
 news:atlfig$29bs$1 digitaldaemon.com...
 
Hi guys,
I know some of you have worked enough with Linux, so I decided to ask you.

I want event handler for keyboard and mouse in console mode (at least the
notification that mouse move or key pressed/released).

Is it possible? If so, how can I do that?

I know I can poll devices for data, but this doesn't suit me (at least in
case of mouse, because I should redraw graphical cursor for it).

Desperately looking forward for an answer,
Nic Tiger.
Dec 17 2002
parent "Nic Tiger" <nictiger progtech.ru> writes:
Thanks. This is what I was hoping to hear.

Nic Tiger.

<user domain.invalid> ???????/???????? ? ???????? ?????????:
news:ato0pr$15ad$1 digitaldaemon.com...
 Well I don't really know linux but I gues it's almost the same as
 FreeBSD, use the ioctl's to get raw-keyboard input and you should
 be able to read in blocking mode from the
 keyboard-input-file-descriptor in blocking mode (see 'termios'
 for more info) for the mouse, if I recall correctly, you just
 open the device with open and start reading event's in blocking
 mode. I possible do not poll on key/mouse events but put both
 'readers' in seperated threads and use a some eventsystem to
 process them.


 Nic Tiger wrote:
 Excuse me for talking to myself, but I think I found the way to
implement
 the things (events) I want.

 But I really want to know if they are performance optimal.
 Is it right solution, if I create the second thread which will poll
keyboard
 and mouse devices every 5 ms (estimated)? Is there undesired overhead
when
 doing this under Linux? Or it is the usual technique?

 Your qualified option is greatly appreciated.
 Nic Tiger.

 "Nic Tiger" <nictiger progtech.ru> ???????/???????? ? ????????
?????????:
 news:atlfig$29bs$1 digitaldaemon.com...

Hi guys,
I know some of you have worked enough with Linux, so I decided to ask
you.
I want event handler for keyboard and mouse in console mode (at least
the
notification that mouse move or key pressed/released).

Is it possible? If so, how can I do that?

I know I can poll devices for data, but this doesn't suit me (at least
in
case of mouse, because I should redraw graphical cursor for it).

Desperately looking forward for an answer,
Nic Tiger.
Dec 17 2002