bsnes/ruby/input/keyboard/quartz.cpp

154 lines
5.0 KiB
C++
Raw Normal View History

Update to v096r02 (OS X Preview for Developers) release. byuu says: Warning: this is not for the faint of heart. This is a very early, unpolished, buggy release. But help testing/fixing bugs would be greatly appreciated for anyone willing. Requirements: - Mac OS X 10.7+ - Xcode 7.2+ Installation Commands: cd higan gmake -j 4 gmake install cd ../icarus gmake -j 4 gmake install (gmake install is absolutely required, sorry. You'll be missing key files in key places if you don't run it, and nothing will work.) (gmake uninstall also exists, or you can just delete the .app bundles from your Applications folder, and the Dev folder on your desktop.) If you want to use the GBA emulation, then you need to drop the GBA BIOS into ~/Emulation/System/Game\ Boy\ Advance.sys\bios.rom Usage: You'll now find higan.app and icarus.app in your Applications folders. First, run icarus.app, navigate to where you keep your game ROMs. Now click the settings button at the bottom right, and check "Create Manifests", and click OK. (You'll need to do this every time you run icarus because there's some sort of bug on OSX saving the settings.) Now click "Import", and let it bring in your games into ~/Emulation. Note: "Create Manifests" is required. I don't yet have a pipe implementation on OS X for higan to invoke icarus yet. If you don't check this box, it won't create manifest.bml files, and your games won't run at all. Now you can run higan.app. The first thing you'll want to do is go to higan->Preferences... and assign inputs for your gamepads. At the very least, do it for the default controller for all the systems you want to emulate. Now this is very important ... close the application at this point so that it writes your config file to disk. There's a serious crashing bug, and if you trigger it, you'll lose your input bindings. Now the really annoying part ... go to Library->{System} and pick the game you want to play. Right now, there's a ~50% chance the application will bomb. It seems the hiro::pListView object is getting destroyed, yet somehow the internal Cocoa callbacks are being triggered anyway. I don't know how this is possible, and my attempts to debug with lldb have been a failure :( If you're unlucky, the application will crash. Restart and try again. If it crashes every single time, then you can try launching your game from the command-line instead. Example: open /Applications/higan.app \ --args ~/Emulation/Super\ Famicom/Zelda3.sfc/ Help wanted: I could really, really, really use some help with that crashing on game loading. There's a lot of rough edges, but they're all cosmetic. This one thing is pretty much the only major show-stopping issue at the moment, preventing a wider general audience pre-compiled binary preview.
2016-01-05 02:59:19 +00:00
struct InputKeyboardQuartz {
Input& input;
InputKeyboardQuartz(Input& input) : input(input) {}
shared_pointer<HID::Keyboard> hid{new HID::Keyboard};
struct Key {
string name;
uint id;
};
vector<Key> keys;
auto assign(uint inputID, bool value) -> void {
auto& group = hid->buttons();
if(group.input(inputID).value() == value) return;
input.doChange(hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
group.input(inputID).setValue(value);
}
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
uint inputID = 0;
for(auto& key : keys) {
bool value = CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState, key.id);
assign(inputID++, value);
}
devices.append(hid);
}
Update to v103r22 release. byuu says: Changelog: - ruby: ported all remaining drivers to new API¹ - ruby/wasapi: fix for dropping one sample per period [SuperMikeMan] - gb: emulated most of the TAMA RTC; but RTC state is still volatile² ¹: the new ports are: - audio/{directsound, alsa, pulseaudio, pulseaudiosimple, ao} - input/{udev, quartz, carbon} It's pretty much guaranteed many of them will have compilation errors. Please paste the error logs and I'll try to fix them up. It may take a WIP or two to get there. It's also possible things broke from the updates. If so, I could use help comparing the old file to the new file, looking for mistakes, since I can't test on these platforms apart from audio/directsound. Please report working drivers in this list, so we can mark them off the list. I'll need both macOS and Linux testers. audio/directsound.cpp:112:    if(DirectSoundCreate(0, &_interface, 0) != DS_OK) return terminate(), false; ²: once I get this working, I'll add load/save support for the RTC values. For now, the RTC data will be lost when you close the emulator. Right now, you can set the date/time in real-time mode, and when you start the game, the time will be correct, and the time will tick forward. Note that it runs off emulated time instead of actual real time, so if you fast-forward to 300%, one minute will be 20 seconds. The really big limitation right now is that when you exit the game, and restart it, and resume a new game, the hour spot gets corrupted, and this seems to instantly kill your pet. Fun. This is crazy because the commands the game sends to the TAMA interface are identical between starting a new game and getting in-game versus loading a game. It's likely going to require disassembling the game's code and seeing what in the hell it's doing, but I am extremely bad at LR35092 assembly. Hopefully endrift can help here :|
2017-07-28 11:42:24 +00:00
auto initialize() -> bool {
Update to v096r02 (OS X Preview for Developers) release. byuu says: Warning: this is not for the faint of heart. This is a very early, unpolished, buggy release. But help testing/fixing bugs would be greatly appreciated for anyone willing. Requirements: - Mac OS X 10.7+ - Xcode 7.2+ Installation Commands: cd higan gmake -j 4 gmake install cd ../icarus gmake -j 4 gmake install (gmake install is absolutely required, sorry. You'll be missing key files in key places if you don't run it, and nothing will work.) (gmake uninstall also exists, or you can just delete the .app bundles from your Applications folder, and the Dev folder on your desktop.) If you want to use the GBA emulation, then you need to drop the GBA BIOS into ~/Emulation/System/Game\ Boy\ Advance.sys\bios.rom Usage: You'll now find higan.app and icarus.app in your Applications folders. First, run icarus.app, navigate to where you keep your game ROMs. Now click the settings button at the bottom right, and check "Create Manifests", and click OK. (You'll need to do this every time you run icarus because there's some sort of bug on OSX saving the settings.) Now click "Import", and let it bring in your games into ~/Emulation. Note: "Create Manifests" is required. I don't yet have a pipe implementation on OS X for higan to invoke icarus yet. If you don't check this box, it won't create manifest.bml files, and your games won't run at all. Now you can run higan.app. The first thing you'll want to do is go to higan->Preferences... and assign inputs for your gamepads. At the very least, do it for the default controller for all the systems you want to emulate. Now this is very important ... close the application at this point so that it writes your config file to disk. There's a serious crashing bug, and if you trigger it, you'll lose your input bindings. Now the really annoying part ... go to Library->{System} and pick the game you want to play. Right now, there's a ~50% chance the application will bomb. It seems the hiro::pListView object is getting destroyed, yet somehow the internal Cocoa callbacks are being triggered anyway. I don't know how this is possible, and my attempts to debug with lldb have been a failure :( If you're unlucky, the application will crash. Restart and try again. If it crashes every single time, then you can try launching your game from the command-line instead. Example: open /Applications/higan.app \ --args ~/Emulation/Super\ Famicom/Zelda3.sfc/ Help wanted: I could really, really, really use some help with that crashing on game loading. There's a lot of rough edges, but they're all cosmetic. This one thing is pretty much the only major show-stopping issue at the moment, preventing a wider general audience pre-compiled binary preview.
2016-01-05 02:59:19 +00:00
keys.append({"Escape", kVK_Escape});
keys.append({"F1", kVK_F1});
keys.append({"F2", kVK_F2});
keys.append({"F3", kVK_F3});
keys.append({"F4", kVK_F4});
keys.append({"F5", kVK_F5});
keys.append({"F6", kVK_F6});
keys.append({"F7", kVK_F7});
keys.append({"F8", kVK_F8});
keys.append({"F9", kVK_F9});
keys.append({"F10", kVK_F10});
keys.append({"F11", kVK_F11});
keys.append({"F12", kVK_F12});
keys.append({"F13", kVK_F13});
keys.append({"F14", kVK_F14});
keys.append({"F15", kVK_F15});
keys.append({"F16", kVK_F16});
keys.append({"F17", kVK_F17});
keys.append({"F18", kVK_F18});
keys.append({"F19", kVK_F19});
keys.append({"F20", kVK_F20});
keys.append({"Tilde", kVK_ANSI_Grave});
keys.append({"Num1", kVK_ANSI_1});
keys.append({"Num2", kVK_ANSI_2});
keys.append({"Num3", kVK_ANSI_3});
keys.append({"Num4", kVK_ANSI_4});
keys.append({"Num5", kVK_ANSI_5});
keys.append({"Num6", kVK_ANSI_6});
keys.append({"Num7", kVK_ANSI_7});
keys.append({"Num8", kVK_ANSI_8});
keys.append({"Num9", kVK_ANSI_9});
keys.append({"Num0", kVK_ANSI_0});
keys.append({"Dash", kVK_ANSI_Minus});
keys.append({"Equal", kVK_ANSI_Equal});
keys.append({"Delete", kVK_Delete});
keys.append({"Erase", kVK_ForwardDelete});
keys.append({"Home", kVK_Home});
keys.append({"End", kVK_End});
keys.append({"PageUp", kVK_PageUp});
keys.append({"PageDown", kVK_PageDown});
keys.append({"A", kVK_ANSI_A});
keys.append({"B", kVK_ANSI_B});
keys.append({"C", kVK_ANSI_C});
keys.append({"D", kVK_ANSI_D});
keys.append({"E", kVK_ANSI_E});
keys.append({"F", kVK_ANSI_F});
keys.append({"G", kVK_ANSI_G});
keys.append({"H", kVK_ANSI_H});
keys.append({"I", kVK_ANSI_I});
keys.append({"J", kVK_ANSI_J});
keys.append({"K", kVK_ANSI_K});
keys.append({"L", kVK_ANSI_L});
keys.append({"M", kVK_ANSI_M});
keys.append({"N", kVK_ANSI_N});
keys.append({"O", kVK_ANSI_O});
keys.append({"P", kVK_ANSI_P});
keys.append({"Q", kVK_ANSI_Q});
keys.append({"R", kVK_ANSI_R});
keys.append({"S", kVK_ANSI_S});
keys.append({"T", kVK_ANSI_T});
keys.append({"U", kVK_ANSI_U});
keys.append({"V", kVK_ANSI_V});
keys.append({"W", kVK_ANSI_W});
keys.append({"X", kVK_ANSI_X});
keys.append({"Y", kVK_ANSI_Y});
keys.append({"Z", kVK_ANSI_Z});
keys.append({"LeftBracket", kVK_ANSI_LeftBracket});
keys.append({"RightBracket", kVK_ANSI_RightBracket});
keys.append({"Backslash", kVK_ANSI_Backslash});
keys.append({"Semicolon", kVK_ANSI_Semicolon});
keys.append({"Apostrophe", kVK_ANSI_Quote});
keys.append({"Comma", kVK_ANSI_Comma});
keys.append({"Period", kVK_ANSI_Period});
keys.append({"Slash", kVK_ANSI_Slash});
keys.append({"Keypad1", kVK_ANSI_Keypad1});
keys.append({"Keypad2", kVK_ANSI_Keypad2});
keys.append({"Keypad3", kVK_ANSI_Keypad3});
keys.append({"Keypad4", kVK_ANSI_Keypad4});
keys.append({"Keypad5", kVK_ANSI_Keypad5});
keys.append({"Keypad6", kVK_ANSI_Keypad6});
keys.append({"Keypad7", kVK_ANSI_Keypad7});
keys.append({"Keypad8", kVK_ANSI_Keypad8});
keys.append({"Keypad9", kVK_ANSI_Keypad9});
keys.append({"Keypad0", kVK_ANSI_Keypad0});
keys.append({"Clear", kVK_ANSI_KeypadClear});
keys.append({"Equals", kVK_ANSI_KeypadEquals});
keys.append({"Divide", kVK_ANSI_KeypadDivide});
keys.append({"Multiply", kVK_ANSI_KeypadMultiply});
keys.append({"Subtract", kVK_ANSI_KeypadMinus});
keys.append({"Add", kVK_ANSI_KeypadPlus});
keys.append({"Enter", kVK_ANSI_KeypadEnter});
keys.append({"Decimal", kVK_ANSI_KeypadDecimal});
keys.append({"Up", kVK_UpArrow});
keys.append({"Down", kVK_DownArrow});
keys.append({"Left", kVK_LeftArrow});
keys.append({"Right", kVK_RightArrow});
keys.append({"Tab", kVK_Tab});
keys.append({"Return", kVK_Return});
keys.append({"Spacebar", kVK_Space});
keys.append({"Shift", kVK_Shift});
keys.append({"Control", kVK_Control});
keys.append({"Option", kVK_Option});
keys.append({"Command", kVK_Command});
hid->setID(1);
for(auto& key : keys) {
hid->buttons().append(key.name);
}
return true;
}
Update to v103r22 release. byuu says: Changelog: - ruby: ported all remaining drivers to new API¹ - ruby/wasapi: fix for dropping one sample per period [SuperMikeMan] - gb: emulated most of the TAMA RTC; but RTC state is still volatile² ¹: the new ports are: - audio/{directsound, alsa, pulseaudio, pulseaudiosimple, ao} - input/{udev, quartz, carbon} It's pretty much guaranteed many of them will have compilation errors. Please paste the error logs and I'll try to fix them up. It may take a WIP or two to get there. It's also possible things broke from the updates. If so, I could use help comparing the old file to the new file, looking for mistakes, since I can't test on these platforms apart from audio/directsound. Please report working drivers in this list, so we can mark them off the list. I'll need both macOS and Linux testers. audio/directsound.cpp:112:    if(DirectSoundCreate(0, &_interface, 0) != DS_OK) return terminate(), false; ²: once I get this working, I'll add load/save support for the RTC values. For now, the RTC data will be lost when you close the emulator. Right now, you can set the date/time in real-time mode, and when you start the game, the time will be correct, and the time will tick forward. Note that it runs off emulated time instead of actual real time, so if you fast-forward to 300%, one minute will be 20 seconds. The really big limitation right now is that when you exit the game, and restart it, and resume a new game, the hour spot gets corrupted, and this seems to instantly kill your pet. Fun. This is crazy because the commands the game sends to the TAMA interface are identical between starting a new game and getting in-game versus loading a game. It's likely going to require disassembling the game's code and seeing what in the hell it's doing, but I am extremely bad at LR35092 assembly. Hopefully endrift can help here :|
2017-07-28 11:42:24 +00:00
auto terminate() -> void {
Update to v096r02 (OS X Preview for Developers) release. byuu says: Warning: this is not for the faint of heart. This is a very early, unpolished, buggy release. But help testing/fixing bugs would be greatly appreciated for anyone willing. Requirements: - Mac OS X 10.7+ - Xcode 7.2+ Installation Commands: cd higan gmake -j 4 gmake install cd ../icarus gmake -j 4 gmake install (gmake install is absolutely required, sorry. You'll be missing key files in key places if you don't run it, and nothing will work.) (gmake uninstall also exists, or you can just delete the .app bundles from your Applications folder, and the Dev folder on your desktop.) If you want to use the GBA emulation, then you need to drop the GBA BIOS into ~/Emulation/System/Game\ Boy\ Advance.sys\bios.rom Usage: You'll now find higan.app and icarus.app in your Applications folders. First, run icarus.app, navigate to where you keep your game ROMs. Now click the settings button at the bottom right, and check "Create Manifests", and click OK. (You'll need to do this every time you run icarus because there's some sort of bug on OSX saving the settings.) Now click "Import", and let it bring in your games into ~/Emulation. Note: "Create Manifests" is required. I don't yet have a pipe implementation on OS X for higan to invoke icarus yet. If you don't check this box, it won't create manifest.bml files, and your games won't run at all. Now you can run higan.app. The first thing you'll want to do is go to higan->Preferences... and assign inputs for your gamepads. At the very least, do it for the default controller for all the systems you want to emulate. Now this is very important ... close the application at this point so that it writes your config file to disk. There's a serious crashing bug, and if you trigger it, you'll lose your input bindings. Now the really annoying part ... go to Library->{System} and pick the game you want to play. Right now, there's a ~50% chance the application will bomb. It seems the hiro::pListView object is getting destroyed, yet somehow the internal Cocoa callbacks are being triggered anyway. I don't know how this is possible, and my attempts to debug with lldb have been a failure :( If you're unlucky, the application will crash. Restart and try again. If it crashes every single time, then you can try launching your game from the command-line instead. Example: open /Applications/higan.app \ --args ~/Emulation/Super\ Famicom/Zelda3.sfc/ Help wanted: I could really, really, really use some help with that crashing on game loading. There's a lot of rough edges, but they're all cosmetic. This one thing is pretty much the only major show-stopping issue at the moment, preventing a wider general audience pre-compiled binary preview.
2016-01-05 02:59:19 +00:00
}
};