-
- lomoonmoonbird
- Posts: 30
- Joined:
Re: keyboard focus not work on android TV
Hi
The image had been correctly set like yours , and the the focus was set on the first button when initialized first time ,but i can't control the focus using remote control,but keyboard event did trigger. can you test it on an AndroidTV,please?
The image had been correctly set like yours , and the the focus was set on the first button when initialized first time ,but i can't control the focus using remote control,but keyboard event did trigger. can you test it on an AndroidTV,please?
Re: keyboard focus not work on android TV
I think I know what is going on (sorry, we don't have an Android TV here for testing). It seems that we have the keyboard disabled in mobiles, incorrectly I would say.
Please, open the file NoesisUIRenderer.cs (at Assets\Plugins\NoesisGUI\Scripts\Core), at the function ProcessEvent (line 382), remove the lines that set enableKeyboard and enableMouse to false.
From this:
to
It should work : )
Please, open the file NoesisUIRenderer.cs (at Assets\Plugins\NoesisGUI\Scripts\Core), at the function ProcessEvent (line 382), remove the lines that set enableKeyboard and enableMouse to false.
From this:
Code: Select all
public void ProcessEvent(UnityEngine.Event ev, bool enableKeyboard, bool enableMouse)
{
#if !UNITY_STANDALONE && !UNITY_EDITOR
enableKeyboard = false;
enableMouse = false;
#endif
// Process keyboard modifiers
if (enableKeyboard)
{
Code: Select all
public void ProcessEvent(UnityEngine.Event ev, bool enableKeyboard, bool enableMouse)
{
// Process keyboard modifiers
if (enableKeyboard)
{
-
- lomoonmoonbird
- Posts: 30
- Joined:
Re: keyboard focus not work on android TV
Hi
I have tried your solution,magic happened, it work perfectly.I’m grateful for your help.Thanks a lot.
But there also remained a small problem, the Enter key on remote control not work, whose keycode is JoystickButton0.
the log

I have tried your solution,magic happened, it work perfectly.I’m grateful for your help.Thanks a lot.
But there also remained a small problem, the Enter key on remote control not work, whose keycode is JoystickButton0.
the log
Thanks again,i will be so grateful if you can help me to solve this problem
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Event:KeyUp Character:\0 Modifiers:None KeyCode:Joystick1Button0
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Layout
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Event:KeyUp Character:\0 Modifiers:None KeyCode:JoystickButton0
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Layout
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Event:KeyDown Character:\0 Modifiers:None KeyCode:Joystick1Button0
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Layout
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.089: I/Unity(16367): Event:KeyDown Character:\0 Modifiers:None KeyCode:JoystickButton0
03-22 11:19:33.089: I/Unity(16367):
03-22 11:19:33.089: I/Unity(16367): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
03-22 11:19:33.092: I/Unity(16367): Layout

-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: keyboard focus not work on android TV
If you are using NoesisGUI 1.2, you can attach a MonoBehavior to the game object next to the NoesisGUIPanel, to inject the input events that your application requires. You can also define different mappings depending on the controller type.
For example:
For example:
Code: Select all
public abstract class BaseController: MonoBehaviour
{
NoesisGUIPanel gui;
void Start()
{
gui = GetComponent<NoesisGUIPanel>();
}
void OnGUI()
{
if (gui != null && UnityEngine.Event.current.type == UnityEngine.EventType.KeyDown)
{
ProcessKey(UnityEngine.Event.current.keyCode);
}
}
protected void GenerateNoesisKey(Noesis.Key key)
{
gui.KeyDown(key);
}
protected abstract void ProcessKey(UnityEngine.KeyCode key);
}
Code: Select all
public class GamePadController: BaseController
{
protected override void ProcessKey(UnityEngine.KeyCode key)
{
switch (key)
{
case KeyCode.JoystickButton0:
{
GenerateNoesisKey(Noesis.Key.Up);
break;
}
case KeyCode.JoystickButton1:
{
GenerateNoesisKey(Noesis.Key.Left);
break;
}
case KeyCode.JoystickButton2:
{
GenerateNoesisKey(Noesis.Key.Right);
break;
}
case KeyCode.JoystickButton3:
{
GenerateNoesisKey(Noesis.Key.Down);
break;
}
// etc.
}
}
}
Code: Select all
public class RemoteController: BaseController
{
protected override void ProcessKey(UnityEngine.KeyCode key)
{
switch (key)
{
case KeyCode.Joystick1Button0:
{
GenerateNoesisKey(Noesis.Key.Return);
break;
}
case KeyCode.Joystick1Button1:
{
GenerateNoesisKey(Noesis.Key.Escape);
break;
}
// etc.
}
}
}
-
- lomoonmoonbird
- Posts: 30
- Joined:
Re: keyboard focus not work on android TV
Hi
Great, I have made it worked with your solution,Thank you Mr save the day.NoesisGUI is a greet plugin,I will dive deeper into NoesisGUI,maybe i will need your help when i meet other ploblems.
Anyway, Thanks very much
Great, I have made it worked with your solution,Thank you Mr save the day.NoesisGUI is a greet plugin,I will dive deeper into NoesisGUI,maybe i will need your help when i meet other ploblems.
Anyway, Thanks very much

Re: keyboard focus not work on android TV
Thanks for the good comments!
By the way, I think we should improve the way we handle key events by supporting Unity Virtual Axes. That way you can configure the mapping for our events: Up, Left, Down, Right, FocusNext, FocusPrev, Action...
By the way, I think we should improve the way we handle key events by supporting Unity Virtual Axes. That way you can configure the mapping for our events: Up, Left, Down, Right, FocusNext, FocusPrev, Action...
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 0 guests