Skip to content

Commit

Permalink
renamed modified gcadapter_oc.c to wmo_oc.c
Browse files Browse the repository at this point in the history
  • Loading branch information
YeaSeb committed Apr 6, 2022
1 parent 6ab4812 commit 5fb7975
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions gcadapter_oc.c → wmo_oc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include <linux/kernel.h>
#include <linux/usb.h>

#define GCADAPTER_VID 0x045e
#define GCADAPTER_PID 0x0040
#define WMO_VID 0x045e
#define WMO_PID 0x0040

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Hannes Mann");
MODULE_DESCRIPTION("Filter kernel module to set the polling rate of the Wii U/Mayflash GameCube Adapter to a custom value.");
MODULE_VERSION("1.4");
MODULE_AUTHOR("Sebastián Zambrano");
MODULE_DESCRIPTION("Filter kernel module to set the polling rate of the WMO to a custom value on XHCI.");
MODULE_VERSION("1.0");

static struct usb_device* adapter_device = NULL;

Expand All @@ -32,7 +32,7 @@ static unsigned short patch_endpoints(unsigned short interval) {
old_interval = altsettingptr->endpoint[endpoint].desc.bInterval;
altsettingptr->endpoint[endpoint].desc.bInterval = interval;

printk(KERN_INFO "gcadapter_oc: bInterval value of endpoint 0x%.2x set to %u.\n", altsettingptr->endpoint[endpoint].desc.bEndpointAddress, interval);
printk(KERN_INFO "wmo_oc: bInterval value of endpoint 0x%.2x set to %u.\n", altsettingptr->endpoint[endpoint].desc.bEndpointAddress, interval);
}
}
}
Expand All @@ -44,11 +44,11 @@ static unsigned short patch_endpoints(unsigned short interval) {
*/
int ret = usb_lock_device_for_reset(adapter_device, NULL);
if(ret) {
printk(KERN_ERR "gcadapter_oc: Warning! Failed to acquire lock for USB device (error: %d). Resetting device anyway...\n", ret);
printk(KERN_ERR "wmo_oc: Warning! Failed to acquire lock for USB device (error: %d). Resetting device anyway...\n", ret);
}
/* TODO: It might be possible to make the new bInterval value take effect without calling usb_reset_device? */
if(usb_reset_device(adapter_device)) {
printk(KERN_ERR "gcadapter_oc: Could not reset device (error: %d). bInterval value was NOT changed.\n", ret);
printk(KERN_ERR "wmo_oc: Could not reset device (error: %d). bInterval value was NOT changed.\n", ret);
}
/* Only unlock the device if usb_lock_device_for_reset succeeded. */
if(!ret) {
Expand All @@ -65,9 +65,9 @@ static int on_usb_notify(struct notifier_block* self, unsigned long action, void

switch(action) {
case USB_DEVICE_ADD:
if(device->descriptor.idVendor == GCADAPTER_VID && device->descriptor.idProduct == GCADAPTER_PID && adapter_device == NULL) {
if(device->descriptor.idVendor == WMO_VID && device->descriptor.idProduct == WMO_PID && adapter_device == NULL) {
adapter_device = device;
printk(KERN_INFO "gcadapter_oc: Adapter connected\n");
printk(KERN_INFO "wmo_oc: Overclockable mouse connected\n");

restore_interval = patch_endpoints(configured_interval);
}
Expand All @@ -76,7 +76,7 @@ static int on_usb_notify(struct notifier_block* self, unsigned long action, void
case USB_DEVICE_REMOVE:
if(adapter_device == device) {
adapter_device = NULL;
printk(KERN_INFO "gcadapter_oc: Adapter disconnected\n");
printk(KERN_INFO "wmo_oc: Overclockable mouse disconnected\n");
}
break;
}
Expand All @@ -87,9 +87,9 @@ static int on_usb_notify(struct notifier_block* self, unsigned long action, void
static struct notifier_block usb_nb = { .notifier_call = on_usb_notify };

static int usb_device_cb(struct usb_device* device, void* data) {
if(device->descriptor.idVendor == GCADAPTER_VID && device->descriptor.idProduct == GCADAPTER_PID && adapter_device == NULL) {
if(device->descriptor.idVendor == WMO_VID && device->descriptor.idProduct == WMO_PID && adapter_device == NULL) {
adapter_device = device;
printk(KERN_INFO "gcadapter_oc: Adapter connected\n");
printk(KERN_INFO "wmo_oc: wheel mouse optical connected\n");

restore_interval = patch_endpoints(configured_interval);
}
Expand All @@ -99,12 +99,12 @@ static int usb_device_cb(struct usb_device* device, void* data) {

static int __init on_module_init(void) {
if(configured_interval > 255) {
printk(KERN_WARNING "gcadapter_oc: Invalid interval parameter specified.\n");
printk(KERN_WARNING "wmo_oc: Invalid interval parameter specified.\n");
configured_interval = 255;
}

if(configured_interval == 0) {
printk(KERN_WARNING "gcadapter_oc: Invalid interval parameter specified.\n");
printk(KERN_WARNING "wmo_oc: Invalid interval parameter specified.\n");
configured_interval = 1;
}

Expand All @@ -130,11 +130,11 @@ static int on_interval_changed(const char* value, const struct kernel_param* kp)

if(!ret) {
if(configured_interval > 255) {
printk(KERN_WARNING "gcadapter_oc: Invalid interval parameter specified.\n");
printk(KERN_WARNING "wmo_oc: Invalid interval parameter specified.\n");
configured_interval = 255;
}
else if(configured_interval == 0) {
printk(KERN_WARNING "gcadapter_oc: Invalid interval parameter specified.\n");
printk(KERN_WARNING "wmo_oc: Invalid interval parameter specified.\n");
configured_interval = 1;
}

Expand Down

0 comments on commit 5fb7975

Please sign in to comment.