Added basic Android touch movement (Refs #173)
This commit is contained in:
parent
143c1c3aac
commit
2eb9b14cc2
2 changed files with 22 additions and 1 deletions
|
|
@ -327,11 +327,22 @@ void VulkanExampleBase::renderLoop()
|
||||||
fpsTimer = 0.0f;
|
fpsTimer = 0.0f;
|
||||||
frameCounter = 0;
|
frameCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool updateView = false;
|
||||||
|
|
||||||
|
// Check touch state (for movement)
|
||||||
|
if (touchDown) {
|
||||||
|
touchTimer += frameTimer;
|
||||||
|
}
|
||||||
|
if (touchTimer >= 1.0) {
|
||||||
|
camera.keys.up = true;
|
||||||
|
viewChanged();
|
||||||
|
}
|
||||||
|
|
||||||
// Check gamepad state
|
// Check gamepad state
|
||||||
const float deadZone = 0.0015f;
|
const float deadZone = 0.0015f;
|
||||||
// todo : check if gamepad is present
|
// todo : check if gamepad is present
|
||||||
// todo : time based and relative axis positions
|
// todo : time based and relative axis positions
|
||||||
bool updateView = false;
|
|
||||||
if (camera.type != Camera::CameraType::firstperson)
|
if (camera.type != Camera::CameraType::firstperson)
|
||||||
{
|
{
|
||||||
// Rotate
|
// Rotate
|
||||||
|
|
@ -1169,9 +1180,17 @@ int32_t VulkanExampleBase::handleAppInput(struct android_app* app, AInputEvent*
|
||||||
int32_t action = AMotionEvent_getAction(event);
|
int32_t action = AMotionEvent_getAction(event);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case AMOTION_EVENT_ACTION_UP: {
|
||||||
|
vulkanExample->touchTimer = 0.0;
|
||||||
|
vulkanExample->touchDown = false;
|
||||||
|
vulkanExample->camera.keys.up = false;
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AMOTION_EVENT_ACTION_DOWN: {
|
case AMOTION_EVENT_ACTION_DOWN: {
|
||||||
vulkanExample->touchPos.x = AMotionEvent_getX(event, 0);
|
vulkanExample->touchPos.x = AMotionEvent_getX(event, 0);
|
||||||
vulkanExample->touchPos.y = AMotionEvent_getY(event, 0);
|
vulkanExample->touchPos.y = AMotionEvent_getY(event, 0);
|
||||||
|
vulkanExample->touchDown = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AMOTION_EVENT_ACTION_MOVE: {
|
case AMOTION_EVENT_ACTION_MOVE: {
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,8 @@ public:
|
||||||
int32_t x;
|
int32_t x;
|
||||||
int32_t y;
|
int32_t y;
|
||||||
} touchPos;
|
} touchPos;
|
||||||
|
bool touchDown = false;
|
||||||
|
double touchTimer = 0.0;
|
||||||
/** @brief Product model and manufacturer of the Android device (via android.Product*) */
|
/** @brief Product model and manufacturer of the Android device (via android.Product*) */
|
||||||
std::string androidProduct;
|
std::string androidProduct;
|
||||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue