mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 09:30:35 +00:00
mobile orientation handling
This commit is contained in:
parent
ad172724e8
commit
bd84b76c1b
14
init.cpp
14
init.cpp
@ -165,6 +165,10 @@
|
|||||||
#define CAP_PNG (!ISMOBWEB)
|
#define CAP_PNG (!ISMOBWEB)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CAP_ORIENTATION
|
||||||
|
#define CAP_ORIENTATION ISMOBILE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_COMMANDLINE
|
#ifndef CAP_COMMANDLINE
|
||||||
#define CAP_COMMANDLINE (!ISMOBILE)
|
#define CAP_COMMANDLINE (!ISMOBILE)
|
||||||
#endif
|
#endif
|
||||||
@ -299,13 +303,13 @@ void gdpush(int t);
|
|||||||
typedef int SDL_Event;
|
typedef int SDL_Event;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #if ISWEB
|
#if ISWEB
|
||||||
// inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; }
|
inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; }
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
/* extern "C" {
|
||||||
Uint8 *SDL_GetKeyState(void*);
|
Uint8 *SDL_GetKeyState(void*);
|
||||||
}
|
} */
|
||||||
|
|
||||||
#ifndef CAP_GLEW
|
#ifndef CAP_GLEW
|
||||||
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX)
|
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX)
|
||||||
|
15
rug.cpp
15
rug.cpp
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace rug {
|
namespace rug {
|
||||||
|
|
||||||
|
int when_enabled;
|
||||||
|
|
||||||
struct rug_exception { };
|
struct rug_exception { };
|
||||||
|
|
||||||
bool fast_euclidean = true;
|
bool fast_euclidean = true;
|
||||||
@ -1196,6 +1198,7 @@ transmatrix currentrot;
|
|||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
if(rugged) return;
|
if(rugged) return;
|
||||||
|
when_enabled = ticks;
|
||||||
glbuf = new renderbuffer(TEXTURESIZE, TEXTURESIZE, vid.usingGL && !rendernogl);
|
glbuf = new renderbuffer(TEXTURESIZE, TEXTURESIZE, vid.usingGL && !rendernogl);
|
||||||
if(!glbuf->valid) {
|
if(!glbuf->valid) {
|
||||||
addMessage(XLAT("Failed to enable"));
|
addMessage(XLAT("Failed to enable"));
|
||||||
@ -1303,12 +1306,24 @@ void finger_on(int coord, ld val) {
|
|||||||
enqueue(finger_center), good_shape = false;
|
enqueue(finger_center), good_shape = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transmatrix last_orientation;
|
||||||
|
|
||||||
void actDraw() {
|
void actDraw() {
|
||||||
try {
|
try {
|
||||||
if(!renderonce) prepareTexture();
|
if(!renderonce) prepareTexture();
|
||||||
physics();
|
physics();
|
||||||
drawRugScene();
|
drawRugScene();
|
||||||
|
|
||||||
|
#if CAP_ORIENTATION
|
||||||
|
if(ticks < when_enabled + 500)
|
||||||
|
last_orientation = getOrientation();
|
||||||
|
else {
|
||||||
|
transmatrix next_orientation = getOrientation();
|
||||||
|
apply_rotation(inverse(last_orientation) * next_orientation);
|
||||||
|
last_orientation = next_orientation;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
Uint8 *keystate = SDL_GetKeyState(NULL);
|
Uint8 *keystate = SDL_GetKeyState(NULL);
|
||||||
int qm = 0;
|
int qm = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user