Esempio n. 1
0
void aw_calibtools(AWINDOWP parent){
  int USE_HACK = aw_confirm(
      parent,
      "Use alternative touch",
      "Do you want to use alternative touch?\n  Only use if the default method does not work.\n\nPress the volume keys to select Yes or No.",
      "@alert",
      acfg_var.text_no,
      acfg_var.text_yes
    );
  byte current_hack = atouch_gethack();
  if (!USE_HACK){
    atouch_sethack(1);
  }
  else{
    atouch_sethack(0);
  }
  
  //-- Set Mask
  CANVAS * tmpc = aw_muteparent(parent);
  on_dialog_window = 1;
  ag_rectopa(agc(),0,0,agw(),agh(),0x0000,220);
  ag_sync();
  byte isvalid = 0;
  
  //-- Initializing Canvas
  CANVAS ccv;
  ag_canvas(&ccv,agw(),agh());
  ag_blur(&ccv,agc(),agdp()*2);
  
  int xpos[5] = { agdp()*10, agw()-(agdp()*10), agdp()*10, agw()-(agdp()*10), agw()/2 };
  int ypos[5] = { agdp()*10, agdp()*10, agh() - (agdp()*10), agh()-(agdp()*10), agh()/2 };
  int xtch[5] = { 0,0,0,0,0 };
  int ytch[5] = { 0,0,0,0,0 };
  
  atouch_plaincalibrate();
  char datx[256];
  
  if (!aw_calibdraw(&ccv,0,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,1,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,2,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,3,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,4,xpos,ypos,xtch,ytch))
    goto doneit;
  
  float padsz     = agdp()*5;
  float leftx     = ((xtch[0]+xtch[2])/2);
  float rightx    = ((xtch[1]+xtch[3])/2);
  float topy      = ((ytch[0]+ytch[1])/2);
  float bottomy   = ((ytch[2]+ytch[3])/2);
  float centerx   = xtch[4];
  float centery   = ytch[4];
  float halfx     = (agw()/2)-padsz;
  float halfy     = (agh()/2)-padsz;
  float fullx     = agw()-padsz;
  float fully     = agh()-padsz;
  
  byte data_is_valid = 0;
  float cal_x = 0;
  float cal_y = 0;
  int   add_x = 0;
  int   add_y = 0;
  if ((halfx>0)&&(fullx>0)&&(halfy>0)&&(fully>0)){
    cal_x     = ((((centerx-leftx)/halfx) + ((rightx-leftx)/fullx))/2);
    cal_y     = ((((centery-topy)/halfy) + ((bottomy-topy)/fully))/2);
    if ((cal_x>0)&&(cal_y>0)){
      add_x     = round((leftx / cal_x) - padsz);
      add_y     = round((topy / cal_y) - padsz);
      data_is_valid = 1;
    }
  }
  
  if (data_is_valid){
    atouch_set_calibrate(cal_x,add_x,cal_y,add_y);    
    if (!USE_HACK){
      snprintf(datx,255,
        "Use/Replace this command in <#009>aroma-config</#>:\n\n"
        "<#060>calibrate(\n  \"%01.4f\",\"%i\",\"%01.4f\",\"%i\",\"yes\"\n);</#>\n\n",
      cal_x,add_x,cal_y,add_y);
    }
    else{
      snprintf(datx,255,
        "Use/Replace this command in <#009>aroma-config</#>:\n\n"
        "<#060>calibrate(\n  \"%01.4f\",\"%i\",\"%01.4f\",\"%i\"\n);</#>\n\n",
      cal_x,add_x,cal_y,add_y);
    }
    
    aw_calibdraw(&ccv,-1,xpos,ypos,xtch,ytch);
    isvalid       = 1;
  }
  else{
    aw_alert(parent,
      "Calibrated Data",
      "Calibrated data not valid, please try again...",
      "@info",
      NULL);
  }
doneit:
  
  ag_ccanvas(&ccv);
  on_dialog_window = 0;
  aw_unmuteparent(parent,tmpc);
  byte dont_restore_caldata = 0;
  if (isvalid){
    aw_alert(parent,
      "Calibrated Data",
      datx,
      "@info",
      NULL);
    dont_restore_caldata = aw_confirm(
      parent,
      "Set Calibrated Data",
      "Do you want to use the current calibrated data in the current process?\n\n<#080>NOTE:</#> It will revert back when you restart the AROMA Installer...",
      "@alert",
      NULL,
      NULL
    );    
  }
  if (!dont_restore_caldata){
    atouch_sethack(current_hack);
    atouch_restorecalibrate();
  }
}
Esempio n. 2
0
void aw_calibtools(AWINDOWP parent){
  //-- Set Mask
  CANVAS * tmpc = aw_muteparent(parent);
  on_dialog_window = 1;
  ag_rectopa(agc(),0,0,agw(),agh(),0x0000,220);
  ag_sync();
  byte isvalid = 0;
  
  //-- Initializing Canvas
  CANVAS ccv;
  ag_canvas(&ccv,agw(),agh());
  ag_blur(&ccv,agc(),agdp()*2);
  
  int xpos[5] = { agdp()*10, agw()-(agdp()*10), agdp()*10, agw()-(agdp()*10), agw()/2 };
  int ypos[5] = { agdp()*10, agdp()*10, agh() - (agdp()*10), agh()-(agdp()*10), agh()/2 };
  int xtch[5] = { 0,0,0,0,0 };
  int ytch[5] = { 0,0,0,0,0 };
  
  atouch_plaincalibrate();
  char datx[256];
  
  if (!aw_calibdraw(&ccv,0,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,1,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,2,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,3,xpos,ypos,xtch,ytch))
    goto doneit;
  if (!aw_calibdraw(&ccv,4,xpos,ypos,xtch,ytch))
    goto doneit;
  
  float padsz     = agdp()*5;
  float leftx     = ((xtch[0]+xtch[2])/2);
  float rightx    = ((xtch[1]+xtch[3])/2);
  float topy      = ((ytch[0]+ytch[1])/2);
  float bottomy   = ((ytch[2]+ytch[3])/2);
  float centerx   = xtch[4];
  float centery   = ytch[4];
  float halfx     = (agw()/2)-padsz;
  float halfy     = (agh()/2)-padsz;
  float fullx     = agw()-padsz;
  float fully     = agh()-padsz;
  
  byte data_is_valid = 0;
  float cal_x = 0;
  float cal_y = 0;
  int   add_x = 0;
  int   add_y = 0;
  if ((halfx>0)&&(fullx>0)&&(halfy>0)&&(fully>0)){
    cal_x     = ((((centerx-leftx)/halfx) + ((rightx-leftx)/fullx))/2);
    cal_y     = ((((centery-topy)/halfy) + ((bottomy-topy)/fully))/2);
    if ((cal_x>0)&&(cal_y>0)){
      add_x     = round((leftx / cal_x) - padsz);
      add_y     = round((topy / cal_y) - padsz);
      data_is_valid = 1;
    }
  }
  
  if (data_is_valid){
    atouch_set_calibrate(cal_x,add_x,cal_y,add_y);
    snprintf(datx,255,
      "Use/Replace this command in top of <#009>aroma-config</#>:\n\n"
      "<#060>calibrate(\"%01.4f\",\"%i\",\"%01.4f\",\"%i\");</#>\n\n",
    cal_x,add_x,cal_y,add_y);
    
    aw_calibdraw(&ccv,-1,xpos,ypos,xtch,ytch);
    isvalid       = 1;
  }
  else{
    aw_alert(parent,
      "Calibrated Data",
      "Calibrated Data not Valid, Please Try Again...",
      "icons/info",
      NULL);
  }
doneit:
  
  ag_ccanvas(&ccv);
  on_dialog_window = 0;
  aw_unmuteparent(parent,tmpc);
  byte dont_restore_caldata = 0;
  if (isvalid){
    aw_alert(parent,
      "Calibrated Data",
      datx,
      "icons/info",
      NULL);
    dont_restore_caldata = aw_confirm(
      parent,
      "Set Calibrated Data",
      "Do You Want to Use Current Calibrated Data in Current Process?\n\n<#080>NOTE:</#> It Will revert back when you restart the AROMA Installer...",
      "icons/alert",
      NULL,
      NULL
    );    
  }
  if (!dont_restore_caldata){
    atouch_restorecalibrate();
  }
}