SlideShare a Scribd company logo
傾斜  Google  地圖 & 火箭発射器 宮川達彦 [email_address] Six Apart, Ltd. /  渋谷  Perl  推廣組   osdc.tw  台北  2007/04/15
 
USB MissileLaunchers by Yappo
Now mashing up With ThinkPad Tilt!
( 公開表演 ) Live Demo
極好 ! sugoi!
如何實現 How can you do that?
 
發現了 2 個範例 Found 2 examples: C++ / Ruby
C++ if( !DeviceIoControl( hFile, 0x733fc, NULL, 0, // via IOCTL(0x733fc) (void *)&AccelerometerData, 0x24, &ulRead, NULL)) throw "Failed to DeviceIoControl"; X = AccelerometerData.x0 + OffsetX; Y = AccelerometerData.y0 + OffsetY;
Ruby device = Device.new ' \\\\ . \\ ShockMgr' device.open values = device.io(command, result_size).unpack("x4s*") cx = values[3] cy = values[2]
Perl  移植 use Win32API::File; my $file = createFile("//./ShockMgr", "r ke") or die "Can't get ShockMgr device"; DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []); my @data = unpack "x4s*", $buf;
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("//./ShockMgr", "r ke")  or die "Can't get ShockMgr device"; DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24,  my($bytes), []); my @data = unpack "x4s*", $buf; return @data; }
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("ctlmissile $command") if $command; }
tilt-missile.pl (3/3) sub detect_command { my($ax, $ay) = @_; if (abs($ax) >= 180 || abs($ay) >= 180) { return "fire"; } elsif ($ax >= 80) { return "right"; } … }
(Google 地圖実演 )
整合  Google  地圖
困難原因 : Google 地圖 API = JavaScript
JavaScript <-> Win32 Perl 能成功嗎?
Active X ™
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>
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>
http://svn.bulknews.net/repos/public/gmaps-thinkpad/ Or google &quot;google maps thinkpad&quot; MacBook + Safari: http://blog.yappo.jp/yappo/archives/000441.html
Thanks to: Yappo (for his LT) Takesako-san (for win32 binary) Gugod (for his missile) clkao (for his idea)
謝謝

More Related Content

What's hot (16)

PPTX
Oops in c++
DravidSh
 
DOCX
Cpp
Ankit Dubey
 
PDF
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
Atsushi Tadokoro
 
PDF
JavaScript - Agora nervoso
Luis Vendrame
 
KEY
Barcamp GoogleMaps - praktické ukázky kódu
Milos Lenoch
 
PDF
Interactive Music II ProcessingとSuperColliderの連携 -2
Atsushi Tadokoro
 
PDF
Seaborn graphing present
Yilin Zeng
 
PDF
What they don't tell you about JavaScript
Raphael Cruzeiro
 
PDF
From Javascript To Haskell
ujihisa
 
DOCX
program on Function overloading in java
One97 Communications Limited
 
PDF
Star bed 2018.07.19
Ruo Ando
 
DOCX
WAP to implement inheritance and overloading methods in java
One97 Communications Limited
 
TXT
PIZZA HUT C program
Prathvi Raj Singh Chouhan
 
ODP
Daniel Sikar: Hadoop MapReduce - 06/09/2010
Skills Matter
 
PDF
2016 gunma.web games-and-asm.js
Noritada Shimizu
 
Oops in c++
DravidSh
 
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
Atsushi Tadokoro
 
JavaScript - Agora nervoso
Luis Vendrame
 
Barcamp GoogleMaps - praktické ukázky kódu
Milos Lenoch
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Atsushi Tadokoro
 
Seaborn graphing present
Yilin Zeng
 
What they don't tell you about JavaScript
Raphael Cruzeiro
 
From Javascript To Haskell
ujihisa
 
program on Function overloading in java
One97 Communications Limited
 
Star bed 2018.07.19
Ruo Ando
 
WAP to implement inheritance and overloading methods in java
One97 Communications Limited
 
PIZZA HUT C program
Prathvi Raj Singh Chouhan
 
Daniel Sikar: Hadoop MapReduce - 06/09/2010
Skills Matter
 
2016 gunma.web games-and-asm.js
Noritada Shimizu
 

