Mode dials and Playback pushbuttons - page 6 - General Discussion and Assistance - CHDK Forum  

Mode dials and Playback pushbuttons

  • 201 Replies
  • 88103 Views
*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Mode dials and Playback pushbuttons
« Reply #50 on: 24 / October / 2009, 20:02:34 »
Advertisements
Does this work for any dial mode position ? If so, this is much better than messing with events.
It seems yes, but I will make full test (for a710) later.
However, we need events for switching record/playback modes.

*

Offline reyalp

  • ******
  • 14114
Re: Mode dials and Playback pushbuttons
« Reply #51 on: 25 / October / 2009, 00:08:05 »
I think there's a lot we can do with events, even if there's a better way to do the dial mode. On my a540 PostLogicalEvent* by itself is works for quite a few things. I can switch between play and rec (using PressRecButton and PressPBButton, even though my cam has a switch), simulate any button press, power off nicely with a PressPowerButton etc.

Mode dail switching is more complicated, but appears to work.

I've made a lua script to interactively test this. Note that the functions I've added are quite low level. If this turns out to work on most cameras, we can add higher level functions for scripts.

The main things I'd like to know are
- does play/rec switching work
- do mode overrides work
There's a lot of events to play with, feel free to report any other results.

The zip includes 2 scripts:
dmplev.lua - this dumps a list of events to A/dmplev.csv I already have this for every camera, but you can get it for your own interest. It will verify that the table address is correct and exercise a couple of the functions.

testlev.lua - Interactive event tester

This script shows a simple menu in the console:
- Up and down scroll through items.
- func/set activates the current the item
- left returns to the main menu
- menu ends the script
- The current item is highlighted with a >

Main items
- Rec/play try to force record or play mode
- Mode... gives a sub menu of mode dial overrides (details below)
- Mode event mask... gives a sub menu controling how SetLogicalEventActive is used when forcing modes
- Script mode [] allows you to turn scriptmode on or off.
- Post func [] you to switch between PostLogicalEventToUI [2UI] and PostLogicalEventForNotPowerType [4NPT]
- Press/Unpress... gives you a menu of all the events whose names start with Press, Unpress or Hold. for many functions, an "unpress" doesn't appear to be required, although the zoom buttons will zoom to the limit unless you send an unpress.
- Misc... gives you a menu of events not in any of the above.
- Shutdown turns the camera off, as if the power button had been pressed.

Notes on mode overrides
The Mode and event mask menus are filled with all events that start with ModeDialTo.
Your camera probably has events that aren't valid for that model (e.g. sports on models without a sports dial setting). These are likely to crash.
Mode overrides work as follows
the event id for the desired mode is set active
the event ids for all other dial modes, except those that are masked, are set inactive
the event is posted

It appears that setting some modes inactive causes the camera to crash (sports mode on the a540)
If you get crashes forcing modes, I suggest adding ModeDialTo events that aren't valid for your camera to the mask list (it's near the top of the lua file, in an obvious format)

ScriptMode sets a boolean variable in the canon code that is somehow related to this.
In my testing, it needs to be set for mode overrides to work, if you entered record mode using the actual switch, not the override. Strangely, if you use the override to get to record mode, it does not appear to be needed.

Source patch below. Note that not all cameras will build, and not all addresses have been verified. I'll some binaries in the next post.
« Last Edit: 25 / October / 2009, 00:32:31 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14114
Re: Mode dials and Playback pushbuttons
« Reply #52 on: 25 / October / 2009, 00:24:47 »
builds: Note, these are just the diskboot/ps.fi2. If you need a full build, get the full zip from the autobuild server and then replace the bins.
a590 101b - verified http://www.zshare.net/download/67463689ecf6166d/
a620 100f -  verified http://www.zshare.net/download/674637212b95c6c2/
a630 100c - not verified http://www.zshare.net/download/674637415856b2e0/
a710 100a - verified http://www.zshare.net/download/674637676b516f4c/
ixus50_sd400 - not verified http://www.zshare.net/download/67463784f3de3fb5/
ixus70_sd1000 - not verified, SetLogicalEventActive poor match http://www.zshare.net/download/67463825bafb6125/
ixus860_sd870 - verified http://www.zshare.net/download/674638678f212620/
ixus870_sd880 -verified http://www.zshare.net/download/674639104d2410b5/
sx10 101a - verified http://www.zshare.net/download/67463937a6ec43d7/
edit to add
a540 100b - verified http://www.zshare.net/download/674642356c6b4ab5/

verified above means I've manually verified the addresses. The others should be ok, but if they crash or malfunction, that's the first place to look.

documentation of the new lua functions
get_levent_def(event)
takes an event id or name, returns "name", id, param or nil

get_levent_index(event)
takes an event id or name, index into levent table, or nil

get_levent_def_by_index(index)
takes an index into the event table
returns "name", id, param if index is valid, otherwise nil
useful for iterating over event table

post_levent_to_ui(event,[unk])
post_levent_for_npt(event,[unk])
calls PostLogicalEventToUI or PostLogicaEventForNotPowerType respectively
This triggers the event, the difference between functions isn't clear
event is an event id or name (NOT index)
unk is an optional number whose meaning is unknown, defaults to zero. Based on code, other values would probably be a pointer. This is NOT the 3rd item in the event table

set_levent_active(event,state)
event is an event id or name (NOT index)
state is a numeric or boolean state. true or non zero numbers turn on zero, false or nil turn off
calls SetLogicalEventActive(id,state)

set_levent_script_mode(state)
state is numeric or boolean state. true or non zero numbers turn on zero, false or nil turn off
calls SetScriptMode(state)

edit:
Added a simple lua script example. This works perfectly on my camera.
« Last Edit: 25 / October / 2009, 01:15:17 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14114
Re: Mode dials and Playback pushbuttons
« Reply #53 on: 25 / October / 2009, 04:29:27 »
It seems yes, but I will make full test (for a710) later.
However, we need events for switching record/playback modes.
This works great on a540, much simpler than doing it with events. Attached is a small patch + lua script. Address is only there for a540, but it's easy to find.

We can use the existing modemap to get available values.

One thing I realized for play/rec overrides: On cameras that have a physical switch for play/rec, CHDK will be confused about what mode it is in, because many of those ports check physw_status to get the mode. We'll have to find a canon variable for these cams.
Don't forget what the H stands for.


*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Mode dials and Playback pushbuttons
« Reply #54 on: 25 / October / 2009, 10:01:01 »
Thx reyalP for this great work !
Started with the tests, but sometimes it's NOT good to own 3 different, CHDK-supported cameras  :haha

Instead of posting dozens of results, hints & comments for all my cameras, i'll post some general things here - if you need some more detailed results, pls. ask...

Tests with testlev.lua on the SD400 1.01b, SD870 1.00C & the SX10 101a:

1) switching between play/rec mode and shutdown works fine on all my cameras, with [4NPT] and the same way in [2UI].
2) MODE menu: most things are working; after setting a mode by script you can't select another mode with the Canon UI...
3) PRESS/UNPRESS: most things are working; on the Ixus cams some events must be used twice, e.g. PressFlashButton on the SD870...
4) MISC menu: some nice things there... e.g. ConnectVideoCable, disables the display (SD870)

Quote
The main things I'd like to know are
- does play/rec switching work  YES
- do mode overrides work  YES

*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: Mode dials and Playback pushbuttons
« Reply #55 on: 25 / October / 2009, 11:05:49 »
considering
Quote
ixus70_sd1000 - not verified, SetLogicalEventActive poor match
i decided to attack this one first

what i did:
- loaded a freshly formatted card with trunk 821
- replaced bootfiles
[oops! forgot to say: left all scripts @default settings]
- ran 'dumplev.lua' -> successfully created A/dmplev.csv
- ran 'testlev2.lua' -> shot 1 pic + 1 movie and switched to play (did not replay the movie though)
- ran 'testlev.lua'   -> - switched from rec to play (both ways)  OK
                              - engaged 'mode...' submenu and tested all entries -> results mostly OK, see attach
                              - 'mode event mask ...' crashed after toggling a couple of entries - quite likely because
                                 it's unclear to me what Y and N stand for here ...
                              - haven't checked the others, except
                              - shutdown: works as advertised
                          
great work, this is definitively going to give scripts wings !

wim
« Last Edit: 25 / October / 2009, 11:10:05 by whim »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Mode dials and Playback pushbuttons
« Reply #56 on: 25 / October / 2009, 14:23:24 »
Awesome stuff... even that lua menu system is highly useful for other uses, especially with resized console. :)

I played around with this on my a570 100e. It has a physical rec/play switch.

Sig finder found PostLogicalEvent* stubs fine. On top of them I used this one from the ida lists, it's ok too:
NHSTUB(SetCurrentCaptureModeType,0xffc17d10)

dmplev.lua works.
testlev2.lua works.
testlev.lua works.

Shutdown works.

Seems both 2UI and 2NPT work for rec/play and mode switching. I wasn't systematic, I haven't tried all possible combinations for power on/2UI/2NPT/REC/PLAY/MODE stuff, but it never failed except in the way you mentioned about the scriptmode boolean thing with mode switching -- appears it happens on a570 too (mode change is announced on screen but mode doesn't really change).

testcapm.lua works after changing modemap for a570. And btw. found a bug in platform/a570/main.c:
-{ MODE_KIDS_PETS,          32764 },   
+{ MODE_KIDS_PETS,          32784 },   

A note: using set_capture_mode_type the mode change popup message does not appear in the middle of the LCD. Because of this, mode appears to be faster than normally. Using either PostLogicalEvent* funcs that message appears as usual. In all three cases the top right corner mode OSD is updated.

SetModeDialToFunColor crashes (modes C, C1 and C2, Sport don't crash but they aren't really useful either since the camera doesn't really have these modes fully implemented... sport mode does appear to use high ISO, though, even when manual ISO is selected).

Didn't try most of the misc or press/unpress stuff, but in general it appears that things the camera doesn't physically have don't work even if it had that functionality from menus (like IsoDial or ISButton) and others do.

*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Mode dials and Playback pushbuttons
« Reply #57 on: 25 / October / 2009, 15:03:38 »
And btw. found a bug in platform/a570/main.c:
-{ MODE_KIDS_PETS,          32764 },   
+{ MODE_KIDS_PETS,          32784 },   
So i guess also some other values from the wikia list are wrong...


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Mode dials and Playback pushbuttons
« Reply #58 on: 25 / October / 2009, 16:36:40 »
So i guess also some other values from the wikia list are wrong...
Not really (well I didn't check today but I think I wrote that wikia table)...get_prop result in scripts doesn't equal to modemap[] or debug propcase viewer in CHDK C code due to different assumptions of datatypes and whatnot.

*

Offline reyalp

  • ******
  • 14114
Re: Mode dials and Playback pushbuttons
« Reply #59 on: 25 / October / 2009, 16:49:35 »
Thx reyalP for this great work !
Started with the tests, but sometimes it's NOT good to own 3 different, CHDK-supported cameras  :haha
2) MODE menu: most things are working; after setting a mode by script you can't select another mode with the Canon UI...
If you use "Reset Masked EV" (which I forgot to mention in the documentation!) this the mode dial should work again.

Quote
3) PRESS/UNPRESS: most things are working; on the Ixus cams some events must be used twice, e.g. PressFlashButton on the SD870...
Interesting. Maybe try a script that does a press/unpress pair ?
Quote
4) MISC menu: some nice things there... e.g. ConnectVideoCable, disables the display (SD870)
Yup. On a540 you can also do "OpenBatteryCover" :P


  - 'mode event mask ...' crashed after toggling a couple of entries - quite likely because                                  it's unclear to me what Y and N stand for here ...
I'll try to describe this a little better. There is a function SetLogicalEventActive(event num, state) in the canon code. When the canon script functions (UIFS_blah) do something like setting the mode dial, they call SetLogicalEventActive(mode event, 0) on most of the mode dial events other than the one being set, and then they call it with 1 on the one being set.

The lua code tries to do the same thing, but it doesn't know which mode dial events are valid on your camera, and can't tell which ones the canon code would mask. Unfortunately, calling SetLogicalEventActive on some of the ones that aren't valid seems to cause a crash. We could call the canon function, but it only does a few modes.

Anyway, the ones with a Y in the mask menu are the ones lua will call SetLogicalEventActive(0) on. Ones with N will be ignored.

Clear as mud ?

I think we should concentrate on SetCurrentCaptureModeType for mode changing, and use events for play/rec/shutdown etc. If anyone wants builds with SetCurrentCaptureModeType, just let me know. I'll try adding this to the sig finder today.
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal