Joystick call from Plugin

Good morning,
i’m writing down my own plugin, and what i need to do now is to intercept joystick events…
How can i do that?
I tried to create an instance of the joystick class, but the constructor ask to me of a “currentInstance” which i don’t know how to pass…

thanks in advance
best regards
Davide

I’m interested in a better Joystick interface myself. And I’m willing to pay for a good one. Let me know if you make any progress.

I think @Michael_Oborne is the only one that can answer on this. Hopefully will help.

You have to implement joystick handling in your plugin, Using the SharpDX.Joystick. (See Joystick.cs for hints) I’m not sure if this works parallel with the original joystick handling, but worth a try.

Or you can check joystick state via the MainV2.Joystick object (Do not create an instance, just use it), but to capture all events, you need to crank up your plugin execution interval…

Thanks a lot for your reply! i’m gonna check if it works this way!

Good morning,
i tried using directly MainV2.Joystick as suggested, and it worked, and from my plugin i can now check and enable/disable joystick…
but i cannot do the most important thing: check the joystick state as there’s no public state access
or method to do that…
Any other suggestions?

thanks a lot in advance

What about
isButtonPressed
and
getValueForChannel or getRawValueForChannel

You have to have enabled and started joy for them

getValueForChannel and getRawValueForChannel give back a short value which i don’t know how to manage.
I need the state.Ry value to correctly manage my zoom slider

The problem is that “state” object within MainV2.Joystick isn’t accessible…
Honestly i don’t know how to get out of here…

You can get a Ry value…

Set up an unused rc channel for Ry (for example Ch16) in Mission Planner. Set RC16_MAX _MIN and _TRIM in your autopilot for 2000,1000,1500. Then use getRawValueForChannel(16) to get a value between 1000 and 2000 set by the position of your Ry joystick axis.

This is all true if you use joystick for controlling your copter/plane as well. If you don’t use joystick for flight control, then you can keep joystick disabled in Mission Planner, and use SharpDX.Joystick to acquire and poll your jostick’s state.