Browse Source

testArrowInput funtionality into getInput

main
fdai7184 2 years ago
parent
commit
bbcbb2e837
  1. 44
      src/input.c

44
src/input.c

@ -10,34 +10,14 @@ char getch(void);
/*int main(int argc, char ** argv){
while(1){
//getInput();
testArrowInput();
getInput();
}
}*/
void getInput(){
if(kbhit()){
char key= getch();
if(key=='w'){
printf("W");
}
else if(key=='a'){
printf("A");
}
else if(key=='s'){
printf("S");
}
else if(key=='d'){
printf("D");
}
}
}
void testArrowInput(){
if(kbhit()){
char key1 = getch();
if(key1 == '\033'){
if(key == '\033'){
getch();
char key = getch();
if(key=='A'){
@ -53,13 +33,29 @@ void testArrowInput(){
printf("left");
}
}
else if(key1=='q'){
printf("Quit");
else{
if(key=='w'){
printf("W");
}
else if(key=='a'){
printf("A");
}
else if(key=='s'){
printf("S");
}
else if(key=='d'){
printf("D");
}
else if(key=='q'){
printf("quit");
}
}
}
}
//khbit und getch aus dem Internet
int kbhit(void){
struct termios oldt, newt;

Loading…
Cancel
Save