Skip to content

Commit

Permalink
[Vita] Use SDL_RegisterEvents() to assign custom event type
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills authored and AJenbo committed May 22, 2023
1 parent 750cebc commit bf93317
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/platform/vita/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ bool touch_initialized = false;
unsigned int simulated_click_start_time[TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
bool direct_touch = true; // pointer jumps to finger
Point Mouse; // always reflects current mouse position
uint32_t IgnoreEvent = SDL_USEREVENT; // custom event type to signal events that should be ignored

enum {
// clang-format off
Expand Down Expand Up @@ -94,6 +95,8 @@ void InitTouch()
visible_width = (current.h * devilution::gnScreenWidth) / devilution::gnScreenHeight;
x_borderwidth = (current.w - visible_width) / 2;
y_borderwidth = (current.h - visible_height) / 2;

IgnoreEvent = SDL_RegisterEvents(1);
}

void SetMouseButtonEvent(SDL_Event &event, uint32_t type, uint8_t button, Point position)
Expand Down Expand Up @@ -440,8 +443,7 @@ void HandleTouchEvent(SDL_Event *event, Point mousePosition)
}
PreprocessEvents(event);
if (event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP || event->type == SDL_FINGERMOTION) {
event->type = SDL_USEREVENT;
event->user.code = -1; // ensure this event is ignored;
event->type = IgnoreEvent;
}
}

Expand Down

0 comments on commit bf93317

Please sign in to comment.