OS/2, eCS & ArcaOS - Technical > Programming

getting a single keypress?

<< < (2/2)

Rich Walsh:
Dave, I saw your post a few days ago but was unable to respond until now. I'm glad you recognized that using select() to get a keystroke on OS/2 is just a crazy-bad idea. And, since this will never be ported back to *nix, the use of KbdCharIn() may be the simplest possible to way avoid using 'stdin' (a method I would never have thought of!).

The good news is that it allows you discard just about every other line of code in your test program. There's no need to open anything - notice that it doesn't require a file descriptor. Unless termio is required elsewhere in the app, it's totally unnecessary as well. The only question I have is whether keyboard input occurs on the same thread as 'mpg123's decode/play code. If they're on separate threads, there's no need for a pointless polling loop - just let it block until a keystroke comes in, no DosSleep() needed. The final version of 'test.exe' should require no more than 8-10 lines of actual code, mostly just to display the keystroke on the console.

Dave Yeo:
Hi Rich, the test program was written by Thomas the maintainer, based on the mpg123 code. It does run on the same thread so the DosSleep()  is required and the file itself is term_posix.c with HAVE_TERMIOS a requirement and Thomas did add the comment,

--- Code: ---#ifdef __OS2__
// Hoping for properly working termios in some future (?!), but until then,
// we need keyboard access bypassing that.
--- End code ---

It does seem to work well.

Navigation

[0] Message Index

[*] Previous page

Go to full version