8000 Implementation of KPAD / WPAD by SteveLeafo · Pull Request #497 · decaf-emu/decaf-emu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implementation of KPAD / WPAD #497

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
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

SteveLeafo
Copy link
Contributor

With these changes I was able to play a two player game of family tennis, but there is still a long way to go.
I wasn't able to get a second player to join a Mario Kart game.

Copy link
Contributor
@VelocityRa VelocityRa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, here's a few nits I noticed.

struct ChanData
{
be2_val<KPADControlDpdCallback> controlDpdCallback;
be2_val<KPADControlMplsCallback > controlMplsCallback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove space before >

if (value < 0) {
return value / 32768.0f;
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {

@SteveLeafo
Copy link
Contributor Author

This latest update is working quite nicely now - helps a few games to in game
2 Mario Kart - https://youtu.be/Han_HamgQBQ

@@ -183,6 +199,10 @@ WPADControlDpd(int32_t chan,
return WPADError::OK;
}

bool IsProControllerAllowed()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type on separate line

@@ -89,6 +100,26 @@ struct KPADExtStatus
};
CHECK_SIZE(KPADExtStatus, 0x50);

struct KPADMPDir {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove space before struct

@exjam
Copy link
Member
exjam commented Oct 10, 2018

Looking pretty solid overall - will merge it when I get a chance at my PC.

I was wondering if you had any thoughts on improving the API between the front-end and decaf itself? I'm not so sure the API I threw together the first time round was a great choice.

Maybe instead of having a function per button in the decaf InputDriver we should consider consolidating them into basically how VPADRead works and read the structure in one go?

Thinking ahead too I think we are also going to need support for frontend notifying decaf of controllers being connected and other such controller events, also adding methods for vibration etc.

Although I am not sure where this could fit in if we ever did bluetooth / usb passthrough as the games do have access to USB devices.

Something to consider for a future PR at least - if you have any ideas about a nicer API that is.

@exjam
Copy link
Member
exjam commented Oct 12, 2018

padscore_kpad.cpp gCoreButtonMap is now unused.

In KPADReadEx you use gLastButtonState but don't update its value., Also gLastButtonState should be moved to sKpadData->lastButtonState. And it needs to be per controller rather than for all.

So something roughly like this:

auto lastButtonState = sKpadData->lastButtonState[channel];
auto currentButtonState = uint32_t { 0 };

....

auto previous = lastButtonState & bit;
if (status == input::ButtonStatus::ButtonPressed) {
currentButtonState |= bit;
}

...

sKpadData->lastButtonState[channel] = currentButtonState;

Also do not worry about constantly rebasing onto latest master, I can do that when merging.

config::input::wpadType[0] = config->get_qualified_as<std::string>("input.wpadType0").value_or(config::input::wpadType[0]);
config::input::wpadType[1] = config->get_qualified_as<std::string>("input.wpadType1").value_or(config::input::wpadType[1]);
config::input::wpadType[2] = config->get_qualified_as<std::string>("input.wpadType2").value_or(config::input::wpadType[2]);
config::input::wpadType[3] = config->get_qualified_as<std::string>("input.wpadType3").value_or(config::input::wpadType[3]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change these repetitive code to use for loops?

also in other places below and in config.cpp and main.cpp ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would require using string formatting to do that, probably nicer like it is here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   for (int i = 0; i < 4; i++) {
       config::input::wpadType[i] = config->get_qualified_as<std::string>("input.wpadType" + std::to_string(i)).value_or(config::input::wpadType[i]);
   }

or simply std::to_string, no need to really use anything more fancy like fmt. Nothing wrong with some small formatting or use of a lookup table (std:string[4] digits = {"0", "1", "2", "3"};).

Copy link
Member
@brett19 brett19 Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point 👍

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.

5 participants
0