supplierdeeply

Key exchange

  • 11 Replies
  • 1627 Views
Key exchange
« on: 14 / April / 2016, 04:29:07 »
Advertisements

Hi,

I have just repaired a Canon G12 (lens) but the func/set key do not work anymore.
I can still take pictures but I sometimes need to use the func/set key to make changes...

So, I wonder if I could modify the chdk source code to exchange my func/set key with another one that I use less often.
I manage to configure the autoboot of chdk (mendatory to use chdk that could not be manually load without the func/set key...)

After some try to modify some kbd files and compilling the modified sources I did not manage to exchange the keys as expected.

But considering the various kbd files I found in the sources, I certainly did not modified the right one.

Could someone give me a hint of the file (files?) I have to modify ?

Thank you in advance,

AA

Re: Key exchange
« Reply #1 on: 14 / April / 2016, 08:16:56 »
So, I wonder if I could modify the chdk source code to exchange my func/set key with another one that I use less often. I manage to configure the autoboot of chdk (mendatory to use chdk that could not be manually load without the func/set key...)  After some try to modify some kbd files and compilling the modified sources I did not manage to exchange the keys as expected.
The file you want is kbd.c in your G12's chdk/platform/g12 folder.   Modify the function kbd_fetch_data() so that it checks for the bit associated with the key you want to remap in the key array pointed to by *dst,  masks that bit if  its found,  and then set the bit for the FUNC/SET button instead.    The keymap[] structure in kdb.c will tell you the necessary bits and offsets.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Key exchange
« Reply #2 on: 14 / April / 2016, 10:13:04 »

Thank you for your answer.

In fact, I did try to modify the kbd.c file.
But (certainly because of my misknowledge) it did not worked.

I was thinking of replace the KEY_SET by the KEY_METERING.
So I exchange the 0x00002000 values.

Is it the move that had to be done ?

Could you give me an example, if not ?

Thank you aggain,

AA

Re: Key exchange
« Reply #3 on: 14 / April / 2016, 10:36:43 »
Unless someone jumps in here today pointing out a mistake, I'll code this and test tonight.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Key exchange
« Reply #4 on: 14 / April / 2016, 12:35:50 »

It is very kind of you.

Thank you.

AA

Re: Key exchange
« Reply #5 on: 14 / April / 2016, 20:22:24 »
It is very kind of you. Thank you. AA
Tested this on my G10 (with suitable mods for the different keymap).  This version should work for your G12.

Code: [Select]
#define KMETER 0x00040000
#define KSET   0x00002000

void kbd_fetch_data(long *dst)
{
    _GetKbdState(dst);
    _kbd_read_keys_r2(dst);
    if ((*dst & KMETER)==0) *dst = (*dst|KMETER) & ~KSET ;   
}


Works well.
« Last Edit: 14 / April / 2016, 20:26:34 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Key exchange
« Reply #6 on: 15 / April / 2016, 05:46:03 »
Well done !
It is working !
Thank you very much.

I could not have found the "void" part.

I have lost my metering key but it is a price to pay  :)

AA

Re: Key exchange
« Reply #7 on: 15 / April / 2016, 09:09:22 »
I have lost my metering key but it is a price to pay  :)
There is a way to fix that too.  Just change the code so that a short press of the metering button is treated as a metering button press,  and a long press (i.e. press & hold) of the metering button is treated as a Func/Set press.

Modify the patch you made to start a counter that increments while the metering key is pressed.  When the key is released, check the value of the counter.  If it's below a certain value then simulate a press of the metering key.   If it's above that value, simulate the press of the Func/Set key.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Key exchange
« Reply #8 on: 15 / April / 2016, 11:05:03 »

It is a very good idea.

I will check the doc to see if I can write that kind of code.

Thank you.

AA

*

Offline srsa_4c

  • ******
  • 3530
Re: Key exchange
« Reply #9 on: 15 / April / 2016, 17:57:13 »

It is a very good idea.

I will check the doc to see if I can write that kind of code.
A hint: kbd_fetch_data() is called once in every 10 milliseconds.

 

Related Topics