Esempio n. 1
0
int
CmdWorker(q_msg *m)
{
	char *c = &(m->cmd[0]);	
	char s[MAX_MSGLEN];
	int rc; 

	NETDEBUG(MEXECD, NETLOG_DEBUG2, ("To: %x From: %x Flag: %x Cmd: %s\n",
		m->self_id, m->peer_id, m->flag, c));
	
	if (ISSET_BIT(m, OUT_BIT)) {
		rc = System(c, s, MAX_CMDLEN);	
	}
	else {
		rc = System(c, NULL, 0);
		s[0]='\0';
	}

	NETDEBUG(MEXECD, NETLOG_DEBUG2, ("Cmd returned %d\n", rc));

	if (ISSET_BIT(m, REQ_BIT)) {
		strncpy(c, s, MAX_CMDLEN);
		SendResp(m, rc);
	}

	free(m);

	return(rc);
}
Esempio n. 2
0
File: WinGL.cpp Progetto: CCQIU/CGE
GLRenderContext::GLRenderContext(uint32_t _flags)
{
	hRC = NULL;
	hWnd = NULL;
	hDC = NULL;

	backBuffer = TRUE;
	fullScreenMode = ISSET_BIT(_flags, CGE_FULLSCREEN_MODE);
	depthBuffer = ISSET_BIT(_flags, CGE_WINDOW_DEPTH);
	stencilBuffer = ISSET_BIT(_flags, CGE_WINDOW_STENCIL);
}
Esempio n. 3
0
File: EGL.cpp Progetto: CCQIU/CGE
CGE_NS_BEGIN

EGLRenderContext::EGLRenderContext(uint32_t _flags)
{
	eglDisplay = NULL;
	eglContext = NULL;
	eglContext = NULL;

	backBuffer = TRUE;
	fullScreenMode = ISSET_BIT(_flags, CGE_FULLSCREEN_MODE);
	depthBuffer = ISSET_BIT(_flags, CGE_WINDOW_DEPTH);
	stencilBuffer = ISSET_BIT(_flags, CGE_WINDOW_STENCIL);
}
Esempio n. 4
0
void f_co_readbit(bool bit)
{
	bool tmp = co_byte & (1 << 7);
	
	co_byte = co_byte << 1;
	co_byte |= bit;
	
	// check if message is real
	if(ISCLEAR_BIT(co_status, MESSAGEREADING))
	{
		if(CO_MESSAGEIDENTIFIER == co_byte)
		{
			SET_BIT(co_status, MESSAGEREADING);
			f_co_MsgCache_setPosition(0);
			tmp = 1;
		}
	}
	
	// reads byte
	if(ISSET_BIT(co_status, MESSAGEREADING) && tmp)
	{
		// ganzes byte gelesen
		f_co_processbyte(co_byte);
		co_byte = 0x01;
	}
	
	// information abspeichern fuer status
	if(bit)
		SET_BIT(co_status, LASTREADBIT);
	else
		CLEAR_BIT(co_status, LASTREADBIT);
}
Esempio n. 5
0
uint8_t f_co_getMsglength() {
	t_co_msg_header* msgheader = ((t_co_msg_header*)f_co_MsgCache_getStart());
	
	uint8_t msglength = CO_READ_HEADERSIZE + 1;
	if(ISSET_BIT(msgheader->Info, 7)){
		msglength += (msgheader->Info & 0x7f);
	}
	return msglength;
}
Esempio n. 6
0
File: UITab.cpp Progetto: CCQIU/CGE
bool_t CC_CALL UITab::userEvent(const int32_t _eventID, const cc_uint_t _data1, const cc_uint_t _data2)
{
    if (!ISSET_BIT(CGE_GUI_VISIBLE, flags) || !ISSET_BIT(CGE_GUI_ENABLED, flags)) {
        return FALSE;
    }
    
	switch(_eventID)
	{
	case CGE_GUI_LBUTTONDOWN:
        {
            int32_t left = CC_LO_WORD(_data2);
            int32_t top = CC_HI_WORD(_data2);
            
			if (hitTest(left, top) == FALSE)
				break;

			lMouseDown = TRUE;

			return TRUE;
		}
	case CGE_GUI_LBUTTONUP:
        {
            int32_t left = CC_LO_WORD(_data2);
            int32_t top = CC_HI_WORD(_data2);

			lMouseDown = FALSE;
            
			if (hitTest(left, top) == FALSE)
				break;

            if (eventCall && ISSET_BIT(CGE_GUI_EVENT_CLICK, eventFlags) == CGE_GUI_EVENT_CLICK) {
                eventCall->eventUI(id, CGE_GUI_EVENT_CLICK, _data2);
            }
			return TRUE;
		}
	}
    
    return UIBase::userEvent(_eventID, _data1, _data2);
}
Esempio n. 7
0
bool_t CC_CALL UILayer::userEvent(const int32_t _eventID, const cc_uint_t _data1, const cc_uint_t _data2)
{
    if (!ISSET_BIT(CGE_GUI_VISIBLE, flags) || !ISSET_BIT(CGE_GUI_ENABLED, flags)) {
        return FALSE;
    }

    if (UIBase::userEvent(_eventID, _data1, _data2)) {
        return TRUE;
    }

    switch(_eventID)
    {
    case CGE_GUI_LBUTTONDOWN:
    {
        int32_t left = CC_LO_WORD(_data2);
        int32_t top = CC_HI_WORD(_data2);

        if (hitTest(left, top) == FALSE)
            break;

        lMouseDown = TRUE;

        lastPosition.x = left - (int32_t)viewRect.left;
        lastPosition.y = top - (int32_t)viewRect.top;
        return TRUE;
    }
    case CGE_GUI_LBUTTONUP:
    {
        int32_t left = CC_LO_WORD(_data2);
        int32_t top = CC_HI_WORD(_data2);


        if (lMouseDown == FALSE)
            return FALSE;

        lMouseDown = FALSE;

        if (hitTest(left, top) == FALSE) {
            return FALSE;
        }

        if (eventCall && ISSET_BIT(CGE_GUI_EVENT_CLICK, eventFlags) == CGE_GUI_EVENT_CLICK) {
            eventCall->eventUI(id, CGE_GUI_EVENT_CLICK, _data2);
        }
        return TRUE;
    }
    case CGE_GUI_MOUSEMOVE:
    {
        int32_t left = CC_LO_WORD(_data2);
        int32_t top = CC_HI_WORD(_data2);

        if (hovering && lMouseDown) {
            move(left - lastPosition.x, top - lastPosition.y);
            return TRUE;
        }
        break;
    }
    }

    return FALSE;
}
Esempio n. 8
0
File: UIList.cpp Progetto: CCQIU/CGE
bool_t CC_CALL UIList::userEvent(const int32_t _eventID, const cc_uint_t _data1, const cc_uint_t _data2)
{
    if (!ISSET_BIT(CGE_GUI_VISIBLE, flags) || !ISSET_BIT(CGE_GUI_ENABLED, flags)) {
        return FALSE;
    }
    
    switch(_eventID)
    {
        case CGE_GUI_LBUTTONDOWN:
        {
            int32_t left = CC_LO_WORD(_data2);
            int32_t top = CC_HI_WORD(_data2);
            
            downSelect = -1;
            fsriction = 0.98f;
            startTime = cc_get_ticks();
            
            if (list.count <= 0) {
                return FALSE;
            }
            
            if (hitTest(left, top) == FALSE)
                return FALSE;
            
            isMoved = FALSE;
            lMouseDown = TRUE;
            
            startPosition.set(left, top);
            lastPosition.set(left, top);
            deltaPosition.set(0.0f, 0.0f);
            
            downSelect = testClicked(left, top);
            return TRUE;
        }
        case CGE_GUI_LBUTTONUP:
        {
            isMoved = FALSE;
            
            if (lMouseDown == FALSE) {
                return FALSE;
            }
            
            int32_t left = CC_LO_WORD(_data2);
            int32_t top = CC_HI_WORD(_data2);
            
            lMouseDown = FALSE;
            
            if (startPosition.x == left && startPosition.y == top) {
                deltaPosition.x = 0;
                deltaPosition.y = 0;
                
                if (downSelect == -1) {
                    return TRUE;
                }
                
                cc_double_iterator_t *findSelect = NULL;
                
                if (downSelect == testClicked(left, top)) {
                    cc_double_iterator_t *find = first;
                    for (int32_t i = offsetStart; i < offsetEnd; i++) {
                        
                        if (i == downSelect) {
                            findSelect = find;
                            break;
                        }
                        
                        if (find) {
                            find = find->next;
                        }
                    }
                    select = downSelect;
                }
                
                if (findSelect && eventCall && ISSET_BIT(CGE_GUI_EVENT_CLICK, eventFlags) == CGE_GUI_EVENT_CLICK) {
                    eventCall->eventUI(id, CGE_GUI_EVENT_CLICK, (cc_uint_t)findSelect);
                }
            } else {
                float df = UIListSpeed * delta;
                if(offset >= 0 && offset < maxOffset){
                    int32_t dealy = (int32_t)(cc_get_ticks() - startTime);
                    if (dealy > 0) {
                        if (dealy > 500) {
                            fsriction = 0.98f;
                        } else {
                            fsriction = 0.90f;
                            df *= (1000/dealy);
                        }
                        
                        if ((startPosition.y - top) < 0) {
                            df *= -1;
                        }
                        
                        deltaPosition.x += df;
                        deltaPosition.y += df;
                    }
                }
            }
            downSelect = -1;
            return TRUE;
        }
        case CGE_GUI_MOUSEMOVE:
        {
            int32_t left = CC_LO_WORD(_data2);
            int32_t top = CC_HI_WORD(_data2);
            
            if (lMouseDown == FALSE) {
                return FALSE;
            }
            
            isMoved = TRUE;
            offset += (lastPosition.y - top);
            
            deltaPosition.set(0.0f, 0.0f);
            lastPosition.set(left, top);
            
            if(offset >= 0 && offset < maxOffset) {
                first = cc_double_link_first(&list);
                if (first) {
                    offsetStart = offset / lineHeight;
                    offsetEnd = (offset + (int32_t)viewRect.getHeight() + lineHeight) / lineHeight;
                    
                    for (int32_t i = 0; i < offsetStart; i++) {
                        first = first->next;
                        if (first == NULL) {
                            break;
                        }
                    }
                }
            }
            
            return TRUE;
        }
    }
    
    return UIBase::userEvent(_eventID, _data1, _data2);
}