YukMingLaw / ArduinoJoystickWithFFBLibrary

An Arduino Joystick Library With Force Feedback Feature
GNU Lesser General Public License v3.0
208 stars 55 forks source link

JOYSTICK_TYPE_GAMEPAD Crashes DCS (Digital Combat Simulator) #3

Closed omarachrafbrasil closed 4 years ago

omarachrafbrasil commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

omarachrafbrasil commented 4 years ago

Hi, I commented out delay(20) and tried again. Then run DCS. Still crashed. In a DCS forum of 2 years ago someone commented regarding FFD on gamepads. This promote some Idea about the problem? Omar Achraf

Em ter., 19 de mai. de 2020 às 14:52, York Law notifications@github.com escreveu:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary/issues/3#issuecomment-630981288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK2MODQ5GXFMOMZYWKGL5ZDRSLBO5ANCNFSM4NEWEOEQ .

omarachrafbrasil commented 4 years ago

Hi, just another feedback. I tested with the library that doesnt have FFB ( https://github.com/MHeironimus/ArduinoJoystickLibrary ) and it worked ok with DCS. Could be related to FFB? Omar Achraf

Em ter., 19 de mai. de 2020 às 17:54, Omar Achraf omarachraf@gmail.com escreveu:

Hi, I commented out delay(20) and tried again. Then run DCS. Still crashed. In a DCS forum of 2 years ago someone commented regarding FFD on gamepads. This promote some Idea about the problem? Omar Achraf

Em ter., 19 de mai. de 2020 às 14:52, York Law notifications@github.com escreveu:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary/issues/3#issuecomment-630981288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK2MODQ5GXFMOMZYWKGL5ZDRSLBO5ANCNFSM4NEWEOEQ .

YukMingLaw commented 4 years ago

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

YukMingLaw commented 4 years ago

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 commented 4 years ago

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

omarachrafbrasil commented 4 years ago

Hi, Updated! and recompiled and upload to my pro micro (without Joystick.getForce(forces); )

It executed DCS simulator withou crash. But, when I exit DCS, DCS hangs. Need too kill.

Omar Achraf

Em seg., 25 de mai. de 2020 às 15:37, York Law notifications@github.com escreveu:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary/issues/3#issuecomment-633680267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK2MODWUBBKY7CKTYWK3JOLRTK3HVANCNFSM4NEWEOEQ .