summaryrefslogtreecommitdiffstats
path: root/core/os/input_event.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /core/os/input_event.h
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
downloadredot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'core/os/input_event.h')
-rw-r--r--core/os/input_event.h136
1 files changed, 60 insertions, 76 deletions
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 1af4ef20c2..fd3f8c4cec 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -29,33 +29,30 @@
#ifndef INPUT_EVENT_H
#define INPUT_EVENT_H
-
-#include "typedefs.h"
+#include "math_2d.h"
#include "os/copymem.h"
+#include "typedefs.h"
#include "ustring.h"
-#include "math_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
-
/**
* Input Event classes. These are used in the main loop.
* The events are pretty obvious.
*/
enum {
- BUTTON_LEFT=1,
- BUTTON_RIGHT=2,
- BUTTON_MIDDLE=3,
- BUTTON_WHEEL_UP=4,
- BUTTON_WHEEL_DOWN=5,
- BUTTON_WHEEL_LEFT=6,
- BUTTON_WHEEL_RIGHT=7,
- BUTTON_MASK_LEFT=(1<<(BUTTON_LEFT-1)),
- BUTTON_MASK_RIGHT=(1<<(BUTTON_RIGHT-1)),
- BUTTON_MASK_MIDDLE=(1<<(BUTTON_MIDDLE-1)),
+ BUTTON_LEFT = 1,
+ BUTTON_RIGHT = 2,
+ BUTTON_MIDDLE = 3,
+ BUTTON_WHEEL_UP = 4,
+ BUTTON_WHEEL_DOWN = 5,
+ BUTTON_WHEEL_LEFT = 6,
+ BUTTON_WHEEL_RIGHT = 7,
+ BUTTON_MASK_LEFT = (1 << (BUTTON_LEFT - 1)),
+ BUTTON_MASK_RIGHT = (1 << (BUTTON_RIGHT - 1)),
+ BUTTON_MASK_MIDDLE = (1 << (BUTTON_MIDDLE - 1)),
};
@@ -99,20 +96,20 @@ enum {
JOY_SNES_Y = JOY_BUTTON_2,
JOY_SNES_X = JOY_BUTTON_3,
- JOY_SONY_CIRCLE=JOY_SNES_A,
- JOY_SONY_X=JOY_SNES_B,
- JOY_SONY_SQUARE=JOY_SNES_Y,
- JOY_SONY_TRIANGLE=JOY_SNES_X,
+ JOY_SONY_CIRCLE = JOY_SNES_A,
+ JOY_SONY_X = JOY_SNES_B,
+ JOY_SONY_SQUARE = JOY_SNES_Y,
+ JOY_SONY_TRIANGLE = JOY_SNES_X,
- JOY_SEGA_B=JOY_SNES_A,
- JOY_SEGA_A=JOY_SNES_B,
- JOY_SEGA_X=JOY_SNES_Y,
- JOY_SEGA_Y=JOY_SNES_X,
+ JOY_SEGA_B = JOY_SNES_A,
+ JOY_SEGA_A = JOY_SNES_B,
+ JOY_SEGA_X = JOY_SNES_Y,
+ JOY_SEGA_Y = JOY_SNES_X,
- JOY_XBOX_B=JOY_SEGA_B,
- JOY_XBOX_A=JOY_SEGA_A,
- JOY_XBOX_X=JOY_SEGA_X,
- JOY_XBOX_Y=JOY_SEGA_Y,
+ JOY_XBOX_B = JOY_SEGA_B,
+ JOY_XBOX_A = JOY_SEGA_A,
+ JOY_XBOX_X = JOY_SEGA_X,
+ JOY_XBOX_Y = JOY_SEGA_Y,
JOY_DS_A = JOY_SNES_A,
JOY_DS_B = JOY_SNES_B,
@@ -127,15 +124,15 @@ enum {
// end of history
- JOY_AXIS_0=0,
- JOY_AXIS_1=1,
- JOY_AXIS_2=2,
- JOY_AXIS_3=3,
- JOY_AXIS_4=4,
- JOY_AXIS_5=5,
- JOY_AXIS_6=6,
- JOY_AXIS_7=7,
- JOY_AXIS_MAX=8,
+ JOY_AXIS_0 = 0,
+ JOY_AXIS_1 = 1,
+ JOY_AXIS_2 = 2,
+ JOY_AXIS_3 = 3,
+ JOY_AXIS_4 = 4,
+ JOY_AXIS_5 = 5,
+ JOY_AXIS_6 = 6,
+ JOY_AXIS_7 = 7,
+ JOY_AXIS_MAX = 8,
JOY_ANALOG_0_X = JOY_AXIS_0,
JOY_ANALOG_0_Y = JOY_AXIS_1,
@@ -150,7 +147,6 @@ enum {
JOY_ANALOG_R2 = JOY_AXIS_7,
};
-
/**
* Input Modifier Status
* for keyboard/mouse events.
@@ -161,32 +157,27 @@ struct InputModifierState {
bool alt;
#ifdef APPLE_STYLE_KEYS
union {
- bool command;
- bool meta; //< windows/mac key
+ bool command;
+ bool meta; //< windows/mac key
};
bool control;
#else
union {
- bool command; //< windows/mac key
- bool control;
+ bool command; //< windows/mac key
+ bool control;
};
bool meta; //< windows/mac key
#endif
- bool operator==(const InputModifierState& rvalue) const {
+ bool operator==(const InputModifierState &rvalue) const {
- return ( (shift==rvalue.shift) && (alt==rvalue.alt) && (control==rvalue.control) && (meta==rvalue.meta));
+ return ((shift == rvalue.shift) && (alt == rvalue.alt) && (control == rvalue.control) && (meta == rvalue.meta));
}
};
-
-
-
-
-
-struct InputEventKey {
+struct InputEventKey {
InputModifierState mod;
@@ -200,66 +191,61 @@ struct InputEventKey {
bool echo; /// true if this is an echo key
};
-
-struct InputEventMouse {
+struct InputEventMouse {
InputModifierState mod;
int button_mask;
- float x,y;
- float global_x,global_y;
+ float x, y;
+ float global_x, global_y;
int pointer_index;
};
struct InputEventMouseButton : public InputEventMouse {
-
int button_index;
bool pressed; //otherwise released
bool doubleclick; //last even less than doubleclick time
-
};
struct InputEventMouseMotion : public InputEventMouse {
- float relative_x,relative_y;
- float speed_x,speed_y;
+ float relative_x, relative_y;
+ float speed_x, speed_y;
};
-struct InputEventJoypadMotion {
+struct InputEventJoypadMotion {
int axis; ///< Joypad axis
float axis_value; ///< -1 to 1
};
-struct InputEventJoypadButton {
+struct InputEventJoypadButton {
int button_index;
bool pressed;
float pressure; //0 to 1
};
-struct InputEventScreenTouch {
+struct InputEventScreenTouch {
int index;
- float x,y;
+ float x, y;
bool pressed;
};
-struct InputEventScreenDrag {
+struct InputEventScreenDrag {
int index;
- float x,y;
- float relative_x,relative_y;
- float speed_x,speed_y;
+ float x, y;
+ float relative_x, relative_y;
+ float speed_x, speed_y;
};
-struct InputEventAction {
+struct InputEventAction {
int action;
bool pressed;
};
-
-
struct InputEvent {
enum Type {
@@ -291,18 +277,16 @@ struct InputEvent {
};
bool is_pressed() const;
- bool is_action(const String& p_action) const;
- bool is_action_pressed(const String& p_action) const;
- bool is_action_released(const String& p_action) const;
+ bool is_action(const String &p_action) const;
+ bool is_action_pressed(const String &p_action) const;
+ bool is_action_released(const String &p_action) const;
bool is_echo() const;
- void set_as_action(const String& p_action, bool p_pressed);
+ void set_as_action(const String &p_action, bool p_pressed);
-
- InputEvent xform_by(const Transform2D& p_xform) const;
+ InputEvent xform_by(const Transform2D &p_xform) const;
bool operator==(const InputEvent &p_event) const;
operator String() const;
- InputEvent() { zeromem(this,sizeof(InputEvent)); }
+ InputEvent() { zeromem(this, sizeof(InputEvent)); }
};
-
#endif