Exemplo n.º 1
0
void MenuItemIntString::ListUpdate(bool selected)
{
	if(selected)
	{
		if(MFInput_WasPressed(Button_DLeft, IDD_Gamepad))
		{
			--data;

			if(data<0)
				while(ppValues[data+1]) data++;

			if(pCallback)
				pCallback(this, pUserData);
		}
		else if(MFInput_WasPressed(Button_DRight, IDD_Gamepad))
		{
			++data;

			if(!ppValues[data])
				data = 0;

			if(pCallback)
				pCallback(this, pUserData);
		}
		else if(MFInput_WasPressed(Button_P2_Cross, IDD_Gamepad))
		{
			if(pCallback)
				pCallback(this, pUserData);
		}
	}
}
Exemplo n.º 2
0
		virtual bool onInterval(uint /*cycle*/) override
		{
			if (PreciseT)
			{
				// current timestamp in ms
				auto now = DateTime::NowMilliSeconds();

				// callback
				bool shouldContinue = pCallback((uint64)(now - pLastTimestamp));

				// fetch again the current to avoid taking into consideration
				// the time spent in the callback
				pLastTimestamp = DateTime::NowMilliSeconds();

				return shouldContinue;
			}
			else
			{
				// current timestamp in ms
				auto now = DateTime::NowMilliSeconds();
				uint64 elapsed = (uint64) (now - pLastTimestamp);
				pLastTimestamp = now;

				return pCallback(elapsed);
			}
		}
