LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-17-2011, 06:21 AM   #1
prabhuraj
LQ Newbie
 
Registered: Aug 2011
Posts: 26

Rep: Reputation: Disabled
Reading values from standard keyboard


Hi all,
I have to write an application which will open the keyboard device file.Once the device is open, I have to define a WriteBuffer and whatever the key I press from the keyboard, the keys should be stored in the WriteBuffer and the same should be copied into the ReadBuffer and should be displayed on the console.To implement this I have to make use of the system calls in Linux.Can anyone help me in this regard?

Thanks in advance,
Prabhuraj
 
Old 08-18-2011, 12:46 AM   #2
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
Use the read, write, open and close system calls. You can run man on these guys.
 
Old 08-18-2011, 05:35 PM   #3
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Is this homework?

There is no such thing as a "keyboard device file". Usually, the standard input is used for this purpose. If you need each individual keypress, you also need to use either ncurses (curses) or the termios interface (to disable canonical mode and turn off echoing, see man termios). Normally input is line-buffered, so your program does not receive individual keypresses, only complete lines, from a terminal.

If you are writing an X11 application with a graphical user interface, then you use the X11 interfaces, not system calls. Even then there is no keyboard device; keypresses and -releases and mouse movement (and many other things) are reported as events. Events are queried from the X11 server using XNextEvent; function see the manpage for details. The net is full of X11 example programs, too.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard values for file transfer in different storages techie Linux - Hardware 13 05-27-2008 01:47 AM
bash; reading values from a file km4hr Programming 16 07-28-2005 02:07 PM
reading values for a background process shadowman21i Programming 1 12-22-2004 06:47 AM
MySQL - UNIQUE values across two columns - non-standard constraint issue benr77 Linux - General 2 11-06-2004 10:48 AM
reading bridge values from kernel anuqan Linux - Networking 3 04-14-2004 06:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration