Jump to content

[0.22] On-Screen Touchscreen Controls (play with no keyboard attached)


Diazo

Recommended Posts

This mod will no longer be updated.

Every touchscreen out there seems to handle the touchscreen to mouseclick logic differently so to update this mod would require a total rewrite to use Unity's touch input as opposed to mouse clicks.

However Unity does not support all touchscreens yet (notably the Microsoft Surface) and so that is not an answer either.

As such I will not be maintaining this any more.

On-Screen Buttons for Touchscreen Control with no Keyboard Required

Release History:

Version 1.3 (Oct. 19/13)

Add RCS Fine Control support.

Version 1.2 (Oct. 19/13)

KSP 0.22 Compatible

Fix Map View Camera window to correctly scale with button scale.

Version 1.1 (Oct. 10/13)

Add Orbital Map Support (Note that the default maneuver nodes are clunky, a maneuver node mod with on-screen buttons, such as Maneuver Node Improvement is highly recommended.)

Add Actiongroups Support

Increase Camera pan/zoom speed

Version 1.0 (Oct. 05/13)

Initial Release

What this mod does:

This mod allows you to fly your craft without an attached keyboard by using on-screen buttons to control the rotation of the craft, the throttle, the RCS system and the camera.

This mod will become a fully capable alternate control scheme so that no keyboard is required from the start of the game until you decide to quit.

However, for this release only the flight functionality is implemented. Controls for EVA mode and the VAB/SPH will follow shortly.

Note that due to how the RCS is turned on/off in the code, pressing 'R' on the keyboard will not make the RCS window appear. Tap the on-screen RCS button a few times to fix this.

Quickstart:

OSKKeyMap2.png

Download:

The mod can be downloaded from Spaceport here.

Usage:

The mod installs into the GameData directory as normal.

The first run after installation will have the Main, Cam, and Actions windows appear in the top left. The RCS window appears when the on-screen RCS button is pressed and the Ctrls (Settings) screen appears when the Ctrls button is pressed.

All windows can be dragged and their placement will be remembered.

The buttons can also be scaled larger or smaller in the Ctrls screen.

There is also the option to flip the pitch controls so that the Pitch Up and Pitch Down arrows reverse the direction they rotate your craft in.

The Ctrls screen also offers access to the Game Menu as without a keyboard there is no ESC button.

RCS Fine Control:

RCS fine control (Caps Lock) needs a special mention.

Unlike the other functions, the Fine Control provided by this mod is completely separate from the Fine Control provided by the Caps Lock key.

Enabling Fine Control via Caps Lock only enables it for the keyboard, enabling it via the button in this mod only enables it for the RCS buttons on the screen.

The code in the game imposes this limitation, but it grants me the ability to set the level of fine control. In Version 1.3 you can toggle between fine control of 50% or 25% thrust of the maximum thrust your RCS can grant you.

Feedback request:

As mentioned, I intend for this mod to expand to be a complete control scheme so that KSP can be played with no keyboard or mouse. However, I lack the different types of touchscreens to test how easy this mod is to use so if you do install this mod please let me know how it works for you. Even if it works great and you have no requests, please let me know so I can confirm my mental image of how the different touchscreens work is correct.

License:

As this mod will hopefully help expand KSP into the touchscreen world (hey, I can dream :D), I release this with no restrictions. Do what you will, as you will with it.

Source:

The source code is included in the .ZIP file that downloads from the Spaceport link.

Planned Features:

Add Trim Controls

Add VAH/SPH functionality

Add EVA functionality

Add player settable camera pan/zoom speed

Add Virtual Joystick (if a workable method can be determined)

Edited by Diazo
Link to comment
Share on other sites

looks really great

if there are actiongroups to tab/click it will be nearly perfect

no way lol,the keyboard is not nearly perfect,it is PERFECT - laid down almost 40 years of development to reach the current state of PC keyboard...

ksp and any other pc game does not need touchscreens.

Link to comment
Share on other sites

Actiongroups.

Right, oops. Totally forgot about those.

Thank you for the reminder.

@anarkhon: Umm, 40 years of development? Try maybe one year for the current QWERTY layout, and even then it was specifically developed to slow down your typing so the typewriter it was originally used on would not jam.

The original typewriters that flung a bit of metal forward with the letter on it would jam if two letters were pressed at the same time as they would collide at the paper trying to both hit the same area of the paper. Therefore the QWERTY layout was laid out so that typists were slowed down just enough that they could not jam the typewriter.

And we've been stuck with that since.

I'd love for there to be some serious development work done on alternative input methods, even as popular as touchscreens are getting, they have their own issues, notably lack of precision.

D.

Link to comment
Share on other sites

Actiongroups.

Right, oops. Totally forgot about those.

Thank you for the reminder.

@anarkhon: Umm, 40 years of development? Try maybe one year for the current QWERTY layout, and even then it was specifically developed to slow down your typing so the typewriter it was originally used on would not jam.

The original typewriters that flung a bit of metal forward with the letter on it would jam if two letters were pressed at the same time as they would collide at the paper trying to both hit the same area of the paper. Therefore the QWERTY layout was laid out so that typists were slowed down just enough that they could not jam the typewriter.

And we've been stuck with that since.

I'd love for there to be some serious development work done on alternative input methods, even as popular as touchscreens are getting, they have their own issues, notably lack of precision.

D.

Since I was alive in those days (almost), I will vouch for that. It was a method to slow typists down. Even then, I knew people that could to 130+ WPM easily, no errors on those old mechanical typewriters. You may not think much of that, given how easy it is to type on a modern keyboard.

On the mechanical typewriter, you had to STRIKE each key ( which had parts attached to it so it had a bit of weight) to get it to go fast enough to hit the paper before the next one got there. Speed only came with the use of greater force of the keyboard.

man... it was tough...

Sorry, off topic.

I could see where this would be useful for playing ksp on a tablet. Good show.

Edited by Papa_Joe
grammer
Link to comment
Share on other sites

Alright, it has been suggested elsewhere that pitch/yaw buttons get replaced with "virtual joystick" type of thing, where you grab a button and slide it around to provide analog control.

I can see the merit of this, my only issue that with a physical joystick, you have the springs to set the zero point and the dead zone. With a virtual joystick that you place your finger down on, how do I handle the dead zone?

Most people are not going to be accurate to the pixel that I can just set the zero point, but if I start making a dead zone 15 pixels wide there is going to be a lot of movement at the start that results in no inputs given to the game.

Anyone with tablets/touchscreens want to offer an opinion on how I could handle this?

D.

Link to comment
Share on other sites

no way lol,the keyboard is not nearly perfect,it is PERFECT - laid down almost 40 years of development to reach the current state of PC keyboard...

ksp and any other pc game does not need touchscreens.

Diazo was kind enough to invest his time to create this mod after I requested help- its purpose was for using KSP with a Smartboard single click projector/screen for a classroom setting... as such it has met and far exceeded my greatest expectations. I for one am very grateful - I am certain many teachers will feel the same way when they look for a way to implement KSP in a classroom without a wireless keyboard/mouse.

Link to comment
Share on other sites

Hmmm.

I'm going to add a new user guide of some sort once I get all the basic functions in I think.

I wrote the mod assuming everyone installing it would be experienced Kerbalnaughts and be able to jump right in.

However, if you don't have a computer with a keyboard and mouse and you install KSP and then this to see what all the fuss is about I need a better introduction to it so you can find your way around while learning both KSP and how to use this mod.

D.

Link to comment
Share on other sites

Alright, it has been suggested elsewhere that pitch/yaw buttons get replaced with "virtual joystick" type of thing, where you grab a button and slide it around to provide analog control.

I can see the merit of this, my only issue that with a physical joystick, you have the springs to set the zero point and the dead zone. With a virtual joystick that you place your finger down on, how do I handle the dead zone?

Most people are not going to be accurate to the pixel that I can just set the zero point, but if I start making a dead zone 15 pixels wide there is going to be a lot of movement at the start that results in no inputs given to the game.

Anyone with tablets/touchscreens want to offer an opinion on how I could handle this?

D.

I worked on a project similar to this at one stage. The control was a square with a '+' in the middle whose lines were around a finger wide, with a separate square in the middle of the '+' where its lines crossed which acted as the deadzone. Touching any part of the square would set the virtual joystick position to the appropriate angle, and it could be zeroed by sliding to the centre deadzone area, or releasing and touching the deadzone. The horizontal and vertical bars allowed accurate single-axis movements. It can be a bit tricky to set up as it's 9 individual cursor-sensitive areas, but it worked well.

Try maybe one year for the current QWERTY layout, and even then it was specifically developed to slow down your typing so the typewriter it was originally used on would not jam.

QWERTY was developed to be faster than other layouts by reducing jamming. If you've ever used a mechanical typewriter, you can see that keys that are side-by-side can be easily jammed together. There was purportedly research done into the frequency of consecutive letter combinations in words, resulting in characters which often occurred next to each other in words being moved apart on the keyboard. Having the keys in a word alternate between each hand also allows for faster typing.

