Left / Right Click via Axis

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

Post Reply
Glodigit
Posts: 4
Joined: Mon Apr 03, 2023 3:37 pm

Left / Right Click via Axis

Post by Glodigit »

I've set up the Global.xml and Desktop.xml files to allow fluid, togglable 2D mouse movement on my Space Explorer (using driver version 10.6.4) but was unable to get HIDMouse_[Left/Right] to activate if one of the rotational axes (HIDMultiAxis_Ry) is tilted with a deadband of 200 or so.

The immediate goal is to tilt one way for a left click and rotate the other way for a right click. Ideally, this could also be used for macros via HIDMultiAxis_Rx.
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Left / Right Click via Axis

Post by jwick »

There is no built-in way to do that.

You would need to write some code (e.g., a script) that would be called by the Axis.

Or possibly, you could use a MouseX/Y event that has a LeftMouseButton/RightMouseButton as a modifier. It would move the cursor, but it would also press and release the button. Maybe if you had an output scaling factor of 0 it might not move the cursor.
Glodigit
Posts: 4
Joined: Mon Apr 03, 2023 3:37 pm

Re: Left / Right Click via Axis

Post by Glodigit »

I tried the modifer method. It's a great way to prove the concept, and left / right mouse click events are sent, but it's quite sensitive:

Code: Select all

<Axis>
	<Enabled>true</Enabled>
		<Input>
                        <ActionID>HIDMultiAxis_Ry</ActionID>
                        <Min>0</Min>
                        <Max>511</Max>
                        <Deadband>0</Deadband>
		</Input>
		<Output>
                        <ActionID>HIDMouse_Y</ActionID>
                        <Scale>0.001</Scale>
                        <Modifiers>
                         	<Modifier>LeftMouse</Modifier>
                        </Modifiers>
	</Output>
</Axis>
The modifier doesn't seem to activate unless there's at least some movement, so Scale 0 (or anything under 0.001) doesn't work. Neither does using HIDMultiAxis_Ry for the output ActionID (to circumvent the mouse moving during clicks) or manually counteracting the mouse movement.

It also seems that the deadband is checked after scaling, so even a value of 1 doesn't work predictably unless the scale is approx 0.1, thus changing the sensitivity from too sensitive to somewhat insensitive. However, it does seem like the deadband is necessary for both left and right clicks to work.

For the script, are you referring to use something like AutoHotKey or something else?

Also, is it possible to run MacroEntries in a similar fashion?
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Left / Right Click via Axis

Post by jwick »

I was thinking along the lines of https://stackoverflow.com/questions/393 ... powershell
But probably calling autohotkey is better. Though it needs to be able to be called a zillion times...
I don't think I implemented a <RepeatStyle>CallOnceAboveThisLevelAndDontCallAgainUntilTheAxisGoesToZero</RepeatStyle>. It is an interesting idea.

I would just do this with a DLL in C. Way less overhead.

To execute it, you need an AxisAction like this, which contains the details of what you want to execute:
In the AppCfg for your app, or Global.xml:

Code: Select all

  <AxisActions>
    <AxisAction Type="Exe">
      <ID>Call_PS_LMB</ID>
      <Name>Send LMB</Name>
      <Executable>yourscriptname (with full path if it is not in your PATH)</Executable>
      <Arg>HIDID</Arg>
    </AxisAction>
  </AxisActions>
Here is an example of a ButtonAction calling a VBS:

Code: Select all

    <ButtonAction Type="Exe">
      <ID>VBS_RunSample</ID>
      <Name>Run Sample VBS</Name>
      <Executable>cscript.EXE</Executable>
      <Arg>e:\mytemp\vbs\samples.vbs SaveDir dirname1 c:\tmp</Arg>
    </ButtonAction>
To use it, assign it to an Axis:

Code: Select all

<Device>
...
   <AxisBank>
      <ID>Default</ID>
      <Name>STR_DEFAULT_BANK</Name>
   <Axis>
       <Enabled>true</Enabled>
       <Input>
          <ActionID>HIDMultiAxis_Ry</ActionID>
          <Min>-512</Min>
          <Max>512</Max>
       <Input>
      <Output>
           <ActionID>Call_PS_LMB</ActionID>
      </Output>
   </Axis>
   </AxisBank>
   </Device>
   
It will get called at ~60Hz. In that code you will get the value for the device axis. You probably want to ignore everything under a certain value. Then trigger a LMB/RMB when that threshold is exceeded. Keep track that you sent it to make sure 1) you release it!! 2) you don't send it more than once.

I don't think we can run the new extended Macros on an Axis. Just Buttons.
Glodigit
Posts: 4
Joined: Mon Apr 03, 2023 3:37 pm

Re: Left / Right Click via Axis

Post by Glodigit »

So what I understand from this is that:
  • AxisAction doesn't have a Type="Button" and/or cannot run HIDMouse_Left/Middle/Right, or if it can, will rapid-click at 60Hz.
  • The script is run with no memory of any previous executions.
  • The script is executed 60 times in a second.
  • The script would need to both check if the axis is over a specified value and if the mouse button is not already down before sending a click-down event. A similar check is needed when the axis is under the value.
I think I'll be fine with just running the left / middle / right clicks on the cylinder and running macros on the programmable buttons.
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Left / Right Click via Axis

Post by jwick »

All correct.

#1 reminds me why I didn't do it inside the driver. A 60Hz LMB isn't of much use.

It is a direct replacement. instead of running my code at 60Hz, it runs your code.

Remembering the state is a bit much to ask of a script.

Let me work on a DLL for you. Make sure your email address is accurate.....email sent.
Post Reply