keyboardupdate

pull/11/head
13195980010 3 years ago
parent 9f032f7f67
commit cf0b3aaaf5

@ -1,6 +1,6 @@
#ifndef _HARDWARELISTENER_H #ifndef _HARDWARELISTENER_H
#define _HARDWARELISTENER_H #define _HARDWARELISTENER_H
#include "Djitellowhite.h"
int listenkeyboard(); int listenkeyboard(Tello T,sockaddr_in serveraddr);
int scanKeyboard(); int scanKeyboard();
#endif #endif

@ -40,6 +40,6 @@ int main(void){
//T.land(serveraddr); //T.land(serveraddr);
pthread_join(thread_receive,NULL); pthread_join(thread_receive,NULL);
listenkeyboard(); listenkeyboard(T,serveraddr);
return 0; return 0;
} }

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include "Hardwarelistener.h" #include "Hardwarelistener.h"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int scanKeyboard() int scanKeyboard()
{ {
@ -26,21 +27,25 @@ int scanKeyboard()
} }
//测试函数 //测试函数
int listenkeyboard(){ int listenkeyboard(Tello T, sockaddr_in serveraddr){
while(1){ while(1){
switch(scanKeyboard()) switch(scanKeyboard())
{ {
case (int)'w': case (int)'w':
cout << "forward"<< endl; cout << "forward"<< endl;
T.forward(serveraddr);
break; break;
case (int)'s': case (int)'s':
cout << "back" << endl; cout << "back" << endl;
T.back(serveraddr);
break; break;
case (int)'a': case (int)'a':
cout << "left" <<endl; cout << "left" <<endl;
T.left(serveraddr);
break; break;
case (int)'d': case (int)'d':
cout << "right"<<endl; cout << "right"<<endl;
T.right(serveraddr);
break; break;
} }
} }

Binary file not shown.
Loading…
Cancel
Save