コード例 #1
0
 void WiiTrackExtension::cwiidDisconnect()
 {
   if (cwiid_disconnect(m_wiimote)) {
     qDebug << "Error on wiimote disconnect";
     return;
   } else {
     qDebug() << "Disconnected from wiimote";
     m_actions.at(StartIndex)->setEnabled(true);
     m_actions.at(StopIndex)->setEnabled(false);
   }
 }
コード例 #2
0
 void WiiTrackExtension::cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[])
 { 
   int valid_source = 0;
   WiimoteDot1x = 0;
   WiimoteDot1y = 0;
   WiimoteDot2x = 0;
   WiimoteDot2y = 0;
   for (int i = 0; i < mesg_count; i++) {
     switch (mesg[i].type) {
       case CWIID_MESG_IR:
         printf("IR Report: ");
         for (int j = 0; j < CWIID_IR_SRC_COUNT; j++) {
           if (mesg[i].ir_mesg.src[j].valid) {
             valid_source = 1;
             printf("(%d,%d) ", mesg[i].ir_mesg.src[j].pos[CWIID_X],
                                mesg[i].ir_mesg.src[j].pos[CWIID_Y]);
             if (j == 0) {
               WiimoteDot1x = mesg[i].ir_mesg.src[j].pos[CWIID_X];
               WiimoteDot1y = mesg[i].ir_mesg.src[j].pos[CWIID_Y];
             } else if (j == 1) {
               WiimoteDot2x = mesg[i].ir_mesg.src[j].pos[CWIID_X];
               WiimoteDot2y = mesg[i].ir_mesg.src[j].pos[CWIID_Y];
             }
           }
         }
         if (!valid_source) {
           printf("no sources detected");
         }
         printf('\n');
         break;
       case CWIID_MESG_ERROR:
         if (cwiid_disconnect(wiimote)) {
           printf("Error on wiimote disconnect\n");
         }
         break;
       default:
         printf("Unknown Report");
         break;
     }
   }
 }
コード例 #3
0
ファイル: CWIID_WiiRemote.cpp プロジェクト: 1c0n/xbmc
/* Disconnect */
void CWiiRemote::DisconnectNow(bool startConnectThread)
{
  if (m_connected) //It shouldn't be enabled at the same time as it is connected
  {
    cwiid_disconnect(m_wiiremoteHandle);

    if (g_AllowReconnect)
    {
      CPacketNOTIFICATION notification("Wii Remote disconnected", "Press 1 and 2 to reconnect", ICON_PNG, g_BluetoothIconPath.c_str());
      notification.Send(m_Socket, m_MyAddr);
    }
    else
    {
      CPacketNOTIFICATION notification("Wii Remote disconnected", "", ICON_PNG, g_BluetoothIconPath.c_str());
      notification.Send(m_Socket, m_MyAddr);
    }

    CPacketLOG log(LOGNOTICE, "Sucessfully disconnected a WiiRemote");
    log.Send(m_Socket, m_MyAddr);
  }
  m_connected = false;
}
コード例 #4
0
ファイル: Wiimote.cpp プロジェクト: dihmuzikien/wiimotter
Wiimote::~Wiimote() {
    qDebug("closing cwiid");

    Q_ASSERT(instance);
    cwiid_disconnect(instance);
}