Example #1
0
		int32_t run(int _argc, char** _argv)
		{
			emscripten_set_mousedown_callback("#canvas", this, true, mouseCb);
			emscripten_set_mouseup_callback("#canvas", this, true, mouseCb);
			emscripten_set_mousemove_callback("#canvas", this, true, mouseCb);

			emscripten_set_wheel_callback("#canvas", this, true, wheelCb);

			emscripten_set_keypress_callback(NULL, this, true, keyCb);
			emscripten_set_keydown_callback(NULL, this, true, keyCb);
			emscripten_set_keyup_callback(NULL, this, true, keyCb);

			emscripten_set_resize_callback(0, this, true, resizeCb);

			EmscriptenFullscreenStrategy fullscreenStrategy = {};
			fullscreenStrategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT;
			fullscreenStrategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE;
			fullscreenStrategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
			fullscreenStrategy.canvasResizedCallback = canvasResizeCb;
			fullscreenStrategy.canvasResizedCallbackUserData = this;

			emscripten_request_fullscreen_strategy("#canvas", false, &fullscreenStrategy);

			emscripten_set_focus_callback(NULL, this, true, focusCb);
			emscripten_set_focusin_callback(NULL, this, true, focusCb);
			emscripten_set_focusout_callback(NULL, this, true, focusCb);

			int32_t result = main(_argc, _argv);
			return result;
		}
Example #2
0
	EmInputWindow::EmInputWindow(EmRenderWindow& renderWindow)
		: InputWindow()
		, m_renderWindow(renderWindow)
	{
		emscripten_set_mousemove_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseMove(*mouseEvent)); });

		emscripten_set_mousedown_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseDown(*mouseEvent)); });
		emscripten_set_mouseup_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseUp(*mouseEvent)); });

		emscripten_set_wheel_callback(0, this, true, [](int eventType, const EmscriptenWheelEvent* wheelEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectWheel(*wheelEvent)); });

		emscripten_set_keydown_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyDown(*keyEvent)); });
		emscripten_set_keyup_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyUp(*keyEvent)); });
		emscripten_set_keypress_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyPress(*keyEvent)); });

		//glfwSetScrollCallback(m_glWindow, [](GLFWwindow* w, double x, double y) { static_cast<GlInputWindow*>(glfwGetWindowUserPointer(w))->injectWheel(x, y); });

		//glfwMakeContextCurrent(m_glWindow);
		//glfwSetInputMode(m_glWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
	}