More from Tatsuhiko Miyagawa (20)

PDF
Carton CPAN dependency manager
Tatsuhiko Miyagawa
 
KEY
Deploying Plack Web Applications: OSCON 2011
Tatsuhiko Miyagawa
 
KEY
Plack at OSCON 2010
Tatsuhiko Miyagawa
 
KEY
cpanminus at YAPC::NA 2010
Tatsuhiko Miyagawa
 
KEY
Plack at YAPC::NA 2010
Tatsuhiko Miyagawa
 
KEY
PSGI/Plack OSDC.TW
Tatsuhiko Miyagawa
 
KEY
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
KEY
Plack - LPW 2009
Tatsuhiko Miyagawa
 
KEY
Tatsumaki
Tatsuhiko Miyagawa
 
KEY
Intro to PSGI and Plack
Tatsuhiko Miyagawa
 
KEY
CPAN Realtime feed
Tatsuhiko Miyagawa
 
KEY
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
PDF
Asynchronous programming with AnyEvent
Tatsuhiko Miyagawa
 
PDF
Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
PPT
Remedie OSDC.TW
Tatsuhiko Miyagawa
 
PDF
Why Open Matters It Pro Challenge 2008
Tatsuhiko Miyagawa
 
PDF
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
PPT
Web::Scraper for SF.pm LT
Tatsuhiko Miyagawa
 
PPT
Web Scraper Shibuya.pm tech talk #8
Tatsuhiko Miyagawa
 
PPT
Web::Scraper
Tatsuhiko Miyagawa
 
Carton CPAN dependency manager
Tatsuhiko Miyagawa
 
Deploying Plack Web Applications: OSCON 2011
Tatsuhiko Miyagawa
 
Plack at OSCON 2010
Tatsuhiko Miyagawa
 
cpanminus at YAPC::NA 2010
Tatsuhiko Miyagawa
 
Plack at YAPC::NA 2010
Tatsuhiko Miyagawa
 
PSGI/Plack OSDC.TW
Tatsuhiko Miyagawa
 
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
Plack - LPW 2009
Tatsuhiko Miyagawa
 
Intro to PSGI and Plack
Tatsuhiko Miyagawa
 
CPAN Realtime feed
Tatsuhiko Miyagawa
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
Asynchronous programming with AnyEvent
Tatsuhiko Miyagawa
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
Remedie OSDC.TW
Tatsuhiko Miyagawa
 
Why Open Matters It Pro Challenge 2008
Tatsuhiko Miyagawa
 
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
Web::Scraper for SF.pm LT
Tatsuhiko Miyagawa
 
Web Scraper Shibuya.pm tech talk #8
Tatsuhiko Miyagawa
 
Web::Scraper
Tatsuhiko Miyagawa
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
July Patch Tuesday
Ivanti
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Ad

Tilting Google Maps and MissileLauncher

  • 1. 傾斜 Google 地圖 & 火箭発射器 宮川達彦 [email_address] Six Apart, Ltd. / 渋谷 Perl 推廣組 osdc.tw 台北 2007/04/15
  • 2.  
  • 4. Now mashing up With ThinkPad Tilt!
  • 5. ( 公開表演 ) Live Demo
  • 7. 如何實現 How can you do that?
  • 8.  
  • 9. 發現了 2 個範例 Found 2 examples: C++ / Ruby
  • 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;
  • 11. Ruby device = Device.new ' \\\\ . \\ ShockMgr' device.open values = device.io(command, result_size).unpack(&quot;x4s*&quot;) cx = values[3] cy = values[2]
  • 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;
  • 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; }
  • 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; }
  • 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;; } … }
  • 17. 整合 Google 地圖
  • 18. 困難原因 : Google 地圖 API = JavaScript
  • 19. JavaScript <-> Win32 Perl 能成功嗎?
  • 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>
  • 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>
  • 23. http://svn.bulknews.net/repos/public/gmaps-thinkpad/ Or google &quot;google maps thinkpad&quot; MacBook + Safari: http://blog.yappo.jp/yappo/archives/000441.html
  • 24. Thanks to: Yappo (for his LT) Takesako-san (for win32 binary) Gugod (for his missile) clkao (for his idea)