@@ -403,6 +403,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
403403 // controller is NULL if --no-control is requested
404404 bool control = im -> controller ;
405405 bool paused = im -> screen -> paused ;
406+ bool video = im -> screen -> video ;
406407
407408 SDL_Keycode keycode = event -> keysym .sym ;
408409 uint16_t mod = event -> keysym .mod ;
@@ -462,13 +463,13 @@ sc_input_manager_process_key(struct sc_input_manager *im,
462463 }
463464 return ;
464465 case SDLK_z :
465- if (down && !repeat ) {
466+ if (video && down && !repeat ) {
466467 sc_screen_set_paused (im -> screen , !shift );
467468 }
468469 return ;
469470 case SDLK_DOWN :
470471 if (shift ) {
471- if (!repeat && down ) {
472+ if (video && !repeat && down ) {
472473 apply_orientation_transform (im ,
473474 SC_ORIENTATION_FLIP_180 );
474475 }
@@ -479,7 +480,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
479480 return ;
480481 case SDLK_UP :
481482 if (shift ) {
482- if (!repeat && down ) {
483+ if (video && !repeat && down ) {
483484 apply_orientation_transform (im ,
484485 SC_ORIENTATION_FLIP_180 );
485486 }
@@ -489,7 +490,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
489490 }
490491 return ;
491492 case SDLK_LEFT :
492- if (!repeat && down ) {
493+ if (video && !repeat && down ) {
493494 if (shift ) {
494495 apply_orientation_transform (im ,
495496 SC_ORIENTATION_FLIP_0 );
@@ -500,7 +501,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
500501 }
501502 return ;
502503 case SDLK_RIGHT :
503- if (!repeat && down ) {
504+ if (video && !repeat && down ) {
504505 if (shift ) {
505506 apply_orientation_transform (im ,
506507 SC_ORIENTATION_FLIP_0 );
@@ -533,22 +534,22 @@ sc_input_manager_process_key(struct sc_input_manager *im,
533534 }
534535 return ;
535536 case SDLK_f :
536- if (!shift && !repeat && down ) {
537+ if (video && !shift && !repeat && down ) {
537538 sc_screen_switch_fullscreen (im -> screen );
538539 }
539540 return ;
540541 case SDLK_w :
541- if (!shift && !repeat && down ) {
542+ if (video && !shift && !repeat && down ) {
542543 sc_screen_resize_to_fit (im -> screen );
543544 }
544545 return ;
545546 case SDLK_g :
546- if (!shift && !repeat && down ) {
547+ if (video && !shift && !repeat && down ) {
547548 sc_screen_resize_to_pixel_perfect (im -> screen );
548549 }
549550 return ;
550551 case SDLK_i :
551- if (!shift && !repeat && down ) {
552+ if (video && !shift && !repeat && down ) {
552553 switch_fps_counter_state (im );
553554 }
554555 return ;
@@ -625,6 +626,23 @@ sc_input_manager_process_key(struct sc_input_manager *im,
625626 im -> kp -> ops -> process_key (im -> kp , & evt , ack_to_wait );
626627}
627628
629+ static struct sc_position
630+ sc_input_manager_get_position (struct sc_input_manager * im , int32_t x ,
631+ int32_t y ) {
632+ if (im -> mp -> relative_mode ) {
633+ // No absolute position
634+ return (struct sc_position ) {
635+ .screen_size = {0 , 0 },
636+ .point = {0 , 0 },
637+ };
638+ }
639+
640+ return (struct sc_position ) {
641+ .screen_size = im -> screen -> frame_size ,
642+ .point = sc_screen_convert_window_to_frame_coords (im -> screen , x , y ),
643+ };
644+ }
645+
628646static void
629647sc_input_manager_process_mouse_motion (struct sc_input_manager * im ,
630648 const SDL_MouseMotionEvent * event ) {
@@ -634,12 +652,7 @@ sc_input_manager_process_mouse_motion(struct sc_input_manager *im,
634652 }
635653
636654 struct sc_mouse_motion_event evt = {
637- .position = {
638- .screen_size = im -> screen -> frame_size ,
639- .point = sc_screen_convert_window_to_frame_coords (im -> screen ,
640- event -> x ,
641- event -> y ),
642- },
655+ .position = sc_input_manager_get_position (im , event -> x , event -> y ),
643656 .pointer_id = im -> forward_all_clicks ? POINTER_ID_MOUSE
644657 : POINTER_ID_GENERIC_FINGER ,
645658 .xrel = event -> xrel ,
@@ -735,7 +748,8 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
735748 }
736749
737750 // double-click on black borders resize to fit the device screen
738- if (event -> button == SDL_BUTTON_LEFT && event -> clicks == 2 ) {
751+ bool video = im -> screen -> video ;
752+ if (video && event -> button == SDL_BUTTON_LEFT && event -> clicks == 2 ) {
739753 int32_t x = event -> x ;
740754 int32_t y = event -> y ;
741755 sc_screen_hidpi_scale_coords (im -> screen , & x , & y );
@@ -759,12 +773,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
759773 uint32_t sdl_buttons_state = SDL_GetMouseState (NULL , NULL );
760774
761775 struct sc_mouse_click_event evt = {
762- .position = {
763- .screen_size = im -> screen -> frame_size ,
764- .point = sc_screen_convert_window_to_frame_coords (im -> screen ,
765- event -> x ,
766- event -> y ),
767- },
776+ .position = sc_input_manager_get_position (im , event -> x , event -> y ),
768777 .action = sc_action_from_sdl_mousebutton_type (event -> type ),
769778 .button = sc_mouse_button_from_sdl (event -> button ),
770779 .pointer_id = im -> forward_all_clicks ? POINTER_ID_MOUSE
@@ -839,11 +848,7 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
839848 uint32_t buttons = SDL_GetMouseState (& mouse_x , & mouse_y );
840849
841850 struct sc_mouse_scroll_event evt = {
842- .position = {
843- .screen_size = im -> screen -> frame_size ,
844- .point = sc_screen_convert_window_to_frame_coords (im -> screen ,
845- mouse_x , mouse_y ),
846- },
851+ .position = sc_input_manager_get_position (im , mouse_x , mouse_y ),
847852#if SDL_VERSION_ATLEAST (2 , 0 , 18 )
848853 .hscroll = CLAMP (event -> preciseX , -1.0f , 1.0f ),
849854 .vscroll = CLAMP (event -> preciseY , -1.0f , 1.0f ),
0 commit comments