1 #ifndef _ECORE_INPUT_H 2 #define _ECORE_INPUT_H 3 4 #ifdef _WIN32 5 # include <stddef.h> 6 #else 7 # include <inttypes.h> 8 #endif 9 10 #include <Eina.h> 11 12 #include <Eo.h> 13 14 #ifdef EAPI 15 # undef EAPI 16 #endif 17 18 #ifdef _WIN32 19 # ifdef EFL_BUILD 20 # ifdef DLL_EXPORT 21 # define EAPI __declspec(dllexport) 22 # else 23 # define EAPI 24 # endif 25 # else 26 # define EAPI __declspec(dllimport) 27 # endif 28 #else 29 # ifdef __GNUC__ 30 # if __GNUC__ >= 4 31 # define EAPI __attribute__ ((visibility("default"))) 32 # else 33 # define EAPI 34 # endif 35 # else 36 # define EAPI 37 # endif 38 #endif 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /** 45 * @defgroup Ecore_Input_Group Ecore Input 46 * @ingroup Ecore_Group 47 * 48 *@{ 49 */ 50 EAPI extern int ECORE_EVENT_KEY_DOWN; 51 EAPI extern int ECORE_EVENT_KEY_UP; 52 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN; 53 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP; 54 EAPI extern int ECORE_EVENT_MOUSE_MOVE; 55 EAPI extern int ECORE_EVENT_MOUSE_WHEEL; 56 EAPI extern int ECORE_EVENT_MOUSE_IN; 57 EAPI extern int ECORE_EVENT_MOUSE_OUT; 58 EAPI extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */ 59 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */ 60 EAPI extern int ECORE_EVENT_JOYSTICK; /**< @since 1.18 */ 61 62 #define ECORE_EVENT_MODIFIER_SHIFT 0x0001 63 #define ECORE_EVENT_MODIFIER_CTRL 0x0002 64 #define ECORE_EVENT_MODIFIER_ALT 0x0004 65 #define ECORE_EVENT_MODIFIER_WIN 0x0008 66 #define ECORE_EVENT_MODIFIER_SCROLL 0x0010 67 #define ECORE_EVENT_MODIFIER_NUM 0x0020 68 #define ECORE_EVENT_MODIFIER_CAPS 0x0040 69 #define ECORE_EVENT_LOCK_SCROLL 0x0080 70 #define ECORE_EVENT_LOCK_NUM 0x0100 71 #define ECORE_EVENT_LOCK_CAPS 0x0200 72 #define ECORE_EVENT_LOCK_SHIFT 0x0300 73 #define ECORE_EVENT_MODIFIER_ALTGR 0x0400 /**< @since 1.7 */ 74 75 #ifndef _ECORE_WINDOW_PREDEF 76 typedef uintptr_t Ecore_Window; 77 #define _ECORE_WINDOW_PREDEF 1 78 #endif 79 80 typedef struct _Ecore_Event_Key Ecore_Event_Key; 81 typedef struct _Ecore_Event_Mouse_Button Ecore_Event_Mouse_Button; 82 typedef struct _Ecore_Event_Mouse_Wheel Ecore_Event_Mouse_Wheel; 83 typedef struct _Ecore_Event_Mouse_Move Ecore_Event_Mouse_Move; 84 typedef struct _Ecore_Event_Mouse_IO Ecore_Event_Mouse_IO; 85 typedef struct _Ecore_Event_Modifiers Ecore_Event_Modifiers; 86 typedef struct _Ecore_Event_Axis_Update Ecore_Event_Axis_Update; /**< @since 1.13 */ 87 typedef struct _Ecore_Axis Ecore_Axis; /**< @since 1.13 */ 88 typedef struct _Ecore_Event_Joystick Ecore_Event_Joystick; /**< @since 1.18 */ 89 90 /** 91 * @typedef Ecore_Event_Modifier 92 * An enum of modifier events. 93 */ 94 typedef enum _Ecore_Event_Modifier 95 { 96 ECORE_NONE, 97 ECORE_SHIFT, 98 ECORE_CTRL, 99 ECORE_ALT, 100 ECORE_WIN, 101 ECORE_SCROLL, 102 ECORE_CAPS, 103 ECORE_MODE, /**< @since 1.7 */ 104 ECORE_LAST 105 } Ecore_Event_Modifier; 106 107 /** 108 * @typedef Ecore_Event_Press 109 * An enum of press events. 110 */ 111 typedef enum _Ecore_Event_Press 112 { 113 ECORE_DOWN, 114 ECORE_UP, 115 ECORE_CANCEL 116 } Ecore_Event_Press; 117 118 /** 119 * @typedef Ecore_Event_IO 120 * An enum of Input/Output events. 121 */ 122 typedef enum _Ecore_Event_IO 123 { 124 ECORE_IN, 125 ECORE_OUT 126 } Ecore_Event_IO; 127 128 /** 129 * @typedef Ecore_Compose_State 130 * An enum of Compose states. 131 */ 132 typedef enum _Ecore_Compose_State 133 { 134 ECORE_COMPOSE_NONE, 135 ECORE_COMPOSE_MIDDLE, 136 ECORE_COMPOSE_DONE 137 } Ecore_Compose_State; 138 139 /** 140 * @struct _Ecore_Event_Joystic_Button 141 * Contains information about a joystick button event. 142 */ 143 typedef enum _Ecore_Event_Joystick_Button 144 { 145 ECORE_EVENT_JOYSTICK_BUTTON_NONE, 146 ECORE_EVENT_JOYSTICK_BUTTON_FACE_0, 147 ECORE_EVENT_JOYSTICK_BUTTON_FACE_1, 148 ECORE_EVENT_JOYSTICK_BUTTON_FACE_2, 149 ECORE_EVENT_JOYSTICK_BUTTON_FACE_3, 150 ECORE_EVENT_JOYSTICK_BUTTON_LEFT_SHOULDER, 151 ECORE_EVENT_JOYSTICK_BUTTON_RIGHT_SHOULDER, 152 ECORE_EVENT_JOYSTICK_BUTTON_SELECT, 153 ECORE_EVENT_JOYSTICK_BUTTON_START, 154 ECORE_EVENT_JOYSTICK_BUTTON_LEFT_ANALOG_STICK, 155 ECORE_EVENT_JOYSTICK_BUTTON_RIGHT_ANALOG_STICK, 156 ECORE_EVENT_JOYSTICK_BUTTON_META, 157 ECORE_EVENT_JOYSTICK_BUTTON_LAST 158 } Ecore_Event_Joystick_Button; /**< @since 1.18 */ 159 160 /** 161 * @struct _Ecore_Event_Joystic_Axis 162 * Contains information about a joystick axis event. 163 */ 164 typedef enum _Ecore_Event_Joystick_Axis 165 { 166 ECORE_EVENT_JOYSTICK_AXIS_NONE, 167 ECORE_EVENT_JOYSTICK_AXIS_HAT_X, 168 ECORE_EVENT_JOYSTICK_AXIS_HAT_Y, 169 ECORE_EVENT_JOYSTICK_AXIS_LEFT_SHOULDER, 170 ECORE_EVENT_JOYSTICK_AXIS_RIGHT_SHOULDER, 171 ECORE_EVENT_JOYSTICK_AXIS_LEFT_ANALOG_HOR, 172 ECORE_EVENT_JOYSTICK_AXIS_LEFT_ANALOG_VER, 173 ECORE_EVENT_JOYSTICK_AXIS_RIGHT_ANALOG_HOR, 174 ECORE_EVENT_JOYSTICK_AXIS_RIGHT_ANALOG_VER, 175 ECORE_EVENT_JOYSTICK_AXIS_LAST 176 } Ecore_Event_Joystick_Axis; /**< @since 1.18 */ 177 178 /** 179 * @struct _Ecore_Event_Joystic_Event_Type 180 * Contains information about a joystick event type. 181 */ 182 typedef enum _Ecore_Event_Joystick_Event 183 { 184 ECORE_EVENT_JOYSTICK_EVENT_TYPE_NONE, 185 ECORE_EVENT_JOYSTICK_EVENT_TYPE_CONNECTED, 186 ECORE_EVENT_JOYSTICK_EVENT_TYPE_DISCONNECTED, 187 ECORE_EVENT_JOYSTICK_EVENT_TYPE_BUTTON, 188 ECORE_EVENT_JOYSTICK_EVENT_TYPE_AXIS, 189 ECORE_EVENT_JOYSTICK_EVENT_TYPE_LAST 190 } Ecore_Event_Joystick_Event_Type; /**< @since 1.18 */ 191 192 /** 193 * @struct _Ecore_Event_Key 194 * Contains information about an Ecore keyboard event. 195 */ 196 struct _Ecore_Event_Key 197 { 198 const char *keyname; /**< The key name */ 199 const char *key; /**< The key symbol */ 200 const char *string; 201 const char *compose; /**< final string corresponding to the key symbol composed */ 202 Ecore_Window window; /**< The main window where event happened */ 203 Ecore_Window root_window; /**< The root window where event happened */ 204 Ecore_Window event_window; /**< The child window where event happened */ 205 206 unsigned int timestamp; /**< Time when the event occurred */ 207 unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ 208 209 int same_screen; /**< same screen flag */ 210 211 unsigned int keycode; /**< Key scan code numeric value @since 1.10 */ 212 213 void *data; /**< User data associated with an Ecore_Event_Key @since 1.10 */ 214 215 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 216 }; 217 218 /** 219 * @struct _Ecore_Event_Mouse_Button 220 * Contains information about an Ecore mouse button event. 221 */ 222 struct _Ecore_Event_Mouse_Button 223 { 224 Ecore_Window window; /**< The main window where event happened */ 225 Ecore_Window root_window; /**< The root window where event happened */ 226 Ecore_Window event_window; /**< The child window where event happened */ 227 228 unsigned int timestamp; /**< Time when the event occurred */ 229 unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ 230 unsigned int buttons; /**< The button that was used */ 231 unsigned int double_click; /**< Double click event */ 232 unsigned int triple_click; /**< Triple click event */ 233 int same_screen; /**< Same screen flag */ 234 235 int x; /**< x coordinate relative to window where event happened */ 236 int y; /**< y coordinate relative to window where event happened */ 237 struct { 238 int x; 239 int y; 240 } root; /**< Coordinates relative to root window */ 241 242 struct { 243 int device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ 244 double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ 245 double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ 246 double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */ 247 double x, y; /**< same as x, y, but with sub-pixel precision, if available */ 248 struct { 249 double x, y; 250 } root; /**< same as root.x, root.y, but with sub-pixel precision, if available */ 251 } multi; 252 253 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 254 }; 255 256 /** 257 * @struct _Ecore_Event_Mouse_Wheel 258 * Contains information about an Ecore mouse wheel event. 259 */ 260 struct _Ecore_Event_Mouse_Wheel 261 { 262 Ecore_Window window; /**< The main window where event happened */ 263 Ecore_Window root_window; /**< The root window where event happened */ 264 Ecore_Window event_window; /**< The child window where event happened */ 265 266 unsigned int timestamp; /**< Time when the event occurred */ 267 unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ 268 269 int same_screen; /**< Same screen flag */ 270 int direction; /**< Orientation of the wheel (horizontal/vertical) */ 271 int z; /**< Value of the wheel event (+1/-1) */ 272 273 int x; /**< x coordinate relative to window where event happened */ 274 int y; /**< y coordinate relative to window where event happened */ 275 struct { 276 int x; 277 int y; 278 } root; /**< Coordinates relative to root window */ 279 280 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 281 }; 282 283 /** 284 * @struct _Ecore_Event_Mouse_Move 285 * Contains information about an Ecore mouse move event. 286 */ 287 struct _Ecore_Event_Mouse_Move 288 { 289 Ecore_Window window; /**< The main window where event happened */ 290 Ecore_Window root_window; /**< The root window where event happened */ 291 Ecore_Window event_window; /**< The child window where event happened */ 292 293 unsigned int timestamp; /**< Time when the event occurred */ 294 unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ 295 296 int same_screen; /**< Same screen flag */ 297 298 int x; /**< x coordinate relative to window where event happened */ 299 int y; /**< y coordinate relative to window where event happened */ 300 struct { 301 int x; 302 int y; 303 } root; /**< Coordinates relative to root window */ 304 305 struct { 306 int device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ 307 double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ 308 double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ 309 double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */ 310 double x, y; /**< same as x, y root.x, root.y, but with sub-pixel precision, if available */ 311 struct { 312 double x, y; 313 } root; 314 } multi; 315 316 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 317 }; 318 319 typedef enum _Ecore_Axis_Label 320 { 321 ECORE_AXIS_LABEL_UNKNOWN, /**< Axis type is not known. Range: Unbounded. Unit: Undefined. @since 1.13 */ 322 ECORE_AXIS_LABEL_X, /**< Position along physical X axis; not window relative. Range: Unbounded. Unit: Undefined. @since 1.13 */ 323 ECORE_AXIS_LABEL_Y, /**< Position along physical Y axis; not window relative. Range: Unbounded. Unit: Undefined. @since 1.13 */ 324 ECORE_AXIS_LABEL_PRESSURE, /**< Force applied to tool tip. Range: [0.0, 1.0]. Unit: Unitless. @since 1.13 */ 325 ECORE_AXIS_LABEL_DISTANCE, /**< Relative distance along physical Z axis. Range: [0.0, 1.0]. Unit: Unitless. @since 1.13 */ 326 ECORE_AXIS_LABEL_AZIMUTH, /**< Angle of tool about the Z axis from positive X axis. Range: [-PI, PI]. Unit: Radians. @since 1.13*/ 327 ECORE_AXIS_LABEL_TILT, /**< Angle of tool about plane of sensor from positive Z axis. Range: [0.0, PI]. Unit: Radians. @since 1.13 */ 328 ECORE_AXIS_LABEL_TWIST, /**< Rotation of tool about its major axis from its "natural" position. Range: [-PI, PI] Unit: Radians. @since 1.13 */ 329 ECORE_AXIS_LABEL_TOUCH_WIDTH_MAJOR, /**< Length of contact ellipse along AZIMUTH. Range: Unbounded: Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */ 330 ECORE_AXIS_LABEL_TOUCH_WIDTH_MINOR, /**< Length of contact ellipse perpendicular to AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */ 331 ECORE_AXIS_LABEL_TOOL_WIDTH_MAJOR, /**< Length of tool ellipse along AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */ 332 ECORE_AXIS_LABEL_TOOL_WIDTH_MINOR, /**< Length of tool ellipse perpendicular to AZIMUTH. Range: Unbounded. Unit: Same as ECORE_AXIS_LABEL_{X,Y}. @since 1.13 */ 333 ECORE_AXIS_LABEL_WINDOW_X, /**< X coordinate mapped to the window. @since 1.19 */ 334 ECORE_AXIS_LABEL_WINDOW_Y, /**< Y coordinate mapped to the window. @since 1.19 */ 335 ECORE_AXIS_LABEL_NORMAL_X, /**< X normalized to the [0, 1] range. @since 1.19 */ 336 ECORE_AXIS_LABEL_NORMAL_Y, /**< Y normalized to the [0, 1] range. @since 1.19 */ 337 ECORE_AXIS_LABEL_TOUCH_PALM, /**< Size of palm contact. Range: Unbounded. Unit: undefined. May be a boolean or a distance value, depending on the underlying H/W. @since 1.20 */ 338 } Ecore_Axis_Label; /**< @since 1.13 */ 339 340 struct _Ecore_Axis 341 { 342 Ecore_Axis_Label label; 343 double value; 344 }; 345 346 struct _Ecore_Event_Axis_Update 347 { 348 Ecore_Window window; 349 Ecore_Window root_window; 350 Ecore_Window event_window; 351 352 unsigned int timestamp; 353 int device; 354 int toolid; 355 356 int naxis; 357 Ecore_Axis *axis; 358 359 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 360 }; 361 362 /** 363 * @struct _Ecore_Event_Mouse_IO 364 * Contains information about an Ecore mouse input/output event. 365 */ 366 struct _Ecore_Event_Mouse_IO 367 { 368 Ecore_Window window; /**< The main window where event happened */ 369 Ecore_Window event_window; /**< The child window where event happened */ 370 371 unsigned int timestamp; /**< Time when the event occurred */ 372 unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ 373 374 int x; /**< x coordinate relative to window where event happened */ 375 int y; /**< y coordinate relative to window where event happened */ 376 377 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 378 }; 379 380 /** 381 * @struct _Ecore_Event_Modifiers 382 * Contains information about an Ecore event modifier. 383 */ 384 struct _Ecore_Event_Modifiers 385 { 386 unsigned int size; 387 unsigned int array[ECORE_LAST]; 388 }; 389 390 /** 391 * @struct _Ecore_Event_Joystick 392 * Contains information about a joystick event. 393 */ 394 struct _Ecore_Event_Joystick 395 { 396 Ecore_Event_Joystick_Event_Type type; 397 unsigned int index; 398 unsigned int timestamp; 399 400 union 401 { 402 struct 403 { 404 Ecore_Event_Joystick_Axis index; 405 double value; /* [-1.0 .. 1.0] -1.0 == up or left, 1.0 == down or right */ 406 } axis; 407 408 struct 409 { 410 Ecore_Event_Joystick_Button index; 411 double value; /* [0.0 .. 1.0] 0.0 == fully unpressed, 1.0 == fully pressed */ 412 } button; 413 }; 414 415 Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */ 416 }; 417 418 /** 419 * Initializes the Ecore Event system. 420 */ 421 EAPI int ecore_event_init(void); 422 /** 423 * Shutdowns the Ecore Event system. 424 */ 425 EAPI int ecore_event_shutdown(void); 426 427 /** 428 * Returns the Ecore modifier event integer associated to a 429 * Ecore_Event_Modifier modifier event. 430 * 431 * @param modifier A Ecore_Event_Modifier event. 432 * @return A event_modifier integer that matches with the provided modifier 433 * event. 434 */ 435 EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier); 436 437 /** 438 * Update a Ecore_Event_Modifiers array with "key" modifier. 439 * 440 * @param key A string describing a modifier key. 441 * @param modifiers A Ecore_Event_Modifiers structure. 442 * @param inc The value to increment in the modifiers array. 443 * 444 * @return ECORE_NONE if the key does not match with an existing one, else 445 * the corresponding Ecore_Event_Modifier. 446 */ 447 EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc); 448 449 /** 450 * Handles a sequence of key symbols to make a final compose string. 451 * 452 * The final compose string seqstr_ret is allocated in this function and 453 * thus shall be freed when not needed anymore. 454 * 455 * @param seq The sequence of key symbols in a Eina_List. 456 * @param seqstr_ret The final compose string. 457 * @return The status of the composition. 458 */ 459 EAPI Ecore_Compose_State ecore_compose_get(const Eina_List *seq, char **seqstr_ret); 460 461 /** 462 * Set deadzone of joystick event for an axis. 463 * 464 * The axis type joystick event occurs without user's control if joystick is 465 * too sensitive. The deadzone prevents unnecessary events. 466 * The default value is 200. The event value for an axis is a signed integer 467 * between -32767 and +32767. 468 * 469 * @param event_axis_deadzone The joystick event axis deadzone. 470 * @since 1.19 471 */ 472 EAPI void ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone); 473 474 /** 475 * Get deadzone of joystick event for an axis. 476 * 477 * @return deadzone of joystick event for an axis. 478 * @since 1.19 479 */ 480 EAPI int ecore_input_joystick_event_axis_deadzone_get(void); 481 482 /** 483 * Get name of joystick 484 * 485 * This function returns the name string of the joysitck. If @p index 486 * does not exist, or on error, this function returns NULL. 487 * 488 * @param index The index of joystick. 489 * @return name of joystick. 490 * @since 1.20 491 */ 492 EAPI const char *ecore_input_joystick_name_get(int index); 493 #ifdef __cplusplus 494 } 495 #endif 496 497 #undef EAPI 498 #define EAPI 499 500 /** @} */ 501 #endif 502