Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
5f69fdbf
There was an error fetching the commit references. Please try again later.
Commit
5f69fdbf
authored
3 years ago
by
german77
Committed by
Narr the Reg
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
core/hid: Explain better what a temporary value does
parent
d8e3f2b1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/hid/emulated_controller.cpp
+20
-18
20 additions, 18 deletions
src/core/hid/emulated_controller.cpp
src/core/hid/emulated_controller.h
+8
-6
8 additions, 6 deletions
src/core/hid/emulated_controller.h
with
28 additions
and
24 deletions
src/core/hid/emulated_controller.cpp
+
20
−
18
View file @
5f69fdbf
...
@@ -88,8 +88,9 @@ void EmulatedController::ReloadFromSettings() {
...
@@ -88,8 +88,9 @@ void EmulatedController::ReloadFromSettings() {
ReloadInput
();
ReloadInput
();
}
}
void
EmulatedController
::
LoadDevices
()
{
void
EmulatedController
::
LoadDevices
()
{
const
auto
left_joycon
=
button_params
[
Settings
::
NativeButton
::
ZL
];
// TODO(german77): Use more buttons to detect the correct device
const
auto
right_joycon
=
button_params
[
Settings
::
NativeButton
::
ZR
];
const
auto
left_joycon
=
button_params
[
Settings
::
NativeButton
::
A
];
const
auto
right_joycon
=
button_params
[
Settings
::
NativeButton
::
DRight
];
// Triggers for GC controllers
// Triggers for GC controllers
trigger_params
[
LeftIndex
]
=
button_params
[
Settings
::
NativeButton
::
ZL
];
trigger_params
[
LeftIndex
]
=
button_params
[
Settings
::
NativeButton
::
ZL
];
...
@@ -142,6 +143,7 @@ void EmulatedController::LoadTASParams() {
...
@@ -142,6 +143,7 @@ void EmulatedController::LoadTASParams() {
param
=
common_params
;
param
=
common_params
;
}
}
// TODO(german77): Replace this with an input profile or something better
tas_button_params
[
Settings
::
NativeButton
::
A
].
Set
(
"button"
,
1
<<
0
);
tas_button_params
[
Settings
::
NativeButton
::
A
].
Set
(
"button"
,
1
<<
0
);
tas_button_params
[
Settings
::
NativeButton
::
B
].
Set
(
"button"
,
1
<<
1
);
tas_button_params
[
Settings
::
NativeButton
::
B
].
Set
(
"button"
,
1
<<
1
);
tas_button_params
[
Settings
::
NativeButton
::
X
].
Set
(
"button"
,
1
<<
2
);
tas_button_params
[
Settings
::
NativeButton
::
X
].
Set
(
"button"
,
1
<<
2
);
...
@@ -271,24 +273,24 @@ void EmulatedController::UnloadInput() {
...
@@ -271,24 +273,24 @@ void EmulatedController::UnloadInput() {
void
EmulatedController
::
EnableConfiguration
()
{
void
EmulatedController
::
EnableConfiguration
()
{
is_configuring
=
true
;
is_configuring
=
true
;
t
e
mp
orary
_is_connected
=
is_connected
;
tmp_is_connected
=
is_connected
;
t
e
mp
orary
_npad_type
=
npad_type
;
tmp_npad_type
=
npad_type
;
}
}
void
EmulatedController
::
DisableConfiguration
()
{
void
EmulatedController
::
DisableConfiguration
()
{
is_configuring
=
false
;
is_configuring
=
false
;
// Apply temporary npad type to the real controller
// Apply temporary npad type to the real controller
if
(
t
e
mp
orary
_npad_type
!=
npad_type
)
{
if
(
tmp_npad_type
!=
npad_type
)
{
if
(
is_connected
)
{
if
(
is_connected
)
{
Disconnect
();
Disconnect
();
}
}
SetNpadType
(
t
e
mp
orary
_npad_type
);
SetNpadType
(
tmp_npad_type
);
}
}
// Apply temporary connected status to the real controller
// Apply temporary connected status to the real controller
if
(
t
e
mp
orary
_is_connected
!=
is_connected
)
{
if
(
tmp_is_connected
!=
is_connected
)
{
if
(
t
e
mp
orary
_is_connected
)
{
if
(
tmp_is_connected
)
{
Connect
();
Connect
();
return
;
return
;
}
}
...
@@ -791,7 +793,7 @@ void EmulatedController::Connect() {
...
@@ -791,7 +793,7 @@ void EmulatedController::Connect() {
{
{
std
::
lock_guard
lock
{
mutex
};
std
::
lock_guard
lock
{
mutex
};
if
(
is_configuring
)
{
if
(
is_configuring
)
{
t
e
mp
orary
_is_connected
=
true
;
tmp_is_connected
=
true
;
TriggerOnChange
(
ControllerTriggerType
::
Connected
,
false
);
TriggerOnChange
(
ControllerTriggerType
::
Connected
,
false
);
return
;
return
;
}
}
...
@@ -808,7 +810,7 @@ void EmulatedController::Disconnect() {
...
@@ -808,7 +810,7 @@ void EmulatedController::Disconnect() {
{
{
std
::
lock_guard
lock
{
mutex
};
std
::
lock_guard
lock
{
mutex
};
if
(
is_configuring
)
{
if
(
is_configuring
)
{
t
e
mp
orary
_is_connected
=
false
;
tmp_is_connected
=
false
;
TriggerOnChange
(
ControllerTriggerType
::
Disconnected
,
false
);
TriggerOnChange
(
ControllerTriggerType
::
Disconnected
,
false
);
return
;
return
;
}
}
...
@@ -821,9 +823,9 @@ void EmulatedController::Disconnect() {
...
@@ -821,9 +823,9 @@ void EmulatedController::Disconnect() {
TriggerOnChange
(
ControllerTriggerType
::
Disconnected
,
true
);
TriggerOnChange
(
ControllerTriggerType
::
Disconnected
,
true
);
}
}
bool
EmulatedController
::
IsConnected
(
bool
temporary
)
const
{
bool
EmulatedController
::
IsConnected
(
bool
get_
temporary
_value
)
const
{
if
(
temporary
)
{
if
(
get_
temporary
_value
)
{
return
t
e
mp
orary
_is_connected
;
return
tmp_is_connected
;
}
}
return
is_connected
;
return
is_connected
;
}
}
...
@@ -838,9 +840,9 @@ NpadIdType EmulatedController::GetNpadIdType() const {
...
@@ -838,9 +840,9 @@ NpadIdType EmulatedController::GetNpadIdType() const {
return
npad_id_type
;
return
npad_id_type
;
}
}
NpadType
EmulatedController
::
GetNpadType
(
bool
temporary
)
const
{
NpadType
EmulatedController
::
GetNpadType
(
bool
get_
temporary
_value
)
const
{
if
(
temporary
)
{
if
(
get_
temporary
_value
)
{
return
t
e
mp
orary
_npad_type
;
return
tmp_npad_type
;
}
}
return
npad_type
;
return
npad_type
;
}
}
...
@@ -850,10 +852,10 @@ void EmulatedController::SetNpadType(NpadType npad_type_) {
...
@@ -850,10 +852,10 @@ void EmulatedController::SetNpadType(NpadType npad_type_) {
std
::
lock_guard
lock
{
mutex
};
std
::
lock_guard
lock
{
mutex
};
if
(
is_configuring
)
{
if
(
is_configuring
)
{
if
(
t
e
mp
orary
_npad_type
==
npad_type_
)
{
if
(
tmp_npad_type
==
npad_type_
)
{
return
;
return
;
}
}
t
e
mp
orary
_npad_type
=
npad_type_
;
tmp_npad_type
=
npad_type_
;
TriggerOnChange
(
ControllerTriggerType
::
Type
,
false
);
TriggerOnChange
(
ControllerTriggerType
::
Type
,
false
);
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/core/hid/emulated_controller.h
+
8
−
6
View file @
5f69fdbf
...
@@ -149,10 +149,10 @@ public:
...
@@ -149,10 +149,10 @@ public:
/**
/**
* Gets the NpadType for this controller
* Gets the NpadType for this controller
* @param
Returns th
e t
e
mp
orary value if true
* @param
If tru
e tmp
_npad_type will be returned
* @return NpadType set on the controller
* @return NpadType set on the controller
*/
*/
NpadType
GetNpadType
(
bool
temporary
=
false
)
const
;
NpadType
GetNpadType
(
bool
get_
temporary
_value
=
false
)
const
;
/// Sets the connected status to true
/// Sets the connected status to true
void
Connect
();
void
Connect
();
...
@@ -162,10 +162,10 @@ public:
...
@@ -162,10 +162,10 @@ public:
/**
/**
* Is the emulated connected
* Is the emulated connected
* @param
Returns th
e t
e
mp
orary value if true
* @param
If tru
e tmp
_is_connected will be returned
* @return true if the controller has the connected status
* @return true if the controller has the connected status
*/
*/
bool
IsConnected
(
bool
temporary
=
false
)
const
;
bool
IsConnected
(
bool
get_
temporary
_value
=
false
)
const
;
/// Returns true if vibration is enabled
/// Returns true if vibration is enabled
bool
IsVibrationEnabled
()
const
;
bool
IsVibrationEnabled
()
const
;
...
@@ -346,12 +346,14 @@ private:
...
@@ -346,12 +346,14 @@ private:
NpadIdType
npad_id_type
;
NpadIdType
npad_id_type
;
NpadType
npad_type
{
NpadType
::
None
};
NpadType
npad_type
{
NpadType
::
None
};
NpadType
temporary_npad_type
{
NpadType
::
None
};
bool
is_connected
{
false
};
bool
is_connected
{
false
};
bool
temporary_is_connected
{
false
};
bool
is_configuring
{
false
};
bool
is_configuring
{
false
};
f32
motion_sensitivity
{
0.01
f
};
f32
motion_sensitivity
{
0.01
f
};
// Temporary values to avoid doing changes while the controller is on configuration mode
NpadType
tmp_npad_type
{
NpadType
::
None
};
bool
tmp_is_connected
{
false
};
ButtonParams
button_params
;
ButtonParams
button_params
;
StickParams
stick_params
;
StickParams
stick_params
;
ControllerMotionParams
motion_params
;
ControllerMotionParams
motion_params
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment