Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to disable nuklear_gamepad dependency? (I have my own controller implementation I'd like to pass forward to it) #106

Open
StrikerMan780 opened this issue Sep 13, 2024 · 2 comments

Comments

@StrikerMan780
Copy link
Contributor

Is there a way to disable the dependency on nuklear_gamepad? I have my own controller implementation, that I'd like to get the input for nuklear_console from.

@RobLoach
Copy link
Owner

Been curious about easing the dependency too. But in the mean time, you are able to implement your own custom gamepad input source. Something like this....

#define NK_GAMEPAD_NONE
#define NK_GAMEPAD_IMPLEMENTATION
#include "nuklear_gamepad.h"

void custom_gamepad_update(struct nk_gamepads* gamepads, void* user_data) {
    // Indicate that the left button is down for gamepad 0
    nk_gamepad_button(gamepads, 0, NK_GAMEPAD_BUTTON_LEFT, nk_true);
}

int main() {
  struct nk_gamepad_input_source input_source = {
    .update = &custom_gamepad_update
  };

  struct nk_gamepads gamepads;
  nk_gamepad_init_with_source(&gamepads, ctx, input_source);

  nk_console_set_gamepads(console, &gamepads);
}

Which platform are you using? I'd love to add more options for input sources to ease integrations.

@StrikerMan780
Copy link
Contributor Author

StrikerMan780 commented Sep 13, 2024

I'm using SDL2 as a base, but I have my own event loop for it, and a custom key->action remapping system so people can bind multiple keys and devices to the same action, among other things. I noticed that nuklear_console responds to the keyboard inputs in my loop, so I'm guessing if I just have my joystick handler send NK_KEY_UP/DOWN/LEFT/RIGHT inputs, I'll be set?

Also, thanks for replying, I appreciate it. I've been trying to get help with Nuklear itself in the main Nuklear repo, but nobody seems to reply there, making me feel like I'm up a creek without a paddle. This gives me some hope, though.

Case in point: Immediate-Mode-UI/Nuklear#646
Might want to look at this, since it's relevant to, and affects nuklear_console quite severely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants