Treat 2-fingers touch as right click

This commit is contained in:
kichikuou
2017-04-01 18:36:56 +09:00
parent a3d1d4dbfa
commit 79a283b42a
5 changed files with 19 additions and 35 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ EMFLAGS += -O2
EMFLAGS += -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
LFLAGS := $(EMFLAGS)
LFLAGS += -s EXPORTED_FUNCTIONS="['_main','_ags_setAntialiasedStringMode','_sdl_rightButton', '_ald_getdata', '_ald_freedata']"
LFLAGS += -s EXPORTED_FUNCTIONS="['_main','_ags_setAntialiasedStringMode', '_ald_getdata', '_ald_freedata']"
WASMFLAGS := -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s "BINARYEN_TRAP_MODE='allow'"
ASMJSFLAGS := -s TOTAL_MEMORY=100663296
-1
View File
@@ -37,7 +37,6 @@ header {
}
.contents {
-webkit-user-select: none;
max-width: 640px;
margin: 2ex auto 0;
}
-17
View File
@@ -96,7 +96,6 @@ namespace xsystem35 {
Module.callMain();
this.antialiasChanged();
}, 0);
this.addRightClickEmulation();
}
setStatus(text: string) {
@@ -140,22 +139,6 @@ namespace xsystem35 {
localStorage.setItem('antialias', String(this.antialiasCheckbox.checked));
_ags_setAntialiasedStringMode(this.antialiasCheckbox.checked ? 1 : 0);
}
private addRightClickEmulation() {
let emulatingRightClick = false;
document.body.addEventListener('touchstart', (e) => {
if (e.target !== document.body)
return;
_sdl_rightButton(1);
emulatingRightClick = true;
});
document.body.addEventListener('touchend', (e) => {
if (!emulatingRightClick)
return;
_sdl_rightButton(0);
emulatingRightClick = false;
});
}
}
export let shell = new System35Shell();
-1
View File
@@ -23,7 +23,6 @@ declare var WebAssembly: any;
// xsystem35 exported functions
declare function _musfade_setvolval_all(vol: number): void;
declare function _ags_setAntialiasedStringMode(on: number): void;
declare function _sdl_rightButton(down: number): void;
declare function _ald_getdata(type: number, no: number): number;
declare function _ald_freedata(data: number): void;
+18 -15
View File
@@ -124,17 +124,27 @@ static void sdl_getEvent(void) {
break;
case SDL_FINGERDOWN:
mouseb |= 1 << SDL_BUTTON_LEFT;
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_LEFT)] = TRUE;
mousex = e.tfinger.x * view_w;
mousey = e.tfinger.y * view_h;
if (SDL_GetNumTouchFingers(SDL_GetTouchDevice(0)) >= 2) {
mouseb &= ~(1 << SDL_BUTTON_LEFT);
mouseb |= 1 << SDL_BUTTON_RIGHT;
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_LEFT)] = FALSE;
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_RIGHT)] = TRUE;
} else {
mouseb |= 1 << SDL_BUTTON_LEFT;
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_LEFT)] = TRUE;
mousex = e.tfinger.x * view_w;
mousey = e.tfinger.y * view_h;
}
break;
case SDL_FINGERUP:
mouseb &= ~(1 << SDL_BUTTON_LEFT);
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_LEFT)] = FALSE;
mousex = e.tfinger.x * view_w;
mousey = e.tfinger.y * view_h;
if (SDL_GetNumTouchFingers(SDL_GetTouchDevice(0)) == 0) {
mouseb &= ~(1 << SDL_BUTTON_LEFT | 1 << SDL_BUTTON_RIGHT);
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_LEFT)] = FALSE;
RawKeyInfo[mouse_to_rawkey(SDL_BUTTON_RIGHT)] = FALSE;
mousex = e.tfinger.x * view_w;
mousey = e.tfinger.y * view_h;
}
break;
case SDL_FINGERMOTION:
@@ -252,10 +262,3 @@ int sdl_getjoyinfo(void) {
return joyinfo;
}
#endif
void sdl_rightButton(int down) {
SDL_Event sdlevent;
sdlevent.type = down ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
sdlevent.button.button = SDL_BUTTON_RIGHT;
SDL_PushEvent(&sdlevent);
}