Example #1
0
size_t Keyboard_::write(uint8_t c)
{
	// Keydown
	{
		KeyReport keys = {0};
		if (_keyMap)
			_keyMap->charToKey(c,&keys);
		else
		{
			if (c >= 128) {
				setWriteError();
				return 0;
			}
			c = pgm_read_byte(_asciimap + c);
			if (!c) {
				setWriteError();
				return 0;
			}
			if (c & 0x80)
			{
				keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
				c &= 0x7F;
			}
			keys.keys[0] = c;
		}
		sendReport(&keys);
	}
	//	Keyup
	{
		KeyReport keys = {0};
		sendReport(&keys);
	}
	return 1;
}
Example #2
0
void Slave::solve() {

        thread_no = so.thread_no;

        srand(thread_no+1);
        
        
        clauseSizeLimits.resize(so.num_threads, so.maxClSz);
        goodClausesFrom.resize(so.num_threads, 0);
        numClausesFrom.resize(so.num_threads, 0);
        
        
        checks = rand()%int(report_freq/check_freq);

        MPI_Buffer_attach(malloc(MPI_BUFFER_SIZE), MPI_BUFFER_SIZE);

        if (FULL_DEBUG) fprintf(stderr, "Solving\n");
        sendReport();
        while (receiveJob()) {
                real_time -= wallClockTime();
//              cpu_time -= cpuTime();
                status = engine.search();
                real_time += wallClockTime();
//              cpu_time += cpuTime();
                sendReport();
        }

        sendStats();
}
Example #3
0
size_t HIDKeyboard::press(uint8_t k) {
    uint8_t modifiers;
    
    k = getKeyCode(k, &modifiers);
    
    if (k == 0) {
        if (modifiers == 0) {
            return 0;
        }
    }
    else {
        for (unsigned i = 0; i<HID_KEYBOARD_ROLLOVER; i++) {
            if (keyReport.keys[i] == k) {
                goto SEND;
            }
        }
        for (unsigned i = 0; i<HID_KEYBOARD_ROLLOVER; i++) {
            if (keyReport.keys[i] == 0) {
                keyReport.keys[i] = k;
                goto SEND;
            }
        }
        return 0;
    }

SEND:
    keyReport.modifiers |= modifiers;
    sendReport();
    return 1;
}
Example #4
0
void HIDKeyboard::releaseAll(void)
{
    memset(keyReport.keys, 0, HID_KEYBOARD_ROLLOVER);
	keyReport.modifiers = 0;
	
	sendReport();
}
Example #5
0
// release() takes the specified key out of the persistent key report and
// sends the report.  This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t Keyboard_::release(uint8_t k) 
{
	uint8_t i;
	if (k >= 136) {			// it's a non-printing key (not a modifier)
		k = k - 136;
	} else if (k >= 128) {	// it's a modifier key
		_keyReport.modifiers &= ~(1<<(k-128));
		k = 0;
	} else {				// it's a printing key
		k = pgm_read_byte(_asciimap + k);
		if (!k) {
			return 0;
		}
		if (k & 0x80) {							// it's a capital letter or other character reached with shift
			_keyReport.modifiers &= ~(0x02);	// the left shift modifier
			k &= 0x7F;
		}
	}
	
	// Test the key report to see if k is present.  Clear it if it exists.
	// Check all positions in case the key is present more than once (which it shouldn't be)
	for (i=0; i<6; i++) {
		if (0 != k && _keyReport.keys[i] == k) {
			_keyReport.keys[i] = 0x00;
		}
	}

	sendReport(&_keyReport);
	return 1;
}
Example #6
0
size_t Keyboard_::press1(uint8_t k, bool shift)
{
	uint8_t i;
  if (k >= 128 && k < 136) {	// it's a modifier key
    _keyReport.modifiers |= (1<<(k-128));

    k = 0;
  } else {
		if (shift) {						// it's a capital letter or other character reached with shift
			_keyReport.modifiers |= 0x02;	// the left shift modifier
		}
  }

	// Add k to the key report only if it's not already present
	// and if there is an empty slot.
	if (_keyReport.keys[0] != k && _keyReport.keys[1] != k && 
		_keyReport.keys[2] != k && _keyReport.keys[3] != k &&
		_keyReport.keys[4] != k && _keyReport.keys[5] != k) {
		
		for (i=0; i<6; i++) {
			if (_keyReport.keys[i] == 0x00) {
				_keyReport.keys[i] = k;
				break;
			}
		}
		if (i == 6) {
			setWriteError();
			return 0;
		}	
	}
	sendReport(&_keyReport);
	return 1;
}
PSK_Reporter::PSK_Reporter(QObject *parent) :
    QObject(parent),
    m_sequenceNumber(0)
{
    m_header_h = "000Allllttttttttssssssssiiiiiiii";

    // We use 50E2 and 50E3 for link Id
    m_rxInfoDescriptor_h = "0003002C50E200040000"
                           "8002FFFF0000768F"     // 2. Rx Call
                           "8004FFFF0000768F"     // 4. Rx Grid
                           "8008FFFF0000768F"     // 8. Rx Soft
                           "8009FFFF0000768F"     // 9. Rx Antenna
                           "0000";

    m_txInfoDescriptor_h = "0002003C50E30007"
                           "8001FFFF0000768F" // 1. Tx Call
                           "800500040000768F" // 5. Tx Freq
                           "800600010000768F" // 6. Tx snr
                           "800AFFFF0000768F" // 10. Tx Mode
                           "8003FFFF0000768F" // 3. Tx Grid
                           "800B00010000768F" // 11. Tx info src
                           "00960004";        // Report time


    qsrand(QDateTime::currentDateTime().toTime_t());
    m_randomId_h = QString("%1").arg(qrand(),8,16,QChar('0'));

    m_udpSocket = new QUdpSocket(this);
    QHostInfo::lookupHost("report.pskreporter.info", this, SLOT(dnsLookupResult(QHostInfo)));

    reportTimer = new QTimer(this);
    connect(reportTimer, SIGNAL(timeout()), this, SLOT(sendReport()));
    reportTimer->start(5*60*1000); // 5 minutes;
}
Example #8
0
void Keyboard_::send_keys( uint8_t modifiers,  int count, uint8_t* p_keys )
{
  _keyReport.modifiers = modifiers;
  if ( count > 6 ) {
    count = 6;
  }
  memcpy( _keyReport.keys, p_keys, count );
  sendReport(&_keyReport);
}
Example #9
0
iqrCRWimpl::iqrCRWimpl(QString _qstrSubject, QString _qstrCoutSumm, QWidget*, const char*):
    qstrSubject(_qstrSubject), qstrCoutSumm(_qstrCoutSumm) {

    
    setFinishEnabled( WizardPage_3, TRUE );
    connect( finishButton() , SIGNAL(clicked()), SLOT(sendReport()) );
    connect( cancelButton() , SIGNAL(clicked()), qApp, SLOT(quit()) );
    finishButton()->setText("&Send");

}
Example #10
0
void QCrashReporter::maybeSendReport()
{
    if (m_sendReportCheckBox->isChecked())
    {
        m_sendReportAnimation->show();
        m_sendReportLabel->show();
        qApp->processEvents();
        sendReport();
    }
}
void USBKeyboard::releaseAll(void)
{
    keyReport.keys[0] = 0;
    keyReport.keys[1] = 0;
    keyReport.keys[2] = 0;
    keyReport.keys[3] = 0;
    keyReport.keys[4] = 0;
    keyReport.keys[5] = 0;
    keyReport.modifiers = 0;
    sendReport();
}
Example #12
0
void CMobileGPS::clock(unsigned int ms)
{
	m_idTimer.clock(ms);

	if (m_idTimer.hasExpired()) {
		pollGPS();
		m_idTimer.start();
	}

	sendReport();
}
Example #13
0
void Keyboard_::releaseAll(void)
{
        KeyboardReport.KeyCode[0] = 0;
        KeyboardReport.KeyCode[1] = 0; 
        KeyboardReport.KeyCode[2] = 0;
        KeyboardReport.KeyCode[3] = 0; 
        KeyboardReport.KeyCode[4] = 0;
        KeyboardReport.KeyCode[5] = 0; 
        KeyboardReport.Modifier = 0;
        sendReport(&KeyboardReport);
}
Example #14
0
void Keyboard_::releaseAll(void)
{
	_keyReport.keys[0] = 0;
	_keyReport.keys[1] = 0;	
	_keyReport.keys[2] = 0;
	_keyReport.keys[3] = 0;	
	_keyReport.keys[4] = 0;
	_keyReport.keys[5] = 0;	
	_keyReport.modifiers = 0;
	sendReport(&_keyReport);
}
Example #15
0
/*****************************************************************************
 * @fn          zb_HandleOsalEvent
 *
 * @brief       The zb_HandleOsalEvent function is called by the operating
 *              system when a task event is set
 *
 * @param       event - Bitmask containing the events that have been set
 *
 * @return      none
 */
