src/video/wayland/SDL_waylandevents.c
changeset 13701 3cc182fa6110
parent 13696 ea20a7434b98
child 13805 4709c1dfeabb
equal deleted inserted replaced
13700:97f6cba13e49 13701:3cc182fa6110
    40 #include "pointer-constraints-unstable-v1-client-protocol.h"
    40 #include "pointer-constraints-unstable-v1-client-protocol.h"
    41 #include "relative-pointer-unstable-v1-client-protocol.h"
    41 #include "relative-pointer-unstable-v1-client-protocol.h"
    42 #include "xdg-shell-client-protocol.h"
    42 #include "xdg-shell-client-protocol.h"
    43 #include "xdg-shell-unstable-v6-client-protocol.h"
    43 #include "xdg-shell-unstable-v6-client-protocol.h"
    44 
    44 
       
    45 #ifdef SDL_INPUT_LINUXEV
    45 #include <linux/input.h>
    46 #include <linux/input.h>
       
    47 #else
       
    48 #define BTN_LEFT    (0x110)
       
    49 #define BTN_RIGHT   (0x111)
       
    50 #define BTN_MIDDLE  (0x112)
       
    51 #define BTN_SIDE    (0x113)
       
    52 #define BTN_EXTRA   (0x114)
       
    53 #endif
    46 #include <sys/select.h>
    54 #include <sys/select.h>
    47 #include <sys/mman.h>
    55 #include <sys/mman.h>
    48 #include <poll.h>
    56 #include <poll.h>
    49 #include <unistd.h>
    57 #include <unistd.h>
    50 #include <xkbcommon/xkbcommon.h>
    58 #include <xkbcommon/xkbcommon.h>
   434 pointer_handle_axis(void *data, struct wl_pointer *pointer,
   442 pointer_handle_axis(void *data, struct wl_pointer *pointer,
   435                     uint32_t time, uint32_t axis, wl_fixed_t value)
   443                     uint32_t time, uint32_t axis, wl_fixed_t value)
   436 {
   444 {
   437     struct SDL_WaylandInput *input = data;
   445     struct SDL_WaylandInput *input = data;
   438 
   446 
   439     if(wl_seat_interface.version >= 5)
   447     if(wl_seat_get_version(input->seat) >= 5)
   440         pointer_handle_axis_common(input, SDL_FALSE, axis, value);
   448         pointer_handle_axis_common(input, SDL_FALSE, axis, value);
   441     else
   449     else
   442         pointer_handle_axis_common_v1(input, time, axis, value);
   450         pointer_handle_axis_common_v1(input, time, axis, value);
   443 }
   451 }
   444 
   452 
   995     data_device_handle_drop,
  1003     data_device_handle_drop,
   996     data_device_handle_selection
  1004     data_device_handle_selection
   997 };
  1005 };
   998 
  1006 
   999 void
  1007 void
  1000 Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
  1008 Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
  1001 {
  1009 {
  1002     struct SDL_WaylandInput *input;
  1010     struct SDL_WaylandInput *input;
  1003     SDL_WaylandDataDevice *data_device = NULL;
  1011     SDL_WaylandDataDevice *data_device = NULL;
  1004 
  1012 
  1005     input = SDL_calloc(1, sizeof *input);
  1013     input = SDL_calloc(1, sizeof *input);
  1006     if (input == NULL)
  1014     if (input == NULL)
  1007         return;
  1015         return;
  1008 
  1016 
  1009     input->display = d;
  1017     input->display = d;
  1010     if (wl_seat_interface.version >= 5)
  1018     input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(5, version));
  1011         input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 5);
       
  1012     else
       
  1013         input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
       
  1014     input->sx_w = wl_fixed_from_int(0);
  1019     input->sx_w = wl_fixed_from_int(0);
  1015     input->sy_w = wl_fixed_from_int(0);
  1020     input->sy_w = wl_fixed_from_int(0);
  1016     d->input = input;
  1021     d->input = input;
  1017     
  1022     
  1018     if (d->data_device_manager != NULL) {
  1023     if (d->data_device_manager != NULL) {