test/relative_mode.markdown
author Sam Lantinga <slouken@libsdl.org>
Sun, 07 Jul 2019 09:10:56 -0700
changeset 12928 3c4a4b1077cd
parent 9337 7e5940a2cda6
permissions -rw-r--r--
Fixed bug 4710 - audio/alsa: avoid configuring hardware parameters with only a single period

Anthony Pesch

The previous code first configured the period size using snd_pcm_hw_par-
ams_set_period_size_near. Then, it further narrowed the configuration
space by calling snd_pcm_hw_params_set_buffer_size_near using a buffer
size of 2 times the _requested_ period size in order to try and get a
configuration with only 2 periods. If the configured period size was
larger than the requested size, the second call could inadvertently
narrow the configuration space to contain only a single period.

Rather than fixing the call to snd_pcm_hw_params_set_buffer_size_near
to use a size of 2 times the configured period size, the code has been
changed to use snd_pcm_hw_params_set_periods_min in order to more
clearly explain the intent.
     1 Relative mode testing
     2 =====================
     3 
     4 See test program at the bottom of this file.
     5 
     6 Initial tests:
     7 
     8  - When in relative mode, the mouse shouldn't be moveable outside of the window.
     9  - When the cursor is outside the window when relative mode is enabled, mouse
    10    clicks should not go to whatever app was under the cursor previously.
    11  - When alt/cmd-tabbing between a relative mode app and another app, clicks when
    12    in the relative mode app should also not go to whatever app was under the
    13    cursor previously.
    14 
    15 
    16 Code
    17 ====
    18 
    19     #include <SDL.h>
    20 
    21     int PollEvents()
    22     {
    23         SDL_Event event;
    24         while (SDL_PollEvent(&event))
    25         {
    26             switch (event.type)
    27             {
    28                 case SDL_QUIT:
    29                     return 1;
    30                 default:
    31                     break;
    32             }
    33         }
    34 
    35         return 0;
    36     }
    37 
    38     int main(int argc, char *argv[])
    39     {
    40         SDL_Window *win;
    41 
    42         SDL_Init(SDL_INIT_VIDEO);
    43 
    44         win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
    45         SDL_SetRelativeMouseMode(SDL_TRUE);
    46 
    47         while (1)
    48         {
    49             if (PollEvents())
    50                 break;
    51         }
    52 
    53         SDL_DestroyWindow(win);
    54 
    55         SDL_Quit();
    56 
    57         return 0;
    58     }