libConsole/cross_getch.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:50:39 +0200
changeset 68 d549894aa6a9
parent 53 6b3d7e3418c1
child 69 b5912e5f899f
permissions -rw-r--r--
Trivial Changes I have made trivial changes to the fts component and renamed the set_limit function to set_proc_limit. It makes it clear that we are dealing with LIMIT_NPROC and not LIMIT_AS settings. committer: Markus Bröker <mbroeker@largo.homelinux.org>

#include <stdio.h>
#include <jni.h>
#include <Console.h>

#ifdef WIN32
#include <conio.h>

int cross_getch ()
{
    int ch = -1;

    while (!kbhit ()) {
        ch = getch ();
    }

    return ch;
}

#else
#include <termios.h>

int cross_getch ()
{
    int ch = -1, fd = 0;
    struct termios neu, alt;

    fd = fileno (stdin);
    tcgetattr (fd, &alt);
    neu = alt;
    neu.c_lflag &= ~(ICANON | ECHO);
    tcsetattr (fd, TCSANOW, &neu);
    ch = getchar ();
    tcsetattr (fd, TCSANOW, &alt);
    return ch;
}
#endif

JNIEXPORT jint JNICALL Java_Console_getch (JNIEnv * env, jclass lass)
{
    return cross_getch ();
}