void Input::sendPointerWheelEvent(spStage stage, const Vector2& dir, PointerState* ps) { TouchEvent me(dir.y > 0 ? TouchEvent::WHEEL_UP : TouchEvent::WHEEL_DOWN, true, ps->getPosition()); me.index = ps->getIndex(); stage->handleEvent(&me); TouchEvent te(TouchEvent::WHEEL_DIR, true, ps->getPosition()); te.index = ps->getIndex(); te.wheelDirection = dir; stage->handleEvent(&te); }
void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps) { Vector2 p(x, y); TouchEvent me(type, true, p); me.index = ps->getIndex(); me.mouseButton = button; me.pressure = pressure; if (type == TouchEvent::TOUCH_DOWN) ps->_isPressed[button] = true; else if (type == TouchEvent::TOUCH_UP) ps->_isPressed[button] = false; ps->_position = p; LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type); stage->handleEvent(&me); if (type == TouchEvent::TOUCH_UP) { _ids[ps->getIndex() - 1] = 0; } }
void example_update() { #if MULTIWINDOW stage2->update(); SDL_Window* wnd = stage2->getAssociatedWindow(); if (core::beginRendering(wnd)) { Color clearColor(32, 32, 32, 255); Rect viewport(Point(0, 0), core::getDisplaySize()); //render all actors. Actor::render would be called also for all children stage2->render(clearColor, viewport); core::swapDisplayBuffers(wnd); } #endif }
void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps) { if (!_multiTouch && ps->getIndex() != 1 && ps != &_pointerMouse) { if (type == TouchEvent::TOUCH_UP) _ids[ps->getIndex() - 1] = 0; return; } Vector2 p(x, y); TouchEvent me(type, true, p); me.index = ps->getIndex(); me.mouseButton = button; me.pressure = pressure; if (type == TouchEvent::TOUCH_DOWN) ps->_pressed |= 1 << button; else if (type == TouchEvent::TOUCH_UP) ps->_pressed &= ~(1 << button); ps->_position = p; LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type); stage->handleEvent(&me); if (type == TouchEvent::TOUCH_UP) _ids[ps->getIndex() - 1] = 0; }
void Input::sendPointerWheelEvent(spStage stage, int scroll, PointerState* ps) { TouchEvent me(scroll > 0 ? TouchEvent::WHEEL_UP : TouchEvent::WHEEL_DOWN, true); me.index = ps->getIndex(); ps->_position = Vector2(0, 0); stage->handleEvent(&me); }
void Input::sendPointerMotionEvent(spStage stage, float x, float y, float pressure, PointerState* ps) { TouchEvent me(TouchEvent::MOVE, true, Vector2(x, y)); me.index = ps->getIndex(); me.pressure = pressure; ps->_position = Vector2(x, y); LOGD("sendPointerMotionEvent %d - (%.2f, %.2f)", me.index, x, y); stage->handleEvent(&me); }
void example_init() { //Load resources in xml file resources.loadXML("xmls/res.xml"); Test::init(); Test::instance = new TestActor; getStage()->addChild(Test::instance); //Initialize http requests HttpRequestTask::init(); #if MULTIWINDOW SDL_Window* window2 = SDL_CreateWindow("Second Oxygine Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, getStage()->getWidth(), getStage()->getHeight(), SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); stage2 = new Stage(false); stage2->setSize(getStage()->getSize()); stage2->associateWithWindow(window2); #endif }
void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps) { Vector2 p(x, y); TouchEvent me(type, true, p); me.index = ps->getIndex(); me.mouseButton = button; me.pressure = pressure; if (type == TouchEvent::TOUCH_DOWN) ps->_isPressed[button] = true; else if (type == TouchEvent::TOUCH_UP) ps->_isPressed[button] = false; ps->_position = p; LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type); stage->handleEvent(&me); if (type == TouchEvent::TOUCH_UP) { // Remove id and compact the array: // - stop on first copied zero id // - if end is reached, zero the last element int i = ps->getIndex() - 1; while (i < MAX_TOUCHES - 1) { if ((_ids[i] = _ids[i + 1]) == 0) break; _pointers[i] = _pointers[i + 1]; _pointers[i]._index = i + 1; ++i; } if (i == MAX_TOUCHES - 1) { _ids[i] = 0; _pointers[i].init(i + 1); } } }