SDL  2.0
SDL_androidmouse.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #include "../../SDL_internal.h"
23 
24 #if SDL_VIDEO_DRIVER_ANDROID
25 
26 #include "SDL_androidmouse.h"
27 
28 #include "SDL_events.h"
29 #include "../../events/SDL_mouse_c.h"
30 
31 #include "../../core/android/SDL_android.h"
32 
33 #define ACTION_DOWN 0
34 #define ACTION_UP 1
35 #define ACTION_HOVER_MOVE 7
36 #define ACTION_SCROLL 8
37 #define BUTTON_PRIMARY 1
38 #define BUTTON_SECONDARY 2
39 #define BUTTON_TERTIARY 4
40 
41 void Android_OnMouse( int androidButton, int action, float x, float y) {
42  static Uint8 SDLButton;
43 
44  if (!Android_Window) {
45  return;
46  }
47 
48  switch(action) {
49  case ACTION_DOWN:
50  // Determine which button originated the event, and store it for ACTION_UP
51  SDLButton = SDL_BUTTON_LEFT;
52  if (androidButton == BUTTON_SECONDARY) {
53  SDLButton = SDL_BUTTON_RIGHT;
54  } else if (androidButton == BUTTON_TERTIARY) {
55  SDLButton = SDL_BUTTON_MIDDLE;
56  }
59  break;
60 
61  case ACTION_UP:
62  // Android won't give us the button that originated the ACTION_DOWN event, so we'll
63  // assume it's the one we stored
66  break;
67 
68  case ACTION_HOVER_MOVE:
70  break;
71 
72  case ACTION_SCROLL:
74  break;
75 
76  default:
77  break;
78  }
79 }
80 
81 #endif /* SDL_VIDEO_DRIVER_ANDROID */
82 
83 /* vi: set ts=4 sw=4 expandtab: */
84 
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:282
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Definition: SDL_mouse.c:188
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:280
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_Window * Android_Window
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:281
void Android_OnMouse(int button, int action, float x, float y)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
Definition: SDL_mouse.c:406
#define SDL_PRESSED
Definition: SDL_events.h:50
#define SDL_RELEASED
Definition: SDL_events.h:49
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
Definition: SDL_mouse.c:326