OSKing for Trouble

One thing that you would think that would be trivial to implement in a game is something that we’ve all seen in console, mobile, and an increasing number of PC games: an On-Screen Keyboard (OSK). Turns out, it’s kind of a pain.

An OSK allows entry of text via means other than the keyboard. Most interesting to this project is the ability to enter text through a gamepad. However, an increasing number of devices at the laptop and desktop level also have touch-screen capability, so that should also be taken into account.

Gamepad support has always been on the feature list for Dehoarder 2, and for the most part has always been there. The UI, though, is the case where things don’t really work as they should in regards to gamepad support. One part of that was that text entry required the player to put down the gamepad and revert to the keyboard.

Dehoarder 2 needs text entry in a couple of areas. Most important to gameplay are the keyword search feature of the mobile phone, and the ability to directly input numbers to sell an item. Text entry is also needed to personalize the character name and to name the save slot, but these are lesser needs that honestly were almost done away with when I was deciding whether I really needed an OSK.

Now that the decision was made that I did indeed need an OSK, it was time to explore my options.

First, one might think that a modern game engine in 2018 would make this trivial, that you could just check a checkbox somewhere, or call some one-line API and OSKs magically start appearing, with flying angels and rainbows and trumpet fanfares, and then you can skin and theme that OSK to your liking. That thought belongs in a fantasy world. Unity has an API relating to OSK, but it only works on mobile platforms and Windows Store apps. Yuck. A couple of forum posters suggest some OS-Dependent P-Invoke gobbledygook that is apparently fragile across OS version updates. Double yuck. Maybe in the years to come we will get this checkbox or one-liner solution. For now, though, dream on.

Second, one might think that lots of developers have this need, therefore surely by now several OSK components have appeared on the Unity Asset Store, and one or two winners among those have emerged that are feature rich, updated regularly, and have lots of followers (like nGUI and Text Mesh Pro did before they were implemented/integrated into Unity). Well, in this case, one would be partially right. Several OSK components have appeared on the asset store, but none of them have mobs of fans singing their praises. I narrowed the field down to one component that seemed to mostly fit my needs, but I needed to confirm one thing. I reached out to the developer, and never received a response. So much for well-supported.

What was left at that point was rolling my own OSK, which did not thrill me in the slightest. I had a feeling that I would be needing to dig into quite a bit of low-level junk, and battling lots of quirks and peculiarities. I was very correct. I’ll spare the grueling details, but the end result is actually something that works pretty well. If I had the time to make it properly fit for consumption by other developers and support it, it could actually give many of the Asset Store OSK components a run for their money. However, I much rather would have spent the 2 weeks of Smiling Cat time working on elements of the game. But, it’s done, and though I’m slightly less sane for the trouble, I can move on.

The cloaking device is now implemented, and can be activated/deactivated at will once obtained. It might not be quite what you think of as a cloaking device – rather than causing any physical change or effect, it actually affects the minds of those around it other than the activator to hide objects (conveniently sidestepping the issues of actually needing to make junk invisible and thus not usefully interactable, or having to apply mass translucency or another expensive effect to hundreds of objects). On activation, it begins animating and giving off a pulsing halo to show that it is working. As for how to obtain it, I’ll leave that to be discovered.

In this year’s hardware upgrade, it was my server disk array that got the attention. The drives in my prior 2TB array were aging, and SMART was reporting that one of the drives wasn’t long for this world. Plus, with the Dehoarder 2 build being close to 1GB, I’m now consuming at least that much per week, and space was starting to get a little tight. I expect that as 4K HD adoption speeds up, future projects will consume even more. So, I went with a 20TB array. I definitely am pushing the limits of RAID; the array took 2 days to initialize. Unless I’m using SSD next time or drive speeds have significantly increased (by an order of magnitude, I’d say), my next array won’t be RAID.