Wikia

CHDK Wiki

Changes: UBASIC/Scripts: Button test

Edit

Back to page

(New page: == Test Keys == :'''Written for/on:''' A560 :'''Also works on:''' All the models :'''Required CHDK build:''' any (tested with SDM-CHDK) Useful script to know the button names on your mod...)
 
 
Line 82: Line 82:
 
end
 
end
   
  +
</pre>
  +
  +
Here's an updated version that has the keys for the S series cameras (macro, flash, timer, video, iso, mf) and I also added zoom in and zoom out. And I got rid of the time limit so the script now runs as long as you want.
  +
  +
<pre>
  +
@title Test Keys
  +
  +
sleep 1000
  +
  +
print "Press a key"
  +
  +
:loop
  +
wait_click
  +
is_key k "left"
  +
if k=1 then gosub "kleft"
  +
is_key k "right"
  +
if k=1 then gosub "kright"
  +
is_key k "down"
  +
if k=1 then gosub "kdown"
  +
is_key k "up"
  +
if k=1 then gosub "kup"
  +
is_key k "print"
  +
if k=1 then gosub "kprint"
  +
is_key k "erase"
  +
if k=1 then gosub "kerase"
  +
is_key k "set"
  +
if k=1 then gosub "kset"
  +
is_key k "menu"
  +
if k=1 then gosub "kmenu"
  +
is_key k "display"
  +
if k=1 then gosub "kdisplay"
  +
is_key k "no_key"
  +
if k=1 then gosub "unknown"
  +
  +
is_key k "zoom_in"
  +
if k=1 then gosub "zoom_in"
  +
is_key k "zoom_out"
  +
if k=1 then gosub "zoom_out"
  +
  +
  +
rem begin S series buttons
  +
is_key k "video"
  +
if k=1 then gosub "video"
  +
is_key k "iso"
  +
if k=1 then gosub "iso"
  +
is_key k "flash"
  +
if k=1 then gosub "flash"
  +
is_key k "mf"
  +
if k=1 then gosub "mf"
  +
is_key k "timer"
  +
if k=1 then gosub "timer"
  +
is_key k "macro"
  +
if k=1 then gosub "macro"
  +
goto "loop"
  +
  +
:unknown
  +
print "unknown key"
  +
return
  +
  +
:kleft
  +
print "left"
  +
return
  +
  +
:kup
  +
print "up"
  +
return
  +
  +
:kdown
  +
print "down"
  +
return
  +
  +
:kright
  +
print "right"
  +
return
  +
  +
:kprint
  +
print "print"
  +
return
  +
  +
:kerase
  +
print "erase"
  +
return
  +
  +
:kset
  +
print "set"
  +
return
  +
  +
:kmenu
  +
print "menu"
  +
return
  +
  +
:kdisplay
  +
print "display"
  +
return
  +
  +
:zoom_in
  +
print "zoom_in"
  +
return
  +
  +
:zoom_out
  +
print "zoom_out"
  +
return
  +
  +
  +
rem Begin S series buttons
  +
  +
:video
  +
print "video"
  +
return
  +
  +
:iso
  +
print "iso"
  +
return
  +
  +
:flash
  +
print "flash"
  +
return
  +
  +
:mf
  +
print "mf"
  +
return
  +
  +
:macro
  +
print "macro"
  +
return
  +
  +
:timer
  +
print "timer"
  +
return
  +
  +
:macro
  +
print "macro"
  +
return
  +
  +
:end
  +
end
 
</pre>
 
</pre>
   

Latest revision as of 19:55, February 18, 2008

Test Keys Edit

Written for/on: A560
Also works on: All the models
Required CHDK build: any (tested with SDM-CHDK)

Useful script to know the button names on your model: will wait for a key to be pressed and print its name on the console.

Script Code (save as "test-keys.bas" to your /CHDK/SCRIPTS/ folder)

@title Test Keys

sleep 1000

:loop
        print "Press a key"
        wait_click 2500
        is_key k "left"
        if k=1 then gosub "kleft"
        is_key k "right"
        if k=1 then gosub "kright"
        is_key k "down"
        if k=1 then gosub "kdown"
        is_key k "up"
        if k=1 then gosub "kup"
        is_key k "print"
        if k=1 then gosub "kprint"
        is_key k "erase"
        if k=1 then gosub "kerase"
        is_key k "set"
        if k=1 then gosub "kset"
        is_key k "menu"
        if k=1 then gosub "kmenu"
        is_key k "display"
        if k=1 then gosub "kdisplay"
        is_key k "no_key"
        if k=1 then gosub "timeout"
goto "loop"

:timeout
print "timeout"
goto "end"

:kleft
print "left"
return

:kup
print "up"
return

:kdown
print "down"
return

:kright
print "right"
return

:kprint
print "print"
return

:kerase
print "erase"
return

:kset
print "set"
return

:kmenu
print "menu"
return

:kdisplay
print "display"
return

:end
end

Here's an updated version that has the keys for the S series cameras (macro, flash, timer, video, iso, mf) and I also added zoom in and zoom out. And I got rid of the time limit so the script now runs as long as you want.

@title Test Keys

sleep 1000

print "Press a key"

:loop
        wait_click
        is_key k "left"
        if k=1 then gosub "kleft"
        is_key k "right"
        if k=1 then gosub "kright"
        is_key k "down"
        if k=1 then gosub "kdown"
        is_key k "up"
        if k=1 then gosub "kup"
        is_key k "print"
        if k=1 then gosub "kprint"
        is_key k "erase"
        if k=1 then gosub "kerase"
        is_key k "set"
        if k=1 then gosub "kset"
        is_key k "menu"
        if k=1 then gosub "kmenu"
        is_key k "display"
        if k=1 then gosub "kdisplay"
        is_key k "no_key"
        if k=1 then gosub "unknown"

        is_key k "zoom_in"
        if k=1 then gosub "zoom_in"
        is_key k "zoom_out"
        if k=1 then gosub "zoom_out"


	rem begin S series buttons
        is_key k "video"
        if k=1 then gosub "video"
        is_key k "iso"
        if k=1 then gosub "iso"
        is_key k "flash"
        if k=1 then gosub "flash"
        is_key k "mf"
        if k=1 then gosub "mf"
        is_key k "timer"
        if k=1 then gosub "timer"
        is_key k "macro"
        if k=1 then gosub "macro"
goto "loop"

:unknown
print "unknown key"
return

:kleft
print "left"
return

:kup
print "up"
return

:kdown
print "down"
return

:kright
print "right"
return

:kprint
print "print"
return

:kerase
print "erase"
return

:kset
print "set"
return

:kmenu
print "menu"
return

:kdisplay
print "display"
return

:zoom_in
print "zoom_in"
return

:zoom_out
print "zoom_out"
return


rem Begin S series buttons

:video
print "video"
return

:iso
print "iso"
return

:flash
print "flash"
return

:mf
print "mf"
return

:macro
print "macro"
return

:timer
print "timer"
return

:macro
print "macro"
return

:end
end

--62.202.127.92

Around Wikia's network

Random Wiki