summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/XBMC_events.h
blob: d9bf3ea8eda05d5745ae151b11d05ea6fd610952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 *      SDL - Simple DirectMedia Layer
 *  Copyright (C) 1997-2009 Sam Lantinga
 *      Sam Lantinga
 *      slouken@libsdl.org
 *
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

/* Include file for SDL event handling */

#include "Resolution.h"
#include "input/XBMC_keyboard.h"

/* Event enumerations */
typedef enum
{
  XBMC_NOEVENT = 0, /* Unused (do not remove) */
  XBMC_KEYDOWN, /* Keys pressed */
  XBMC_KEYUP, /* Keys released */
  XBMC_MOUSEMOTION, /* Mouse moved */
  XBMC_MOUSEBUTTONDOWN, /* Mouse button pressed */
  XBMC_MOUSEBUTTONUP, /* Mouse button released */
  XBMC_QUIT, /* User-requested quit */
  XBMC_VIDEORESIZE, /* User resized video mode */
  XBMC_FULLSCREEN_UPDATE, /* Triggered by an OS event when Kodi is running in fullscreen, rescale and repositioning is required  */
  XBMC_VIDEOMOVE, /* User moved the window */
  XBMC_MODECHANGE, /* Video mode must be changed */
  XBMC_TOUCH,
  XBMC_BUTTON, /* Button (remote) pressed */
  XBMC_SETFOCUS,
  XBMC_USEREVENT,

  XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */
} XBMC_EventType;

/* Keyboard event structure */
typedef struct XBMC_KeyboardEvent {
	XBMC_keysym keysym;
} XBMC_KeyboardEvent;

/* Mouse motion event structure */
typedef struct XBMC_MouseMotionEvent {
	uint16_t x, y;	/* The X/Y coordinates of the mouse */
} XBMC_MouseMotionEvent;

/* Mouse button event structure */
typedef struct XBMC_MouseButtonEvent {
	unsigned char button;	/* The mouse button index */
	uint16_t x, y;	/* The X/Y coordinates of the mouse at press time */
} XBMC_MouseButtonEvent;

/* The "window resized" event
   When you get this event, you are responsible for setting a new video
   mode with the new width and height.
 */
typedef struct XBMC_ResizeEvent {
	int w;		/* New width */
	int h;		/* New height */
} XBMC_ResizeEvent;

typedef struct XBMC_MoveEvent {
	int x;		/* New x position */
	int y;		/* New y position */
} XBMC_MoveEvent;

struct XBMC_ModeChangeEvent
{
  RESOLUTION res;
};

/* The "quit requested" event */
typedef struct XBMC_QuitEvent {
} XBMC_QuitEvent;

/* A user-defined event type */
typedef struct XBMC_UserEvent {
	int code;	/* User defined event code */
	void *data1;	/* User defined data pointer */
	void *data2;	/* User defined data pointer */
} XBMC_UserEvent;

/* Multimedia keys on keyboards / remotes are mapped to APPCOMMAND events */
typedef struct XBMC_AppCommandEvent {
  unsigned int action; /* One of ACTION_... */
} XBMC_AppCommandEvent;

/* Mouse motion event structure */
typedef struct XBMC_TouchEvent {
  int action;           /* action ID */
  float x, y;           /* The X/Y coordinates of the mouse */
  float x2, y2;         /* Additional X/Y coordinates */
  float x3, y3;         /* Additional X/Y coordinates */
  int pointers;         /* number of touch pointers */
} XBMC_TouchEvent;

typedef struct XBMC_SetFocusEvent {
	int x;		/* x position */
	int y;		/* y position */
} XBMC_SetFocusEvent;

/* Button event structure */
typedef struct XBMC_ButtonEvent
{
  uint32_t button;
  uint32_t holdtime;
} XBMC_ButtonEvent;

/* General event structure */
typedef struct XBMC_Event {
  uint8_t type;
  union
  {
    XBMC_KeyboardEvent key;
    XBMC_MouseMotionEvent motion;
    XBMC_MouseButtonEvent button;
    XBMC_ResizeEvent resize;
    XBMC_MoveEvent move;
    XBMC_ModeChangeEvent mode;
    XBMC_QuitEvent quit;
    XBMC_UserEvent user;
    XBMC_AppCommandEvent appcommand;
    XBMC_TouchEvent touch;
    XBMC_ButtonEvent keybutton;
    XBMC_SetFocusEvent focus;
  };
} XBMC_Event;