mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-10-04 08:21:49 +02:00
byuu says: I imagine you guys will like this WIP very much. Changelog: - ListView check boxes on Windows - ListView removal of columns on reset (changing input dropdowns) - DirectSound audio duplication on latency change - DirectSound crash on 20ms latency - Fullscreen window sizing in multi-monitor setups - Allow joypad bindings of hotkeys - Allow triggers to be mapped (Xbox 360 / XInput / Windows only) - Support joypad rumble for Game Boy Player - Video scale settings modified from {1x,2x,3x} to {2x,3x,4x} - System menu now renames to active emulation core - Added fast forward hotkey Not changing for v095: - not adding input focus settings yet - not adding shaders yet Not changing at all: - not implementing maximize
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
|
|
setIcon(Icon::Device::Keyboard);
|
|
setText("Hotkeys");
|
|
|
|
layout.setMargin(5);
|
|
mappingList.onActivate([&] { assignMapping(); });
|
|
mappingList.onChange([&] {
|
|
eraseButton.setEnabled((bool)mappingList.selected());
|
|
});
|
|
resetButton.setText("Reset").onActivate([&] {
|
|
if(MessageDialog("Are you sure you want to erase all hotkey mappings?").setParent(*settingsManager).question() == "Yes") {
|
|
for(auto& mapping : inputManager->hotkeys) mapping->unbind();
|
|
refreshMappings();
|
|
}
|
|
});
|
|
eraseButton.setText("Erase").onActivate([&] {
|
|
if(auto item = mappingList.selected()) {
|
|
inputManager->hotkeys[item->offset()]->unbind();
|
|
refreshMappings();
|
|
}
|
|
});
|
|
|
|
reloadMappings();
|
|
refreshMappings();
|
|
}
|
|
|
|
auto HotkeySettings::reloadMappings() -> void {
|
|
mappingList.reset();
|
|
mappingList.append(ListViewHeader().setVisible()
|
|
.append(ListViewColumn().setText("Name"))
|
|
.append(ListViewColumn().setText("Mapping").setExpandable())
|
|
.append(ListViewColumn().setText("Device"))
|
|
);
|
|
for(auto& hotkey : inputManager->hotkeys) {
|
|
mappingList.append(ListViewItem()
|
|
.append(ListViewCell().setText(hotkey->name))
|
|
.append(ListViewCell())
|
|
.append(ListViewCell())
|
|
);
|
|
}
|
|
mappingList.resizeColumns();
|
|
}
|
|
|
|
auto HotkeySettings::refreshMappings() -> void {
|
|
unsigned position = 0;
|
|
for(auto& hotkey : inputManager->hotkeys) {
|
|
mappingList.item(position)->cell(1)->setText(hotkey->assignmentName());
|
|
mappingList.item(position)->cell(2)->setText(hotkey->deviceName());
|
|
position++;
|
|
}
|
|
mappingList.resizeColumns();
|
|
}
|
|
|
|
auto HotkeySettings::assignMapping() -> void {
|
|
inputManager->poll(); //clear any pending events first
|
|
|
|
if(auto item = mappingList.selected()) {
|
|
activeMapping = inputManager->hotkeys[item->offset()];
|
|
settingsManager->layout.setEnabled(false);
|
|
settingsManager->statusBar.setText({"Press a key or button to map [", activeMapping->name, "] ..."});
|
|
}
|
|
}
|
|
|
|
auto HotkeySettings::inputEvent(shared_pointer<HID::Device> device, unsigned group, unsigned input, int16 oldValue, int16 newValue) -> void {
|
|
if(!activeMapping) return;
|
|
if(device->isMouse()) return;
|
|
|
|
if(activeMapping->bind(device, group, input, oldValue, newValue)) {
|
|
activeMapping = nullptr;
|
|
settingsManager->statusBar.setText("");
|
|
settingsManager->layout.setEnabled(true);
|
|
refreshMappings();
|
|
}
|
|
}
|