Jump to content

Input Keypad Keys


photo

Recommended Posts

9 hours ago, silent said:

LouMatalka

Numpad keys are working like an arrows (at least 4 8 6 and 2). There is no specific numpad key codes, I'm afraid.

Any reason for that ? they play a major part in the game I'm developing, I know they are not available on all keyboards/laptops, but is there a way to get input for them ?

Edited by LouMatalka
Link to comment
7 minutes ago, silent said:

You can try to get numpad input via regular KEY_ enums (like KEY_DIGIT_1 for 1, KEY_PLUS for +; KEY_DELETE for , and so on).

That doesn't work, I've tried it (asuming you mean for example "Input.IsKeyDown(Input.KEY.DIGIT_1")

Link to comment
4 hours ago, silent said:

I've checked keycodes in UnigineScript sample: SDK Browser -> Samples -> Script -> Widgets -> text_00. Here is the text that printed from NumPad (Unigine 2.12.0.2 SDK):

image.png

I've checked this out, I noticed both the numpad keys (specifaclly the numbers) and the alpha numbers (which is the numbers row above the letters) share the same code number (this is what the enigine.message is showing when pressing them in this sample code), for example the "0" key returns the code 48 and pressing the "0" key on the keypad also returns the code 48, I've attempted to create an custom method for the input wrapper to accept Int as a parameter instead of a Enum ( public static bool IsKeyDown(int key) ) and pass the code 48 to it, it only turns true if I press the "0" key that is at the number row and not the keypad, I've noticed that passing 0 to this function ( IsKeyDown(0) ) turns true if I press any of the numbers on the keypad (0 through 9) so I guess any key that is not recognised is interpreted as a code "0" but all other keys work in this custom method by passing their corresponding int code defined in the enum. What can I do about this ?

Thanks

Edited by LouMatalka
Link to comment
On 9/28/2020 at 4:21 PM, LouMatalka said:

I've checked this out, I noticed both the numpad keys (specifaclly the numbers) and the alpha numbers (which is the numbers row above the letters) share the same code number (this is what the enigine.message is showing when pressing them in this sample code), for example the "0" key returns the code 48 and pressing the "0" key on the keypad also returns the code 48, I've attempted to create an custom method for the input wrapper to accept Int as a parameter instead of a Enum ( public static bool IsKeyDown(int key) ) and pass the code 48 to it, it only turns true if I press the "0" key that is at the number row and not the keypad, I've noticed that passing 0 to this function ( IsKeyDown(0) ) turns true if I press any of the numbers on the keypad (0 through 9) so I guess any key that is not recognised is interpreted as a code "0" but all other keys work in this custom method by passing their corresponding int code defined in the enum. What can I do about this ?

Thanks

So is there a solution to this ?

Link to comment
3 hours ago, silent said:

Could you please show us your current code that isn't working?

 

I've edited the Input class's function to receive int keycode instead of enum to try and check if there are keycodes for the keypad keys that aren't listed in the enum, here is it:

{
	private void Update()
	{
		if (CustomInput.IsKeyDown(0))
		{
			Log.Warning("Key Down!\n");
		}
	}
}

public class CustomInput
{
	public static bool IsKeyDown(int key)
	{
		return CustomInput.Input_isKeyDown(key);
	}

	[DllImport("UnigineWrapper_x64d", CallingConvention = CallingConvention.Cdecl)]
	[return: MarshalAs(UnmanagedType.U1)]
	internal static extern bool Input_isKeyDown(int key);
}

