胡斌

code about PendoTech pen support

正在显示 1 个修改的文件 包含 46 行增加50 行删除
@@ -97,10 +97,10 @@ @@ -97,10 +97,10 @@
97 97
98 #content{ 98 #content{
99 position: absolute; 99 position: absolute;
100 - top: 80px; 100 + top: 90px;
101 left: 0px; 101 left: 0px;
102 right: 0px; 102 right: 0px;
103 - bottom: 46px; 103 + bottom: 0px;
104 overflow:hidden; 104 overflow:hidden;
105 background-color:#ddd; 105 background-color:#ddd;
106 } 106 }
@@ -341,8 +341,8 @@ @@ -341,8 +341,8 @@
341 341
342 342
343 var ctx, color = "#000"; 343 var ctx, color = "#000";
344 - var voffset = 80;  
345 - var footerheight = 50; 344 + var voffset = 90;
  345 + var footerheight = 0;//50;
346 var canvas_width,canvas_height; 346 var canvas_width,canvas_height;
347 var ext_input_panel_width,ext_input_panel_height; 347 var ext_input_panel_width,ext_input_panel_height;
348 var ratio_x,ratio_y; 348 var ratio_x,ratio_y;
@@ -360,7 +360,7 @@ @@ -360,7 +360,7 @@
360 // setup canvas 360 // setup canvas
361 ctx = document.getElementById("canvas").getContext("2d"); 361 ctx = document.getElementById("canvas").getContext("2d");
362 ctx.strokeStyle = color; 362 ctx.strokeStyle = color;
363 - ctx.lineWidth = 1; 363 + ctx.lineWidth = 0.2;
364 ctx.translate(0.5, 0.5); 364 ctx.translate(0.5, 0.5);
365 365
366 // setup to trigger drawing on mouse or touch 366 // setup to trigger drawing on mouse or touch
@@ -395,8 +395,8 @@ @@ -395,8 +395,8 @@
395 //x = canvas_width - px * ratio_x; 395 //x = canvas_width - px * ratio_x;
396 //y = canvas_height - py * ratio_y; 396 //y = canvas_height - py * ratio_y;
397 397
398 - x = px * ratio_x;  
399 - y = py * ratio_y; 398 + var x = px * ratio_x;
  399 + var y = py * ratio_y;
