77 Commits

Author SHA1 Message Date
joevt fc0777c45f display: Fix display size changes in full screen.
Fix virtual display resolution change while in full screen mode.

Switching resolutions should keep the same full screen mode (integer,
full, no bars) unless a custom scale (using the zoom keys Control-- or
Control-+) has been selected.

Control-F is for switching forward through the full screen modes. Add
Control-Shift-F for switching backward through the full screen modes.
This allows reducing full screen mode without going through not full
screen mode.
2025-07-03 07:04:43 -07:00
joevt 0f8876f348 viacuda: Post key events at startup.
Keys that are held down too early are ignored which makes it difficult
perform some tasks at startup:
- Shift key to disable extensions.
- Command-Option-O-F to enter Open Firmware.
- Command-Option-P-R to reset nvram.
- Capslock to boot MkLinux or Copland.

This change hopes to grab all the keys being pressed and post events for
all of them when the ADB bus is ready.
2025-06-29 06:49:15 -07:00
joevt dbadbb4cce hostevents_sdl: Remove superfluous semicolons. 2025-06-29 06:48:51 -07:00
joevt 23b142008f hostevents_sdl: Use key mods from the SDL key event.
No reason to call SDL_GetModState separately.
2025-06-29 06:48:40 -07:00
joevt d3e0b743bb hostevents_sdl: Add key for entering debugger.
Because Control-C (sigint) in terminal window isn't always reliable (for
example, release version launched from Xcode).
2025-06-29 06:48:33 -07:00
joevt 91410f3690 hostevents_sdl: Control-L toggles max logging. 2025-06-29 06:48:23 -07:00
joevt 5412fbc198 Remove superfluous semicolons. 2025-06-27 19:01:14 -07:00
joevt 3f830eb5b5 hostevents_sdl: Ignore repeat events.
SDL2 will send a key down event multiple times (with the repeat flag
set) after the first key down event for the same key.
2025-06-27 18:57:35 -07:00
joevt 7ed8bda0fe adbkeyboard: Support Device Handler ID 3.
Device Handler ID 3 returns separate key codes for the right control,
option, and shift keys.
2025-06-27 18:55:55 -07:00
joevt 5ed44f73cd hostevents: Include gamepad handler.
For some reason this handler was not included with other input handlers
for disconnect or disable.
2025-06-27 18:54:05 -07:00
joevt 7b7dc90158 hostevents: Add keyboard_locale.
Add a keyboard locale field instead of passing it as a parameter to
poll_events.
2025-06-27 18:54:01 -07:00
joevt 8c05e8ac82 hostevents: Remove unused keys_state field. 2025-06-27 18:53:54 -07:00
joevt f2f048d435 hostevents: Fix mouse grab for multiple displays.
Create a mouse grab toggle event to toggle the mouse grab using the current window. After the toggle event is transmitted, transmit a mouse grab changed event so that all windows can update their title.
2025-05-03 06:04:07 -07:00
joevt 16762ab9e3 bitops: Handle rotate count 0. 2025-04-24 06:33:54 -07:00
joevt 28c497e455 bitops: Spelling. 2025-04-24 06:33:31 -07:00
joevt 72ef266d07 display: Update grabbed mouse when resizing.
If the window's size is reduced such that the grabbed mouse is no longer inside the window, then a mouse click will go to another app. Therefore, check the mouse position and update if necessary every time the window changes size.
2025-04-23 06:56:25 -07:00
joevt 47c66666bb display: Add zoom and fullscreen no letterbox.
Added a third full screen mode which removes letterbox or pillarbox black bars.
Added Control-- and control-+ to decrease or increase the scale by a factor of 2^(1/8). This means the scale doubles or halves after pressing the same key 8 times.

drawable_w and drawable_h are floating point so that scaling is reversible (i.e. scaling from 100% to 800% and back to 100% gives 100% instead of 99 or 101%).
default_scale_x

Handle switching host resolution between Retina (HiDPI) and Low resolution modes. This involves updating the window scale factor.

