{"id":340,"date":"2010-07-14T11:50:42","date_gmt":"2010-07-14T17:50:42","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/?p=340"},"modified":"2010-08-13T11:13:20","modified_gmt":"2010-08-13T17:13:20","slug":"porting-to-palm-webos","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2010\/07\/14\/porting-to-palm-webos\/","title":{"rendered":"Porting to Palm \/ WebOS"},"content":{"rendered":"<p>I&#8217;ve just completed and submitted my port of Galcon to the Palm.  The entire process took 2.5 days.  Here&#8217;s my play-by-play of the porting process.  A huge thanks goes out to <a href=\"http:\/\/www.toonormal.com\/\">Mike Kasprzak<\/a> for hand-holding me through the process and co-writing this post. \u00a0If you&#8217;re doing a Palm port, be sure to read the whole blog post over before you begin so you get the big picture. \u00a0Also, not everything is exactly in the right order, so that&#8217;ll give you the birds-eye view.<\/p>\n<h2>Day 1: Preparing the device for Development<\/h2>\n<p>11:00<\/p>\n<p>&#8211; Unbox the Palm Pre Plus.<\/p>\n<p>&#8211; Figure out how to plug in the USB. \u00a0This is a bit tricky, you gotta really yank on that plastic tab on the side to get it off.<\/p>\n<p>11:30<\/p>\n<p>&#8211; Use WebOS Doctor to flash the device with latest OS<\/p>\n<p><a href=\"http:\/\/ws.palm.com\/webosdoctor\/sorry.htm  \">http:\/\/ws.palm.com\/webosdoctor\/sorry.htm<\/a><\/p>\n<p>12:00<\/p>\n<p>&#8211; Activate phone. \u00a0If your phone isn&#8217;t activated, you use a program that can bypass activation<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=2051&amp;Itemid=30  \">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=2051&amp;Itemid=30<\/a><\/p>\n<p>12:15<\/p>\n<p>&#8211; Connected to local WiFi on activated device<\/p>\n<p>12:30<\/p>\n<p>&#8211; Final preparation of the device for development.<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1973&amp;Itemid=336\">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1973&amp;Itemid=336<\/a><\/p>\n<p>&#8220;Card view&#8221; is the view where you can see a view of all the open apps minimized.  Apps are called Cards.<\/p>\n<p>12:45<\/p>\n<p>&#8211; ssh onto the device, password is blank<\/p>\n<p>$ ssh -oPort=10022 root@localhost<br \/>\nroot@localhost&#8217;s password:<br \/>\nroot@palm-webos-device:\/var\/home\/root#<\/p>\n<p>1:00<\/p>\n<p>&#8211; Install the Palm SDK and PDK, read whole document so you know where the cross-compiling binaries are located.  It varies depending on windows \/ mac.<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1970&amp;Itemid=335\">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1970&amp;Itemid=335<\/a><\/p>\n<p>1:30<\/p>\n<p>&#8211; Install a SSH key. \u00a0This way I don&#8217;t have to keep pressing return on the password entry during SSH sessions.<\/p>\n<p>$ pdk-ssh-init localhost:10022<\/p>\n<p>1:45<\/p>\n<p>&#8211; Verify installation by using a Palm demo app. \u00a0This is an important step! \u00a0This step shows you where the example code and scripts are and you&#8217;ll be referring to those when you build your own build\/deploy\/packaging scripts for your own app. \u00a0And if it works, you know your Palm is ready to go!<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1974&amp;Itemid=336\">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1974&amp;Itemid=336<\/a><\/p>\n<p>&#8211; Errors about not finding various .so files can be ignored<\/p>\n<p>&#8211; [<strong>This should be irrelevant<\/strong> as Palm gets their SDK&#8217;s and firmware all synced across the networks] The PDL_Init error is actually the device talking back to you. \u00a0I had to go into the src folder and comment out PDL_Init to get it to run.  This error is due to the 1.4.1.1 firmware on my Palm Pre Plus .. 1.4.5 is required for apps. \u00a0Had to do some hacks to get around this, won&#8217;t bother explaining, as this shouldn&#8217;t matter in a few days.]<\/p>\n<p>3:00<\/p>\n<p>&#8211; Rebuild simple sample app with PDL_Init included, works fine<\/p>\n<p>3:30<\/p>\n<p>&#8211; Got a copy of Mike&#8217;s app and tried it out. \u00a0Works nicely.<\/p>\n<h2>Day 2: Porting the App<\/h2>\n<p>&#8211; 10:30<\/p>\n<p>Hacking up the \/opt\/PalmPDK\/share\/samplecode\/simple\/mac example building, packaging and deployment scripts. \u00a0Mostly just getting them to work with my code. \u00a0Was pretty straightforward if you know shell stuff. \u00a0I&#8217;m doing my work on the Mac, so I have a bash shell at hand all the time.<\/p>\n<p>&#8211; 11:30<\/p>\n<p>Got it compiling with a few tweaks.  using rsync over ssh to deploy my game \ud83d\ude42 \u00a0I&#8217;m a big fan of rsync. \u00a0Here&#8217;s my &#8220;deploy&#8221; script:<\/p>\n<p>rsync -v -urt &#8211;exclude &#8216;*~&#8217; &#8211;exclude tmp &#8211;exclude .svn -e &#8220;ssh -oPort=10022&#8221; .\/out\/ root@localhost:\/media\/internal\/galcon<\/p>\n<p>&#8211; 12:00<\/p>\n<p>I had trouble loading images to textures. \u00a0But this was mostly due to my own dumbness. \u00a0Ended up being really straightforward. \u00a0Used SDL_image to load, converted it to 32 bit, then loaded it in.<\/p>\n<p>&#8211; 1:30<\/p>\n<p>.mp3&#8217;s won&#8217;t play with SDL_Mixer, so you must use oggs instead, check out this hack that I use to covert my &#8220;.mp3&#8221; extensions to &#8220;.ogg&#8221;:<\/p>\n<p>sprintf(f,&#8221;%s\/%s&#8221;,DRIVER_DATADIR,fname);<br \/>\nint l = strlen(f);f[l-3]=&#8217;o&#8217;;f[l-2]=&#8217;g&#8217;;f[l-1]=&#8217;g&#8217;;<\/p>\n<p>&#8211; 1:45<\/p>\n<p>SDL keyboard events not passing numbers when I use the Palm number presser key.<\/p>\n<p>This is a palm bug, I should file a bug report.  If the user holds down the NUMBER key, and then pressed a letter, they get the proper number.<\/p>\n<p>-5:30<\/p>\n<p>Handled SDL_ACTIVEEVENT to switch game into pause mode when being minimized.<br \/>\nif ((e.active.state&amp;SDL_APPACTIVE)!=0 &amp;&amp; e.active.gain == 0) { \/* pause game *\/ }<\/p>\n<p>&#8211; 6:00<\/p>\n<p>Added a few PDL_ calls. \u00a0I&#8217;m really liking the set of lightweight functions they give you. \u00a0They cover most all the stuff you need for game integration in just a few calls.<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1990&amp;Itemid=340\">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1990&amp;Itemid=340<\/a><\/p>\n<p>#include &#8220;PDL.h&#8221;<\/p>\n<p>PDL_Init(0); \/\/ in init function<br \/>\nPDL_GetCallingPath(char *buffer, int bufferLen);  \/\/ to find out where our app is being launched from so i can find my data files<br \/>\nPDL_GetDataFilePath(char *dataFileName, char *buffer, int bufferLen);    \/\/ find out where my app can write save games and settings.. the buffer is a fullpath to where we can save a file to<br \/>\nPDL_LaunchBrowser(const char* Url); \/\/ go to interwebs<br \/>\nPDL_Quit(); \/\/ wrap it up<\/p>\n<p>Here are a few tips from Mike that I found really helpful:<\/p>\n<p><strong>About the Palm itself:<\/strong><\/p>\n<p><span style=\"color: #111111; \"> <\/span><\/p>\n<ul>\n<li>There&#8217;s a touch strip beneath the LCD screen. Gesture up or down from the middle of the strip to bring up the menu.<\/li>\n<li>To \u201cCard\u201d (minimize) a running application, gesture upward or tap on the gesture strip<\/li>\n<li>To close an application, throw the card away (up)<\/li>\n<li>To delete an application, hold down the keyboard button with a square on it, then tap the icon of the app you want to remove.<\/li>\n<li>When you plug a device in,\u00a0<strong>Just Charge<\/strong> is the ideal mode. USB mode is useful for copying files via drag+drop, but you can&#8217;t run things while in USB mode<\/li>\n<\/ul>\n<p><strong>Linkable Libraries<\/strong><\/p>\n<ul>\n<li>-lSDL<\/li>\n<li>-lGLES_CM (for OpenGL ES 1.1)<\/li>\n<li>-lGLESv2 (for OpenGL ES 2.0)<\/li>\n<li>-lSDL_mixer<\/li>\n<li>-lpdl (Palm specific calls)<\/li>\n<\/ul>\n<p><strong>SDL Tips<\/strong><\/p>\n<p>The following call is required BEFORE setting your graphics mode, yet after initializing SDL<\/p>\n<pre>SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);<\/pre>\n<p>The number represents the OpenGL ES version. 1 for 1.1, 2 for 2.0.<\/p>\n<p>webOS actually supports blending what you do against hardware decoded video. Unfortunately, this feature is on by default. The alpha value in the frame buffer decides weather video will bleed through or not (even if no video is displayed). To disable writing Alpha to the framebuffer, use this call.<\/p>\n<pre>    glClearColor(0,0,0,1);\r\n    glClear(GL_COLOR_BUFFER_BIT);\r\n    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);<\/pre>\n<h2>Day 2.5: Packaging the App<\/h2>\n<p>Time to figure out how to package this into a sellable .. package! \u00a0I used Mike&#8217;s app and found that we really don&#8217;t need all the skeleton stuff palm-generate can generate for you.<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1976&amp;Itemid=375\">http:\/\/developer.palm.com\/index.php?option=com_content&amp;view=article&amp;id=1976&amp;Itemid=375<\/a><\/p>\n<p>You need an appinfo.json file in your distribution folder.  It should contain something like this:<br \/>\n{<br \/>\n&#8220;id&#8221;: &#8220;com.galcon.app.igalcon&#8221;,<br \/>\n&#8220;version&#8221;: &#8220;1.9.8&#8221;,<br \/>\n&#8220;vendor&#8221;: &#8220;GALCON.COM&#8221;,<br \/>\n&#8220;type&#8221;: &#8220;pdk&#8221;,<br \/>\n&#8220;main&#8221;: &#8220;galcon&#8221;,<br \/>\n&#8220;title&#8221;: &#8220;Galcon&#8221;,<br \/>\n&#8220;icon&#8221;: &#8220;icon.png&#8221;,<br \/>\n&#8220;requiredMemory&#8221;: 48<br \/>\n}<\/p>\n<p>I ssh&#8217;d in and used top to figure out my required memory.<\/p>\n<p>And also a framework_config.json containing:<br \/>\n{<br \/>\n&#8220;logLevel&#8221;: 99,<br \/>\n&#8220;debuggingEnabled&#8221;: true,<br \/>\n&#8220;timingEnabled&#8221;: false,<br \/>\n&#8220;logEvents&#8221;: false,<br \/>\n&#8220;escapeHTMLInTemplates&#8221; : true<br \/>\n}<\/p>\n<p>And lastly, I gotta include icon.png .  Palm specifies this:<\/p>\n<p>&#8220;Application icons should be 1 in. square, 64 x 64 pixels, encoded as a PNG with 24 bit\/pixel RGB and 8 bits alpha. The icon&#8217;s image should be about 56 x 56 pixels within the PNG bounds.&#8221;<\/p>\n<p>And lastly create this file:<br \/>\npackage.properties containing:<br \/>\nfilemode.755=your_app_binary<\/p>\n<p>Then just copy all those files, and the app files into a folder named the same as your app id (com.galcon.app.igalcon for example)\u00a0then run palm-package against that folder and you&#8217;re done! \u00a0Here&#8217;s a checklist from Palm that helped me through a few things:<\/p>\n<p><a href=\"http:\/\/developer.palm.com\/blog\/2010\/07\/a-quick-pdk-submission-checklist\/\">http:\/\/developer.palm.com\/blog\/2010\/07\/a-quick-pdk-submission-checklist\/<\/a><\/p>\n<p>Then you just send that app package off to Palm!  Have fun!<\/p>\n<p>-Phil<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve just completed and submitted my port of Galcon to the Palm. The entire process took 2.5 days. Here&#8217;s my play-by-play of the porting process. A huge thanks goes out to Mike Kasprzak for hand-holding me through the process and co-writing this post. \u00a0If you&#8217;re doing a Palm port, be sure to read the whole [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,20,114],"tags":[],"class_list":["post-340","post","type-post","status-publish","format-standard","hentry","category-development","category-galcon","category-palm"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=340"}],"version-history":[{"count":17,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":485,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/340\/revisions\/485"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}