Code Monkey home page Code Monkey logo

Comments (15)

Ryochan7 avatar Ryochan7 commented on July 26, 2024

That is a side effect from how the controller input thread is written. The only time that the input thread sleeps is when it is waiting for input from the ReadFile function. The DS4 has a different poll rate depending on the connection being used. For a USB connection, the poll rate is around 4 ms. For a Bluetooth connection, the poll rate averages around 1.5 ms although there can be isolated periods of latency as high as 15 ms; that is considered normal behavior for the DS4 hardware. The main way to reduce CPU usage would be to impose a slower poll rate for the controller input thread as opposed to reading input as soon as it is ready.

from ds4windows.

GingerAdonis avatar GingerAdonis commented on July 26, 2024

Clear explanation. Thank you.

Just for my curiosity: why is there a different polling timeout/sleep-time for Bt?

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

Based on what I have read, that is just how the hardware was designed to behave. A DS4 using a Bluetooth connection can supposedly send reports as quickly as 1.3 ms. The following is my main source. The page is really useful for the various documented HID reports.

http://eleccelerator.com/wiki/index.php?title=DualShock_4

from ds4windows.

Kaan88 avatar Kaan88 commented on July 26, 2024

In my case the cpu usage is at 11% on i7 6700hq. I've tried it with default settings too. Cpu usage is at 1% with Jays2Kings version.

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

Are you using multiple controllers? In the old Jays2Kings version, one major limiting factor that increased lag but reduced CPU usage were some ties to the GUI thread which caused some extra sleep time in the input thread. The changes made since have reduced lag but increased CPU usage since there is less waiting happening in the input thread now. The problem really affects Bluetooth connections the most because of the high poll rate of the controller when using a Bluetooth connection.

The only decent way to lower CPU usage would be to set a fixed poll rate for the input thread. When using a Bluetooth connection, a new input report is read about once every 1.5 ms. If more than one Bluetooth controller is connected then that can likely cause DS4Windows to always be active and increase CPU usage. On my system, CPU usage maxes out at around 5% when using one controller connected via Bluetooth.

from ds4windows.

Kaan88 avatar Kaan88 commented on July 26, 2024

I see, 5% usage is probably comparable to mine depending on your cpu. I only have one controller. Is the input lag higher with usb connection?

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

As an aside, besides imposing a sleep time in the input thread, I have found decent values to control the input report rate from the DS4 hardware when a controller is connected via Bluetooth. The byte that sets the mode was already known but I have only ever seen a few known values documented; the primary source is from the hid_sony Linux driver. There is a fairly simple way to get the input report rate to change between 1000 Hz to 66 Hz. The lower 4 bits for 0x80 allow for the input report period rate to be changed by 1 ms increments.

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

Looking back at this has shown that the Task based async FileStream methods caused the biggest jump in CPU usage. I have done some experiments and I think the next release will just use the synchronous methods but still use overlapped IO. It looks like the system will still impose its own timeout on the device handles. Looking at the current test, the CPU maxes out around 2 % for a Bluetooth controller compared to the older standard in version 1.4.52 which makes out at around 3%.

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

In case anyone would like to test it out, here is an archive with the latest changes.

https://drive.google.com/open?id=0B6yGHDx0CFzDaEV2RXZEZV9hRHc

from ds4windows.

Kaan88 avatar Kaan88 commented on July 26, 2024

Cpu usage is almost 0 now, with 1.4.70 it was around 10 to 11%.

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

That is good news. Also, it looks like the next release will have the option to change the poll rate used for a DS4 connected via Bluetooth. I have to test it a bit more but it seems like the controls are slightly better when the poll rate interval is set at 4 ms instead of using the highest poll rate. That might just be me but it seems like the option could be useful. The default will still be set at the maximum possible poll rate.

from ds4windows.

shinra358 avatar shinra358 commented on July 26, 2024

Needs moar test versions xD

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

Ask and ye shall receive. There are some other experiments being done that are not finalized yet.

https://drive.google.com/open?id=0B6yGHDx0CFzDd3M0QXVHVzYtU00

from ds4windows.

shinra358 avatar shinra358 commented on July 26, 2024

thank you

from ds4windows.

Ryochan7 avatar Ryochan7 commented on July 26, 2024

A new version has been released. This should solve issues with high CPU usage in DS4Windows. I will keep this issue open for a few days just in case anyone runs into problems.

https://github.com/Ryochan7/DS4Windows/releases/download/v1.4.71/DS4Windows_1.4.71_x64.zip

from ds4windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.