diff --git a/Arduino/Esp32/Main/Controller.cpp b/Arduino/Esp32/Main/Controller.cpp index b7736927..fff8fcdc 100644 --- a/Arduino/Esp32/Main/Controller.cpp +++ b/Arduino/Esp32/Main/Controller.cpp @@ -39,34 +39,40 @@ static const int16_t JOYSTICK_RANGE = JOYSTICK_MAX_VALUE - JOYSTICK_MIN_VALUE; char ssid[23]; uint64_t chipid = ESP.getEfuseMac(); // The chip ID is essentially its MAC address(length: 6 bytes). unsigned int chip = (unsigned int)(chipid >> 32); - std::string bluetoothName_lcl = "DiyActivePedal_" + std::to_string( chip ); + std::string bluetoothName_lcl = "DiyFfbPedal_" + std::to_string( chip ); BleGamepad bleGamepad(bluetoothName_lcl, bluetoothName_lcl, 100); void SetupController() { BleGamepadConfiguration bleGamepadConfig; - bleGamepadConfig.setControllerType(CONTROLLER_TYPE_GAMEPAD); // CONTROLLER_TYPE_JOYSTICK, CONTROLLER_TYPE_GAMEPAD (DEFAULT), CONTROLLER_TYPE_MULTI_AXIS + bleGamepadConfig.setControllerType(CONTROLLER_TYPE_MULTI_AXIS); // CONTROLLER_TYPE_JOYSTICK, CONTROLLER_TYPE_GAMEPAD (DEFAULT), CONTROLLER_TYPE_MULTI_AXIS bleGamepadConfig.setAxesMin(JOYSTICK_MIN_VALUE); // 0 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal bleGamepadConfig.setAxesMax(JOYSTICK_MAX_VALUE); // 32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal //bleGamepadConfig.setWhichSpecialButtons(false, false, false, false, false, false, false, false); - //bleGamepadConfig.setWhichAxes(false, false, false, false, false, false, false, false); - bleGamepadConfig.setWhichSimulationControls(false, false, false, true, false); // only brake active + bleGamepadConfig.setWhichAxes(true, true, true, true, true, true, true, true); + //bleGamepadConfig.setWhichSimulationControls(true, true, true, true, true); // only brake active bleGamepadConfig.setButtonCount(0); bleGamepadConfig.setHatSwitchCount(0); bleGamepadConfig.setAutoReport(false); bleGamepadConfig.setPid(chip); // product id bleGamepad.begin(&bleGamepadConfig); + + //bleGamepad.deviceManufacturer = "DiyFfbPedal"; + //bleGamepad.deviceName = chip; } bool IsControllerReady() { return bleGamepad.isConnected(); } void SetControllerOutputValue(int32_t value) { + //bleGamepad.setBrake(value); if (bleGamepad.isConnected() ) { - // bleGamepad.setBrake(value); - bleGamepad.setAxes(0, 0, 0, 0, value, 0, 0, 0); + //bleGamepad.setAxes(value, 0, 0, 0, 0, 0, 0, 0); + bleGamepad.setX(value); + //bleGamepad.setSimulationControls(value, 0, 0, 0, 0); + //bleGamepad.setSliders(value,0); bleGamepad.sendReport(); } else @@ -90,4 +96,4 @@ int32_t NormalizeControllerOutputValue(float value, float minVal, float maxVal, float fractional = (value - minVal) / valRange; int32_t controller = JOYSTICK_MIN_VALUE + (fractional * JOYSTICK_RANGE); return constrain(controller, JOYSTICK_MIN_VALUE, (maxGameOutput/100.) * JOYSTICK_MAX_VALUE); -} +} \ No newline at end of file