//  For reference  //
/*
SPACE = 32, // 0x00000020
EXCLAIM = 33, // 0x00000021
DOUBLE_QUOTE = 34, // 0x00000022
HASH = 35, // 0x00000023
DOLLAR = 36, // 0x00000024
PERCENT = 37, // 0x00000025
AMPERSAND = 38, // 0x00000026
APOSTROPHE = 39, // 0x00000027
QUOTE = 39, // 0x00000027
LEFT_PAREN = 40, // 0x00000028
RIGHT_PAREN = 41, // 0x00000029
ASTERISK = 42, // 0x0000002A
PLUS = 43, // 0x0000002B
COMMA = 44, // 0x0000002C
MINUS = 45, // 0x0000002D
DOT = 46, // 0x0000002E
SLASH = 47, // 0x0000002F
DIGIT_0 = 48, // 0x00000030
DIGIT_1 = 49, // 0x00000031
DIGIT_2 = 50, // 0x00000032
DIGIT_3 = 51, // 0x00000033
DIGIT_4 = 52, // 0x00000034
DIGIT_5 = 53, // 0x00000035
DIGIT_6 = 54, // 0x00000036
DIGIT_7 = 55, // 0x00000037
DIGIT_8 = 56, // 0x00000038
DIGIT_9 = 57, // 0x00000039
COLON = 58, // 0x0000003A
SEMICOLON = 59, // 0x0000003B
LESS = 60, // 0x0000003C
EQUALS = 61, // 0x0000003D
GREATER = 62, // 0x0000003E
QUESTION = 63, // 0x0000003F
AT = 64, // 0x00000040
LEFT_BRACKET = 91, // 0x0000005B
BACK_SLASH = 92, // 0x0000005C
RIGHT_BRACKET = 93, // 0x0000005D
CARET = 94, // 0x0000005E
UNDERSCORE = 95, // 0x0000005F
BACK_QUOTE = 96, // 0x00000060
A = 97, // 0x00000061
B = 98, // 0x00000062
C = 99, // 0x00000063
D = 100, // 0x00000064
E = 101, // 0x00000065
F = 102, // 0x00000066
G = 103, // 0x00000067
H = 104, // 0x00000068
I = 105, // 0x00000069
J = 106, // 0x0000006A
K = 107, // 0x0000006B
L = 108, // 0x0000006C
M = 109, // 0x0000006D
N = 110, // 0x0000006E
O = 111, // 0x0000006F
P = 112, // 0x00000070
Q = 113, // 0x00000071
R = 114, // 0x00000072
S = 115, // 0x00000073
T = 116, // 0x00000074
U = 117, // 0x00000075
V = 118, // 0x00000076
W = 119, // 0x00000077
X = 120, // 0x00000078
Y = 121, // 0x00000079
Z = 122, // 0x0000007A
ESC = 256, // 0x00000100
TAB = 257, // 0x00000101
BACKSPACE = 258, // 0x00000102
RETURN = 259, // 0x00000103
DELETE = 260, // 0x00000104
INSERT = 261, // 0x00000105
HOME = 262, // 0x00000106
END = 263, // 0x00000107
PGUP = 264, // 0x00000108
PGDOWN = 265, // 0x00000109
LEFT = 266, // 0x0000010A
RIGHT = 267, // 0x0000010B
UP = 268, // 0x0000010C
DOWN = 269, // 0x0000010D
SHIFT = 270, // 0x0000010E
CTRL = 271, // 0x0000010F
ALT = 272, // 0x00000110
CMD = 273, // 0x00000111
SCROLL = 274, // 0x00000112
CAPS = 275, // 0x00000113
NUM = 276, // 0x00000114
F1 = 277, // 0x00000115
F2 = 278, // 0x00000116
F3 = 279, // 0x00000117
F4 = 280, // 0x00000118
F5 = 281, // 0x00000119
F6 = 282, // 0x0000011A
F7 = 283, // 0x0000011B
F8 = 284, // 0x0000011C
F9 = 285, // 0x0000011D
F10 = 286, // 0x0000011E
F11 = 287, // 0x0000011F
F12 = 288, // 0x00000120
NUM_KEYS = 289, // 0x00000121
*/

If you send "0" as a parameter to "CustomInput.IsKeyDown()" as shown above, you will receive input for all keypad keys from 0 to 9 and for other undefined keys such as Scrlk, Pause, Windows Key, and more, but this isn't a solution since I can't identify what key was pressed since they all share the same "Keycode" which is a keycode for undefined keys

 

Thanks.

Edited by LouMatalka
Link to comment

As I already mentioned before, there is no way to find out if the key (for example '7') is pressed from numpad or from the default numeric part of the keyboard. Return codes will be the same for them.

There is however a strange behavior with isKeyDown(0). It should not be triggered for the numpad keys, I guess. We need some additional time to check this behavior and understand if this is bug or not.

Thanks!

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

Link to comment
17 minutes ago, silent said:

As I already mentioned before, there is no way to find out if the key (for example '7') is pressed from numpad or from the default numeric part of the keyboard. Return codes will be the same for them.

I am fine with not knowing if the button was pressed from the numeric part of the keyboard of the keypad, but keypad keys won't work at all, for example, if you try out the following code:

		if (Input.IsKeyDown(Input.KEY.DIGIT_7))
		{
			Log.Warning("Key Down!\n");
		}

or using my version:

		//DIGIT_7 = 55
		if (CustomInput.IsKeyDown(55))
		{
			Log.Warning("Key Down!\n");
		}

this will work only when pressing '7' from the numeric part of the keyboard, pressing '7' on the keypad won't work.

Edited by LouMatalka
Link to comment
13 minutes ago, silent said:

OK, I found the root cause of this behavior. What you currently observe is an engine bug.

For some reason I thought it was fixed in the 2.12.x branch, but fix wasn't merged. This bug fix will be available in 2.13 release.

Sorry for the inconvenience caused.

No problem, glad you found the issue.

Happy to contribute with the development of this awesome engine!

Thank you.

  • Like 1
Link to comment
×
×
  • Create New...