Browse Source

[vita] Add L2/R2 on back touch

pull/1037/head
Ivan Epifanov 5 years ago committed by Anders Jenbo
parent
commit
ab20c6fd4c
  1. 53
      SourceX/controls/touch.cpp

53
SourceX/controls/touch.cpp

@ -27,6 +27,10 @@ static void init_touch(void);
static void preprocess_events(SDL_Event *event);
static void preprocess_finger_down(SDL_Event *event);
static void preprocess_finger_up(SDL_Event *event);
#ifdef __vita__
static void preprocess_back_finger_down(SDL_Event *event);
static void preprocess_back_finger_up(SDL_Event *event);
#endif
static void preprocess_finger_motion(SDL_Event *event);
static void set_mouse_button_event(SDL_Event *event, uint32_t type, uint8_t button, int32_t x, int32_t y);
static void set_mouse_motion_event(SDL_Event *event, int32_t x, int32_t y, int32_t xrel, int32_t yrel);
@ -101,6 +105,16 @@ static void preprocess_events(SDL_Event *event)
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
if (port != 0) {
#ifdef __vita__
switch (event->type) {
case SDL_FINGERDOWN:
preprocess_back_finger_down(event);
break;
case SDL_FINGERUP:
preprocess_back_finger_up(event);
break;
}
#endif
return;
}
@ -157,6 +171,45 @@ static void preprocess_finger_down(SDL_Event *event)
break;
}
}
#ifdef __vita__
static void preprocess_back_finger_down(SDL_Event *event)
{
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
if (port != 1) return;
event->type = SDL_CONTROLLERAXISMOTION;
event->caxis.value = 32767;
event->caxis.which = 0;
if (event->tfinger.x <= 0.5) {;
event->caxis.axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
} else {
event->caxis.axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
}
}
static void preprocess_back_finger_up(SDL_Event *event)
{
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
if (port != 1) return;
event->type = SDL_CONTROLLERAXISMOTION;
event->caxis.value = 0;
event->caxis.which = 0;
if (event->tfinger.x <= 0.5) {;
event->caxis.axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
} else {
event->caxis.axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
}
}
#endif
static void preprocess_finger_up(SDL_Event *event)
{

Loading…
Cancel
Save