Keyboard events

This is slightly off-topic because the info I’m looking for will be used in a
non-SDL app.

However, I’ve been going through the SDL source code trying to find out how
SDL puts stdin in raw mode in Windows. Easy to do in Linux, but I want the
app to be cross-platform. I need to get keyboard input for each key press.
Anyone know where in the SDL code (for Windows) that is initialized?

setvbuf() doesn’t work when compiled using mingw32–the Windows console input
remains in cooked mode.

Thanks for any help,
Jeff

Jeff wrote:

This is slightly off-topic because the info I’m looking for will be used in a
non-SDL app.

However, I’ve been going through the SDL source code trying to find out how
SDL puts stdin in raw mode in Windows. Easy to do in Linux, but I want the
app to be cross-platform. I need to get keyboard input for each key press.
Anyone know where in the SDL code (for Windows) that is initialized?

setvbuf() doesn’t work when compiled using mingw32–the Windows console input
remains in cooked mode.

Thanks for any help,

Did you look at ioctl()? Just a WAG

setvbuf() doesn’t work when compiled using mingw32–the Windows console
input remains in cooked mode.

Did you look at ioctl()? Just a WAG

As far as I can tell, Win32 doesn’t have ioctl.
#include <sys/ioctl.h> or
#include <ioctl.h>
both fail - “no such file”

Obviously I’m not a Windoze programmer, but there always seem to be those
who want Windows versions of my projects.

JeffOn Sunday 15 May 2005 10:54 am, Uzik wrote:

Jeff wrote:>On Sunday 15 May 2005 10:54 am, Uzik wrote:

setvbuf() doesn’t work when compiled using mingw32–the Windows console
input remains in cooked mode.

Did you look at ioctl()? Just a WAG

As far as I can tell, Win32 doesn’t have ioctl.
#include <sys/ioctl.h> or
#include <ioctl.h>
both fail - “no such file”

Obviously I’m not a Windoze programmer, but there always seem to be those
who want Windows versions of my projects.

It was in DOS so I would bet it’s still present. I used it many years ago.
Try grepping the includes to see which has the definition. Try this:

http://www.delorie.com/djgpp/doc/libc/libc_493.html

ioctl (DOS)

The DOSish version of |ioctl| performs an interrupt 0x21, function 0x44.
It takes care of supplying transfer buffers in low address regions, if
they are needed. For an exhaustive description of the various commands
and subcommands, see Ralf Brown’s interrupt list.

It is highly recommended to use only the DOS_* functions listed in
`sys/ioctl.h’.

It was in DOS so I would bet it’s still present. I used it many years ago.
Try grepping the includes to see which has the definition. Try this:
http://www.delorie.com/djgpp/doc/libc/libc_493.html

I’m using mingw32 in Linux, not djgpp. I’ve grepped all over the mingw32
include files and find no reference to ioctl.

There has to be some Win32 equivalent (right?), because SDL generates
keyboard events. So far I’ve been unable to locate the code in SDL that sets
up Windows to generate keyboard events.

I’m hoping that someone more familiar with SDL internals might already know
the answer and say something along the lines of “hey, dummy, look in
directory/subdirectory/filewhatever.c”. A two minute reply saves me hours of
banging my head against the wall :slight_smile:

Sam? Bob P.? Bill K.? Anyone?

JeffOn Sunday 15 May 2005 12:14 pm, Uzik wrote:

Jeff wrote:>On Sunday 15 May 2005 12:14 pm, Uzik wrote:

It was in DOS so I would bet it’s still present. I used it many years ago.
Try grepping the includes to see which has the definition. Try this:
http://www.delorie.com/djgpp/doc/libc/libc_493.html

I’m using mingw32 in Linux, not djgpp. I’ve grepped all over the mingw32
include files and find no reference to ioctl.

There has to be some Win32 equivalent (right?), because SDL generates
keyboard events. So far I’ve been unable to locate the code in SDL that sets
up Windows to generate keyboard events.

I’m hoping that someone more familiar with SDL internals might already know
the answer and say something along the lines of “hey, dummy, look in
directory/subdirectory/filewhatever.c”. A two minute reply saves me hours of
banging my head against the wall :slight_smile:

It’s called using INT21 and is present in DOS. As far as I knew Windows
still emulates DOS calls
so it should work. If you can find an include for it I can’t say. If you
can find docs on it using google
it’s about 3 lines of assembler to call it. Will ming let you put inline
assembler into your code?
Sorry I’m not more help. I’ve never used Ming.

Jeff wrote:>On Sunday 15 May 2005 12:14 pm, Uzik wrote:

It was in DOS so I would bet it’s still present. I used it many years ago.
Try grepping the includes to see which has the definition. Try this:
http://www.delorie.com/djgpp/doc/libc/libc_493.html

I’m using mingw32 in Linux, not djgpp. I’ve grepped all over the mingw32
include files and find no reference to ioctl.

There has to be some Win32 equivalent (right?), because SDL generates
keyboard events. So far I’ve been unable to locate the code in SDL that sets
up Windows to generate keyboard events.

I’m hoping that someone more familiar with SDL internals might already know
the answer and say something along the lines of “hey, dummy, look in
directory/subdirectory/filewhatever.c”. A two minute reply saves me hours of
banging my head against the wall :slight_smile:

Did you try to reopen() or freopen() stdin?
You might be able to set the mode that way.

As far as I can tell, Win32 doesn’t have ioctl.
#include <sys/ioctl.h> or
#include <ioctl.h>
both fail - “no such file”

Obviously I’m not a Windoze programmer, but there always seem to be those
who want Windows versions of my projects.

Check <io.h> under windows. It’s got some UNIX-ish stuff, though it’s fairly
spotty.

Just too save further traffic on the mailing list I should let everyone know
that Neil Griffiths has found the solution. Thanks Neil! Email me off list if
you would like to know how it’s done.

Thanks to everyone,
Jeff

Hello,
I use the [0-9] keys above letters on my keyboard to do events in SDL.
When I’m on a Windows operating system, there is no problem tu use them.
When I’m on a Linux operating system, I can’t to use them on my AZERTY
keyboard(FR). The program don’t respond. I must to use a QWERTY
keyboard(US).
(the problem is also in a game that I’ve played “America’s Army” see
armyops.com)

I have an idea: use SDLK_1, SDLK_2, SDLK_3, … And also: SDLK_&,
SDLK_?, SDLK_", …In the events. But maybe there is another solution,
easier?

Thanx a lot to respond and sorry for my bad English :slight_smile: