View Single Post
Old 04-15-2012, 09:43 PM   #49
jmseight
Zealot
jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'
 
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
Hi,

Please find the script below. This has to be ran from Kite or Launchpad (I have never tested it on launchpad).

The keyboard entry part is from Geekmaster.

Please put all your roms in the ./roms directory.

The program will start with ls of the roms, which must have .gb extension. You then type the rom you want.

I had to use aA for the enter key, because the kindle screen somehow is not deactivated.

The code is not pretty, and I am sure someone on the forum can make this A LOT better.

Code:
#!/bin/sh
#===================================================
# getkb - get translated ascii keys from K3 keyboard
# v1.2                                 by geekmaster
# STDOUT: pressed keys, until Enter key pressed.
#---------------------------------------------------
getkb() {
  eips -z 2 38  # scroll
  XP=0
  YP=39
  DN=/dev/null
  KN="1234567890____qwertyuiop____asdfghjkl_____zxcvbnm_."
  KS="1234567890____QWERTYUIOP____ASDFGHJKL_____ZXCVBNM_,"
  KP="1234567890____~@#$%^&*()____<>[]{}?/\_____;:'|-+=_?"
  KM=$KN
  ST=""
  while :;do
    eips $XP $YP "$ST""_ "
    L="_"
    set $(waitforkey); K=$1 D=$2
    [[ $D -eq 0 ]]&& continue
#    [[ $K -eq 28 ]]&& break # enter
    [[ $K -eq 190 ]]&& break # use Aa for enter
    [[ $K -eq 14 ]]&& ST="$(echo ${ST%?})" && continue # del
    [[ $K -eq 42 ]]&& KM=$KS && continue # shift
    [[ $K -eq 126 ]]&& KM=$KP && continue # Sym
    [[ $K -eq 57 ]]&& L=" " # space
    [[ $K -le 52 ]]&& L="$(echo \"$KM\"|cut -b$K-$K)"
#    [[ "$L" == "_" ]]&& L="($K)"
    [[ "$L" == "_" ]]&& continue
#    echo -n "$L"
    ST="$ST$L"
    KM=$KN
  done
  echo "$ST"
}

putei() {
  st=$1
  ii=${#st}
  while [ $ii -ge 0 ] 
  do
    eips -z 2 38  # scroll
    eips 0 39 "$(echo $st | cut -b-50)"  # write to the bottom
    st="$(echo $st | cut -b51-)"
    ii=$(( ii - 50 ))
  done
}


killall -stop cvm launchpad 2>$DN 
cd /mnt/us/fbgnuboy
eips -c;
putei "fbgnuboy - Games Boy Advanced Emulator"
putei ""
putei "Available ROMS -"
putei "$(ls ./roms)"
putei ""
putei "Execute Which ROM?"
HOME=/tmp ./fbgnuboy ./roms/"$(getkb)".gb 2>gnuboy.log
killall -cont cvm launchpad 2>$DN
jmseight is offline   Reply With Quote