コード例 #1
0
ファイル: kbd_common.c プロジェクト: adongy/ixus160_elph160
long kbd_use_zoom_as_mf() {
    static long zoom_key_pressed = 0;

    if (kbd_is_key_pressed(KEY_ZOOM_IN) && camera_info.state.mode_rec) {
        if (shooting_get_focus_mode()) {
            kbd_key_release_all();
            kbd_key_press(KEY_RIGHT);
            zoom_key_pressed = KEY_ZOOM_IN;
            return 1;
        }
    } else {
        if (zoom_key_pressed==KEY_ZOOM_IN) {
            kbd_key_release(KEY_RIGHT);
            zoom_key_pressed = 0;
            return 1;
        }
    }
    if (kbd_is_key_pressed(KEY_ZOOM_OUT) && camera_info.state.mode_rec) {
        if (shooting_get_focus_mode()) {
            kbd_key_release_all();
            kbd_key_press(KEY_LEFT);
            zoom_key_pressed = KEY_ZOOM_OUT;
            return 1;
        }
    } else {
        if (zoom_key_pressed==KEY_ZOOM_OUT) {
            kbd_key_release(KEY_LEFT);
            zoom_key_pressed = 0;
            return 1;
        }
    }
    return 0;
}
コード例 #2
0
ファイル: kbd_process.c プロジェクト: BioDesignRealWorld/CHDK
long kbd_get_autoclicked_key()
{
	register long key, t;

	key=kbd_get_clicked_key();
	if (key && (key != last_kbd_key))
    {
		last_kbd_key = key;
		press_count = 0;
		last_kbd_time = get_tick_count();
		return key;
	}
    else
    {
		if (last_kbd_key && kbd_is_key_pressed(last_kbd_key))
        {
			t = get_tick_count();
			if (t-last_kbd_time > ((press_count) ? KBD_REPEAT_DELAY : KBD_INITIAL_DELAY))
            {
				++press_count;
				last_kbd_time = t;
				return last_kbd_key;
			}
            else
            {
				return 0;
			}
		}
        else
        {
			last_kbd_key = 0;
			return 0;
		}
	}
}
コード例 #3
0
__attribute__((short_call)) int script_key_is_pressed(int k)
{
    if (k==0xFF)
        return get_usb_power(1);
    if (k > 0)
        return kbd_is_key_pressed(k);
    return 0;
}
コード例 #4
0
ファイル: kbd.c プロジェクト: shentok/chdk-a430
int ubasic_camera_is_pressed(const char *s)
{
    long k = keyid_by_name(s);
    if (k==0xFF) return get_usb_power(1);
	if (k > 0) {
        return (kbd_is_key_pressed(k));
    } else {
	ubasic_error = 3;
    }
    return 0;
}
コード例 #5
0
ファイル: gui_osd.c プロジェクト: de-wolff/CHDK
void gui_kbd_shortcuts()
{
    static int half_disp_press_old=0;
    
    if (camera_info.state.is_shutter_half_press)
    {
        if (conf.enable_shortcuts == 1)
        {
            kbd_shortcut(SHORTCUT_TOGGLE_ZEBRA, &conf.zebra_draw, 1);
            kbd_shortcut(SHORTCUT_TOGGLE_HISTO, &conf.show_histo, SHOW_HISTO_HALF);
            kbd_shortcut(SHORTCUT_TOGGLE_OSD, &conf.show_osd, 1);
            kbd_shortcut(SHORTCUT_DISABLE_OVERRIDES, &conf.override_disable, 1);
        }
#if !CAM_HAS_MANUAL_FOCUS && CAM_HAS_ZOOM_LEVER
        // Todo, check for AF and if its running, don't override
        if (kbd_is_key_pressed(SHORTCUT_SD_SUB)) {
            if (!(conf.override_disable==1) && shooting_can_focus() && shooting_get_common_focus_mode()) {
                gui_subj_dist_override_value_enum(-1,0);
                shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
            }
        } else if (kbd_is_key_pressed(SHORTCUT_SD_ADD)) {
            if (!(conf.override_disable==1) && shooting_can_focus() && shooting_get_common_focus_mode()) {
                gui_subj_dist_override_value_enum(1,0);
                shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
            }
        }
#endif
    }

    half_disp_press = camera_info.state.mode_photo && camera_info.state.is_shutter_half_press && kbd_is_key_pressed(KEY_DISPLAY);
    if (half_disp_press && !half_disp_press_old)
        gui_set_need_restore();
#ifdef CAM_DISP_ALT_TEXT
    if (half_disp_press)
    {
        extern void gui_reset_alt_helper();
        gui_reset_alt_helper();
    }
#endif
    half_disp_press_old = half_disp_press;
}
コード例 #6
0
ファイル: gui_menu.c プロジェクト: DIYBookScanner/chdk
// Move up / down in menu, adjusting scroll position if needed
//   increment = -1 to move up, 1 to move down
static void gui_menu_updown(int increment)
{
    int c, j;

    // Determine number of rows to move (1 or 4)
    if (camera_info.state.is_shutter_half_press || kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) c=4; else c=1;

    for (j = 0; j < c; ++j)
    {
        do
        {
            // Move to next or previous row
            gui_menu_curr_item += increment;

            if (gui_menu_curr_item < 0)                                     // Off top, move to bottom
            {
                gui_menu_curr_item = gui_menu_rows() - 1;
                gui_menu_top_item = gui_menu_curr_item - num_lines + 1;
            }
            else if (gui_menu_curr_item >= gui_menu_rows())                 // Off bottom, move to top
            {
                gui_menu_curr_item = gui_menu_top_item = 0;
            }
            else if (increment == 1)                                        // Still in menu, if moving down adjust scroll if needed
            {
                if (gui_menu_curr_item - gui_menu_top_item >= num_lines - 1)
                {
                    gui_menu_top_item = gui_menu_curr_item - num_lines + 2;
                    if (gui_menu_top_item + num_lines > gui_menu_rows()) gui_menu_top_item = gui_menu_rows() - num_lines;
                }
            }
            else                                                            // Still in menu, and moving up, adjust scroll
            {
                if (gui_menu_curr_item == gui_menu_top_item) 
                    --gui_menu_top_item;
            }

            // Check in case scroll moved off top of menu
            if (gui_menu_top_item < 0) gui_menu_top_item = 0;
        } while ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || 
                 (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR);

        // Reset amount to increment integer values by
        int_incr = 1;
        if (((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_STATE_VAL_PAIR) &&
            (curr_menu->menu[gui_menu_curr_item].arg > 0))
            int_incr = curr_menu->menu[gui_menu_curr_item].arg;

        // Redraw menu if needed
        if (gui_menu_redraw == 0) gui_menu_redraw=1;
    }
}
コード例 #7
0
// Move up / down in menu, adjusting scroll position if needed
//   increment = -1 to move up, 1 to move down
static void gui_menu_updown(int increment)
{
    int c, j;

    if (count == 0) return;

    // Determine number of rows to move (1 or 4)
    if (camera_info.state.is_shutter_half_press || kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) c=4; else c=1;

    for (j = 0; j < c; ++j)
    {
        do
        {
            // Move to next or previous row
            gui_menu_curr_item += increment;

            if (gui_menu_curr_item < 0)                                     // Off top, move to bottom
            {
                gui_menu_curr_item = gui_menu_rows() - 1;
                gui_menu_top_item = gui_menu_curr_item - num_lines + 1;
            }
            else if (gui_menu_curr_item >= gui_menu_rows())                 // Off bottom, move to top
            {
                gui_menu_curr_item = gui_menu_top_item = 0;
            }
            else if (increment == 1)                                        // Still in menu, if moving down adjust scroll if needed
            {
                if (gui_menu_curr_item - gui_menu_top_item >= num_lines - 1)
                {
                    gui_menu_top_item = gui_menu_curr_item - num_lines + 2;
                    if (gui_menu_top_item + num_lines > gui_menu_rows()) gui_menu_top_item = gui_menu_rows() - num_lines;
                }
            }
            else                                                            // Still in menu, and moving up, adjust scroll
            {
                if (gui_menu_curr_item == gui_menu_top_item) 
                    --gui_menu_top_item;
            }

            // Check in case scroll moved off top of menu
            if (gui_menu_top_item < 0) gui_menu_top_item = 0;
        } while (!validrow(gui_menu_curr_item));

        // Redraw menu if needed
        if (gui_menu_redraw == 0) gui_menu_redraw=1;
    }
}
コード例 #8
0
ファイル: wrappers.c プロジェクト: c10ud/CHDK
long lens_get_focus_pos()
{
    static long v=CAMERA_MAX_DIST;
    return (kbd_is_key_pressed(KEY_SHOOT_HALF) || camera_info.state.state_kbd_script_run  || shooting_get_common_focus_mode())?v=_GetFocusLensSubjectDistance():v;
//  return _GetFocusLensSubjectDistance();
}
コード例 #9
0
ファイル: edgeoverlay.c プロジェクト: de-wolff/CHDK
static int draw_edge_overlay()
{
    int shutter_fullpress = kbd_is_key_pressed(KEY_SHOOT_FULL);

    int x, y;
    int x_off, y_off;

    const color cl = FG_COLOR(user_color(conf.edge_overlay_color));
    const int y_slice_min = camera_screen.edge_hmargin+ slice   *slice_height;
    const int y_slice_max = camera_screen.edge_hmargin+(slice+1)*slice_height;
    const int y_min = camera_screen.edge_hmargin;
    const int y_max = camera_screen.edge_hmargin+viewport_height;
    const int x_min = 2;
    const int x_max = (viewport_width - 2);

    if( !is_buffer_ready() ) return 0;

    for (y = y_slice_min; y < y_slice_max; ++y)
    {
        y_off = y + yoffset;
        
        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL);

        if ((unsigned)(y_off-y_min) < (y_max-y_min)) // is the same as ((y_off > y_min) && (y_off < y_max)) // do not draw outside of allowed area
        {
            const int y_edgebuf = (y-y_min) * viewport_width;

            for (x = x_min; x < x_max; ++x)
            {
                x_off = x + xoffset;

                if ((unsigned)(x_off-x_min) < (x_max-x_min)) // is the same as  ((x_off > x_min) && (x_off < x_max)) // do not draw outside of allowed area
                {
                    // Draw a pixel to the screen wherever we detected an edge.
                    // If there is no edge based on the newest data, but there is one painted on the screen
                    // from previous calls, delete it from the screen.
                    const int bEdge = bv_get(edgebuf, y_edgebuf + x);
                    const int bDraw = bEdge || (draw_get_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset) == cl);
                    if (bEdge || bDraw)
                        draw_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset, bEdge ? cl : 0);
                    
                }
            }   // for x
        }
    }   // for y


    // Drawing the overlay is over.
    // But as a finishing touch we clear up garbage on the screen
    // by clearing those parts that the overlay has left.

    if (xoffset != 0)
    {
        // Cleans up leftover from horizontal motion

        const int x_min_c = (xoffset < 0) ? x_max + xoffset : x_min;
        const int x_max_c = (xoffset > 0) ? x_min + xoffset : x_max;

        for (y = y_min; y < y_max; ++y)
        {
            for (x = x_min_c; x < x_max_c; ++x)
            {
                // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen
                if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl)
                    draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 );
            }
        }
    }

    if (yoffset != 0)
    {
        // Cleans up leftover from vertical motion

        const int y_min_c = (yoffset < 0) ? y_max + yoffset : y_min;
        const int y_max_c = (yoffset > 0) ? y_min + yoffset : y_max;

        for (y = y_min_c; y < y_max_c; ++y)
        {
            for (x = x_min; x < x_max; ++x)
            {
                // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen
                if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl)
                    draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 );
            }
        }
    }

    return shutter_fullpress;
}
コード例 #10
0
ファイル: edgeoverlay.c プロジェクト: de-wolff/CHDK
// Main edge overlay function.
// It works by detecting edges using the Sobel operator
// (calc_edgeoverlay()), the detected edges are then stored into an
// array of 1-bit elements. A set bit indicates that there is an
// edge and that it should be drawn onto the overlay.
// When needed, the 1-bit edge buffer is drawn onto the screen
// (dynamically decompressing it) using draw_edge_overlay().
void edge_overlay()
{
    // Was the shutter fully pressed the last time we ran?
    // We use this to make sure that the user has released
    // the button before processing the next FullPress event.
    // This prevents switching FSM states more than once
    // per press.
    static int bFullPress_prev = 0;

    // Have we already started taking pictures in panorama mode?
    // We use this variable to be able to detect if panorama
    // mode has been turned off.
    static int bPanoInProgress = 0;

    // Precalculate some values to make the rest of the
    // code easier to read.
    int bFullPress = kbd_is_key_pressed(KEY_SHOOT_FULL);
    const int bHalfPress = camera_info.state.is_shutter_half_press;
    const int bPlayMode = camera_info.state.mode_play;
    const int bPanoramaMode = (conf.edge_overlay_pano != 0);
    const int bNeedHalfPress = (conf.edge_overlay_show != 1);
    const int bDisplayInPlay = (conf.edge_overlay_play == 1);
    const int bCanDisplay = (
                                (!bPlayMode && (bHalfPress || !bNeedHalfPress)) ||   // we have a HalfPress in rec-mode
                                ( bPlayMode && bDisplayInPlay)  // or we are in play-mode with the right settings
                            );

    if (bPanoInProgress && !bPanoramaMode)
    {
        // This means panorama mode has been recently
        // turned off in the menu. So let's release
        // Frozen mode for the user.
        reset_edge_overlay();
        bPanoInProgress = 0;
    }

    get_viewport_size();

    // For just two states a state machine is not actually needed.
    // But it is scalable in the future in case anybody
    // wants to extend the functionality of edge overlay.
    switch (fsm_state)
    {
    case EDGE_LIVE:
    {
        camera_info.state.edge_state_draw=0;
        // In this state we assume no edge overlay in memory,
        // but we are ready to create one if the user presses wishes so.

        int bRealtimeUpdate = bCanDisplay && (camera_info.state.gui_mode_alt || camera_info.state.gui_mode_none);
        if (bRealtimeUpdate)
        {
            // We try to detect button presses during the lengthy
            // calculations.
            bFullPress |= calc_edge_overlay();
            bFullPress |= draw_edge_overlay();
        }

        int bSwitch2Frozen = bFullPress && !bFullPress_prev && camera_info.state.gui_mode_none;
        if (bSwitch2Frozen)
        {
            // Switch to Frozen mode

            // Make sure we have one whole consistent frame
            for (slice = 0; slice < EDGE_SLICES; ++slice)
                calc_edge_overlay();

            set_offset_from_overlap();
            fsm_state = EDGE_FROZEN;
            bPanoInProgress = bPanoramaMode;
        }

        if (!bRealtimeUpdate && !bSwitch2Frozen)
        {
            // Nothing happens. So do nothing.
            // Or rather, we could clean up if we are that bored.
            reset_edge_overlay();
        }
        break;
    }
    case EDGE_FROZEN:
    {
        camera_info.state.edge_state_draw=1;
        // We have a stored edge overlay in memory and we display
        // it on screen in 'frozen' mode.

        // Move edge overlay around.
        if (camera_info.state.gui_mode_alt)
        {
            if (kbd_is_key_pressed(KEY_RIGHT))
                xoffset +=XINC;
            if (kbd_is_key_pressed(KEY_LEFT))
                xoffset -=XINC;
            if (kbd_is_key_pressed(KEY_DOWN))
                yoffset +=YINC;
            if (kbd_is_key_pressed(KEY_UP))
                yoffset -=YINC;
        }

        if (bCanDisplay && (camera_info.state.gui_mode_alt || camera_info.state.gui_mode_none))
        {
            // We try to detect button presses during the lengthy
            // calculations.
            bFullPress |= draw_edge_overlay();
            //draw_string(0, 0, "Frozen", user_color(conf.osd_color));
        }

        // In event of a FullPress, we either capture a new
        // overlay and stay frozen, OR we go back to live mode.
        if (bFullPress && !bFullPress_prev && camera_info.state.gui_mode_none)
        {
            // Possible mode switch
            if (bPanoramaMode)
            {
                // Make sure we have one whole consistent frame
                for (slice = 0; slice < EDGE_SLICES; ++slice)
                    calc_edge_overlay();

                set_offset_from_overlap();
                bPanoInProgress = 1;
            }
            else
                fsm_state = EDGE_LIVE;
        }

        break;
    }   // case
    }   // switch


    bFullPress_prev = bFullPress;

    if (++slice >= EDGE_SLICES)
        slice = 0;

}   // function
コード例 #11
0
ファイル: kbd_process.c プロジェクト: BioDesignRealWorld/CHDK
//-------------------------------------------------------------------
// Core keyboard handler
long kbd_process()
{
    static int key_pressed;

    if (camera_info.perf.md_af_tuning)
    {
        switch (camera_info.perf.md_af_on_flag)
        {
        case 1:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay))
            {
                camera_info.perf.md_af_on_flag = 2;
                camera_set_led(camera_info.cam_af_led,1,200);
            }
            break;
        case 2:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay + camera_info.perf.md_af_on_time))
            {
                camera_info.perf.md_af_on_flag = 0;
                camera_set_led(camera_info.cam_af_led,0,0);
            }
            break;
        }
    }

    // Reset keyboard auto repeat if no buttons pressed
    if (kbd_get_pressed_key() == 0)
        last_kbd_key = 0;

    // Set clicked key for scripts.
    if (kbd_get_clicked_key())
    {
        camera_info.state.kbd_last_clicked = kbd_get_clicked_key();
        camera_info.state.kbd_last_clicked_time = get_tick_count();
    }

    // Set Shutter Half Press state for GUI task.
    camera_info.state.is_shutter_half_press = kbd_is_key_pressed(KEY_SHOOT_HALF);

	// Alternative keyboard mode stated/exited by pressing print key.
	// While running Alt. mode shoot key will start a script execution.

	// alt-mode switch and delay emulation
 
	if ( key_pressed  && !usb_remote_active ) 
	{
        if (kbd_is_key_pressed(conf.alt_mode_button)
                || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
                && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
        {
            if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                key_pressed++;
            if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) 
                kbd_key_press(conf.alt_mode_button);
            else if (key_pressed == CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                kbd_key_release(conf.alt_mode_button);
            return 1;
        } 
        else if (kbd_get_pressed_key() == 0)
        {
            if (key_pressed < CAM_EMUL_KEYPRESS_DELAY)
            {
                if (!kbd_blocked) 
                    enter_alt();
                else
                    exit_alt();
            }
            key_pressed = 0;
            return 1;
        }
        return 1;
    }
       
    // auto iso shift
    if (camera_info.state.is_shutter_half_press && kbd_is_key_pressed(conf.alt_mode_button)) 
        return 0;

    if (kbd_is_key_pressed(conf.alt_mode_button)) 
	{
        key_pressed = 1;
        kbd_key_release_all();          
        return 1;
    }

#ifdef CAM_TOUCHSCREEN_UI
    extern int ts_process_touch();
    if (ts_process_touch())
    {
        gui_set_need_restore();
    }
#endif

    // deals with the rest

    if ( !kbd_blocked || usb_remote_active ) 
	{
		kbd_blocked = handle_usb_remote();
	}

    if (gui_kbd_process())
        return 1;

    action_stack_process_all();

    return kbd_blocked;
}
コード例 #12
0
ファイル: edgeoverlay.c プロジェクト: de-wolff/CHDK
// Sobel edge detector
static int calc_edge_overlay()
{
    int shutter_fullpress = kbd_is_key_pressed(KEY_SHOOT_FULL);

    const unsigned char* img = vid_get_viewport_active_buffer();
    if (!img) return shutter_fullpress;

    const unsigned char*  ptrh1 = NULL;    // previous pixel line
    const unsigned char*  ptrh2 = NULL;    // current pixel line
    const unsigned char*  ptrh3 = NULL;    // next pixel line
    unsigned char*  smptr = NULL;    // pointer to line in smbuf
    int x, y, xdiv3;
    int conv1, conv2;

    const int y_min = camera_screen.edge_hmargin+ slice   *slice_height;
    const int y_max = camera_screen.edge_hmargin+(slice+1)*slice_height;
    const int x_min = 6;
    const int x_max = (viewport_width - 2) * 3;

    img += vid_get_viewport_image_offset();		// offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD)

    xoffset = 0;
    yoffset = 0;

    // Reserve buffers
    ensure_allocate_imagebuffer();
    if( !is_buffer_ready() ) return 0;

    // In every 6 bytes the Y of four pixels are described in the
    // viewport (UYVYYY format). For edge detection we only
    // consider the second in the current and the first
    // in the next pixel.

    // Clear all edges in the current slice
    int compressed_slice = edgebuf->ptrLen / EDGE_SLICES;
    memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice);

    if (conf.edge_overlay_filter)
    {
        // Prefill smbuf with three lines of avergae-filtered data.
        // This looks much more complex then it actually is.
        // We really are just summing up nine pixels in a 3x3 box
        // and averaging the current pixel based on them. And
        // we do it 4 bytes at a time because of the UYVYYY format.
        for (y = -1; y <= 1; ++y)
        {
            shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL);

            ptrh1 = img + (y_min+y-1) * viewport_byte_width*viewport_yscale;
            smptr = smbuf + (y+1) * viewport_byte_width;

            average_filter_row(ptrh1, smptr, x_min, x_max);
        }
    }

    for (y = y_min; y < y_max; ++y)
    {
        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL);

        if (conf.edge_overlay_filter)
        {
            // We need to shift up our smbuf one line,
            // and fill in the last line (which now empty)
            // with average-filtered data from img.
            // By storing only three lines of smoothed picture
            // in memory, we save memory.

            // Shift
            memcpy(smbuf, smbuf+viewport_byte_width, viewport_byte_width*2);

            // Filter new line
            ptrh1 = img + y * viewport_byte_width*viewport_yscale;
            smptr = smbuf + 2 * viewport_byte_width;
            average_filter_row(ptrh1, smptr, x_min, x_max);

            ptrh1 = smbuf;
        }
        else
        {
            ptrh1 = img + (y-1) * viewport_byte_width*viewport_yscale;
        }
        ptrh2 = ptrh1 + viewport_byte_width*viewport_yscale;
        ptrh3 = ptrh2 + viewport_byte_width*viewport_yscale;

        // Now we do sobel on the current line

        for (x = x_min, xdiv3 = x_min/3; x < x_max; x += 6, xdiv3 += 2)
        {
            // convolve vert (second Y)
            conv1 = *(ptrh1 + x + 1) * ( 1) +
                    *(ptrh1 + x + 4) * (-1) +

                    *(ptrh2 + x + 1) * ( 2) +
                    *(ptrh2 + x + 4) * (-2) +

                    *(ptrh3 + x + 1) * ( 1) +
                    *(ptrh3 + x + 4) * (-1);
            if  (conv1 < 0)     // abs()
                conv1 = -conv1;

            // convolve vert (first Y of next pixel)
            conv2 = *(ptrh1 + x + 1) * ( 1) +
                    *(ptrh1 + x + 3) * ( 2) +
                    *(ptrh1 + x + 4) * ( 1) +

                    *(ptrh3 + x + 1) * (-1) +
                    *(ptrh3 + x + 3) * (-2) +
                    *(ptrh3 + x + 4) * (-1);
            if  (conv2 < 0)     // abs()
                conv2 = -conv2;

            if (conv1 + conv2 > conf.edge_overlay_thresh)
            {
                bv_set(edgebuf, (y-camera_screen.edge_hmargin)*viewport_width + xdiv3, 1);
            }

            // Do it once again for the next 'pixel'

            // convolve vert (second Y)
            conv1 = *(ptrh1 + x + 5) * ( 1) +
                    *(ptrh1 + x + 9) * (-1) +

                    *(ptrh2 + x + 5) * ( 2) +
                    *(ptrh2 + x + 9) * (-2) +

                    *(ptrh3 + x + 5) * ( 1) +
                    *(ptrh3 + x + 9) * (-1);
            if  (conv1 < 0)     // abs()
                conv1 = -conv1;

            // convolve vert (first Y of next pixel)
            conv2 = *(ptrh1 + x + 5) * ( 1) +
                    *(ptrh1 + x + 7) * ( 2) +
                    *(ptrh1 + x + 9) * ( 1) +

                    *(ptrh3 + x + 5) * (-1) +
                    *(ptrh3 + x + 7) * (-2) +
                    *(ptrh3 + x + 9) * (-1);
            if  (conv2 < 0)     // abs()
                conv2 = -conv2;

            if (conv1 + conv2 > conf.edge_overlay_thresh)
            {
                bv_set(edgebuf, (y-camera_screen.edge_hmargin)*viewport_width + xdiv3+1, 1);
            }
        }   // for x
    }   // for y