Add window scale factor to window title.
2025-04-22 06:36:04 -07:00
joevt e82d9d1522 Add Full Screen modes.
A display begins in Windowed mode.
1) Press Control-F once to use full screen mode with integer scaling. If this mode is the same size as full screen mode then it is skipped.
2) Press Control-F again to use full screen mode. Smooth Scaling should be used for this mode if the scaling is not integer. Look at the Mac OS 7/8/9 window stripes to see the problem.
3) Press Control-F a third time to get back to windowed mode.

Fixed a bug where Control-S (Toggle Smooth Scaling mode) did not immediately update the display.

These keys only affect the current display.
2025-04-19 05:38:37 -07:00
joevt 1340fbedb8 hostevends_sdl: Check all modifier keys.
When checking if certain modifier keys are being pressed, also make sure that all other modifier keys are not being pressed.
2025-04-18 18:51:47 -07:00
joevt 36c7c807a4 display: Add update_window_title and window event.
update_window_title can be used to update statistics about the display (such as display resolution) or about DingusPPC in general (such as "mouse grabbed" status).

A DPPC_WINDOWEVENT_MOUSE_GRAB_CHANGED window event is added so that Display::handle_events can update the "mouse grabbed" indicator in each display window. The event handler doesn't check the window ID because the status should be reflected in all windows.

The SDL_WINDOWEVENT_SIZE_CHANGED event causes the window to update the display resolution indicator.

In the future, we might add indicators for HD and CD and floppy disk activity, etc. They will be handled by a window event handler or a general DPPC event handler.
2025-04-18 07:20:49 -07:00
Rairii 61a8402f84 hostevents_sdl: Ralt+delete to ctrl+alt+del.
"Right Option + Forward Delete" is translated to "Control + Right Option + Backspace".
2025-04-18 07:20:46 -07:00
joevt 28c50a2018 hostevents: Spaces. 2025-04-04 20:52:05 -07:00
dingusdev 77503df677 Code clean-up 2025-03-12 07:58:32 -07:00
joevt 2f30395d00 Break long lines.
Make them 130 characters or less.
2025-01-30 06:30:51 -07:00
dingusdev 8de2c9dafc Start i18n 2025-01-29 21:14:36 -07:00
Mihai Parparita f65f9b9845 Add a deterministic execution mode
Adds support for a --deterministic command-line option that makes
repeated runs the same:
- Keyboard and mouse input is ignored
- The sound server does a periodic pull from the DMA channel (so that
  it gets drained), but only does so via a periodic timer (instead of
  being driven by a cubeb callback, which could arrive at different
  times)
- Disk image writes are disabled (reads of a modified area still
  work via an in-memory copy)
- NVRAM writes are disabled
- The current time that ViaCuda initializes the guest OS is always the
  same.

This makes execution exactly the same each time, which should
make debugging of more subtle issues easier.

To validate that the deterministic mode is working, I've added a
periodic log of the current "time" (measured in cycle count), PC
and opcode. When comparing two runs with --log-no-uptime, the generated
log files are identical.
2024-11-09 22:48:06 -08:00
Mihai Parparita fc13f6870b Enable HiDPI mode for SDL and ensure that we use nearest-neighbor scaling
Avoids blurriness on macOS hosts with Retina displays.

