Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
1176e078
Commit
1176e078
authored
Apr 23, 2020
by
Marcel Admiraal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse SDL game controller half axis and inverted axis entries.
parent
a92f5f30
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
19 deletions
+73
-19
input.cpp
core/input/input.cpp
+0
-0
input.h
core/input/input.h
+72
-7
input_builders.py
core/input/input_builders.py
+1
-12
No files found.
core/input/input.cpp
View file @
1176e078
This diff is collapsed.
Click to expand it.
core/input/input.h
View file @
1176e078
...
...
@@ -183,26 +183,91 @@ private:
TYPE_MAX
,
};
enum
SDLJoyButton
{
SDL_INVALID_BUTTON
=
-
1
,
SDL_BUTTON_A
,
SDL_BUTTON_B
,
SDL_BUTTON_X
,
SDL_BUTTON_Y
,
SDL_BUTTON_BACK
,
SDL_BUTTON_GUIDE
,
SDL_BUTTON_START
,
SDL_BUTTON_LEFTSTICK
,
SDL_BUTTON_RIGHTSTICK
,
SDL_BUTTON_LEFTSHOULDER
,
SDL_BUTTON_RIGHTSHOULDER
,
SDL_BUTTON_DPAD_UP
,
SDL_BUTTON_DPAD_DOWN
,
SDL_BUTTON_DPAD_LEFT
,
SDL_BUTTON_DPAD_RIGHT
,
SDL_BUTTON_MAX
};
enum
SDLJoyAxis
{
SDL_INVALID_AXIS
=
-
1
,
SDL_AXIS_LEFTX
,
SDL_AXIS_LEFTY
,
SDL_AXIS_RIGHTX
,
SDL_AXIS_RIGHTY
,
SDL_AXIS_TRIGGERLEFT
,
SDL_AXIS_TRIGGERRIGHT
,
SDL_AXIS_MAX
,
};
enum
JoyAxisRange
{
NEGATIVE_HALF_AXIS
=
-
1
,
FULL_AXIS
=
0
,
POSITIVE_HALF_AXIS
=
1
};
struct
JoyEvent
{
int
type
;
int
index
;
int
value
;
};
struct
JoyDeviceMapping
{
struct
SDLExtendedJoyBind
{
JoyType
inputType
;
union
{
int
button
;
struct
{
int
axis
;
JoyAxisRange
range
;
}
axis
;
struct
{
int
hat
;
HatMask
hat_mask
;
}
hat
;
}
input
;
JoyType
outputType
;
union
{
SDLJoyButton
button
;
struct
{
SDLJoyAxis
axis
;
JoyAxisRange
range
;
}
axis
;
}
output
;
};
struct
JoyDeviceMapping
{
String
uid
;
String
name
;
Map
<
int
,
JoyEvent
>
buttons
;
Map
<
int
,
JoyEvent
>
axis
;
JoyEvent
hat
[
HAT_MAX
];
Vector
<
SDLExtendedJoyBind
>
bindings
;
};
JoyEvent
hat_map_default
[
HAT_MAX
];
Vector
<
JoyDeviceMapping
>
map_db
;
JoyEvent
_find_to_event
(
String
p_to
);
JoyEvent
_get_mapped_button_event
(
const
JoyDeviceMapping
&
mapping
,
int
p_button
);
JoyEvent
_get_mapped_axis_event
(
const
JoyDeviceMapping
&
mapping
,
int
p_axis
);
void
_get_mapped_hat_events
(
const
JoyDeviceMapping
&
mapping
,
int
p_hat
,
JoyEvent
r_events
[
HAT_MAX
]);
SDLJoyButton
_get_output_button
(
String
output
);
SDLJoyAxis
_get_output_axis
(
String
output
);
void
_button_event
(
int
p_device
,
int
p_index
,
bool
p_pressed
);
void
_axis_event
(
int
p_device
,
int
p_axis
,
float
p_value
);
float
_handle_deadzone
(
int
p_device
,
int
p_axis
,
float
p_value
);
...
...
core/input/input_builders.py
View file @
1176e078
...
...
@@ -42,18 +42,7 @@ def make_default_controller_mappings(target, source, env):
src_path
,
current_platform
,
platform_mappings
[
current_platform
][
guid
]
)
)
valid_mapping
=
True
for
input_map
in
line_parts
[
2
:]:
if
"+"
in
input_map
or
"-"
in
input_map
or
"~"
in
input_map
:
g
.
write
(
"// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}
\n
"
.
format
(
src_path
,
current_platform
,
line
)
)
valid_mapping
=
False
break
if
valid_mapping
:
platform_mappings
[
current_platform
][
guid
]
=
line
platform_mappings
[
current_platform
][
guid
]
=
line
platform_variables
=
{
"Linux"
:
"#if X11_ENABLED"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment