mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
d/qwerty: Make controller support press-and-hold
This commit is contained in:
parent
469cc0516f
commit
3b0af8d184
|
@ -113,17 +113,10 @@ qwerty_update_inputs(struct xrt_device *xd)
|
||||||
struct qwerty_controller *qc = qwerty_controller(xd);
|
struct qwerty_controller *qc = qwerty_controller(xd);
|
||||||
struct qwerty_device *qd = &qc->base;
|
struct qwerty_device *qd = &qc->base;
|
||||||
|
|
||||||
xd->inputs[QWERTY_SELECT].value.boolean = qc->select_clicked;
|
QWERTY_TRACE(qd, "select: %u, menu: %u", qc->select_clicked, qc->menu_clicked);
|
||||||
if (qc->select_clicked) {
|
|
||||||
QWERTY_INFO(qd, "[%s] Select click", xd->str);
|
|
||||||
qc->select_clicked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
xd->inputs[QWERTY_SELECT].value.boolean = qc->select_clicked;
|
||||||
xd->inputs[QWERTY_MENU].value.boolean = qc->menu_clicked;
|
xd->inputs[QWERTY_MENU].value.boolean = qc->menu_clicked;
|
||||||
if (qc->menu_clicked) {
|
|
||||||
QWERTY_INFO(qd, "[%s] Menu click", xd->str);
|
|
||||||
qc->menu_clicked = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -509,8 +502,10 @@ qwerty_release_all(struct qwerty_device *qd)
|
||||||
// Controller methods
|
// Controller methods
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
void qwerty_select_click(struct qwerty_controller *qc) { qc->select_clicked = true; }
|
void qwerty_press_select(struct qwerty_controller *qc) { qc->select_clicked = true; }
|
||||||
void qwerty_menu_click(struct qwerty_controller *qc) { qc->menu_clicked = true; }
|
void qwerty_release_select(struct qwerty_controller *qc) { qc->select_clicked = false; }
|
||||||
|
void qwerty_press_menu(struct qwerty_controller *qc) { qc->menu_clicked = true; }
|
||||||
|
void qwerty_release_menu(struct qwerty_controller *qc) { qc->menu_clicked = false; }
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -254,18 +254,32 @@ struct qwerty_controller *
|
||||||
qwerty_controller(struct xrt_device *xd);
|
qwerty_controller(struct xrt_device *xd);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Simulate input/select/click
|
* Simulate pressing input/select/click
|
||||||
* @public @memberof qwerty_controller
|
* @public @memberof qwerty_controller
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
qwerty_select_click(struct qwerty_controller *qc);
|
qwerty_press_select(struct qwerty_controller *qc);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Simulate input/menu/click
|
* Simulate releasing input/select/click
|
||||||
* @public @memberof qwerty_controller
|
* @public @memberof qwerty_controller
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
qwerty_menu_click(struct qwerty_controller *qc);
|
qwerty_release_select(struct qwerty_controller *qc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Simulate pressing input/menu/click
|
||||||
|
* @public @memberof qwerty_controller
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
qwerty_press_menu(struct qwerty_controller *qc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Simulate releasing input/menu/click
|
||||||
|
* @public @memberof qwerty_controller
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
qwerty_release_menu(struct qwerty_controller *qc);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Attach/detach the pose of `qc` to its HMD. Only works when a qwerty_hmd is present.
|
* Attach/detach the pose of `qc` to its HMD. Only works when a qwerty_hmd is present.
|
||||||
|
|
|
@ -210,8 +210,10 @@ qwerty_process_event(struct xrt_device **xdevs, size_t xdev_count, SDL_Event eve
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select and menu clicks only for controllers.
|
// Select and menu clicks only for controllers.
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) qwerty_select_click(qctrl);
|
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) qwerty_press_select(qctrl);
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_MIDDLE) qwerty_menu_click(qctrl);
|
if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT) qwerty_release_select(qctrl);
|
||||||
|
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_MIDDLE) qwerty_press_menu(qctrl);
|
||||||
|
if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_MIDDLE) qwerty_release_menu(qctrl);
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue