Commit graph

50 commits

Author SHA1 Message Date
Davide Baldo 1b0c7515ff Allow to specify a custom strength when calling Input.action_press(), this allows virtual axis, mainly for mobile. 2018-11-10 10:25:59 +00:00
Pedro J. Estébanez 9692549c34 Track screen drag speed
Following the universal input handling effort, this works the same for every platform, as long as the touch move event coming from it contains the relative movement.

The same tracking algorithm used to track the mouse speed is used here, but tracking separately each touch index.

Fixes #3623.
2018-10-14 18:01:06 +02:00
Rémi Verschelde 2b084352b9 Fix warnings on non-static data member initializers (C++11 feature)
We're not formally using C++11 yet so those trigger compilation warnings
(at least with GCC 5):

./main/input_default.h:122:30: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
  CursorShape default_shape = CURSOR_ARROW;
                              ^

Note: We may allow those eventually (especially for non-int static const),
but most of current occurrences were inconsistent with all other classes.

See also http://www.stroustrup.com/C++11FAQ.html#member-init
2018-09-27 10:29:48 +02:00
Rémi Verschelde 277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Rémi Verschelde 18c28c159d
Merge pull request #17196 from RandomShaper/improve-gui-touch
Implement universal translation of touch to mouse (3.1)
2018-05-02 10:47:49 +02:00
Pedro J. Estébanez de9d40a953 Implement universal translation of touch to mouse
Now generating mouse events from touch is optional (on by default) and it's performed by `InputDefault` instead of having each OS abstraction doing it. (*)

The translation algorithm waits for a touch index to be pressed and tracks it translating its events to mouse events until it is raised, while ignoring other pointers.

Furthermore, to avoid an stuck "touch mouse", since not all platforms may report touches raised when the window is unfocused, it checks if touches are still down by the time it's focused again and if so it resets the state of the emulated mouse.

*: In the case of Windows, since it already provides touch-to-mouse translation by itself, "echo" mouse events are filtered out to have it working like the rest.

On X11 a little hack has been needed to avoid a case of a spurious mouse motion event that is generated during touch interaction.

Plus: Improve/fix tracking of current mouse position.

** Summary of changes to settings: **

- `display/window/handheld/emulate_touchscreen` becomes `input/pointing_devices/emulate_touch_from_mouse`
- New setting: `input/pointing_devices/emulate_mouse_from_touch`
2018-04-30 19:03:38 +02:00
Rémi Verschelde bf7ca623a6 Fix Coverity reports of uninitialized scalar variable
Fixes most current reports on Coverity Scan of uninitialized scalar
variable (CWE-457): https://cwe.mitre.org/data/definitions/457.html

These happen most of the time (in our code) when instanciating structs
without a constructor (or with an incomplete one), and later returning
the instance. This is sometimes intended though, as some parameters are
only used in some situations and should not be double-initialized for
performance reasons (e.g. `constant` in ShaderLanguage::Token).
2018-04-19 15:20:45 +02:00
Juan Linietsky 1a3688d0cc
Merge pull request #16902 from groud/analog_action_system
Allow actions to provide an analog value
2018-04-18 07:21:29 -03:00
Gilles Roudiere ebfa731012 Allow actions to provide an analog value 2018-04-16 23:20:43 +02:00
Guilherme Felipe 4f05190fb0 Implement Input.set_default_cursor_shape to change the default shape
Closes #18043
2018-04-10 11:38:34 -03:00
Guilherme Felipe 19d2a44e5d Allow set_custom_mouse_cursor use same cursor(image) with different shapes. 2018-04-09 14:33:13 -03:00
Rémi Verschelde e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde 6322b0bbb7
Merge pull request #12814 from guilhermefelipecgs/add_hardware_custom_cursor
Custom hardware-accelerated mouse cursor
2018-01-03 08:35:59 +01:00
Rémi Verschelde b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Guilherme Silva a392dbdbe3 Add implementation for custom hardware cursor 2017-12-17 13:40:29 -02:00
AndreaCatania 4537977d6d Renamed fixed_process to physics_process 2017-09-30 16:19:07 +02:00
letheed 5ad9be4c24 Rename pos to position in user facing methods and variables
Rename user facing methods and variables as well as the corresponding
C++ methods according to the folloming changes:

* pos -> position
* rot -> rotation
* loc -> location

C++ variables are left as is.
2017-09-20 13:11:10 +02:00
Rémi Verschelde bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
TwistedTwigleg 00f6c85928 Synchronize parameter names in definition and declaration
Fixes #10244.
2017-08-16 17:22:23 +02:00
Juan Linietsky 5b3709d309 Removal of InputEvent as built-in Variant type..
this might cause bugs I haven't found yet..
2017-05-20 17:05:38 -03:00
Sergey Pusnei 8589ca3903 Rename [gs]et_pos to [gs]et_position for Controls
Control set_pos -> set_position
Control set_global_pos -> set_global_position
[gs]et_mouse_pos -> [gs]et_mouse_position
[gs]et_global_mouse_pos -> [gs]et_global_mouse_position
fixes #8005
2017-04-10 08:27:34 +02:00
Rémi Verschelde df61dc4b2b Add "Godot Engine contributors" copyright line 2017-04-08 00:11:42 +02:00
Andreas Haas c0b6756875
Input: Remove usage of platform dependent event IDs.
The ID property for InputEvents is set by `SceneTree` when sending the event down the tree.
So there's no need for the platform specific code to set this value when it will later be overriden anyway...
2017-03-26 15:59:32 +02:00
Pedro J. Estébanez f5004b78d0 Implement warped mouse panning for 2D & 3D editors
Enabled by default as in Blender, but can be disabled separately for 2D & 3D;
the core functionality is in Input so this could be reused or even exposed to scripts in the future
2017-03-22 21:36:52 +01:00
Andreas Haas a69e449782
Input: bind parse_input_event()
When using get_tree().input_event(ev), the engine will JUST send the event down the SceneTree.
However, you won't get any of the benefits of the Input singleton:
- No InputMap actions will be emitted
- The internal input state won't be modified, so methods like `Input.get_mouse_pos()` or `Input.is_joy_button_pressed` won't return the expected output after sending the event.

