Current approaches for onscreen keyboard

Hi vvvvolks,

forgive me if this has been discussed recently, but at least I wasn’t able to find such…
What’s the current best practice for onscreen keyboards? I couldn’t find any modules or plugins - does that mean there are none? Or am I overseeing something? All I could find was this: http://nuigroup.com/forums/viewthread/118/#560 - but it looks a bit outdated (and GDI).

Thanks,
Philipp

hey philipp,

i find it very usefull to have a spread of string keys. make a logic with that (getting the slice that is pressed as pure string) and then convert that string to keycode. That keycode you can use in a keyboard state. This way you can use the touch keyboard in almost any situation (like e.g. the HTML texture)or with the typewriter etc.

I didnt really find a vvvv way of converting string to the right keycode, but maybe there is one - so i wrote a quick plugin that does the conversion. Maybe there is one, anyone?

As for the code it is very simple, i only added extra cases for the keys i needed so if you need more you should probably add them, unless there is some better way of converting to keycode?!:

- region usings
using System;
using System.ComponentModel.Composition;
using System.Windows.Forms;

using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;

using VVVV.Core.Logging;
- endregion usings

namespace VVVV.Nodes
{
	#region PluginInfo
	[PluginInfo(Name = "StringToKeyCode", 
	Category = "Windows", 
	Help = "Converts Chars to KeyCodes", 
	Tags = "",
	AutoEvaluate=false)]
	#endregion PluginInfo
	public class WindowsStringToKeyCodeNode : IPluginEvaluate
	{
		#region fields & pins
		[Input("Input")](Input("Input"))
		public ISpread<string> FInput;

		[Output("Key code")](Output("Key code"))
		public ISpread<int> FOutput;
		
		[Output("Caps", IsSingle=true)](Output("Caps", IsSingle=true))
		public ISpread<bool> FCaps;

		[Import()](Import())
		public ILogger FLogger;
		#endregion fields & pins
		
		[System.Runtime.InteropServices.DllImport("user32.dll")](System.Runtime.InteropServices.DllImport("user32.dll"))
   		private static extern short VkKeyScan(char ch);
				
		//called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			FOutput.SliceCount = SpreadMax;
			
			for (int i = 0; i < SpreadMax; i++)
			{
				if(FInput[i](i) == "")
				{
					FOutput[i](i) = 0;
					return;
				}
				
				if(FInput[i](i) == " ")
				{
					FOutput[i](i) = 32;
					return;
				}
				
				if(FInput[i](i) == "Bksp")
				{
					FOutput[i](i) = 8;
					return;
				}
				
				if(FInput[i](i) == "Shift")
				{
					FCaps[i](i) = !FCaps[i](i);
					return;
				}
				
				if(FInput[i](i) == "@")
				{
					FOutput.SliceCount += 2;
					FOutput[i](i) = 17;
					FOutput[i+1](i+1) = 18;
					FOutput[i+2](i+2) = 81;
					return;
				}
				
				if(FInput[i](i) == "_")
				{
					FOutput.SliceCount += 1;
					FOutput[i](i) = 16;
					FOutput[i+1](i+1) = 189;
					return;
				}
				
				FOutput[i](i) = VkKeyScan( FInput[i](i)[0](0) );
			}
			//FLogger.Log(LogType.Debug, "hi tty!");
		}
	}
}

dunno if this could help: display-keyboard