MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / exec

Method exec

source/src/scriptinterpreter.cpp:1644–1683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1642 }
1643};
1644/*
1645num volume: set volume
1646str deviceName
1647
1648num return
1649*/
1650struct QiFunc_volume_set : public QiFunc
1651{
1652 QiFunc_volume_set() : QiFunc(1, 2) {}
1653 QiVar exec(const std::vector<QiVar>& args, QiScriptInterpreter*) const override
1654 {
1655 AudioDevice ad;
1656 if (ad)
1657 {
1658 std::wstring deviceId;
1659 if (args.size() > 1)
1660 {
1661 const std::wstring deviceName = args[1].toWString();
1662 AudioDeviceInfos infos = ad.findDevice(AudioDeviceInfo::OUTPUT, AudioDeviceInfo::ACTIVATED);
1663 for (const auto& i : infos) if (i.name == deviceName) deviceId = i.id;
1664 }
1665 else
1666 {
1667 AudioDeviceInfo info = ad.getOutputDefault();
1668 if (info.ok) deviceId = info.id;
1669 }
1670 if (!deviceId.empty())
1671 {
1672 return ad.setVolume(deviceId, args[0].toNumber());
1673 }
1674 }
1675 return false;
1676 }
1677};
1678/*
1679[0] get default output
1680str return: device name
1681
1682[1] set default output
1683str deviceName
1684
1685bool return
1686*/

Callers

nothing calls this directly

Calls 3

isIntegerMethod · 0.80
toIntegerMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected