项目作者: couriersud

项目描述 :
MSI Gaming Device control application
高级语言: C++
项目地址: git://github.com/couriersud/msigd.git
创建时间: 2019-12-07T18:40:03Z
项目社区:https://github.com/couriersud/msigd

开源协议:GNU General Public License v2.0

下载


1. msigd

The msigd command line tool allows you to change most settings for MSI monitors which can be set in the monitor’s OSD menu.

Warning: Use msigd only if you are sure what you are doing.
The monitor firmware seems to have no protection against unsupported accesses.

Using msigd may make your monitor permantently unusable.

Please make sure you use at least msigd version 0.17

With version 0.12 the syntax of the “—mystic” option has changed. For the
MPG273CQR two led groups (0 and 1) are supported. For all other mystic light
monitors only group 1 is supported.

1. Build status:

OS Compiler Status
Linux g++
Windows MinGW++
OSX clang++

2. Supported monitors

All monitors for which the OSD Gaming Device App is available most likely
should be supported. There are differences between those monitors which msigd
currently does not know about.

If you own an MSI monitor supported by the MSI App, please provide the following
information by opening an issue.

  • The id of your monitor, e.g. MAG321CURV
  • The output of msigd --debug --info --query
  • For linux the output of lsusb
  • Your operating system and version
  • any other information which might be helpful, e.g. OSD setting xyz is not
    supported.

2.1. MSI Monitors

ID Firmware Supported Version Special Panel Manual
MPG27CQ ? Yes “V18” “001” ?
MAG241C ? Yes “V18” “002” ? Manual
MAG241C ? Yes “V49” “002” ?
MAG241CP ? Yes “V18” “002” ? Manual
MAG241CV ? Yes “V18” “002” ? Manual
MAG241CR ? Yes “V18” “004” ? Manual
MAG271CR ? Yes “V18” “005” ? Manual
MAG271CQR ? Yes “V19” “006” TPM270WQ1_DP01
MAG321CQR ? Yes “V18” “00:” ?
MAG321CURV FW.009 Yes “V18” “00;” SAM_LSM315FP01 Manual
MAG321CURV FW.011 Yes “V43” “00;” ? Manual
MPG341CQR ? WIP “V09” “00>” ? Manual
PS341WU FW.024 Yes “V06” “00?” ?
MPG273CQR FW.022 Yes “V51” “00[“ ? Manual
MAG251RX ? WIP “V18” “00B” ? Manual
MAG272CQR ? Yes “V18” “00E” ? Manual
MAG272CQR ? Yes “V41” “00E” ? Manual
MAG272QR ? Partial 1) “V18” “00G” ? Manual
MAG272 ? Yes “V18” “00L” ? Manual
MAG272QP ? Yes “V18” “00O” ? Manual
MAG274R ? Yes “V41” “00Z” ? Manual
MAG274QRF-QD FW.011 Yes “V43” “00e” AUO_M270DAN08_2
MAG274QRF-QD FW.015 Yes “V48” “00e” AUO_M270DAN08_2
MAG274QRF-QD FW.020 Yes “V56” “00e” AUO_M270DAN08_2 Manual
MAG274QRX ? Partial 2) “V53” “00\ ? Manual
MAG270CR ? ? ? ? ?
MAG271C ? ? “V18” “002” ? Manual
MAG271CP ? ? “V18” “002” ? Manual
MAG271CQP ? ? “V19” “006” ?
MAG271CV ? ? “V18” “002” ? Manual
MAG271QR ? ? ? ? ?
MAG271R ? ? ? ? ?
MAG271V ? ? ? ? ?
MAG272C ? ? “V18” “00O” ?
MAG272CR ? ? “V18” “00O” ?
MAG272CRX ? ? “V18” “00O” ?
MAG272R ? ? “V18” “00O” ?
MAG322CQR ? ? ? ? ?
MAG322CQRV ? ? ? ? ?
MAG322CR ? ? ? ? ?
MPG341CQRV ? ? ? ? ?
MD272QP ? Partial 3) “V51” “00\x85” ? Manual

1) Mystic support is not working. Has 12 lights - Steel series interface?
2) Currently only query possible until feedback is given on issue #43
3) Audio Volume and Navi-Key not working

2.2. Service menu

The panel information and more is displayed by the service menu.

  • Hold the joystick button down
  • Unplug your monitor power supply - keep holding down
  • Plug in your monitor supply - keep holding down
  • When msi logo appears - stop holding down
  • When monitor displays screen - push joystick button down to show OSD
  • Push joystick button down again
  • Service menu opens

The service menu also has more information about the preset color
temperature modes.

2.3. USB manufacturer and product id

  1. ID 1462:3fa4 Micro Star International

3. Compile

3.1. Linux

Make sure you have libusb installed. On debian based systems

  1. sudo apt install libusb-dev libhidapi-dev

On Fedora use

  1. dnf install libusb-devel hidapi-devel

Compile with

  1. make

For Arch-Linux the name of the usb library differs (usb-1.0). Please use

  1. sudo pacman -S libusb hidapi
  2. make TARGETOS=arch

to install dependencies and compile.

3.2. WSL

Warning: you need Windows Subsystem for Linux 2 with a kernel version of at least 5.10.60.1

Make sure you have libusb installed. On debian based systems

  1. sudo apt install libusb-dev libhidapi-dev

Compile with libusb

  1. make USE_HIDAPI=0

On Windows, install usbipd-win as described here.

You need to attach two usb devices to WSL. You can either find them in Device Manager or by checking usbpid wsl list before and after pluggin in the monitor.

Drawback: Attached usb devices are not saved and need to be reattached every time the monitor is turned on.

Perform the steps of 4.1. Linux.

3.3. Windows

To compile on windows you need a working mingw environment.

Make sure you have libusb installed:

  1. pacman -S mingw-w64-x86_64-libusb-compat-git
  2. pacman -S mingw-w64-x86_64-hidapi

Compile

  1. make TARGETOS=windows

3.4. OSX

Make sure you have homebrew installed.

  1. brew install libusb-compat
  2. brew install hidapi

Compile

  1. make TARGETOS=osx

4. Security

4.1. Linux

This program needs root privilidges. Use with care.

Alternatively you may use udev to grant user access rights. More information is
available on here: Documentation on askubuntu

In a nutshell:

  • Ensure that your system has a group plugdev and that the current user is a member of the plugdev group.

  • Create /etc/udev/rules.d/51-msi-gaming-device.rules:

  1. # Allow access to members of plugdev - both for usb and hidraw access
  2. SUBSYSTEM=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="3fa4", GROUP="plugdev", TAG+="uaccess"
  3. KERNEL=="hidraw*", ATTRS{idVendor}=="1462", ATTRS{idProduct}=="3fa4", GROUP="plugdev", TAG+="uaccess"
  • Execute
  1. sudo udevadm control --reload-rules
  • Turn your monitor off and on.

4.2. Windows

On Windows 7 msigd does need no additional user rights. It however conflicts
with OSD Gaming device software.

You have two alternatives:

  1. Completely remove the MSI Gaming Device software to run the application.

  2. Use Task Manager and stop MonitorMicroKeyDetector.exe

4.3. OSX

On OSX no elevated user rights are needed.

4.4. Building with libusb

You can also use make USE_HIDAPI=0 to build with libusb instead of the default libhidapi.
This introduces issues on Windows and OSX builds and therefore is not recommended.

  • For Windows administrator rights are needed.

  • On OSX the usb interface will be claimed by the OSX HID driver. Basically this prevents
    msigd to claim the usb interface. There is no easy way around this. More information
    can be found here: libusb FAQ.
    A solution is described on stackoverflow.
    This includes turning of security settings and thus I am not going to
    pursue this further here.

5. Usage

msigd --help

man msigd

6. Settings not supported

6.1. MAG241 series

6.1.1. Screen size

Although documented in the manual setting the screen size (4:3, 16:9) is not
supported. The setting will kill the usb interface and the monitor needs a
plug/unplug power cable cycle.

6.2. PS341 series

6.2.1. Quick charge

Changing the quick charge setting is not supported. We were not able to identify
how to enable or disable quick charge programmatically. The status however
can be queried.

6.2.2. Eye saver

--eye_saver works with the modes user, hdr, cinema, reader and bw.
In mode eyecare it is always reported as on while in modes adobe_rgb,
dci_p3, srgb and dicom it is always off.

7. Examples

7.1. Automatically switch input source

I have a usb swiched port. Upon pressing a button on the switch, keyboard and
mouse (or up to four devices) are switched between two computers: my desktop and
my laptop. There is a USB-C docking station connected to the switch. The laptop
is connected via USB-C. The docking station is connected to the USB-C hub and via
HDMI to input hdmi1 to the monitor.

The following script runs on the desktop. If the keyboard gets disconnect - switched
to laptop, it will switch monitor input to hdmi1. Once the keyboard
reconnects, it will switch back monitor input to dp.

The inotifywait tool needed by this script is available on debian systems.
Use sudo apt install inotify-tools to install it.

  1. #!/bin/sh
  2. WATCH_DIR=/dev/input/by-id
  3. WATCH_INPUT=usb-046a_010d-event-kbd
  4. DISP_INPUT=dp
  5. DISP_ALTERNATIVE=hdmi1
  6. inotifywait -q -m ${WATCH_DIR} | while read event
  7. do
  8. f=`echo $event | cut -f 3 "-d "`
  9. if [ _$f = _${WATCH_INPUT} ]; then
  10. ev=`echo $event | cut -f 2 "-d "`
  11. test _$ev = _DELETE && ./msigd --input $DISP_ALTERNATIVE
  12. test _$ev = _CREATE && ./msigd --input $DISP_INPUT
  13. fi
  14. done

7.2. Change settings depending on foreground window

The script below is an example on how to change display settings automatically
depending on the active application. When watching movies, you may want to use
image enhancement while when using the terminal you may prefer a reduced
brightness.

This script is an example what you can do using msigd:

  1. #!/bin/sh
  2. DISP_DEFAULT='--brightness 80 --eye_saver off --image_enhancement off'
  3. MSIGD=./msigd
  4. if [ ! -x "$(command -v xdotool)" ]; then
  5. echo Error: xdotool required >&2
  6. exit 1
  7. fi
  8. setting=""
  9. while true; do
  10. # Get foreground window commandline
  11. vwin=`xdotool getwindowfocus`
  12. vpid=`xdotool getwindowpid $vwin 2>/dev/null`
  13. if [ "$vpid" != "" ]; then
  14. cl=`cat /proc/${vpid}/cmdline | sed -e "s/\\x0/ /g"`
  15. else
  16. cl=`xdotool getwindowname $vwin`
  17. fi
  18. case "$cl" in
  19. *gnome-terminal-server*)
  20. nsetting='--brightness 30'
  21. ;;
  22. *eclipse*)
  23. nsetting='--eye_saver on'
  24. ;;
  25. *xine*)
  26. nsetting='--image_enhancement strong'
  27. ;;
  28. *)
  29. nsetting=''
  30. ;;
  31. esac
  32. if [ "$nsetting" != "$setting" ]; then
  33. $MSIGD $DISP_DEFAULT $nsetting
  34. setting="$nsetting"
  35. fi
  36. sleep 1
  37. done

7.3. Using msigd in a libvirt-qemu hook

mike-vivas contributed an example of using
msigd within a libvirt-qemu hook to automatically switch the monitor to
virtual guests booting up.

8. TODO

  • Code cleanup
  • Support more monitors - depends on user contributions
  • Document --mystic option better
  • Match options of WIP monitors against manuals.
  • Provide link to monitor manual in table.

9. Credits

John Wehin - PS341WU support and bug fixing

Daniel Connolly - MAG271CQR support

Maxime - MAG241C support

mike-vivas - Arch linux support, contrib

gbirchley - MAG272 support

Térence Clastres - MPG27CQ support and steel series LED support

elric1789 - MAG272QP support

andaag - MAG272CQR support

usrErr0r - MAG272QR support

glaon - MPG341CQR support

Marco Rodolfi - MAG274QRF-QD support

Preston - Multi-Monitor support

Michael J Brancato - Multi-Monitor support

Dominik Helfenstein - WSL compile instructions

Stephen Lee — MAG321QR support

Thorou - MAG271CR support

Skyyblaze - MAG241CR support

Deathof1 - MAG321CQR support

Maxime - MAG241C support

Sahil Gupte - MAG241C V49 support

Pontus Jensen Karlsson - MAG274R support

kunver400 - MAG274QRX support