#ifndef _Input_H
#define _Input_H
#include <ncurses.h>
char getInput()
{
int input = getch();
char retCh;
switch (input)
{
case KEY_UP:
retCh= 'U';
break;
case KEY_LEFT:
retCh= 'L';
break;
case KEY_RIGHT:
retCh= 'R';
break;
case KEY_DOWN:
retCh= 'D';
break;
default:
retCh='X';
break;
}
return retCh;
}
#endif
Main에서 호출하는 getInput함수이다.
주의할점은 getch함수는 입력값이 있을때까지 blocking이 되는 함수이다.
따라서 메인에서
nodelay(stdscr,TRUE);
함수를 실행해야 non-blocking으로 작동해서 프로그램이 멈추지않는다.
많은 도움이 되었습니다, 감사합니다.