void zb_HandleOsalEvent( uint16 event )
{
  if( event & SYS_EVENT_MSG )
  {
  }

  if( event & ZB_ENTRY_EVENT )
  {
    // blind LED 1 to indicate joining a network
    HalLedBlink ( HAL_LED_1, 0, 50, 500 );
    // Set Pin Port to output
    MCU_IO_DIR_OUTPUT_PREP(0, 0);
    MCU_IO_OUTPUT_PREP(0, 0, 0);
    
    // Set Button
    MCU_IO_DIR_INPUT_PREP(0, 1);
    MCU_IO_INPUT_PREP(0,1,MCU_IO_PULLDOWN); 
    //MCU_IO_SET_HIGH(0, 1);
    // Start the device
    zb_StartRequest();
    
  }

  if ( event & MY_START_EVT )
  {
    zb_StartRequest();
  }

  if ( event & MY_REPORT_EVT )
  {
    if ( appState == APP_REPORT )
    {
      sendReport();
      osal_start_timerEx( sapi_TaskID, MY_REPORT_EVT, myReportPeriod );
    }
  }

  if ( event & MY_FIND_COLLECTOR_EVT )
  {
    // Delete previous binding
    if ( appState == APP_REPORT )
    {
      zb_BindDevice( FALSE, SENSOR_REPORT_CMD_ID, (uint8 *)NULL );
    }

    appState = APP_BIND;
    // blink LED 2 to indicate discovery and binding
    HalLedBlink ( HAL_LED_2, 0, 50, 500 );

    // Find and bind to a collector device
    zb_BindDevice( TRUE, SENSOR_REPORT_CMD_ID, (uint8 *)NULL );
  }
}
// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report.  Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t USBKeyboard::press(uint16_t key, uint16_t modifiers)
{
    bool doReport = false;
    if (key >= KEY_LEFTCTRL && key <= KEY_RIGHTGUI)
    {
       // it's a modifier key
       keyReport.modifiers |= (1 << (key - KEY_LEFTCTRL));
       key = 0;
       doReport = true;
    }

    if (key > KEY_KPHEX)
        return 0;

    if (modifiers) {
        if (modifiers > MOD_RESERVED && modifiers <= (MOD_RESERVED | 0xFF)) {
            modifiers &= 0x00FF;
            keyReport.modifiers |= modifiers;
            doReport = true;
        } else {
            modifiers = 0;
        }
    }

    // Add key to the keyReport only if it's not already present
    // and if there is an empty slot.
    if (key && keyReport.keys[0] != key && keyReport.keys[1] != key &&
        keyReport.keys[2] != key && keyReport.keys[3] != key &&
        keyReport.keys[4] != key && keyReport.keys[5] != key)
    {
        uint8_t i;
        for (i = 0; i < 6; i++)
        {
            if (keyReport.keys[i] == 0x00)
            {
                keyReport.keys[i] = key;
                doReport = true;
                break;
            }
        }
        if (i == 6)
        {
            setWriteError();
            return 0;
        }
    }

    if (doReport) {
        sendReport();
        return 1;
    }
    return 0;
}
Example #17
0
/** Execute the algorithm.
 */
