Changeset 1032 for trunk


Ignore:
Timestamp:
01/09/11 00:38:10 (2 years ago)
Author:
reyalP
Message:

script key handling rework from ultima in http://chdk.setepontos.com/index.php?topic=5793.msg59376#msg59376

Location:
trunk/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/action_stack.c

    r1004 r1032  
    143143} 
    144144 
     145void action_wait_for_click(int timeout) 
     146{ 
     147    action_push(timeout); 
     148    action_push(AS_WAIT_CLICK); 
     149} 
     150 
    145151// Can only be called from an action stack 
    146152void action_push(long p) 
  • trunk/core/action_stack.h

    r1000 r1032  
    3030void action_push_release(long key); 
    3131void action_push_click(long key); 
     32void action_wait_for_click(int timeout); 
    3233void action_pop(); 
    3334long action_get_prev(int p); 
  • trunk/core/kbd.c

    r1021 r1032  
    107107#endif 
    108108 
    109 void camera_press(const char *s) 
    110 { 
    111     long k = keyid_by_name(s); 
    112     if (k > 0) { 
    113         action_push_press(k); 
    114     } else { 
    115         ubasic_error = 3; 
    116     } 
    117 } 
    118  
    119 void camera_release(const char *s) 
    120 { 
    121     long k = keyid_by_name(s); 
    122     if (k > 0) { 
    123         action_push_release(k); 
    124     } else { 
    125         ubasic_error = 3; 
    126     } 
    127 } 
    128  
    129 void camera_click(const char *s) 
    130 { 
    131     long k = keyid_by_name(s); 
    132     if (k > 0) { 
    133         action_push_click(k); 
    134     } else { 
    135         ubasic_error = 3; 
    136     } 
    137 } 
    138  
    139 void camera_wait_click(int timeout) 
    140 { 
    141     action_push(timeout); 
    142     action_push(AS_WAIT_CLICK); 
    143 } 
    144  
    145 int camera_is_pressed(const char *s) 
    146 { 
    147     long k = keyid_by_name(s); 
    148     if (k==0xFF) return get_usb_power(1); 
    149         if (k > 0) { 
    150         return (kbd_is_key_pressed(k)); 
    151     } else { 
    152         ubasic_error = 3; 
    153     } 
    154     return 0; 
    155 } 
    156  
    157 int camera_is_clicked(const char *s) 
    158 { 
    159     long k = keyid_by_name(s); 
    160     if (k==0xFF) return get_usb_power(1); 
    161         if (k > 0) { 
    162         return (kbd_last_clicked == k); 
    163     } else { 
    164         ubasic_error = 3; 
    165     } 
    166     return 0; 
    167 } 
    168  
    169 void camera_sleep(long v) 
    170 { 
    171     action_push_delay(v); 
    172 } 
    173  
    174 void camera_shoot() 
    175 { 
    176     action_push(AS_SHOOT); 
    177 } 
    178109// remote autostart 
    179110void script_autostart() 
  • trunk/core/luascript.c

    r1021 r1032  
    510510{ 
    511511  int timeout = luaL_optnumber( L, 1, 0 ); 
    512   camera_wait_click(timeout); 
     512  action_wait_for_click(timeout); 
    513513  return lua_yield( L, 0 ); 
    514514} 
  • trunk/core/script.c

    r1020 r1032  
    1010#include "action_stack.h" 
    1111#include "luascript.h" 
     12#include "lauxlib.h" 
    1213#include "motion_detector.h" 
    1314#include "shot_histogram.h" 
     
    651652} 
    652653 
     654int camera_is_pressed(const char *s) 
     655{ 
     656    long k = keyid_by_name(s); 
     657    if (k==0xFF) return get_usb_power(1); 
     658    if (k > 0) { 
     659        return (kbd_is_key_pressed(k)); 
     660    } else { 
     661        if (is_lua()) 
     662            luaL_error( L, "unknown key" ); 
     663        else 
     664            ubasic_error = UBASIC_E_UNK_KEY; 
     665    } 
     666    return 0; 
     667} 
     668 
     669int camera_is_clicked(const char *s) 
     670{ 
     671    long k = keyid_by_name(s); 
     672    if (k==0xFF) return get_usb_power(1); 
     673    if (k > 0) { 
     674        return (kbd_last_clicked == k); 
     675    } else { 
     676        if (is_lua()) 
     677            luaL_error( L, "unknown key" ); 
     678        else 
     679            ubasic_error = UBASIC_E_UNK_KEY; 
     680    } 
     681    return 0; 
     682} 
     683 
     684 
     685void camera_press(const char *s) 
     686{ 
     687    // For Lua, luaCB_keyfunc handles this command. 
     688 
     689    long k = keyid_by_name(s); 
     690    if (k > 0) { 
     691        action_push_press(k); 
     692    } else { 
     693        ubasic_error = UBASIC_E_UNK_KEY; 
     694    } 
     695} 
     696 
     697void camera_release(const char *s) 
     698{ 
     699    // For Lua, luaCB_keyfunc handles this command. 
     700 
     701    long k = keyid_by_name(s); 
     702    if (k > 0) { 
     703        action_push_release(k); 
     704    } else { 
     705        ubasic_error = UBASIC_E_UNK_KEY; 
     706    } 
     707} 
     708 
     709void camera_click(const char *s) 
     710{ 
     711    // For Lua, luaCB_keyfunc handles this command. 
     712 
     713    long k = keyid_by_name(s); 
     714    if (k > 0) { 
     715        action_push_click(k); 
     716    } else { 
     717        ubasic_error = UBASIC_E_UNK_KEY; 
     718    } 
     719} 
     720 
     721void camera_shoot() 
     722{ 
     723    action_push(AS_SHOOT); 
     724} 
     725 
     726void camera_sleep(long v) 
     727{ 
     728    action_push_delay(v); 
     729} 
     730 
     731void camera_wait_click(int t) 
     732{ 
     733    action_wait_for_click(t); 
     734} 
     735 
Note: See TracChangeset for help on using the changeset viewer.