Edited by pizzaoverhead
Link to comment
Share on other sites

Wow, this is a great idea. I should be getting my Surface Pro 2 in a few weeks so I'll test this out on that as soon as I get it. I'm anxious to see how the VAB/SPH controls work when you get to them; in my mind that could be a better way to build than using the keyboard/mouse.

Link to comment
Share on other sites

I worked on a project similar to this at one stage. The control was a square with a '+' in the middle whose lines were around a finger wide, with a separate square in the middle of the '+' where its lines crossed which acted as the deadzone. Touching any part of the square would set the virtual joystick position to the appropriate angle, and it could be zeroed by sliding to the centre deadzone area, or releasing and touching the deadzone. The horizontal and vertical bars allowed accurate single-axis movements. It can be a bit tricky to set up as it's 9 individual cursor-sensitive areas, but it worked well.

So rather then press and hold to drag the virtual joystick around, where ever you tapped in the larger square was the joystick angle, with a finger sized square in the middle that when tapped zeroed the joystick?

I could see that working. However, that would effectively disable SAS. When SAS is enabled it overrides all other inputs. When inputs are being entered, SAS is disabled for as long as the inputs are present (even though the SAS light stays on). So I tap slightly east (right) for my gravity turn. SAS is now disabled until I tap the center again to zero the joystick.

However, a thought I had for touchscreens that are drag enabled (I'm pretty sure most are these days) is to set the dead zone to where ever the finger first touches and interpolate from there. There would have to be a border around the edge that is simply "max" to account for variations.

(Random numbers picked)

Control area is 240 pixels wide, 20 pixel border that if touched maxed out the joystick. That leaves a 200 pixel wide area to drag the finger around in. So the finger touches at pixel 115,122, so 5 pixels off horizontally and 2 pixels off vertically, for this touch, 115,122 is my zero. Then for each pixel moved, the joystick moves 1% in that direction (200 pixels wide = 100 pixels in each direction from zero.)

The zero point would reset every time you touched the joystick control area.

The disadvantage to this is that when you reached the edge it would jump to 100%. On the 115,122 example, when the joystick crossed from 21,122 to 20,122 it would jump from 95% to 100% because it hits the 'max' border at the edge of the control area.

I'm not sure, I like my second example of dragging the joystick around, but I'm assuming all (or at least most) touchscreens are drag-enabled for that to work. I don't actually know that for sure.

D.

Link to comment
Share on other sites

So rather then press and hold to drag the virtual joystick around, where ever you tapped in the larger square was the joystick angle, with a finger sized square in the middle that when tapped zeroed the joystick?

I could see that working. However, that would effectively disable SAS. When SAS is enabled it overrides all other inputs. When inputs are being entered, SAS is disabled for as long as the inputs are present (even though the SAS light stays on). So I tap slightly east (right) for my gravity turn. SAS is now disabled until I tap the center again to zero the joystick.

SAS is only disabled on a single-axis basis during manual control as of 0.21, so it would still be active for up/down and roll in your example. Tapping and waiting is the equivalent of holding the D key, so SAS should be disabled for that axis. Tapping the centre is the equivalent of releasing the D key again.

The setup I worked on was a bit more complicated than that described as it was for an eye-tracking system. It worked on hover rather than click. I see that MacTee has made something similar too. There are many different ways of implementing it, and our three goals are slightly different. I'd recommend just trying as many different control methods as you can think of, even just on paper.

Your dragging distance idea sounds like a good one. Another approach I've seen used is measuring the speed of the drag rather than the offset. Something else to think about is multi-touch support. Judging by the comments about having multiple students helping each other, it sounds like Mr. Sloan's smartboard supports multiple pens. You could see if Unity's Input.touches is compatible with it. That would allow you to steer while staging for example.

Link to comment
Share on other sites

SAS is only disabled on a single axis on keyboard control input?

I'll have to look into that. The only way I was able to get the on-screen buttons to work was to override the SAS entirely via the FlightInputHandler.SASoverride=true setting.

So in the mod as it stands, any inputs disable SAS entirely.

I'll also look into that Input.touches class and see what that offers. I've been working to make an "on screen keyboard" which is nice and straightforward but not necessarily the best way to go about things.

D.

Link to comment
Share on other sites

I had a similar problem on a plugin I was working on. I was using Vessel.OnFlyByWire as you are now, but from what I remember, my changes to the flight state were being overwritten instantly. I switched to modifying the values in Vessel.ctrlState during Update instead and it solved the problem. YMMV.

Link to comment
Share on other sites

Alright, new version is out.

Orbital map support and Actiongroups have been added.

EVA support is next, but the controlling code is totally different so the next release will probably be a couple weeks.

However, with this release everything else necessary to fly a ship should now be present.

D.

Link to comment
Share on other sites

  • 2 weeks later...

Okay, updated for KSP 0.22 and fixed a minor bug in how the camera map window scales.

No real progress on getting EVA kerbals to work. That's getting involved in the animation functions on Unity and it's something of a beast.

D.

Link to comment
Share on other sites

I spot a few missing buttons. Namely, a pretty important one for Fine Control toggle, and a set of somewhat important ones for trim, as I see no way to set trim currently.

The nature of these buttons sort of requires there being some ways of having precise controls.

Also, consider moving the Abort button to a separate panel and making it more distinct. Perhaps larger. By its nature it's a button you want to be able to reach quickly and hit reliably when you need it, while letting it be out of the way at all other times.

Link to comment
Share on other sites

Heh. I'll add those to the to-do list.

I've never actually used either function (rockets don't need trim and I build big enough that I have not needed the Fine Control setting to dock).

