Oct 30, 2013

Dical! - Chinese-English Dictionary extension for Chrome

  • 瀏覽網頁時,只要點兩下圈選單字,右下角跳出單字翻譯視窗
  • 簡單又快速
  • 支援中英-英中字典
  • 使用Yahoo的字典功能

安裝

使用 Chrome 時,您可以按照以下步驟加入擴充功能:
  1. 請對下方的link右鍵點擊後,另存新檔儲存至您的電腦。
    dicall.crx
  2. 按一下瀏覽器工具列中的 Chrome 選單圖示 Chrome menu。
  3. 依序選取 [工具] > [擴充功能]。
  4. 在電腦上找出擴充功能擋案,並拖曳到「擴充功能」頁面。
  5. 在隨即顯示的對話方塊中檢閱權限清單。如果您要繼續進行,請按一下 [安裝]。
由於本套件尚未上架,請先手動安裝 :P

by Sean Lee 2013/10/18

Apr 24, 2013

Build your Emdebian Grip for ARM (WM8850 support)

Here is the instruction that how to install an embedded debian OS for your ARM system. Linux Kernel Image for your ARM system is a prerequisite. [1]

Please follow the instruction step by step to build emdebian rootfs on Debian/Ubuntu. :)

1. Using Bootstrap

(Use apt-get install debootstrap to install it if you don't have yet.)

Use the command to retrieve the packages for ARM:
sudo debootstrap \
--arch=armel \
--include=vim,openssh-server \
--foreign \
squeeze grip/ http://www.emdebian.org/grip/

After this step, the installation rootfs is ready at "./grip", but it is like an installation disc rather than a working rootfs.
"--inculde" is to install any additional packages. In this example, vim and ssh server are added manually.

2. Write Rootfs to disk/SD card.

Copy the installation rootfs (at ./grip) to ext3 partition of a SD card or other media.

Save the following content to target's rootfs "/first.sh" :
#!/bin/sh
mkdir -p ./usr/share/man/man1
echo "proc /proc proc rw 0 0" >> /etc/fstab
echo 'deb http://www.emdebian.org/grip/ squeeze main' >> etc/apt/sources.list
echo 'deb http://ftp.tw.debian.org/debian squeeze main' >> etc/apt/sources.list
mount /proc /proc -t proc
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/debootstrap/debootstrap --second-stage

3. First Boot

Before entering Linux Kernel, add "init=/bin/sh" to bootargs at uboot or other bootloader.[2] 
"#" prompt should be appeared. (If you can't see that, press enter to make sure your system isn't crash.). Just execute "/first.sh" at "/" and wait for couple minutes to install the base system.
if anything works normally, use "passwd" to modify root's password then reboot the system.

4. Second Boot

Modify bootargs from "init=/bin/sh" to "init=/sbin/init" at uboot or other bootloader before entering Linux Kernel. [3]

So far, login with root should be successfully. :)

P.S.

Attach some files for my WM8850 netbook.
[1] Linux Kernel :
[2] boot script for First Boot:
[3] boot script for Second Boot:
[4] Emdebian Linux on WM8850 Netbook
https://www.youtube.com/watch?v=JzPxJVLE2Zc&hd=1

Mar 12, 2013

Draw Take6 Cards With KineticJS

Did you ever play a board game - Take 6? Here is a card-drawing library in Javascript with KineticJS. It is implemented with HTML5 + JS + Kinetic. You can learn something about canvas of HTML5 in this library.

https://github.com/weilonge/take6

Jan 23, 2013

Setup PlayStation Joysticks on Raspberry Pi



My friends and I are big fans of KOF. We all know the latency between PC and USB converter of PS joysticks is too long to enjoy our fight. However, the PS joysticks to PC via parallel port is a nice choice for low latency. (It you want to know how the converter works, please refer another Chinese site : http://stevie.myweb.hinet.net/adaptor2.htm )

PlayStation joysticks converter via Parallel Port.

Although it's nice but my computer with parallel port is broken. Why don't we play NeoGeo or MAME on Raspberry Pi? Thus, there is a plan in my mind to turn Raspberry Pi as a console game platform to play many kind of emulators, and RetroPie is a such great project supports SNES, NES, GBA. GB, SEGA, and MAME. In this part, I only focus on how to modify the joysticks and won't mention how to setup an emulator.

I should have a set of very handful joysticks for my game platform. The legacy PlayStation joysticks via GPIO is the best choice because it got the benefits of 12 buttons and 4-axis analog control, and the most important one is with very lower latency via GPIO than USB. If you are a fighting gamer (KOF, Street Fighter) as us, you will know why the latency is such important.


So, let's start to modify the converter for RaspberryPi.

gamecon_gpio_rpi is the driver for NES, SNES, GameCube, and PS Joystick via GPIO, and it's included in RetroPie. In this instruction, you will see how to connect a PS joys to Raspberry Pi. If you need to know the pin descriptions of PS joy, this site gives you how PS joysticks work. The connection method is some different between rev 1.0 and rev 2.0 of RPi. My RPi is rev 2.0, so I summarized the pin table. 


I start to make a simple connector for the P1 of RPi and DB25-Male. Here are some materials I prepared and the connector that I finished:




After a little work, connect with PS joysticks, converters, and RPi together. Start to test it!!!!


Before playing games, use RetroPie-Setup to install the emulator platform and gamecon_gpio_rpi driver for joysticks. The detail instruction can be found here. (The driver should be compiled and installed separately without RetroPie installed, but I haven't tried that yet. :P).

If the kernel module of gamecon_gpio_rpi is built correctly, you can install the module by the command:
pi@raspberrypi ~ $ sudo modprobe gamecon_gpio_rpi map=0,0,0,0,7,7 psx_delay=14

The parameter "map=0,0,0,0,7,7" is indicated using Pad5&6 as both PlayStation joysticks.
The parameter "psx_delay=14" configures the access delay for psx pads to 14ms. The default is 10ms, but it doesn't work correctly. 14ms is more save for me. 
After modprobe, there should be two joystick devices in /dev/input/jsX. (X indicated 0 & 1.) Then use the command to test:
pi@raspberrypi ~ $ jstest /dev/input/js0 

Driver version is 2.1.0.
Joystick (PSX controller) has 6 axes (X, Y, Rx, Ry, Hat0X, Hat0Y)
and 12 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?).
Testing ... (interrupt to exit)
Axes:  0:-32767  1:-32767  2:-32767  3:-32767  4:-32767  5:-32767 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off 11:off 


If all buttons and axis work well, congratulation that the joysticks setup correctly on RPi!!

There will be another article soon to share how to setup the emulators on RPi.

編譯Nethack for Android筆記


一直以來都對NETHACK很有興趣,發現有ANDROID的版本時,更是好奇如何將以C語言寫成的程式移植到以JAVA為主的ANDROID平台。
關於移植上的重點,我想應該非JNI莫屬,JNI提供一個界面,提供由NDK編譯出Shared Object有機會可以直接在ANDROID APP中使用。
這次的目的是要紀錄如何成功編譯NETHACK for ANDROID。

專案的網站為

因此先將原始碼checkout下來:
svn checkout http://nethack-android.googlecode.com/svn/trunk/ nethack-android-read-only

直接閱讀編譯ANDROID版本的README
vim ./nethack-3.4.3/sys/android/README

以下節錄編譯時的重要步驟:
1. Unpack the source tree somewhere.
# 這部份已經完成了

2. Open 'sys/android/setup.sh' in a text editor, and change ANDROID_NDK_DIR to indicate the path where you have installed the Android NDK.
# 由於需要用到c/c++ compiler編譯nehack的原始碼,在這裡要設定NDK的目錄
ANDROID_NDK_DIR=/opt/android-ndk-r8b

3. Verify options in 'include/config.h' and elsewhere, if you want anything different than the standard configuration.
# 在這裡基本上不需要特別針對config.h做特別的修改,文件中雖然#define ANDROID是註解,但makefile中會自動加上。

4. Run Eclipse and create a new project, importing the source code from 'sys/android/NetHackApp'.
# 在Eclipse中匯入APP的專案:File -> Import… -> Android -> Existing Android Code Into Workspace

5. Make 'sys/android' your current directory, and run 'setup.sh'. This should create some symbolic links and do other preparations to make your source tree ready to build the Android port.
# 在執行setup.sh前,請先在NDK的目錄中新增apps目錄:mkdir ${ANDROID_NDK_DIR}/apps
# 如果發生設定的錯誤時,可以執行sh ./setup_clean.sh && sh ./clean.sh清空產生的檔案

6. Go to the 'dat' folder, and type 'make'. This builds the data files, using tools built for the host computer.
# 照步驟作即可

7. Go to your NDK directory (as specified as ANDROID_NDK_DIR).
# 照步驟作即可

8. Type 'make APP=NetHackNative' to build the native code.
# 在編譯的最後要進行shared library的link時,遇到以下錯誤:
SharedLibrary  : libnethack.so
./out/apps/NetHackNative/armeabi/objs/nethack/__/sys/share/unixtty.o: In function `init_linux_cons':
/Users/leeweilun/Desktop/VBShare/src/android_app_src/nethack-android-read-only/nethack-3.4.3/sys/android/NetHackNative/nethack/../sys/share/unixtty.c:429: undefined reference to `has_colors'
collect2: ld returned 1 exit status
make: *** [out/apps/NetHackNative/armeabi/libnethack.so] Error 1
# 發現是在./sys/shared/unixtty.c中,有用到curses library的has_colors(),
# 我自己的解法是在unixtty.c中加入#undef TEXTCOLOR,使得這段code不會被編譯到
# 重新在執行一次make就成功了,也會將libnethack.so複製到APP的project中。

9. Go back to Eclipse, build and launch the application.
# 接下來應該可以正常編譯並將APP(APK)安裝到Android系統上了。

以上就是這次編譯的過程。