update for direct press ui button
This commit is contained in:
parent
1d68454512
commit
b26d19b624
|
@ -150,9 +150,13 @@ static Uint32 lastType = -1;
|
||||||
static bool longPressed = false;
|
static bool longPressed = false;
|
||||||
static bool clicked = false;
|
static bool clicked = false;
|
||||||
|
|
||||||
|
bool gTouch = false;
|
||||||
|
int gTouchX;
|
||||||
|
int gTouchY;
|
||||||
|
|
||||||
bool mouseDeviceGetData(MouseData* mouseState)
|
bool mouseDeviceGetData(MouseData* mouseState)
|
||||||
{
|
{
|
||||||
mouseState->em_mode = false;
|
gTouch = false;
|
||||||
|
|
||||||
if (gLastInputType == INPUT_TYPE_TOUCH) {
|
if (gLastInputType == INPUT_TYPE_TOUCH) {
|
||||||
mouseState->x = gTouchMouseDeltaX;
|
mouseState->x = gTouchMouseDeltaX;
|
||||||
|
@ -174,9 +178,9 @@ bool mouseDeviceGetData(MouseData* mouseState)
|
||||||
} else if (clicked) {
|
} else if (clicked) {
|
||||||
clicked = false;
|
clicked = false;
|
||||||
if (em_mode) {
|
if (em_mode) {
|
||||||
mouseState->em_mode = em_mode;
|
gTouch = true;
|
||||||
mouseState->rawx = gTouchMouseLastX;
|
gTouchX = gTouchMouseLastX;
|
||||||
mouseState->rawy = gTouchMouseLastY;
|
gTouchY = gTouchMouseLastY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gTouchMouseLastX < screenGetWidth() / 4) {
|
if (gTouchMouseLastX < screenGetWidth() / 4) {
|
||||||
|
@ -208,8 +212,8 @@ void handleTouchEvent(SDL_Event* event)
|
||||||
Uint32 type = event->tfinger.type;
|
Uint32 type = event->tfinger.type;
|
||||||
SDL_FingerID id = event->tfinger.fingerId;
|
SDL_FingerID id = event->tfinger.fingerId;
|
||||||
|
|
||||||
if (id >= 2)
|
//if (id >= 2) ios platform may cause some problems
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
if (type == SDL_FINGERDOWN) {
|
if (type == SDL_FINGERDOWN) {
|
||||||
if (lastTouchId != -1 && id != lastTouchId) {
|
if (lastTouchId != -1 && id != lastTouchId) {
|
||||||
|
|
|
@ -11,9 +11,6 @@ typedef struct MouseData {
|
||||||
unsigned char buttons[2];
|
unsigned char buttons[2];
|
||||||
int wheelX;
|
int wheelX;
|
||||||
int wheelY;
|
int wheelY;
|
||||||
int rawx;
|
|
||||||
int rawy;
|
|
||||||
bool em_mode;
|
|
||||||
} MouseData;
|
} MouseData;
|
||||||
|
|
||||||
typedef struct KeyboardData {
|
typedef struct KeyboardData {
|
||||||
|
@ -38,6 +35,10 @@ void keyboardDeviceFree();
|
||||||
void handleMouseEvent(SDL_Event* event);
|
void handleMouseEvent(SDL_Event* event);
|
||||||
void handleTouchEvent(SDL_Event* event);
|
void handleTouchEvent(SDL_Event* event);
|
||||||
|
|
||||||
|
extern bool gTouch;
|
||||||
|
extern int gTouchX;
|
||||||
|
extern int gTouchY;
|
||||||
|
|
||||||
} // namespace fallout
|
} // namespace fallout
|
||||||
|
|
||||||
#endif /* DINPUT_H */
|
#endif /* DINPUT_H */
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
#include "window_manager_private.h"
|
#include "window_manager_private.h"
|
||||||
|
|
||||||
|
#include "dinput.h"
|
||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
#define MAX_WINDOW_COUNT (50)
|
#define MAX_WINDOW_COUNT (50)
|
||||||
|
@ -1738,6 +1740,22 @@ int _GNW_check_buttons(Window* window, int* keyCodePtr)
|
||||||
|
|
||||||
*keyCodePtr = -1;
|
*keyCodePtr = -1;
|
||||||
|
|
||||||
|
if (gTouch == true && gTouchX > window->rect.left && gTouchX < window->rect.right && gTouchY > window->rect.top && gTouchY < window->rect.bottom) {
|
||||||
|
int xx = gTouchX - window->rect.left;
|
||||||
|
int yy = gTouchY - window->rect.top;
|
||||||
|
|
||||||
|
Button* touchButton = window->buttonListHead;
|
||||||
|
while (touchButton != NULL && gTouch) {
|
||||||
|
if (!(touchButton->flags & BUTTON_FLAG_DISABLED)) {
|
||||||
|
if (xx > touchButton->rect.left && xx < touchButton->rect.right && yy > touchButton->rect.top && yy < touchButton->rect.bottom) {
|
||||||
|
|
||||||
|
_win_button_press_and_release(touchButton->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
touchButton = touchButton->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_mouse_click_in(window->rect.left, window->rect.top, window->rect.right, window->rect.bottom)) {
|
if (_mouse_click_in(window->rect.left, window->rect.top, window->rect.right, window->rect.bottom)) {
|
||||||
int mouseEvent = mouseGetEvent();
|
int mouseEvent = mouseGetEvent();
|
||||||
if ((window->flags & WINDOW_FLAG_0x40) || (mouseEvent & MOUSE_EVENT_LEFT_BUTTON_DOWN) == 0) {
|
if ((window->flags & WINDOW_FLAG_0x40) || (mouseEvent & MOUSE_EVENT_LEFT_BUTTON_DOWN) == 0) {
|
||||||
|
|
Loading…
Reference in New Issue