void SendUsage::exec() {
  // generate the default header - this uses a cache variable
  this->generateHeader();

  std::string json = this->generateJson();
  this->setPropertyValue("Json", json);

  // send the report
  if (doSend()) {
    sendReport(json);
  } else {
    g_log.debug("Sending usage reports is disabled\n");
  }
}
Example #18
0
void
Reporting_processReportEvents(MmsMapping* self, uint64_t currentTimeInMs)
{
    LinkedList element = self->reportControls;

    while ((element = LinkedList_getNext(element)) != NULL ) {
        ReportControl* rc = (ReportControl*) element->data;

        if (rc->enabled) {
            if (rc->triggerOps & TRG_OPT_GI) {
                if (rc->gi) {
                    updateTimeOfEntry(rc, currentTimeInMs);
                    sendReport(rc, false, true);
                    rc->triggered = false;
                }
            }

            if (rc->triggerOps & TRG_OPT_INTEGRITY) {
                if (rc->intgPd > 0) {
                    if (currentTimeInMs >= rc->nextIntgReportTime) {
                        rc->nextIntgReportTime = currentTimeInMs + rc->intgPd;
                        updateTimeOfEntry(rc, currentTimeInMs);
                        sendReport(rc, true, false);
                        rc->triggered = false;
                    }
                }
            }

            if (rc->triggered) {
                if (currentTimeInMs >= rc->reportTime) {
                    sendReport(rc, false, false);
                    rc->triggered = false;
                }
            }
        }
    }
}
Example #19
0
/*****************************************************************************
 * @fn          zb_HandleOsalEvent
 *
 * @brief       The zb_HandleOsalEvent function is called by the operating
 *              system when a task event is set
 *
 * @param       event - Bitmask containing the events that have been set
 *
 * @return      none
 */
void zb_HandleOsalEvent( uint16 event )
{
  if(event & SYS_EVENT_MSG)
  {
    
  }
  
  if( event & ZB_ENTRY_EVENT )
  { 
    // blind LED 1 to indicate joining a network
#ifndef SYS_DEBUG_SH
    HalLedBlink ( HAL_LED_1, 0, 50, 500 );
#else    
    HalLedSet ( HAL_LED_1, HAL_LED_MODE_ON);
#endif
     
    // Start the device 
    zb_StartRequest();
  }
  
  if ( event & MY_REPORT_EVT )
  {
    if ( appState == APP_REPORT ) 
    {
      sendReport();
      osal_start_timerEx( sapi_TaskID, MY_REPORT_EVT, myReportPeriod );
    }
  }
  if ( event & MY_FIND_COLLECTOR_EVT )
  {
    // Delete previous binding
    if ( appState==APP_REPORT ) 
    {
      zb_BindDevice( FALSE, SENSOR_REPORT_CMD_ID, (uint8 *)NULL );
    }
    
    appState = APP_BIND;
    // blind LED 2 to indicate discovery and binding
#ifndef SYS_DEBUG_SH
    HalLedBlink ( HAL_LED_2, 0, 50, 500 );
#else
    HalLedSet ( HAL_LED_2, HAL_LED_MODE_ON);
#endif
    
    // Find and bind to a collector device
    zb_BindDevice( TRUE, SENSOR_REPORT_CMD_ID, (uint8 *)NULL );
  }
}
// release() takes the specified key out of the persistent key report and
// sends the report.  This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t USBKeyboard::release(uint16_t key, uint16_t modifiers)
{
    bool doReport = false;
    if (key >= KEY_LEFTCTRL && key <= KEY_RIGHTGUI)
    {
       // it's a modifier key
       keyReport.modifiers &= ~(1 << (key - KEY_LEFTCTRL));
       key = 0;
       doReport = true;
    }

    if (key > KEY_KPHEX)
        return 0;

    if (modifiers) {
        if (modifiers > MOD_RESERVED && modifiers <= (MOD_RESERVED | 0xFF)) {
            modifiers &= 0x00FF;
            keyReport.modifiers &= ~(modifiers);
            doReport = true;
        } else {
            modifiers = 0;
        }
    }

    // Test the key report to see if key is present.  Clear it if it exists.
    // Check all positions in case the key is present more than once (which it shouldn't be)
    if (key) {
        for (uint8_t i = 0; i < 6; i++)
        {
            if (0 != key && keyReport.keys[i] == key)
            {
                keyReport.keys[i] = 0x00;
                doReport = true;
            }
        }
    }

    if (doReport) {
        sendReport();
        return 1;
    }

    return 0;
}
Example #21
0
// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report.  Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t Keyboard_::press(uint8_t k)
{
    uint8_t i;
    if (k >= 136) {			// it's a non-printing key (not a modifier)
        k = k - 136;
    }
    else if (k >= 128) {	// it's a modifier key
        _keyReport.modifiers |= (1<<(k-128));
        k = 0;
    }
    else {				// it's a printing key
        k = pgm_read_byte(_asciimap + k);
        if (!k) {
            setWriteError();
            return 0;
        }
        if (k & 0x80) {						// it's a capital letter or other character reached with shift
            _keyReport.modifiers |= 0x02;	// the left shift modifier
            k &= 0x7F;
        }
    }

    // Add k to the key report only if it's not already present
    // and if there is an empty slot.
    if (_keyReport.keys[0] != k && _keyReport.keys[1] != k &&
            _keyReport.keys[2] != k && _keyReport.keys[3] != k &&
            _keyReport.keys[4] != k && _keyReport.keys[5] != k) {

        for (i=0; i<6; i++) {
            if (_keyReport.keys[i] == 0x00) {
                _keyReport.keys[i] = k;
                break;
            }
        }
        if (i == 6) {
            setWriteError();
            return 0;
        }
    }
    sendReport(&_keyReport);
    return 1;
}
Example #22
0
    void StatusSender::handleRead(Socket&, const std::vector<uint8_t>& newData)
    {
        const std::vector<uint8_t> clrf = {'\r', '\n'};

        data.insert(data.end(), newData.begin(), newData.end());

        for (;;)
        {
            auto i = std::search(data.begin(), data.end(), clrf.begin(), clrf.end());

            if (i == data.end())
            {
                break;
            }

            std::string line(data.begin(), i);

            if (line.empty()) // end of header
            {
                if (!startLine.empty()) // received header
                {
                    sendReport();
                    socket.close();
                    break;
                }
            }
            else
            {
                if (startLine.empty())
                {
                    startLine = line;
                }
                else
                {
                    headers.push_back(line);
                }
            }

            data.erase(data.begin(), i + 2);
        }
    }
