static void handleScreenEvent(bps_event_t *event) { int screen_val, buttons; int pair[2]; static bool mouse_pressed = false; screen_event_t screen_event = screen_event_get_event(event); //Query type of screen event and its location on the screen screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, pair); //There is a difference between touch screen events and mouse events if (screen_val == SCREEN_EVENT_MTOUCH_RELEASE) { //This is touch screen event. add_cube((float) pair[0], (float) pair[1]); } else if (screen_val == SCREEN_EVENT_POINTER) { //This is a mouse move event, it is applicable to a device with a usb mouse or simulator screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &buttons); if (buttons == SCREEN_LEFT_MOUSE_BUTTON) { //Left mouse button is pressed mouse_pressed = true; } else { if (mouse_pressed) { //Left mouse button was released, add a cube add_cube((float) pair[0], (float) pair[1]); mouse_pressed = false; } } } }
static void process_gamepad_event(screen_event_t screen_event, int type) { screen_device_t device; screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device); input_device_t* controller = NULL; int i; for (i = 0; i < MAX_PADS; ++i) { if (device == devices[i].handle) { controller = &devices[i]; break; } } if (!controller) return; // Store the controller's new state. screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons); if (controller->analogCount > 0) screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0); if (controller->analogCount == 2) screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1); //Only player 1 //TODO: Am I missing something? Is there a better way? if((controller->port == 0) && (controller->buttons & g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey)) g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); }
static void qnx_process_keyboard_event( qnx_input_t *qnx, screen_event_t event, int type) { // Get key properties from screen event int flags = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); int cap = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); int mod = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod); // Calculate state unsigned keycode = input_keymaps_translate_keysym_to_rk(cap); bool keydown = flags & KEY_DOWN; bool keyrepeat = flags & KEY_REPEAT; // Fire keyboard event if(!keyrepeat) { input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD); } // Apply keyboard state if(keydown && !keyrepeat) { BIT_SET(qnx->keyboard_state, cap); } else if(!keydown && !keyrepeat) { BIT_CLEAR(qnx->keyboard_state, cap); } }
void PLAYBOOK_PumpEvents(_THIS) { while (1) { int rc = screen_get_event(this->hidden->screenContext, this->hidden->screenEvent, 0 /*timeout*/); if (rc) break; int type; rc = screen_get_event_property_iv(this->hidden->screenEvent, SCREEN_PROPERTY_TYPE, &type); if (rc || type == SCREEN_EVENT_NONE) break; screen_window_t window; screen_get_event_property_pv(this->hidden->screenEvent, SCREEN_PROPERTY_WINDOW, (void **)&window); if (!window && type != SCREEN_EVENT_KEYBOARD) break; switch (type) { case SCREEN_EVENT_CLOSE: SDL_PrivateQuit(); // We can't stop it from closing anyway break; case SCREEN_EVENT_PROPERTY: { int val; screen_get_event_property_iv(this->hidden->screenEvent, SCREEN_PROPERTY_NAME, &val); //fprintf(stderr, "Property change (property val=%d)\n", val); } break; case SCREEN_EVENT_POINTER: handlePointerEvent(this->hidden->screenEvent, window); break; case SCREEN_EVENT_KEYBOARD: handleKeyboardEvent(this->hidden->screenEvent); break; case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_MOVE: case SCREEN_EVENT_MTOUCH_RELEASE: handleMtouchEvent(this->hidden->screenEvent, window, type); break; } } #ifdef TOUCHPAD_SIMULATE if (state.pending[0] || state.pending[1]) { SDL_PrivateMouseMotion(state.mask, 1, state.pending[0], state.pending[1]); state.pending[0] = 0; state.pending[1] = 0; } #endif if (moveEvent.pending) { SDL_PrivateMouseMotion((moveEvent.touching?SDL_BUTTON_LEFT:0), 0, moveEvent.pos[0], moveEvent.pos[1]); moveEvent.pending = 0; } }
static void process_keyboard_event(screen_event_t event, int type) { input_device_t* controller = NULL; int i = 0; //Get Keyboard state int sym = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); int modifiers = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); int flags = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); int scan = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); int cap = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); #ifdef HAVE_BB10 //Find device that pressed the key screen_device_t device; screen_get_event_property_pv(event, SCREEN_PROPERTY_DEVICE, (void**)&device); for (i = 0; i < MAX_PADS; ++i) { if (device == devices[i].handle) { controller = &devices[i]; break; } } if (!controller) return; #else controller = &devices[0]; #endif if(controller->port == -1) return; int b; for (b = 0; b < RARCH_FIRST_CUSTOM_BIND; ++b) { if ((unsigned int)g_settings.input.binds[controller->port][b].joykey == (unsigned int)(sym&0xFF)) { if (flags & KEY_DOWN) controller->buttons |= 1 << b; else controller->buttons &= ~(1<<b); } } //TODO: Am I missing something? Is there a better way? if((controller->port == 0) && ((unsigned int)g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey == (unsigned int)(sym&0xFF))) if (flags & KEY_DOWN) g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); }
void handleScreenEvent(bps_event_t *event) { screen_event_t screen_event = screen_event_get_event(event); mtouch_event_t mtouch_event; int screen_val; int position[2]; int rc; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_MOVE: case SCREEN_EVENT_MTOUCH_RELEASE: rc = screen_get_mtouch_event(screen_event, &mtouch_event, 0); if (rc) fprintf(stderr, "Error: failed to get mtouch event\n"); rc = gestures_set_process_event(set, &mtouch_event, NULL); // No gesture detected, pass through if (!rc) { if (screen_val == SCREEN_EVENT_MTOUCH_TOUCH) MouseDown(mtouch_event.x, mtouch_event.y); else if (screen_val == SCREEN_EVENT_MTOUCH_MOVE) test->MouseMove(ConvertScreenToWorld(mtouch_event.x, mtouch_event.y)); else test->MouseUp(ConvertScreenToWorld(mtouch_event.x, mtouch_event.y)); } break; case SCREEN_EVENT_KEYBOARD: screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &screen_val); if (screen_val & KEY_DOWN) { screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM, &screen_val); if (screen_val >= ' ' && screen_val < '~') { Keyboard(screen_val, 0, 0); } else { screen_val = screen_val - 0xf000; Keyboard(screen_val, 0, 0); } } break; } }
static void qnx_process_gamepad_event( qnx_input_t *qnx, screen_event_t screen_event, int type) { int i; screen_device_t device; qnx_input_device_t* controller = NULL; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); uint64_t *state_cur = NULL; (void)type; screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device); for (i = 0; i < MAX_PADS; ++i) { if (device == qnx->devices[i].handle) { controller = (qnx_input_device_t*)&qnx->devices[i]; break; } } if (!controller) return; /* Store the controller's new state. */ screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons); state_cur = (uint64_t*)&qnx->pad_state[controller->port]; *state_cur = 0; for (i = 0; i < 20; i++) *state_cur |= (controller->buttons & (1 << i) ? (1 << i) : 0); if (controller->analogCount > 0) screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0); if (controller->analogCount == 2) screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1); /* Only user 1 * TODO: Am I missing something? Is there a better way? */ if((controller->port == 0) && (controller->buttons & settings->input.binds[0][RARCH_MENU_TOGGLE].joykey)) global->lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); }
void handleScreenEvent(bps_event_t *event) { screen_event_t screen_event = screen_event_get_event(event); int screen_val; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_KEYBOARD: screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &screen_val); if (screen_val & KEY_DOWN) { screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM,&screen_val); printf("The '%c' key was pressed\n", (char)screen_val); fflush(stdout); switch (screen_val) { case KEYCODE_I: // Display the email layout with "Send" enter key virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL, VIRTUALKEYBOARD_ENTER_SEND); break; case KEYCODE_O: // Display the phone layout with "Connect" enter key virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_PHONE, VIRTUALKEYBOARD_ENTER_CONNECT); break; case KEYCODE_P: // Display the default layout with default enter key virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT); break; case KEYCODE_H: // Hide the keyboard virtualkeyboard_hide(); break; case KEYCODE_A: // Increment rotation angle angle = fmod(angle + ANGLE_INCREMENT, CIRCLE_DEGREES ); break; case KEYCODE_Z: // Decrement rotation angle angle = fmod(angle - ANGLE_INCREMENT, CIRCLE_DEGREES ); break; default: break; } } break; } }
static void qnx_process_gamepad_event( qnx_input_t *qnx, screen_event_t screen_event, int type) { int i; screen_device_t device; qnx_input_device_t* controller = NULL; uint64_t *state_cur = NULL; (void)type; screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device); for (i = 0; i < MAX_PADS; ++i) { if (device == qnx->devices[i].handle) { controller = (qnx_input_device_t*)&qnx->devices[i]; break; } } if (!controller) return; /* Store the controller's new state. */ screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons); if (controller->analogCount > 0) { screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0); controller->analog0[0] *= 256; controller->analog0[1] *= 256; if (controller->analogCount == 2) { screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1); controller->analog1[0] *= 256; controller->analog1[1] *= 256; } } }
bool ScreenWindow::pollEvent(WinEvent *event) { bps_event_t *bpsEvent; bps_get_event(&bpsEvent, 0); if (bpsEvent) { int domain = bps_event_get_domain(bpsEvent); if (domain == navigator_get_domain()) { if (bps_event_get_code(bpsEvent) == NAVIGATOR_EXIT) { event->type = QUIT; return true; } } else if (domain == screen_get_domain()) { screen_event_t se = screen_event_get_event(bpsEvent); int type; screen_get_event_property_iv(se, SCREEN_PROPERTY_TYPE, &type); if (type == SCREEN_EVENT_CLOSE) { event->type = QUIT; return true; } else if (type == SCREEN_EVENT_MTOUCH_TOUCH) { event->type = MOUSEBUTTONDOWN; return true; } } } return false; }
bool WindowGrabber::handleScreenEvent(screen_event_t screen_event) { int eventType; if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) { qWarning() << "WindowGrabber: Failed to query screen event type"; return false; } if (eventType != SCREEN_EVENT_CREATE) return false; screen_window_t window = 0; if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) { qWarning() << "WindowGrabber: Failed to query window property"; return false; } const int maxIdStrLength = 128; char idString[maxIdStrLength]; if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) { qWarning() << "WindowGrabber: Failed to query window ID string"; return false; } if (m_windowId == idString) { m_window = window; start(); } return false; }
void handleScreenEvent(bps_event_t *event) { screen_event_t screen_event = screen_event_get_event(event); int screen_val; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); mtouch_event_t mtouch_event; int rc = screen_get_mtouch_event(screen_event, &mtouch_event, 0); if (rc) { //fprintf(stderr, "Error: failed to get mtouch event\n"); } p = points.begin(); bool found; found = false; while (p != points.end()) { if (p->id == mtouch_event.contact_id) { found = true; break; } p++; } switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: if (!found) { Touchpoint *tp = new Touchpoint(mtouch_event.x, mtouch_event.y, mtouch_event.contact_id); if(mtouch_event.contact_id<4){ tp->setColor(colors[mtouch_event.contact_id][0],colors[mtouch_event.contact_id][1],colors[mtouch_event.contact_id][2]); } points.push_back(*tp); fprintf(stderr,"neuer touchpoint: %i Orientation: %i \n",mtouch_event.contact_id,tp->startRotation); } else { p->updatePosition(mtouch_event.x, mtouch_event.y); } break; case SCREEN_EVENT_MTOUCH_MOVE: if (found) { p->updatePosition(mtouch_event.x, mtouch_event.y); } else { fprintf(stderr, "ERROR: TOUCH POINT NOT FOUND\n"); } break; case SCREEN_EVENT_MTOUCH_RELEASE: if (found) { p->setInvisible(); } else { fprintf(stderr, "ERROR: TOUCH POINT NOT FOUND\n"); } break; } }
int NativeWindow::screenDisplayAttached(bps_event_t *event, int *size) { screen_display_t eventDisplay; int type; int attached = -1; screen_event_t screen_event = screen_event_get_event(event); //Query type of screen event and its location on the screen screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &type); _displaysMutex.lock(); if (_screenDisplays) { free (_screenDisplays); } // try this first as it will fail if an HDMI display is not attached screen_get_context_property_iv(_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &_numberDisplays); _screenDisplays = (screen_display_t *)calloc(_numberDisplays, sizeof(screen_display_t)); screen_get_context_property_pv(_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)_screenDisplays); switch (type) { case SCREEN_EVENT_DISPLAY: screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DISPLAY, (void **)&eventDisplay); for (int index = 0; index < _numberDisplays; index++) { if (eventDisplay == _screenDisplays[index]) { screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ATTACHED, &attached); if (attached) { screen_get_display_property_iv(_screenDisplays[index], SCREEN_PROPERTY_SIZE, size); if (size[0] == 0 || size[1] == 0) { attached = 0; } } } } break; } _displaysMutex.unlock(); return attached; }
static void qnx_process_joystick_event(qnx_input_t *qnx, screen_event_t screen_event, int type) { int displacement[2]; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_DISPLACEMENT, displacement); if(displacement != 0) { qnx->trackpad_acc[0] += displacement[0]; if(abs(qnx->trackpad_acc[0]) > TRACKPAD_THRESHOLD) { if(qnx->trackpad_acc < 0) { input_keyboard_event(true, RETROK_LEFT, 0, 0, RETRO_DEVICE_KEYBOARD); input_keyboard_event(false, RETROK_LEFT, 0, 0, RETRO_DEVICE_KEYBOARD); } else if(qnx->trackpad_acc > 0) { input_keyboard_event(true, RETROK_RIGHT, 0, 0, RETRO_DEVICE_KEYBOARD); input_keyboard_event(false, RETROK_RIGHT, 0, 0, RETRO_DEVICE_KEYBOARD); } qnx->trackpad_acc[0] = 0; } qnx->trackpad_acc[1] += displacement[1]; if(abs(qnx->trackpad_acc[1]) > TRACKPAD_THRESHOLD) { if(qnx->trackpad_acc < 0) { input_keyboard_event(true, RETROK_UP, 0, 0, RETRO_DEVICE_KEYBOARD); input_keyboard_event(false, RETROK_UP, 0, 0, RETRO_DEVICE_KEYBOARD); } else if(qnx->trackpad_acc > 0) { input_keyboard_event(true, RETROK_DOWN, 0, 0, RETRO_DEVICE_KEYBOARD); input_keyboard_event(false, RETROK_DOWN, 0, 0, RETRO_DEVICE_KEYBOARD); } qnx->trackpad_acc[1] = 0; } } int buttons = 0; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &buttons); input_keyboard_event(buttons != 0, RETROK_RETURN, 0, 0, RETRO_DEVICE_KEYBOARD); }
static void handlePointerEvent(screen_event_t event, screen_window_t window) { int buttonState = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState); int coords[2]; screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, coords); int screen_coords[2]; screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, screen_coords); int wheel_delta; screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel_delta); if (coords[1] < 0) { fprintf(stderr, "Detected pointer swipe event: %d,%d\n", coords[0], coords[1]); return; } //fprintf(stderr, "Pointer: %d,(%d,%d),(%d,%d),%d\n", buttonState, coords[0], coords[1], screen_coords[0], screen_coords[1], wheel_delta); if (wheel_delta != 0) { int button; if ( wheel_delta > 0 ) button = SDL_BUTTON_WHEELDOWN; else if ( wheel_delta < 0 ) button = SDL_BUTTON_WHEELUP; SDL_PrivateMouseButton( SDL_PRESSED, button, 0, 0); SDL_PrivateMouseButton( SDL_RELEASED, button, 0, 0); } // FIXME: Pointer events have never been tested. static int lastButtonState = 0; if (lastButtonState == buttonState) { moveEvent.touching = buttonState; moveEvent.pos[0] = coords[0]; moveEvent.pos[1] = coords[1]; moveEvent.pending = 1; return; } lastButtonState = buttonState; SDL_PrivateMouseButton(buttonState ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT, coords[0], coords[1]); // FIXME: window moveEvent.pending = 0; }
static void event(bps_event_t *event, int domain, int code, void *data) { if(domain == screen_get_domain()) { screen_event_t screenEvent = screen_event_get_event(event); int eventType; screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType); if(eventType == SCREEN_EVENT_MTOUCH_TOUCH/* || eventType == SCREEN_EVENT_MTOUCH_MOVE*/) { int pair[2]; screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, pair); Game::OnScreenTouch(pair[0], pair[1]); } } }
static void handleKeyboardEvent(screen_event_t event) { static const int KEYBOARD_TYPE_MASK = 0x20; int sym = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); int modifiers = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); int flags = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); int scan = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); int cap = 0; screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); int shifted = 0; SDL_keysym keysym; if (flags & KEYBOARD_TYPE_MASK) { if (!TranslateBluetoothKeyboard(sym, modifiers, flags, scan, cap, &keysym)) { return; // No translation } } else { shifted = TranslateVKB(sym, modifiers, flags, scan, cap, &keysym); } if (shifted) { SDL_keysym temp; temp.scancode = 42; temp.sym = SDLK_LSHIFT; SDL_PrivateKeyboard(SDL_PRESSED, &temp); } SDL_PrivateKeyboard((flags & 0x1)?SDL_PRESSED:SDL_RELEASED, &keysym); if (shifted) { SDL_keysym temp; temp.scancode = 42; temp.sym = SDLK_LSHIFT; SDL_PrivateKeyboard(SDL_RELEASED, &temp); } }
static void handle_screen_event(bps_event_t *event) { int screen_val; screen_event_t screen_event = screen_event_get_event(event); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: fprintf(stderr,"Touch event\n"); touch = true; break; case SCREEN_EVENT_MTOUCH_MOVE: fprintf(stderr,"Move event\n"); break; case SCREEN_EVENT_MTOUCH_RELEASE: fprintf(stderr,"Release event\n"); break; case SCREEN_EVENT_CREATE: // in a more involved application, it may be wise to actually check the window name to ensure // that we are processing the viewfinder window here, and not some other window if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { perror("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); } else { fprintf(stderr,"viewfinder window found!\n"); // mirror viewfinder if this is the front-facing camera int i = (shouldmirror?1:0); screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_MIRROR, &i); // place viewfinder in front of the black application background window. // note that a child window's ZORDER is relative to it's parent. // if we wanted to draw a UI on the application window, we could place the // viewfinder behind it and rely on transparency. or alternately, another // child window could be overlaid on top of the viewfinder. i = +1; screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); // make viewfinder window visible i = 1; screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); screen_flush_context(screen_ctx, 0); // we should now have a visible viewfinder // other things we could do here include rotating the viewfinder window (screen rotation), // or adjusting the size & position of the window. // some properties are immutable for security reasons since the window was actually created // in another process. anything related to presentation should be modifiable. touch = false; state = STATE_VIEWFINDER; } break; default: break; } }
bool QQnxScreenEventHandler::handleEvent(screen_event_t event) { // get the event type errno = 0; int qnxType; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType); if (result) { qFatal("QQNX: failed to query event type, errno=%d", errno); } return handleEvent(event, qnxType); }
void handleScreenEvent(bps_event_t *event) { screen_event_t screen_event = screen_event_get_event(event); int screen_val; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_MOVE: case SCREEN_EVENT_MTOUCH_RELEASE: break; } }
void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event) { // get flags of key event errno = 0; int flags; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); if (result) { qFatal("QQNX: failed to query event flags, errno=%d", errno); } // get key code errno = 0; int sym; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); if (result) { qFatal("QQNX: failed to query event sym, errno=%d", errno); } int modifiers; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); if (result) { qFatal("QQNX: failed to query event modifiers, errno=%d", errno); } int scan; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); if (result) { qFatal("QQNX: failed to query event modifiers, errno=%d", errno); } int cap; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); if (result) { qFatal("QQNX: failed to query event cap, errno=%d", errno); } injectKeyboardEvent(flags, sym, modifiers, scan, cap); }
void MinutesPerGameRenderer::screenEvent(bps_event_t *event) { screen_event_t screen_event = screen_event_get_event(event); int screen_val; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_RELEASE: break; case SCREEN_EVENT_MTOUCH_MOVE: break; } }
void QBBScreenEventThread::run() { screen_event_t event; // create screen event errno = 0; int result = screen_create_event(&event); if (result) qFatal("QBB: failed to create screen event, errno=%d", errno); #if defined(QBBSCREENEVENTTHREAD_DEBUG) qDebug() << "QBB: screen event thread started"; #endif // loop indefinitely while (!mQuit) { // block until screen event is available errno = 0; result = screen_get_event(mContext, event, -1); if (result) qFatal("QBB: failed to get screen event, errno=%d", errno); // process received event errno = 0; int qnxType; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType); if (result) qFatal("QBB: failed to query screen event type, errno=%d", errno); if (qnxType == SCREEN_EVENT_USER) { // treat all screen user events as shutdown requests #if defined(QBBSCREENEVENTTHREAD_DEBUG) qDebug() << "QBB: QNX screen user event"; #endif mQuit = true; } else { mEventHandler->handleEvent(event, qnxType); } } #if defined(QBBSCREENEVENTTHREAD_DEBUG) qDebug() << "QBB: screen event thread stopped"; #endif // cleanup screen_destroy_event(event); }
static void gfx_ctx_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; //Request and process all available BPS events bps_event_t *event = NULL; bps_get_event(&event, 0); *quit = false; unsigned new_width, new_height; gfx_ctx_get_video_size(&new_width, &new_height); if (new_width != *width || new_height != *height) { *width = new_width; *height = new_height; *resize = true; } if (event) { int domain = bps_event_get_domain(event); if (domain == screen_get_domain()) { screen_event_t screen_event = screen_event_get_event(event); int screen_val; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_MOVE: case SCREEN_EVENT_MTOUCH_RELEASE: break; } } else if ((domain == navigator_get_domain()) && (NAVIGATOR_EXIT == bps_event_get_code(event))) g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); } // Check if we are exiting. if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) *quit = true; }
void QBBEventThread::dispatchEvent(screen_event_t event) { // get the event type errno = 0; int qnxType; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType); if (result) { qFatal("QBB: failed to query event type, errno=%d", errno); } switch (qnxType) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_MOVE: case SCREEN_EVENT_MTOUCH_RELEASE: handleTouchEvent(event, qnxType); break; case SCREEN_EVENT_KEYBOARD: handleKeyboardEvent(event); break; case SCREEN_EVENT_POINTER: handlePointerEvent(event); break; case SCREEN_EVENT_CLOSE: handleCloseEvent(event); break; case SCREEN_EVENT_USER: // treat all user events as shutdown requests #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: QNX user event"; #endif mQuit = true; break; default: // event ignored #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: QNX unknown event"; #endif break; } }
void BbVideoWindowControl::bpsEventHandler(bps_event_t *event) { if (event && bps_event_get_domain(event) == screen_get_domain()) { const screen_event_t screen_event = screen_event_get_event(event); int eventType; if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) { perror("BbVideoWindowControl: Failed to query screen event type"); return; } if (eventType != SCREEN_EVENT_CREATE) return; screen_window_t window = 0; if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) { perror("BbVideoWindowControl: Failed to query window property"); return; } const int maxIdStrLength = 128; char idString[maxIdStrLength]; if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) { perror("BbVideoWindowControl: Failed to query window ID string"); return; } if (m_windowName == idString) { m_window = window; updateVideoPosition(); const int visibleFlag = 1; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visibleFlag) != 0) { perror("BbVideoWindowControl: Failed to make window visible"); return; } } } }
bool WindowGrabber::nativeEventFilter(const QByteArray&, void *message, long*) { bps_event_t * const event = static_cast<bps_event_t *>(message); if (event && bps_event_get_domain(event) == screen_get_domain()) { const screen_event_t screen_event = screen_event_get_event(event); int eventType; if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) { qWarning() << "WindowGrabber: Failed to query screen event type"; return false; } if (eventType != SCREEN_EVENT_CREATE) return false; screen_window_t window = 0; if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) { qWarning() << "WindowGrabber: Failed to query window property"; return false; } const int maxIdStrLength = 128; char idString[maxIdStrLength]; if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) { qWarning() << "WindowGrabber: Failed to query window ID string"; return false; } if (m_windowId == idString) { m_window = window; start(); } } return false; }
void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event) { screen_display_t nativeDisplay = 0; if (screen_get_event_property_pv(event, SCREEN_PROPERTY_DISPLAY, (void **)&nativeDisplay) != 0) { qWarning("QQnx: failed to query display property, errno=%d", errno); return; } int isAttached = 0; if (screen_get_event_property_iv(event, SCREEN_PROPERTY_ATTACHED, &isAttached) != 0) { qWarning("QQnx: failed to query display attached property, errno=%d", errno); return; } qScreenEventDebug() << Q_FUNC_INFO << "display attachment is now:" << isAttached; QQnxScreen *screen = m_qnxIntegration->screenForNative(nativeDisplay); if (!screen) { if (isAttached) { qScreenEventDebug() << "creating new QQnxScreen for newly attached display"; m_qnxIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */); } } else if (!isAttached) { // We never remove the primary display, the qpa plugin doesn't support that and it crashes. // To support it, this would be needed: // - Adjust all qnx qpa code which uses screens // - Make QWidgetBackingStore not dereference a null paint device // - Create platform resources ( QQnxWindow ) for all QWindow because they would be deleted // when you delete the screen if (!screen->isPrimaryScreen()) { // libscreen display is deactivated, let's remove the QQnxScreen / QScreen qScreenEventDebug() << "removing display"; m_qnxIntegration->removeDisplay(screen); } } }
static void handle_screen_event(bps_event_t *event) { int type; screen_event_t screen_event = screen_event_get_event(event); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &type); switch(type) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_RELEASE: case SCREEN_EVENT_MTOUCH_MOVE: process_touch_event(screen_event, type); break; case SCREEN_EVENT_KEYBOARD: process_keyboard_event(screen_event, type); break; #ifdef HAVE_BB10 case SCREEN_EVENT_GAMEPAD: case SCREEN_EVENT_JOYSTICK: process_gamepad_event(screen_event, type); break; case SCREEN_EVENT_DEVICE: { // A device was attached or removed. screen_device_t device; int attached; int type; screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ATTACHED, &attached); if (attached) screen_get_device_property_iv(device, SCREEN_PROPERTY_TYPE, &type); int i; if (attached && (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD)) { for (i = 0; i < MAX_PADS; ++i) { if (!devices[i].handle) { devices[i].handle = device; loadController(&devices[i]); break; } } } else { for (i = 0; i < MAX_PADS; ++i) { if (device == devices[i].handle) { RARCH_LOG("Device %s: Disconnected.\n", devices[i].id); initController(&devices[i]); break; } } } } break; #endif default: break; } }
static void process_touch_event(screen_event_t event, int type) { int contact_id; int pos[2]; int i; screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, (int*)&contact_id); screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, pos); switch(type) { case SCREEN_EVENT_MTOUCH_TOUCH: //Find a free touch struct for(i=0;i<MAX_TOUCH;++i) { if(touch[i].contact_id == -1) { touch[i].contact_id = contact_id; input_translate_coord_viewport(pos[0], pos[1], &touch[i].x, &touch[i].y, &touch[i].full_x, &touch[i].full_y); //Add this touch to the map to signal it's valid touch[i].map = touch_count; touch_map[touch_count] = i; touch_count++; break; } } //printf("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout); //printf("Map: %d %d %d %d %d %d\n", touch_map[0], touch_map[1], touch_map[2], touch_map[3], touch_map[4], touch_map[5]);fflush(stdout); break; case SCREEN_EVENT_MTOUCH_RELEASE: for(i=0; i<MAX_TOUCH; ++i) { if(touch[i].contact_id == contact_id) { //Invalidate the finger touch[i].contact_id = -1; //Remove touch from map and shift remaining valid ones to the front touch_map[touch[i].map] = -1; int j; for(j=touch[i].map;j<touch_count;++j) { touch_map[j] = touch_map[j+1]; touch[touch_map[j+1]].map = j; touch_map[j+1] = -1; } touch_count--; break; } } //printf("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout); //printf("Map: %d %d %d %d %d %d\n", touch_map[0], touch_map[1], touch_map[2], touch_map[3], touch_map[4], touch_map[5]);fflush(stdout); break; case SCREEN_EVENT_MTOUCH_MOVE: //Find the finger we're tracking and update for(i=0; i<touch_count; ++i) { if(touch[i].contact_id == contact_id) { //During a move, we can go ~30 pixel into the bezel which gives negative //numbers or numbers larger than the screen res. Normalize. if(pos[0] < 0) pos[0] = 0; if(pos[0] > screen_width) pos[0] = screen_width; if(pos[1] < 0) pos[1] = 0; if(pos[1] > screen_height) pos[1] = screen_height; input_translate_coord_viewport(pos[0], pos[1], &touch[i].x, &touch[i].y, &touch[i].full_x, &touch[i].full_y); //printf("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout); break; } } break; } }