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 clicked = false;
|
||||
|
||||
bool gTouch = false;
|
||||
int gTouchX;
|
||||
int gTouchY;
|
||||
|
||||
bool mouseDeviceGetData(MouseData* mouseState)
|
||||
{
|
||||
mouseState->em_mode = false;
|
||||
gTouch = false;
|
||||
|
||||
if (gLastInputType == INPUT_TYPE_TOUCH) {
|
||||
mouseState->x = gTouchMouseDeltaX;
|
||||
|
@ -174,9 +178,9 @@ bool mouseDeviceGetData(MouseData* mouseState)
|
|||
} else if (clicked) {
|
||||
clicked = false;
|
||||
if (em_mode) {
|
||||
mouseState->em_mode = em_mode;
|
||||
mouseState->rawx = gTouchMouseLastX;
|
||||
mouseState->rawy = gTouchMouseLastY;
|
||||
gTouch = true;
|
||||
gTouchX = gTouchMouseLastX;
|
||||
gTouchY = gTouchMouseLastY;
|
||||
}
|
||||
|
||||
if (gTouchMouseLastX < screenGetWidth() / 4) {
|
||||
|
@ -208,8 +212,8 @@ void handleTouchEvent(SDL_Event* event)
|
|||
Uint32 type = event->tfinger.type;
|
||||
SDL_FingerID id = event->tfinger.fingerId;
|
||||
|
||||
if (id >= 2)
|
||||
return;
|
||||
//if (id >= 2) ios platform may cause some problems
|
||||
// return;
|
||||
|
||||
if (type == SDL_FINGERDOWN) {
|
||||
if (lastTouchId != -1 && id != lastTouchId) {
|
||||
|
|
|
@ -11,9 +11,6 @@ typedef struct MouseData {
|
|||
unsigned char buttons[2];
|
||||
int wheelX;
|
||||
int wheelY;
|
||||
int rawx;
|
||||
int rawy;
|
||||
bool em_mode;
|
||||
} MouseData;
|
||||
|
||||
typedef struct KeyboardData {
|
||||
|
@ -38,6 +35,10 @@ void keyboardDeviceFree();
|
|||
void handleMouseEvent(SDL_Event* event);
|
||||
void handleTouchEvent(SDL_Event* event);
|
||||
|
||||
extern bool gTouch;
|
||||
extern int gTouchX;
|
||||
extern int gTouchY;
|
||||
|
||||
} // namespace fallout
|
||||
|
||||
#endif /* DINPUT_H */
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "win32.h"
|
||||
#include "window_manager_private.h"
|
||||
|
||||
#include "dinput.h"
|
||||
|
||||
namespace fallout {
|
||||
|
||||
#define MAX_WINDOW_COUNT (50)
|
||||
|
@ -1738,6 +1740,22 @@ int _GNW_check_buttons(Window* window, int* keyCodePtr)
|
|||
|
||||
*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)) {
|
||||
int mouseEvent = mouseGetEvent();
|
||||
if ((window->flags & WINDOW_FLAG_0x40) || (mouseEvent & MOUSE_EVENT_LEFT_BUTTON_DOWN) == 0) {
|
||||
|
|
Loading…
Reference in New Issue