|
@ -10,34 +10,14 @@ char getch(void); |
|
|
|
|
|
|
|
|
/*int main(int argc, char ** argv){ |
|
|
/*int main(int argc, char ** argv){ |
|
|
while(1){ |
|
|
while(1){ |
|
|
//getInput(); |
|
|
|
|
|
testArrowInput(); |
|
|
|
|
|
|
|
|
getInput(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
}*/ |
|
|
|
|
|
|
|
|
void getInput(){ |
|
|
void getInput(){ |
|
|
if(kbhit()){ |
|
|
if(kbhit()){ |
|
|
char key= getch(); |
|
|
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(); |
|
|
getch(); |
|
|
char key = getch(); |
|
|
char key = getch(); |
|
|
if(key=='A'){ |
|
|
if(key=='A'){ |
|
@ -53,13 +33,29 @@ void testArrowInput(){ |
|
|
printf("left"); |
|
|
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 |
|
|
//khbit und getch aus dem Internet |
|
|
int kbhit(void){ |
|
|
int kbhit(void){ |
|
|
struct termios oldt, newt; |
|
|
struct termios oldt, newt; |
|
|