Skip to content

Commit

Permalink
WhiteButton detectors for Left Stick and A button with dark background
Browse files Browse the repository at this point in the history
  • Loading branch information
jw098 committed Sep 1, 2024
1 parent 2f17b07 commit 85f7a74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const char* white_button_template_path(WhiteButton type){
switch (type){
case WhiteButton::ButtonA:
return "PokemonSV/Buttons/WhiteButtonA.png";
case WhiteButton::ButtonA2:
return "PokemonSV/Buttons/WhiteButtonA-dark.png";
case WhiteButton::ButtonB:
return "PokemonSV/Buttons/WhiteButtonB.png";
case WhiteButton::ButtonX:
Expand All @@ -44,6 +46,8 @@ const char* white_button_template_path(WhiteButton type){
return "PokemonSV/Buttons/ArrowLeft.png";
case WhiteButton::ButtonRight:
return "PokemonSV/Buttons/ArrowRight.png";
case WhiteButton::ButtonLStick:
return "PokemonSV/Buttons/LStick.png";
default:
return "";
}
Expand All @@ -53,6 +57,8 @@ const WhiteButtonMatcher& get_button_matcher(WhiteButton type){
switch (type){
case WhiteButton::ButtonA:
return WhiteButtonMatcher::A();
case WhiteButton::ButtonA2:
return WhiteButtonMatcher::A2();
case WhiteButton::ButtonB:
return WhiteButtonMatcher::B();
case WhiteButton::ButtonX:
Expand All @@ -65,6 +71,8 @@ const WhiteButtonMatcher& get_button_matcher(WhiteButton type){
return WhiteButtonMatcher::ArrowLeft();
case WhiteButton::ButtonRight:
return WhiteButtonMatcher::ArrowRight();
case WhiteButton::ButtonLStick:
return WhiteButtonMatcher::LStick();
default:
throw std::runtime_error("No corresponding ButtonMatcher for WhiteButton");
}
Expand All @@ -85,6 +93,10 @@ const WhiteButtonMatcher& WhiteButtonMatcher::A(){
static WhiteButtonMatcher matcher(WhiteButton::ButtonA, 15, 15, 100);
return matcher;
}
const WhiteButtonMatcher& WhiteButtonMatcher::A2(){
static WhiteButtonMatcher matcher(WhiteButton::ButtonA2, 15, 15, 100);
return matcher;
}
const WhiteButtonMatcher& WhiteButtonMatcher::B(){
static WhiteButtonMatcher matcher(WhiteButton::ButtonB, 15, 15, 90);
return matcher;
Expand All @@ -109,6 +121,11 @@ const WhiteButtonMatcher& WhiteButtonMatcher::ArrowRight(){
static WhiteButtonMatcher matcher(WhiteButton::ButtonRight, 15, 15, 90);
return matcher;
}
const WhiteButtonMatcher& WhiteButtonMatcher::LStick(){
static WhiteButtonMatcher matcher(WhiteButton::ButtonLStick, 15, 15, 90);
return matcher;
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,29 @@ namespace PokemonSV{

enum class WhiteButton{
ButtonA,
ButtonA2,
ButtonB,
ButtonX,
ButtonY,
ButtonMinus,
ButtonLeft,
ButtonRight,
ButtonLStick,
};


class WhiteButtonMatcher : public ImageMatch::WaterfillTemplateMatcher{
public:
WhiteButtonMatcher(WhiteButton type, size_t min_width, size_t max_width, double max_rmsd);
static const WhiteButtonMatcher& A();
static const WhiteButtonMatcher& A2();
static const WhiteButtonMatcher& B();
static const WhiteButtonMatcher& X();
static const WhiteButtonMatcher& Y();
static const WhiteButtonMatcher& Minus();
static const WhiteButtonMatcher& ArrowLeft();
static const WhiteButtonMatcher& ArrowRight();
static const WhiteButtonMatcher& LStick();

virtual bool check_image(const ImageViewRGB32& image) const override{
return image.width() >= m_min_width && image.height() >= m_min_height;
Expand Down

0 comments on commit 85f7a74

Please sign in to comment.