Exemplo n.º 3
0
void MenuItemColour::ListUpdate(bool selected)
{
	if(selected)
	{
		if(MFInput_WasPressed(Button_XB_A, IDD_Gamepad))
			pCurrentMenu = this;

		if(MFInput_WasPressed(Button_DLeft, IDD_Gamepad))
		{
			preset = preset <= 0 ? COLOUR_PRESETS-1 : preset-1;

			pData->FromPackedColour(presets[preset]);

			if(pCallback)
				pCallback(this, pUserData);
		}
		else if(MFInput_WasPressed(Button_DRight, IDD_Gamepad))
		{
			preset = preset >= COLOUR_PRESETS-1 ? 0 : preset+1;

			pData->FromPackedColour(presets[preset]);

			if(pCallback)
				pCallback(this, pUserData);
		}
	}
}
Exemplo n.º 4
0
void CBLed::doWork()
{
  if (isFading){
    if (fadingUp){
      if ((millis() - lastFadeTime) > 80){
        if (intensity < targetValue){
          int nextValue = intensity + fadeSpeed;
          if (nextValue > targetValue){
            nextValue = targetValue;
          }
          CBLed::setFade(nextValue);
        }
        else{
          isFading = false;
          if (pCallback != NULL){
            pCallback();
          }
        }
        lastFadeTime = millis();
      }
    }
    else{
      if ((millis() - lastFadeTime) > 80){
        if (intensity > targetValue){
          int nextValue = intensity - fadeSpeed;
          if (nextValue < targetValue){
            nextValue = targetValue;
          }
          CBLed::setFade(nextValue);
        }
        else{
          isFading = false;
          if (pCallback != NULL){
            pCallback();
          }
        }
        lastFadeTime = millis();
      }
    }
  }
  else if (isBlinking){
    if ((millis() - lastBlinkTime) > blinkDelay){
      if (state == LOW){
        CBLed::set(HIGH);
      }
      else{
        CBLed::set(LOW);
      }
      lastBlinkTime = millis();
    }
  }
}
Exemplo n.º 5
0
void	LinkList_TraverseListBackwards(LIST_HEADER *pListHeader,void *pData,int (*pCallback)(void *,void *))
{
LIST_NODE *pListNode;
int Status;

	if (pListHeader->pLastNode == NULL)
		return;

	if (pCallback == NULL)
		return;
		
	pListNode = pListHeader->pLastNode;
		
	do
	{
		/* Execute callback to display item in list if necessary */
		
		Status = pCallback(pData,pListNode->pNodeData);
		
		if (Status == LINKLIST_TRAVERSE_STOP)
			return;
		
		/* Go to next node */
		pListNode = pListNode->pPreviousNode;
	}
	while (pListNode != NULL);
}
Exemplo n.º 6
0
int DtaNfcDepExchangeData(const unsigned char *cmd, unsigned char cmd_len, DtaCallbackFunction *pCallback)
{
    unsigned char RspBuf[1024];
    unsigned long RspBufLen = 0;
    unsigned long nStatus = 0;
    int result = 0;

    LOGD("%s:", __FUNCTION__);
    LOGD("request buffer [%p]:length(%ld)", cmd, (unsigned long)cmd_len);

    memset(RspBuf, 0x00, 1024);
    result = JniDtaDepExchange(cmd,cmd_len,RspBuf,&RspBufLen);

    LOGD("response buffer [%p]:length(%ld),%d", RspBuf,RspBufLen, result);

    if (result == 1) // success
    {
        nStatus = 0x0000;
    }
    else
    {
        nStatus = 0x0001;
    }
    pCallback((void*)RspBuf, RspBufLen, nStatus);

    RspBufLen = 0;
    return cmd_len;
}
Exemplo n.º 7
0
void MenuItemPosition2D::ListUpdate(bool selected)
{
	if(selected)
	{
		MFVector t = *pData;
		float input;

		if(MFInput_WasPressed(Button_XB_B, IDD_Gamepad)) *pData = defaultValue;
		if(MFInput_WasPressed(Button_XB_X, IDD_Gamepad)) *pData = MakeVector(0.0f, 0.0f, 0.0f);

		if((input = MFInput_Read(Axis_RX, IDD_Gamepad)))
		{
			input = input < 0.0f ? -(input*input) : input*input;
			pData->x += input*increment*MFTimeDelta();
		}

		if((input = MFInput_Read(Axis_RY, IDD_Gamepad)))
		{
			input = input < 0.0f ? -(input*input) : input*input;
			pData->y -= input*increment*MFTimeDelta();
		}

		if(pCallback && t != *pData)
			pCallback(this, pUserData);
	}
}
Exemplo n.º 8
0
void MenuItemFloat::ListUpdate(bool selected)
{
	if(selected)
	{
		float t = *pData;
		float input;

		if(MFInput_WasPressed(Button_XB_B, IDD_Gamepad)) *pData = defaultValue;
		if(MFInput_WasPressed(Button_XB_X, IDD_Gamepad)) *pData = 0.0f;

		if(MFInput_WasPressed(Button_DLeft, IDD_Gamepad))
		{
			*pData -= increment;
		}
		else if(MFInput_WasPressed(Button_DRight, IDD_Gamepad))
		{
			*pData += increment;
		}

		if((input = MFInput_Read(Axis_RX, IDD_Gamepad)))
		{
			input = input < 0.0f ? -(input*input) : input*input;
			*pData += input*increment*MFTimeDelta();
		}

		if(*pData < minimumValue) *pData = maximumValue+(*pData-minimumValue);
		if(*pData > maximumValue) *pData = minimumValue+(*pData-maximumValue);

		if(pCallback && t != *pData)
			pCallback(this, pUserData);
	}
}
Exemplo n.º 9
0
void MenuItemInt::ListUpdate(bool selected)
{
	if(selected)
	{
		int t = *pData;

		if(MFInput_WasPressed(Button_XB_B, IDD_Gamepad)) *pData = defaultValue;
		if(MFInput_WasPressed(Button_XB_X, IDD_Gamepad)) *pData = 0;

		if(MFInput_WasPressed(Button_DLeft, IDD_Gamepad))
		{
			*pData -= increment;
		}
		else if(MFInput_WasPressed(Button_DRight, IDD_Gamepad))
		{
			*pData += increment;
		}

		if(*pData < minimumValue) *pData = maximumValue+(*pData-minimumValue);
		if(*pData > maximumValue) *pData = minimumValue+(*pData-maximumValue);

		if(pCallback && t != *pData)
			pCallback(this, pUserData);
	}
}
Exemplo n.º 10
0
int DtaIsoDslCmd(DtaCallbackFunction *pCallback)
{
    int rtn = 0;
    unsigned long nStatus = 0;
    void* ptr = NULL;

    LOGD("%s:", __FUNCTION__);

    rtn = JniDtaIsoDslCmd();

    if (0 == rtn ) // success
    {
        nStatus = 0x0000;
    }
    else if (0x0D == rtn) // timeout
    {
        nStatus = 0x0001;
    }
    else
    {
        nStatus = 0x0002;
    }
    pCallback(ptr,0,nStatus);
    return 1;
}
Exemplo n.º 11
0
HRESULT TestMarkupServices(BSTR bstrHtml, MarkupCallback *pCallback, BSTR &message)
{
	IHTMLDocument3 *pHtmlDocRoot = NULL;

	// Create the root document -- a "workspace" for parsing.
	HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pHtmlDocRoot));
	if (SUCCEEDED(hr) && pHtmlDocRoot) {
		IPersistStreamInit *pPersistStreamInit = NULL;

		hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pPersistStreamInit));
		if (SUCCEEDED(hr)) {
			// Initialize the root document to a default state -- ready for parsing.
			pPersistStreamInit->InitNew();

			IMarkupServices *pMarkupServices = NULL;
			hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pMarkupServices));
			if (SUCCEEDED(hr)) {
				IMarkupPointer *pMarkupBegin = NULL;
				IMarkupPointer *pMarkupEnd = NULL;

				// These markup pointers indicate the insertion point.
				hr = pMarkupServices->CreateMarkupPointer(&pMarkupBegin);
				if (SUCCEEDED(hr))
					hr = pMarkupServices->CreateMarkupPointer(&pMarkupEnd);

				if (SUCCEEDED(hr) && pMarkupBegin && pMarkupEnd) {
					IMarkupContainer *pMarkupContainer = NULL;

					// Parse the string -- the markup container contains the parsed HTML.
					// Markup pointers are updated to point to begining and end of new container.
					hr = pMarkupServices->ParseString(bstrHtml, 0, &pMarkupContainer, pMarkupBegin, pMarkupEnd);
					if (SUCCEEDED(hr) && pMarkupContainer) {
						IHTMLDocument3 *pHtmlDoc = NULL;

						// Retrieve the document interface to the markup container.
						hr = pMarkupContainer->QueryInterface(IID_PPV_ARGS(&pHtmlDoc));
						if (SUCCEEDED(hr) && pHtmlDoc) {
							// Invoke the user-defined action for this new fragment.
							hr = pCallback(pHtmlDoc, message);

							// Clean up.
							pHtmlDoc->Release();
						}
						pMarkupContainer->Release();
					}
					pMarkupEnd->Release();
				}
				if (pMarkupBegin)
					pMarkupBegin->Release();
				pMarkupServices->Release();
			}
			pPersistStreamInit->Release();
		}
		pHtmlDocRoot->Release();
	}
	return hr;
}
Exemplo n.º 12
0
void CBPir::doWork()
{
  int value = digitalRead(pin);
  if (value != state){
    state = value;
    movement = state == HIGH;
    pCallback(this);
  }
  lastValue = value;
}
Exemplo n.º 13
0
int DtaIsoDepExchangeData(const unsigned char *cmd, unsigned char cmd_len, DtaCallbackFunction *pCallback)
{
#if 0
    int len = cmd_len;
    int result = false;
    unsigned char *TransceiveCmd;
    LOGD("%s:", __FUNCTION__);

    TransceiveCmd = (unsigned char *)cmd;

    LOGD("DtaIsoDepExchangeData,Len(%d)",len);
    result = dta_doTransceive(TransceiveCmd, &len);
    LOGD("DtaIsoDepExchangeData,result(%d),Receive_Len(%d)",result,len);

    /*
    typedef void DtaCallbackFunction(
                   void* pCallbackParameter,
                   unsigned long nDataLength,
                   unsigned long nResult );

    */

    //if(result == TRUE)
    {
        pCallback(TransceiveCmd, len, result);
    }

    return len;
#else
    unsigned char* pRspBuf = NULL;
    unsigned long RspBufLen = 0;
    int result = 0;

    LOGD("%s:", __FUNCTION__);

    result = JniDtaRfCmd(cmd,cmd_len,&pRspBuf,&RspBufLen);
    LOGD("response buffer [%p]:length(%lu)", pRspBuf,RspBufLen);
    pCallback((void*)pRspBuf, RspBufLen, result);
    return cmd_len;
#endif
}
Exemplo n.º 14
0
int DtaRfCmd(const unsigned char *cmd, unsigned char cmd_len, DtaCallbackFunction *pCallback)
{
    unsigned char* pRspBuf = NULL;
    unsigned long RspBufLen = 0;
    int result = 0;

    LOGD("%s:", __FUNCTION__);

    result = JniDtaRfCmd(cmd,cmd_len,&pRspBuf,&RspBufLen);
    LOGD("response buffer [%p]:length(%lu)", pRspBuf,RspBufLen);
    pCallback((void*)pRspBuf, RspBufLen, result);
    return cmd_len;
}
Exemplo n.º 15
0
void MenuItemBool::ListUpdate(bool selected)
{
	if(selected)
	{
		if(MFInput_WasPressed(Button_DLeft, IDD_Gamepad) || MFInput_WasPressed(Button_DRight, IDD_Gamepad) || MFInput_WasPressed(Button_XB_A, IDD_Gamepad))
		{
			data = !data;

			if(pCallback)
				pCallback(this, pUserData);
		}
	}
}
CairoDesklet *gldi_desklets_foreach (GldiDeskletForeachFunc pCallback, gpointer user_data)
{
	CairoDesklet *pDesklet;
	GList *dl;
	for (dl = s_pDeskletList; dl != NULL; dl = dl->next)
	{
		pDesklet = dl->data;
		if (pCallback (pDesklet, user_data))
			return pDesklet;
	}
	
	return NULL;
}
Exemplo n.º 17
0
void SimpleTimer::Run()
{
    if (timerAttribs.bmEnabled == 0)
        return;

    if (TimeoutEllapsed())
    {
        if (pCallback)
            pCallback();

        if (timerAttribs.bmOneTime == 1)
            timerAttribs.bmEnabled = 0;
    }
}
Exemplo n.º 18
0
bool SchedulerTask::Run(time_t time)
{
    if (!IsSet() || !IsEnabled())
        return true;
        
    if (time >= timeToFire)
    {
        pCallback();
        
        if (countDown != DO_IT_FOREVER)
            countDown --;
            
        UpdateTime();
    }
    return true;
}
Exemplo n.º 19
0
int
MT_WaitForTasks(gboolean(*pCallback) (gpointer), int callbackTime, int autosave)
{
    int callbackLoops = callbackTime / UI_UPDATETIME;
    int waits = 0;
    int polltime = callbackLoops ? UI_UPDATETIME : callbackTime;
    guint as_source = 0;

    /* Set total tasks to wait for */
    td.totalTasks = td.addedTasks;
#if USE_GTK
    GTKSuspendInput();
#endif

    if (autosave)
        as_source = g_timeout_add(nAutoSaveTime * 60000, save_autosave, NULL);
    multi_debug("Waiting for all tasks");
    while (!WaitForAllTasks(polltime)) {
        waits++;
        if (pCallback && waits >= callbackLoops) {
            waits = 0;
            pCallback(NULL);
        }
        ProcessEvents();
    }
    if (autosave) {
        g_source_remove(as_source);
        save_autosave(NULL);
    }
    multi_debug("Done waiting for all tasks");

    td.doneTasks = td.addedTasks = 0;
    td.totalTasks = -1;

#if USE_GTK
    GTKResumeInput();
#endif
    return td.result;
}
Exemplo n.º 20
0
int
MT_WaitForTasks(gboolean(*pCallback) (gpointer), int callbackTime, int autosave)
{
    GList *member;
    guint cb_source = 0;
    guint as_source = 0;
    td.doneTasks = 0;

#if USE_GTK
    GTKSuspendInput();
#endif

    multi_debug("Waiting for all tasks");

    pCallback(NULL);
    cb_source = g_timeout_add(1000, pCallback, NULL);
    if (autosave)
        as_source = g_timeout_add(nAutoSaveTime * 60000, save_autosave, NULL);
    for (member = g_list_first(td.tasks); member; member = member->next, td.doneTasks++) {
        Task *task = member->data;
        task->fun(task->data);
        free(task->pLinkedTask);
        free(task);
        ProcessEvents();
    }
    g_list_free(td.tasks);
    if (autosave) {
        g_source_remove(as_source);
        save_autosave(NULL);
    }
    td.tasks = NULL;

#if USE_GTK
    GTKResumeInput();
#endif
    return td.result;
}
Exemplo n.º 21
0
int DynamicLibrariesSearch(String dir, String funct, DynamicLibrariesSearchCallbackFunction* pCallback, void* pCustom) throw (Exception) {
    int iLibsLoadedCount = 0;

    #if defined(WIN32)
    WIN32_FIND_DATA win32FindData;
    const String dllpattern = dir + "\\*.dll";
    HANDLE hDir = FindFirstFile(dllpattern.c_str(), &win32FindData);
    if (hDir == INVALID_HANDLE_VALUE) {
        if (GetLastError() != ERROR_FILE_NOT_FOUND) {
            throw Exception("library path '" + dir + "' doesn't exist");
        } else {
            return 0; // no file found
        }
    }

    do {
        // skip directory entries
        if (win32FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            continue;
        // dir entry name as full qualified path
        const String sPath = dir + "\\" + win32FindData.cFileName;
        // load the DLL
        HINSTANCE hinstLib;
        void* pDLL = hinstLib = LoadLibrary(sPath.c_str());
        if (!pDLL) {
            std::cerr << "Failed to load DLL: " << sPath << std::endl;
            continue;
        }

        void* pFunct = (void*)GetProcAddress(hinstLib, funct.c_str());
        if (pFunct == NULL) {
            std::cerr << "ERROR: unable to find " << funct << "() in " << sPath
                      << std::endl << std::flush;
            FreeLibrary(hinstLib);
            continue;
        }

        // call the the supplied callback function to report the found DLL
        pCallback(sPath, pDLL, pFunct, pCustom);

        iLibsLoadedCount++;

    } while (FindNextFile(hDir, &win32FindData));

    if (hDir != INVALID_HANDLE_VALUE) FindClose(hDir);

    #else // POSIX

    #if defined(__APPLE__)  /*  20071224 Toshi Nagata  */
    if (dir.find("~") == 0)
        dir.replace(0, 1, getenv("HOME"));
    #endif
    DIR* hDir = opendir(dir.c_str());
    if (!hDir) {
        throw Exception("library path '" + dir + "' doesn't exist");
    }
    for (dirent* pEntry = readdir(hDir); pEntry; pEntry = readdir(hDir)) {
        // dir entry name as full qualified path
        const String sPath = dir + "/" + pEntry->d_name;
        // skip entries that are not regular files
        struct stat entry_stat;
        if (lstat(sPath.c_str(), &entry_stat) != 0 ||
            (entry_stat.st_mode & S_IFMT) != S_IFREG)
            continue;
        // skip files that are not .so files
        if (sPath.length() < 3 ||
            sPath.substr(sPath.length() - 3) != ".so" &&
            sPath.find(".so.") == String::npos)
            continue;
        // load the DLL
        void* pDLL = dlopen(sPath.c_str(), RTLD_NOW);
        if (!pDLL) {
            std::cerr << "failed to load DLL: '" << sPath << "', cause: "
                      << dlerror() << std::endl;
            continue;
        }
        // load the requested function
        void* pFunct = dlsym(pDLL, funct.c_str());
        char* pcErr = dlerror();
        if (pcErr || !pFunct) {
            std::cerr << "ERROR: unable to find " << funct << "() in '" << sPath
                      << "'" << std::endl << std::flush;
            dlclose(pDLL);
            continue;
        }

        // call the the supplied callback function to report the found and
        // successfully opened DLL
        pCallback(sPath, pDLL, pFunct, pCustom);

        iLibsLoadedCount++;
    }
    closedir(hDir);
    #endif

    return iLibsLoadedCount;
}
Exemplo n.º 22
0
void MenuItemStatic::ListUpdate(bool selected)
{
	if(selected)
		if(pCallback && MFInput_WasPressed(Button_XB_A, IDD_Gamepad))
			pCallback(this, pUserData);
}
Exemplo n.º 23
0
void C4FileMonitor::OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) // main thread
{
	if (eEvent != Ev_FileChange) return;
	pCallback((const char *)pEventData, 0);
}
Exemplo n.º 24
0
		virtual bool onInterval(uint /*cycle*/) override
		{
			return pCallback();
		}