CHDK Forum

CHDK Development => General Discussion and Assistance => Topic started by: whoever on 28 / July / 2008, 06:44:00

Title: IXUS950/SD850 1.00C fixed touchwheel overwriting OSD
Post by: whoever on 28 / July / 2008, 06:44:00
I sort of grew used to unsteady OSD menus, taking their flickering as natural. But is it natural? Of course not, as mil22 reminded (http://chdk.setepontos.com/index.php/topic,1966.0.html) us recently. Inspired by mil22 and cail, here's a quick fix to tame the touchwheel task TouchW and get perfectly steady menus and smooth navigation. The necessary tools, taskNameToId(), taskSuspend(), and taskResume(), are provided by VxWorks. The last two have been known since long; the first has to be identified by hand in stubs_entry_2.S:
Code: [Select]
NHSTUB(taskNameToId, 0xFF935A64)

Then, in platform\ixus950_sd850\kbd.c:
Code: [Select]
void my_kbd_read_keys()
{
    kbd_prev_state[0] = kbd_new_state[0];
    kbd_prev_state[1] = kbd_new_state[1];
    kbd_prev_state[2] = kbd_new_state[2];
    _kbd_pwr_on();
    kbd_fetch_data(kbd_new_state);

///////////// ADD THIS: /////////////
    static int handle_taskTouchW = 0, isRunning_taskTouchW = 1;
    extern int _taskNameToId(void*);
    extern void _taskSuspend(int), _taskResume(int);
    if (handle_taskTouchW == 0) { handle_taskTouchW = _taskNameToId("tTouchW"); }
////////////////////////////////////////

    if (kbd_process() == 0){
// leave it alone...
physw_status[0] = kbd_new_state[0];
physw_status[1] = kbd_new_state[1];
physw_status[2] = kbd_new_state[2];
//physw_status[1] |= alt_mode_key_mask;

///////////// ADD THIS: /////////////
if (!isRunning_taskTouchW) { _taskResume(handle_taskTouchW); isRunning_taskTouchW = 1; }
////////////////////////////////////////

    } else {
      // override keys
        physw_status[0] = (kbd_new_state[0] & (~KEYS_MASK0)) |
              (kbd_mod_state[0] & KEYS_MASK0);
        physw_status[1] = (kbd_new_state[1] & (~KEYS_MASK1)) |
              (kbd_mod_state[1] & KEYS_MASK1);
        physw_status[2] = (kbd_new_state[2] & (~KEYS_MASK2)) |
              (kbd_mod_state[2] & KEYS_MASK2);

///////////// ADD THIS: /////////////
if (isRunning_taskTouchW && !state_kbd_script_run)
{ _taskSuspend(handle_taskTouchW); isRunning_taskTouchW = 0; }
else if (!isRunning_taskTouchW && state_kbd_script_run)
{ _taskResume(handle_taskTouchW); isRunning_taskTouchW = 1; }
////////////////////////////////////////

    }

    _kbd_read_keys_r2(physw_status);

if (conf.remote_enable) {
remote_key = (physw_status[USB_REG] & USB_MASK)==USB_MASK;
if (remote_key)
remote_count += 1;
else if (remote_count) {
usb_power = remote_count;
remote_count = 0;
}
physw_status[USB_REG] = physw_status[USB_REG] & ~USB_MASK;
}

    physw_status[2] = physw_status[2] & ~SD_READONLY_FLAG;

    _kbd_pwr_off();
}

This suspends the wheel task in ALT-mode unless a script is running that might need to emulate navigation keys.

Attached are precompiled binaries, should anybody wish to try it out.
Title: Re: IXUS950/SD850 1.00C fixed touchwheel overwriting OSD
Post by: PhyrePhoX on 01 / August / 2008, 17:13:38
added into beta branch "collaborative chdk" as of now. Changeset 461 - chdk - Trac (http://tools.assembla.com/chdk/changeset/461)
can and probably will be added to trunk if no reports of crashes, bugs & the likes occur ;)
Title: Re: IXUS950/SD850 1.00C fixed touchwheel overwriting OSD
Post by: ewavr on 01 / August / 2008, 18:31:08
I believe that it works  :)
Changeset 462 - chdk - Trac (http://tools.assembla.com/chdk/changeset/462)

BTW, similar code for IXUS65 don't contain code for resuming touchwheel task while script is running. Maybe this is bug?