AntiMicroX / antimicrox

Graphical program used to map keyboard buttons and mouse controls to a gamepad. Useful for playing games with no gamepad support.
GNU General Public License v3.0
2.53k stars 146 forks source link

Option to disable battery level notification #45

Closed maxigaz closed 2 years ago

maxigaz commented 4 years ago

AntimicroX shows a warning when the battery level of my DS4 goes bellow 20%. While this is a neat feature, I’d like it to be optional because I already use a script for Polybar that informs me of the current level while it's connected.


Upvote & Fund

Fund with Polar

Zenajj commented 3 years ago

+1 on option to disable battery notification. This is in my opinion really annoying feature, since it's not working properly. I got Razer Panthera Evo fightstick, and it's wired (no battery), yet I still get low battery warning. What is worse is that warning popup minimizes all other apps (including game I'm playing). So far, I just let warning popup open, since if I close it, it reapers few minutes later (and again, minimizes the game I'm playing).

maxigaz commented 3 years ago

I have an idea: how about removing this feature completely? I think it’s easier to do so than add an option for it—a feature that apparently not only makes the user experience worse but is IMO redundant.

With my limited knowledge of C++, I’ve taken a look at the code and I think I’ve found the parts that make the battery level check and popup window work in the first place. I’ll try it with those parts removed in the upcoming days, and if it doesn’t break anything and there are no objections, I’ll send a PR.

pktiuk commented 3 years ago

I will check disabling/changing this feature. I think it would be better to use regular system notification instead of opening this popup window.

maxigaz commented 3 years ago

I will check disabling/changing this feature.

Thank you! Much appreciated.

I think it would be better to use regular system notification instead of opening this popup window.

I agree, this would definitely be a step in the right direction.

In addition to that, there could be a setting to adjust when that notification appears. For example, let’s say the user can choose between one of the following options:

pktiuk commented 3 years ago

I will check this, but SDL doesn't provide so accurate way of measuring power levels:

typedef enum
{
    SDL_JOYSTICK_POWER_UNKNOWN = -1,
    SDL_JOYSTICK_POWER_EMPTY,   /* <= 5% */
    SDL_JOYSTICK_POWER_LOW,     /* <= 20% */
    SDL_JOYSTICK_POWER_MEDIUM,  /* <= 70% */
    SDL_JOYSTICK_POWER_FULL,    /* <= 100% */
    SDL_JOYSTICK_POWER_WIRED,
    SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel;
maxigaz commented 3 years ago

I will check this, but SDL doesn't provide so accurate way of measuring power levels:

typedef enum
{
    SDL_JOYSTICK_POWER_UNKNOWN = -1,
    SDL_JOYSTICK_POWER_EMPTY,   /* <= 5% */
    SDL_JOYSTICK_POWER_LOW,     /* <= 20% */
    SDL_JOYSTICK_POWER_MEDIUM,  /* <= 70% */
    SDL_JOYSTICK_POWER_FULL,    /* <= 100% */
    SDL_JOYSTICK_POWER_WIRED,
    SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel;

Oh… so, that’s why I keep seeing a different value in the Polybar indicator (whose values are steps of 10%, as in “10%, 20%, 30%, …, 90%, and 100%”). Less accurate but works across multiple platforms, I guess?

I would still welcome the option to turn it off altogether, because both a popup window and a desktop notification can be distracting, especially when I want to be notified only when the battery level is below 10% (which I can already do outside AntimicroX).

pktiuk commented 3 years ago

Don't worry, this will be optional anyway.

This change will be ready tomorrow

I hope you will be able to test it for me. :D (I don't have any gamepad with showing power level)

pktiuk commented 3 years ago

Change is ready
@maxigaz @Zenajj
Would you like to test it? Test builds are available here. (I recommend AppImage - it is universal package and doesn't affect your current installations of AntiMicroX, just download package make it executable and run)

Zenajj commented 3 years ago

I tested it for a bit, and so far it works perfectly. It recognizes my controller, I mapped all keys without a problem, and no battery warning so far (after 1 hour of running a program). Thank you for this :)

pktiuk commented 3 years ago

Try to use it until your controller will be discharged. (just to be sure).

Zenajj commented 3 years ago

I can't, since I got controller without battery, so it's always charged. This was my main issue, since I got warnings even tho my controller is wire only. (I got Razer Panthera Evo)

pktiuk commented 3 years ago

Ok, so for now we know notifications can be disabled. :D

Could you enable these notifications for tests? (save new settings and restart app) Now instead of popup with warning you should get regular linux-style system notifications.
Moreover, you should get this notification only once per battery level (since now it should inform you about low battery level only once and only once when your battery is empty).

maxigaz commented 3 years ago

Could you enable these notifications for tests?

I’ve just tried running the AppImage you linked earlier and let it run in the background while using the gamepad in wireless mode. Its battery went from 30% to 10% or less in about 2 hours and I didn’t get any notifications, although I had both options checked and clicked on OK.

Then I realised you also wrote this:

(save new settings and restart app)

Maybe I didn’t get any notifications because I didn’t restart it?

Edit: When I looked at mainwindow.cpp, I found that the battery level was checked every ten minutes, set by a variable whose value was in milliseconds. Any chance you could make this configurable for testing purposes?

Zenajj commented 3 years ago

I tried with both notifications enabled and disabled, and I don't get any notification in both cases.

pktiuk commented 3 years ago

Then I realised you also wrote this:

(save new settings and restart app)

Maybe I didn’t get any notifications because I didn’t restart it?

Yes, but now I have fixed this. Changes won't need restarting app.

Edit: When I looked at mainwindow.cpp, I found that the battery level was checked every ten minutes, set by a variable whose value was in milliseconds. Any chance you could make this configurable for testing purposes?

I have changed it to 10 seconds (for new test build only)

I have created a new test build with these changes: https://github.com/pktiuk/antimicrox/releases/tag/test-optional-batt2

maxigaz commented 3 years ago

Sorry for only replying just now.

I have created a new test build with these changes: https://github.com/pktiuk/antimicrox/releases/tag/test-optional-batt2

I gave this a try and I didn’t get any notification, regardless of whether the options were checked or not.

blackwind commented 2 years ago

Yep, not working properly in release build. Window keeps popping up even with freshly charged batteries.