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(); });
|
2015-04-13 11:16:33 +00:00
|
|
|
mappingList.setHeaderVisible();
|
|
|
|
mappingList.onActivate([&] { assignMapping(); });
|
2015-05-23 05:29:18 +00:00
|
|
|
mappingList.onChange([&] { updateControls(); });
|
|
|
|
assignMouse1.setVisible(false).onActivate([&] { assignMouseInput(0); });
|
|
|
|
assignMouse2.setVisible(false).onActivate([&] { assignMouseInput(1); });
|
|
|
|
assignMouse3.setVisible(false).onActivate([&] { assignMouseInput(2); });
|
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-04-13 11:16:33 +00:00
|
|
|
|
2015-03-02 09:13:28 +00:00
|
|
|
reloadPorts();
|
|
|
|
}
|
|
|
|
|
2015-05-23 05:29:18 +00:00
|
|
|
auto InputSettings::updateControls() -> void {
|
|
|
|
eraseButton.setEnabled((bool)mappingList.selected());
|
|
|
|
assignMouse1.setVisible(false);
|
|
|
|
assignMouse2.setVisible(false);
|
|
|
|
assignMouse3.setVisible(false);
|
|
|
|
|
|
|
|
if(auto mapping = mappingList.selected()) {
|
|
|
|
auto input = activeDevice().mappings[mapping->offset()];
|
|
|
|
|
|
|
|
if(input->isDigital()) {
|
|
|
|
assignMouse1.setVisible().setText("Mouse Left");
|
|
|
|
assignMouse2.setVisible().setText("Mouse Middle");
|
|
|
|
assignMouse3.setVisible().setText("Mouse Right");
|
|
|
|
} else if(input->isAnalog()) {
|
|
|
|
assignMouse1.setVisible().setText("Mouse X-axis");
|
|
|
|
assignMouse2.setVisible().setText("Mouse Y-axis");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-02 09:13:28 +00:00
|
|
|
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));
|
2015-04-21 11:51:57 +00:00
|
|
|
mappingList.append(ListViewColumn().setText("Device").setForegroundColor({0, 128, 0}));
|
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) {
|
2015-05-23 05:29:18 +00:00
|
|
|
mappingList.item(position++)->setText(1, mapping->assignmentName()).setText(2, mapping->deviceName());
|
2015-03-02 09:13:28 +00:00
|
|
|
}
|
|
|
|
mappingList.resizeColumns();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto InputSettings::assignMapping() -> void {
|
|
|
|
inputManager->poll(); //clear any pending events first
|
|
|
|
|
Update to v094r22 release.
byuu says:
I fixed the hiro layout enable bug, so when you go to assign joypad
input, the window disables itself so your input doesn't mess with the
controls.
I added "reset" to the hotkeys, in case you feel like clearing all of
them at once.
I added device selection support and the ability to disable audio
synchronization (run > 60fps) to the ruby/OSS driver. This is exposed in
tomoko's configuration file.
I added checks to stringify so that assigning null char* strings to
nall::string won't cause crashes anymore (technically the crash was in
strlen(), which doesn't check for null strings, but whatever ... I'll do
the check myself.)
I hooked up BrowserDialog::folderSelect() to loading slotted media for
now. Tested it by loading a Game Boy game successfully through the Super
Game Boy. Definitely want to write a custom window for this though, that
looks more like the library dialog.
Remaining issues:
- finish slotted cart loader (SGB, BSX, ST)
- add DIP switch selection window (NSS) [I may end up punting this one
to v096]
- add more configuration panels (video, audio, timing)
2015-05-25 12:23:49 +00:00
|
|
|
if(auto mapping = mappingList.selected()) {
|
|
|
|
activeMapping = activeDevice().mappings[mapping->offset()];
|
|
|
|
settingsManager->layout.setEnabled(false);
|
|
|
|
settingsManager->statusBar.setText({"Press a key or button to map [", activeMapping->name, "] ..."});
|
|
|
|
}
|
2015-03-02 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2015-05-23 05:29:18 +00:00
|
|
|
auto InputSettings::assignMouseInput(unsigned id) -> void {
|
|
|
|
if(auto mouse = inputManager->findMouse()) {
|
|
|
|
if(auto mapping = mappingList.selected()) {
|
|
|
|
activeMapping = activeDevice().mappings[mapping->offset()];
|
|
|
|
|
|
|
|
if(activeMapping->isDigital()) {
|
2015-05-24 09:44:28 +00:00
|
|
|
return inputEvent(mouse, HID::Mouse::GroupID::Button, id, 0, 1, true);
|
2015-05-23 05:29:18 +00:00
|
|
|
} else if(activeMapping->isAnalog()) {
|
2015-05-24 09:44:28 +00:00
|
|
|
return inputEvent(mouse, HID::Mouse::GroupID::Axis, id, 0, +32767, true);
|
2015-05-23 05:29:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-24 09:44:28 +00:00
|
|
|
auto InputSettings::inputEvent(shared_pointer<HID::Device> device, unsigned group, unsigned input, int16 oldValue, int16 newValue, bool allowMouseInput) -> void {
|
2015-03-02 09:13:28 +00:00
|
|
|
if(!activeMapping) return;
|
2015-05-24 09:44:28 +00:00
|
|
|
if(device->isMouse() && !allowMouseInput) return;
|
2015-03-02 09:13:28 +00:00
|
|
|
|
|
|
|
if(activeMapping->bind(device, group, input, oldValue, newValue)) {
|
|
|
|
activeMapping = nullptr;
|
|
|
|
settingsManager->statusBar.setText("");
|
Update to v094r22 release.
byuu says:
I fixed the hiro layout enable bug, so when you go to assign joypad
input, the window disables itself so your input doesn't mess with the
controls.
I added "reset" to the hotkeys, in case you feel like clearing all of
them at once.
I added device selection support and the ability to disable audio
synchronization (run > 60fps) to the ruby/OSS driver. This is exposed in
tomoko's configuration file.
I added checks to stringify so that assigning null char* strings to
nall::string won't cause crashes anymore (technically the crash was in
strlen(), which doesn't check for null strings, but whatever ... I'll do
the check myself.)
I hooked up BrowserDialog::folderSelect() to loading slotted media for
now. Tested it by loading a Game Boy game successfully through the Super
Game Boy. Definitely want to write a custom window for this though, that
looks more like the library dialog.
Remaining issues:
- finish slotted cart loader (SGB, BSX, ST)
- add DIP switch selection window (NSS) [I may end up punting this one
to v096]
- add more configuration panels (video, audio, timing)
2015-05-25 12:23:49 +00:00
|
|
|
settingsManager->layout.setEnabled(true);
|
2015-03-02 09:13:28 +00:00
|
|
|
refreshMappings();
|
|
|
|
}
|
|
|
|
}
|