Example #23
0
void MicroJoy::set(dataForController_t controllerData)
{
    _joystickReport.d2 = controllerData.d2;
    _joystickReport.d3 = controllerData.d3;
    _joystickReport.d4 = controllerData.d4;
    _joystickReport.d5 = controllerData.d5;
    _joystickReport.d6 = controllerData.d6;
    _joystickReport.d7 = controllerData.d7;
    _joystickReport.d8 = controllerData.d8;
    _joystickReport.d9 = controllerData.d9;
    _joystickReport.d10 = controllerData.d10;
    _joystickReport.d14 = controllerData.d14;
    _joystickReport.d15 = controllerData.d15;
    _joystickReport.d16 = controllerData.d16;

    _joystickReport.a0 = controllerData.a0;
    _joystickReport.a1 = controllerData.a1;
    _joystickReport.a2 = controllerData.a2;
    _joystickReport.a3 = controllerData.a3;

    // And send the data out!
    sendReport(&_joystickReport);
}
Example #24
0
// release() takes the specified key out of the persistent key report and
// sends the report.  This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t HIDKeyboard::release(uint8_t k)
{
    uint8_t modifiers;
    k = getKeyCode(k, &modifiers);
    
    if (k != 0) {
        for (unsigned i=0; i<HID_KEYBOARD_ROLLOVER; i++) {
             if (keyReport.keys[i] == k) {
                 keyReport.keys[i] = 0;
                 break;
             }
        }
    }
    else {
        if (modifiers == 0)
            return 0;
    }
    
    keyReport.modifiers &= ~modifiers;
    
	sendReport();
	return 1;
}
Example #25
0
size_t Keyboard_::release1(uint8_t k, bool shift)
{
	uint8_t i;
  if (k >= 128 && k < 136) {	// it's a modifier key
		_keyReport.modifiers &= ~(1<<(k-128));
    k = 0;
  } else {
		if (shift) {						// it's a capital letter or other character reached with shift
			_keyReport.modifiers &= ~(0x02);	// the left shift modifier
		}
  }

	
	// Test the key report to see if k is present.  Clear it if it exists.
	// Check all positions in case the key is present more than once (which it shouldn't be)
	for (i=0; i<6; i++) {
		if (0 != k && _keyReport.keys[i] == k) {
			_keyReport.keys[i] = 0x00;
		}
	}

	sendReport(&_keyReport);
	return 1;
}
Example #26
0
bool Slave::checkMessages() {
        //if (engine.decisionLevel() <= engine.assumptions.size()) return false;

        double t = wallClockTime();

        if (t <= next_check && engine.decisionLevel() > 0) return false;

        real_time += t;
//      cpu_time += cpuTime();

        int received;
        //fprintf(stderr, "%d: CheckMessages! \n", thread_no);
        while (true) {
                MPI_Iprobe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &received, &s);
                if (!received) break;
                switch (s.MPI_TAG) {
                        case INTERRUPT_TAG:
                                MPI_Recv(NULL, 0, MPI_INT, 0, INTERRUPT_TAG, MPI_COMM_WORLD, &s);
                                if (PAR_DEBUG) fprintf(stderr, "%d: Interrupted! %f\n", thread_no, wallClockTime());
                                real_time -= wallClockTime();
//                              cpu_time -= cpuTime();
                                return true;
                        case STEAL_TAG:
                                //fprintf(stderr, "%d asked to split job\n", thread_no);
                                splitJob();
                                break;
                        case LEARNTS_TAG:
                                //fprintf(stderr, "%d receives learnts\n", thread_no);
                                receiveLearnts();
                                
                                break;
                        case SOLUTION_TAG:
                                receiveSolution();
                          break;
                        case INT_SOLUTION_TAG:
                          assert(false && "This version does not support forwarding solution! ");
                          break;
                        case NEW_EXPORT_LIMIT:
                                // Only 1 Integer: New length
                                int newLength;
                                //fprintf(stderr, "Receiving new export limit! \n");
                                MPI_Recv(&newLength, 1, MPI_INT, 0, NEW_EXPORT_LIMIT, MPI_COMM_WORLD, &s);
                                so.maxClSz = newLength;
                                //fprintf(stderr, "Done, set to %d \n", newLength);
                          break;
                        case NEW_STATE_TAG:
                          int newState;
                          MPI_Recv(&newState, 1, MPI_INT, 0, NEW_STATE_TAG, MPI_COMM_WORLD, &s);
                          if(_state != newState){
                            if(_state == RUNNING_GREEDY)
                              engine.stop_init_phase = true;
                            _state = newState;
                            
                          }
                          MPI_Bsend(&_state, 1, MPI_INT, 0, SLAVE_NEW_STATE_TAG , MPI_COMM_WORLD);
                          break;
                        default:
                                fprintf(stderr, "assert false!\n");
                                assert(false);
                }
        }
        
        if ((++checks%int(report_freq/check_freq) == 0) 
              || unitFound){
                unitFound = false;
                sendReport();
        }

        t = wallClockTime();
        if(engine.decisionLevel() > 0)
          next_check = t + check_freq;

        real_time -= t;
        if(engine.decisionLevel() == 0){
          for(int i = 0 ; i < storedClauses.size() ; i++){
            assert(storedClauses[i].size() > 0);
            assert(storedClauses[i][0] == tmp_header[i]);
            
            // TODO: 
            vec<int> tmp;
            for(int j = 0 ; j < storedClauses[i].size() ; j++)
              tmp.push(storedClauses[i][j]);
            sat.convertToClause(tmp);
            sat.addLearnt();
          }
          storedClauses.clear();
          tmp_header.clear();
        }
        return false;
}
Example #27
0
void Joystick_::set(dataForController_t controllerData)
{
    _joystickReport.triangle_btn = controllerData.triangleOn;
    _joystickReport.square_btn = controllerData.squareOn;
    _joystickReport.cross_btn = controllerData.crossOn;
    _joystickReport.circle_btn = controllerData.circleOn;
    _joystickReport.l1_btn = controllerData.l1On;
    _joystickReport.r1_btn = controllerData.r1On;
    _joystickReport.l2_btn = controllerData.l2On;
    _joystickReport.r2_btn = controllerData.r2On;

    if (_joystickReport.triangle_btn == 1)
        _joystickReport.triangle_axis = 0xFF;
    else
        _joystickReport.triangle_axis = 0;
        
    if (_joystickReport.square_btn == 1)
        _joystickReport.square_axis = 0xFF;
    else
        _joystickReport.square_axis = 0;

    if (_joystickReport.cross_btn == 1)
        _joystickReport.cross_axis = 0xFF;
    else
        _joystickReport.cross_axis = 0;

    if (_joystickReport.circle_btn == 1)
        _joystickReport.circle_axis = 0xFF;
    else
        _joystickReport.circle_axis = 0;

    if (_joystickReport.l1_btn == 1)
        _joystickReport.l1_axis = 0xFF;
    else
        _joystickReport.l1_axis = 0;
        
    if (_joystickReport.l2_btn == 1)
        _joystickReport.l2_axis = 0xFF;
    else
        _joystickReport.l2_axis = 0;
        
    if (_joystickReport.r1_btn == 1)
        _joystickReport.r1_axis = 0xFF;
    else
        _joystickReport.r1_axis = 0;
            
    if (_joystickReport.r2_btn == 1)
        _joystickReport.r2_axis = 0xFF;
    else
        _joystickReport.r2_axis = 0;
        
    _joystickReport.select_btn = controllerData.selectOn;
    _joystickReport.start_btn = controllerData.startOn;
    _joystickReport.l3_btn = controllerData.l3On;
    _joystickReport.r3_btn = controllerData.r3On;
    _joystickReport.ps_btn = controllerData.homeOn;

    // digital direction, use the dir_* constants(enum)
    // 8 = center, 0 = up, 1 = up/right, 2 = right, 3 = right/down
    // 4 = down, 5 = down/left, 6 = left, 7 = left/up
    _joystickReport.direction = 8;
    if (controllerData.dpadUpOn == 1){
        if (controllerData.dpadLeftOn == 1){
            _joystickReport.direction = 7;
        } 
        else if (controllerData.dpadRightOn == 1){
            _joystickReport.direction = 1;
        }
        else
            _joystickReport.direction = 0;
        
    }
    else if (controllerData.dpadDownOn == 1){
                if (controllerData.dpadLeftOn == 1){
            _joystickReport.direction = 5;
        } 
        else if (controllerData.dpadRightOn == 1){
            _joystickReport.direction = 3;
        }
        else
            _joystickReport.direction = 4;		
    }
    else if (controllerData.dpadLeftOn == 1){
        _joystickReport.direction = 6;
    }
    else if (controllerData.dpadRightOn == 1){
        _joystickReport.direction = 2;
    }
            
    // left and right analog sticks, 0x00 left/up, 0x80 middle, 0xff right/down
    _joystickReport.l_x_axis = controllerData.leftStickX;
    _joystickReport.l_y_axis = controllerData.leftStickY;
    _joystickReport.r_x_axis = controllerData.rightStickX;
    _joystickReport.r_y_axis = controllerData.rightStickY;

    // And send the data out!
    sendReport(&_joystickReport);
}
Example #28
0
void Report::reportIssue( const Message& command )
{
    std::string report = command.body();
    if( !checkReport( report ) )
        sendReport( report );
}
Example #29
0
/*!
 * \brief CrashReportDialog::CrashReportDialog
 */
