keyboardupdate

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

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

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

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

Binary file not shown.
Loading…
Cancel
Save