Esempio n. 1
0
/* update_panels - Refresh the pile of panels */
void
update_panels(void)
{
	PANEL	*panel;

	/*
	 * if stdscr has been touched, touch the visible lines
	 * in each panel.
	 */

	if (is_wintouched(stdscr)) {
	    if (_Bottom_panel)
		std_touchup();

	    (void) wnoutrefresh(stdscr);
	}

	/*
	 * Refresh panals starting at the bottom of the pile.
	 * If a line in a window has been touched, touch all
	 * corresponding lines in the obscuring windows.
	 */

	for (panel = _Bottom_panel; panel; panel = panel -> above) {
		if (is_wintouched(panel -> win)) {
			if (panel -> obscured)
				touchup(panel);
			(void) wnoutrefresh(panel -> win);
		}
	}
}
Esempio n. 2
0
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
{
	struct engine* engine = (struct engine*)app->userData;
	if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
	{
		// touch event

		int action = AMotionEvent_getAction( event ) & 0xff;
		int pointer = (AMotionEvent_getAction( event ) >> 8) & 0xff;
		int flags = AMotionEvent_getFlags( event );
		int pointers = AMotionEvent_getPointerCount( event );
		int id = AMotionEvent_getPointerId( event, pointer );

		float x = AMotionEvent_getX( event, pointer );
		float y = AMotionEvent_getY( event, pointer );
		//if ( action != 2 ) LOGW("Action: %d, pointer: %d, count: %d, id: %d", action, pointer, pointers, id);
		//__android_log_print(ANDROID_LOG_VERBOSE, "test", "Action: %d, pointer: %d, count: %d, id: %d, lx: %f, ly: %f, rx: %f, ry: %f", action, pointer, pointers, id, lx, ly, rx, ry);
		switch ( action )
		{
			case 0:
			case 5: touchdown( id, x, y ); break;
			case 1:
			case 3:
			case 6: touchup( id, x, y ); break;
			case 2:
				{
				float lx = AMotionEvent_getAxisValue(event, AXIS_X, pointer);
				float ly = AMotionEvent_getAxisValue(event, AXIS_Y, pointer);
				float rx = AMotionEvent_getAxisValue(event, AXIS_Z, pointer);
				float ry = AMotionEvent_getAxisValue(event, AXIS_RZ, pointer);
				
				if((lx > joystick_treshold || lx < -joystick_treshold) || (ly > joystick_treshold || ly < -joystick_treshold)) 
				{
					touchdown( 0, lx*1000.0f, ly*1000.0f );
//					touchmoved( 0, x*100.0f, y*100.0f );
				}
				else
					touchup( 0, lx*1000.0f, ly*1000.0f );

				if((rx > joystick_treshold || rx < -joystick_treshold) || (ry > joystick_treshold || ry < -joystick_treshold))
				{
					touchdown( 1, rx*1000.0f, ry*1000.0f );
//					touchmoved( -1, x*255.0f, y*255.0f );
//					__android_log_print(ANDROID_LOG_VERBOSE, "test", "right joystick moved");
				}			
				else
					touchup( 1, rx*1000.0f, ry*1000.0f );
					// only the primary pointer sends move messages so get the other pointer positions while we are here
					if ( pointers > 1 )
					{
						int i = 1;
						for ( i = 1; i < pointers; i++ )
						{
							int id = AMotionEvent_getPointerId( event, i );
							x = AMotionEvent_getX( event, i );
							y = AMotionEvent_getY( event, i );
							touchmoved( id, x, y );
						}
					}
					break;
				}
			default: break;
		}

		return 1;
	}