-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mainlining #2
Comments
To be fair I would like to ^^ But I need to learn how exactly the kernel development work and there is also the current issue that usb-hid driver take the upper hand as the GameCube adapter report itself as a USB hid device. I will close this issue if it got into the kernel :) |
Patch send for review :3 |
I haven’t narrowed it down, but I got it working after many failed attempts using the following udev rules:
Those first rules were my attempt to prevent the built-in drivers to bind the USB device by not authorizing them. The last rule then authorizes the device and binds your driver to it. System log:
Works fine in Firefox on https://hardwaretester.com/gamepad for example :) Edit: Rumble didn’t work in Chromium nor with |
Hi @max-m ,
Concerning Chromium support, if you tell me it work with firefox, it means that it seems to that chrome does not handle it correctly, and modifying chrome is out of scope of this project
Works correctly might add it with an automatic install script
Do you test fftest on the correct device ? It should not be jsX but eventX corresponding to the controller in question and also make sure to plug the grey plug of the gamecube controller as it provide power for rumble functionnalities. |
Hi :)
Oh, no. I meant by changing the way the controllers are reported to the system. I already tried the easy and simple things: giving each controller a unique display name (this did not change Chrome's behavior, Firefox uses those names), setting the parent device (this made Chrome pick the manufacturer and product name of the parent device, Nintendo WUP-028, as the display name), probably some other simple tweaks I tried and forgot.
I used the corresponding |
Do you obtain the same output as me with fftest ?
|
Hmm, I actually missed that it reports
The reported ff effect types and periodic effects differ from your results. :s It does work with my DualShock 3 though:
By the way, the adapter also sets a bit in the controller status flags when the external power is plugged in, so you might be able to dynamically report FF support per controller and update it when this state changes.
My current diff: diff --git a/dkms.conf b/dkms.conf
new file mode 100644
index 0000000..291758a
--- /dev/null
+++ b/dkms.conf
@@ -0,0 +1,10 @@
+BUILT_MODULE_NAME[0]="gamecube-adapter"
+DEST_MODULE_LOCATION[0]="/extra"
+
+PACKAGE_NAME="$BUILT_MODULE_NAME"
+PACKAGE_VERSION="1.0.2"
+
+MAKE[0]="make KERNEL_SOURCE_DIR=$kernel_source_dir"
+CLEAN[0]="make KERNEL_SOURCE_DIR=$kernel_source_dir clean"
+
+AUTOINSTALL="yes"
diff --git a/usb-gamecube-adapter.c b/gamecube-adapter.c
similarity index 92%
rename from usb-gamecube-adapter.c
rename to gamecube-adapter.c
index aef5029..e1d4a54 100644
--- a/usb-gamecube-adapter.c
+++ b/gamecube-adapter.c
@@ -4,7 +4,7 @@
#include <linux/input.h>
#include <linux/usb/input.h>
-#include "usb-gamecube-adapter.h"
+#include "gamecube-adapter.h"
/* Callers must hold gdata->odata_lock spinlock */
static int gc_queue_rumble(struct gc_data *gdata)
@@ -116,15 +116,22 @@ static void gcc_input(struct gcc_data *gccdata, const u8 *keys)
input_report_key(gccdata->input, BTN_DPAD_UP, !!(keys[1] & BIT(7)));
input_report_key(gccdata->input, BTN_START, !!(keys[2] & BIT(0)));
- input_report_key(gccdata->input, BTN_TR2, !!(keys[2] & BIT(1)));
- input_report_key(gccdata->input, BTN_TR, !!(keys[2] & BIT(2)));
- input_report_key(gccdata->input, BTN_TL, !!(keys[2] & BIT(3)));
+ input_report_key(gccdata->input, BTN_TR2, !!(keys[2] & BIT(1))); // Z
+ input_report_key(gccdata->input, BTN_TR, !!(keys[2] & BIT(2))); // L (digital)
+ input_report_key(gccdata->input, BTN_TL, !!(keys[2] & BIT(3))); // R (digital)
+ // Left analog stick
input_report_abs(gccdata->input, ABS_X, keys[3]);
input_report_abs(gccdata->input, ABS_Y, keys[4] ^ 0xFF);
+
+ // Right analog stick (C stick)
input_report_abs(gccdata->input, ABS_RX, keys[5]);
input_report_abs(gccdata->input, ABS_RY, keys[6] ^ 0xFF);
+
+ // Left trigger
input_report_abs(gccdata->input, ABS_Z, keys[7]);
+
+ // Right trigger
input_report_abs(gccdata->input, ABS_RZ, keys[8]);
input_sync(gccdata->input);
@@ -195,9 +202,13 @@ static int gc_controller_init(struct gcc_data *gccdev, u8 status)
input_set_drvdata(gccdev->input, gccdev);
usb_to_input_id(gccdev->adapter->udev, &gccdev->input->id);
- gccdev->input->name = "Nintendo GameCube Controller";
+
+ gccdev->input->name = gccdev->name;
gccdev->input->phys = gccdev->adapter->phys;
+ // dev_set_name(&gccdev->input->dev, "input%d", gccdev->no);
+ // gccdev->input->dev.parent = &gccdev->adapter->intf->dev;
+
set_bit(EV_KEY, gccdev->input->evbit);
set_bit(BTN_A, gccdev->input->keybit);
@@ -249,17 +260,32 @@ gc_deinit_controller:
return error;
}
+#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
+#define BYTE_TO_BINARY(byte) \
+ ((byte) & 0x80 ? '1' : '0'), \
+ ((byte) & 0x40 ? '1' : '0'), \
+ ((byte) & 0x20 ? '1' : '0'), \
+ ((byte) & 0x10 ? '1' : '0'), \
+ ((byte) & 0x08 ? '1' : '0'), \
+ ((byte) & 0x04 ? '1' : '0'), \
+ ((byte) & 0x02 ? '1' : '0'), \
+ ((byte) & 0x01 ? '1' : '0')
+
static void gc_controller_update_work(struct work_struct *work)
{
int i;
u8 status[4];
bool enable[4];
+ bool rumble_allowed[4];
unsigned long flags;
struct gc_data *gdata = container_of(work, struct gc_data, work);
for (i = 0; i < 4; i++) {
status[i] = gdata->controllers[i].status;
enable[i] = gc_connected_type(status[i]) != 0;
+ rumble_allowed[i] = (status[i] & GAMECUBE_WIRELESS) == 0 && (status[i] & 0x04) != 0;
+
+ dev_info(&gdata->intf->dev, "Port %d; Status: "BYTE_TO_BINARY_PATTERN"; Enable: %d; Rumble Allowed: %d\n", i, BYTE_TO_BINARY(status[i]), enable[i], rumble_allowed[i]);
}
for (i = 0; i < 4; i++) {
@@ -449,6 +475,8 @@ static void gc_init_controllers(struct gc_data *gdata)
gdata->controllers[i].no = i;
gdata->controllers[i].status = GAMECUBE_NONE;
gdata->controllers[i].enable = false;
+
+ snprintf(gdata->controllers[i].name, 32, "Nintendo GameCube Controller #%d", i + 1);
}
}
@@ -530,7 +558,7 @@ static const struct usb_device_id gc_usb_devices[] = {
MODULE_DEVICE_TABLE(usb, gc_usb_devices);
static struct usb_driver gc_usb_driver = {
- .name = "gamecube_adapter",
+ .name = "gamecube-adapter",
.id_table = gc_usb_devices,
.probe = gc_usb_probe,
.disconnect = gc_usb_disconnect,
diff --git a/usb-gamecube-adapter.h b/gamecube-adapter.h
similarity index 98%
rename from usb-gamecube-adapter.h
rename to gamecube-adapter.h
index 26b794b..c835167 100644
--- a/usb-gamecube-adapter.h
+++ b/gamecube-adapter.h
@@ -32,6 +32,7 @@ struct gcc_data {
u8 no;
u8 status;
bool enable;
+ char name[32];
};
struct gc_data { |
Well I know that there is a flag for that but I first wanted a module which work ^^' and is simple enought to understand |
Hi In my quest to try to play with a gcc I stumbled on your driver, and also on a forum post where you asked for a review. Some time ago I found this driver by sheer luck. It ended up not being included in the kernel (for no apparent reason), but I changed it a little to turn it into a module and it works. I thought you might be interested in studying it, so here it is. |
I just found this repository. Some time ago I picked up your patches from the v3 serie, and made it compile on the latest kernel. You find this my work in my hid-gamecube-adapter repository. The ultimate goal was to generate the hid-gamecube-adapter-dkms-git AUR package for Arch Linux. So that I can just build it as an out-of-tree module without bothering about kernel updates and stuff. Now moving forward :
|
Hi,
|
Could you try to test with a controller already in the kernel ? I would suggest a XBox Controller or one of it's clone as I based my most of my work on xpad.c to see if you have the same issues with it ? |
Can you mainline this driver please? The driver will be deployed to billions of devices, and the adapter will work with future Linux, Android, and ChromeOS devices.
The text was updated successfully, but these errors were encountered: