Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the ADB keyboard #56

Merged
merged 1 commit into from Nov 9, 2023
Merged

Conversation

mihaip
Copy link
Contributor

@mihaip mihaip commented Oct 29, 2023

Besides generating KeyboardEvents in the SDL event handler and returning the key state in the register 0 reads of the AdbKeyboard device, we also needed to generalize the ADB bus polling a bit. We now check all devices that have the service request bit set, instead of hardcoding the mouse.

The SDL key event -> ADB raw key code mapping is based on BasiliskII/ SheepShaver's, but cleaned up a bit.

To test this, I've been using the PDM ROM with a slightly tweaked 7.1.2 Disk Tools image that has the Key Caps DA installed.

Besides generating KeyboardEvents in the SDL event handler and
returning the key state in the register 0 reads of the AdbKeyboard
device, we also needed to generalize the ADB bus polling a bit. We now
check all devices that have the service request bit set, instead of
hardcoding the mouse.

The SDL key event -> ADB raw key code mapping is based on BasiliskII/
SheepShaver's, but cleaned up a bit.
mihaip added a commit to mihaip/dingusppc that referenced this pull request Oct 29, 2023
As part of adding ADB keyboard support (dingusdev#56), we're now running into
conflicts between the guest and host OS keyboard shortcuts when running
on macOS hosts.

SDL2 unconditionally adds some menu items to the "Window" menu, and
there are built-in ones too. As a workaround, we now iterate over all
menu items are swap out command for control, since the the latter is
generally unused in classic Mac OS.
@maximumspatium
Copy link
Collaborator

maximumspatium commented Nov 8, 2023

Please convert all those kVK_ANSI_x comments into an enum and use the corresponding constants instead of magic numbers.
I find the kVK_ANSI prefix misleading and propose to use kVK_x instead:

enum {
    kVK_A = 0x00,
    // ...
};

switch (event.keysym.sym) {
     case SDLK_a:            return kVK_A;
}

if (ke.key == kVK_CapsLock) {
    ke.flags = SDL_GetModState() & KMOD_CAPS ?
        KEYBOARD_EVENT_DOWN : KEYBOARD_EVENT_UP;
}

The definitions for the virtual keys should go into adbkeyboard.h.

@mihaip mihaip force-pushed the upstreaming branch 2 times, most recently from 9b6e4ce to 73272b2 Compare November 9, 2023 07:11
@mihaip
Copy link
Contributor Author

mihaip commented Nov 9, 2023

Please convert all those kVK_ANSI_x comments into an enum and use the corresponding constants instead of magic numbers. I find the kVK_ANSI prefix misleading and propose to use kVK_x instead.

Makes sense. I went with an AbbKey prefix for the enums, since kVK_ didn't seem quite right either -- they're raw ADB key codes, not virtual ones.

@maximumspatium maximumspatium merged commit b350bea into dingusdev:master Nov 9, 2023
1 check passed
@mihaip mihaip deleted the upstreaming branch November 10, 2023 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants