mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-14 09:04:31 +02:00
#15 fix web touch, remoove page margin
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>OpenLara</title></head>
|
||||
<body>
|
||||
<span id="status">Starting...</span>
|
||||
<canvas id="canvas" width="854" height="480" oncontextmenu="event.preventDefault()"></canvas><br>
|
||||
<head>
|
||||
<title>OpenLara</title>
|
||||
<style>
|
||||
html {
|
||||
overflow: hidden;
|
||||
}
|
||||
body {
|
||||
margin: 0px;
|
||||
}
|
||||
.game_fs {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<meta charset="utf-8">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="viewport" content="width=854px, user-scalable=no">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<canvas class="game" id="canvas" width="854px" height="480px" oncontextmenu="event.preventDefault()"></canvas><br>
|
||||
<div id="status">Starting...</div>
|
||||
<script type='text/javascript'>
|
||||
var statusElement = document.getElementById('status');
|
||||
var canvasElement = document.getElementById('canvas');
|
||||
|
@@ -139,8 +139,14 @@ void freeGL() {
|
||||
}
|
||||
|
||||
EM_BOOL resize() {
|
||||
int f;
|
||||
emscripten_get_canvas_size(&Core::width, &Core::height, &f);
|
||||
//int f;
|
||||
//emscripten_get_canvas_size(&Core::width, &Core::height, &f);
|
||||
double w, h;
|
||||
emscripten_get_element_css_size(NULL, &w, &h);
|
||||
Core::width = int(w);
|
||||
Core::height = int(h);
|
||||
emscripten_set_canvas_size(Core::width, Core::height);
|
||||
LOG("resize %d %d\n", Core::width, Core::height);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -200,6 +206,7 @@ EM_BOOL keyCallback(int eventType, const EmscriptenKeyboardEvent *e, void *userD
|
||||
|
||||
EM_BOOL touchCallback(int eventType, const EmscriptenTouchEvent *e, void *userData) {
|
||||
for (int i = 0; i < e->numTouches; i++) {
|
||||
if (!e->touches[i].isChanged) continue;
|
||||
InputKey key = Input::getTouch(e->touches[i].identifier);
|
||||
if (key == ikNone) continue;
|
||||
Input::setPos(key, vec2(e->touches[i].canvasX, e->touches[i].canvasY));
|
||||
@@ -207,7 +214,6 @@ EM_BOOL touchCallback(int eventType, const EmscriptenTouchEvent *e, void *userDa
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART || eventType == EMSCRIPTEN_EVENT_TOUCHEND || eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL)
|
||||
Input::setDown(key, eventType == EMSCRIPTEN_EVENT_TOUCHSTART);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -237,7 +243,7 @@ int main() {
|
||||
|
||||
emscripten_set_keydown_callback(0, 0, 1, keyCallback);
|
||||
emscripten_set_keyup_callback(0, 0, 1, keyCallback);
|
||||
emscripten_set_resize_callback(0, 0, 1, resizeCallback);
|
||||
emscripten_set_resize_callback(0, 0, 0, resizeCallback);
|
||||
|
||||
emscripten_set_touchstart_callback(0, 0, 0, touchCallback);
|
||||
emscripten_set_touchend_callback(0, 0, 0, touchCallback);
|
||||
|
Reference in New Issue
Block a user