Beispiel #1
0
void BlackberryMain::startDisplays() {
	int num_configs;
	EGLint attrib_list[]= {
		EGL_RED_SIZE,        8,
		EGL_GREEN_SIZE,      8,
		EGL_BLUE_SIZE,       8,
		EGL_DEPTH_SIZE,      24,
		EGL_STENCIL_SIZE,    8,
		EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_NONE};

	const EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };

	screen_get_context_property_iv(screen_cxt, SCREEN_PROPERTY_DISPLAY_COUNT, &ndisplays);
	egl_disp = (EGLDisplay*)calloc(ndisplays, sizeof(EGLDisplay));
	egl_surf = (EGLSurface*)calloc(ndisplays, sizeof(EGLSurface));
	displays = (dispdata_t*)calloc(ndisplays, sizeof(dispdata_t));
	screen_win = (screen_window_t *)calloc(ndisplays, sizeof(screen_window_t ));
	screen_dpy = (screen_display_t*)calloc(ndisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(screen_cxt, SCREEN_PROPERTY_DISPLAYS, (void **)screen_dpy);

	// Common data
	int usage = SCREEN_USAGE_ROTATION | SCREEN_USAGE_OPENGL_ES2;
	int format = SCREEN_FORMAT_RGBX8888;
	int sensitivity = SCREEN_SENSITIVITY_ALWAYS;

	// Initialise every display
	for (int i = 0; i < ndisplays; i++) {
		screen_get_display_property_iv(screen_dpy[i], SCREEN_PROPERTY_TYPE, &(displays[i].type));
		screen_get_display_property_iv(screen_dpy[i], SCREEN_PROPERTY_ATTACHED, &(displays[i].attached));

		screen_create_window(&screen_win[i], screen_cxt);
		screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_FORMAT, &format);
		screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_USAGE, &usage);
		screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_SENSITIVITY, &sensitivity);
		screen_set_window_property_pv(screen_win[i], SCREEN_PROPERTY_DISPLAY, (void **)&screen_dpy[i]);

		egl_disp[i] = eglGetDisplay((EGLNativeDisplayType)i);
		eglInitialize(egl_disp[i], NULL, NULL);
		if (egl_cont == EGL_NO_CONTEXT) {
			eglChooseConfig(egl_disp[0], attrib_list, &egl_conf, 1, &num_configs);
			egl_cont = eglCreateContext(egl_disp[0], egl_conf, EGL_NO_CONTEXT, attributes);
		}

		fprintf(stderr, "Display %i: %s, %s\n", i, displayTypeString(displays[i].type), displays[i].attached ? "Attached" : "Detached");
		if (displays[i].attached)
			realiseDisplay(i);
	}
#ifdef ARM
	screen_get_display_property_iv(screen_dpy[0], SCREEN_PROPERTY_DPI, &dpi); // Only internal display has DPI
	// We only use dpi to calculate the width. Smaller aspect ratios have giant text despite high DPI.
	dpi = dpi * (((float)displays[0].width/(float)displays[0].height) / (16.0/9.0)); // Adjust to 16:9
#else
	dpi = 340.0f;
#endif
	g_dpi_scale = 210.0f / dpi;
	switchDisplay(screen_ui);
}
Beispiel #2
0
void BlackberryMain::unrealiseDisplay(int idx) {
	if (displays[idx].type != SCREEN_DISPLAY_TYPE_INTERNAL) // Always true, only external can unrealise
	{
		screen_emu = screen_ui;
		if (emulating)
			switchDisplay(screen_ui);
	}
	killDisplay(idx, false);
	displays[idx].realised = false;
}
int		DisplayManager::exec(void)
{
	int render;
	do
	{
		render = _current->show();
		if (render == 0)
			switchDisplay();
	} while (render != 1);
	return 0;
}
Beispiel #4
0
void MidiWindow::getNewNoteValue(int channel, int note, int velocity)
{
    if(isLearning) {
        learningNote->setValue(note);
        learningNote = NULL;
        isLearning = false;
        ui->btnSwitchDisplay->setEnabled(true);
        ui->btnSceneNext->setEnabled(true);
        ui->btnSceneBack->setEnabled(true);
        ui->btnTransitionUp->setEnabled(true);
        ui->btnTransitionDown->setEnabled(true);
    }
    else
    {
        if(note == ui->spinSwitchDisplay->value())
        {
            emit switchDisplay();
        }
        else if(note == ui->spinSceneNext->value())
        {
            emit sceneUp();
        }
        else if(note == ui->spinSceneBack->value())
        {
            emit sceneDown();
        }
        else if(note == ui->spinTransitionUp->value())
        {
            emit transitionUp();
        }
        else if(note == ui->spinTransitionDown->value())
        {
            emit transitionDown();
        }
    }
    saveConf();
}
Beispiel #5
0
void			Master::loop(void) {
	clock_t		t;
	clock_t		tmp;
	int			input;

	t = clock();
	_dis->render(_mods);
	while (true) {
		input = _dis->input();
		if (input == ESCFL || input == ESCNC) {
			break ;
		} else if (input == 'a' || input == 'd') {
			switchDisplay(input ==  'a' ? 1 : 0);
			_dis->start(_mods);
			_dis->render(_mods);
		}
		if ((tmp = clock() - t) > REFRESH_TIME) {
			for (std::vector<IMonitorModule *>::iterator i = _mods.begin(); i != _mods.end(); ++i) {
				(*i)->refresh();
			}
			_dis->render(_mods);
		}
	}
}
Beispiel #6
0
void BlackberryMain::realiseDisplay(int idx) {
	const EGLint egl_surfaceAttr[] = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER, EGL_NONE };
	int size[2] = { atoi(getenv("WIDTH")), atoi(getenv("HEIGHT")) };
	if (idx != 0)
		screen_get_display_property_iv(screen_dpy[idx], SCREEN_PROPERTY_SIZE, size);

	displays[idx].width = size[0];
	displays[idx].height = size[1];
	screen_set_window_property_iv(screen_win[idx], SCREEN_PROPERTY_BUFFER_SIZE, size);
	screen_create_window_buffers(screen_win[idx], 2); // Double buffered
	fprintf(stderr, "Display %i realised with %ix%i\n", idx, size[0], size[1]);

	egl_surf[idx] = eglCreateWindowSurface(egl_disp[idx], egl_conf, screen_win[idx], egl_surfaceAttr);

	// Only enable for devices with hardware QWERTY, 1:1 aspect ratio
	if ((pixel_xres == pixel_yres) && displays[idx].type != SCREEN_DISPLAY_TYPE_INTERNAL)
	{
		screen_emu = idx;
		if (emulating)
			switchDisplay(idx);
	}

	displays[idx].realised = true;
}
Beispiel #7
0
void BlackberryMain::runMain() {
	bool running = true;
	while (running && !g_quitRequested) {
		input_state.mouse_valid = false;
		input_state.accelerometer_valid = false;
		while (true) {
			// Handle Blackberry events
			bps_event_t *event = NULL;
			bps_get_event(&event, 0);
			if (event == NULL)
				break; // Ran out of events
			int domain = bps_event_get_domain(event);
			if (domain == screen_get_domain()) {
				handleInput(screen_event_get_event(event));
			} else if (domain == navigator_get_domain()) {
				switch(bps_event_get_code(event))
				{
				case NAVIGATOR_INVOKE_TARGET:
					{
						const navigator_invoke_invocation_t *invoke = navigator_invoke_event_get_invocation(event);
						if(invoke) {
							boot_filename = navigator_invoke_invocation_get_uri(invoke)+7; // Remove file://
						}
					}
					break;
				case NAVIGATOR_ORIENTATION:
					sensor_remap_coordinates(navigator_event_get_orientation_angle(event));
					break;
				case NAVIGATOR_BACK:
				case NAVIGATOR_SWIPE_DOWN:
					NativeKey(KeyInput(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE, KEY_DOWN));
					break;
				case NAVIGATOR_EXIT:
					return;
				}
			} else if (domain == sensor_get_domain()) {
				if (SENSOR_ACCELEROMETER_READING == bps_event_get_code(event)) {
					sensor_event_get_xyz(event, &(input_state.acc.y), &(input_state.acc.x), &(input_state.acc.z));
					AxisInput axis;
					axis.deviceId = DEVICE_ID_ACCELEROMETER;
					axis.flags = 0;

					axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_X;
					axis.value = input_state.acc.x;
					NativeAxis(axis);

					axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Y;
					axis.value = input_state.acc.y;
					NativeAxis(axis);

					axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Z;
					axis.value = input_state.acc.z;
					NativeAxis(axis);
				}
			}
		}
		UpdateInputState(&input_state);
		NativeUpdate(input_state);
		// Work in Progress
		// Currently: Render to HDMI port (eg. 1080p) when in game. Render to device when in menu.
		// Idea: Render to all displays. Controls go to internal, game goes to external(s).
		if (GetUIState() == UISTATE_INGAME && !emulating) {
			emulating = true;
			switchDisplay(screen_emu);
			if (g_Config.iShowFPSCounter == 4) {
				int options = SCREEN_DEBUG_STATISTICS;
				screen_set_window_property_iv(screen_win[0], SCREEN_PROPERTY_DEBUG, &options);
			}
		} else if (GetUIState() != UISTATE_INGAME && emulating) {
			emulating = false;
			switchDisplay(screen_ui);
		}
		NativeRender();
		EndInputState(&input_state);
		time_update();
		// This handles VSync
		if (emulating)
			eglSwapBuffers(egl_disp[screen_emu], egl_surf[screen_emu]);
		else
			eglSwapBuffers(egl_disp[screen_ui], egl_surf[screen_ui]);
	}
}