示例#1
0
void MCScreenDC::process_touch(MCEventTouchPhase p_phase, void *p_touch_handle, int32_t p_timestamp, int32_t p_x, int32_t p_y)
{
	MCActiveTouch *t_touch, *t_previous_touch;
	t_previous_touch = nil;
	for(t_touch = m_active_touches; t_touch != nil; t_previous_touch = t_touch, t_touch = t_touch -> next)
		if (t_touch -> touch == p_touch_handle)
			break;
	
	if (p_phase == kMCEventTouchPhaseBegan)
	{
		if (t_touch == nil)
		{
			uint32_t t_touch_id;
			t_touch_id = ++m_last_touch_id;
			
			t_touch = new MCActiveTouch;
			t_touch -> ident = t_touch_id;
			t_touch -> touch = p_touch_handle;
			t_touch -> next = m_active_touches;
			m_active_touches = t_touch;
		}
		else
			return;
	}
	
	if (t_touch == nil)
		return;
	
	t_touch -> x = p_x;
	t_touch -> y = p_y;
	t_touch -> timestamp = p_timestamp;
	
	MCGFloat t_scale;
	t_scale = MCResGetPixelScale();
	
	// IM-2013-08-02: [[ ResIndependence]] scale touch coords to user space
	MCEventQueuePostTouch((MCStack *)m_current_window, p_phase, t_touch -> ident, 1, p_x / t_scale, p_y / t_scale);
	
	if (p_phase == kMCEventTouchPhaseEnded || p_phase == kMCEventTouchPhaseCancelled)
	{
		if (t_previous_touch != nil)
			t_previous_touch -> next = t_touch -> next;
		else
			m_active_touches = t_touch -> next;
		
		delete t_touch;
	}
	
}
示例#2
0
文件: mbldc.cpp 项目: bduck/livecode
void MCScreenDC::process_touch(MCEventTouchPhase p_phase, void *p_touch_handle, int32_t p_timestamp, int32_t p_x, int32_t p_y)
{
	MCActiveTouch *t_touch, *t_previous_touch;
	t_previous_touch = nil;
	for(t_touch = m_active_touches; t_touch != nil; t_previous_touch = t_touch, t_touch = t_touch -> next)
		if (t_touch -> touch == p_touch_handle)
			break;
	
	if (p_phase == kMCEventTouchPhaseBegan)
	{
		if (t_touch == nil)
		{
			uint32_t t_touch_id;
			t_touch_id = ++m_last_touch_id;
			
			t_touch = new MCActiveTouch;
			t_touch -> ident = t_touch_id;
			t_touch -> touch = p_touch_handle;
			t_touch -> next = m_active_touches;
			m_active_touches = t_touch;
		}
		else
			return;
	}
	
	if (t_touch == nil)
		return;
	
	t_touch -> x = p_x;
	t_touch -> y = p_y;
	t_touch -> timestamp = p_timestamp;
	
	MCEventQueuePostTouch((MCStack *)m_current_window, p_phase, t_touch -> ident, 1, p_x, p_y);
	
	if (p_phase == kMCEventTouchPhaseEnded || p_phase == kMCEventTouchPhaseCancelled)
	{
		if (t_previous_touch != nil)
			t_previous_touch -> next = t_touch -> next;
		else
			m_active_touches = t_touch -> next;
		
		delete t_touch;
	}
	
}