Rev 77 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 77 | Rev 80 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | ***************************************************************/ |
9 | ***************************************************************/ |
Line 10... | Line 10... | ||
10 | 10 | ||
11 | import javax.microedition.lcdui.*; |
11 | import javax.microedition.lcdui.*; |
Line -... | Line 12... | ||
- | 12 | import javax.microedition.rms.*; |
|
- | 13 | ||
Line 12... | Line 14... | ||
12 | import javax.microedition.rms.*; |
14 | import javax.microedition.media.*; |
13 | 15 | import javax.microedition.media.control.*; |
|
14 | 16 | ||
15 | public class MKMiniCanvas |
17 | public class MKMiniCanvas |
Line -... | Line 18... | ||
- | 18 | extends Canvas |
|
- | 19 | implements Runnable |
|
- | 20 | { |
|
- | 21 | ||
- | 22 | private boolean debug_screen=false; |
|
- | 23 | private byte[] debug_screen_sequence={KEY_POUND,KEY_NUM4,KEY_NUM2}; |
|
16 | extends Canvas |
24 | private byte debug_screen_sequence_pos=0; |
17 | implements Runnable |
25 | |
Line 18... | Line 26... | ||
18 | { |
26 | String debug_msg=""; |
19 | 27 | ||
Line 30... | Line 38... | ||
30 | //#endif |
38 | //#endif |
Line 31... | Line 39... | ||
31 | 39 | ||
32 | private String err=""; |
40 | private String err=""; |
Line -... | Line 41... | ||
- | 41 | private DUBwise root; |
|
- | 42 | ||
33 | private DUBwise root; |
43 | private UFOProber ufo_prober; |
Line 34... | Line 44... | ||
34 | 44 | ||
35 | byte[] settings_arr; |
45 | byte[] settings_arr; |
36 | 46 | ||
Line 241... | Line 251... | ||
241 | 251 | ||
Line 242... | Line 252... | ||
242 | root=_root; |
252 | root=_root; |
243 | 253 | ||
244 | bt_scanner = new BTSearcher(); |
- | |
- | 254 | bt_scanner = new BTSearcher(); |
|
Line 245... | Line 255... | ||
245 | params_editor = new MKParamsEditor(this); |
255 | params_editor = new MKParamsEditor(this); |
246 | 256 | ufo_prober = new UFOProber(); |
|
Line 247... | Line 257... | ||
247 | 257 | ||
Line 468... | Line 478... | ||
468 | boolean firstrun=true; |
478 | boolean firstrun=true; |
Line 469... | Line 479... | ||
469 | 479 | ||
470 | 480 | ||
- | 481 | // drawing section |
|
- | 482 | public void paint(Graphics g) { |
|
- | 483 | if (debug_screen) |
|
- | 484 | { |
|
- | 485 | g.setColor(0x0000FF); |
|
- | 486 | g.fillRect(0,0,this.getWidth(),this.getHeight()); |
|
- | 487 | g.setColor(0xFFFFFF); |
|
- | 488 | String tmp_str=""; |
|
- | 489 | y_off=0; |
|
- | 490 | for(int tmp_i=0;tmp_i<debug_msg.length();tmp_i++) |
|
- | 491 | { |
|
- | 492 | if ((debug_msg.charAt(tmp_i)=='\r')||(debug_msg.charAt(tmp_i)=='\n')) { |
|
- | 493 | g.drawString(tmp_str,0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 494 | y_off+=g.getFont().getHeight(); |
|
- | 495 | tmp_str=""; |
|
- | 496 | } |
|
- | 497 | else |
|
- | 498 | tmp_str+=debug_msg.charAt(tmp_i); |
|
- | 499 | } |
|
- | 500 | g.drawString(tmp_str,0,y_off,Graphics.TOP | Graphics.LEFT); |
|
- | 501 | ||
- | 502 | ||
- | 503 | return; |
|
471 | // drawing section |
504 | } |
472 | public void paint(Graphics g) { |
505 | |
473 | if (firstrun) |
506 | if (firstrun) |
474 | { |
507 | { |
475 | if (fullscreen) setFullScreenMode(fullscreen); |
508 | if (fullscreen) setFullScreenMode(fullscreen); |
Line 615... | Line 648... | ||
615 | 648 | ||
Line 616... | Line 649... | ||
616 | break; |
649 | break; |
- | 650 | ||
- | 651 | ||
617 | 652 | case STATEID_MAINMENU: |
|
618 | 653 | g.drawString("probed_device" + ufo_prober.probe_result + " by " + ufo_prober.reply,0,y_off,Graphics.TOP | Graphics.LEFT); |
|
619 | case STATEID_MAINMENU: |
654 | y_off+=spacer; |
620 | g.drawString("MK-Connection(" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"close")+"):",0,y_off,Graphics.TOP | Graphics.LEFT); |
655 | g.drawString("MK-Connection(" + (mk.connected?("open"+((System.currentTimeMillis()- mk.connection_start_time)/1000)+"s"):"close")+"):",0,y_off,Graphics.TOP | Graphics.LEFT); |
621 | y_off+=spacer; |
656 | y_off+=spacer; |
Line 724... | Line 759... | ||
724 | } |
759 | } |
Line 725... | Line 760... | ||
725 | 760 | ||
- | 761 | ||
- | 762 | ||
- | 763 | } catch (Exception e) {} |
|
- | 764 | g.setClip(0,0,this.getWidth(),this.getHeight()); |
|
726 | 765 | g.drawImage(cam_img,-cam_img_off,-cam_img_off,g.TOP | g.LEFT); |
|
727 | - | ||
- | 766 | cam_img_off++; |
|
- | 767 | cam_img_off%=cam_img.getWidth(); |
|
- | 768 | } |
|
- | 769 | Player mPlayer; |
|
728 | } catch (Exception e) {} |
770 | VideoControl mVideoControl; |
729 | } |
771 | Image cam_img; |
- | 772 | int cam_img_off=0; |
|
730 | 773 | private void connect_mk(String url,String name) |
|
- | 774 | { |
|
- | 775 | // ufo_prober.bluetooth_probe(url); |
|
- | 776 | // mk.connect_to(url,name); |
|
- | 777 | try |
|
- | 778 | { |
|
- | 779 | debug_msg+="creating player\n"; |
|
- | 780 | mPlayer = Manager.createPlayer("capture://video?encoding=png&width=2048&height=1536"); |
|
- | 781 | ||
- | 782 | debug_msg+="realizing player\n"; |
|
- | 783 | mPlayer.realize(); |
|
- | 784 | ||
- | 785 | debug_msg+="get_videocontrol\n"; |
|
- | 786 | ||
- | 787 | mVideoControl = (VideoControl)mPlayer.getControl("VideoControl"); |
|
- | 788 | ||
- | 789 | debug_msg+="switching Canvas\n"; |
|
- | 790 | mVideoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); |
|
- | 791 | ||
- | 792 | ||
- | 793 | debug_msg+="get snap\n"; |
|
- | 794 | byte[] raw = mVideoControl.getSnapshot(null); |
|
- | 795 | ||
- | 796 | debug_msg+="making img\n"; |
|
- | 797 | cam_img = Image.createImage(raw, 0, raw.length); |
|
- | 798 | } |
|
- | 799 | catch ( Exception e) |
|
- | 800 | { |
|
Line 731... | Line 801... | ||
731 | private void connect_mk(String url,String name) |
801 | debug_msg+=e.toString(); |
Line 732... | Line 802... | ||
732 | { |
802 | } |
733 | mk.connect_to(url,name); |
803 | |
Line 752... | Line 822... | ||
752 | g.fillRect(x,line_middle_y-y1,1,y1-y2); |
822 | g.fillRect(x,line_middle_y-y1,1,y1-y2); |
753 | else |
823 | else |
754 | g.fillRect(x,line_middle_y-y2,1,y2-y1); |
824 | g.fillRect(x,line_middle_y-y2,1,y2-y1); |
755 | } |
825 | } |
Line -... | Line 826... | ||
- | 826 | ||
- | 827 | ||
- | 828 | ||
756 | 829 | ||
Line 757... | Line 830... | ||
757 | } |
830 | } |
Line 924... | Line 997... | ||
924 | 997 | ||
Line 925... | Line 998... | ||
925 | } |
998 | } |
926 | 999 | ||
- | 1000 | public void keyPressed(int keyCode) |
|
- | 1001 | { |
|
- | 1002 | if (keyCode==KEY_NUM0) |
|
- | 1003 | { |
|
- | 1004 | try |
|
- | 1005 | { |
|
- | 1006 | ||
- | 1007 | ||
- | 1008 | debug_msg+="get snap\n"; |
|
- | 1009 | byte[] raw = mVideoControl.getSnapshot(null); |
|
- | 1010 | ||
- | 1011 | debug_msg+="making img\n"; |
|
- | 1012 | cam_img = Image.createImage(raw, 0, raw.length); |
|
- | 1013 | ||
- | 1014 | ||
- | 1015 | } |
|
- | 1016 | catch ( Exception e) |
|
- | 1017 | { |
|
- | 1018 | debug_msg+=e.toString(); |
|
- | 1019 | } |
|
- | 1020 | ||
- | 1021 | } |
|
- | 1022 | ||
- | 1023 | if (!debug_screen) |
|
- | 1024 | { |
|
- | 1025 | if (keyCode==debug_screen_sequence[debug_screen_sequence_pos]) |
|
- | 1026 | { |
|
- | 1027 | debug_screen_sequence_pos++; |
|
- | 1028 | if(debug_screen_sequence_pos==debug_screen_sequence.length) |
|
- | 1029 | { |
|
- | 1030 | debug_screen=true; |
|
- | 1031 | debug_screen_sequence_pos=0; |
|
- | 1032 | } |
|
- | 1033 | } |
|
- | 1034 | else |
|
- | 1035 | debug_screen_sequence_pos=0; |
|
- | 1036 | } |
|
- | 1037 | else |
|
- | 1038 | { |
|
- | 1039 | if (keyCode==KEY_STAR) |
|
Line 927... | Line 1040... | ||
927 | public void keyPressed(int keyCode) |
1040 | debug_screen=false; |
928 | { |
1041 | } |
929 | 1042 | ||
930 | if (keyCode==KEY_STAR) |
1043 | if (keyCode==KEY_STAR) |