Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JOYSTICK_TYPE_GAMEPAD Crashes DCS (Digital Combat Simulator) #3

Closed
omarachrafbrasil opened this issue May 19, 2020 · 9 comments
Closed

Comments

@omarachrafbrasil
Copy link

The sketch below works in windows joystick usb configuration. However when I start DCS (Digital Combat Simulator) DCS crashes.

/*
switch in pin 2
potentiometers in A0, A1 and A2
Arduino pro micro
*/

#include "Joystick.h"

Joystick_ Joystick(
JOYSTICK_DEFAULT_REPORT_ID, // hidReportId
JOYSTICK_TYPE_GAMEPAD, // joystickType
1, // buttonCount
0, // hatSwitchCount
true, // includeXAxis
true, // includeYAxis
true, // includeZAxis
false,// includeRxAxis
false,// includeRyAxis
false,// includeRzAxis
false,// includeRudder
false,// includeThrottle
false,// includeAccelerator
false,// includeBrake
false // includeSteerings
);

const int pinButton = 2;

int sx, sy, sz; // sensor values
int x, y, z; // values to Joy X, Y, Z

void setup() {
pinMode(pinButton, INPUT_PULLUP);

Joystick.setXAxisRange(-1023, 1023);
Joystick.setYAxisRange(-1023, 1023);
Joystick.setZAxisRange(-127, 127);

Joystick.begin(false);
}

void loop() {
if (digitalRead(pinButton)) {
Joystick.pressButton(0); // 0..31
} else {
Joystick.releaseButton(0);
}

sx = analogRead(A0);
sy = analogRead(A1);
sz = analogRead(A2);

x = map(sx, 0, 1023, -1023, 1023);
y = map(sy, 0, 1023, -1023, 1023);
z = map(sz, 0, 1023, -127, 127);

Joystick.setXAxis(x);
Joystick.setYAxis(y);
Joystick.setZAxis(z);

Joystick.sendState();

delay(20);
}

@YukMingLaw
Copy link
Owner

Hi,I compiled your code and uploaded it to my arduino pro micro.It works nice.I cant recurrent the problem what you said.Maybe change another chip and try again?

@omarachrafbrasil
Copy link
Author

Hi, had you tried running DCS after your pro micro is plugged?
It worked for me too. Even it is possoble to perform the Settings in the Windows Game Controllers Windows.
The problem happens when the DCS (Digital combat simulator) is executed. DCS crashes with pro micro running this sketch/in my board.
If there my pro micro with is not plugged and DCS is executed, DCS dont crash.

@YukMingLaw
Copy link
Owner

You can delete delay(20); and try again.Or use more less delay like delay(1);.

@omarachrafbrasil
Copy link
Author

omarachrafbrasil commented May 19, 2020 via email

@omarachrafbrasil
Copy link
Author

omarachrafbrasil commented May 19, 2020 via email

@YukMingLaw
Copy link
Owner

got it,I will test the library in DCS soon:)

@YukMingLaw
Copy link
Owner

Hi,I have recurrented this problem yet.You must add Joystick.getForce(forces); to your code.
Because the force feddback part is appended to the HID descriptor,so when the game start,it will ask for the force feedback reply from device.

@YukMingLaw
Copy link
Owner

I updated the library.It changed a lot.You should download the latest version of library to make your program.

@omarachrafbrasil
Copy link
Author

omarachrafbrasil commented May 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants