Jump to content

Incomplete input Key enum?


photo

Recommended Posts

Posted

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

Posted

Hi Charles,

If you are talking about scan codes naming, "+" button on a keyboard is available only on NumPad, so there is no issue here.

The other button that you may refer is probably "=" ("Shift" + "=" equals "+") on QWERTY.

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

Posted

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

Posted

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:

Posted

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?

Posted

getKeyLocalName() should return result with modifier applied. Did you test it on your side and have different results?

Can you show us output of this code with shift pressed and released?

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

Posted (edited)

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
Posted

Yep, something like that.

The only why there is a KEY_ANY_MINUS constant exists because there are actually two "-" scan codes available at the same time, while "+" has only a single physical button that you can press without modifiers.

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

×
×
  • Create New...