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
d8e3f2b1
There was an error fetching the commit references. Please try again later.
Commit
d8e3f2b1
authored
3 years ago
by
german77
Committed by
Narr the Reg
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
input_common: Fix GC adapter initialization
Fix GC controller
parent
2d3a63b2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/input_common/drivers/gc_adapter.cpp
+12
-12
12 additions, 12 deletions
src/input_common/drivers/gc_adapter.cpp
with
12 additions
and
12 deletions
src/input_common/drivers/gc_adapter.cpp
+
12
−
12
View file @
d8e3f2b1
...
@@ -73,7 +73,7 @@ GCAdapter::GCAdapter(const std::string input_engine_) : InputEngine(input_engine
...
@@ -73,7 +73,7 @@ GCAdapter::GCAdapter(const std::string input_engine_) : InputEngine(input_engine
if
(
usb_adapter_handle
)
{
if
(
usb_adapter_handle
)
{
return
;
return
;
}
}
LOG_
INFO
(
Input
,
"
GC Adapter
Initialization started"
);
LOG_
DEBUG
(
Input
,
"Initialization started"
);
libusb_ctx
=
std
::
make_unique
<
LibUSBContext
>
();
libusb_ctx
=
std
::
make_unique
<
LibUSBContext
>
();
const
int
init_res
=
libusb_ctx
->
InitResult
();
const
int
init_res
=
libusb_ctx
->
InitResult
();
...
@@ -90,7 +90,7 @@ GCAdapter::~GCAdapter() {
...
@@ -90,7 +90,7 @@ GCAdapter::~GCAdapter() {
}
}
void
GCAdapter
::
AdapterInputThread
(
std
::
stop_token
stop_token
)
{
void
GCAdapter
::
AdapterInputThread
(
std
::
stop_token
stop_token
)
{
LOG_DEBUG
(
Input
,
"
GC Adapter i
nput thread started"
);
LOG_DEBUG
(
Input
,
"
I
nput thread started"
);
Common
::
SetCurrentThreadName
(
"yuzu:input:GCAdapter"
);
Common
::
SetCurrentThreadName
(
"yuzu:input:GCAdapter"
);
s32
payload_size
{};
s32
payload_size
{};
AdapterPayload
adapter_payload
{};
AdapterPayload
adapter_payload
{};
...
@@ -120,7 +120,7 @@ bool GCAdapter::IsPayloadCorrect(const AdapterPayload& adapter_payload, s32 payl
...
@@ -120,7 +120,7 @@ bool GCAdapter::IsPayloadCorrect(const AdapterPayload& adapter_payload, s32 payl
LOG_DEBUG
(
Input
,
"Error reading payload (size: {}, type: {:02x})"
,
payload_size
,
LOG_DEBUG
(
Input
,
"Error reading payload (size: {}, type: {:02x})"
,
payload_size
,
adapter_payload
[
0
]);
adapter_payload
[
0
]);
if
(
input_error_counter
++
>
20
)
{
if
(
input_error_counter
++
>
20
)
{
LOG_ERROR
(
Input
,
"
GC adapter t
imeout, Is the adapter connected?"
);
LOG_ERROR
(
Input
,
"
T
imeout, Is the adapter connected?"
);
adapter_input_thread
.
request_stop
();
adapter_input_thread
.
request_stop
();
restart_scan_thread
=
true
;
restart_scan_thread
=
true
;
}
}
...
@@ -263,13 +263,6 @@ bool GCAdapter::Setup() {
...
@@ -263,13 +263,6 @@ bool GCAdapter::Setup() {
}
}
bool
GCAdapter
::
CheckDeviceAccess
()
{
bool
GCAdapter
::
CheckDeviceAccess
()
{
// This fixes payload problems from offbrand GCAdapters
const
s32
control_transfer_error
=
libusb_control_transfer
(
usb_adapter_handle
->
get
(),
0x21
,
11
,
0x0001
,
0
,
nullptr
,
0
,
1000
);
if
(
control_transfer_error
<
0
)
{
LOG_ERROR
(
Input
,
"libusb_control_transfer failed with error= {}"
,
control_transfer_error
);
}
s32
kernel_driver_error
=
libusb_kernel_driver_active
(
usb_adapter_handle
->
get
(),
0
);
s32
kernel_driver_error
=
libusb_kernel_driver_active
(
usb_adapter_handle
->
get
(),
0
);
if
(
kernel_driver_error
==
1
)
{
if
(
kernel_driver_error
==
1
)
{
kernel_driver_error
=
libusb_detach_kernel_driver
(
usb_adapter_handle
->
get
(),
0
);
kernel_driver_error
=
libusb_detach_kernel_driver
(
usb_adapter_handle
->
get
(),
0
);
...
@@ -291,6 +284,13 @@ bool GCAdapter::CheckDeviceAccess() {
...
@@ -291,6 +284,13 @@ bool GCAdapter::CheckDeviceAccess() {
return
false
;
return
false
;
}
}
// This fixes payload problems from offbrand GCAdapters
const
s32
control_transfer_error
=
libusb_control_transfer
(
usb_adapter_handle
->
get
(),
0x21
,
11
,
0x0001
,
0
,
nullptr
,
0
,
1000
);
if
(
control_transfer_error
<
0
)
{
LOG_ERROR
(
Input
,
"libusb_control_transfer failed with error= {}"
,
control_transfer_error
);
}
return
true
;
return
true
;
}
}
...
@@ -370,9 +370,9 @@ void GCAdapter::SendVibrations() {
...
@@ -370,9 +370,9 @@ void GCAdapter::SendVibrations() {
libusb_interrupt_transfer
(
usb_adapter_handle
->
get
(),
output_endpoint
,
payload
.
data
(),
libusb_interrupt_transfer
(
usb_adapter_handle
->
get
(),
output_endpoint
,
payload
.
data
(),
static_cast
<
s32
>
(
payload
.
size
()),
&
size
,
16
);
static_cast
<
s32
>
(
payload
.
size
()),
&
size
,
16
);
if
(
err
)
{
if
(
err
)
{
LOG_DEBUG
(
Input
,
"
Adapter l
ibusb write failed: {}"
,
libusb_error_name
(
err
));
LOG_DEBUG
(
Input
,
"
L
ibusb write failed: {}"
,
libusb_error_name
(
err
));
if
(
output_error_counter
++
>
5
)
{
if
(
output_error_counter
++
>
5
)
{
LOG_ERROR
(
Input
,
"
GC adapter o
utput timeout, Rumble disabled"
);
LOG_ERROR
(
Input
,
"
O
utput timeout, Rumble disabled"
);
rumble_enabled
=
false
;
rumble_enabled
=
false
;
}
}
return
;
return
;
...
...
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