diff options
| author | 2025-07-08 01:21:53 +0200 | |
|---|---|---|
| committer | 2025-07-08 01:22:03 +0200 | |
| commit | b93a6afad7f0e4a7f8fdb01159b13568afe330a5 (patch) | |
| tree | 94cc4d4a25250ae5a80ea5def8792d6806d94048 | |
| parent | 514b5c1268364ce90f500afd3227e55516b16795 (diff) | |
viewgfx: add shift/ctrl/alt modifier keys to some controls
| -rw-r--r-- | docs/source/usingmame/defaultkeys.rst | 31 | ||||
| -rw-r--r-- | src/frontend/mame/ui/viewgfx.cpp | 63 |
2 files changed, 53 insertions, 41 deletions
diff --git a/docs/source/usingmame/defaultkeys.rst b/docs/source/usingmame/defaultkeys.rst index 947a4ce5d00..edce72acd20 100644 --- a/docs/source/usingmame/defaultkeys.rst +++ b/docs/source/usingmame/defaultkeys.rst @@ -35,22 +35,22 @@ and saving/loading save states. If you are running with -debug, this key sends a ‘break’ in emulation. - When a slider control is visible, you can use the following keys to control - it: + When a slider control is visible, the keyboard controls are the same as + in the Slider Controls menu: * **Up** - select previous parameter to modify. * **Down** - select next parameter to modify. * **Left** - decrease the value of the selected parameter. * **Right** - increase the value of the selected parameter. - * **Enter** - reset parameter value to its default. + * **Delete** - reset parameter value to its default. + * **Alt+Left** - decrease the value by the largest amount. * **Control+Left** - decrease the value by 10x. * **Shift+Left** - decrease the value by 0.1x. - * **Alt+Left** - decrease the value by the smallest amount. + * **Shift+Alt+Left** - decrease the value by the smallest amount. + * **Alt+Right** - increase the value by the largest amount. * **Control+Right** - increase the value by 10x. * **Shift+Right** - increase the value by 0.1x. - * **Alt+Right** - increase the value by the smallest amount. - * **End** - temporarily hide the On Screen Display. - * **Home** - bring the On Screen Display back after hiding it. + * **Shift+Alt+Right** - increase the value by the smallest amount. **Up Arrow** Highlight previous UI menu option. **Down Arrow** @@ -88,14 +88,16 @@ and saving/loading save states. Use the Enter key to switch between the three modes (palette, graphics, and tilemaps). - Press F4 again to turn off the display. + Press F4 again to turn off the viewer. The key controls in each mode vary slightly: Palette/colortable mode: * **[** **]** - switch between palette devices. * **Up**/**Down** - scroll up/down one line at a time. - * **Page Up**/**Page Down** - scroll up/down one page at a time. + * **Shift+Up**/**Down** - scroll right/left one cell at a time. + * **Page Up**/**Page Down** - scroll up/down one page at a time (hold + Control or Alt to scroll 10 or 100 pages). * **Home**/**End** - move to top/bottom of list. * **-**/**+** - increase/decrease the number of colors per row. * **0** - restore the default number of colors per row. @@ -105,12 +107,15 @@ and saving/loading save states. * **[** **]** - switch between different graphics sets. * **Up**/**Down** - scroll up/down one line at a time. - * **Page Up**/**Page Down** - scroll up/down one page at a time. + * **Shift+Up**/**Down** - scroll right/left one cell at a time. + * **Page Up**/**Page Down** - scroll up/down one page at a time (hold + Control or Alt to scroll 10 or 100 pages). * **Home**/**End** - move to top/bottom of list. - * **Left**/**Right** - change color displayed. + * **Left**/**Right** - change color displayed (hold Control or Alt for + wider control). * **R** - rotate tiles 90 degrees clockwise. - * **-**/**+** - increase/decrease the number of tiles per row (hold Shift to - restrict to integer scale factors). + * **-**/**+** - increase/decrease the number of tiles per row (hold Shift + to restrict to integer scale factors). * **0** - restore the default number of tiles per row (hold Shift to restrict to integer scale factors). * **Enter** - switch to tilemap viewer. diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp index 1d772da645d..969bad81fd5 100644 --- a/src/frontend/mame/ui/viewgfx.cpp +++ b/src/frontend/mame/ui/viewgfx.cpp @@ -259,20 +259,17 @@ private: public: struct setinfo { - void next_color() noexcept + // step must be 2^x for these + void next_color(int step) noexcept { - if ((m_color_count - 1) > m_color) - ++m_color; - else - m_color = 0U; + m_color = (((m_color & ~(step - 1)) + step) % m_color_count) & ~(step - 1); } - void prev_color() noexcept + void prev_color(int step) noexcept { - if (m_color) - --m_color; - else - m_color = m_color_count - 1; + const int minuend = (m_color > 0) ? m_color : m_color_count; + const int step2 = minuend & (step - 1); + m_color = minuend - (step2 ? step2 : step); } device_palette_interface *m_palette = nullptr; @@ -539,7 +536,7 @@ private: } } - bool prev_catagory() noexcept + bool prev_category() noexcept { if (!m_flags) { @@ -737,14 +734,18 @@ void gfx_viewer::palette::handle_keys(running_machine &machine) int const screencount = rowcount * rowcount; // handle keyboard navigation + bool const alt_pressed = machine.input().code_pressed(KEYCODE_LALT) || machine.input().code_pressed(KEYCODE_RALT); + bool const ctrl_pressed = machine.input().code_pressed(KEYCODE_LCONTROL) || machine.input().code_pressed(KEYCODE_RCONTROL); + bool const shift_pressed = machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT); + if (input.pressed_repeat(IPT_UI_UP, 4)) - m_offset -= rowcount; + m_offset -= shift_pressed ? 1 : rowcount; if (input.pressed_repeat(IPT_UI_DOWN, 4)) - m_offset += rowcount; + m_offset += shift_pressed ? 1 : rowcount; if (input.pressed_repeat(IPT_UI_PAGE_UP, 6)) - m_offset -= screencount; + m_offset -= screencount * (alt_pressed ? 100 : ctrl_pressed ? 10 : 1); if (input.pressed_repeat(IPT_UI_PAGE_DOWN, 6)) - m_offset += screencount; + m_offset += screencount * (alt_pressed ? 100 : ctrl_pressed ? 10 : 1); if (input.pressed_repeat(IPT_UI_HOME, 4)) m_offset = 0; if (input.pressed_repeat(IPT_UI_END, 4)) @@ -760,8 +761,11 @@ void gfx_viewer::palette::handle_keys(running_machine &machine) bool gfx_viewer::gfxset::handle_keys(running_machine &machine, int xcells, int ycells) { - auto &input = machine.ui_input(); + bool const alt_pressed = machine.input().code_pressed(KEYCODE_LALT) || machine.input().code_pressed(KEYCODE_RALT); + bool const ctrl_pressed = machine.input().code_pressed(KEYCODE_LCONTROL) || machine.input().code_pressed(KEYCODE_RCONTROL); bool const shift_pressed = machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT); + + auto &input = machine.ui_input(); bool result = false; // handle previous/next group @@ -802,24 +806,27 @@ bool gfx_viewer::gfxset::handle_keys(running_machine &machine, int xcells, int y } // handle navigation within the cells (up,down,pgup,pgdown) + int const total = gfx.elements(); + int const screencount = xcells * ycells; + if (input.pressed_repeat(IPT_UI_UP, 4)) { - set.m_offset -= xcells; + set.m_offset -= shift_pressed ? 1 : xcells; result = true; } if (input.pressed_repeat(IPT_UI_DOWN, 4)) { - set.m_offset += xcells; + set.m_offset += shift_pressed ? 1 : xcells; result = true; } if (input.pressed_repeat(IPT_UI_PAGE_UP, 6)) { - set.m_offset -= xcells * ycells; + set.m_offset -= screencount * (alt_pressed ? 100 : ctrl_pressed ? 10 : 1); result = true; } if (input.pressed_repeat(IPT_UI_PAGE_DOWN, 6)) { - set.m_offset += xcells * ycells; + set.m_offset += screencount * (alt_pressed ? 100 : ctrl_pressed ? 10 : 1); result = true; } if (input.pressed_repeat(IPT_UI_HOME, 4)) @@ -829,14 +836,14 @@ bool gfx_viewer::gfxset::handle_keys(running_machine &machine, int xcells, int y } if (input.pressed_repeat(IPT_UI_END, 4)) { - set.m_offset = gfx.elements(); + set.m_offset = total; result = true; } // clamp within range - if (set.m_offset + xcells * ycells > ((gfx.elements() + xcells - 1) / xcells) * xcells) + if (set.m_offset + screencount > ((total + xcells - 1) / xcells) * xcells) { - set.m_offset = ((gfx.elements() + xcells - 1) / xcells) * xcells - xcells * ycells; + set.m_offset = ((total + xcells - 1) / xcells) * xcells - screencount; result = true; } if (set.m_offset < 0) @@ -848,12 +855,12 @@ bool gfx_viewer::gfxset::handle_keys(running_machine &machine, int xcells, int y // handle color selection (left,right) if (input.pressed_repeat(IPT_UI_LEFT, 4)) { - set.prev_color(); + set.prev_color(alt_pressed ? 0x100 : ctrl_pressed ? 0x10 : 1); result = true; } if (input.pressed_repeat(IPT_UI_RIGHT, 4)) { - set.next_color(); + set.next_color(alt_pressed ? 0x100 : ctrl_pressed ? 0x10 : 1); result = true; } @@ -913,7 +920,7 @@ bool gfx_viewer::tilemap::handle_keys(running_machine &machine, float pixelscale } // handle flags (category) - if (input.pressed(IPT_UI_PAGE_UP) && info.prev_catagory()) + if (input.pressed(IPT_UI_PAGE_UP) && info.prev_category()) { result = true; if (TILEMAP_DRAW_ALL_CATEGORIES == info.m_flags) @@ -1082,7 +1089,7 @@ uint32_t gfx_viewer::handle_palette(mame_ui_manager &mui, render_container &cont { x0 = boxbounds.x0 + 6.0f * chwidth + float(x) * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; - container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, aspect, rgb_t::white(), *ui_font, "0123456789ABCDEF"[x & 0xf]); + container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, aspect, rgb_t::white(), *ui_font, "0123456789ABCDEF"[(x + m_palette.index(0, 0)) & 0xf]); // if we're skipping, draw a point between the character and the box to indicate which one it's referring to if (rowskip) @@ -1294,7 +1301,7 @@ uint32_t gfx_viewer::handle_gfxset(mame_ui_manager &mui, render_container &conta { x0 = boxbounds.x0 + 6.0f * chwidth + float(x) * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; - container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, aspect, rgb_t::white(), *ui_font, "0123456789ABCDEF"[x & 0xf]); + container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, aspect, rgb_t::white(), *ui_font, "0123456789ABCDEF"[(x + set.m_offset) & 0xf]); // if we're skipping, draw a point between the character and the box to indicate which one it's referring to if (colskip) |
