Trouble getting started with the customization API in 4coder 4.0.25

Hi! I just bought 4coder this morning and I am trying to get started with some customization. I have checked Allen's youtube channel and the 4coder website, but I can't seem to find anything up to date. Most youtube stuff refers to the 4coder_custom.cpp and .h files, which are not present in the current version. I'm trying to wrap my head around the source code but I can't find a way to rebind keys and add custom functionality.
Can someone point me in the right direction?

Also I remember from Handmade Hero that 4coder used to come with Casey's customization source code, but I can't seem to find any of it in the 4.0.25 folder, is that still the case?

Edited by Thebigfox on Reason: Initial post
1. I'm sorry to admit, it has indeed become quite complicated in the custom layer. Shipping simpler example layers and tutorials for modifying the default one is one of my main objectives before I retire this engine.

2. Under 4coder_generated/remapping.h you will see the default bindings. This used to be in normal easy to read code, but in order to easily support multiple bindings for Mac, and to support the documentation of default bindings, I ended up moving it into generated code. There are two good ways to do your own bindings. The first option is to modify remapping.h. The advantage is that it is easy to get it done quickly and without any boilerplate code, but the downside is that you'll have to redo it with new builds. The second option is to make a "my_bindings.cpp" file, include at the top "4coder_default_include.cpp" then define the procedure:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);
    // put bindings here
    
    int32_t result = end_bind_helper(context);
    return(result);
}


3. Right now Casey's customization is only available with handmade hero source. I will begin including it in the next build (4.0.26).
Thanks so much for the help! I'm starting to figure stuff out and I managed to get my keybindings going.
Looking forward to the next updates, keep up the awesome work!
Hi, I'm trying to implement what you said and have some problems with building.

my_bindings.cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);
    // put bindings here
    bind(context, 'w', MDFR_ALT, change_active_panel);
    
    int32_t result = end_bind_helper(context);
    return(result);
    sad
}


4coder_default_include.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
/*
4coder_default_include.cpp - Default set of commands and setup used in 4coder.
*/

// TOP
#if !defined(FCODER_DEFAULT_INCLUDE_CPP)
#define FCODER_DEFAULT_INCLUDE_CPP

#include "my_bindings.cpp"


// NOTE(allen): Define USE_OLD_STYLE_JUMPS before 4coder_default_include.cpp to get
// the direct jumps (instead of sticky jumps).

#include "4coder_API/custom.h"


There are a long list of error but first:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
c:\Users\qqffx\Downloads\4coder
λ buildsuper.bat
4coder_default_bindings.cpp
4coder_metadata_generator.cpp
4coder_default_bindings.cpp
c:\users\qqffx\downloads\4coder\my_bindings.cpp(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\qqffx\downloads\4coder\my_bindings.cpp(2): error C2146: syntax error: missing ';' before identifier 'get_bindings'
c:\users\qqffx\downloads\4coder\my_bindings.cpp(2): error C2143: syntax error: missing ';' before '{'
c:\users\qqffx\downloads\4coder\my_bindings.cpp(2): error C2447: '{': missing function header (old-style formal list?)
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\stdint.h(19): error C2378: 'int32_t': redefinition; symbol cannot be overloaded with a typedef
c:\users\qqffx\downloads\4coder\my_bindings.cpp(1): note: see declaration of 'int32_t'
c:\users\qqffx\downloads\4coder\4coder_lib\4coder_string.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


Did i do something wrong?
Version 4.0.28
cl-64x
The customization layer - getting started thread might help you.

I think you should not edit 4coder_default_include.cpp. But include it at the top of my_bindings.cpp.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include "4coder_default_include.cpp"

extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);
    // put bindings here
    bind(context, 'w', MDFR_ALT, change_active_panel);
    
    int32_t result = end_bind_helper(context);
    return(result);
}


Then you need to pass my_bindings.cpp to the buildsuper.bat script. In a console:
1
buildsuper.bat my_bindings.cpp


@Allen, if it's ok with you could you pin the getting started thread ?
My plan is to get a few wiki pages up very soon, and I'll use your getting started post as one of those wiki pages.
steughar:
Seems like you have a sad written without any context at line 12 of my_bindings.cpp.

Edited by nj on
It's was placed for debug purposes, I was testing is the build saw my new file)
Mrmixer explanation clear that for me.
After I did this code compiled successfully but editor wont start:

my_bindings.cpp file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include "4coder_default_include.cpp"

extern "C" int32_t
get_bindings(void *data, int32_t size){
    Bind_Helper context_ = begin_bind_helper(data, size);
    Bind_Helper *context = &context_;
    
    set_all_default_hooks(context);
    // put bindings here
    bind(context, 'w', MDFR_ALT, change_active_panel);
    
    int32_t result = end_bind_helper(context);
    return(result);
}


how I build:
1
2
3
4
5
6
c:\Users\qqffx\Downloads\4coder
λ buildsuper.bat my_bindings.cpp
my_bindings.cpp
4coder_metadata_generator.cpp
my_bindings.cpp
   Creating library custom_4coder.lib and object custom_4coder.exp


Update:

Doesn't matter I read mrmixer manual and all works fine now, thank you for your prompt help. I hope I will be okay now)

Edited by steughar on
steughar
Creating library custom_4coder.lib and object custom_4coder.exp

It's weird that it was creating a static library instead of a dynamic (dll). Did you modify buildsuper.bat ?
No it creates a lib whenever you build a dll, so that you can link to the dll with the linker instead of manually calling LoadLibrary, that is normal behavior.