2015-03-02 09:13:28 +00:00
|
|
|
InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
|
|
|
|
setIcon(Icon::Device::Joypad);
|
|
|
|
setText("Input");
|
|
|
|
|
|
|
|
layout.setMargin(5);
|
|
|
|
for(auto& emulator : inputManager->emulators) {
|
|
|
|
emulatorList.append(ComboButtonItem().setText(emulator.name));
|
|
|
|
}
|
|
|
|
emulatorList.onChange([&] { reloadPorts(); });
|
|
|
|
portList.onChange([&] { reloadDevices(); });
|
|
|
|
deviceList.onChange([&] { reloadMappings(); });
|
Update to v094r13 release.
byuu says:
This version polishes up the input dialogue (reset, erase, disable
button when item not focused, split device ID from mapping name), adds
color emulation toggle, and add dummy menu items for remaining features
(to be filled in later.)
Also, it now compiles cleanly on Windows with GTK.
I didn't test with TDM-GCC-32, because for god knows what reason, the
32-bit version ships with headers from Windows 95 OSR2 only. So I built
with TDM-GCC-64 with arch=x86.
And uh, apparently, moving or resizing a window causes a Visual C++
runtime exception in the GTK+ DLLs. This doesn't happen with trance or
renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
2015-03-07 10:21:47 +00:00
|
|
|
mappingList.onActivate([&] { assignMapping(); }).onChange([&] {
|
|
|
|
eraseButton.setEnabled((bool)mappingList.selected());
|
|
|
|
});
|
2015-03-02 09:13:28 +00:00
|
|
|
mappingList.setHeaderVisible();
|
Update to v094r13 release.
byuu says:
This version polishes up the input dialogue (reset, erase, disable
button when item not focused, split device ID from mapping name), adds
color emulation toggle, and add dummy menu items for remaining features
(to be filled in later.)
Also, it now compiles cleanly on Windows with GTK.
I didn't test with TDM-GCC-32, because for god knows what reason, the
32-bit version ships with headers from Windows 95 OSR2 only. So I built
with TDM-GCC-64 with arch=x86.
And uh, apparently, moving or resizing a window causes a Visual C++
runtime exception in the GTK+ DLLs. This doesn't happen with trance or
renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
2015-03-07 10:21:47 +00:00
|
|
|
resetButton.setText("Reset").onActivate([&] {
|
|
|
|
if(MessageDialog("Are you sure you want to erase all mappings for this device?").setParent(*settingsManager).question() == 0) {
|
|
|
|
for(auto& mapping : activeDevice().mappings) mapping->unbind();
|
|
|
|
refreshMappings();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
eraseButton.setText("Erase").onActivate([&] {
|
|
|
|
if(auto mapping = mappingList.selected()) {
|
|
|
|
activeDevice().mappings[mapping->offset()]->unbind();
|
|
|
|
refreshMappings();
|
|
|
|
}
|
|
|
|
});
|
2015-03-02 09:13:28 +00:00
|
|
|
reloadPorts();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::activeEmulator() -> InputEmulator& {
|
|
|
|
return inputManager->emulators[emulatorList.selected()->offset()];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::activePort() -> InputPort& {
|
|
|
|
return activeEmulator().ports[portList.selected()->offset()];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::activeDevice() -> InputDevice& {
|
|
|
|
return activePort().devices[deviceList.selected()->offset()];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::reloadPorts() -> void {
|
|
|
|
portList.reset();
|
|
|
|
for(auto& port : activeEmulator().ports) {
|
|
|
|
portList.append(ComboButtonItem().setText(port.name));
|
|
|
|
}
|
|
|
|
reloadDevices();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::reloadDevices() -> void {
|
|
|
|
deviceList.reset();
|
|
|
|
for(auto& device : activePort().devices) {
|
|
|
|
deviceList.append(ComboButtonItem().setText(device.name));
|
|
|
|
}
|
|
|
|
reloadMappings();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::reloadMappings() -> void {
|
Update to v094r13 release.
byuu says:
This version polishes up the input dialogue (reset, erase, disable
button when item not focused, split device ID from mapping name), adds
color emulation toggle, and add dummy menu items for remaining features
(to be filled in later.)
Also, it now compiles cleanly on Windows with GTK.
I didn't test with TDM-GCC-32, because for god knows what reason, the
32-bit version ships with headers from Windows 95 OSR2 only. So I built
with TDM-GCC-64 with arch=x86.
And uh, apparently, moving or resizing a window causes a Visual C++
runtime exception in the GTK+ DLLs. This doesn't happen with trance or
renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
2015-03-07 10:21:47 +00:00
|
|
|
eraseButton.setEnabled(false);
|
2015-03-02 09:13:28 +00:00
|
|
|
mappingList.reset();
|
|
|
|
mappingList.append(ListViewColumn().setText("Name"));
|
Update to v094r13 release.
byuu says:
This version polishes up the input dialogue (reset, erase, disable
button when item not focused, split device ID from mapping name), adds
color emulation toggle, and add dummy menu items for remaining features
(to be filled in later.)
Also, it now compiles cleanly on Windows with GTK.
I didn't test with TDM-GCC-32, because for god knows what reason, the
32-bit version ships with headers from Windows 95 OSR2 only. So I built
with TDM-GCC-64 with arch=x86.
And uh, apparently, moving or resizing a window causes a Visual C++
runtime exception in the GTK+ DLLs. This doesn't happen with trance or
renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
2015-03-07 10:21:47 +00:00
|
|
|
mappingList.append(ListViewColumn().setText("Mapping").setWidth(~0));
|
|
|
|
mappingList.append(ListViewColumn().setText("Device"));
|
2015-03-02 09:13:28 +00:00
|
|
|
for(auto& mapping : activeDevice().mappings) {
|
|
|
|
mappingList.append(ListViewItem().setText(0, mapping->name));
|
|
|
|
}
|
|
|
|
refreshMappings();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::refreshMappings() -> void {
|
|
|
|
unsigned position = 0;
|
|
|
|
for(auto& mapping : activeDevice().mappings) {
|
Update to v094r13 release.
byuu says:
This version polishes up the input dialogue (reset, erase, disable
button when item not focused, split device ID from mapping name), adds
color emulation toggle, and add dummy menu items for remaining features
(to be filled in later.)
Also, it now compiles cleanly on Windows with GTK.
I didn't test with TDM-GCC-32, because for god knows what reason, the
32-bit version ships with headers from Windows 95 OSR2 only. So I built
with TDM-GCC-64 with arch=x86.
And uh, apparently, moving or resizing a window causes a Visual C++
runtime exception in the GTK+ DLLs. This doesn't happen with trance or
renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
2015-03-07 10:21:47 +00:00
|
|
|
auto path = mapping->assignment.split("/");
|
|
|
|
string assignment = path.takeLast();
|
|
|
|
string device = path(0);
|
|
|
|
mappingList.item(position++)->setText(1, assignment).setText(2, device);
|
2015-03-02 09:13:28 +00:00
|
|
|
}
|
|
|
|
mappingList.resizeColumns();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::assignMapping() -> void {
|
|
|
|
inputManager->poll(); //clear any pending events first
|
|
|
|
|
|
|
|
auto item = mappingList.selected();
|
|
|
|
activeMapping = activeDevice().mappings[item->offset()];
|
|
|
|
|
|
|
|
//settingsManager->layout.setEnabled(false);
|
|
|
|
settingsManager->statusBar.setText({"Press a key or button to map [", activeMapping->name, "] ..."});
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::inputEvent(HID::Device& device, unsigned group, unsigned input, int16 oldValue, int16 newValue) -> void {
|
|
|
|
if(!activeMapping) return;
|
|
|
|
if(!device.isKeyboard() || oldValue != 0 || newValue != 1) return;
|
|
|
|
|
|
|
|
if(activeMapping->bind(device, group, input, oldValue, newValue)) {
|
|
|
|
activeMapping = nullptr;
|
|
|
|
settingsManager->statusBar.setText("");
|
|
|
|
//settingsManager->layout.setEnabled(true); //todo: this isn't enabling child widgets properly (bug in hiro)
|
|
|
|
refreshMappings();
|
|
|
|
}
|
|
|
|
}
|