Brikwerk / nxbt

Control your Nintendo Switch through a website, terminal, or macro.
MIT License
809 stars 97 forks source link

Skips button presses #47

Open mataln opened 2 years ago

mataln commented 2 years ago

Seems to skip button presses intermittently during macros, not sure if due to bluetooth adapter? Same effect on two different bluetooth adapters though. Using the webapp

Phybersaur commented 2 years ago

@mja2106 Just out of curiosity, which games are you having issues with it on?

Phybersaur commented 2 years ago

I've been using NXBT for around a month now and have found it to be an amazingly powerful tool for automating tasks on some games (e.g. releasing boxes of Pokemon). However, I am having this exact same issue and haven't been able to find a solution; I will write a macro, run it, and it will be working fine then all of a sudden skip an input and the automated task messes up and I have to force-stop NXBT as a result. The skip is not always in the same place, either; sometimes I can leave a macro running for 30-45 minutes and it will carry out its function perfectly, then I run the same function again and it will randomly miss an input after a random amount of time.

Because I'm not really sure what information would be useful for helping to determine what is causing the issue, I will include everything I can think of:

HARDWARE:

ATTEMPTED FIXES:

If there is any useful information that I can provide then please let me know what it is and I'll do my best to post it. :)

(New to GitHub so still not 100% sure what I'm doing, I hope this was the right place for this comment!)

Phybersaur commented 2 years ago

UPDATE:

I've been messing around this evening trying out a couple of other things I didn't try before:

I also checked the dev branch of NXBT and saw that it had been updated 10 days ago, with the updates described "Added dynamic frequency, better timing, macro fix**". I wasn't sure if this was the issue that was fixed or not but thought it was worth a try and so updated my files to reflect the changes; again, this initially seemed promising but eventually the issues returned.

Not sure if there's anything I can do to help provide more useful info on what's going on when the issues are occurring but if there is then I'm happy to do so!

jackwiseman commented 2 years ago

Glad to see this addressed here as well. I'm facing the same issue, while utilizing the python API to automate the breeding process in Pokémon BD. I have tried many of the above attempted fixes including massive time.sleep calls in between button presses, yet buttons are randomly missed.

Phybersaur commented 2 years ago

I'm facing the same issue, while utilizing the python API to automate the breeding process in Pokémon BD.

I've had some success automating most aspects of the breeding process in BDSP consistently but not everything unfortunately. Here's everything I have on this:

  BDSP Breeding Macro Stuff ### COLLECTING EGGS To set this up, make sure you have: - Text Speed set to Fast - A full party with no eggs - Empty boxes at the start of your PC (to make the next steps easier) - The Pokémon you want to breed already in the Daycare Centre - An egg ready to collect from the man outside the Daycare Centre (he will be facing to the right when this is the case) - Your bike equipped (i.e. you should be cycling, Gear doesn't matter) Stand in the tile to the left of the Daycare Man, then activate the macro:
  Egg Collection Macro ``` 5.0S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S DPAD_LEFT 1.0S DPAD_RIGHT 1.0S 0.5S DPAD_RIGHT 1.0S 0.5S DPAD_RIGHT 1.0S 0.5S ``` (then repeat everything except Line 1 (5.0S) over and over until you have as many eggs as you need)
  Egg Collection Macro Explanation **INITIALISING** `5.0S` (I always include this once at the start of any macro to deal with any initial connection issues) --- **SPEAKING TO DAYCARE MAN** ``` A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S A 0.1S 1.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S B 0.1S 0.5S ``` In theory, you should collect the egg on the sixth A press, after which you could just use B to back out. However, if it misses an A input, then the sixth press would be a B, which would result in you giving the egg away to the Daycare Couple rather than collecting it yourself, so I've set the three inputs following the sixth to A also. At the end, it should exit the dialogue and probably toggle the bike a few times as well; **this is due to the additional B inputs to counter any missed inputs.** Also, since a new egg being generated is chance-based (see Generating New Egg below for more details) this macro also works when the Daycare Man doesn't have an egg to give to you; assuming no missed inputs it will speak to him a few times then back out completely and toggle the bike mode a couple of times. The timings on these could be a lot better, but using a load of 1.5S spacers accommodates: - egg collection dialogue - no egg dialogue - missed inputs By the end of this, you should be stood to the left of the Daycare Man with no dialogue boxes open. ------------------- **GENERATING NEW EGG** ``` DPAD_LEFT 1.0S DPAD_RIGHT 1.0S (repeat this 30+ times) 0.5S DPAD_RIGHT 1.0S 0.5S DPAD_RIGHT 1.0S 0.5S ``` This makes you walk left and right in the 4 tiles to the left of the Daycare Man. This is quite slow, I know, but literally everything else I tried messed up if inputs were missed: - I've tried doing the normal up and down route and moving to the left once enough steps had been taken, but the instant that a movement input is missed then it is broken until you manually reset it. - I've tried having the trainer fly into Solaceon Town after the number of steps required had been taken but if any kind of movement input is missed whilst navigating from the Pokémon Centre to the Daycare Man then the whole thing breaks until manually reset. Since this method only requires you to move left and right over and over in a small area, it's very consistent and relatively failsafe, with the final set of "DPAD_RIGHT"s mainly there to ensure the trainer is stood next to the Daycare Man in case the final normal DPAD_RIGHT was missed for some reason. It seems like every 175 steps it has a chance to spawn an egg, though this might be affected by whether or not you have the Oval Charm, how much the two Pokémon you're breeding get along, etc.. I'm not 100% sure on the mechanics of this but it is has always been after 175/350/525/600 steps during my tests, indicating a chance every 175 steps, and since one DPAD_LEFT + DPAD_RIGHT is 6 steps, it should only take 30 cycles (totalling 180 steps) to get the Daycare Man ready to possibly give you another egg. If you are worried about missing inputs, then you can add additional cycles; I think mine has 32 altogether (192 steps if no inputs are missed) and it hasn't messed up yet. By the end of this, you should be stood in the tile to the left of the Daycare Man. ------------------- Then just repeat SPEAKING TO DAYCARE MAN and GENERATING NEW EGG over and over until you have as many eggs as you'd like.
------------------- ### HATCHING EGGS To set this up, make sure you have: - Text Speed set to Fast - Give Nicknames set to Don't give - The egg(s) you want to hatch in your party - Your bike equipped (i.e. you should be cycling) and set to Fourth Gear (the speedy one!) - (Optional) A Pokémon with the ability Magma Armor or Flame Body in the first slot of your party Navigate to the southern-most tile of the long path spanning Route 209 <--> Solaceon Town <--> Route 210 ([screenshot](https://i.imgur.com/xYRj9eD.jpg)), then activate the macro:
  Hatching Eggs Macro ``` 5.0S DPAD_UP 11.0S DPAD_DOWN 11.0S (repeat as many times as needed, then) A 0.1S 0.4S (repeat as many times as needed; ) ```
I haven't inserted a complete macro for this one into the post because it depends heavily on which Pokémon you're trying to hatch (and whether or not you're using a Flame Body/Magma Armor Pokémon) as to how many steps are required (and thus how many lines of DPAD_UP/DPAD_DOWN you will need) but to work it out: - Find out how many steps are required to hatch the Pokémon you're breeding ([Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_base_Egg_cycles); use final column, and see below for converting this for Flame Body/Magma Armor egg hatching) - Divide that number by 254 (the path is 128 steps long but the first step each way doesn't count, so one complete "loop" (up+down) is 254 steps) Then just include that many DPAD_UP+DPAD_DOWN couples (rounded up). As for the A spam, each egg hatching animation takes aroud 20 seconds from "Oh?" to end, so 200 repetitions should be fine but I'd recommend 240+ to be safe. Originally, I had this part set to do A a few times then wait 15 seconds or so then spam A more times and repeat, but spamming A like above seems to be more consistent for some reason. This macro has never failed for me; not sure if that's because it's very simple inputs or very long inputs.
  Flame Body/Magma Armor Steps Calculations 1. Find out how many steps are required to hatch the Pokémon you're breeding ([Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_base_Egg_cycles); use final column! 2. Divide this number by 512. - If this does not produce a whole number, round up to the nearest whole number (e.g. 7.5 --> 8) 3. Multiply this by 256 This should produce the number of steps required when using a Pokémon with Flame Body or Magma Armor.
------------------- ### THE REST I used to have a macro that combined the two above so that, if you started out with a party of eggs, you could walk them whilst collecting more eggs. This macro also worked very consistently, but I opted to split them into the two above because that would allow you to run the first one (Collecting Eggs) as many times as needed without having to come back and swap new eggs into the party, as is currently the case with the second one (Hatching Eggs). Unfortunately, swapping hatched Pokémon out and new eggs in has proved impossible to macro consistently; the macro code I was using for this purpose was something like:
  Egg Swap Macro ``` X 0.1S 1.0S A 0.1S 1.5S R 0.1S 1.5S Y 0.1S 0.5S Y 0.1S 0.5S DPAD_DOWN 0.1S 0.5S A 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S A 0.1S 0.5s DPAD_RIGHT 0.1S 0.5S DPAD_UP 0.1S 0.5S (then some amount of DPAD_RIGHT inputs corresponding to which column the hatched Pokémon were going into) A 0.1S 0.5S DPAD_RIGHT 0.1S 0.5S A 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S DPAD_DOWN 0.1S 0.5S A 0.1S 0.5S DPAD_DOWN 0.1S 0.5S (then some amount of DPAD_LEFT inputs to allow the new eggs to be slotted into the party) B 0.1S 1.5S B 0.1S 1.5S B 0.1S 1.0S ```
However, almost any kind of missed input here messes the whole thing up (missing Y inputs interferes with the selection mode, missing DPAD inputs interferes with Pokémon/Egg positions and selections, missing A inputs interferes with the selection process, missing B inputs would leave you in the menu and adding extras would mess with the Bike Gears), so I had to remove this part of the macro and just use the above two, with the egg swapping done manually inbetween Hatching Eggs macros.

Since BDSP has become somewhat notorious for bugs, I did consider that maybe the issue was with the game not responding to inputs properly rather than NXBT not providing them successfully (which is why I asked the OP what game they were having issues with above), but I've had issues with missed inputs on Animal Crossing and the Switch's Button Test function in Settings so I don't think that's it.


Just in case it's useful, could you post:

jackwiseman commented 2 years ago

@Phybersaur I'm using an external bluetooth 4.0 adapter on my raspberry pi 4 model B, and similarly I've run into the same issue you have. Most of the macros work fine, both getting new eggs and hatching eggs, but it's the switching hatched pokemon into the box and eggs into the party that often gets messed up.

mataln commented 2 years ago

@Phybersaur you might find the macro below works better for collecting eggs from the man (+ I think it's faster to do it without the bike when you're left of the man - the bike doesn't accelerate quickly enough in the small number of tiles).

I've set it up so that it's robust to skipped button presses. I haven't managed to do the same for hatching them - it generally seems to be navigating the menus to get 5 fresh eggs out of the boxes when it goes wrong, but it might just be that I don't notice it during the other bits.

Egg collecting macro LOOP 1000 LOOP 90 L_STICK@-100+000 0.45s A 0.05S L_STICK@+100+000 0.45s A 0.05s

Edit: Lines 3 and 7 should be tabbed in one step and 4,5,6 by two, dunno how to format it on here