Add the ability to use a custom delay time for button presses.
This commit is contained in:
11
Joystick.cpp
11
Joystick.cpp
@ -21,11 +21,12 @@ bool operator !=(JoyReport a, JoyReport b){
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
Joystick::Joystick(bool debug) {
|
||||
Joystick::Joystick(uint8_t release_delay, bool debug) {
|
||||
_debug = debug;
|
||||
_virtual_buttons = 0;
|
||||
_num_axes = 0;
|
||||
_num_buttons = 0;
|
||||
this->release_delay = release_delay;
|
||||
|
||||
for (uint8_t i=0; i < JOYSTICK_NUM_AXES; i++) {
|
||||
_joyReport.axis[i] = 0;
|
||||
@ -58,7 +59,7 @@ void Joystick::AddEncoder(uint8_t pin1, uint8_t pin2, int8_t tick_threshold, But
|
||||
switch (type) {
|
||||
case ENCODER_PULSED_SPLIT:
|
||||
// add an encoder button. _BuildButton() doesn't do everything we need, however...
|
||||
button = new EncoderButton(pin1, pin2, _virtual_buttons, tick_threshold);
|
||||
button = new EncoderButton(pin1, pin2, _virtual_buttons, tick_threshold, release_delay);
|
||||
_buttons[_num_buttons] = button;
|
||||
_num_buttons++;
|
||||
_virtual_buttons += 2;
|
||||
@ -157,15 +158,15 @@ void Joystick::_addButton(ButtonType type, Reader* reader) {
|
||||
_virtual_buttons++;
|
||||
break;
|
||||
case BUTTON_PULSED:
|
||||
button = new PulsedButton(_virtual_buttons, reader, false, false);
|
||||
button = new PulsedButton(_virtual_buttons, reader, release_delay, false, false);
|
||||
_virtual_buttons++;
|
||||
break;
|
||||
case BUTTON_PULSED_DOUBLE_ACTION:
|
||||
button = new PulsedButton(_virtual_buttons, reader, true, false);
|
||||
button = new PulsedButton(_virtual_buttons, reader, release_delay, true, false);
|
||||
_virtual_buttons++;
|
||||
break;
|
||||
case BUTTON_PULSED_DOUBLE_ACTION_SPLIT:
|
||||
button = new PulsedButton(_virtual_buttons, reader, true, true);
|
||||
button = new PulsedButton(_virtual_buttons, reader, release_delay, true, true);
|
||||
_virtual_buttons += 2;
|
||||
break;
|
||||
case BUTTON_LATCHED_MOMENTARY:
|
||||
|
Reference in New Issue
Block a user