From 37e0fc1c9003e1d06e4a44ac54462e251de19507 Mon Sep 17 00:00:00 2001 From: schnoog Date: Fri, 10 Nov 2023 13:06:19 +0100 Subject: [PATCH] Fix of ISSUE 6. Timeout with a defauls of 2 ms added to sendState. Individual timeout can be defined in the begin() methode Readme updated. --- README.md | 3 ++- library.properties | 4 ++-- src/Joystick_ESP32S2.cpp | 4 ++-- src/Joystick_ESP32S2.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4ebb080..c8fe69a 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,10 @@ The following constants define the default values for the constructor parameters - `JOYSTICK_DEFAULT_BUTTON_COUNT` is set to `32` - `JOYSTICK_DEFAULT_HATSWITCH_COUNT` is set to `2` -### Joystick.begin(bool initAutoSendState) +### Joystick.begin(bool initAutoSendState, uint8_t timeout_ms = 2) Starts emulating a game controller connected to a computer. By default, all methods update the game controller state immediately. If `initAutoSendState` is set to `false`, the `Joystick.sendState` method must be called to update the game controller state. +The timeout_ms defines the timeout for the USB communication. ### Joystick.end() diff --git a/library.properties b/library.properties index 3cbf23e..2463cea 100644 --- a/library.properties +++ b/library.properties @@ -1,7 +1,7 @@ name=Joystick_ESP32S2 -version=0.9.4 +version=0.9.5 author=Schnoog feat. Matthew Heironimus -maintainer=Matthew Heironimus +maintainer=Schnoog sentence=Allows an ESP32S2/S3 board with USB capabilities to appear as a Joystick or Gamepad. paragraph=This library is built on the espressif/arduino-esp32 library. It can be used with or without other HID-based libraries (Mouse, Keyboard, etc.). category=Device Control diff --git a/src/Joystick_ESP32S2.cpp b/src/Joystick_ESP32S2.cpp index a2d695e..c7d737f 100644 --- a/src/Joystick_ESP32S2.cpp +++ b/src/Joystick_ESP32S2.cpp @@ -486,10 +486,10 @@ Joystick_::Joystick_( } -void Joystick_::begin(bool initAutoSendState, uint8_t intervalMs) +void Joystick_::begin(bool initAutoSendState, uint8_t timeout_ms) { HID.begin(); - _timeout_ms = intervalMs; + _timeout_ms = timeout_ms; _autoSendState = initAutoSendState; sendState(); } diff --git a/src/Joystick_ESP32S2.h b/src/Joystick_ESP32S2.h index d750253..1f89a44 100644 --- a/src/Joystick_ESP32S2.h +++ b/src/Joystick_ESP32S2.h @@ -128,7 +128,7 @@ class Joystick_: public USBHIDDevice bool includeBrake = true, bool includeSteering = true); - void begin(bool initAutoSendState = true, uint8_t interval_ms = 2); + void begin(bool initAutoSendState = true, uint8_t timeout_ms = 2); void end();