-
Notifications
You must be signed in to change notification settings - Fork 130
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
Famicom/NES - Added SNES-2-NES Controller Adaptor support. #1340
Open
Kalixtan
wants to merge
1
commit into
ares-emulator:master
Choose a base branch
from
Kalixtan:Famicom-Stuff-01
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
Changes from all commits
Commits
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 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 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 |
---|---|---|
|
@@ -31,3 +31,4 @@ struct Controller { | |
|
||
#include "port.hpp" | ||
#include "gamepad/gamepad.hpp" | ||
#include "sfcgamepad/sfcgamepad.hpp" |
This file contains 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 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,94 @@ | ||
SFC_Gamepad::SFC_Gamepad(Node::Port parent) { | ||
node = parent->append<Node::Peripheral>("Super Famicom Gamepad"); | ||
|
||
up = node->append<Node::Input::Button>("Up"); | ||
down = node->append<Node::Input::Button>("Down"); | ||
left = node->append<Node::Input::Button>("Left"); | ||
right = node->append<Node::Input::Button>("Right"); | ||
b = node->append<Node::Input::Button>("B"); | ||
a = node->append<Node::Input::Button>("A"); | ||
y = node->append<Node::Input::Button>("Y"); | ||
x = node->append<Node::Input::Button>("X"); | ||
l = node->append<Node::Input::Button>("L"); | ||
r = node->append<Node::Input::Button>("R"); | ||
select = node->append<Node::Input::Button>("Select"); | ||
start = node->append<Node::Input::Button>("Start"); | ||
} | ||
|
||
auto SFC_Gamepad::data() -> n3 { | ||
if(latched == 1) { | ||
platform->input(b); | ||
return b->value(); | ||
} | ||
|
||
//note: D-pad physically prevents up+down and left+right from being pressed at the same time | ||
switch(counter++) { | ||
case 0: return b->value(); | ||
case 1: return y->value(); | ||
case 2: return select->value(); | ||
case 3: return start->value(); | ||
case 4: return upLatch; | ||
case 5: return downLatch; | ||
case 6: return leftLatch; | ||
case 7: return rightLatch; | ||
case 8: return a->value(); | ||
case 9: return x->value(); | ||
case 10: return l->value(); | ||
case 11: return r->value(); | ||
|
||
case 12: return 0; //4-bit device signature | ||
case 13: return 0; | ||
case 14: return 0; | ||
case 15: return 0; | ||
} | ||
|
||
counter = 16; | ||
return 1; | ||
} | ||
|
||
auto SFC_Gamepad::latch(n1 data) -> void { | ||
if(latched == data) return; | ||
latched = data; | ||
counter = 0; | ||
|
||
if(latched == 0) { | ||
platform->input(b); | ||
platform->input(y); | ||
platform->input(select); | ||
platform->input(start); | ||
platform->input(up); | ||
platform->input(down); | ||
platform->input(left); | ||
platform->input(right); | ||
platform->input(a); | ||
platform->input(x); | ||
platform->input(l); | ||
platform->input(r); | ||
|
||
if(!(up->value() & down->value())) { | ||
yHold = 0, upLatch = up->value(), downLatch = down->value(); | ||
} else if(!yHold) { | ||
yHold = 1, swap(upLatch, downLatch); | ||
} | ||
|
||
if(!(left->value() & right->value())) { | ||
xHold = 0, leftLatch = left->value(), rightLatch = right->value(); | ||
} else if(!xHold) { | ||
xHold = 1, swap(leftLatch, rightLatch); | ||
} | ||
} | ||
} | ||
|
||
|
||
auto SFC_Gamepad::serialize(serializer& s) -> void { | ||
s(latched); | ||
s(counter); | ||
|
||
s(yHold); | ||
s(upLatch); | ||
s(downLatch); | ||
s(xHold); | ||
s(leftLatch); | ||
s(rightLatch); | ||
} | ||
|
This file contains 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,31 @@ | ||
struct SFC_Gamepad : Controller { | ||
Node::Input::Button up; | ||
Node::Input::Button down; | ||
Node::Input::Button left; | ||
Node::Input::Button right; | ||
Node::Input::Button b; | ||
Node::Input::Button a; | ||
Node::Input::Button y; | ||
Node::Input::Button x; | ||
Node::Input::Button l; | ||
Node::Input::Button r; | ||
Node::Input::Button select; | ||
Node::Input::Button start; | ||
|
||
SFC_Gamepad(Node::Port); | ||
|
||
auto data() -> n3 override; | ||
auto latch(n1 data) -> void override; | ||
auto serialize(serializer&) -> void override; | ||
|
||
private: | ||
n1 latched; | ||
n8 counter; | ||
|
||
n1 yHold; | ||
n1 upLatch; | ||
n1 downLatch; | ||
n1 xHold; | ||
n1 leftLatch; | ||
n1 rightLatch; | ||
}; |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We don't usually use underscores in class names; consider
SuperFamicomController
, as SFCController looks awkward.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make whatever changes you want, dont have time to deal with this right now, personal things are happening in my life and its likey 5 seconds for you anyways....
Same with the other pull request for those Coleco-Vision Mappers.