Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
傾斜  Google  地圖 & 火箭発射器 宮川達彦 [email_address] Six Apart, Ltd. /  渋谷  Perl  推廣組   osdc.tw  台北  2007/04/15
 
<ul><li>USB MissileLaunchers </li></ul><ul><li>by Yappo </li></ul>
<ul><li>Now mashing up </li></ul><ul><li>With ThinkPad Tilt! </li></ul>
<ul><li>( 公開表演 ) </li></ul><ul><li>Live Demo </li></ul>
<ul><li>極好 ! </li></ul><ul><li>sugoi! </li></ul>
<ul><li>如何實現 </li></ul><ul><li>How can you do that? </li></ul>
 
<ul><li>發現了 2 個範例 </li></ul><ul><li>Found 2 examples: </li></ul><ul><li>C++ / Ruby </li></ul>
C++ if( !DeviceIoControl( hFile, 0x733fc, NULL, 0, // via IOCTL(0x733fc) (void *)&AccelerometerData, 0x24, &ulRead, NULL))...
Ruby device = Device.new ' \\\\ . \\ ShockMgr' device.open values = device.io(command, result_size).unpack(&quot;x4s*&quot...
Perl  移植 use Win32API::File; my $file = createFile(&quot;//./ShockMgr&quot;, &quot;r ke&quot;) or die &quot;Can't get Shoc...
tilt-missile.pl (1/3) use Time::HiRes qw(sleep); use Win32::API; use Win32API::File qw(:ALL); use Win32::OLE; sub get_pos ...
tilt-missile.pl (2/3) my @pos = get_pos; my($base_x, $base_y) = @pos[3, 2]; while (my @pos = get_pos) { my $ax = ($pos[1] ...
tilt-missile.pl (3/3) sub detect_command { my($ax, $ay) = @_; if (abs($ax) >= 180 || abs($ay) >= 180) { return &quot;fire&...
<ul><li>(Google 地圖実演 ) </li></ul>
<ul><li>整合  Google  地圖 </li></ul>
<ul><li>困難原因 : </li></ul><ul><li>Google 地圖 API </li></ul><ul><li>= JavaScript </li></ul>
<ul><li>JavaScript </li></ul><ul><li><-> Win32 Perl </li></ul><ul><li>能成功嗎? </li></ul>
<ul><li>Active X ™ </li></ul>
gmaps.html (1/2) <script  language=&quot;JavaScript&quot; > function load() { if (GBrowserIsCompatible()) { map = new GMap...
gmaps.html (2/2) <script  language=&quot;PerlScript&quot; > use Win32API::File qw(:ALL); sub get_pos { my $base = shift; m...
<ul><li>http://svn.bulknews.net/repos/public/gmaps-thinkpad/ </li></ul><ul><li>Or google &quot;google maps thinkpad&quot; ...
<ul><li>Thanks to: </li></ul><ul><li>Yappo (for his LT) </li></ul><ul><li>Takesako-san (for win32 binary) </li></ul><ul><l...
<ul><li>謝謝 </li></ul>
Upcoming SlideShare
Loading in …5
×

Tilting Google Maps and MissileLauncher

6,415 views

Published on

Gmaps and MissileLauncher hacking talk in OSDC.tw

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Tilting Google Maps and MissileLauncher

  1. 1. 傾斜 Google 地圖 & 火箭発射器 宮川達彦 [email_address] Six Apart, Ltd. / 渋谷 Perl 推廣組 osdc.tw 台北 2007/04/15
  2. 3. <ul><li>USB MissileLaunchers </li></ul><ul><li>by Yappo </li></ul>
  3. 4. <ul><li>Now mashing up </li></ul><ul><li>With ThinkPad Tilt! </li></ul>
  4. 5. <ul><li>( 公開表演 ) </li></ul><ul><li>Live Demo </li></ul>
  5. 6. <ul><li>極好 ! </li></ul><ul><li>sugoi! </li></ul>
  6. 7. <ul><li>如何實現 </li></ul><ul><li>How can you do that? </li></ul>
  7. 9. <ul><li>發現了 2 個範例 </li></ul><ul><li>Found 2 examples: </li></ul><ul><li>C++ / Ruby </li></ul>
  8. 10. C++ if( !DeviceIoControl( hFile, 0x733fc, NULL, 0, // via IOCTL(0x733fc) (void *)&AccelerometerData, 0x24, &ulRead, NULL)) throw &quot;Failed to DeviceIoControl&quot;; X = AccelerometerData.x0 + OffsetX; Y = AccelerometerData.y0 + OffsetY;
  9. 11. Ruby device = Device.new ' \\\\ . \\ ShockMgr' device.open values = device.io(command, result_size).unpack(&quot;x4s*&quot;) cx = values[3] cy = values[2]
  10. 12. Perl 移植 use Win32API::File; my $file = createFile(&quot;//./ShockMgr&quot;, &quot;r ke&quot;) or die &quot;Can't get ShockMgr device&quot;; DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []); my @data = unpack &quot;x4s*&quot;, $buf;
  11. 13. tilt-missile.pl (1/3) use Time::HiRes qw(sleep); use Win32::API; use Win32API::File qw(:ALL); use Win32::OLE; sub get_pos { my $file = createFile(&quot;//./ShockMgr&quot;, &quot;r ke&quot;) or die &quot;Can't get ShockMgr device&quot;; DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []); my @data = unpack &quot;x4s*&quot;, $buf; return @data; }
  12. 14. tilt-missile.pl (2/3) my @pos = get_pos; my($base_x, $base_y) = @pos[3, 2]; while (my @pos = get_pos) { my $ax = ($pos[1] - $base_x) / 30; my $ay = ($pos[0] - $base_y) / 30; my $command = detect_command($ax, $ay); system(&quot;ctlmissile $command&quot;) if $command; }
  13. 15. tilt-missile.pl (3/3) sub detect_command { my($ax, $ay) = @_; if (abs($ax) >= 180 || abs($ay) >= 180) { return &quot;fire&quot;; } elsif ($ax >= 80) { return &quot;right&quot;; } … }
  14. 16. <ul><li>(Google 地圖実演 ) </li></ul>
  15. 17. <ul><li>整合 Google 地圖 </li></ul>
  16. 18. <ul><li>困難原因 : </li></ul><ul><li>Google 地圖 API </li></ul><ul><li>= JavaScript </li></ul>
  17. 19. <ul><li>JavaScript </li></ul><ul><li><-> Win32 Perl </li></ul><ul><li>能成功嗎? </li></ul>
  18. 20. <ul><li>Active X ™ </li></ul>
  19. 21. gmaps.html (1/2) <script language=&quot;JavaScript&quot; > function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById(&quot;map&quot;)); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); if (debug) document.getElementById('log').style.visibility = 'visible'; GEvent.addListener(map, &quot;dragstart&quot;, function() { dragging = 1 }); GEvent.addListener(map, &quot;dragend&quot;, function() { var center = map.getCenter(); x = center.x; y = center.y; dragging = 0; }); … map.setCenter(new GLatLng(y, x), 14); base = get_pos(1). split(/,/); </script>
  20. 22. gmaps.html (2/2) <script language=&quot;PerlScript&quot; > use Win32API::File qw(:ALL); sub get_pos { my $base = shift; my $file = createFile(&quot;//./ShockMgr&quot;, &quot;r ke&quot;) or die &quot;Can't get ShockMgr device&quot;; DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []); my @data = unpack &quot;x4s*&quot;, $buf; return join &quot;,&quot;, ($base ? @data[3, 2] : @data[1, 0]); } </script>
  21. 23. <ul><li>http://svn.bulknews.net/repos/public/gmaps-thinkpad/ </li></ul><ul><li>Or google &quot;google maps thinkpad&quot; </li></ul><ul><li>MacBook + Safari: </li></ul><ul><li>http://blog.yappo.jp/yappo/archives/000441.html </li></ul>
  22. 24. <ul><li>Thanks to: </li></ul><ul><li>Yappo (for his LT) </li></ul><ul><li>Takesako-san (for win32 binary) </li></ul><ul><li>Gugod (for his missile) </li></ul><ul><li>clkao (for his idea) </li></ul>
  23. 25. <ul><li>謝謝 </li></ul>

×