Esempio n. 1
0
int _ji_system_init()
{
  /* Install timer related stuff.  */
  LOCK_VARIABLE(ji_clock);
  LOCK_VARIABLE(m_b);
  LOCK_FUNCTION(clock_inc);

  if (install_int_ex(clock_inc, BPS_TO_TIMER(1000)) < 0)
    return -1;

  if (screen)
    jmouse_poll();

  moved = true;
  mouse_cursor_type = kNoCursor;

  return 0;
}
Esempio n. 2
0
// Returns false when the user stop the click-loop: releases the
// button or press the second click (depend of the mode)
int Editor::editor_click(int *x, int *y, int *update,
                         void (*scroll_callback) (int before_change))
{
  int prev_x, prev_y;

  poll_keyboard();

  if (click_first) {
    click_first = false;

    if (click_mode == MODE_CLICKANDCLICK) {
      do {
        jmouse_poll();
        gui_feedback();
      } while (jmouse_b(0));

      jmouse_set_position(click_start_x, click_start_y);
      clear_keybuf();
    }
  }

  *update = jmouse_poll();

  screenToEditor(click_last_x, click_last_y, &prev_x, &prev_y);

  click_prev_last_b = click_last_b;

  click_last_x = jmouse_x(0);
  click_last_y = jmouse_y(0);
  click_last_b = jmouse_b(0);

  screenToEditor(click_last_x, click_last_y, x, y);

  /* the mouse was moved */
  if (*update) {
    View* view = View::getView(this);
    gfx::Rect vp = view->getViewportBounds();

    /* update scroll */
    if (jmouse_control_infinite_scroll(vp)) {
      if (scroll_callback)
        (*scroll_callback)(true);

      /* smooth scroll movement */
      if (get_config_bool("Options", "MoveSmooth", true)) {
        jmouse_set_position(MID(vp.x+1, click_last_x, vp.x+vp.w-2),
                            MID(vp.y+1, click_last_y, vp.y+vp.h-2));
      }
      /* this is better for high resolutions: scroll movement by big steps */
      else {
        jmouse_set_position((click_last_x != jmouse_x(0)) ?
                            (click_last_x + (vp.x+vp.w/2))/2: jmouse_x(0),

                            (click_last_y != jmouse_y(0)) ?
                            (click_last_y + (vp.y+vp.h/2))/2: jmouse_y(0));
      }

      gfx::Point scroll = view->getViewScroll();
      setEditorScroll(scroll.x+click_last_x-jmouse_x(0),
                      scroll.y+click_last_y-jmouse_y(0), true);

      click_last_x = jmouse_x(0);
      click_last_y = jmouse_y(0);

      if (scroll_callback)
        (*scroll_callback)(false);
    }

    // If the cursor hasn't subpixel movement
    if (!editor_cursor_is_subpixel()) {
      // Check if the mouse change to other pixel of the sprite
      *update = ((prev_x != *x) || (prev_y != *y));
    }
    else {
      // Check if the mouse change to other pixel of the screen
      *update = ((prev_x != click_last_x) || (prev_y != click_last_y));
    }
  }

  /* click-and-click mode */
  if (click_mode == MODE_CLICKANDCLICK) {
    if (click_last_b) {
      click_prev_last_b = click_last_b;

      do {
        jmouse_poll();
        gui_feedback();
      } while (jmouse_b(0));

      jmouse_set_position(click_last_x, click_last_y);
      clear_keybuf();

      return false;
    }
    else {
      return true;
    }
  }
  /* click-and-release mode */
  else {
    return (click_last_b) ? true: false;
  }
}