Jump to content

Control panel, ALT combination keys


Mopikel

Recommended Posts

Hi everyone,

Yesterday, I have just finished programming my Arduino Leonardo card to make my control panel send ALT combination keys to make it easier to avoid conflicts with other keys. Unfortunately, it doesn't work on KSP. It detects "left alt" then "numpad [number]" and once again "left alt". 

So, I just wanted to know if there is a trick or an add-on that make KSP able to get ALT combinations.

Regards,

Mopikel

1478343467-20161105-114444.png        1478343468-20161105-114502.png       1478343464-program.png

Edited by Mopikel
Link to comment
Share on other sites

Hi, and welcome to the forum.

We'd love to hear more about your panel, there is a thread in the Fan Works section (or make your own dedicated thread). Secondly, are you sure it is a KSP problem? Do you use code like the one mentioned here to send a combination of keypresses? I do not use keypress emulation myself, but I think that you send the keys separately with your individual Keyboard.release instead of the final Keyboard.releaseAll(). If that did not help, @stibbons and @Antipaten use a Leonardos as well, and might know a solution to the issue.

Edited by Freshmeat
Discovered the code in pic 3.
Link to comment
Share on other sites

At a glance, your Arduino code seems to be doing what you expect. But have you confirmed that it's sending working alt-codes by testing it in a text editor or similar?

I don't play KSP in Windows, so don't really have much helpful advice. But is Unity even able to use an alt-code combo as a keypress? My gut feeling is that it just plain won't work (and can't work). But I'd love to be proven wrong - what happens when you try to map a command to an alt-code?

Link to comment
Share on other sites

1 hour ago, Freshmeat said:

Hi, and welcome to the forum.

We'd love to hear more about your panel, there is a thread in the Fan Works section (or make your own dedicated thread). Secondly, are you sure it is a KSP problem? Do you use code like the one mentioned here to send a combination of keypresses? I do not use keypress emulation myself, but I think that you send the keys separately with your individual Keyboard.release instead of the final Keyboard.releaseAll(). If that did not help, @stibbons and @Antipaten use a Leonardos as well, and might know a solution to the issue.

KSP is problematic in that way. After days of trying to get it to accept different combinations of ctrl, alt and shift modifiers I finally gave up on trying to use keyboard commands. The approach also added the problem of my controller sending commands that other programs would try to interpret if they inadvertently was in focus when I threw a switch.

What I finally did was to emulate a joystick with 7 axes and 32 buttons and map most of the controls to a joystick button or axis. It looks like the most promising solution so far. For everything that cannot be mapped to a joystick i plan to use the kRPC mod. I tried using the Action Groups Extended mod for a while, but it drove me crazy having to map all those action groups, not only every time I built a new roscket, but every time Windows decided it would re-enumerate my joystick to a new ID (which happens fairly often after recompiling the Arduino software and every time I make changes to the USB HID definition).

Link to comment
Share on other sites

Hi everyone, thanks for answering.

I tried on a text editor and it's works. KSP doesn't get key sequences, like I said, when I try to map a key, it detects the alt key, then the numpad key, and once again the alt key. I'll try with scan codes, maybe it will work.

And could I or someone move this topic to the Fan Work section?

Edited by Mopikel
Link to comment
Share on other sites

Hi everyone,

After some tests, I FINALLY :D discovered that ksp doesn't know keys that aren't on a classical keyboard like F24. I searched for a file that lists all the KSP-known keyboard keys but I can't find it. Maybe it doesn't exist. I hope that one of our great member like  @Freshmeat  ,  @stibbonsor @Antipaten:wink: could help me because I have 42 switches (OMG 42, THE ANSWER TO THE LIFE ANS THE UNIVERSE xD) on my panel but I don't have 42 free keys on my keyboard.

Link to comment
Share on other sites

15 minutes ago, Mopikel said:

Hi everyone,

After some tests, I FINALLY :D discovered that ksp doesn't know keys that aren't on a classical keyboard like F24. I searched for a file that lists all the KSP-known keyboard keys but I can't find it. Maybe it doesn't exist. I hope that one of our great member like  @Freshmeat  ,  @stibbonsor @Antipaten:wink: could help me because I have 42 switches (OMG 42, THE ANSWER TO THE LIFE ANS THE UNIVERSE xD) on my panel but I don't have 42 free keys on my keyboard.

I had the same problem which is why I decided to go for joystick emulation on the Arduino instead. That way I can emulate 32 buttons using this Joystick library: https://github.com/MHeironimus/ArduinoJoystickLibrary

If you need more buttons, you may add another joystick device to the Arduino USB HID definition, which has proven to be a bit flaky, or you add another arduino and let it emulate another joystick, which work like a charm. Just map the joystick buttons instead of keyboard keys and it works like a charm. A note however is that if you use AGextended you can only map 20 buttons (if I remember correctly) from each joystick so in order to map 42 keys you may have to add a third Arduino.

Link to comment
Share on other sites

13 hours ago, Antipaten said:

I had the same problem which is why I decided to go for joystick emulation on the Arduino instead. That way I can emulate 32 buttons using this Joystick library: https://github.com/MHeironimus/ArduinoJoystickLibrary

If you need more buttons, you may add another joystick device to the Arduino USB HID definition, which has proven to be a bit flaky, or you add another arduino and let it emulate another joystick, which work like a charm. Just map the joystick buttons instead of keyboard keys and it works like a charm. A note however is that if you use AGextended you can only map 20 buttons (if I remember correctly) from each joystick so in order to map 42 keys you may have to add a third Arduino.

There's a way to emulate 48 buttons : I'm using the Joystick 3 library from the github link. This library can emulate 3 joysticks with X and Y axis and 16 buttons!

Thanks at all for The link :wink:

Link to comment
Share on other sites

Hi again!

After some successful flights, I'm happy to introduce you to my control panel!!! 1478967893-20161112-172322-1.png I just finished the code and it's working very well. Later, I think I'll try to add a potentiometer to control the thrust and a joystick for docking maneuvers but for now, I very happy. I think I will also make a video of it for my YouTube channel ( https://www.youtube.com/channel/UChQUpu4H-LYlCX25abffzXw in French :wink:) and try to continue a KSP series with it.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...