Skip to content

Commit c38c6c0

Browse files
committed
pybricks.iodevices.XboxController: Add rumble defaults.
1 parent 5dfd49f commit c38c6c0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pybricks/iodevices/pb_type_iodevices_xbox_controller.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ typedef struct {
471471
STATIC mp_obj_t pb_xbox_rumble(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
472472
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
473473
pb_type_xbox_obj_t, self,
474-
PB_ARG_REQUIRED(power),
475-
PB_ARG_REQUIRED(duration),
476-
PB_ARG_REQUIRED(delay),
477-
PB_ARG_REQUIRED(count)
474+
PB_ARG_DEFAULT_INT(power, 100),
475+
PB_ARG_DEFAULT_INT(duration, 200),
476+
PB_ARG_DEFAULT_INT(delay, 100),
477+
PB_ARG_DEFAULT_INT(count, 1)
478478
);
479479

480480
(void)self;
@@ -488,6 +488,11 @@ STATIC mp_obj_t pb_xbox_rumble(size_t n_args, const mp_obj_t *pos_args, mp_map_t
488488
// Number of rumbles, capped at 100.
489489
mp_int_t count = pb_obj_get_pct(count_in);
490490

491+
// Don't prefix delay if there is only one rumble.
492+
if (count == 1) {
493+
delay = 0;
494+
}
495+
491496
// User order is left, right, left trigger, right trigger.
492497
int8_t intensity[4];
493498
pb_obj_get_pct_or_array(power_in, 4, intensity);

0 commit comments

Comments
 (0)