mirror of
https://github.com/CrispyPin/sinpin-vr.git
synced 2025-06-07 14:35:34 +02:00
add haptic feedback on scroll
This commit is contained in:
parent
47ebf9d64c
commit
6f44ea6b5a
5 changed files with 24 additions and 1 deletions
|
@ -75,6 +75,8 @@ App::App()
|
|||
assert(action_err == 0);
|
||||
action_err = vr_input->GetActionHandle("/actions/cursor/in/scroll", &_input_handles.cursor.scroll);
|
||||
assert(action_err == 0);
|
||||
action_err = vr_input->GetActionHandle("/actions/cursor/out/scroll_haptic", &_input_handles.cursor.scroll_haptic);
|
||||
assert(action_err == 0);
|
||||
action_err = vr_input->GetActionSetHandle("/actions/main", &_input_handles.main_set);
|
||||
assert(action_err == 0);
|
||||
action_err = vr_input->GetActionSetHandle("/actions/edit", &_input_handles.edit_set);
|
||||
|
|
|
@ -32,6 +32,7 @@ struct InputHandles
|
|||
vr::VRActionHandle_t mouse_right;
|
||||
vr::VRActionHandle_t mouse_middle;
|
||||
vr::VRActionHandle_t scroll;
|
||||
vr::VRActionHandle_t scroll_haptic;
|
||||
} cursor;
|
||||
vr::VRActionSetHandle_t cursor_set;
|
||||
struct
|
||||
|
|
|
@ -8,6 +8,8 @@ const float LASER_WIDTH = 0.004f;
|
|||
const Color EDIT_COLOR{1, 0.6f, 1};
|
||||
const Color CURSOR_COLOR{0.3f, 1, 1};
|
||||
const float SCROLL_SPEED = 48;
|
||||
const float SCROLL_HAPTIC_STRENGTH = 0.15f;
|
||||
const float SCROLL_HAPTIC_TIME = 0.1f;
|
||||
const float MOUSE_DRAG_THRESHOLD = 48;
|
||||
|
||||
Controller::Controller(App *app, ControllerSide side)
|
||||
|
@ -161,11 +163,13 @@ void Controller::Update(float dtime)
|
|||
{
|
||||
_app->SendMouseInput(4, true);
|
||||
_app->SendMouseInput(4, false);
|
||||
_app->vr_input->TriggerHapticVibrationAction(_app->_input_handles.cursor.scroll_haptic, 0, SCROLL_HAPTIC_TIME, 1 / SCROLL_HAPTIC_TIME, SCROLL_HAPTIC_STRENGTH, _input_handle);
|
||||
}
|
||||
else if (scroll_state.y < 0)
|
||||
{
|
||||
_app->SendMouseInput(5, true);
|
||||
_app->SendMouseInput(5, false);
|
||||
_app->vr_input->TriggerHapticVibrationAction(_app->_input_handles.cursor.scroll_haptic, 0, SCROLL_HAPTIC_TIME, 1 / SCROLL_HAPTIC_TIME, SCROLL_HAPTIC_STRENGTH, _input_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue