コード例 #1
0
ファイル: touchstk.c プロジェクト: apalrd/palscreen
//Touch stack functions
//Process buttons in the loop
void touch_stack_proc()
{
    //Process the touch stack
    
    //New touched id defaults to none
    int new_id = -1;
    
    //Cache x and y since they have to do math internally
    int xpos = touch_get_x();
    int ypos = touch_get_y();
    
    //If we are touched down:
    if(touch_down())
    {
        //Get the first number that matches the current position
        new_id = touch_stack_find(xpos,ypos);
        //Poke the backlight
        backlight_poke();
    }
    
    //If our new id is different from our old id
    if(new_id != touched_last_id)
    {
        //Was old ID a real button?
        if(touched_last_id >= 0)
        {
            //Yes it was, process lift off event every time the button is inactive
            //See if the lo event is mapped (not null)
            if(touch_stack_glob[touched_last_id].evt_lo != NULL)
            {
                touch_stack_glob[touched_last_id].evt_lo(touched_last_id,touch_stack_glob[touched_last_id].user_ptr);
            }
            
            //If we are no longer touched down, also process the button event
            //But only if the event is mapped
            if(!touch_down() && touch_stack_glob[touched_last_id].evt_btn != NULL)
            {
                touch_stack_glob[touched_last_id].evt_btn(touched_last_id,touch_stack_glob[touched_last_id].user_ptr);
            }
        }
        
        //Is the new button real?
        //Is the touch down event mapped?
        if(new_id >= 0 && touch_stack_glob[new_id].evt_td != NULL)
        {
            //Process the touch down event for that button
            touch_stack_glob[new_id].evt_td(new_id,touch_stack_glob[new_id].user_ptr);
        }
    }
    
    //If any button is pressed, process thd down event for it
    //But only if the event is mapped
    if(new_id >= 0 && touch_stack_glob[new_id].evt_dn != NULL)
    {
        touch_stack_glob[new_id].evt_dn(new_id,touch_stack_glob[new_id].user_ptr,xpos,ypos,touch_get_prs());
    }
    
    //Store the last id
    touched_last_id = new_id;
}
コード例 #2
0
ファイル: atci_touch_cmd.c プロジェクト: V-GeN/mediatek-1
void touch_emu_cmd(TP_POINT points[], int point_num)
{
    int i;
    int down_flag;

    //ALOGD("[touch_emu_cmd]:num=%d", point_num);
    
    for (i=0; i<point_num; i++)
    {
        //ALOGD("[touch_emu_cmd]act=%d,x=%d,y=%d", points[i].action, points[i].x, points[i].y);
        
        if (points[i].action == TP_EMU_DEPRESS) //Down
        {
            ALOGD("[DOWN %d]:(%d, %d)", i, points[i].x, points[i].y);
            touch_down(3, points[i].x, points[i].y);
            down_flag = 1;
        }
        else if(points[i].action == TP_EMU_RELEASE) //Up
        {
            ALOGD("[UP %d]:(%d, %d)", i, points[i].x, points[i].y);
            if (down_flag) touch_down(3, points[i].x, points[i].y);
            touch_up();
            break;
        }
        else if(points[i].action == TP_EMU_SINGLETAP) //Single tap
        {
            ALOGD("[SingleTap %d]:(%d, %d)", i, points[i].x, points[i].y);
            touch_down(3, points[i].x, points[i].y);
            touch_up();
            break;
        }
        else if(points[i].action == TP_EMU_DOUBLETAP) //Double tap
        {
            ALOGD("[DoubleTap %d]:(%d, %d)", i, points[i].x, points[i].y);
            touch_down(3, points[i].x, points[i].y);
            touch_up();
            touch_down(3, points[i].x, points[i].y);
            touch_up();
            break;
        }

    }
}
コード例 #3
0
ファイル: tetris.cpp プロジェクト: DealerNextDoor/tetris
void    tetris::world(bool fall)
{
  if (_l_object.get() == NULL)
    _l_object.add(_objects);
  if (touch_down() == false && fall)
    _l_object.get()->fall(_world);
  _l_object.actualise(_world);
  if (_fall == false)
    {
      game_over();
      test_line();
      _l_object.add(_objects);
      _fall = true;
    }
}
コード例 #4
0
ファイル: tetris.cpp プロジェクト: DealerNextDoor/tetris
void	tetris::action()
{
  if (_event_ok == false)
    return ;

  if (_case[0])
    {
      _l_object.get()->flip(_world, _objects);
      _event_ok = false;
      world(false);
      refresh();
    }
  else if (_case[1])
    {
      _l_object.get()->fall(_world);
      if (touch_down() == true)
	_l_object.get()->jump(_world);
      _event_ok = false;
      world(false);
      refresh();
    }
  else if (_case[2])
    {
      if (touch_left() == false)
	_l_object.get()->left(_world);
      _event_ok = false;
      world(false);
      refresh();
    }
  else if (_case[3])
    {
      if (touch_right() == false)
	_l_object.get()->right(_world);
      _event_ok = false;
      world(false);
      refresh();
    }
  else if (_case[4])
    {
      _l_object.get()->down(_world);
      _score += 1 * _level;
      _event_ok = false;
      _fall = false;
      world(true);
      refresh();
    }
}
コード例 #5
0
ファイル: minitouch.c プロジェクト: openstf/minitouch
static void parse_input(char* buffer, internal_state_t* state)
{
  char* cursor;
  long int contact, x, y, pressure, wait;

  cursor = (char*) buffer;
  cursor += 1;

  switch (buffer[0])
  {
    case 'c': // COMMIT
      commit(state);
      break;
    case 'r': // RESET
      touch_panic_reset_all(state);
      break;
    case 'd': // TOUCH DOWN
      contact = strtol(cursor, &cursor, 10);
      x = strtol(cursor, &cursor, 10);
      y = strtol(cursor, &cursor, 10);
      pressure = strtol(cursor, &cursor, 10);
      touch_down(state, contact, x, y, pressure);
      break;
    case 'm': // TOUCH MOVE
      contact = strtol(cursor, &cursor, 10);
      x = strtol(cursor, &cursor, 10);
      y = strtol(cursor, &cursor, 10);
      pressure = strtol(cursor, &cursor, 10);
      touch_move(state, contact, x, y, pressure);
      break;
    case 'u': // TOUCH UP
      contact = strtol(cursor, &cursor, 10);
      touch_up(state, contact);
      break;
    case 'w':
      wait = strtol(cursor, &cursor, 10);
      if (g_verbose)
        fprintf(stderr, "Waiting %ld ms\n", wait);
      usleep(wait * 1000);
      break;
    default:
      break;
  }
}