This is fixed by using `Input.parse_input_event(ev)` instead.
I guess we'll also have to update the docs to reflect that this is the preferred method of sending custom InputEvents.
2017-03-19 09:20:44 +01:00
Rémi Verschelde 5dbf1809c6 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
2017-03-05 16:44:50 +01:00
Andreas Haas a175ac7032
Better handling of joypad device IDs.
Now InputDefault is responsible for giving out joypad device IDs to the platform, instead of each platform handling this itself.
This makes it possible for c++ modules to add their own "custom" gamepad devices, without the risk of messing up events in case the user also has regular gamepads attached (using the OS code).
For now, it's implemented for the main desktop platforms.
Possible targets for future work: android, uwp, javascript
2017-02-26 21:01:31 +01:00
Rémi Verschelde d4eb8ec884 Merge pull request #7127 from BastiaanOlij/ios_meters
Core motion implementation for iPhone (Accelerometer/Gyro/Magnetometer support)
2017-01-15 00:08:46 +01:00
Juan Linietsky a97551902e rename Input.get_mouse_speed() to Input.get_last_mouse_speed() 2017-01-13 19:24:28 -03:00
BastiaanOlij 5e4dcb3b7f Added support for getting gravity vector from iOS 2017-01-12 16:37:27 +11:00
Juan Linietsky 547a57777b renamed joystick to joypad everywhere around source code! 2017-01-08 17:06:33 -03:00
Juan Linietsky 118eed485e ObjectTypeDB was renamed to ClassDB. Types are meant to be more generic to Variant.
All usages of "type" to refer to classes were renamed to "class"
ClassDB has been exposed to GDScript.
OBJ_TYPE() macro is now GDCLASS()
2017-01-02 23:03:46 -03:00
Rémi Verschelde c7bc44d5ad Welcome in 2017, dear changelog reader!
That year should bring the long-awaited OpenGL ES 3.0 compatible renderer
with state-of-the-art rendering techniques tuned to work as low as middle
end handheld devices - without compromising with the possibilities given
for higher end desktop games of course. Great times ahead for the Godot
community and the gamers that will play our games!
2017-01-01 22:03:33 +01:00
Andreas Haas e0fcd9331a
Add function to get readable names for joystick events
Closes #6476
2016-09-20 23:36:09 +02:00
Juan Linietsky 5b96c3a552 -Modified Input and added is_action_just_pressed() as well as is_action_just_released() 2016-09-01 18:59:46 -03:00
Jamil Halabi 370ae3512d Added gyroscope support to Godot and Android 2016-07-16 01:43:32 +08:00
Andreas Haas 45cfd199a4
Input: add get_connected_joysticks() method.
fixes #5465
2016-07-05 14:08:02 +02:00
Andreas Haas 6d09183c44 Set default duration parameter of joystick vibration to 0. 2016-06-21 17:06:41 +02:00
Rémi Verschelde a7fc04626a Add missing license headers in our source files (#5255)
Also removes a couple wrong Godot headers from third-party source files.
2016-06-18 14:46:12 +02:00
Wilhem Barbier f665200df7 Add joystick vibration support on Linux (#5043) 2016-06-15 07:25:35 +02:00
fluffrabbit 4877b714b3
Add magnetometer sensor support for Android 2016-05-27 14:36:55 -03:00
hinsbart 0022af9647 use joystick name from mapping-db if available 2016-02-29 16:48:19 +01:00
Hondres e7b6e3f20b use fallback mapping from list 2016-01-27 12:18:34 +01:00
hondres 285bcac224 can use fallback mapping on all platforms 2016-01-24 18:01:37 +01:00
hondres e7c920fdba support gamepad remapping on android 2016-01-24 05:29:09 +01:00
hondres 1ad6ca0a81 add mappings and increase max number of buttons 2016-01-22 22:56:05 +01:00
hondres c632c13c66 Add some joystick functions to input. Enables manipulation of mappings at runtime 2016-01-08 00:40:41 +01:00
hondres 87dab29f4b Use tabs instead of spaces for new gamepad code 2015-12-18 19:15:32 +01:00
hondres af633c7941 Better gamepad support 2015-12-18 06:12:53 +01:00
Juan Linietsky 82a3304458 Added ability to set custom mouse cursors. Not hardware accelerated yet. 2015-09-24 18:06:15 -03:00