diff --git a/bsnes/phoenix/core/core.cpp b/bsnes/phoenix/core/core.cpp index 2ae68c1d..ddb868cb 100755 --- a/bsnes/phoenix/core/core.cpp +++ b/bsnes/phoenix/core/core.cpp @@ -102,6 +102,10 @@ Widget::Widget(pWidget &p) : state(*new State), p(p) { p.constructor(); } void Button::setText(const string &text) { state.text = text; return p.setText(text); } Button::Button() : state(*new State), base_from_member(*new pButton(*this)), Widget(base_from_member::value), p(base_from_member::value) { p.constructor(); } +uint32_t* Canvas::buffer() { return p.buffer(); } +void Canvas::update() { return p.update(); } +Canvas::Canvas() : base_from_member(*new pCanvas(*this)), Widget(base_from_member::value), p(base_from_member::value) { p.constructor(); } + bool CheckBox::checked() { return p.checked(); } void CheckBox::setChecked(bool checked) { state.checked = checked; return p.setChecked(checked); } void CheckBox::setText(const string &text) { state.text = text; return p.setText(text); } diff --git a/bsnes/phoenix/core/core.hpp b/bsnes/phoenix/core/core.hpp index d763e8ad..2f087b42 100755 --- a/bsnes/phoenix/core/core.hpp +++ b/bsnes/phoenix/core/core.hpp @@ -16,6 +16,7 @@ struct pRadioItem; struct pLayout; struct pWidget; struct pButton; +struct pCanvas; struct pCheckBox; struct pComboBox; struct pHexEdit; @@ -235,6 +236,14 @@ struct Button : private nall::base_from_member, Widget { pButton &p; }; +struct Canvas : private nall::base_from_member, Widget { + uint32_t* buffer(); + void update(); + + Canvas(); + pCanvas &p; +}; + struct CheckBox : private nall::base_from_member, Widget { nall::function onTick; diff --git a/bsnes/phoenix/gtk/gtk.cpp b/bsnes/phoenix/gtk/gtk.cpp index 5974fd6e..c711d7a2 100755 --- a/bsnes/phoenix/gtk/gtk.cpp +++ b/bsnes/phoenix/gtk/gtk.cpp @@ -14,6 +14,7 @@ #include "widget/widget.cpp" #include "widget/button.cpp" +#include "widget/canvas.cpp" #include "widget/check-box.cpp" #include "widget/combo-box.cpp" #include "widget/hex-edit.cpp" diff --git a/bsnes/phoenix/gtk/gtk.hpp b/bsnes/phoenix/gtk/gtk.hpp index c2df6619..f6abacce 100755 --- a/bsnes/phoenix/gtk/gtk.hpp +++ b/bsnes/phoenix/gtk/gtk.hpp @@ -173,7 +173,7 @@ struct pWidget : public pObject { void setEnabled(bool enabled); virtual void setFocused(); virtual void setFont(Font &font); - void setGeometry(const Geometry &geometry); + virtual void setGeometry(const Geometry &geometry); void setVisible(bool visible); pWidget(Widget &widget) : widget(widget) {} @@ -190,6 +190,20 @@ struct pButton : public pWidget { void constructor(); }; +struct pCanvas : public pWidget { + Canvas &canvas; + uint32_t *bufferRGB; + uint32_t *bufferBGR; + + uint32_t* buffer(); + void setGeometry(const Geometry &geometry); + void update(); + + pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} + void constructor(); + void redraw(); +}; + struct pCheckBox : public pWidget { CheckBox &checkBox; diff --git a/bsnes/phoenix/qt/qt.cpp b/bsnes/phoenix/qt/qt.cpp index 9f5f4e7a..d971d04b 100755 --- a/bsnes/phoenix/qt/qt.cpp +++ b/bsnes/phoenix/qt/qt.cpp @@ -15,6 +15,7 @@ #include "widget/widget.cpp" #include "widget/button.cpp" +#include "widget/canvas.cpp" #include "widget/check-box.cpp" #include "widget/combo-box.cpp" #include "widget/hex-edit.cpp" diff --git a/bsnes/phoenix/qt/qt.moc b/bsnes/phoenix/qt/qt.moc index 3d6067d5..5f8602a4 100755 --- a/bsnes/phoenix/qt/qt.moc +++ b/bsnes/phoenix/qt/qt.moc @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'qt.moc.hpp' ** -** Created: Wed Mar 23 03:03:27 2011 +** Created: Wed Mar 23 16:17:23 2011 ** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) ** ** WARNING! All changes made in this file will be lost! @@ -311,6 +311,57 @@ int pButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) } return _id; } +static const uint qt_meta_data_pCanvas[] = { + + // content: + 5, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + 0 // eod +}; + +static const char qt_meta_stringdata_pCanvas[] = { + "pCanvas\0" +}; + +const QMetaObject pCanvas::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_pCanvas, + qt_meta_data_pCanvas, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &pCanvas::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *pCanvas::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *pCanvas::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_pCanvas)) + return static_cast(const_cast< pCanvas*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pCanvas*>(this)); + return QObject::qt_metacast(_clname); +} + +int pCanvas::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} static const uint qt_meta_data_pCheckBox[] = { // content: diff --git a/bsnes/phoenix/qt/qt.moc.hpp b/bsnes/phoenix/qt/qt.moc.hpp index 8b1e71a7..d7466d6b 100755 --- a/bsnes/phoenix/qt/qt.moc.hpp +++ b/bsnes/phoenix/qt/qt.moc.hpp @@ -200,7 +200,7 @@ struct pWidget : public pObject { void setEnabled(bool enabled); void setFocused(); void setFont(Font &font); - void setGeometry(const Geometry &geometry); + virtual void setGeometry(const Geometry &geometry); void setVisible(bool visible); pWidget(Widget &widget) : widget(widget) {} @@ -224,6 +224,28 @@ public slots: void onTick(); }; +struct pCanvas : public QObject, public pWidget { + Q_OBJECT + +public: + Canvas &canvas; + QImage *qtImage; + struct QtCanvas : public QWidget { + pCanvas &self; + void paintEvent(QPaintEvent*); + QtCanvas(pCanvas &self); + } *qtCanvas; + + uint32_t* buffer(); + void setGeometry(const Geometry &geometry); + void update(); + + pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} + void constructor(); + +public slots: +}; + struct pCheckBox : public QObject, public pWidget { Q_OBJECT diff --git a/bsnes/phoenix/windows/windows.cpp b/bsnes/phoenix/windows/windows.cpp index 8b737e07..4c3596a4 100755 --- a/bsnes/phoenix/windows/windows.cpp +++ b/bsnes/phoenix/windows/windows.cpp @@ -14,6 +14,7 @@ #include "widget/widget.cpp" #include "widget/button.cpp" +#include "widget/canvas.cpp" #include "widget/check-box.cpp" #include "widget/combo-box.cpp" #include "widget/hex-edit.cpp" @@ -183,6 +184,18 @@ void pOS::initialize() { wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(0, IDI_APPLICATION); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Canvas_windowProc; + wc.lpszClassName = L"phoenix_canvas"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); diff --git a/bsnes/phoenix/windows/windows.hpp b/bsnes/phoenix/windows/windows.hpp index 2d1aa6f3..70933131 100755 --- a/bsnes/phoenix/windows/windows.hpp +++ b/bsnes/phoenix/windows/windows.hpp @@ -182,6 +182,19 @@ struct pButton : public pWidget { void setParent(Window &parent); }; +struct pCanvas : public pWidget { + Canvas &canvas; + uint32_t *bufferRGB; + + uint32_t* buffer(); + void setGeometry(const Geometry &geometry); + void update(); + + pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} + void constructor(); + void setParent(Window &parent); +}; + struct pCheckBox : public pWidget { CheckBox &checkBox; diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index 1b514fc2..383acd82 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,7 +1,7 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "077.03"; + static const char Version[] = "077.04"; static const unsigned SerializerVersion = 19; } } diff --git a/bsnes/ui/base.hpp b/bsnes/ui/base.hpp index 449c1cea..cdcdc615 100755 --- a/bsnes/ui/base.hpp +++ b/bsnes/ui/base.hpp @@ -55,23 +55,3 @@ private: }; extern Application application; - -struct Style { - enum : unsigned { - #if defined(PLATFORM_WIN) - ButtonHeight = 25, - CheckBoxHeight = 15, - ComboBoxHeight = 22, - LabelHeight = 15, - SliderHeight = 25, - LineEditHeight = 22, - #else - ButtonHeight = 25, - CheckBoxHeight = 15, - ComboBoxHeight = 22, - LabelHeight = 15, - SliderHeight = 22, - LineEditHeight = 22, - #endif - }; -}; diff --git a/bsnes/ui/debugger/console.cpp b/bsnes/ui/debugger/console.cpp index fd2d3111..f0fb71d1 100755 --- a/bsnes/ui/debugger/console.cpp +++ b/bsnes/ui/debugger/console.cpp @@ -23,9 +23,8 @@ void Console::create() { controlLayout.append(spacer, 120, ~0 ); controlLayout.append(clearConsole, 120, 0 ); layout.append(controlLayout ); - - setGeometry({ 0, 0, layout.minimumGeometry().width + 585, 350 }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width + 585, 350 }); onClose = []() { debugger.showConsole.setChecked(false); diff --git a/bsnes/ui/debugger/cpu/debugger.cpp b/bsnes/ui/debugger/cpu/debugger.cpp index 84a67fd0..bcdf8392 100755 --- a/bsnes/ui/debugger/cpu/debugger.cpp +++ b/bsnes/ui/debugger/cpu/debugger.cpp @@ -18,9 +18,8 @@ void CPUDebugger::create() { controlLayout.append(proceed, 80, 0 ); controlLayout.append(spacer, 80, ~0 ); layout.append(controlLayout ); - - setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); onClose = []() { debugger.showCPUDebugger.setChecked(false); diff --git a/bsnes/ui/debugger/debugger.cpp b/bsnes/ui/debugger/debugger.cpp index 301d4af4..7fe9ce51 100755 --- a/bsnes/ui/debugger/debugger.cpp +++ b/bsnes/ui/debugger/debugger.cpp @@ -35,9 +35,8 @@ void Debugger::create() { layout.append(showSMPDebugger, ~0, 0); layout.append(showBreakpointEditor, ~0, 0); layout.append(showMemoryEditor, ~0, 0); - - setGeometry({ 0, 0, layout.minimumGeometry().width, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width, layout.minimumGeometry().height }); //windows shown by default showConsole.setChecked(); diff --git a/bsnes/ui/debugger/smp/debugger.cpp b/bsnes/ui/debugger/smp/debugger.cpp index baa63c6c..2eb98599 100755 --- a/bsnes/ui/debugger/smp/debugger.cpp +++ b/bsnes/ui/debugger/smp/debugger.cpp @@ -18,9 +18,8 @@ void SMPDebugger::create() { controlLayout.append(proceed, 80, 0 ); controlLayout.append(spacer, 80, ~0 ); layout.append(controlLayout ); - - setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); onClose = []() { debugger.showSMPDebugger.setChecked(false); diff --git a/bsnes/ui/debugger/tools/breakpoint-editor.cpp b/bsnes/ui/debugger/tools/breakpoint-editor.cpp index ebc4c73c..edffcc0d 100755 --- a/bsnes/ui/debugger/tools/breakpoint-editor.cpp +++ b/bsnes/ui/debugger/tools/breakpoint-editor.cpp @@ -26,11 +26,11 @@ void BreakpointEditor::create() { breakpointLayout[n].append(valueBox[n], 30, 0, 5); breakpointLayout[n].append(typeBox[n], 0, 0, 5); breakpointLayout[n].append(sourceBox[n], 0, 0 ); - layout.append(breakpointLayout[n], 5); + layout.append(breakpointLayout[n], n < Breakpoints - 1 ? 5 : 0); } - setGeometry({ 0, 0, layout.minimumGeometry().width, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width, layout.minimumGeometry().height }); onClose = []() { debugger.showBreakpointEditor.setChecked(false); diff --git a/bsnes/ui/debugger/tools/memory-editor.cpp b/bsnes/ui/debugger/tools/memory-editor.cpp index ce580196..ed92d9a9 100755 --- a/bsnes/ui/debugger/tools/memory-editor.cpp +++ b/bsnes/ui/debugger/tools/memory-editor.cpp @@ -21,9 +21,8 @@ void MemoryEditor::create() { controlLayout.append(refreshButton, 80, 0 ); controlLayout.append(spacer, 80, ~0 ); layout.append(controlLayout ); - - setGeometry({ 0, 0, layout.minimumGeometry().width + 475, 230 }); append(layout); + setGeometry({ 0, 0, layout.minimumGeometry().width + 475, 230 }); onClose = []() { debugger.showMemoryEditor.setChecked(false); diff --git a/bsnes/ui/general/file-browser.cpp b/bsnes/ui/general/file-browser.cpp index 79fbad34..6482cf1f 100755 --- a/bsnes/ui/general/file-browser.cpp +++ b/bsnes/ui/general/file-browser.cpp @@ -12,9 +12,8 @@ void FileBrowser::create() { pathLayout.append(upButton, 25, 25 ); layout.append(pathLayout, 5); layout.append(contentsBox, ~0, ~0 ); - - setGeometry({ 0, 0, 640, layout.minimumGeometry().height + 400 }); append(layout); + setGeometry({ 0, 0, 640, layout.minimumGeometry().height + 400 }); pathBox.onActivate = []() { string path = fileBrowser.pathBox.text(); @@ -31,11 +30,20 @@ void FileBrowser::create() { void FileBrowser::fileOpen(FileBrowser::Mode requestedMode, function requestedCallback) { callback = requestedCallback; -//if(mode == requestedMode && folder == config.path.current) { -// setVisible(); -// contentsBox.setFocused(); -// return; -//} + switch(requestedMode) { + case Mode::Cartridge: folderPath = "sfc"; break; + case Mode::Satellaview: folderPath = "bs"; break; + case Mode::SufamiTurbo: folderPath = "st"; break; + case Mode::GameBoy: folderPath = "gb"; break; + } + string activePath = path.load(folderPath); + + //if path has not changed, do not reload list; this will preserve previously selected file + if(mode == requestedMode && folder == activePath) { + setVisible(); + contentsBox.setFocused(); + return; + } setVisible(false); filters.reset(); @@ -43,45 +51,32 @@ void FileBrowser::fileOpen(FileBrowser::Mode requestedMode, function callback); void create(); diff --git a/bsnes/ui/general/slot-loader.cpp b/bsnes/ui/general/slot-loader.cpp index 6230a18f..db8174c5 100755 --- a/bsnes/ui/general/slot-loader.cpp +++ b/bsnes/ui/general/slot-loader.cpp @@ -22,9 +22,8 @@ void SingleSlotLoader::create() { controlLayout.append(spacer, ~0, 0 ); controlLayout.append(okButton, 80, 0 ); layout.append(controlLayout); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); baseBrowse.onTick = []() { fileBrowser.fileOpen(FileBrowser::Mode::Cartridge, [](string filename) { @@ -120,9 +119,8 @@ void DoubleSlotLoader::create() { controlLayout.append(spacer, ~0, 0 ); controlLayout.append(okButton, 80, 0 ); layout.append(controlLayout); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); baseBrowse.onTick = []() { fileBrowser.fileOpen(FileBrowser::Mode::Cartridge, [](string filename) { diff --git a/bsnes/ui/input/hotkeys.cpp b/bsnes/ui/input/hotkeys.cpp index 401a7c38..fb716545 100755 --- a/bsnes/ui/input/hotkeys.cpp +++ b/bsnes/ui/input/hotkeys.cpp @@ -9,31 +9,31 @@ void InputMapper::poll_hotkeys(unsigned scancode, int16_t value) { if(mainWindow.focused() == false) return; //save states - if(scancode == keyboard(0)[Keyboard::F5]) { + if(scancode == hotkeysGeneral.stateSave.scancode) { utility.saveState(activeSlot); } - if(scancode == keyboard(0)[Keyboard::F7]) { + if(scancode == hotkeysGeneral.stateLoad.scancode) { utility.loadState(activeSlot); } - if(scancode == keyboard(0)[Keyboard::F6]) { + if(scancode == hotkeysGeneral.stateDecrement.scancode) { activeSlot = (activeSlot == 1 ? 5 : activeSlot - 1); utility.showMessage({ "Slot ", activeSlot, " selected" }); } - if(scancode == keyboard(0)[Keyboard::F8]) { + if(scancode == hotkeysGeneral.stateIncrement.scancode) { activeSlot = (activeSlot == 5 ? 1 : activeSlot + 1); utility.showMessage({ "Slot ", activeSlot, " selected" }); } //fullscreen - if(scancode == keyboard(0)[Keyboard::F11]) { + if(scancode == hotkeysGeneral.fullscreenToggle.scancode) { utility.setFullscreen(!utility.fullscreen); } //mouse capture - if(scancode == keyboard(0)[Keyboard::F12]) { + if(scancode == hotkeysGeneral.mouseCaptureToggle.scancode) { if(input.acquired() == false) { input.acquire(); } else { @@ -42,12 +42,12 @@ void InputMapper::poll_hotkeys(unsigned scancode, int16_t value) { } //pause - if(scancode == keyboard(0)[Keyboard::P]) { + if(scancode == hotkeysGeneral.pauseToggle.scancode) { application.pause = !application.pause; } //fast forward - if(scancode == keyboard(0)[Keyboard::Tilde]) { + if(scancode == hotkeysGeneral.fastForward.scancode) { videoSync = config.video.synchronize; audioSync = config.audio.synchronize; video.set(Video::Synchronize, config.video.synchronize = false); @@ -56,12 +56,22 @@ void InputMapper::poll_hotkeys(unsigned scancode, int16_t value) { SNES::ppu.set_frameskip(9); #endif } + + //power cycle + if(scancode == hotkeysGeneral.power.scancode) { + mainWindow.systemPower.onTick(); + } + + //reset + if(scancode == hotkeysGeneral.reset.scancode) { + mainWindow.systemReset.onTick(); + } } else { //key released if(mainWindow.focused() == false) return; //fast forward - if(scancode == keyboard(0)[Keyboard::Tilde]) { + if(scancode == hotkeysGeneral.fastForward.scancode) { video.set(Video::Synchronize, config.video.synchronize = videoSync); audio.set(Audio::Synchronize, config.audio.synchronize = audioSync); #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) @@ -70,3 +80,46 @@ void InputMapper::poll_hotkeys(unsigned scancode, int16_t value) { } } } + +void InputMapper::HotkeysGeneral::create(const char *deviceName, const char *configName) { + name = deviceName; + + stateSave.name = "Save State"; + stateLoad.name = "Load State"; + stateDecrement.name = "Decrement State"; + stateIncrement.name = "Increment State"; + fullscreenToggle.name = "Fullscreen"; + mouseCaptureToggle.name = "Mouse Capture"; + pauseToggle.name = "Pause Emulation"; + fastForward.name = "Fast-Forward"; + power.name = "Power Cycle"; + reset.name = "Reset"; + + append(&stateSave); + append(&stateLoad); + append(&stateDecrement); + append(&stateIncrement); + append(&fullscreenToggle); + append(&mouseCaptureToggle); + append(&pauseToggle); + append(&fastForward); + append(&power); + append(&reset); + + config.attach(stateSave.mapping = "KB0::F5", string("input.", configName, ".stateSave")); + config.attach(stateLoad.mapping = "KB0::F7", string("input.", configName, ".stateLoad")); + config.attach(stateDecrement.mapping = "KB0::F6", string("input.", configName, ".stateDecrement")); + config.attach(stateIncrement.mapping = "KB0::F8", string("input.", configName, ".stateIncrement")); + config.attach(fullscreenToggle.mapping = "KB0::F11", string("input.", configName, ".fullscreenToggle")); + config.attach(mouseCaptureToggle.mapping = "KB0::F12", string("input.", configName, ".mouseCaptureToggle")); + config.attach(pauseToggle.mapping = "KB0::P", string("input.", configName, ".pauseToggle")); + config.attach(fastForward.mapping = "KB0::Tilde", string("input.", configName, ".fastForward")); + config.attach(power.mapping = "", string("input.", configName, ".power")); + config.attach(reset.mapping = "", string("input.", configName, ".reset")); +} + +void InputMapper::create_hotkeys() { + hotkeys.name = "Hotkeys"; + hotkeysGeneral.create("General", "hotkeys.general"); + hotkeys.append(&hotkeysGeneral); +} diff --git a/bsnes/ui/input/input.cpp b/bsnes/ui/input/input.cpp index 08746047..ce3b5367 100755 --- a/bsnes/ui/input/input.cpp +++ b/bsnes/ui/input/input.cpp @@ -227,6 +227,8 @@ void InputMapper::create() { port2.append(&port2.superScope); port2.append(&port2.justifierA); port2.append(&port2.justifierB); + + create_hotkeys(); } void InputMapper::bind() { @@ -238,6 +240,10 @@ void InputMapper::bind() { Controller &controller = *port2[i]; for(unsigned n = 0; n < controller.size(); n++) controller[n]->bind(); } + for(unsigned i = 0; i < hotkeys.size(); i++) { + Controller &controller = *hotkeys[i]; + for(unsigned n = 0; n < controller.size(); n++) controller[n]->bind(); + } } void InputMapper::poll() { diff --git a/bsnes/ui/input/input.hpp b/bsnes/ui/input/input.hpp index d3dd6d20..d7b66c07 100755 --- a/bsnes/ui/input/input.hpp +++ b/bsnes/ui/input/input.hpp @@ -1,4 +1,7 @@ struct InputMapper { + int16_t state[2][Scancode::Limit]; + bool activeState; + struct AbstractInput { enum class Type : unsigned { Button, MouseAxis, MouseButton, HatUp, HatDown, HatLeft, HatRight, AxisLo, AxisHi } type; string name; @@ -73,13 +76,13 @@ struct InputMapper { Justifier justifierB; } port2; - int16_t state[2][Scancode::Limit]; - bool activeState; + #include "hotkeys.hpp" void create(); void bind(); void poll(); int16_t poll(bool port, SNES::Input::Device device, unsigned index, unsigned id); + void create_hotkeys(); void poll_hotkeys(unsigned scancode, int16_t value); int16_t value(unsigned scancode); }; diff --git a/bsnes/ui/settings/advanced.cpp b/bsnes/ui/settings/advanced.cpp index f6c61b29..50ab774d 100755 --- a/bsnes/ui/settings/advanced.cpp +++ b/bsnes/ui/settings/advanced.cpp @@ -33,9 +33,8 @@ void AdvancedSettings::create() { focusPolicyLayout.append(focusPolicyIgnore, ~0, 0, 5); focusPolicyLayout.append(focusPolicyAllow, ~0, 0); layout.append(focusPolicyLayout); - - setGeometry({ 0, 0, 640, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, 640, layout.minimumGeometry().height }); lstring list; diff --git a/bsnes/ui/settings/audio.cpp b/bsnes/ui/settings/audio.cpp index 679e77a6..a6a1d802 100755 --- a/bsnes/ui/settings/audio.cpp +++ b/bsnes/ui/settings/audio.cpp @@ -18,9 +18,8 @@ void AudioSettings::create() { frequencyLayout.append(frequencyValue, 60, 0); frequencyLayout.append(frequencySlider, ~0, 0); layout.append(frequencyLayout); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); volumeSlider.onChange = []() { config.audio.volume = audioSettings.volumeSlider.position(); diff --git a/bsnes/ui/settings/input.cpp b/bsnes/ui/settings/input.cpp index 077ee6f7..f5662a4a 100755 --- a/bsnes/ui/settings/input.cpp +++ b/bsnes/ui/settings/input.cpp @@ -13,6 +13,7 @@ void InputSettings::create() { portLabel.setText("Port:"); portBox.append(inputMapper.port1.name); portBox.append(inputMapper.port2.name); + portBox.append(inputMapper.hotkeys.name); deviceLabel.setText("Device:"); mappingList.setHeaderText("Name", "Mapping"); mappingList.setHeaderVisible(true); @@ -47,10 +48,10 @@ void InputSettings::create() { buttonControlLayout.append(mouseRight, 100, 0, 5); buttonLayout.append(buttonControlLayout); - setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); append(axisLayout); append(buttonLayout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); axisLayout.setVisible(false); buttonLayout.setVisible(false); @@ -74,9 +75,9 @@ void InputSettings::create() { void InputSettings::portChanged() { deviceBox.reset(); InputMapper::ControllerPort &port = ( - portBox.selection() == 0 - ? (InputMapper::ControllerPort&)inputMapper.port1 - : (InputMapper::ControllerPort&)inputMapper.port2 + portBox.selection() == 0 ? (InputMapper::ControllerPort&)inputMapper.port1 : + portBox.selection() == 1 ? (InputMapper::ControllerPort&)inputMapper.port2 : + /*portBox.selection() == 2*/ (InputMapper::ControllerPort&)inputMapper.hotkeys ); for(unsigned i = 0; i < port.size(); i++) deviceBox.append(port[i]->name); @@ -86,9 +87,9 @@ void InputSettings::portChanged() { void InputSettings::deviceChanged() { mappingList.reset(); InputMapper::ControllerPort &port = ( - portBox.selection() == 0 - ? (InputMapper::ControllerPort&)inputMapper.port1 - : (InputMapper::ControllerPort&)inputMapper.port2 + portBox.selection() == 0 ? (InputMapper::ControllerPort&)inputMapper.port1 : + portBox.selection() == 1 ? (InputMapper::ControllerPort&)inputMapper.port2 : + /*portBox.selection() == 2*/ (InputMapper::ControllerPort&)inputMapper.hotkeys ); InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()]; @@ -102,9 +103,9 @@ void InputSettings::deviceChanged() { void InputSettings::mappingChanged() { InputMapper::ControllerPort &port = ( - portBox.selection() == 0 - ? (InputMapper::ControllerPort&)inputMapper.port1 - : (InputMapper::ControllerPort&)inputMapper.port2 + portBox.selection() == 0 ? (InputMapper::ControllerPort&)inputMapper.port1 : + portBox.selection() == 1 ? (InputMapper::ControllerPort&)inputMapper.port2 : + /*portBox.selection() == 2*/ (InputMapper::ControllerPort&)inputMapper.hotkeys ); InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()]; @@ -119,9 +120,9 @@ void InputSettings::mappingChanged() { void InputSettings::assignInput() { if(mappingList.selected() == false) return; InputMapper::ControllerPort &port = ( - portBox.selection() == 0 - ? (InputMapper::ControllerPort&)inputMapper.port1 - : (InputMapper::ControllerPort&)inputMapper.port2 + portBox.selection() == 0 ? (InputMapper::ControllerPort&)inputMapper.port1 : + portBox.selection() == 1 ? (InputMapper::ControllerPort&)inputMapper.port2 : + /*portBox.selection() == 2*/ (InputMapper::ControllerPort&)inputMapper.hotkeys ); InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()]; @@ -143,9 +144,9 @@ void InputSettings::assignInput() { void InputSettings::clearInput() { if(mappingList.selected() == false) return; InputMapper::ControllerPort &port = ( - portBox.selection() == 0 - ? (InputMapper::ControllerPort&)inputMapper.port1 - : (InputMapper::ControllerPort&)inputMapper.port2 + portBox.selection() == 0 ? (InputMapper::ControllerPort&)inputMapper.port1 : + portBox.selection() == 1 ? (InputMapper::ControllerPort&)inputMapper.port2 : + /*portBox.selection() == 2*/ (InputMapper::ControllerPort&)inputMapper.hotkeys ); InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()]; diff --git a/bsnes/ui/settings/video.cpp b/bsnes/ui/settings/video.cpp index 605223e4..3aa1f042 100755 --- a/bsnes/ui/settings/video.cpp +++ b/bsnes/ui/settings/video.cpp @@ -40,9 +40,8 @@ void VideoSettings::create() { fullscreenLayout.append(fullscreenScale, ~0, 0, 5); fullscreenLayout.append(fullscreenStretch, ~0, 0 ); layout.append(fullscreenLayout); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); brightnessSlider.setPosition(config.video.brightness); brightnessValue.setText({ config.video.brightness, "%" }); diff --git a/bsnes/ui/tools/cheat-database.cpp b/bsnes/ui/tools/cheat-database.cpp index 0ab13654..cc3722d6 100755 --- a/bsnes/ui/tools/cheat-database.cpp +++ b/bsnes/ui/tools/cheat-database.cpp @@ -15,8 +15,8 @@ void CheatDatabase::create() { controlLayout.append(spacerWidget, ~0, 0 ); controlLayout.append(okButton, 80, 0 ); layout.append(controlLayout ); - setGeometry({ 0, 0, 600, layout.minimumGeometry().height + 350 }); append(layout); + setGeometry({ 0, 0, 600, layout.minimumGeometry().height + 350 }); selectAllButton.onTick = [this]() { foreach(item, this->listData, n) this->listView.setChecked(n, true); diff --git a/bsnes/ui/tools/cheat-editor.cpp b/bsnes/ui/tools/cheat-editor.cpp index 5e580728..ee8edc07 100755 --- a/bsnes/ui/tools/cheat-editor.cpp +++ b/bsnes/ui/tools/cheat-editor.cpp @@ -104,9 +104,8 @@ void CheatEditor::create() { controlLayout.append(clearAllButton, 80, 0, 5); controlLayout.append(clearButton, 80, 0 ); layout.append(controlLayout); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); synchronize(); diff --git a/bsnes/ui/tools/state-manager.cpp b/bsnes/ui/tools/state-manager.cpp index e8578e10..e226ae58 100755 --- a/bsnes/ui/tools/state-manager.cpp +++ b/bsnes/ui/tools/state-manager.cpp @@ -21,9 +21,8 @@ void StateManager::create() { controlLayout.append(saveButton, 80, 0, 5); controlLayout.append(eraseButton, 80, 0 ); layout.append(controlLayout ); - - setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); synchronize();