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

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