Exemple #1
0
static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
      menu_entry_t *entry, unsigned action)
{
   unsigned header_height;
   size_t selection;
   int ret                  = 0;
   menu_list_t *menu_list   = menu_list_get_ptr();
   menu_input_t *menu_input = menu_input_get_ptr();
   settings_t *settings     = config_get_ptr();

   if (!menu_input)
      return -1;
   if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
      return -1;
   menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);

   if (!settings->menu.pointer.enable
#ifdef HAVE_OVERLAY
       || (settings->input.overlay_enable && input_overlay_is_alive())
#endif
      )
      return 0;

   if (menu_input->pointer.pressed[0])
   {
      int16_t pointer_x = menu_input_pointer_state(MENU_POINTER_X_AXIS);
      int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);

      if (!menu_input->pointer.oldpressed[0])
      {
         menu_input->pointer.accel         = 0;
         menu_input->pointer.accel0        = 0;
         menu_input->pointer.accel1        = 0;
         menu_input->pointer.start_x       = pointer_x;
         menu_input->pointer.start_y       = pointer_y;
         menu_input->pointer.old_x         = pointer_x;
         menu_input->pointer.old_y         = pointer_y;
         menu_input->pointer.oldpressed[0] = true;
      }
      else if (abs(pointer_x - menu_input->pointer.start_x) > 3
            || abs(pointer_y - menu_input->pointer.start_y) > 3)
      {
         float s, delta_time;
         menu_input->pointer.dragging      = true;
         menu_input->pointer.dx            = pointer_x - menu_input->pointer.old_x;
         menu_input->pointer.dy            = pointer_y - menu_input->pointer.old_y;
         menu_input->pointer.old_x         = pointer_x;
         menu_input->pointer.old_y         = pointer_y;

         menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);

         s =  menu_input->pointer.dy / delta_time * 1000000.0;
         menu_input->pointer.accel = (menu_input->pointer.accel0 + menu_input->pointer.accel1 + s) / 3;
         menu_input->pointer.accel0 = menu_input->pointer.accel1;
         menu_input->pointer.accel1 = menu_input->pointer.accel;
      }
   }
   else
   {
      if (menu_input->pointer.oldpressed[0])
      {
         if (!menu_input->pointer.dragging)
         {
            if ((unsigned)menu_input->pointer.start_y < header_height)
            {
               menu_list_pop_stack(menu_list, &selection);
               menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
            }
            else if (menu_input->pointer.ptr <= menu_list_get_size(menu_list)-1)
            {
               menu_input->pointer.oldpressed[0] = false;
               ret = pointer_tap(cbs, entry, action);
            }
         }

         menu_input->pointer.oldpressed[0] = false;
         menu_input->pointer.start_x       = 0;
         menu_input->pointer.start_y       = 0;
         menu_input->pointer.old_x         = 0;
         menu_input->pointer.old_y         = 0;
         menu_input->pointer.dx            = 0;
         menu_input->pointer.dy            = 0;
         menu_input->pointer.dragging      = false;
      }
   }

   if (menu_input->pointer.back)
   {
      if (!menu_input->pointer.oldback)
      {
         menu_input->pointer.oldback = true;
         menu_list_pop_stack(menu_list, &selection);
         menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
      }
   }
   menu_input->pointer.oldback = menu_input->pointer.back;

   return ret;
}
Exemple #2
0
static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
      menu_entry_t *entry, unsigned action)
{
   int ret                  = 0;
   menu_display_t *disp     = menu_display_get_ptr();
   menu_navigation_t *nav   = menu_navigation_get_ptr();
   menu_list_t *menu_list   = menu_list_get_ptr();
   menu_input_t *menu_input = menu_input_get_ptr();
   settings_t *settings     = config_get_ptr();

   if (!menu_input)
      return -1;

   if (!settings->menu.pointer.enable
#ifdef HAVE_OVERLAY
       || (settings->input.overlay_enable && input_overlay_is_alive())
#endif
      )
      return 0;

   if (menu_input->pointer.pressed[0])
   {
      if (!menu_input->pointer.oldpressed[0])
      {
         menu_input->pointer.accel  = 0;
         menu_input->pointer.accel0 = 0;
         menu_input->pointer.accel1 = 0;
         menu_input->pointer.start_x       = menu_input->pointer.x;
         menu_input->pointer.start_y       = menu_input->pointer.y;
         menu_input->pointer.old_x         = menu_input->pointer.x;
         menu_input->pointer.old_y         = menu_input->pointer.y;
         menu_input->pointer.oldpressed[0] = true;
      }
      else if (abs(menu_input->pointer.x - menu_input->pointer.start_x) > 3
            || abs(menu_input->pointer.y - menu_input->pointer.start_y) > 3)
      {
         float s;
         menu_input->pointer.dragging = true;
         menu_input->pointer.dx       = menu_input->pointer.x - menu_input->pointer.old_x;
         menu_input->pointer.dy       = menu_input->pointer.y - menu_input->pointer.old_y;
         menu_input->pointer.old_x    = menu_input->pointer.x;
         menu_input->pointer.old_y    = menu_input->pointer.y;

         s =  menu_input->pointer.dy / menu_animation_get_delta_time(disp->animation) * 1000000.0;
         menu_input->pointer.accel = (menu_input->pointer.accel0 + menu_input->pointer.accel1 + s) / 3;
         menu_input->pointer.accel0 = menu_input->pointer.accel1;
         menu_input->pointer.accel1 = menu_input->pointer.accel;
      }
   }
   else
   {
      if (menu_input->pointer.oldpressed[0])
      {
         if (!menu_input->pointer.dragging)
         {
            if ((unsigned)menu_input->pointer.start_y < disp->header_height)
               menu_list_pop_stack(menu_list, &nav->selection_ptr);
            else if (menu_input->pointer.ptr <= menu_list_get_size(menu_list)-1)
            {
               menu_input->pointer.oldpressed[0] = false;
               ret = pointer_tap(cbs, entry, action);
            }
         }

         menu_input->pointer.oldpressed[0] = false;
         menu_input->pointer.start_x       = 0;
         menu_input->pointer.start_y       = 0;
         menu_input->pointer.old_x         = 0;
         menu_input->pointer.old_y         = 0;
         menu_input->pointer.dx            = 0;
         menu_input->pointer.dy            = 0;
         menu_input->pointer.dragging      = false;
      }
   }

   if (menu_input->pointer.back)
   {
      if (!menu_input->pointer.oldback)
      {
         menu_input->pointer.oldback = true;
         menu_list_pop_stack(menu_list, &nav->selection_ptr);
      }
   }
   menu_input->pointer.oldback = menu_input->pointer.back;

   return ret;
}
Exemple #3
0
static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
      menu_entry_t *entry, unsigned action)
{
   int ret = 0;
   menu_handle_t *menu  = menu_driver_get_ptr();
   driver_t *driver     = driver_get_ptr();
   settings_t *settings = config_get_ptr();

   if (!menu)
      return -1;

   if (!settings->menu.pointer.enable
#ifdef HAVE_OVERLAY
       || (settings->input.overlay_enable && driver && driver->overlay)
#endif
      )
      return 0;

   if (menu->pointer.pressed[0])
   {
      if (!menu->pointer.oldpressed[0])
      {
         menu->pointer.start_x = menu->pointer.x;
         menu->pointer.start_y = menu->pointer.y;
         menu->pointer.old_x = menu->pointer.x;
         menu->pointer.old_y = menu->pointer.y;
         menu->pointer.oldpressed[0] = true;
      }
      else if (menu->pointer.x != menu->pointer.start_x
         && menu->pointer.y != menu->pointer.start_y)
      {
         menu->pointer.dragging = true;
         menu->pointer.dx = menu->pointer.x - menu->pointer.old_x;
         menu->pointer.dy = menu->pointer.y - menu->pointer.old_y;
         menu->pointer.old_x = menu->pointer.x;
         menu->pointer.old_y = menu->pointer.y;
      }
   }
   else
   {
      if (menu->pointer.oldpressed[0])
      {
         if (!menu->pointer.dragging)
         {
            if (menu->pointer.start_y < menu->header_height)
            {
               menu_list_pop_stack(menu->menu_list);
            }
            else if (menu->pointer.ptr <= menu_list_get_size(menu->menu_list)-1)
            {
               menu->pointer.oldpressed[0] = false;
               ret = pointer_tap(cbs, entry, action);
            }
         }
         menu->pointer.oldpressed[0] = false;
         menu->pointer.start_x = 0;
         menu->pointer.start_y = 0;
         menu->pointer.old_x = 0;
         menu->pointer.old_y = 0;
         menu->pointer.dx = 0;
         menu->pointer.dy = 0;
         menu->pointer.dragging = false;
      }
   }

   if (menu->pointer.back)
   {
      if (!menu->pointer.oldback)
      {
         menu->pointer.oldback = true;
         menu_list_pop_stack(menu->menu_list);
      }
   }
   menu->pointer.oldback = menu->pointer.back;

   return ret;
}