Smooth scaling can be toggled back on via control-S
2024-11-09 15:48:00 -08:00
Keith Kaisershot d23f21b391 sdl: handle gamepad events
Add new GamepadButton enum with bits corresponding to AppleJack button bits.
Both the AppleJack controller and the SDL GameController coincidentally define
one d-pad, two shoulder buttons, four face buttons, and three system buttons.
This makes mapping modern game controllers to the AppleJack straightforward.
2024-10-06 23:28:05 -07:00
joevt c6060ad812 timermanager: Use decimal ints, not floats or hex. 2024-08-31 18:09:15 -07:00
joevt f09710a5f7 viacuda: Do shutdown.
Shutdown will enter the debugger or quit depending on the execution mode.
Quit is different from shutdown since it is triggered outside the guest by using the host Quit menu item.
2024-08-31 18:09:12 -07:00
dingusdev 2a8e5538b2 Partially addressing Issue #109
It'll be better to use a keycode file in the future. This will hopefully do for now.
2024-08-04 15:02:48 -07:00
dyharlan 7ba7bff3d5 Do not test for equality when checking if ctrl is pressed.
The initial change I committed worked fine before.
2024-07-11 10:38:57 +08:00
dingusdev 40b537767d Update hostevents_sdl.cpp
A further fix by dyharlan to fix the mouse grabbing
2024-07-10 07:51:23 -07:00
dyharlan 0267fc82c9 fix indent of change 2024-07-10 19:03:37 +08:00
dyharlan c4022f466f Fix modstate bug preventing mousegrab 2024-07-10 18:54:05 +08:00
dingusdev d3096ebaac Fixing compiler warnings, pt. 1 2024-06-21 08:01:21 -07:00
joevt 59fba285b5 adbmouse: Add tablet and more bits and buttons.
Add absolute coordinates for tablets. Absolute coordinates is relative to window so it can't work for multiple displays? Doesn't work for single display without mouse driver modification.
Add arbitrary number of buttons. Previously, only one mouse button was supported.
Add arbitrary number of bits. Previously, only 7 bits per axis was supported which is good enough for relative movement but not absolute movement.
2024-05-06 06:49:15 -07:00
dingusdev 284f58dec4 Continued build fixing 2024-03-16 19:24:40 -07:00
dingusdev da9770c99b Attempted build fix 2024-03-16 13:45:28 -07:00
joevt 266d45e13a timermanager: Make immediate timer more immediate. 2024-03-16 11:46:40 -07:00
joevt 703662cb5b timermanager: Add some thread safety. 2024-03-16 11:46:30 -07:00
joevt 833f74dce6 timemanager: Remove unnecessary parameter. 2024-03-16 11:36:41 -07:00
joevt 014aa90462 timemanager: Remove timer minimum timeout. 2024-03-16 11:36:25 -07:00
joevt f5dcaebbf8 timemanager: 0 is also < a positive integer. 2024-03-16 11:36:10 -07:00
Maxim Poliakovski 54ce23d0a8 platinum: cleanup non-DWORD register reads. 2024-03-12 17:29:19 +01:00
Maxim Poliakovski 3c7ce3de8b Merge pull request #62 from mihaip/upstream-cuda-restart
Add support for the CUDA_RESTART_SYSTEM command
2024-03-08 15:25:02 +01:00
dingusdev e56d4e63f4 Merge pull request #76 from mihaip/upstream-mouse-grab2
Add a basic mouse grab mode
2024-03-08 07:10:10 -07:00
Mihai Parparita 57e6e90002 Add support for the CUDA_RESTART_SYSTEM command
There are cases where when it's necessary (e.g. given uninitialized NVRAM,
the Beige G3 with the 10.2 install CD inserted will update the boot
device and restart to boot from it).

Restart support was done by wrapping the ppc_exec function in a loop and
checking for a restart power off reason. We also need to disconnect all
event listeners, since they will be recreated when the machine is
re-initialized.
2024-03-07 23:32:23 -08:00
joevt 177098c957 debugger: Fix interrupt signal.
Typing Control-C in Terminal app causes an interrupt signal that should enter the DPPC debugger but this only worked once since the signal handler never returned. Even if the signal handler reenabled the signal somehow, it calls enter_debugger recursively which is strange since the earlier calls to enter_debugger would never return.

Now the signal handler just sets a flag (power_on) which can be used to exit any loop (emulator loops, stepping loops, disassembly loops, dumping loops).

Main always calls enter_debugger now which calls the ppc_exec loop. The power_on flag will exit the ppc_exec loop to return to the debugger. Recursion of enter_debugger is eliminated except for calls to loguru's ABORT_F.

An enum power_off_reason is used to indicate why the power_on flag is set to false and to determine what happens next.
2024-03-02 12:57:02 -07:00
joevt 7fc92e236b Fix extract_bits and insert_bits.
(1 << len) is actually 1 when len is (sizeof(T)*8) so we need to special case that. len is usually constant so the compare won't be compiled.
2024-03-02 06:54:58 -07:00