400 400
401 if(last_ext_press == 0 && press != 0){ 401 if(last_ext_press == 0 && press != 0){
402 onTouchDownEvent(x, y, press); 402 onTouchDownEvent(x, y, press);
@@ -431,6 +431,7 @@ @@ -431,6 +431,7 @@
431 var P_LOW = 200; 431 var P_LOW = 200;
432 var P_MIDDLE = 500; 432 var P_MIDDLE = 500;
433 var P_HIGN = 800; 433 var P_HIGN = 800;
  434 + //var kWIDTH_MIN = 1.0;
434 var kWIDTH_MIN = 1.0; 435 var kWIDTH_MIN = 1.0;
435 var kWIDTH_MAX = 3.0; 436 var kWIDTH_MAX = 3.0;
436 //current width 437 //current width
@@ -1107,27 +1108,6 @@ @@ -1107,27 +1108,6 @@
1107 doCmd(obj.id); 1108 doCmd(obj.id);
1108 } 1109 }
1109 1110
1110 - var ext_input_connecting = false;  
1111 -  
1112 - function onConnectClick(obj) {  
1113 - var cur_pen_type = document.getElementById("pen_type").selectedIndex;  
1114 - if(cur_pen_type == 0) {  
1115 - ext_input_panel_width = 21000;  
1116 - ext_input_panel_height = 29800;  
1117 - ratio_x = (canvas_width + 0.0) / ext_input_panel_width;  
1118 - ratio_y = (canvas_height + 0.0) / ext_input_panel_height;  
1119 - }  
1120 -  
1121 - if( !ext_input_connecting ) {  
1122 - doCmd("open_ext_input");  
1123 - }  
1124 - else {  
1125 - doCmd("close_ext_input");  
1126 - ext_input_open = false;  
1127 - }  
1128 - ext_input_connecting = !ext_input_connecting;  
1129 - }  
1130 -  
1131 function rotateExtInput() { 1111 function rotateExtInput() {
1132 doCmd("rotate_ext_input"); 1112 doCmd("rotate_ext_input");
1133 } 1113 }
@@ -1361,11 +1341,30 @@ @@ -1361,11 +1341,30 @@
1361 cmd.type = 54; 1341 cmd.type = 54;
1362 } 1342 }
1363 else if(cmdName == "open_ext_input") { 1343 else if(cmdName == "open_ext_input") {
  1344 + cur_pen_type = document.getElementById("pen_type").selectedIndex;
  1345 + if(cur_pen_type == 0) {
  1346 + ext_input_panel_width = 21000;
  1347 + ext_input_panel_height = 29800;
  1348 + var w = ext_input_panel_width * 1.0;
  1349 + var h = ext_input_panel_height * 1.0;
  1350 + var canvasw = w / h * canvas_height;
  1351 + ratio_x = (canvasw + 0.0) / ext_input_panel_width;
  1352 + ratio_y = (canvas_height + 0.0) / ext_input_panel_height;
  1353 + P_LOW = 300;
  1354 + P_MIDDLE = 1000;
  1355 + P_HIGN = 1800;
  1356 + }
  1357 + else {
  1358 + P_LOW = 200;
  1359 + P_MIDDLE = 500;
  1360 + P_HIGN = 800;
  1361 + }
  1362 +
1364 cmd.type = 57; 1363 cmd.type = 57;
1365 cmd.data_len = 1; 1364 cmd.data_len = 1;
1366 var buffer = new ArrayBuffer(cmd.data_len); 1365 var buffer = new ArrayBuffer(cmd.data_len);
1367 cmd.data = new Uint8Array(buffer, 0, cmd.data_len); 1366 cmd.data = new Uint8Array(buffer, 0, cmd.data_len);
1368 - if(pen_type == 0) { 1367 + if(cur_pen_type == 0) {
1369 cmd.data[0] = 10; 1368 cmd.data[0] = 10;
1370 } 1369 }
1371 else { 1370 else {
@@ -1378,7 +1377,7 @@ @@ -1378,7 +1377,7 @@
1378 cmd.data_len = 1; 1377 cmd.data_len = 1;
1379 var buffer = new ArrayBuffer(cmd.data_len); 1378 var buffer = new ArrayBuffer(cmd.data_len);
1380 cmd.data = new Uint8Array(buffer, 0, cmd.data_len); 1379 cmd.data = new Uint8Array(buffer, 0, cmd.data_len);
1381 - if(pen_type == 0) { 1380 + if(cur_pen_type == 0) {
1382 cmd.data[0] = 11; 1381 cmd.data[0] = 11;
1383 } 1382 }
1384 else { 1383 else {
@@ -1978,30 +1977,27 @@ @@ -1978,30 +1977,27 @@
1978 <a id="open_ext_input" class="navbtn" onclick="onTestClick(this)">open_ext_input</a> 1977 <a id="open_ext_input" class="navbtn" onclick="onTestClick(this)">open_ext_input</a>
1979 <a id="close_ext_input" class="navbtn" onclick="onTestClick(this)">close_ext_input</a> 1978 <a id="close_ext_input" class="navbtn" onclick="onTestClick(this)">close_ext_input</a>
1980 <a id="rotate_ext_input" class="navbtn" onclick="rotateExtInput()">Rotate 90</a> 1979 <a id="rotate_ext_input" class="navbtn" onclick="rotateExtInput()">Rotate 90</a>
  1980 + <div class="palette-box">
  1981 + </div>
  1982 + <div class="palette-box">
  1983 + <div class="palette white" onclick="selectColor(this)"></div>
  1984 + </div>
  1985 + <div class="palette-box">
  1986 + <div class="palette red" onclick="selectColor(this)"></div>
  1987 + </div>
  1988 + <div class="palette-box">
  1989 + <div class="palette blue" onclick="selectColor(this)"></div>
  1990 + </div>
  1991 + <div class="palette-box">
  1992 + <div class="palette green" onclick="selectColor(this)"></div>
  1993 + </div>
  1994 + <div class="palette-box">
  1995 + <div class="palette black" onclick="selectColor(this)"></div>
  1996 + </div>
1981 </div> 1997 </div>
1982 <div id="content"> 1998 <div id="content">
1983 <p style="text-align:center">Loading Canvas...</p> 1999 <p style="text-align:center">Loading Canvas...</p>
1984 </div> 2000 </div>
1985 - <div class="footer">  
1986 - <div class="palette-case">  
1987 - <div class="palette-box">  
1988 - <div class="palette white" onclick="selectColor(this)"></div>  
1989 - </div>  
1990 - <div class="palette-box">  
1991 - <div class="palette red" onclick="selectColor(this)"></div>  
1992 - </div>  
1993 - <div class="palette-box">  
1994 - <div class="palette blue" onclick="selectColor(this)"></div>  
1995 - </div>  
1996 - <div class="palette-box">  
1997 - <div class="palette green" onclick="selectColor(this)"></div>  
1998 - </div>  
1999 - <div class="palette-box">  
2000 - <div class="palette black" onclick="selectColor(this)"></div>  
2001 - </div>  
2002 - <div style="clear:both"></div>  
2003 - </div>  
2004 - </div>  
2005 </div> 2001 </div>
2006 </div> 2002 </div>
2007 <div> 2003 <div>