mirror of
https://github.com/MiSTer-devel/Scripts_MiSTer.git
synced 2026-04-19 03:05:34 +00:00
Scripts to toggle 1ms USB polling on and off
Script preserves any non-polling related settings in u-boot.txt :)
This commit is contained in:
75
fast_USB_polling_off.sh
Normal file
75
fast_USB_polling_off.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# You can download the latest version of this script from:
|
||||
# https://github.com/MiSTer-devel/Scripts_MiSTer
|
||||
|
||||
# Version 1.0 - 2020-01-222 - first version
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import re
|
||||
from os import path
|
||||
|
||||
UBOOT_PATH = "/media/fat/linux/u-boot.txt"
|
||||
|
||||
if os.uname()[1] != "MiSTer":
|
||||
print "This script must be run on a MiSTer system."
|
||||
sys.exit(1)
|
||||
|
||||
if path.exists(UBOOT_PATH):
|
||||
|
||||
poll_prefixes = ("v=loglevel=","usbhid.jspoll=","xpad.cpoll=")
|
||||
|
||||
#reads lines, removing old polling choices and stripping whitespace
|
||||
with open("/media/fat/linux/u-boot.txt","r") as file:
|
||||
lines_out = []
|
||||
for l in file.readlines():
|
||||
stripped_line = re.sub("(%s|%s|%s)\d+\s*" % poll_prefixes,"",l).strip()
|
||||
if len(stripped_line) > 0:
|
||||
lines_out.append(stripped_line)
|
||||
|
||||
#rewrites cleaned output with 1ms polling turned off
|
||||
with open("/media/fat/linux/u-boot.txt","w") as file:
|
||||
for l in lines_out:
|
||||
file.write(l + "\n")
|
||||
file.write("v=loglevel=4 usbhid.jspoll=0 xpad.cpoll=0\n")
|
||||
|
||||
else:
|
||||
with open("/media/fat/linux/u-boot.txt","w") as file:
|
||||
file.write("v=loglevel=4 usbhid.jspoll=0 xpad.cpoll=0\n")
|
||||
|
||||
os.system("clear")
|
||||
|
||||
print """
|
||||
Fast USB polling is OFF and
|
||||
will be inactive after reboot.
|
||||
|
||||
Rebooting in:
|
||||
""",
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
t = 5
|
||||
while t > 0:
|
||||
print "...%x" % t
|
||||
t -= 1
|
||||
time.sleep(1)
|
||||
|
||||
print "...NOW!"
|
||||
os.system("reboot")
|
||||
|
||||
time.sleep(10) # Reboot without showing "Press any key..."
|
||||
77
fast_USB_polling_on.sh
Normal file
77
fast_USB_polling_on.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# You can download the latest version of this script from:
|
||||
# https://github.com/MiSTer-devel/Scripts_MiSTer
|
||||
|
||||
# Version 1.0 - 2020-01-22 - first version
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import re
|
||||
from os import path
|
||||
|
||||
UBOOT_PATH = "/media/fat/linux/u-boot.txt"
|
||||
|
||||
if os.uname()[1] != "MiSTer":
|
||||
print "This script must be run on a MiSTer system."
|
||||
sys.exit(1)
|
||||
|
||||
if path.exists(UBOOT_PATH):
|
||||
|
||||
poll_prefixes = ("v=loglevel=","usbhid.jspoll=","xpad.cpoll=")
|
||||
|
||||
#reads lines, removing old polling choices and stripping whitespace
|
||||
with open("/media/fat/linux/u-boot.txt","r") as file:
|
||||
lines_out = []
|
||||
for l in file.readlines():
|
||||
stripped_line = re.sub("(%s|%s|%s)\d+\s*" % poll_prefixes,"",l).strip()
|
||||
if len(stripped_line) > 0:
|
||||
lines_out.append(stripped_line)
|
||||
|
||||
#rewrites cleaned output with 1ms polling turned on
|
||||
with open("/media/fat/linux/u-boot.txt","w") as file:
|
||||
for l in lines_out:
|
||||
file.write(l + "\n")
|
||||
file.write("v=loglevel=4 usbhid.jspoll=1 xpad.cpoll=1\n")
|
||||
|
||||
else:
|
||||
with open("/media/fat/linux/u-boot.txt","w") as file:
|
||||
file.write("v=loglevel=4 usbhid.jspoll=1 xpad.cpoll=1\n")
|
||||
|
||||
os.system("clear")
|
||||
|
||||
print """
|
||||
Fast USB polling is ON and will be active after reboot.
|
||||
|
||||
This will force 1000mhz polling on all gamepads and joysticks!
|
||||
If you have any input issues, please run fast_USB_polling_off.sh
|
||||
|
||||
Rebooting in:
|
||||
""",
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
t = 5
|
||||
while t > 0:
|
||||
print "...%x" % t
|
||||
t -= 1
|
||||
time.sleep(1)
|
||||
|
||||
print "...NOW!"
|
||||
os.system("reboot")
|
||||
|
||||
time.sleep(10) # Reboot without showing "Press any key..."
|
||||
Reference in New Issue
Block a user