1. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    I've learned the basics of making Homebrew so i wanna help some people out and make a tutorial on making Homebrew, so here it is!
    BTW this tutorial is for Windows only'
    If anything is incorrect, please correct me in the comments.
    Although you could get the switch examples on their own, I would reccomend DevKitPro as it has msys2 built in and lets you run make from Command Prompt which is neccessary. You will also want Notepad++.
    Step 1: Go to github.com/devkitPro/installer/releases/ and download the latest release as an *.exe file. On the installer, click Next then select "Remove Downloaded Files" as it saves space on storage. Click next and you should get to a screen where you can choose what to install. If your only going to be making Switch Homebrew (and want to save the most amount of storage) untick everything except "Switch Development" click Next and wait for it to install. When it's done click Next and Click Finish, although you could donate to them for their hard work.

    Step 2: Unless you already have it installed, we are gonna want to install Notepad++. Go to notepad-plus-plus.org/download/v7.5.7.html. Get either "Notepad++ Installer 32-bit x86" or "Notepad++ Installer 64-bit x64" depending on what Bit you have. If you dont know what Bit you have, I would recommend getting the 32-Bit one. After downloading and running the Notepad++ installer. You'll wanna select your language and click Ok, then click Next and I Agree. Select an install location. I would recommend leaving it as default, then click Next. On choose components, I would recommend you keep "Auto-completion files", "Plugins", "Auto Updater", and "Context menu entry" although if your saving storage space, untick them all except "Context Menu Entry". On the next screen dont tick anything except "Create Desktop Shortcut" if you would like. Click Next and wait for it to install. When done, untick "Run Notepad++"and click Finish.
    Now we can get onto making Homebrew!
    Step 3: Go to where DevKitPro installed, most likely "C:\devkitPro" then go to "examples\switch\graphics\printing\hello-world". There should be a file named "Makefile" and another folder called "source". On Windows 7, hold Shift in the folder that has "Makefile" in it and right click, then select "Open Command Window Here". On Windows 10, click on this
    upload_2018-7-7_9-12-45.png
    then copy the link and open up CMD in start menu. You'll then want to type "CD " then right click and paste the link in. You should get something like this.
    upload_2018-7-7_9-13-42.png
    Now type the word "make" into cmd and it should create some files in the same place as "Makefile". Delet all the files it makes except for "source", "Makefile" and "hello-world.nro" copy "hello-world.nro" to your "switch" folder on your SD Card and run it using the Homebrew Launcher on your switch, or through an emulator. If it says "Hello world!" then CONGRATULATIONS! YOU JUST MADE (really you compiled) YOUR FIRST HOMEBREW!
    Now you can add extra features and make it more in-depth.
    Go into \source and right click on main.c and Open it Using Notepad++. Don't be scared of all the code, just find " printf("\x1b[16;20HHello world!");". the \x1b[16;20H is just telling the system where to place the text on the screen. You can delete that bit if you want to it will say printf("Hello world!"); if it makes you less confused. Change the words "Hello world!" to anything you want (but don't try emojis). If you go to the GitHub of my first app (github.com/lolicop123/fuck-u/releases/) and find the oldest version, you'll see that all I did was change the word "Hello World!" to "Fuck you". After changing the words "Hello World"to whatever you want, hit the save button ( The blue floppy disk (Not the one of 3 Floppy Disks)) and close Notepad++. Delete hello-world.nro and re-run "make", deleting all the files I said to delete before. and copy hello-world.nro to "\switch" on your SD Card and running it, or running it through an emulator. If everything went well it should display the text you wrote on the screen. CONGRATULATIONS! YOU MADE YOUR SECOND EVER HOMEBREW!
    Open up main.c again. Scroll down until you find "u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);" and press enter underneath it for a new line. TYPE (dont copy+paste unless you HAVE to) this code out on the new line:
    Code:
    if(kDown & KEY_A)
            {
                printf(" INSERT TEXT HERE");
            }
    Take a look at this code. KEY_A corresponds to the A button. You could change this to B, X, Y or whatever other button, heres a button list: witchbrew.github.io/libnx/hid_8h.html#ae829d22473d2e99ee1157f6e2d526b95 printf obviously corresponds to printing on the screen, you should know that already though. Obviously, change INSERT TEXT HERE to whatever text you want, although i will need to show you a cheat. Always put a space after the printf(" so it looks likle this printf"( <-- theres a space there") otherwise your words wont be separated if you press A twice once you've got the code and changed the INSERT TEXT HERE thing, save, run "make", delete the stuff and run hello-world.nro on your switch/emulator. Now try pressing A and if it says what you want it to CONGRATULATIONS!
    If you want to add more button prompts, take a look at my latest release of "Fuck you".
    (GBATemp wont let me insert pics anymore so https://ibb.co/h5jtwo )
    I'll add more stuff as time goes by, but for now this is just the bare bones of making Homebrew for the Switch, for any new Homebrew creators that need help!

    If you want to make some C++ apps wich use console, make sure to check this out: https://gist.github.com/XorTroll/94b542e3d5a8164a10742df0ca4f052b (Thanks @XorTroll )
     
    Last edited by xXxSwagnemitexXx, Jul 14, 2018
    Garou, JellyPerson, gnilwob and 7 others like this.
  2. jimmyj

    jimmyj Official founder of altariaism. Copyright jimmyj
    Member

    Joined:
    May 26, 2017
    Messages:
    1,480
    Country:
    United Kingdom
    10/10. No joke though. I have a basic knowledge of programming and this is basically all you do when you're learing stuff
     
    bennyman123abc likes this.
  3. MyLegGuy

    MyLegGuy GBAtemp Advanced Fan
    Member

    Joined:
    Nov 26, 2014
    Messages:
    651
    Country:
    United States
    okay I made a thing that just says hello world, now how do I do an image
     
  4. jimmyj

    jimmyj Official founder of altariaism. Copyright jimmyj
    Member

    Joined:
    May 26, 2017
    Messages:
    1,480
    Country:
    United Kingdom
    there is images in the examples.
     
    MyLegGuy likes this.
  5. MyLegGuy

    MyLegGuy GBAtemp Advanced Fan
    Member

    Joined:
    Nov 26, 2014
    Messages:
    651
    Country:
    United States
    Okay, here is my review. 2/10, no joke though.

    * Doesn't explain anything about C programming at all, doesn't even tell me that the program starts at the "main" function.
    * Doesn't explain the printf position markup at all, or even how to do format strings.
    * Tells you to manually delete files instead of doing "make clean"
    * Doesn't explain how the makefile works at all, or even that "make" executes the makefile.
    * Doesn't explain how the & operator works.
    * Most of the links can't be clicked because they don't start with "http(s)://".
    * Tells me to install Notepad++ so I can write Hello World.

    Things it does well:
    * How to type "make"
    * How to use the DevkitPro installer
    * Links to the list of button constants.

    Anybody following this guide will be very, very confused when they try to do anything but make Hello World. At least give a link where people can learn more.
     
    ZetaDesigns, 8BitWonder and safan41 like this.
  6. jimmyj

    jimmyj Official founder of altariaism. Copyright jimmyj
    Member

    Joined:
    May 26, 2017
    Messages:
    1,480
    Country:
    United Kingdom
    10/10 was sarcasm. the parts after the no joke is what people usally do when they get their hands on compiling and stuffs.
     
  7. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    thanks
    i might add a bit for images later

    — Posts automatically merged - Please don't double post! —

    and i know this guide is not good its only very small and minimal, if people want to learn more they can go find out themselves
     
    jimmyj likes this.
  8. DutchyDutch

    DutchyDutch COPYRIGHT LOLOLOLOL
    Member

    Joined:
    Nov 16, 2014
    Messages:
    950
    Country:
    Netherlands
    I doubt the guy meant to do anything but show how to get your code working on the Switch. This isn't supposed to be a guide that learns you C, you should probably have a basic knowledge of that before doing anything on Switch.
     
  9. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    YES, finally someone who understands, thanks!
     
  10. RHOPKINS13

    RHOPKINS13 Geek
    Member

    Joined:
    Jan 31, 2009
    Messages:
    1,209
    Country:
    United States
    Definitely a good start. Obviously to do anything useful you're going to have to learn or have some previous experience coding with C. I'd love to see some more links added where noobs can learn more about the SDK and it's functions.

    Even better, a multi-page tutorial with examples that progress in difficulty, you already have "Hello World" and basic button input. Add examples that respond to the touchscreen, display an image, or play a sound.
     
  11. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    thanks, i will definitely be adding links soon and i will be considering adding more things to do that get more difficult
     
  12. gnilwob

    gnilwob GBAtemp Regular
    Member

    Joined:
    Mar 16, 2008
    Messages:
    204
    Country:
    Hong Kong
    It is good to be able to compile and have an executable file to test on the switch.
    Thanks for your guide, I will try it :)
     
  13. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    no problem
     
  14. XorTroll

    XorTroll Tired of classic HOME menu
    Developer

    Joined:
    Dec 28, 2017
    Messages:
    630
    Country:
    Spain
    gnilwob likes this.
  15. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    gnilwob likes this.
  16. gnilwob

    gnilwob GBAtemp Regular
    Member

    Joined:
    Mar 16, 2008
    Messages:
    204
    Country:
    Hong Kong
    I have not read your post in detail yet.
    Just a request. If you can consider to record your screen step by step.
    That would help a developer who is not familiar with c or makefile.
    Thanks a lot.
     
  17. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    sure, ill try make a video
     
    gnilwob likes this.
  18. Garou

    Garou GBAtemp Maniac
    Member

    Joined:
    Jan 13, 2015
    Messages:
    1,200
    Country:
    now how to build your app, sideload the nro to the switch and run it in 1 command? better yet, with the ability to debug as well
    haven't got into developing any homebrew apps for any console simply because I couldn't find how to do this easily

    good read though, making me interested to start developing app for switch
     
  19. xXxSwagnemitexXx

    OP xXxSwagnemitexXx meme machine
    Member

    Joined:
    Dec 7, 2016
    Messages:
    657
    Country:
    United Kingdom
    to sideload you just run it through cfw, its not to hard to find that out so i wont add it.
     
  20. Garou

    Garou GBAtemp Maniac
    Member

    Joined:
    Jan 13, 2015
    Messages:
    1,200
    Country:
    care to elaborate?
    if you mean to copy the .nro manually to the sdcard or using ftp, then that's not what I meant
    I was thinking something like when you do android dev, just plug the phone using usb cable and run it directly from the ide
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Homebrew, first,