Shortcuts: provide some default actions for mute, increment and decrement volume media keys
Works for HID-aware devices (USB & PS/2). Change-Id: I45e9ededaab1699f30e55fb644ec0e3ceebeb191 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5937 Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
c44b267fb3
commit
d9f90ce7f3
@ -289,3 +289,8 @@ AddDirectoryToHaikuImage home config settings printers "Save as PDF"
|
||||
|
||||
# padblocker
|
||||
AddDirectoryToHaikuImage home config settings touchpad ;
|
||||
|
||||
# shortcuts defaults
|
||||
local shortcutsSettingsFile = <settings>shortcuts_settings ;
|
||||
SEARCH on $(shortcutsSettingsFile) = [ FDirName $(HAIKU_TOP) data settings ] ;
|
||||
AddFilesToHaikuImage home config settings : $(shortcutsSettingsFile) ;
|
||||
|
BIN
data/settings/shortcuts_settings
Normal file
BIN
data/settings/shortcuts_settings
Normal file
Binary file not shown.
@ -40,6 +40,8 @@
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <usb/USB_hid.h>
|
||||
#include <usb/USB_hid_page_consumer.h>
|
||||
|
||||
#include "EditWindow.h"
|
||||
#include "KeyInfos.h"
|
||||
@ -215,6 +217,12 @@ ShortcutsWindow::ShortcutsWindow()
|
||||
message.AddString("startupRef", "please");
|
||||
PostMessage(&message);
|
||||
// tell ourselves to load this file if it exists
|
||||
} else {
|
||||
_AddNewSpec("/bin/setvolume -m", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_MUTE);
|
||||
_AddNewSpec("/bin/setvolume -i", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_VOLUME_INCREMENT);
|
||||
_AddNewSpec("/bin/setvolume -d", (B_HID_USAGE_PAGE_CONSUMER << 16) | B_HID_UID_CON_VOLUME_DECREMENT);
|
||||
fLastSaved = BEntry(&keySetRef);
|
||||
PostMessage(SAVE_KEYSET);
|
||||
}
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||
@ -315,11 +323,9 @@ ShortcutsWindow::_GetSettingsFile(entry_ref* eref)
|
||||
return false;
|
||||
else
|
||||
path.Append(SHORTCUTS_SETTING_FILE_NAME);
|
||||
|
||||
if (BEntry(path.Path(), true).GetRef(eref) == B_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
BEntry entry(path.Path(), true);
|
||||
entry.GetRef(eref);
|
||||
return entry.Exists();
|
||||
}
|
||||
|
||||
|
||||
@ -435,7 +441,7 @@ ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMessage)
|
||||
// Creates a new entry and adds it to the GUI. (defaultCommand) will be the
|
||||
// text in the entry, or NULL if no text is desired.
|
||||
void
|
||||
ShortcutsWindow::_AddNewSpec(const char* defaultCommand)
|
||||
ShortcutsWindow::_AddNewSpec(const char* defaultCommand, uint32 keyCode)
|
||||
{
|
||||
_MarkKeySetModified();
|
||||
|
||||
@ -454,6 +460,10 @@ ShortcutsWindow::_AddNewSpec(const char* defaultCommand)
|
||||
fColumnListView->ScrollTo(spec);
|
||||
if (defaultCommand)
|
||||
spec->SetCommand(defaultCommand);
|
||||
if (keyCode != 0) {
|
||||
spec->ProcessColumnTextString(ShortcutsSpec::KEY_COLUMN_INDEX,
|
||||
GetFallbackKeyName(keyCode).String());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
private:
|
||||
BMenuItem* _CreateActuatorPresetMenuItem(const char* label)
|
||||
const;
|
||||
void _AddNewSpec(const char* defaultCommand);
|
||||
void _AddNewSpec(const char* defaultCommand, uint32 keyCode = 0);
|
||||
void _MarkKeySetModified();
|
||||
bool _LoadKeySet(const BMessage& loadMessage);
|
||||
bool _SaveKeySet(BEntry& saveEntry);
|
||||
|
Loading…
Reference in New Issue
Block a user