Skip to content

Commit 2e2796e

Browse files
committed
Add rough random movements... WIP?
1 parent 6d89af0 commit 2e2796e

File tree

2 files changed

+53
-69
lines changed

2 files changed

+53
-69
lines changed

Joystick.c

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void HID_Task(void)
148148

149149
typedef enum {
150150
SYNC_CONTROLLER,
151+
BOOYAH,
151152
SYNC_POSITION,
152153
ZIG_ZAG,
153154
MOVE,
@@ -239,6 +240,8 @@ void complete_zig_zag_pattern(USB_JoystickReport_Input_t *const ReportData)
239240
return;
240241
}
241242

243+
bool moving_left = true;
244+
242245
// Prepare the next report for the host
243246
void GetNextReport(USB_JoystickReport_Input_t *const ReportData)
244247
{
@@ -281,7 +284,7 @@ void GetNextReport(USB_JoystickReport_Input_t *const ReportData)
281284
if (command_count > ms_2_count(2000))
282285
{
283286
command_count = 0;
284-
state = SYNC_POSITION;
287+
state = BOOYAH;
285288
}
286289
else
287290
{
@@ -292,6 +295,47 @@ void GetNextReport(USB_JoystickReport_Input_t *const ReportData)
292295
command_count++;
293296
}
294297
break;
298+
case BOOYAH: ;
299+
bool a_down = false;
300+
if(command_count % 2 != 0)
301+
{
302+
ReportData->Button |= SWITCH_A | SWITCH_RCLICK;
303+
a_down = true;
304+
}
305+
306+
if(command_count/60 % 3 != 0)
307+
ReportData->Button |= SWITCH_ZR;
308+
else
309+
ReportData->Button |= SWITCH_ZL;
310+
311+
int rnd;
312+
313+
// Booyah!
314+
if((rnd = rand() % 512) == 0 && a_down)
315+
ReportData->HAT = HAT_BOTTOM;
316+
317+
if((rnd = rand() % 16) == 0)
318+
moving_left = !moving_left;
319+
if(moving_left)
320+
ReportData->LX = STICK_MIN;
321+
else
322+
ReportData->LX = STICK_MAX;
323+
324+
ReportData->LY = STICK_MIN;
325+
326+
if((rnd = rand() % 16) == 0)
327+
{
328+
if((rnd = rand() % 4) == 0)
329+
moving_left = !moving_left;
330+
if(moving_left)
331+
ReportData->RX = STICK_MIN;
332+
else
333+
ReportData->RX = STICK_MAX;
334+
}
335+
336+
337+
command_count++;
338+
break;
295339
case SYNC_POSITION:
296340
if (command_count > ms_2_count(4000))
297341
{
@@ -344,7 +388,7 @@ void GetNextReport(USB_JoystickReport_Input_t *const ReportData)
344388
return;
345389
}
346390

347-
if (state != SYNC_CONTROLLER && state != SYNC_POSITION && state != DONE)
391+
/*if (state != SYNC_CONTROLLER && state != SYNC_POSITION && state != DONE)
348392
{
349393
// Position update (diagonal moves doesn't work since they ink two dots... is not necessary to test them)
350394
if (ReportData->HAT == HAT_RIGHT)
@@ -359,7 +403,7 @@ void GetNextReport(USB_JoystickReport_Input_t *const ReportData)
359403
// Inking (the printing patterns above will not move outside the canvas... is not necessary to test them)
360404
if (is_black(xpos, ypos))
361405
ReportData->Button |= SWITCH_A;
362-
}
406+
}*/
363407

364408
// Prepare to echo this report
365409
memcpy(&last_report, ReportData, sizeof(USB_JoystickReport_Input_t));

README.md

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ On June 20, 2017, Nintendo released System Update v3.0.0 for the Nintendo Switch
88

99
Unlike the Wii U, which handles these controllers on a 'per-game' basis, the Switch treats the Pokken controller as if it was a Switch Pro Controller. Along with having the icon for the Pro Controller, it functions just like it in terms of using it in other games, apart from the lack of physical controls such as analog sticks, the buttons for the stick clicks, or other system buttons such as Home or Capture.
1010

11-
### Printing Splatoon Posts
12-
For my own personal use, I repurposed Switch-Fightstick to output a set sequence of inputs to systematically print Splatoon posts. This works by using the smallest size pen and D-pad inputs to plot out each pixel one-by-one.
11+
### Booyah?
12+
For my own personal experiment, I re-purposed Switch-Fightstick to use random inputs to spray ink in turf war.
1313

14-
#### Printing Procedure
15-
Just press L to select the pixel pen and plug in the controller: it will automatically sync with the console, reset the cursor position, clean the canvas and print. In case you see issues with controller conflicts while in docked mode, try using a USB-C to USB-A adapter in handheld mode. In dock mode, changes in the HDMI connection will briefly make the Switch not respond to incoming USB commands, skipping pixels in the printout. These changes may include turning off the TV, or switching the HDMI input. (Switching to the internal tuner will be OK, if this doesn't trigger a change in the HDMI input.)
14+
#### That's bad. Your team will lose...
15+
I like to see the world burn.
1616

17-
The printing goes from top to bottom, alternating between two lines, from left to right and viceversa. Printing currently takes about 25 minutes.
18-
19-
Optionally, upon completion, the Teensy's LED will begin flashing. On compatible Arduino boards, some combination of the onboard LEDs will flash. On the UNO, for instance, both TX and RX LEDs will flash, however the other LEDs will not. If this functionality is desired, issue `make with-alert` when building the firmware. All pins on both PORTB and PORTD are toggled! Beware of possible interactions with any attached peripherals, say from another project.
20-
21-
This repository has been tested using a Teensy 2.0++, Arduino UNO R3, and Arduino Micro.
17+
#### I'll repor-
18+
I mean after like a few matches, it'll be ranked into only playing with baby squids by the match making anyway. They most likely don't play much better than random inputs anyway.
2219

2320
#### Compiling and Flashing onto the Teensy 2.0++
2421
Go to the Teensy website and download/install the [Teensy Loader application](https://www.pjrc.com/teensy/loader.html). For Linux, follow their instructions for installing the [GCC Compiler and Tools](https://www.pjrc.com/teensy/gcc.html). For Windows, you will need the [latest AVR toolchain](http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx) from the Atmel site. See [this issue](https://github.com/LightningStalker/Splatmeme-Printer/issues/10) and [this thread](http://gbatemp.net/threads/how-to-use-shinyquagsires-splatoon-2-post-printer.479497/) on GBAtemp for more information. (Note for Mac users - the AVR MacPack is now called AVR CrossPack. If that does not work, you can try installing `avr-gcc` with `brew`.)
@@ -42,60 +39,3 @@ Sometimes, the Arduino will show up under a different port, so you may need to r
4239
If you ever need to use your Arduino Micro with Arduino IDE again, the process is somewhat similar. Upload your sketch in the usual way and double tap reset button on the Arduino. It may take several tries and various timings, but should eventually be successful.
4340

4441
The Arduino Leonardo is theoretically compatible, but has not been tested. It also has the ATmega32u4, and is layed out somewhat similar to the Micro.
45-
46-
#### Attaching the optional buzzer
47-
A suitable 5V buzzer may be attached to any of the available pins on PORTB or PORTD. When compiled with `make with-alert`, it will begin sounding once printing has finished. See above warning about PORTB and PORTD. Reference section 31 of [the AT90USB1286 datasheet](http://www.atmel.com/images/doc7593.pdf) for maximum current specs.
48-
49-
Pin 6 on the Teensy is already used for the LED and it draws around 3mA when fully lit. It is recommended to connect the buzzer to another pin. Do not bridge pins for more current.
50-
51-
For the Arduino UNO, the easiest place to connect the buzzer is to any pin of JP2, or pins 1, 3, or 4 of ICSP1, next to JP2. Refer to section 29 of [the ATmega16u2 datasheet](http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf) for maximum current specs. Do not bridge pins for more current.
52-
53-
On the Arduino Micro, D0-D3 may be used, or pins 1, 3, or 4 (PORTB) on the ICSP header. Power specs are the same as for the AT90USB1286 used on the Teensy. The TX and RX LEDs are on PORTD and PORTB respectively and draw around 3mA apiece. Do not bridge pins for more current.
54-
55-
#### Using your own image
56-
The image printed depends on `image.c` which is generated with `png2c.py` which takes a 320x120 .png image. `png2c.py` will pack the image to a linear 1bpp array. If the image is not already made up of only black and white pixels, it will be dithered.
57-
58-
In order to run `png2c.py`, you need to [install Python](https://www.python.org/downloads/) (I use Python 2.7). Also, you need to have the [Python Imaging Library](https://pillow.readthedocs.io/en/3.0.0/installation.html) installed ([install pip](https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip) if you need to).
59-
Using the supplied sample image, splatoonpattern.png:
60-
61-
```
62-
$ python png2c.py splatoonpattern.png
63-
```
64-
Substitute your own .png image to generate the `image.c` file necessary to print. Just make sure your image is in the `Switch-Fightstick` directory.
65-
66-
To generate an inverted colormap of the image:
67-
68-
```
69-
$ python png2c.py -i splatoonpattern.png
70-
```
71-
72-
#### What the dither?
73-
As previously mentioned, png2c.py will dither the input image if you supply an image that is not already made up of only black and white pixels. Say you want to print this bomb image you created...
74-
75-
![http://imgur.com/r2GoVdD.png](http://imgur.com/r2GoVdD.png)
76-
77-
*image via [vjapolitzer](https://github.com/vjapolitzer)*
78-
79-
...but you want to know what it will look like before committing to printing it in Splatoon. Fret not! You can also preview or save a copy of the bilevel version of your image.
80-
81-
To preview the bilevel image:
82-
83-
```
84-
$ python png2c.py -p yourImage.png
85-
```
86-
87-
To save the bilevel image:
88-
89-
```
90-
$ python png2c.py -s yourImage.png
91-
```
92-
93-
![http://imgur.com/uUOeJ7P.png](http://imgur.com/uUOeJ7P.png)
94-
95-
*image via [vjapolitzer](https://github.com/vjapolitzer)*
96-
97-
Looks good! Time to get printing.
98-
99-
### Sample
100-
![http://i.imgur.com/93B1Usb.jpg](http://i.imgur.com/93B1Usb.jpg)
101-
*image via [/u/Stofers](https://www.reddit.com/user/Stofers)*

0 commit comments

Comments
 (0)