Servers by jDrones

Joystick call from Plugin

(Davide Gianuzzi) #1

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

(charles linquist) #2

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.

(Corrado Steri) #3

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

(Andras Schaffer) #4

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…

(Davide Gianuzzi) #5

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

(Corrado Steri) #6

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

(Andras Schaffer) #7

What about
isButtonPressed
and
getValueForChannel or getRawValueForChannel

You have to have enabled and started joy for them

(Corrado Steri) #8

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…

(Andras Schaffer) #9

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.

(Andras Schaffer) #10

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.