mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-04 14:30:35 +00:00
reworked some modifier keys
This commit is contained in:
parent
5e0aac5e92
commit
009b05c919
110
control.cpp
110
control.cpp
@ -14,8 +14,11 @@ EX bool outoffocus = false;
|
|||||||
EX int mousex, mousey;
|
EX int mousex, mousey;
|
||||||
EX hyperpoint mouseh, mouseoh;
|
EX hyperpoint mouseh, mouseoh;
|
||||||
|
|
||||||
EX bool leftclick, rightclick, targetclick, hiliteclick, anyshiftclick, wheelclick;
|
EX bool pandora_leftclick, pandora_rightclick;
|
||||||
EX bool forcetarget, lshiftclick, lctrlclick, numlock_on;
|
|
||||||
|
EX bool lshiftclick, rshiftclick, lctrlclick, rctrlclick, anyshiftclick, anyctrlclick, wheelclick;
|
||||||
|
|
||||||
|
EX bool targetclick, hiliteclick, forcetarget, numlock_on;
|
||||||
EX bool gtouched;
|
EX bool gtouched;
|
||||||
|
|
||||||
EX bool holdmouse;
|
EX bool holdmouse;
|
||||||
@ -463,8 +466,8 @@ EX void handleKeyNormal(int sym, int uni) {
|
|||||||
if(DEFAULTCONTROL) {
|
if(DEFAULTCONTROL) {
|
||||||
if(sym == SDLK_RIGHT) movepckeydir(0);
|
if(sym == SDLK_RIGHT) movepckeydir(0);
|
||||||
if(sym == SDLK_LEFT) movepckeydir(4);
|
if(sym == SDLK_LEFT) movepckeydir(4);
|
||||||
if(sym == SDLK_DOWN) movepckeydir(2 + (leftclick?1:0) - (rightclick?1:0));
|
if(sym == SDLK_DOWN) movepckeydir(2 + (pandora_leftclick?1:0) - (pandora_rightclick?1:0));
|
||||||
if(sym == SDLK_UP) movepckeydir(6 - (leftclick?1:0) + (rightclick?1:0));
|
if(sym == SDLK_UP) movepckeydir(6 - (pandora_leftclick?1:0) + (pandora_rightclick?1:0));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -691,13 +694,20 @@ EX void mainloopiter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Uint8 *keystate = SDL_GetKeyState(NULL);
|
Uint8 *keystate = SDL_GetKeyState(NULL);
|
||||||
rightclick = keystate[SDLK_RCTRL];
|
|
||||||
leftclick = keystate[SDLK_RSHIFT];
|
pandora_rightclick = keystate[SDLK_RCTRL];
|
||||||
lctrlclick = keystate[SDLK_LCTRL];
|
pandora_leftclick = keystate[SDLK_RSHIFT];
|
||||||
|
|
||||||
lshiftclick = keystate[SDLK_LSHIFT];
|
lshiftclick = keystate[SDLK_LSHIFT];
|
||||||
forcetarget = (keystate[SDLK_RSHIFT] | keystate[SDLK_LSHIFT]);
|
rshiftclick = keystate[SDLK_RSHIFT];
|
||||||
|
anyshiftclick = lshiftclick | rshiftclick;
|
||||||
|
|
||||||
|
lctrlclick = keystate[SDLK_LCTRL];
|
||||||
|
rctrlclick = keystate[SDLK_RCTRL];
|
||||||
|
anyctrlclick = lctrlclick | rctrlclick;
|
||||||
|
|
||||||
|
forcetarget = anyshiftclick;
|
||||||
hiliteclick = keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
hiliteclick = keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
||||||
anyshiftclick = keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT];
|
|
||||||
wheelclick = false;
|
wheelclick = false;
|
||||||
|
|
||||||
getcshift = 1;
|
getcshift = 1;
|
||||||
@ -708,11 +718,14 @@ EX void mainloopiter() {
|
|||||||
didsomething = false;
|
didsomething = false;
|
||||||
|
|
||||||
if(vid.shifttarget&1) {
|
if(vid.shifttarget&1) {
|
||||||
leftclick = false;
|
#if ISPANDORA
|
||||||
|
targetclick = pandora_leftclick | pandora_rightclick;
|
||||||
|
pandora_leftclick = pandora_rightclick = 0;
|
||||||
|
#else
|
||||||
targetclick = keystate[SDLK_RSHIFT] | keystate[SDLK_LSHIFT];
|
targetclick = keystate[SDLK_RSHIFT] | keystate[SDLK_LSHIFT];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
leftclick = keystate[SDLK_RSHIFT];
|
|
||||||
targetclick = true;
|
targetclick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,8 +772,6 @@ EX void mainloopiter() {
|
|||||||
|
|
||||||
EX void handle_event(SDL_Event& ev) {
|
EX void handle_event(SDL_Event& ev) {
|
||||||
bool normal = cmode & sm::NORMAL;
|
bool normal = cmode & sm::NORMAL;
|
||||||
Uint8 *keystate = SDL_GetKeyState(NULL);
|
|
||||||
|
|
||||||
DEBB(DF_GRAPH, ("got event type #%d\n", ev.type));
|
DEBB(DF_GRAPH, ("got event type #%d\n", ev.type));
|
||||||
int sym = 0;
|
int sym = 0;
|
||||||
int uni = 0;
|
int uni = 0;
|
||||||
@ -855,9 +866,6 @@ EX void handle_event(SDL_Event& ev) {
|
|||||||
|
|
||||||
bool rollchange = (cmode & sm::OVERVIEW) && getcstat >= 2000 && cheater;
|
bool rollchange = (cmode & sm::OVERVIEW) && getcstat >= 2000 && cheater;
|
||||||
|
|
||||||
bool anyctrl = keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL];
|
|
||||||
bool anyshift = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT];
|
|
||||||
|
|
||||||
if(ev.type == SDL_MOUSEBUTTONDOWN || ev.type == SDL_MOUSEBUTTONUP) {
|
if(ev.type == SDL_MOUSEBUTTONDOWN || ev.type == SDL_MOUSEBUTTONUP) {
|
||||||
mousepressed = ev.type == SDL_MOUSEBUTTONDOWN;
|
mousepressed = ev.type == SDL_MOUSEBUTTONDOWN;
|
||||||
if(mousepressed) flashMessages();
|
if(mousepressed) flashMessages();
|
||||||
@ -880,49 +888,47 @@ EX void handle_event(SDL_Event& ev) {
|
|||||||
if(was_holdmouse && ev.type == SDL_MOUSEBUTTONUP)
|
if(was_holdmouse && ev.type == SDL_MOUSEBUTTONUP)
|
||||||
sym = uni = PSEUDOKEY_RELEASE;
|
sym = uni = PSEUDOKEY_RELEASE;
|
||||||
|
|
||||||
|
/* simulate RMB and MMB for Mac users etc. */
|
||||||
|
if(ev.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
if(ISPANDORA ? pandora_rightclick : lctrlclick)
|
||||||
|
ev.button.button = SDL_BUTTON_MIDDLE;
|
||||||
|
else if(ISPANDORA ? pandora_leftclick : lshiftclick)
|
||||||
|
ev.button.button = SDL_BUTTON_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
if(!act) ;
|
if(!act) ;
|
||||||
|
|
||||||
else if(ev.button.button==SDL_BUTTON_RIGHT || leftclick)
|
else if(ev.button.button==SDL_BUTTON_RIGHT)
|
||||||
sym = SDLK_F1;
|
sym = SDLK_F1;
|
||||||
else if(ev.button.button==SDL_BUTTON_MIDDLE || rightclick) {
|
else if(ev.button.button==SDL_BUTTON_MIDDLE)
|
||||||
sym = 1, didsomething = true;
|
sym = 1, didsomething = true;
|
||||||
if(anyshift)
|
|
||||||
pconf.xposition = pconf.yposition = 0;
|
|
||||||
}
|
|
||||||
else if(ev.button.button == SDL_BUTTON_LEFT) {
|
else if(ev.button.button == SDL_BUTTON_LEFT) {
|
||||||
sym = getcstat, uni = getcstat, shiftmul = getcshift;
|
sym = getcstat, uni = getcstat, shiftmul = getcshift;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(ev.button.button==SDL_BUTTON_WHEELDOWN) {
|
else if(ev.button.button==SDL_BUTTON_WHEELDOWN || ev.button.button == SDL_BUTTON_WHEELUP) {
|
||||||
if(anyctrl && anyshift && !rug::rugged && GDIM == 2) {
|
ld dir = ev.button.button == SDL_BUTTON_WHEELUP ? 0.25 : -0.25;
|
||||||
mapeditor::scaleall(1/1.2);
|
if(lshiftclick && rshiftclick && !rug::rugged && GDIM == 2) {
|
||||||
pconf.alpha /= 1.2;
|
mapeditor::scaleall(pow(2, dir), lctrlclick);
|
||||||
|
pconf.alpha *= pow(2, dir);
|
||||||
|
}
|
||||||
|
else if(lshiftclick && !rug::rugged && GDIM == 2)
|
||||||
|
mapeditor::scaleall(pow(2, dir), lctrlclick);
|
||||||
|
else if(rshiftclick && !rug::rugged && GDIM == 2)
|
||||||
|
pconf.alpha -= dir;
|
||||||
|
else if(lctrlclick) {
|
||||||
|
if(dir>0) {
|
||||||
|
pconf.xposition += (.0 + mousex - current_display->xcenter) / vpconf.scale / current_display->scrsize;
|
||||||
|
pconf.yposition += (.0 + mousey - current_display->ycenter) / vpconf.scale / current_display->scrsize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pconf.xposition = pconf.yposition = 0;
|
||||||
}
|
}
|
||||||
else if(anyctrl && !rug::rugged && GDIM == 2)
|
|
||||||
mapeditor::scaleall(pow(2, -.25));
|
|
||||||
else if(anyshift && !rug::rugged && GDIM == 2)
|
|
||||||
pconf.alpha -= 0.25;
|
|
||||||
else if(rollchange) {
|
else if(rollchange) {
|
||||||
sym = getcstat, uni = getcstat, shiftmul = getcshift, wheelclick = true;
|
sym = getcstat, uni = getcstat, shiftmul = -dir*4*getcshift, wheelclick = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sym = uni = PSEUDOKEY_WHEELDOWN;
|
sym = uni = dir > 0 ? PSEUDOKEY_WHEELUP : PSEUDOKEY_WHEELDOWN;
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ev.button.button==SDL_BUTTON_WHEELUP) {
|
|
||||||
if(anyctrl && anyshift && !rug::rugged && GDIM == 2) {
|
|
||||||
mapeditor::scaleall(1.2);
|
|
||||||
pconf.alpha *= 1.2;
|
|
||||||
}
|
|
||||||
else if(anyctrl && !rug::rugged && GDIM == 2)
|
|
||||||
mapeditor::scaleall(pow(2, .25));
|
|
||||||
else if(anyshift && !rug::rugged && GDIM == 2)
|
|
||||||
pconf.alpha += 0.25;
|
|
||||||
else if(rollchange) {
|
|
||||||
sym = getcstat, uni = getcstat, shiftmul = -getcshift, wheelclick = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sym = uni = PSEUDOKEY_WHEELUP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -948,9 +954,9 @@ EX void handle_event(SDL_Event& ev) {
|
|||||||
|
|
||||||
if(holdmouse && getcstat == '-') sym = uni = getcstat, fix_mouseh();
|
if(holdmouse && getcstat == '-') sym = uni = getcstat, fix_mouseh();
|
||||||
|
|
||||||
if((rightclick || (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2()) {
|
if(((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2()) {
|
||||||
fix_mouseh();
|
fix_mouseh();
|
||||||
if(anyctrl) {
|
if(lctrlclick) {
|
||||||
pconf.xposition += (mousex - lmousex) * 1. / current_display->scrsize,
|
pconf.xposition += (mousex - lmousex) * 1. / current_display->scrsize,
|
||||||
pconf.yposition += (mousey - lmousey) * 1. / current_display->scrsize;
|
pconf.yposition += (mousey - lmousey) * 1. / current_display->scrsize;
|
||||||
}
|
}
|
||||||
@ -981,17 +987,17 @@ EX void handle_event(SDL_Event& ev) {
|
|||||||
else quitmainloop = true;
|
else quitmainloop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sym == SDLK_F4 && anyshift) {
|
if(sym == SDLK_F4 && anyshiftclick) {
|
||||||
nomap = !nomap;
|
nomap = !nomap;
|
||||||
sym = 0;
|
sym = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sym == SDLK_F2 && anyshift) {
|
if(sym == SDLK_F2 && anyshiftclick) {
|
||||||
nohud = !nohud;
|
nohud = !nohud;
|
||||||
sym = 0;
|
sym = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sym == SDLK_F3 && anyshift) {
|
if(sym == SDLK_F3 && anyshiftclick) {
|
||||||
nofps = !nofps;
|
nofps = !nofps;
|
||||||
sym = 0;
|
sym = 0;
|
||||||
}
|
}
|
||||||
|
@ -262,16 +262,9 @@ EX namespace mapeditor {
|
|||||||
EX editwhat ew, ewsearch;
|
EX editwhat ew, ewsearch;
|
||||||
EX bool autochoose = ISMOBILE;
|
EX bool autochoose = ISMOBILE;
|
||||||
|
|
||||||
EX void scaleall(ld z) {
|
EX void scaleall(ld z, bool keep_mouse) {
|
||||||
|
|
||||||
// (mx,my) = (xcb,ycb) + ss * (xpos,ypos) + (mrx,mry) * scale
|
|
||||||
|
|
||||||
// (mrx,mry) * (scale-scale') =
|
|
||||||
// ss * ((xpos',ypos')-(xpos,ypos))
|
|
||||||
|
|
||||||
// mx = xb + ssiz*xpos + mrx * scale
|
|
||||||
// mx = xb + ssiz*xpos' + mrx * scale'
|
|
||||||
|
|
||||||
|
if(keep_mouse) {
|
||||||
ld mrx = (.0 + mousex - current_display->xcenter) / vpconf.scale;
|
ld mrx = (.0 + mousex - current_display->xcenter) / vpconf.scale;
|
||||||
ld mry = (.0 + mousey - current_display->ycenter) / vpconf.scale;
|
ld mry = (.0 + mousey - current_display->ycenter) / vpconf.scale;
|
||||||
|
|
||||||
@ -279,6 +272,7 @@ EX namespace mapeditor {
|
|||||||
vpconf.xposition += (vpconf.scale - vpconf.scale*z) * mrx / current_display->scrsize;
|
vpconf.xposition += (vpconf.scale - vpconf.scale*z) * mrx / current_display->scrsize;
|
||||||
vpconf.yposition += (vpconf.scale - vpconf.scale*z) * mry / current_display->scrsize;
|
vpconf.yposition += (vpconf.scale - vpconf.scale*z) * mry / current_display->scrsize;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vpconf.scale *= z;
|
vpconf.scale *= z;
|
||||||
// printf("scale = " LDF "\n", vpconf.scale);
|
// printf("scale = " LDF "\n", vpconf.scale);
|
||||||
|
Loading…
Reference in New Issue
Block a user