move some key stuff out of sdl_poll, zoom won't be triggered even when disabled by lua now
Conflicts: src/interface.c src/main.c
This commit is contained in:
parent
23f9de6f81
commit
daeddd5519
@ -196,7 +196,7 @@ typedef struct ui_richtext ui_richtext;
|
|||||||
|
|
||||||
int SLALT;
|
int SLALT;
|
||||||
extern SDLMod sdl_mod;
|
extern SDLMod sdl_mod;
|
||||||
extern int sdl_key, sdl_rkey, sdl_wheel, sdl_caps, sdl_ascii, sdl_zoom_trig;
|
extern int sdl_key, sdl_rkey, sdl_wheel, sdl_ascii, sdl_zoom_trig;
|
||||||
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
|
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
|
||||||
extern SDL_SysWMinfo sdl_wminfo;
|
extern SDL_SysWMinfo sdl_wminfo;
|
||||||
extern Atom XA_CLIPBOARD, XA_TARGETS;
|
extern Atom XA_CLIPBOARD, XA_TARGETS;
|
||||||
@ -319,6 +319,8 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
|
|||||||
|
|
||||||
int sdl_poll(void);
|
int sdl_poll(void);
|
||||||
|
|
||||||
|
void stickmen_keys();
|
||||||
|
|
||||||
void set_cmode(int cm);
|
void set_cmode(int cm);
|
||||||
|
|
||||||
char *download_ui(pixel *vid_buf, char *uri, int *len);
|
char *download_ui(pixel *vid_buf, char *uri, int *len);
|
||||||
|
148
src/interface.c
148
src/interface.c
@ -46,7 +46,7 @@
|
|||||||
#include "save.h"
|
#include "save.h"
|
||||||
|
|
||||||
SDLMod sdl_mod;
|
SDLMod sdl_mod;
|
||||||
int sdl_key, sdl_rkey, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
|
int sdl_key, sdl_rkey, sdl_wheel, sdl_ascii, sdl_zoom_trig=0;
|
||||||
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
|
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
|
||||||
SDL_SysWMinfo sdl_wminfo;
|
SDL_SysWMinfo sdl_wminfo;
|
||||||
Atom XA_CLIPBOARD, XA_TARGETS;
|
Atom XA_CLIPBOARD, XA_TARGETS;
|
||||||
@ -2891,93 +2891,18 @@ int sdl_poll(void)
|
|||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
sdl_key=event.key.keysym.sym;
|
sdl_key=event.key.keysym.sym;
|
||||||
sdl_ascii=event.key.keysym.unicode;
|
sdl_ascii=event.key.keysym.unicode;
|
||||||
if (event.key.keysym.sym == SDLK_CAPSLOCK)
|
if (event.key.keysym.sym == SDLK_PLUS)
|
||||||
sdl_caps = 1;
|
|
||||||
if (event.key.keysym.sym=='z')
|
|
||||||
{
|
|
||||||
if (event.key.keysym.mod&KMOD_ALT)//toggle
|
|
||||||
sdl_zoom_trig = (!sdl_zoom_trig)*2;
|
|
||||||
else
|
|
||||||
sdl_zoom_trig = 1;
|
|
||||||
}
|
|
||||||
if ( event.key.keysym.sym == SDLK_PLUS)
|
|
||||||
{
|
{
|
||||||
sdl_wheel++;
|
sdl_wheel++;
|
||||||
}
|
}
|
||||||
if ( event.key.keysym.sym == SDLK_MINUS)
|
if (event.key.keysym.sym == SDLK_MINUS)
|
||||||
{
|
{
|
||||||
sdl_wheel--;
|
sdl_wheel--;
|
||||||
}
|
}
|
||||||
// 4
|
|
||||||
//1 8 2
|
|
||||||
if (event.key.keysym.sym == SDLK_RIGHT)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)|0x02; //Go right command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_LEFT)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)|0x01; //Go left command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_DOWN && ((int)(player.comm)&0x08)!=0x08)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)|0x08; //Go left command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_UP && ((int)(player.comm)&0x04)!=0x04)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)|0x04; //Jump command
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.key.keysym.sym == SDLK_d)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)|0x02; //Go right command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_a)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)|0x01; //Go left command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_s && ((int)(player2.comm)&0x08)!=0x08)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)|0x08; //Go left command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_w && ((int)(player2.comm)&0x04)!=0x04)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)|0x04; //Jump command
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
sdl_rkey=event.key.keysym.sym;
|
sdl_rkey=event.key.keysym.sym;
|
||||||
if (event.key.keysym.sym == SDLK_CAPSLOCK)
|
|
||||||
sdl_caps = 0;
|
|
||||||
if (event.key.keysym.sym == 'z' && sdl_zoom_trig==1)//if ==2 then it was toggled with alt+z, don't turn off on keyup
|
|
||||||
sdl_zoom_trig = 0;
|
|
||||||
if (event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_LEFT)
|
|
||||||
{
|
|
||||||
player.pcomm = player.comm; //Saving last movement
|
|
||||||
player.comm = (int)(player.comm)&12; //Stop command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_UP)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)&11;
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_DOWN)
|
|
||||||
{
|
|
||||||
player.comm = (int)(player.comm)&7;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a)
|
|
||||||
{
|
|
||||||
player2.pcomm = player2.comm; //Saving last movement
|
|
||||||
player2.comm = (int)(player2.comm)&12; //Stop command
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_w)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)&11;
|
|
||||||
}
|
|
||||||
if (event.key.keysym.sym == SDLK_s)
|
|
||||||
{
|
|
||||||
player2.comm = (int)(player2.comm)&7;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
if (event.button.button == SDL_BUTTON_WHEELUP)
|
if (event.button.button == SDL_BUTTON_WHEELUP)
|
||||||
@ -3037,6 +2962,73 @@ int sdl_poll(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stickmen_keys()
|
||||||
|
{
|
||||||
|
// 4
|
||||||
|
//1 8 2
|
||||||
|
if (sdl_key == SDLK_RIGHT)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)|0x02; //Go right command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_LEFT)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)|0x01; //Go left command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_DOWN && ((int)(player.comm)&0x08)!=0x08)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)|0x08; //Use element command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_UP && ((int)(player.comm)&0x04)!=0x04)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)|0x04; //Jump command
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdl_key == SDLK_d)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)|0x02; //Go right command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_a)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)|0x01; //Go left command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_s && ((int)(player2.comm)&0x08)!=0x08)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)|0x08; //Use element command
|
||||||
|
}
|
||||||
|
if (sdl_key == SDLK_w && ((int)(player2.comm)&0x04)!=0x04)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)|0x04; //Jump command
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdl_rkey == SDLK_RIGHT || sdl_rkey == SDLK_LEFT)
|
||||||
|
{
|
||||||
|
player.pcomm = player.comm; //Saving last movement
|
||||||
|
player.comm = (int)(player.comm)&12; //Stop command
|
||||||
|
}
|
||||||
|
if (sdl_rkey == SDLK_UP)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)&11;
|
||||||
|
}
|
||||||
|
if (sdl_rkey == SDLK_DOWN)
|
||||||
|
{
|
||||||
|
player.comm = (int)(player.comm)&7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdl_rkey == SDLK_d || sdl_rkey == SDLK_a)
|
||||||
|
{
|
||||||
|
player2.pcomm = player2.comm; //Saving last movement
|
||||||
|
player2.comm = (int)(player2.comm)&12; //Stop command
|
||||||
|
}
|
||||||
|
if (sdl_rkey == SDLK_w)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)&11;
|
||||||
|
}
|
||||||
|
if (sdl_rkey == SDLK_s)
|
||||||
|
{
|
||||||
|
player2.comm = (int)(player2.comm)&7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void set_cmode(int cm) // sets to given view mode
|
void set_cmode(int cm) // sets to given view mode
|
||||||
{
|
{
|
||||||
int cmode = cm;
|
int cmode = cm;
|
||||||
|
19
src/main.c
19
src/main.c
@ -1287,6 +1287,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
|
if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
|
||||||
{
|
{
|
||||||
|
stickmen_keys();
|
||||||
if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
|
if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
|
||||||
{
|
{
|
||||||
if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
|
if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
|
||||||
@ -1713,7 +1714,9 @@ int main(int argc, char *argv[])
|
|||||||
if (it > 50)
|
if (it > 50)
|
||||||
it = 50;
|
it = 50;
|
||||||
}*/
|
}*/
|
||||||
if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo
|
if (sdl_key=='z') // Undo
|
||||||
|
{
|
||||||
|
if (sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
||||||
{
|
{
|
||||||
int cbx, cby, cbi;
|
int cbx, cby, cbi;
|
||||||
|
|
||||||
@ -1738,6 +1741,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
force_stacking_check = 1;//check for excessive stacking of particles next time update_particles is run
|
force_stacking_check = 1;//check for excessive stacking of particles next time update_particles is run
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sdl_mod & KMOD_ALT)//toggle
|
||||||
|
sdl_zoom_trig = (!sdl_zoom_trig)*2;
|
||||||
|
else
|
||||||
|
sdl_zoom_trig = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
if (sdl_rkey == 'z' && sdl_zoom_trig==1)//if ==2 then it was toggled with alt+z, don't turn off on keyup
|
||||||
|
sdl_zoom_trig = 0;
|
||||||
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
|
>>>>>>> 230ab97... move some key stuff out of sdl_poll, zoom won't be triggered even when disabled by lua now
|
||||||
}
|
}
|
||||||
#ifdef INTERNAL
|
#ifdef INTERNAL
|
||||||
int counterthing;
|
int counterthing;
|
||||||
|
Loading…
Reference in New Issue
Block a user