mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	faster reaction to mouse_movement in rug
This commit is contained in:
		
							
								
								
									
										24
									
								
								control.cpp
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								control.cpp
									
									
									
									
									
								
							| @@ -413,6 +413,18 @@ void handleKeyNormal(int sym, int uni) { | |||||||
| #endif | #endif | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | bool need_mouseh = false; | ||||||
|  |  | ||||||
|  | void fix_mouseh() { | ||||||
|  |   if(!need_mouseh) ; | ||||||
|  | #if CAP_RUG | ||||||
|  |   else if(rug::rugged) | ||||||
|  |     mouseh = rug::gethyper(mousex, mousey); | ||||||
|  |   else | ||||||
|  | #endif | ||||||
|  |     mouseh = gethyper(mousex, mousey); | ||||||
|  |   } | ||||||
|  |  | ||||||
| void handlekey(int sym, int uni) { | void handlekey(int sym, int uni) { | ||||||
|  |  | ||||||
|   if(callhandlers(false, hooks_handleKey, sym, uni)) return; |   if(callhandlers(false, hooks_handleKey, sym, uni)) return; | ||||||
| @@ -519,6 +531,7 @@ void mainloopiter() { | |||||||
|   DEBB(DF_GRAPH, (debugfile,"polling for events\n")); |   DEBB(DF_GRAPH, (debugfile,"polling for events\n")); | ||||||
|    |    | ||||||
|   achievement_pump(); |   achievement_pump(); | ||||||
|  |    | ||||||
|   while(SDL_PollEvent(&ev)) { |   while(SDL_PollEvent(&ev)) { | ||||||
|     DEBB(DF_GRAPH, (debugfile,"got event type #%d\n", ev.type)); |     DEBB(DF_GRAPH, (debugfile,"got event type #%d\n", ev.type)); | ||||||
|     int sym = 0; |     int sym = 0; | ||||||
| @@ -660,6 +673,8 @@ void mainloopiter() { | |||||||
|       bool anyctrl = keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL]; |       bool anyctrl = keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL]; | ||||||
|       bool anyshift = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT]; |       bool anyshift = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT]; | ||||||
|        |        | ||||||
|  |       if(ev.type != SDL_MOUSEMOTION) fix_mouseh(); | ||||||
|  |        | ||||||
|       if(!act) ; |       if(!act) ; | ||||||
|  |  | ||||||
|       else if(ev.button.button==SDL_BUTTON_RIGHT || leftclick)  |       else if(ev.button.button==SDL_BUTTON_RIGHT || leftclick)  | ||||||
| @@ -712,12 +727,7 @@ void mainloopiter() { | |||||||
|       mousex = ev.motion.x; |       mousex = ev.motion.x; | ||||||
|       mousey = ev.motion.y; |       mousey = ev.motion.y; | ||||||
|        |        | ||||||
| #if CAP_RUG |       need_mouseh = true; | ||||||
|       if(rug::rugged) |  | ||||||
|         mouseh = rug::gethyper(mousex, mousey); |  | ||||||
|       else |  | ||||||
| #endif |  | ||||||
|         mouseh = gethyper(mousex, mousey); |  | ||||||
|  |  | ||||||
|       if(holdmouse && getcstat == '-') sym = uni = getcstat; |       if(holdmouse && getcstat == '-') sym = uni = getcstat; | ||||||
|  |  | ||||||
| @@ -746,6 +756,8 @@ void mainloopiter() { | |||||||
|  |  | ||||||
|     handlekey(sym, uni); |     handlekey(sym, uni); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   fix_mouseh(); | ||||||
|   } |   } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue