Jump to content

Incomplete input Key enum?


photo

Recommended Posts

Hi,

In UnigineInput.h, there is maybe an incomplete enum for the PLUS and MINUS keys..

For MINUS, 3 values..
KEY_MINUS
KEY_NUMPAD_MINUS
KEY_ANY_MINUS -> this one you confirm it is KEY_MINUS || KEY_NUMPAD_MINUS right?

.. but for PLUS, only 1 value:
KEY_NUMPAD_PLUS

Is it normal?

Regards,
Charles

Link to comment

Hi,

Thanks for indication regarding this API change.

I do understand 2 ways to capture keyboard interaction:

  • Logical key (char code)
  • Physical key (scan code)

Logical key -> depends on keyboard layout whereas we do have users with keyboard French, German or English.
Our German users do have keyboard with +/- keys and +/- numpad keys.

So, is there a nice way to handle it (as it was previously)?

Would it make sense in the API to expose a getLogicalKey and getPhysicalKey?

Regards,
Charles

Link to comment

As far as I know you can obtain local key from scan using Input::getKeyLocalName() and keyToUnicode() combination.

Sample from Input class documentation:

#include "AppWorldLogic.h"
#include <UnigineInput.h>
#include <UnigineConsole.h>

using namespace Unigine;

int AppWorldLogic::init()
{
	Console::setOnscreen(true);
	return 1;
}

int AppWorldLogic::update()
{
	auto print_info = [](const char *state, Input::KEY key)
	{
		unsigned int unicode = Input::keyToUnicode(key);
		Console::message("%s: (key='%s', unicode='%s', local_name='%s') ",
						 state,
						 Input::getKeyName(key),
						 String::unicodeToUtf8(unicode).get(),
						 Input::getKeyLocalName(key));
	};

	print_info("Up", Input::KEY_W);
	print_info("Jump", Input::KEY_SPACE);
	print_info("Run", Input::KEY_RIGHT_SHIFT);
	Console::message("\n");

	return 1;
}

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi, This code doesn't consider any modifier (Shift or AltGrph). So I suspect it can only give the main symbol for a physical key. How do you account for a modifier then?

Link to comment

Hi,

This is what I get with German (QWERTZ) keyboard:

  • keyboard event: (key='RIGHT_BRACKET', unicode='+', local_name='+')
  • keyboard event: (key='SLASH', unicode='-', local_name='-')
  • keyboard event: (key='NUMPAD_PLUS', unicode='', local_name='Numpad Plus')
  • keyboard event: (key='NUMPAD_MINUS', unicode='', local_name='Numpad Minus')

So.. I guess I'll have to

  • addCallback to receiving the immediate input and get an InputEventPtr with arbitrary key
  • test string contain local_name with +/Plus or -/Minus..

Regards,
Charles

Edited by Lales.Charles
Link to comment
×
×
  • Create New...