CrashReportDialog::CrashReportDialog()
  : QDialog(0, Qt::WindowTitleHint)
{
  setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::crashReport));
  setAttribute(Qt::WA_DeleteOnClose);
  // set heading
  mpCrashReportHeading = new Label(Helper::crashReport);
  mpCrashReportHeading->setFont(QFont(Helper::systemFontInfo.family(), Helper::headingFontSize));
  // set seperator line
  mpHorizontalLine = new QFrame();
  mpHorizontalLine->setFrameShape(QFrame::HLine);
  mpHorizontalLine->setFrameShadow(QFrame::Sunken);
  // Email label and textbox
  mpEmailLabel = new Label(tr("Your Email (in case you want us to contact you regarding this error):"));
  mpEmailTextBox = new QLineEdit;
  // bug description label and textbox
  mpBugDescriptionLabel = new Label(tr("Describe in a few words what you were doing when the error occurred:"));
  mpBugDescriptionTextBox = new QPlainTextEdit;
  // files label and checkboxes
  mpFilesDescriptionLabel = new Label(tr("Following selected files will be sent alongwith the crash report,"));
  QString& tmpPath = OpenModelica::tempDirectory();
  // omeditcommunication.log file checkbox
  QFileInfo OMEditCommunicationLogFileInfo(QString("%1omeditcommunication.log").arg(tmpPath));
  mpOMEditCommunicationLogFileCheckBox = new QCheckBox(OMEditCommunicationLogFileInfo.absoluteFilePath());
  if (OMEditCommunicationLogFileInfo.exists()) {
    mpOMEditCommunicationLogFileCheckBox->setChecked(true);
  } else {
    mpOMEditCommunicationLogFileCheckBox->setChecked(false);
  }
  // omeditcommands.mos file checkbox
  QFileInfo OMEditCommandsMosFileInfo(QString("%1omeditcommands.mos").arg(tmpPath));
  mpOMEditCommandsMosFileCheckBox = new QCheckBox(OMEditCommandsMosFileInfo.absoluteFilePath());
  if (OMEditCommandsMosFileInfo.exists()) {
    mpOMEditCommandsMosFileCheckBox->setChecked(true);
  } else {
    mpOMEditCommandsMosFileCheckBox->setChecked(false);
  }
  // openmodelica.stacktrace.OMEdit file checkbox
  QFileInfo OMStackTraceFileInfo(QString("%1openmodelica.stacktrace.%2").arg(tmpPath).arg(Helper::OMCServerName));
  mpOMStackTraceFileCheckBox = new QCheckBox(OMStackTraceFileInfo.absoluteFilePath());
  if (OMStackTraceFileInfo.exists()) {
    mpOMStackTraceFileCheckBox->setChecked(true);
  } else {
    mpOMStackTraceFileCheckBox->setChecked(false);
  }
  // create send report button
  mpSendReportButton = new QPushButton(tr("Send Report"));
  mpSendReportButton->setAutoDefault(true);
  connect(mpSendReportButton, SIGNAL(clicked()), SLOT(sendReport()));
  mpCancelButton = new QPushButton(Helper::cancel);
  connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
  // create buttons box
  mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
  mpButtonBox->addButton(mpSendReportButton, QDialogButtonBox::ActionRole);
  mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
  // set grid layout
  QGridLayout *pMainLayout = new QGridLayout;
  pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  pMainLayout->addWidget(mpCrashReportHeading, 0, 0);
  pMainLayout->addWidget(mpHorizontalLine, 1, 0);
  pMainLayout->addWidget(mpEmailLabel, 2, 0);
  pMainLayout->addWidget(mpEmailTextBox, 3, 0);
  pMainLayout->addWidget(mpBugDescriptionLabel, 4, 0);
  pMainLayout->addWidget(mpBugDescriptionTextBox, 5, 0);
  int index = 6;
  if (OMEditCommunicationLogFileInfo.exists() || OMEditCommandsMosFileInfo.exists() || OMStackTraceFileInfo.exists()) {
    pMainLayout->addWidget(mpFilesDescriptionLabel, index, 0);
    index++;
  }
  if (OMEditCommunicationLogFileInfo.exists()) {
    pMainLayout->addWidget(mpOMEditCommunicationLogFileCheckBox, index, 0);
    index++;
  }
  if (OMEditCommandsMosFileInfo.exists()) {
    pMainLayout->addWidget(mpOMEditCommandsMosFileCheckBox, index, 0);
    index++;
  }
  if (OMStackTraceFileInfo.exists()) {
    pMainLayout->addWidget(mpOMStackTraceFileCheckBox, index, 0);
    index++;
  }
  pMainLayout->addWidget(mpButtonBox, index, 0, 1, 1, Qt::AlignRight);
  setLayout(pMainLayout);
}