BOOL InitCiscoTouchpadInput (INPUT* input, const char* mdev, const char* mtype)
{
    {
#       define KBD "/dev/input/event0"
        char keyboard_device[] = KBD;
        system("mknod "KBD" c 13 64 > /dev/null 2>&1");
        kbd_fd = keyboard_open(keyboard_device);
        if (kbd_fd < 0) {
            fprintf (stderr, "[WARNING] IAL Native Engine: Can not init keyboard right now, %s(%s).\nPlease plug in the KEYBOARD!\n", 
                    strerror(errno), keyboard_device);
        }
    }

    mouse_fd = mouse_open(mdev);
    if (mouse_fd <0) {
        fprintf (stderr, "[WARNING] IAL Native Engine: Can not init mouse right now, %s(%s).\nPlease plug in the MOUSE!\n", 
                strerror(errno), mdev);
    }

    if (getenv("MG_ENV_DISABLE_APP_MODE")) {
        s_enable_appmode = 0;
    }else{
        s_enable_appmode = 1;
    }

    if (s_enable_appmode) {
        system("mknod /dev/hidraw0 c 253 0 > /dev/null 2>&1");
        system("mknod /dev/hidraw1 c 253 1 > /dev/null 2>&1");
#       define HIDRAW "/dev/hidraw1"
        app_fd = open(HIDRAW, O_RDWR);
        if (app_fd < 0) {
            fprintf(stderr, "Fatal error> Failed to open %s: [errno=%d]%s", HIDRAW, errno, strerror(errno));
            return -1;
        }

        mg_ial_ioctl(CMD_SET_MODE, MICE_MODE);
        // mg_ial_ioctl(CMD_SET_MODE, APP_MODE);
    }else{
        s_current_mode = s_expect_mode = MICE_MODE;
    }

    xpos = 0;
    ypos = 0;
    buttons = 0;
    minx = 0;
    miny = 0;
    maxx = WIDTHOFPHYSCREEN;
    maxy = HEIGHTOFPHYSCREEN;

    input->update_mouse = mouse_update;
    input->get_mouse_xy = mouse_getxy;
    input->set_mouse_xy = mouse_setposition;
    input->get_mouse_button = mouse_getbutton;
    input->set_mouse_range = mouse_setrange;
    input->suspend_mouse= mouse_suspend;
    input->resume_mouse = mouse_resume;

    input->update_keyboard = keyboard_update;
    input->get_keyboard_state = keyboard_getstate;
    input->suspend_keyboard = keyboard_suspend;
    input->resume_keyboard = keyboard_resume;
    input->set_leds = NULL;

    input->wait_event = wait_event; 
    return TRUE;
}
Ejemplo n.º 2
0
void xfer(serial_h com, configuration_t *config)
{
  FILE *log = NULL ;
  int ch ;
  int linelen ;
  char buffer[MAXLINELEN] ;

  do {
    bbc_status_t result = BBC_OK ;

    printf("\f\n\n"
           "     (R)eceive files from BBC          (S)end files to BBC\n"
           "     (*)-command on BBC                (D)o command on PC\n"
           "     (T)erminal emulation              (G)et disc image from BBC\n"
           "     (L)og BBC OSCLI output %s      (C)d to directory\n"
           "     (P)C file CRC                     (B)BC file CRC\n"
           "     (Q)uit\n\n"
           "Enter command: ", log ? "(on) " : "(off)") ;

    do {
      ch = toupper(keyboard_char()) ;
    } while ( strchr("RS*DTGLCQPB", ch) == NULL ) ;

    putchar(ch) ;

    switch ( ch ) {
    case 'L':
      putchar('\n') ;
      if ( log ) {
        fclose(log) ;
        log = NULL ;
        puts("Logging turned off") ;
      } else {
        printf("Log OSCLI output to file: ") ;
        linelen = keyboard_line(buffer, MAXLINELEN) ;

        if ( linelen == 0 )
          puts("No log file specified, not logging\n") ;
        else if ( (log = fopen(buffer, "w+")) == NULL )
          printf("Problem opening log file %s, not logging\n", buffer) ;
      }

      break ;
    case 'R':
      putchar('\n') ;
      result = retrieve_files(com, config->wildcards, config->directories) ;
      break ;
    case 'S':
      putchar('\n') ;
      result = send_files(com, config->wildcards, config->directories) ;
      break ;
    case 'P':
      putchar('\n') ;
      result = local_crc() ;
      break ;
    case 'B':
      putchar('\n') ;
      result = remote_crc(com, config->wildcards, config->directories) ;
      break ;
    case '*':
      result = oscli(com, log) ;
      break ;
    case 'G':
      putchar('\n') ;
      result = retrieve_disc(com) ;
      break ;
    case 'D':
      (void)getcwd(buffer, MAXLINELEN) ;
      printf("\n%s> ", buffer) ;
      linelen = keyboard_line(buffer, MAXLINELEN) ;

      fflush(stdout) ;
      fflush(stdin) ;

      if ( linelen > 0 ) {
        keyboard_close() ;
        system(buffer) ;
        keyboard_open() ;
      }

      break ;
    case 'C':
      printf("\nDirectory: ") ;
      linelen = keyboard_line(buffer, MAXLINELEN) ;

      if ( chdir(buffer) != 0 )
        printf("Problem changing directory to %s, ignoring\n", buffer) ;

      break ;
    case 'T':
      putchar('\n') ;
      result = terminal(com) ;
      break ;
    }

    while ( result == BBC_ERROR ) {
      serial_printf(com, ERR_TXT) ;
      if ( (result = bbc_readline(com, buffer, MAXLINELEN)) == BBC_OK &&
           (result = bbc_readline(com, buffer, MAXLINELEN)) == BBC_OK )
        printf("BBC Error: %s\n", buffer) ;
    }
  } while ( ch != 'Q' ) ;

  putchar('\n') ;

  serial_printf(com, "Q") ;

  if ( log )
    fclose(log) ;
}