XBMCMove 1.0
Controlar o XBMC com gestos

XBMCMove.cpp

Go to the documentation of this file.
00001 
00009 #include "kinect.h"
00010 #include "teclado.h"
00011 #include "Socket.h"
00012 
00013 #define PORTA 9090 
00018 int main() {
00019 
00020     printf("XBMCMove iniciado!\n");
00021     Socket * xbmc = new Socket();        
00022     pthread_t thread;
00023     long t;
00024     
00025     printf("[INFO] Conectando ao XBMC!\n");
00026 
00027     do {
00028         msg = xbmc->conectar(PORTA); // Conecta ao XBMC e joga status em msg
00029         if (msg == FALHOU) {
00030             sleep(2);
00031         }
00032     } while (msg == FALHOU);
00033 
00034     rodando = true;
00035     printf("[INFO] Conectado ao XBMC!\n");
00036 
00037     xbmc->Start(); //Inicia Thread que fica ouvindo novas mensagens;
00038 
00039     printf("[INFO]Aguardando Dispositivo!\n");
00040 
00041     do {
00042         carregarKinect();
00043         if (rc != XN_STATUS_OK) {
00044             sleep(2);
00045         }
00046         msg = xbmc->getMsg();
00047         if (msg == CLOSE) {
00048             printf("[INFO] XBMC Finalizado antes de carregar dispositivo!\n");
00049             delete xbmc;
00050             return 0;
00051         }
00052     } while (rc != XN_STATUS_OK);
00053 
00054     iniciar(); //Inicia Kinect
00055 
00056     printf("[INFO]Tudo pronto! Levante sua mão para começar!\n");
00057 
00058     pthread_create(&thread, NULL, update, (void *)t);
00059 
00060     while (rodando) { // Enquanto XBMC rodando fica nesse LOOP
00061 
00062         msg = xbmc->getMsg();
00063         tipo = xbmc->getTipo();
00064 
00065         pSessao(msg,tipo); //Gerencia Sessao conforme msg e tipo
00066             
00067         rodando = !xbmc->getFechar(); //Verifica se XBMC ainda esta rodando
00068     }
00069     pthread_join(thread, NULL); //Aguarda thread ser finalizada corretamente!
00070     xbmc->setFechar(true); // Tenta fechar socket (por segurança);
00071     CleanupExit();
00072     delete xbmc;
00073     printf("\n[INFO]XBMCMove Finalizado com Sucesso!\n");
00074     return 0;
00075 
00076 }
 All Classes Files Functions Variables Defines