I agree they should be in the mod though so I'll look at getting them in.

On the Abort button, I'm not sure how to handle that. I'm developing on a giant 23" desktop screen so I have plenty of real estate. How big of a screen do I have to account for with the typical touchscreen sizes that exist? I know they are not as big as what I've developing on and I'm quite worried I'll get so many buttons on the screen you can't see your ship anymore.

At the same time I have to keep the buttons big so a finger can touch them, if the buttons are smaller then your finger that leads to control issues as you will sometimes hit a different button then you mean to.

That is the feedback I need though, I never even considered adding those features until you mentioned it.

D.

Link to comment
Share on other sites

Alright, I had a brainwave and the RCS fine control is in.

Note that due to how mods interface with KSP I could not just turn fine control on/off.

Therefore there is now two RCS fine controls settings in the game. The Caps Lock turns fine control on/off for your keyboard, the button on the screen turns it on for the RCS buttons on-screen.

However, this lets me set the level of fine control. Version 1.3 can set the fine control to either 25% or 50% of your max RCS thrust.

I have no clue how this relates to the fine control amount set by the keyboard however. Please let me know if I got it close.

D.

Link to comment
Share on other sites

  • 2 weeks later...
@DMagic: Thanks for the feedback.

That is what I was worried about on the drag issue, I'm thinking I'll need to add an "edit last piece" window that allows you to move it around somehow, but that is going to be a pain to code.

On the long-touch = right click, that's new. The Smartboard that kicked this project off did not have that feature so I'll have to think on that one.

Either way, controlling Kerbals on EVA is still next on the list for this project, but things are in the queue.

D.

I guess it's probably better to take this conversation here.

I've been playing around a bit and discovered a few things.

The hold-to-right-click seems to be a windows control panel option and you can turn it off. Of course that means you can't right-click anymore. The Surface has the pen which still works fine for right-click, but that's a special case. Ultimately though, it's probably better to leave it on, since turning it off doesn't seem to affect the click-and-drag, or the click-and-hold function.

In the VAB you can build something using just the touchscreen. You can touch the object, then let go, then touch and hold and drag the object into place. This works ok, the problem is that the part description won't disappear after touching a part in the list. The description window just follows you around wherever you touch. You can get rid of it with the pen, but again, that's a special case.

I managed to get into orbit and land with the Kerbal X ok, though I did get stuck in IVA near the end. I found that touching and holding doesn't work, but if you touch then drag your finger a bit you can get the click-and-hold effect, making turning and throttling up easier. Maneuver nodes are tricky but it is possible to grab a vector and pull it out.

I also found that the standard pinch-to-zoom seems to be recognized. In flight it works like normal, zooming the camera in or out, but in the VAB it moves the camera up or down. You still don't have any other way to move the camera in the VAB, but up and down is probably the most important function.

Link to comment
Share on other sites

Hmmm.

Just the camera in the VAB and no added functionality for placing pieces should be pretty straightforward.

I've also got voneiden's okay to implement his Maneuver Node Improvement mod as part of my mod release. It has on screen buttons for changing maneuver nodes that you can tap. (Link in first post in thread.)

I'm thinking I'll make the next release just those two things now, I've made no real progress on Kerbal EVA controls yet so pushing that back is not a big deal.

D.

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...