mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 23:50:27 +00:00
CAP_MOUSEGRAB
This commit is contained in:
parent
de05d11cbd
commit
977c5f2d69
@ -30,7 +30,9 @@ bool mousemoved = false;
|
|||||||
bool actonrelease = false;
|
bool actonrelease = false;
|
||||||
|
|
||||||
bool mousepan, oldmousepan;
|
bool mousepan, oldmousepan;
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
ld mouseaim_x, mouseaim_y;
|
ld mouseaim_x, mouseaim_y;
|
||||||
|
#endif
|
||||||
ld mouseaim_sensitivity = 0.01;
|
ld mouseaim_sensitivity = 0.01;
|
||||||
|
|
||||||
int timetowait;
|
int timetowait;
|
||||||
@ -561,6 +563,7 @@ void mainloopiter() {
|
|||||||
mousepan = (cmode & (sm::NORMAL | sm::DRAW | sm::MAP)) && DIM == 3 && mouseaim_sensitivity;
|
mousepan = (cmode & (sm::NORMAL | sm::DRAW | sm::MAP)) && DIM == 3 && mouseaim_sensitivity;
|
||||||
if(mousepan != oldmousepan) {
|
if(mousepan != oldmousepan) {
|
||||||
oldmousepan = mousepan;
|
oldmousepan = mousepan;
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
if(mousepan) {
|
if(mousepan) {
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
@ -572,6 +575,7 @@ void mainloopiter() {
|
|||||||
SDL_WarpMouse(vid.xres/2, vid.yres/2);
|
SDL_WarpMouse(vid.xres/2, vid.yres/2);
|
||||||
mouseaim_x = mouseaim_y = 0;
|
mouseaim_x = mouseaim_y = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ISWEB
|
#if ISWEB
|
||||||
@ -635,8 +639,10 @@ void mainloopiter() {
|
|||||||
DEBB(DF_GRAPH, ("polling for events\n"));
|
DEBB(DF_GRAPH, ("polling for events\n"));
|
||||||
|
|
||||||
if(DIM == 3 && !shmup::on && !rug::rugged) {
|
if(DIM == 3 && !shmup::on && !rug::rugged) {
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View;
|
View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View;
|
||||||
mouseaim_x = mouseaim_y = 0;
|
mouseaim_x = mouseaim_y = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(smooth_scrolling && !shmup::on && !rug::rugged) {
|
if(smooth_scrolling && !shmup::on && !rug::rugged) {
|
||||||
|
5
hyper.h
5
hyper.h
@ -2591,7 +2591,10 @@ void initquickqueue();
|
|||||||
void quickqueue();
|
void quickqueue();
|
||||||
int darkenedby(int c, int lev);
|
int darkenedby(int c, int lev);
|
||||||
extern int mousex, mousey;
|
extern int mousex, mousey;
|
||||||
extern ld mouseaim_x, mouseaim_y, mouseaim_sensitivity;
|
#if CAP_MOUSEGRAB
|
||||||
|
extern ld mouseaim_x, mouseaim_y;
|
||||||
|
#endif
|
||||||
|
extern ld mouseaim_sensitivity;
|
||||||
string generateHelpForItem(eItem it);
|
string generateHelpForItem(eItem it);
|
||||||
bool graphglyph();
|
bool graphglyph();
|
||||||
extern bool hiliteclick;
|
extern bool hiliteclick;
|
||||||
|
12
shmup.cpp
12
shmup.cpp
@ -726,11 +726,13 @@ void handleInput(int delta) {
|
|||||||
panspin *= d;
|
panspin *= d;
|
||||||
panmove *= d;
|
panmove *= d;
|
||||||
|
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
if(lctrlclick) {
|
if(lctrlclick) {
|
||||||
panx += mouseaim_x / 2;
|
panx += mouseaim_x / 2;
|
||||||
pany += mouseaim_y / 2;
|
pany += mouseaim_y / 2;
|
||||||
mouseaim_x = mouseaim_y = 0;
|
mouseaim_x = mouseaim_y = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(panx || pany || panspin || (GDIM == 3 && panmove)) {
|
if(panx || pany || panspin || (GDIM == 3 && panmove)) {
|
||||||
if(DIM == 2) {
|
if(DIM == 2) {
|
||||||
@ -1717,12 +1719,14 @@ void movePlayer(monster *m, int delta) {
|
|||||||
|
|
||||||
bool blown = m->blowoff > curtime;
|
bool blown = m->blowoff > curtime;
|
||||||
|
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
if(WDIM == 2 && GDIM == 3 && !lctrlclick && cpid == 0) {
|
if(WDIM == 2 && GDIM == 3 && !lctrlclick && cpid == 0) {
|
||||||
if(!stdracing) playerturn[cpid] -= mouseaim_x;
|
if(!stdracing) playerturn[cpid] -= mouseaim_x;
|
||||||
playerturny[cpid] -= mouseaim_y;
|
playerturny[cpid] -= mouseaim_y;
|
||||||
mouseaim_x = 0;
|
mouseaim_x = 0;
|
||||||
mouseaim_y = 0;
|
mouseaim_y = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(playerturn[cpid] && canmove && !blown && WDIM == 2) {
|
if(playerturn[cpid] && canmove && !blown && WDIM == 2) {
|
||||||
m->swordangle -= playerturn[cpid];
|
m->swordangle -= playerturn[cpid];
|
||||||
@ -1775,11 +1779,13 @@ void movePlayer(monster *m, int delta) {
|
|||||||
playerturn[cpid] = mgo * SCALE * delta / 200;
|
playerturn[cpid] = mgo * SCALE * delta / 200;
|
||||||
playerturny[cpid] = mturn * SCALE * delta / 200;
|
playerturny[cpid] = mturn * SCALE * delta / 200;
|
||||||
|
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
if(!lctrlclick && cpid == 0) {
|
if(!lctrlclick && cpid == 0) {
|
||||||
playerturn[cpid] += mouseaim_x;
|
playerturn[cpid] += mouseaim_x;
|
||||||
playerturny[cpid] += mouseaim_y;
|
playerturny[cpid] += mouseaim_y;
|
||||||
mouseaim_x = mouseaim_y = 0;
|
mouseaim_x = mouseaim_y = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playergo[cpid] && markOrb(itOrbDash)) playergo[cpid] *= 1.5;
|
if(playergo[cpid] && markOrb(itOrbDash)) playergo[cpid] *= 1.5;
|
||||||
@ -3295,12 +3301,18 @@ void turn(int delta) {
|
|||||||
if(racing::on && subscreens::split( [delta] () { turn(delta); })) return;
|
if(racing::on && subscreens::split( [delta] () { turn(delta); })) return;
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
ld maimx = mouseaim_x;
|
ld maimx = mouseaim_x;
|
||||||
ld maimy = mouseaim_y;
|
ld maimy = mouseaim_y;
|
||||||
|
#else
|
||||||
|
ld maimx, maimy;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(dual::split( [&id, maimx, maimy, delta] () {
|
if(dual::split( [&id, maimx, maimy, delta] () {
|
||||||
turn(delta); id++;
|
turn(delta); id++;
|
||||||
|
#if CAP_MOUSEGRAB
|
||||||
if(id==1) mouseaim_x = maimx, mouseaim_y = maimy;
|
if(id==1) mouseaim_x = maimx, mouseaim_y = maimy;
|
||||||
|
#endif
|
||||||
})) return;
|
})) return;
|
||||||
|
|
||||||
if(callhandlers(false, hooks_turn, delta)) return;
|
if(callhandlers(false, hooks_turn, delta)) return;
|
||||||
|
@ -194,6 +194,10 @@
|
|||||||
#define CAP_ORIENTATION ISMOBILE
|
#define CAP_ORIENTATION ISMOBILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CAP_MOUSEGRAB
|
||||||
|
#define CAP_MOUSEGRAB (!ISMOBILE)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_COMMANDLINE
|
#ifndef CAP_COMMANDLINE
|
||||||
#define CAP_COMMANDLINE (!ISMOBILE)
|
#define CAP_COMMANDLINE (!ISMOBILE)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user