- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
How can I check if a key was pressed? I didn't found a appropriate function in the C which is used by Microtronix. Bye, Lothar.Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you referring to a key press at the console? ... like fgetc() ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
fgetc() is not a solution for me, because I only have to check if key was pressed or not. And fgetc() is waiting for a key. Bye, Lothar.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
There are a few choices of what you can do here. One is to use the inl() functions defined in linux/io.h or asm/io.h. You will have to include the nios system header file for the io structures you want to use and the base address of the buttons. The second and better 'Linux way' I would say is edit the existing altera_pio_buttons.c (or something like that) in drivers/char/ with adding support for ioctl() commands. Here you would place the inl() functions. There is a thread where I asked about drivers ect where you can find a link to some documentation on Linux device drivers. There are a lot of links here on drivers, makefiles ect. Good luck. Rual- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Lothar,
> fgetc() is not a solution for me, because I only have to check if key was > pressed or not. Okay ... I'll take a giant step into the abstract ;-) and just assume you're referring to a serial device, consonle, pty, etc. rather than some sort of custom keypad or custom hardware: You can use the select() system call with an appropriate timeout. If you just want to poll, set the timeout to zero. Regards, --Scott
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page