root/modules/script_key_funcs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. script_key_is_pressed
  2. script_key_is_clicked
  3. script_keyid_by_name

   1 #include "camera_info.h"
   2 #include "keyboard.h"
   3 #include "usb_remote.h"
   4 
   5 //-------------------------------------------------------------------
   6 // Lua and uBasic script key helper funtions
   7 
   8 __attribute__((short_call)) int script_key_is_pressed(int k)
   9 {
  10     if (k==0xFF)
  11         return get_usb_power(USB_STATE);
  12     if (k > 0)
  13         return kbd_is_key_pressed(k);
  14     return 0;
  15 }
  16 
  17 __attribute__((short_call)) int script_key_is_clicked(int k)
  18 {
  19     if (k > 0)
  20         return (camera_info.state.kbd_last_clicked == k);
  21     return 0;
  22 }
  23 
  24 static const struct Keynames {
  25     int keyid;
  26     char *keyname;
  27 } keynames[] = {
  28     { KEY_UP,               "up"         },
  29     { KEY_DOWN,             "down"       },
  30     { KEY_LEFT,             "left"       },
  31     { KEY_RIGHT,            "right"      },
  32     { KEY_SET,              "set"        },
  33     { KEY_SHOOT_HALF,       "shoot_half" },
  34     { KEY_SHOOT_FULL,       "shoot_full" },
  35     { KEY_SHOOT_FULL_ONLY,  "shoot_full_only" },
  36     { KEY_ZOOM_IN,          "zoom_in"    },
  37     { KEY_ZOOM_OUT,         "zoom_out"   },
  38     { KEY_MENU,             "menu"       },
  39     { KEY_DISPLAY,          "display"    },
  40     { KEY_PRINT,            "print"      },
  41     { KEY_ERASE,            "erase"      },
  42     { KEY_ISO,              "iso"        },
  43     { KEY_FLASH,            "flash"      },
  44     { KEY_MF,               "mf"         },
  45     { KEY_MACRO,            "macro"      },
  46     { KEY_VIDEO,            "video"      },
  47     { KEY_TIMER,            "timer"      },
  48     { KEY_EXPO_CORR,        "expo_corr"  },
  49     { KEY_MICROPHONE,       "fe"         },
  50     { KEY_FACE,             "face"       },
  51     { KEY_ZOOM_ASSIST,      "zoom_assist"},
  52     { KEY_AE_LOCK,          "ae_lock"    },
  53     { KEY_METERING,         "metering_mode"},
  54     { KEY_PLAYBACK,         "playback"   },
  55     { KEY_HELP,             "help"       },
  56     { KEY_MODE,             "mode"       },
  57     { KEY_WIFI,             "wifi"       },
  58     { KEY_FRAMING_ASSIST,   "framing_assist" },
  59         { KEY_AUTO,             "auto"       },
  60     { 0xFF,                 "remote"     },
  61     { 0xFFFF,               "no_key"     },
  62 };
  63 
  64 __attribute__((short_call)) int script_keyid_by_name (const char *n)
  65 {
  66     unsigned i;
  67     for (i=0;i<sizeof(keynames)/sizeof(keynames[0]);i++)
  68     if (strcmp(keynames[i].keyname,n) == 0)
  69         return keynames[i].keyid;
  70     return 0;
  71 }
  72 
  73 //-------------------------------------------------------------------

/* [<][>][^][v][top][bottom][index][help] */