-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Wiimote to GunCon3 #18154
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
Open
SomeoneIsWorking
wants to merge
39
commits into
RPCS3:master
Choose a base branch
from
SomeoneIsWorking:wiimote-to-guncon3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Wiimote to GunCon3 #18154
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
cb01548
Wiimote to GunCon3
SomeoneIsWorking e20e74e
Wiimote to GunCon3 remapping support
SomeoneIsWorking 17b72ae
Wiimote to GunCon3 PR review updates
SomeoneIsWorking 0376d7c
Wiimote to GunCon3 apply (https://wiibrew.org/wiki/Wiimote#IR_Camera)…
SomeoneIsWorking 6b68a70
Wiimote to GunCon3 removed 2 extra spaces
SomeoneIsWorking c4c93f0
Wiimote to GunCon3 removed fake wiimote_continuous_scanning
SomeoneIsWorking 2579a76
Wiimote to GunCon3 compile error
SomeoneIsWorking f50ed87
Wiimote to GunCon3: removed bogus mapping remnant
SomeoneIsWorking 81bc25d
Wiimote to GunCon3: rework disconnect/reconnect logic
SomeoneIsWorking da55ae9
Wiimote to GunCon3: IR healthchecks to determine connection state
SomeoneIsWorking 234a128
Merge branch 'RPCS3:master' into wiimote-to-guncon3
SomeoneIsWorking 607e045
Wiimote to GunCon3: revert pad_types.h
SomeoneIsWorking e274375
Wiimote to GunCon3: Address review comments
SomeoneIsWorking 53717ad
Wiimote to GunCon3: Address review comments (Untested)
SomeoneIsWorking e74432d
Merge branch 'master' into wiimote-to-guncon3
SomeoneIsWorking b600979
Wiimote to GunCon3: retry github actions
SomeoneIsWorking caa0be0
Rename WiimoteManager to wiimote_handler, attempt to fix the structur…
SomeoneIsWorking b2b35fc
Attempt to get Windows build working
SomeoneIsWorking 840df4e
Wiimote to GunCon3: GunCon3: use constants more
SomeoneIsWorking 8bd7d3c
Attempt to resolve threading issues
SomeoneIsWorking d8cc077
Remove unnecessary Apple-specific HID API include from hid_pad_handle…
SomeoneIsWorking 1369699
unused usings
SomeoneIsWorking bb9d12b
Address review comments
SomeoneIsWorking 7e325a3
Merge branch 'master' into wiimote-to-guncon3
Megamouse d009e89
Address review comments
SomeoneIsWorking 91b238e
Address review comments
SomeoneIsWorking c78f4fc
fix and utillize hid_instance::enumerate_devices
SomeoneIsWorking b7eeaac
Refactor wiimote_settings_dialog: Improve variable naming and initial…
SomeoneIsWorking 02fb9b5
Refactor wiimote handling: Replace hardcoded values with MAX_WIIMOTES…
SomeoneIsWorking f9e8fd5
Wiimotes: Actually we have two constants MAX_WIIMOTES and MAX_WIIMOTE…
SomeoneIsWorking 6828bec
Enhance Wiimote support for GunCon emulation: Add configuration optio…
SomeoneIsWorking 6dde741
Refactor update_list: Extract repeated strings into variables for cla…
SomeoneIsWorking 4b53c17
Refactor update_state: Simplify condition checks for Wiimote state re…
SomeoneIsWorking 7a3e056
Fix update_list: Improve connection status label updates for Wiimote …
SomeoneIsWorking 8c7a277
Fix GunCon3: Change type casting from int16_t to s16 for gun coordinates
SomeoneIsWorking 2af6fe0
Refactor Wiimote configuration: Move types to a new header and update…
SomeoneIsWorking 6a3a77f
Refactor Wiimote and GunCon3 integration: Update button mapping and c…
SomeoneIsWorking ff0e27d
Merge branch 'master' into wiimote-to-guncon3
SomeoneIsWorking 0bb3983
Refactor wiimote_handler: Replace raw pointer with unique_ptr for ins…
SomeoneIsWorking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #include "stdafx.h" | ||
| #include "wiimote_config.h" | ||
| #include "Utilities/File.h" | ||
|
|
||
| LOG_CHANNEL(wiimote_log, "Wiimote"); | ||
|
|
||
| template <> | ||
| void fmt_class_string<wiimote_button>::format(std::string& out, u64 arg) | ||
| { | ||
| format_enum(out, arg, [](wiimote_button value) | ||
| { | ||
| switch (value) | ||
| { | ||
| case wiimote_button::None: return "None"; | ||
| case wiimote_button::Left: return "Left"; | ||
| case wiimote_button::Right: return "Right"; | ||
| case wiimote_button::Down: return "Down"; | ||
| case wiimote_button::Up: return "Up"; | ||
| case wiimote_button::Plus: return "Plus"; | ||
| case wiimote_button::Two: return "Two"; | ||
| case wiimote_button::One: return "One"; | ||
| case wiimote_button::B: return "B"; | ||
| case wiimote_button::A: return "A"; | ||
| case wiimote_button::Minus: return "Minus"; | ||
| case wiimote_button::Home: return "Home"; | ||
| } | ||
| return unknown; | ||
| }); | ||
| } | ||
|
|
||
| cfg_wiimote& get_wiimote_config() | ||
| { | ||
| static cfg_wiimote instance; | ||
| return instance; | ||
| } | ||
|
|
||
| cfg_wiimote::cfg_wiimote() | ||
| : cfg::node() | ||
| , path(fs::get_config_dir(true) + "wiimote.yml") | ||
| { | ||
| } | ||
|
|
||
| bool cfg_wiimote::load() | ||
| { | ||
| if (fs::file f{path, fs::read}) | ||
| { | ||
| return cfg::node::from_string(f.to_string()); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void cfg_wiimote::save() const | ||
| { | ||
| if (!cfg::node::save(path)) | ||
| { | ||
| wiimote_log.error("Failed to save wiimote config to '%s'", path); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #pragma once | ||
|
|
||
| #include "Utilities/Config.h" | ||
| #include "Input/wiimote_types.h" | ||
|
|
||
| struct cfg_wiimote : cfg::node | ||
| { | ||
| cfg_wiimote(); | ||
| bool load(); | ||
| void save() const; | ||
|
|
||
| cfg::_bool use_for_guncon{ this, "UseForGunCon", true }; | ||
|
|
||
| struct node_guncon_mapping : cfg::node | ||
| { | ||
| node_guncon_mapping(cfg::node* _parent) : cfg::node(_parent, "GunCon Mapping") {} | ||
|
|
||
| cfg::_enum<wiimote_button> trigger{ this, "Trigger", wiimote_button::B }; | ||
| cfg::_enum<wiimote_button> a1{ this, "A1", wiimote_button::A }; | ||
| cfg::_enum<wiimote_button> a2{ this, "A2", wiimote_button::Minus }; | ||
| cfg::_enum<wiimote_button> a3{ this, "A3", wiimote_button::Left }; | ||
| cfg::_enum<wiimote_button> b1{ this, "B1", wiimote_button::One }; | ||
| cfg::_enum<wiimote_button> b2{ this, "B2", wiimote_button::Two }; | ||
| cfg::_enum<wiimote_button> b3{ this, "B3", wiimote_button::Home }; | ||
| cfg::_enum<wiimote_button> c1{ this, "C1", wiimote_button::Plus }; | ||
| cfg::_enum<wiimote_button> c2{ this, "C2", wiimote_button::Right }; | ||
|
|
||
| cfg::_enum<wiimote_button> b1_alt{ this, "B1_Alt", wiimote_button::Up }; | ||
| cfg::_enum<wiimote_button> b2_alt{ this, "B2_Alt", wiimote_button::Down }; | ||
| } guncon_mapping{ this }; | ||
|
|
||
| const std::string path; | ||
| }; | ||
|
|
||
| cfg_wiimote& get_wiimote_config(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #include "stdafx.h" | ||
| #include "hid_instance.h" | ||
| #include "util/logs.hpp" | ||
| #include "Emu/System.h" | ||
| #include "Utilities/Thread.h" | ||
|
|
||
| #if defined(__APPLE__) | ||
| #include "3rdparty/hidapi/hidapi/mac/hidapi_darwin.h" | ||
| #endif | ||
|
|
||
| LOG_CHANNEL(hid_log, "HID"); | ||
|
|
||
| std::mutex g_hid_mutex; | ||
|
|
||
| hid_instance::~hid_instance() | ||
| { | ||
| std::lock_guard lock(m_hid_mutex); | ||
|
|
||
| // Only exit HIDAPI once on exit. HIDAPI uses a global state internally... | ||
| if (m_initialized) | ||
| { | ||
| hid_log.notice("Exiting HIDAPI..."); | ||
|
|
||
| if (hid_exit() != 0) | ||
| { | ||
| hid_log.error("hid_exit failed!"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| bool hid_instance::initialize() | ||
| { | ||
| std::lock_guard lock(m_hid_mutex); | ||
|
|
||
| // Only init HIDAPI once. HIDAPI uses a global state internally... | ||
| if (m_initialized) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| hid_log.notice("Initializing HIDAPI ..."); | ||
|
|
||
| #if defined(__APPLE__) | ||
| int error_code = 0; | ||
| Emu.BlockingCallFromMainThread([&error_code]() | ||
| { | ||
| error_code = hid_init(); | ||
| hid_darwin_set_open_exclusive(0); | ||
| }, false); | ||
| #else | ||
| const int error_code = hid_init(); | ||
| #endif | ||
| if (error_code != 0) | ||
| { | ||
| hid_log.fatal("hid_init error %d: %s", error_code, hid_error(nullptr)); | ||
| return false; | ||
| } | ||
|
|
||
| m_initialized = true; | ||
| return true; | ||
| } | ||
|
|
||
| void hid_instance::enumerate_devices(u16 vid, u16 pid, std::function<void(hid_device_info*)> callback) | ||
| { | ||
| std::lock_guard lock(g_hid_mutex); | ||
| #if defined(__APPLE__) | ||
| Emu.BlockingCallFromMainThread([&]() | ||
| { | ||
| hid_device_info* devs = hid_enumerate(vid, pid); | ||
| callback(devs); | ||
| hid_free_enumeration(devs); | ||
| }, false); | ||
| #else | ||
| hid_device_info* devs = hid_enumerate(vid, pid); | ||
| callback(devs); | ||
| hid_free_enumeration(devs); | ||
| #endif | ||
| } | ||
|
|
||
| hid_device* hid_instance::open_path(const char* path) | ||
| { | ||
| std::lock_guard lock(g_hid_mutex); | ||
| #if defined(__APPLE__) | ||
| if (!thread_ctrl::is_main()) | ||
| { | ||
| hid_device* dev = nullptr; | ||
| Emu.BlockingCallFromMainThread([&]() { dev = hid_open_path(path); }, false); | ||
| return dev; | ||
| } | ||
| #endif | ||
| return hid_open_path(path); | ||
| } | ||
|
|
||
| void hid_instance::close(hid_device* dev) | ||
| { | ||
| if (!dev) return; | ||
|
|
||
| std::lock_guard lock(g_hid_mutex); | ||
| #if defined(__APPLE__) | ||
| Emu.BlockingCallFromMainThread([&]() { hid_close(dev); }, false); | ||
| #else | ||
| hid_close(dev); | ||
| #endif | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.