dial and button issues on some cams - General Discussion and Assistance - CHDK Forum
supplierdeeply

dial and button issues on some cams

  • 30 Replies
  • 1026 Views
*

Offline reyalp

  • ******
  • 12586
dial and button issues on some cams
« on: 25 / May / 2020, 21:39:47 »
Advertisements
From @Caefix in the sd980 thread: https://chdk.setepontos.com/index.php?topic=4228.msg143504#msg143504
:) ..., except when FW update is used, yes. (My_fw=101c)

There´s another jogdial issue: :o
Ix200 & S110 ignore the wheels, S90 & Ix300 the clicks, (Ix870 takes them all.)
Code: [Select]
--[[
@title jogdial test
@chdk_version 1.4
]]

set_console_layout(0,0,25,10)

play_sound(4)
wheel_right()
print("wheel_right()", 1)
 sleep(2000)
 play_sound(4)
click "right"
print("click 'right'", 2)
 sleep(2000)
 play_sound(4)
wheel_left()
print("wheel_left()", 3)
 sleep(2000)
 play_sound(4)
click "left"
print("click 'left'", 4)
sleep(2000)
play_sound(5)

JogDialTest.Lua should perform 4 moves in the wheel-click combo, not 2.
Clicks allone work.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 12586
Re: dial and button issues on some cams
« Reply #1 on: 25 / May / 2020, 21:41:02 »
I don't really understand what the issue is, or what the script is supposed to do.

Do wheel_left() and wheel_right() work by themselves?
Don't forget what the H stands for.

*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #2 on: 26 / May / 2020, 12:42:06 »
Once a mystic man tried to reinvent the wheel, that´s why we have the triangle. :lol

Wheel works in menues, textbox() & file_browser().

In upper script (playmode) I would expect no sense but shifting 2 pics >> & 2 pics <<, like Sx200,Sx280,Ix870,... do.
But SX 230,260, Ix200 & S90,110, ... eat the wheels,
S90, Ix300, ?... the following clicks,
!Edi2: Sx210: the clicks & wheel_right() fail.

Because of the cams without jogdial at all I avoid the wheel_ statements in scripts, but there is the manual...
« Last Edit: 08 / June / 2020, 13:55:53 by Caefix »
All lifetime is a loan from eternity.

*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #3 on: 26 / May / 2020, 15:09:25 »
 :xmas Last line outdated!
Code: [Select]
/usr/bin/sh: svnversion: command not found

.../ubasic/ubasic.c  // factors
...
Enhanced & merged ... ( ( ( (  8)
Code: [Select]
@title jogdial.bas
@chdk_version 1.4

do
print -wheel_left,wheel_right
sleep 111
print , wheel_right,-wheel_left
sleep 222
until 1>2
end
« Last Edit: 28 / May / 2020, 13:25:25 by Caefix »
All lifetime is a loan from eternity.


*

Offline reyalp

  • ******
  • 12586
Re: dial and button issues on some cams
« Reply #4 on: 26 / May / 2020, 18:50:48 »
:xmas Last line outdated
I'm sorry. I don't understand what you are trying to communicate.

wheel_left() and wheel_right() send wheel events to the Canon firmware. They do not return anything, and are not expected to affect get_jogdial_direction()

get_jogdial_direction() is completely separate code which receives wheel changes (usually from hardware MMIO) to allow CHDK to respond to wheel inputs.

If you want to test the wheel_ functions, you can use chdkptp. Put the camera in a mode where using the physical wheel adjusts something, like Tv mode, or a menu, and then use
Code: [Select]
=wheel_left()
If the firmware responds the same as it does to physically turning the wheel one click, then it's ok.
Don't forget what the H stands for.

*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #5 on: 27 / May / 2020, 11:03:42 »
In modes without jogdial-function it´s nice on the parameter side. 8)
Code: [Select]
// tokenizer.c
#define MAX_NUMLEN 9  //
  {"get_wheel",               TOKENIZER_GET_WHEEL},
 
// tokenizer.h
  TOKENIZER_GET_WHEEL,
 
// ubasic.c
   short jogdial=0;

// ubasic.c  // factor
  case TOKENIZER_GET_WHEEL:
      accept(TOKENIZER_GET_WHEEL);
      r=get_jogdial_direction();
  jogdial=0;
  if (r==0) break;
      r=r==JOGDIAL_LEFT ? -1:1; // left=-1 | right=1
flag_yield=1;
    break;
  case TOKENIZER_WHEEL_LEFT:
      accept(TOKENIZER_WHEEL_LEFT);
  if (jogdial==-1) {jogdial=0; r=1; break;}
  if (jogdial== 1) {break;}
      r=get_jogdial_direction();
  jogdial=r==JOGDIAL_RIGHT ? 1:0; //
  if (r==0) break;
  r=r==JOGDIAL_LEFT ? 1:0;
flag_yield=1;
    break;
  case TOKENIZER_WHEEL_RIGHT:
      accept(TOKENIZER_WHEEL_RIGHT);
  if (jogdial== 1) {jogdial=0; r=1; break;}
  if (jogdial==-1) {break;} 
      r=get_jogdial_direction();
  jogdial=r==JOGDIAL_LEFT ? -1:0; //
  if (r==0) break;
  r=r==JOGDIAL_RIGHT ? 1:0;
flag_yield=1;
    break;
Code: [Select]
@title jogdial.bas
@chdk_version 1.4
@param J Use Jogdial
@default J 1
@range J 0 1

do
if J=1 then j=get_wheel
if j=-1 then print j, "wheel_left"
if j=1  then print j, "wheel_right"
sleep 111
until 1>2
end
« Last Edit: 28 / May / 2020, 13:16:44 by Caefix »
All lifetime is a loan from eternity.

*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #6 on: 28 / May / 2020, 15:30:19 »
 ??? Sx200-100d´s dual-zoom keys don´t respond to script commands.
In Ubasic with the upper update (Edit: & Lua with the lower ) I have now a workaround.
Code: [Select]
if J then
  R=get_wheel
  if R=-1 then click "zoom_out"
  if R=1  then click "zoom_in"
  sleep 333  // sleep 222 leads to a AFromlog
endif
« Last Edit: 02 / June / 2020, 15:17:20 by Caefix »
All lifetime is a loan from eternity.

*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #7 on: 01 / June / 2020, 12:01:36 »
   :haha       :xmas                                 FUNC(get_wheel)
    FUNC(is_wheel_left)
    FUNC(is_wheel_right)
    FUNC(get_metering_mode)
    FUNC(set_metering_mode)
Code: [Select]
--[[--
@title jogdial.Lua
@chdk_version 1.4
@param J Use Jogdial
@default J 1
@range J 0 1
--]]--

repeat
print(-is_wheel_left(),is_wheel_right())
sleep( 111)
print("", is_wheel_right(),-is_wheel_left())
sleep( 222)
until is_key "set"

c=0; j=0
repeat
if J==1 then
   j=get_wheel(); c=c+j;
   if j==-1 then print( j, "wheel_left",c) end
   if j==1  then print( j, "wheel_right",c) end
   sleep(111) end
until 1>2


--[[--
    FUNC(get_wheel)
    FUNC(is_wheel_left)
    FUNC(is_wheel_right)
    FUNC(get_metering_mode)
    FUNC(set_metering_mode)

static int luaCB_get_wheel( lua_State * L )
{
  short r=get_jogdial_direction();
  jogdial=0;
  if (r==0) {
     lua_pushnumber( L, 0 );
     return 1;
  }
  r=r==JOGDIAL_LEFT ? -1:1; // left=-1 | right=1
  lua_pushnumber( L, r );
    return 1;
}
static int luaCB_is_wheel_right( lua_State* L )
{
  if (jogdial==1) {jogdial=0;
         lua_pushnumber( L, 1 );
return 1;}
  if (jogdial==-1) {
         lua_pushnumber( L, 0 );
return 1;}
      short r=get_jogdial_direction();
  jogdial=r==JOGDIAL_LEFT ? -1:0; //
  if (r==0) {
         lua_pushnumber( L, 0 );
return 1;}
  r=r==JOGDIAL_RIGHT ? 1:0;
      lua_pushnumber( L, r );
  return 1;
}

static int luaCB_is_wheel_left( lua_State* L )
{
  if (jogdial==-1) {jogdial=0;
         lua_pushnumber( L, 1 );
return 1;}
  if (jogdial== 1) {
         lua_pushnumber( L, 0 );
return 1;}
      short r=get_jogdial_direction();
  jogdial=r==JOGDIAL_RIGHT ? 1:0; //
  if (r==0) {
         lua_pushnumber( L, 0 );
return 1;}
  r=r==JOGDIAL_LEFT ? 1:0;
      lua_pushnumber( L, r );
  return 1;
}


static int luaCB_get_metering_mode( lua_State* L )
{
  lua_pushnumber( L, camera_info.props.metering_mode );
  return 1;
}

static int luaCB_set_metering_mode( lua_State* L )
{
  shooting_set_prop(camera_info.props.metering_mode, luaL_checknumber( L, 1 ));
  return 0;
}

--]]--
::) Replacement of .zip because of twiligthed filename.
 If You place Luascript.c in /modules then happens that:
Code: [Select]
/usr/bin/sh: svnversion: command not found
gmake[1]: *** No rule to make target '.o/luascript.o', needed by '.o/lua.flt'.  Stop.
gmake: *** [all-recursive] Error 1
Edit2: No Borgs within a parsec, :D they had assimilated it at once, needs 1/2kb only.
« Last Edit: 06 / June / 2020, 13:13:20 by Caefix »
All lifetime is a loan from eternity.


*

Offline Caefix

  • ***
  • 213
  • Sorry, busy deleting test shots...
Re: dial and button issues on some cams
« Reply #8 on: 06 / June / 2020, 11:33:38 »
Sx260 all fine now! (Edit: Have seen it updated to download...)

 ???
Sx230,Sx240-100c,Sx260, Ix200-101c & S90-101c,S110-102b clicks good, wheels fail

Ix300 wheels good, click(key) fails. (only playback & shoot_half are fine)
Sx210  wheel_left() good, clicks like Ix300.
« Last Edit: 09 / June / 2020, 13:47:39 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 12586
Re: dial and button issues on some cams
« Reply #9 on: 08 / June / 2020, 15:42:45 »
Sx210  wheel_left() good else fails.
The event IDs in lib.c JogDial_ appear to be off by 1. Test build attached.

You can get the correct values in Lua using get_levent_def('RotateJogDialRight') and for JogDial_CW and get_levent_def('RotateJogDialLeft') for _CCW. The event number is the second return value. So a chdkptp one liner would be
Code: [Select]
=return ('CW:0x%x CCW:0x%x'):format(({get_levent_def('RotateJogDialRight')})[2],({get_levent_def('RotateJogDialLeft')})[2])

If the numbers are correct and wheel_left and wheel_right do not work, it may be like the issue discussed in the sx260 thread, where _PostLogicalEventToUI must be used instead of _PostLogicalEventForNotPowerType. Or it may be the final value must be 2 instead of one.

You can test these in chdkptp, using
=post_levent_for_npt('RotateJogDialLeft',1)
=post_levent_to_ui('RotateJogDialLeft',1)
etc.

As koshy discovered, the _for_npt variant may only work after _to_ui has been called. In that case, the port should use _to_ui.
Don't forget what the H stands for.

 

Related Topics