//  For an even more improved edge overlay, enabling the following lines will
//  post-filter the results of the edge detection, removing false edge 'dots'
//  from the display. However, the speed hit is large. In the developer's opinion
//  this code is not needed, but if you want that additional quality and do not
//  care so much about performance, you can enable it.
//
//    if (conf.edge_overlay_filter)
//    {
//        // Here we do basic filtering on the detected edges.
//        // If a pixel is marked as edge but just a few of its
//        // neighbors are also edges, then we assume that the
//        // current pixel is just noise and delete the mark.
//
//        bit_vector_t* bv_tmp = bv_create(edgebuf->nElem, edgebuf->nBits);
//        if (bv_tmp != NULL)
//        {
//            memset(bv_tmp->ptr, 0, bv_tmp->ptrLen);
//
//            for (y = 1; y < viewport_height-1; ++y)
//            {
//                shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL);
//
//                for (x=12; x<(viewport_width - 4); ++x)
//                {
//                    int bEdge = bv_get(edgebuf, y*viewport_width + x);
//                    if (bEdge)
//                    {
//                        // Count the number of neighbor edges
//                        int sum =
//                            bv_get(edgebuf, (y-1)*viewport_width + (x-1)) +
//                            bv_get(edgebuf, (y-1)*viewport_width + (x)) +
//                            bv_get(edgebuf, (y-1)*viewport_width + (x+1)) +
//
//                            bv_get(edgebuf, (y)*viewport_width + (x-1)) +
////              bv_get(&edgebuf, (y)*viewport_width + (x)) + //  we only inspect the neighbors
//                            bv_get(edgebuf, (y)*viewport_width + (x+1)) +
//
//                            bv_get(edgebuf, (y+1)*viewport_width + (x-1)) +
//                            bv_get(edgebuf, (y+1)*viewport_width + (x)) +
//                            bv_get(edgebuf, (y+1)*viewport_width + (x+1));
//
//                        if (!conf.edge_overlay_show)
//                        {
//                            if (sum >= 5)    // if we have at least 5 neighboring edges
//                                bv_set(bv_tmp, y*viewport_width + x, 1);   // keep the edge
//                            // else
//                            // there is no need to delete because the buffer is already zeroed
//                        }
//                    }
//                }   // for x
//            }   // for y
//
//            // Swap the filtered edge buffer for the real one
//            bit_vector_t* swap_tmp = edgebuf;
//            edgebuf = bv_tmp;
//            bv_free(swap_tmp);
//        }   // NULL-check
//    }   // if filtering

    return shutter_fullpress;
}
コード例 #13
0
ファイル: kbd.c プロジェクト: shentok/chdk-a430
long kbd_use_up_down_left_right_as_fast_switch() {
    static long key_pressed = 0; // ??? static masking a global
    int m=mode_get(); 
    int mode_video = MODE_IS_VIDEO(m) || (movie_status > 1);
    int ev_video=0;
    int jogdial;

#if CAM_EV_IN_VIDEO
    ev_video=get_ev_video_avail(); 
#endif

    if (!(kbd_is_key_pressed(KEY_UP)) && !(kbd_is_key_pressed(KEY_DOWN))) key_pressed = 0;

    if (canon_shoot_menu_active!=0 || (m&MODE_MASK) != MODE_REC)
        return 0;

#if !CAM_HAS_JOGDIAL
    if (kbd_is_key_pressed(KEY_UP) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
        if (conf.fast_ev && key_pressed == 0) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
            key_pressed = KEY_UP;
                
            return 1;
        }

    } 

    if (kbd_is_key_pressed(KEY_DOWN) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
        if (conf.fast_ev && key_pressed == 0) {
            kbd_key_release_all();
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
            key_pressed = KEY_DOWN;
            EnterToCompensationEVF();
            return 1;
        }
    } 

#else
    jogdial=get_jogdial_direction();

    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_RIGHT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }

    if (conf.fast_ev &&kbd_is_key_pressed(KEY_SHOOT_HALF) && (jogdial==JOGDIAL_LEFT) && ((m&MODE_SHOOTING_MASK) != MODE_M) && !mode_video) {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_prop(PROPCASE_EV_CORRECTION_1)-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_prop(PROPCASE_EV_CORRECTION_2)-(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }
     

#endif

    if (kbd_is_key_pressed(KEY_UP) && mode_video && movie_status == 4 ) {
        if (conf.fast_movie_quality_control && key_pressed == 0) {
            if (conf.video_mode==0) {
#if !CAM_VIDEO_QUALITY_ONLY
                conf.video_bitrate+=1;
                if (conf.video_bitrate>=VIDEO_BITRATE_STEPS)
                    conf.video_bitrate=VIDEO_BITRATE_STEPS-1;
                shooting_video_bitrate_change(conf.video_bitrate);
                movie_reset = 1;
#endif
            }    
            else if (conf.video_mode==1) {
                conf.video_quality+=1;
                if (conf.video_quality>VIDEO_MAX_QUALITY)
                    conf.video_quality=VIDEO_MAX_QUALITY;
                movie_reset = 1;
            }              
            key_pressed = KEY_UP;
            return 1;
        }
    } 
    
    if (kbd_is_key_pressed(KEY_DOWN) && mode_video && movie_status == 4) {
        if (conf.fast_movie_quality_control && key_pressed == 0) {
            if (conf.video_mode==0) {                
#if !CAM_VIDEO_QUALITY_ONLY
                conf.video_bitrate-=1;
                if (conf.video_bitrate<0)
                    conf.video_bitrate=0;

                shooting_video_bitrate_change(conf.video_bitrate);
                movie_reset = 1;
#endif
            }
            else if (conf.video_mode==1) {
                conf.video_quality-=1;
                if (conf.video_quality<1)
                    conf.video_quality=1;
                movie_reset = 1;
            }          
            key_pressed = KEY_DOWN;
            return 1;
        }
    } 
    
    if (kbd_is_key_pressed(KEY_LEFT) && mode_video && (movie_status == 4) && !ev_video) {
        if (conf.fast_movie_control && key_pressed == 0) {
            movie_status = VIDEO_RECORD_STOPPED;
            key_pressed = KEY_LEFT;
            return 1;
        }
    } 
	// reyalp - HACK for cams that can do video in any mode
	// note that this means this will probably run whenever you press right
    if (kbd_is_key_pressed(KEY_RIGHT) &&
#ifndef CAM_HAS_VIDEO_BUTTON 
            mode_video &&
#endif
	        (movie_status == 1) && !ev_video) {
        // BUG this doesn't know whether recording was stopped or paused.
        if (conf.fast_movie_control && key_pressed == 0) {
            movie_status = VIDEO_RECORD_IN_PROGRESS;
            movie_reset = 1;
            key_pressed = KEY_RIGHT;
            return 1;
        }
    } 

    return 0;
}
コード例 #14
0
ファイル: wrappers.c プロジェクト: barryk/CHDK-SD1200
long lens_get_focus_pos()
{
    static long v=MAX_DIST;
    return (kbd_is_key_pressed(KEY_SHOOT_HALF) || state_kbd_script_run  || shooting_get_focus_mode())?v=_GetFocusLensSubjectDistance():v;
}
コード例 #15
0
ファイル: wrappers.c プロジェクト: barryk/CHDK-SD1200
long lens_get_target_distance()
{
    static long v=65535;
    return (kbd_is_key_pressed(KEY_SHOOT_HALF) || state_kbd_script_run|| shooting_get_common_focus_mode())?v=_GetCurrentTargetDistance():v;
// return _GetCurrentTargetDistance();
}
コード例 #16
0
ファイル: gui_osd.c プロジェクト: de-wolff/CHDK
//------------------------------------------------------------------- 
// Process up/down/left/right/jogdial shortcuts when control options enabled
static int kbd_use_up_down_left_right_as_fast_switch()
{
    static long key_pressed = 0;
    int ev_video = 0;
    int jogdial;

#if CAM_EV_IN_VIDEO
    ev_video = get_ev_video_avail(); 
#endif

    // One of the control options must be enabled or don't do anything
    if (!conf.fast_ev && !conf.fast_movie_control && !conf.fast_movie_quality_control) return 0;

    // Clear state variable is neither UP or DOWN is pressed
    if (!kbd_is_key_pressed(KEY_UP) && !kbd_is_key_pressed(KEY_DOWN)) key_pressed = 0;

    // Must be in record mode and not have either Canon menu open
    if ( (canon_menu_active!=(int)&canon_menu_active-4) || canon_shoot_menu_active!=0 || !camera_info.state.mode_rec) return 0;

    // Adjust exposure if 'Enable Fast EV switch?' option is set
    if (conf.fast_ev && (key_pressed == 0) && (camera_info.state.mode_shooting != MODE_M))
    {
#if !CAM_HAS_JOGDIAL
        if (kbd_is_key_pressed(KEY_UP))
        {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_ev_correction1()+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_ev_correction2()+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
            key_pressed = KEY_UP;
                    
            return 1;
        } 

        if (kbd_is_key_pressed(KEY_DOWN))
        {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_ev_correction1()-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_ev_correction2()-(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
            key_pressed = KEY_DOWN;

            return 1;
        }
#else
        jogdial=get_jogdial_direction();

        if (camera_info.state.is_shutter_half_press && (jogdial==JOGDIAL_RIGHT))
        {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_ev_correction1()+(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_ev_correction2()+(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }

        if (camera_info.state.is_shutter_half_press && (jogdial==JOGDIAL_LEFT))
        {
            shooting_set_prop(PROPCASE_EV_CORRECTION_1,shooting_get_ev_correction1()-(conf.fast_ev_step+1)*16);
            shooting_set_prop(PROPCASE_EV_CORRECTION_2,shooting_get_ev_correction2()-(conf.fast_ev_step+1)*16);
            EnterToCompensationEVF();
        }
#endif
    } 

    // Adjust video quality/bitrate if 'Video Quality Control?' option is set
    if (conf.fast_movie_quality_control && key_pressed == 0 && is_video_recording())
    {
        if (kbd_is_key_pressed(KEY_UP))
        {
            if (conf.video_mode==0)
            {
#if !CAM_VIDEO_QUALITY_ONLY
                gui_video_bitrate_enum(1,0);
                movie_reset = 1;
#endif
            }    
            else if (conf.video_mode==1)
            {
                conf.video_quality+=1;
                if (conf.video_quality>VIDEO_MAX_QUALITY)
                    conf.video_quality=VIDEO_MAX_QUALITY;
                movie_reset = 1;
            }              
            key_pressed = KEY_UP;
            return 1;
        }
    
        if (kbd_is_key_pressed(KEY_DOWN))
        {
            if (conf.video_mode==0)
            {
#if !CAM_VIDEO_QUALITY_ONLY
                conf.video_bitrate-=1;
                if (conf.video_bitrate<0)
                    conf.video_bitrate=0;

                shooting_video_bitrate_change(conf.video_bitrate);
                movie_reset = 1;
#endif
            }
            else if (conf.video_mode==1)
            {
                conf.video_quality-=1;
                if (conf.video_quality<1)
                    conf.video_quality=1;
                movie_reset = 1;
            }          
            key_pressed = KEY_DOWN;
            return 1;
        }
    } 
    
#if CAM_VIDEO_CONTROL
    // Pause / unpause video if 'Fast Movie Control' option is set
    if (conf.fast_movie_control && key_pressed == 0 && !ev_video
#ifndef CAM_HAS_VIDEO_BUTTON 
        && (camera_info.state.mode_video || is_video_recording())
#endif
        )
    {
        if (kbd_is_key_pressed(KEY_LEFT) && is_video_recording())
        {
            movie_status = VIDEO_RECORD_STOPPED;
            key_pressed = KEY_LEFT;
            return 1;
        }

    	// reyalp - HACK for cams that can do video in any mode
	    // note that this means this will probably run whenever you press right
        // BUG this doesn't know whether recording was stopped or paused.
        if (kbd_is_key_pressed(KEY_RIGHT) && (movie_status == VIDEO_RECORD_STOPPED))
        {
            movie_status = VIDEO_RECORD_IN_PROGRESS;
            movie_reset = 1;
            key_pressed = KEY_RIGHT;
            return 1;
        }
    } 
#endif

    return key_pressed;
}
コード例 #17
0
ファイル: kbd.c プロジェクト: shentok/chdk-a430
long kbd_process()
{
/* Alternative keyboard mode stated/exited by pressing print key.
 * While running Alt. mode shoot key will start a script execution.
 */
static int nCER=0;
// ------ modif by Masuji SUTO (start) --------------

unsigned int mmode;
unsigned int nCrzpos,i;
unsigned int drmode = 0;

   if(conf.ricoh_ca1_mode && conf.remote_enable)
  {
	drmode = shooting_get_drive_mode();
	mmode = mode_get();
	mplay = (mmode&MODE_MASK)==MODE_PLAY;
//	mvideo= ((mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_STD || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_SPEED || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_COMPACT ||(mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_MY_COLORS || (mmode&MODE_SHOOTING_MASK)==MODE_VIDEO_COLOR_ACCENT);
	mvideo=MODE_IS_VIDEO(mmode);
  }
       // deals with alt-mode switch and delay emulation
        if (key_pressed)
        {
                if (kbd_is_key_pressed(conf.alt_mode_button) ||
                        ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY) && 
                         (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
                {
                        if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                                key_pressed++;
                        if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) 
                                kbd_key_press(conf.alt_mode_button);
                        else if (key_pressed == +CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                                kbd_key_release(conf.alt_mode_button);
                        return 1;
                } else 
                if (kbd_get_pressed_key() == 0)
                {
                        if (key_pressed != 100 && (key_pressed < CAM_EMUL_KEYPRESS_DELAY))
                        {
                                kbd_blocked = 1-kbd_blocked;
                                if (kbd_blocked) gui_kbd_enter(); else gui_kbd_leave();
                        }
                        key_pressed = 0;
                        return 1;
                }
                return 1;
        }
       
       // auto iso shift
        if (kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(conf.alt_mode_button)) return 0;
        
        if (kbd_is_key_pressed(conf.alt_mode_button))
        {
                if (conf.ricoh_ca1_mode && conf.remote_enable) conf.synch_enable=1;
                key_pressed = 1;
                kbd_key_release_all();          
                return 1;
        }

        // deals with the rest
        if (kbd_blocked && nRmt==0)
        {
/*------------------- Alex scriptless remote additions start --------------------*/
        if (remoteShooting) {

          if (remoteHalfShutter) {
            if (get_usb_power(1)) {
              if (remoteClickTimer < REMOTE_MAX_CLICK_LENGTH) {
                remoteHalfShutter=0;
                remoteFullShutter=1;
                kbd_key_press(KEY_SHOOT_FULL);
              }
              return 1;
            } else {
              --remoteClickTimer;
              if ( remoteClickTimer == 0 ) {
                kbd_key_release_all();
                remoteHalfShutter=0;
                remoteShooting=0;
                kbd_blocked=0;
                return 0;
              }
            }
          }

          if (remoteFullShutter) {
            if (get_usb_power(1)) {
              return 1;
            } else {
              kbd_key_release_all();
              remoteFullShutter=0;
              remoteShooting=0;
              kbd_blocked=0;
              return 0;
            }
          }

        }
/*-------------------- Alex scriptless remote additions end ---------------------*/
                if (kbd_is_key_pressed(KEY_SHOOT_FULL))
                {
                        key_pressed = 100;
                        if (!state_kbd_script_run)
                        {
                                script_start(0);
                        } else if (state_kbd_script_run == 2 || state_kbd_script_run == 3)
                        {
                                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                                script_end();
                        } else if (L)
                        {
                            state_kbd_script_run = 2;
                            lua_getglobal(Lt, "restore");
                            if (lua_isfunction(Lt, -1))
                                {
                                if (lua_pcall( Lt, 0, 0, 0 ))
                                {
                                    script_console_add_line( lua_tostring( Lt, -1 ) );
                                }
                            }
                            script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                            script_end();
                        }
                        else
                        {
                            state_kbd_script_run = 2;
                            if (jump_label("restore") == 0)
                            {
                                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
                                script_end();
                            }
                        }
                }

                if (state_kbd_script_run) 
                        process_script(); else
                        gui_kbd_process();
        } else
        {

#ifndef SYNCHABLE_REMOTE_NOT_ENABLED
if(conf.ricoh_ca1_mode && conf.remote_enable)
{

// ------ add by Masuji SUTO (start) --------------
if(nWt>0) {nWt--;return 1;}
#if defined(CAMERA_ixus960)
if(nFirst==1){
    if(nSW==0){
        nSW=1;
        nWt=10;
        kbd_key_release_all();
        kbd_key_press(KEY_SHOOT_HALF); 
        soft_half_press = 1;
        set_key_press(1);
        return 1;
    }
    else if(nSW==1){
        nSW=2;
        nWt=10;
        kbd_key_release(KEY_SHOOT_HALF); 
        soft_half_press = 0;
        set_key_press(1);
        return 1;
    }
    else if(nSW==2){
        set_key_press(0);
        nWt=10;
        nSW=0;
        nFirst=0;
        return 1;
    }
}
#endif
if (kbd_is_key_pressed(KEY_SHOOT_FULL)) conf.synch_enable=0;
	if (kbd_is_key_pressed(KEY_SHOOT_HALF) && nTxzoom>0) {
		nCount2=0;
		nTxzoom=0;
		nReczoom=0;
		nTxvideo=0;
		debug_led(0);
		}
	if (mplay && (kbd_is_key_pressed(KEY_LEFT) || kbd_is_key_pressed(KEY_RIGHT))){
		nPlyname=KEY_LEFT;
		if(kbd_is_key_pressed(KEY_RIGHT)) nPlyname=KEY_RIGHT;
		}
	if (kbd_is_key_pressed(KEY_VIDEO)){
		nCount2=0;
		nTxzoom=0;
		nReczoom=0;
		nTxvideo++;
		if(nTxvideo<50){
			kbd_key_release_all();
			debug_led(1);
			}
		else {
			debug_led(0);
			return 0;
			}
		return 1;
		}
	else if(nTxvideo>49) nTxvideo=0;
	if (kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)){
		nCount2=0;
		nTxvideo=0;
		if(kbd_is_key_pressed(KEY_ZOOM_IN)) {
			if(nTxzname==KEY_ZOOM_IN) nTxzoom++;
			else nTxzoom=1;
			nTxzname=KEY_ZOOM_IN;
			}
		else {
			if(nTxzname==KEY_ZOOM_OUT) nTxzoom++;
			else nTxzoom=1;
			nTxzname=KEY_ZOOM_OUT;
			}
		if(nTxzoom<50){
			kbd_key_release_all();
			debug_led(1);
			}
		else {
			debug_led(0);
			return 0;
			}
		return 1;
		}
	if(!get_usb_power(1) && nSW<100 && nCount==0 && nTxzoom>0) {
		nCount2++;
		if(nCount2>conf.zoom_timeout*100){
			if(nTxzoom>0){
				nTxzoom=0;
				nReczoom=0;
				debug_led(0);
				}
			nCount2=0;
			}
		return 1;
		}
	if(get_usb_power(1) && nSW<100 && nCount==0) {nCount2=0;kbd_key_release_all();conf.synch_enable=1;}

	
	if(get_usb_power(1) && nSW<100 && nCount==0) {kbd_key_release_all();conf.synch_enable=1;}
	if(get_usb_power(1) && nSW<100 && nCount<6){
		nCount++;
		return 1;
		}
	if(nCount>0 && nSW<100){
		if(mplay) {
			if(get_usb_power(1)) return 1;
			kbd_key_release_all();
			kbd_key_press(nPlyname);
			set_key_press(1);
			nCount=0;
			nCa=2;
			nSW=101;
			nWt=5;
			return 1;
			}
		if(nTxvideo>49) nTxvideo=0;
		if(nCount<5) nCa=1;		//for Richo remote switch CA-1
		else nCa=2;				//for hand made remote switch
		nCount=0;
//		debug_led(1);
		nSW=109;
		}

// -------------------------------------------------------------  hand made switch  --------------

	if(nCa==2){
     		if(nSW==101){
			kbd_key_release_all();
			set_key_press(0);
			nWt=50;
			nSW=0;
			nCa=0;
			return 1;
			}                                       
		if(nSW==109){
		//	nSW=110;
			nCER=0;
			if(nTxzoom>0 && conf.remote_zoom_enable){
				if(nTxzoom<100){
					nIntzpos=lens_get_zoom_point();
					for(i=0;i<ZSTEP_TABLE_SIZE;i++){
						if(nIntzpos<=nTxtbl[i]){
							if(i>0){
								if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) nTxtblcr=i;
								else nTxtblcr=i-1;
								}
							else nTxtblcr=i;
							i=ZSTEP_TABLE_SIZE;
							}
						}
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) nTxtblcr=(ZSTEP_TABLE_SIZE-1);
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0) nTxtblcr=0;
						}
					nSW=108;
					return 1;
					}
				nTxzoom=0;
				nReczoom=0;
				}
			if(nTxvideo>0 && conf.remote_zoom_enable) {nSW=121;return 1;}
                                    nSW=110;
			nWt=2;
			kbd_key_release_all();
			kbd_key_press(KEY_SHOOT_HALF); 
		//	key_pressed = 1;
		//	kbd_blocked = 1;
		//	nRmt=1;
                  soft_half_press = 1;
                  set_key_press(1);
			return 1;
			}
			if(nTxzoom>0 && nSW==108 && conf.remote_zoom_enable){
				nCrzpos=lens_get_zoom_point();
				if(nIntzpos!=nCrzpos) {nReczoom=0;}
				if(nIntzpos==nCrzpos && nCER>50){
					if(!get_usb_power(1)){
						kbd_key_release_all();
						set_key_press(0);
						nTxzoom=1;
						nSW=0;
						nCount=0;
						nWt=10;
						nReczoom=1;
						return 1;
						}
					}
				if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))){
					if(get_usb_power(1)){
						i=1;
						if(nTxzname==KEY_ZOOM_IN){
							nTxtblcr++;
							if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){
                            nTxtblcr=(ZSTEP_TABLE_SIZE-1);
                            nTxzname=KEY_ZOOM_OUT;
                            }
							}
						else{
							nTxtblcr--;
							if(nTxtblcr<0){
                            nTxtblcr=0;
                            nTxzname=KEY_ZOOM_IN;
                            }
							}
						if(i==1) return 1;
						}
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=1;
	//				lens_set_zoom_speed(25);
					nSW=120;
					nWt=5;
					return 1;
					}
				kbd_key_release_all();
				kbd_key_press(nTxzname); 
				set_key_press(1);
				nCER++;
				return 1;
				}
				
		if(nTxvideo>0 && nSW==121){
			if(!get_usb_power(1)) {
				nWt=10;
				kbd_key_press(KEY_VIDEO);
				set_key_press(1);
				nSW=122;
				}
			return 1;
			}
		if(nTxvideo>0 && nSW==122){
			nWt=10;
			kbd_key_release(KEY_VIDEO);
			set_key_press(1);
			nSW=123;
			return 1;
			}
		if(nTxvideo>0 && nSW==123){
			set_key_press(0);
			nWt=50;
			nSW=0;
			nCa=0;
			nTxvideo=0;
			debug_led(0);
			return 1;
			}

		if(nSW==110){
			if (shooting_in_progress() || mvideo || nCER>100) {
				state_expos_recalculated = 0;
				histogram_restart();
				nCER=0;
				nSW=111;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==111){
			if (state_expos_recalculated || nCER>100) {
				state_expos_under = under_exposed;
				state_expos_over = over_exposed;
				nCER=0;
				nSW=112;
                        //presynch();
			    }
			else {nCER++;return 1;}
			}
		if(nSW==112){
		    if (shooting_is_flash_ready() || nCER>10){
				nCER=0;
				nSW=113;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==113){
			if(get_usb_power(1) && !mvideo) nSW=114;
			else if(!get_usb_power(1) && mvideo) nSW=114;
			else return 1;
			}
		if(nTxzoom>0 && nSW==120 && conf.remote_zoom_enable){
			nCrzpos=lens_get_zoom_point();
			if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])){
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
				lens_set_zoom_speed(100);
				nSW=0;
				nCount=0;
				nWt=10;
				return 1;
				}
			lens_set_zoom_speed(5);
			kbd_key_release_all();
			if(nTxzname==KEY_ZOOM_IN) kbd_key_press(KEY_ZOOM_OUT); 
			else kbd_key_press(KEY_ZOOM_IN); 
			set_key_press(1);
			return 1;
			}

		if(nSW==114){
			nSW=115;
			nWt=2;
                  shutter_int=0;
			kbd_key_press(KEY_SHOOT_FULL); 
                                    set_key_press(1);
		//	kbd_blocked = 1;
		//	nRmt=1;
			nCount=0;
			return 1;
			}
		if(nSW==115){
	//		debug_led(0);
			if(drmode==1 && shutter_int==0){
				return 1;
				}
			nSW=116;
			nWt=2;
			kbd_key_release(KEY_SHOOT_FULL); 
                                    set_key_press(1);
                                    soft_half_press = 0;
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(!get_usb_power(1) && nSW==116) {
                                    set_key_press(0);
		//	kbd_blocked = 0;
		//	key_pressed = 0;
			nWt=50;
			nSW=0;
		//	nRmt=0;
			nCa=0;
                  //postsynch();
			return 1;
			}
		}

// -------------------------------------------------------------  Ricoh remote switch CA-1 --------------
	if(nCa==1){
		if(get_usb_power(1) && nSW>108 && nSW<120){
			nCount++;
			}
		if(nSW==109){
		//	nSW=110;
			nCER=0;
			if(nTxzoom>0 && conf.remote_zoom_enable){
				if(nTxzoom<100){
					nIntzpos=lens_get_zoom_point();
					for(i=0;i<ZSTEP_TABLE_SIZE;i++){
						if(nIntzpos<=nTxtbl[i]){
							if(i>0){
								if(abs(nTxtbl[i]-nIntzpos)<=abs(nTxtbl[i-1]-nIntzpos)) nTxtblcr=i;
								else nTxtblcr=i-1;
								}
							else nTxtblcr=i;
							i=ZSTEP_TABLE_SIZE;
							}
						}
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)) nTxtblcr=(ZSTEP_TABLE_SIZE-1);
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0) nTxtblcr=0;
						}
					nSW=113;
					return 1;
					}
				nTxzoom=0;
				nReczoom=0;
				}
			if(nTxvideo>0 && conf.remote_zoom_enable) {nSW=121;return 1;}
                  nSW=110;
			nWt=2;
			kbd_key_release_all();
			kbd_key_press(KEY_SHOOT_HALF); 
//			debug_led(1);
                                    soft_half_press = 1;
                                    set_key_press(1);
		//	key_pressed = 1;
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(nTxvideo>0 && nSW==121){
			if(get_usb_power(1)) {
				nWt=10;
				kbd_key_press(KEY_VIDEO);
				set_key_press(1);
				nSW=122;
				}
			return 1;
			}
		if(nTxvideo>0 && nSW==122){
			nWt=10;
			kbd_key_release(KEY_VIDEO);
			set_key_press(1);
			nSW=123;
			return 1;
			}
		if(nTxvideo>0 && nSW==123){
			set_key_press(0);
			nWt=100;
			nCount=0;
			nSW=0;
			nCa=0;
			nTxvideo=0;
			debug_led(0);
			return 1;
			}

		if(nSW==110){
			if (shooting_in_progress() || mvideo || nCER>100) {
//				debug_led(0);
				state_expos_recalculated = 0;
				histogram_restart();
				nCER=0;
				nSW=111;
			    }
			else {nCER++;return 1;}
			}
		if(nSW==111){
			if (state_expos_recalculated || nCER>100) {
				state_expos_under = under_exposed;
				state_expos_over = over_exposed;
				nCER=0;
				nSW=112;
                        //presynch();
			    }
			else {nCER++;return 1;}
			}
		if(nSW==112){
		    if (shooting_is_flash_ready() || nCER>10){
				nCER=0;
				nSW=113;
			    }
			else {nCER++;return 1;}
			}
		if(nTxzoom>0 && nSW==114 && conf.remote_zoom_enable){
			nCrzpos=lens_get_zoom_point();
			if(nIntzpos!=nCrzpos) {nReczoom=0;}
			if(nIntzpos==nCrzpos && nCER>50){
				if(nCount>0){
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=1;
					nSW=0;
					nCount=0;
					nWt=10;
					nReczoom=1;
					return 1;
					}
				}
			if(nReczoom==0 && ((nTxzname==KEY_ZOOM_IN && nCrzpos>=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos<=nTxtbl[nTxtblcr]))){
				if(nCount==0){
					i=1;
					if(nTxzname==KEY_ZOOM_IN){
						nTxtblcr++;
						if(nTxtblcr>(ZSTEP_TABLE_SIZE-1)){
                        nTxtblcr=(ZSTEP_TABLE_SIZE-1);
                        nTxzname=KEY_ZOOM_OUT;
                        }
						}
					else{
						nTxtblcr--;
						if(nTxtblcr<0){
                        nTxtblcr=0;
                        nTxzname=KEY_ZOOM_IN;
                        }
						}
					if(i==1) return 1;
					}
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
//				lens_set_zoom_speed(25);
				nSW=115;
				nWt=5;
				return 1;
				}
			kbd_key_release_all();
			kbd_key_press(nTxzname); 
			set_key_press(1);
			nCER++;
			return 1;
			}
		if(nTxzoom>0 && nSW==115 && conf.remote_zoom_enable){
			if(nCount==0) return 1;
			nCrzpos=lens_get_zoom_point();
			if((nTxzname==KEY_ZOOM_IN && nCrzpos<=nTxtbl[nTxtblcr]) || (nTxzname==KEY_ZOOM_OUT && nCrzpos>=nTxtbl[nTxtblcr])){
				kbd_key_release_all();
				set_key_press(0);
				nTxzoom=1;
				lens_set_zoom_speed(100);
				nSW=0;
				nCount=0;
				nWt=10;
				return 1;
				}
			lens_set_zoom_speed(5);
			kbd_key_release_all();
			if(nTxzname==KEY_ZOOM_IN) kbd_key_press(KEY_ZOOM_OUT); 
			else kbd_key_press(KEY_ZOOM_IN); 
			set_key_press(1);
			return 1;
			}


		if(get_usb_power(1)){
			return 1;
			}
		if(nCount>0 && nSW==113){
			if(nCount<9){
				if(nTxzoom>0 && conf.remote_zoom_enable){
					kbd_key_release_all();
					set_key_press(0);
					nTxzoom=0;
					nReczoom=0;
					nSW=0;
					nCa=0;
					nCount=0;
					nWt=10;
//					lens_set_zoom_speed(100);
					debug_led(0);
					return 1;
					}
				nSW=125;
				nWt=10;
				kbd_key_release(KEY_SHOOT_HALF); 
	                                    soft_half_press = 0;
                                        set_key_press(1);
			//	kbd_blocked = 1;
			//	nRmt=1;
				nCount=0;
				return 1;
				}
			else{
				if(nTxzoom>0 && conf.remote_zoom_enable){
					nCount=0;
					nSW=114;
					return 1;
					}
				nSW=124;
				nWt=2;
                        shutter_int=0;
//				debug_led(0);
				kbd_key_press(KEY_SHOOT_FULL); 
                                                set_key_press(1);
			//	kbd_blocked = 1;
			//	nRmt=1;
				nCount=0;
				return 1;
				}
			}
		if(nSW==124){
	//		debug_led(0);
			if(drmode==1 && shutter_int==0){
				return 1;
				}
			nSW=125;
			nWt=2;
			kbd_key_release(KEY_SHOOT_FULL);
                  soft_half_press = 0;
                  set_key_press(1);
		//	kbd_blocked = 1;
		//	nRmt=1;
			return 1;
			}
		if(!get_usb_power(1) && nSW==125) {
                                    set_key_press(0);
		//	kbd_blocked = 0;
		//	key_pressed = 0;
			nWt=50;
			nSW=0;
		//	nRmt=0;
			nCa=0;
                  //postsynch();
			return 1;
			}
		}

// ------ add by Masuji SUTO (end)   --------------

} // ricoh_ca1_mode
#endif
/*------------------- Alex scriptless remote additions start --------------------*/
        if (conf.remote_enable && !conf.ricoh_ca1_mode && key_pressed != 2 && get_usb_power(1)) {
          remoteShooting = 1;
          kbd_blocked = 1;
          kbd_key_release_all();
          remoteClickTimer = REMOTE_MAX_CLICK_LENGTH;
          if (shooting_get_focus_mode()) {
            remoteFullShutter = 1;
            kbd_key_press(KEY_SHOOT_FULL);
          } else {
            remoteHalfShutter = 1;
            kbd_key_press(KEY_SHOOT_HALF);
          }
          return 1;
        }
/*-------------------- Alex scriptless remote additions end ---------------------*/
#ifdef CAM_USE_ZOOM_FOR_MF
                if (conf.use_zoom_mf && kbd_use_zoom_as_mf()) {
                    return 1;
                }
#endif
                if ((conf.fast_ev || conf.fast_movie_control || conf.fast_movie_quality_control) && kbd_use_up_down_left_right_as_fast_switch()) {
                    return 1;
                }
                other_kbd_process(); // processed other keys in not <alt> mode 
        }

        return kbd_blocked;
}
コード例 #18
0
ファイル: wrappers.c プロジェクト: barryk/CHDK-SD1200
long lens_get_target_distance()
{
    static long v=MAX_DIST;
    return (kbd_is_key_pressed(KEY_SHOOT_HALF) || state_kbd_script_run  || shooting_get_focus_mode())?v=_GetCurrentTargetDistance():v;
}
コード例 #19
0
ファイル: histogram.c プロジェクト: arne182/chdk-eyefi
void histogram_process()
{
    static unsigned char *img;
    int i, hi, c;
    int y, v, u;
	static int x;
    static int viewport_size;
    unsigned int histo_fill[5];

	    switch (histogram_stage) {
        case 0:
            img=((mode_get()&MODE_MASK) == MODE_PLAY)?vid_get_viewport_fb_d():((kbd_is_key_pressed(KEY_SHOOT_HALF))?vid_get_viewport_fb():vid_get_viewport_live_fb());
      	
        	if (img==NULL){
	    	  img = vid_get_viewport_fb();
		    }
			img += vid_get_viewport_image_offset();		// offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD)
            viewport_size = vid_get_viewport_height() * vid_get_viewport_buffer_width();
            for (c=0; c<5; ++c) {
                for (i=0; i<HISTO_WIDTH; ++i) {
                    histogram_proc[c][i]=0;
                }
                histo_max[c] = histo_max_center[c] = 0;
            }

            histogram_stage=1;
            break;
        
        case 1:
        case 2:
        case 3:
			x = 0;	// count how many blocks we have done on the current row (to skip unused buffer space at end of each row)
            for (i=(histogram_stage-1)*6; i<viewport_size*3; i+=HISTO_STEP_SIZE*6) {
                y = img[i+1];
                u = *(signed char*)(&img[i]);
                if (u&0x00000080) u|=0xFFFFFF00;
                v = *(signed char*)(&img[i+2]);
                if (v&0x00000080) v|=0xFFFFFF00;

                hi = y*HISTO_WIDTH/256; // Y
                ++histogram_proc[HISTO_Y][hi];
                hi = clip(((y<<12)          + v*5743 + 2048)/4096)*HISTO_WIDTH/256; // R
                ++histogram_proc[HISTO_R][hi];
                hi = clip(((y<<12) - u*1411 - v*2925 + 2048)/4096)*HISTO_WIDTH/256; // G
                ++histogram_proc[HISTO_G][hi];
                hi = clip(((y<<12) + u*7258          + 2048)/4096)*HISTO_WIDTH/256; // B
                ++histogram_proc[HISTO_B][hi];

				// Handle case where viewport memory buffer is wider than the actual buffer.
				x += HISTO_STEP_SIZE * 2;	// viewport width is measured in blocks of three bytes each even though the data is stored in six byte chunks !
				if (x == vid_get_viewport_width())
				{
					i += vid_get_viewport_row_offset();
					x = 0;
				}
			}

            ++histogram_stage;
            break;

        case 4:
            for (i=0; i<HISTO_WIDTH; ++i) { // G
                histogram_proc[HISTO_RGB][i]=histogram_proc[HISTO_R][i]+histogram_proc[HISTO_G][i]+histogram_proc[HISTO_B][i];
            }
            for (c=0; c<5; ++c) { // calculate maximums
                for (i=0; i<HISTO_WIDTH; ++i) {
                    if (histo_max[c]<histogram_proc[c][i])
                        histo_max[c]=histogram_proc[c][i];
                    if (histo_max_center[c]<histogram_proc[c][i] && i>=conf.histo_ignore_boundary && i<HISTO_WIDTH-conf.histo_ignore_boundary)
                        histo_max_center[c]=histogram_proc[c][i];
                }
                
                if (histo_max[c] > 0) {
                    histo_max_invw[c] = ((float)HISTO_HEIGHT)/histogram_transform((float)histo_max[c]);
                } else {
                    histo_max_invw[c] = 0.0f;
                }

                if (histo_max_center[c] > 0) {
                    histo_max_center_invw[c] = ((float)HISTO_HEIGHT)/histogram_transform((float)histo_max_center[c]);
                } else {
                    histo_max_center_invw[c] = 0.0f;
                }
            }

            if (histo_max[HISTO_RGB] > 0) { // over- / under- expos
                under_exposed = (histogram_proc[HISTO_RGB][0]*8
                                +histogram_proc[HISTO_RGB][1]*4
                                +histogram_proc[HISTO_RGB][2]) > exposition_thresh;

                over_exposed = (histogram_proc[HISTO_RGB][HISTO_WIDTH-3]
                               +histogram_proc[HISTO_RGB][HISTO_WIDTH-2]*4
                               +histogram_proc[HISTO_RGB][HISTO_WIDTH-1]*8) > exposition_thresh;
            } else {
                over_exposed = 0;
                under_exposed = 1;
            }

            histogram_stage=5;
            state_expos_recalculated = 1;
            break;

        case 5:
            for (c=0; c<5; ++c) {
                histo_fill[c]=0;
                for (i=0; i<HISTO_WIDTH; ++i) {
                    histogram[c][i] = (histogram_transform((float)histogram_proc[c][i]))*histo_max_center_invw[c];
                    if (histogram[c][i] > HISTO_HEIGHT)
                        histogram[c][i] = HISTO_HEIGHT;
                    histo_fill[c]+=histogram[c][i];
                }
            }

            if (conf.histo_auto_ajust) {
                histo_magnification = histo_fill[histo_main]*1000/(HISTO_HEIGHT*HISTO_WIDTH);
                if (histo_magnification<200) { // try to ajust if average level is less than 20%
                    histo_magnification=200*1000/histo_magnification;
                    for (c=0; c<5; ++c) {
                        for (i=0;i<HISTO_WIDTH;i++) {
                            histogram[c][i] = (histogram_transform((float)histogram_proc[c][i]))*histo_max_center_invw[c]*histo_magnification/1000;
                            if (histogram[c][i] > HISTO_HEIGHT)
                                histogram[c][i] = HISTO_HEIGHT;
                        }
                    }
                } else 
                    histo_magnification=0;
            } else {
                histo_magnification=0;
            }

            histogram_stage=0;
            break;

        case HISTOGRAM_IDLE_STAGE:
            break;
    }

}