Skip to content

Instantly share code, notes, and snippets.

@dnmodder
Last active January 28, 2025 13:57
Show Gist options
  • Save dnmodder/de2df973323b7c6acf45f40dc66e8db3 to your computer and use it in GitHub Desktop.
Save dnmodder/de2df973323b7c6acf45f40dc66e8db3 to your computer and use it in GitHub Desktop.

Revisions

  1. dnmodder revised this gist Sep 21, 2021. No changes.
  2. dnmodder revised this gist Sep 23, 2020. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions fixcontroller.py
    Original file line number Diff line number Diff line change
    @@ -9,15 +9,15 @@
    import usb.util
    except ImportError:
    print("First, install the pyusb module with PIP or your package manager.")
    finally:
    sys.exit()

    if os.geteuid() != 0:
    print("You need to run this script with sudo")
    sys.exit()
    else:
    if os.geteuid() != 0:
    print("You need to run this script with sudo")
    sys.exit()

    dev = usb.core.find(find_all=True)
    dev = usb.core.find(find_all=True)

    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
    finally:
    sys.exit()
  3. dnmodder revised this gist Sep 22, 2020. 1 changed file with 15 additions and 5 deletions.
    20 changes: 15 additions & 5 deletions fixcontroller.py
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,23 @@
    #!/usr/bin/env python3

    import os
    import sys


    try:
    import usb.core
    import usb.util
    except ImportError:
    print("First, install the pyusb module with PIP or your package manager.")
    else:
    dev = usb.core.find(find_all=True)
    finally:
    sys.exit()

    if os.geteuid() != 0:
    print("You need to run this script with sudo")
    sys.exit()

    dev = usb.core.find(find_all=True)

    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
  4. dnmodder revised this gist Sep 19, 2020. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions fixcontroller.py
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    #!/usr/bin/env python3

    import usb.core
    import usb.util
    try:
    import usb.core
    import usb.util
    except ImportError:
    print("First, install the pyusb module with PIP or your package manager.")
    else:
    dev = usb.core.find(find_all=True)

    dev = usb.core.find(find_all=True)

    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
  5. dnmodder revised this gist Jul 12, 2020. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions fixcontroller.py
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,10 @@
    #!/usr/bin/env python3

    import usb.core
    import usb.util

    dev = usb.core.find(idVendor=0x045e, idProduct=0x028e)

    if dev is None:
    raise ValueError('Device not found')
    else:
    dev.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
    dev = usb.core.find(find_all=True)

    for d in dev:
    if d.idVendor == 0x045e and d.idProduct == 0x028e:
    d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
  6. dnmodder renamed this gist Dec 2, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. dnmodder created this gist Nov 26, 2018.
    11 changes: 11 additions & 0 deletions pyusb-test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/usr/bin/env python3

    import usb.core

    dev = usb.core.find(idVendor=0x045e, idProduct=0x028e)

    if dev is None:
    raise ValueError('Device not found')
    else:
    dev.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)