flat assembler
Message board for the users of flat assembler.

Index > Linux > Text input without the need to press ENTER:

Author
Thread Post new topic Reply to topic
naburgondux



Joined: 05 Sep 2024
Posts: 7
naburgondux 14 Nov 2024, 23:32
what i want is,as the title says,when i press any key,it automatically registers it,and store its value in some space in memory,and in a loop.
for learning purposes,im doing a simple CLI game,so how would i do this is C?
using ncurses,but i want to try this with just ansi escape codes and minimal libc functions.

how can i do this? Rolling Eyes
Post 14 Nov 2024, 23:32
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 434
Location: Australia
redsock 15 Nov 2024, 00:09
Why use libc functions in the first place? You can do what you describe with two system calls (read/write).
Post 15 Nov 2024, 00:09
View user's profile Send private message Reply with quote
naburgondux



Joined: 05 Sep 2024
Posts: 7
naburgondux 15 Nov 2024, 00:22
uhm,ive tried using the read and write calls indeed,but it still waits for me to press enter to register it.
Post 15 Nov 2024, 00:22
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 434
Location: Australia
redsock 15 Nov 2024, 00:37
Ahh yes, you need the ioctl syscall also for TCSETSF (which is what disables linemode among others). ICANON and friends ...

If you look in https://2ton.com.au/library_as_html/tui_terminal.inc.html and search for ICANON you can see where I did the same for the TUI side of my library.
Post 15 Nov 2024, 00:37
View user's profile Send private message Reply with quote
naburgondux



Joined: 05 Sep 2024
Posts: 7
naburgondux 15 Nov 2024, 00:44
cool,can you elaborate on this syscall a little further?
Post 15 Nov 2024, 00:44
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 434
Location: Australia
redsock 15 Nov 2024, 00:51
Code:
$> man 3 tcsetattr
$> man 2 ioctl    
Post 15 Nov 2024, 00:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.