GUI navigation with controller / keyboard..
by Harvey Greensall · in Torque Game Engine · 04/26/2008 (3:39 pm) · 3 replies
Hey all..
I've been looking through the forums for hours, and can't get a definite answer on this. It must be dead easy.
I want to navigate my GUI through a 360 controller, so D pad controls up down, left right, 'A' select, 'B' back...
....or on keyboard, arrow keys up down, left right, 'enter' select, 'escape' back or similar...
I've been reading vague stuff about move maps, 'tabbing' through gui controls etc. but can't actually find ANYTHING that says, 'If you want to ditch the mouse cursor in your GUI and use up, down, left, right keys, do this etc.'
Can anyone help? I'll gladly post our results and any working scripts etc.
Many thanks in advance
I've posted this on TGEA too, but will update if I get a bite, and someone spils the beans.. 8)
Harvey
I've been looking through the forums for hours, and can't get a definite answer on this. It must be dead easy.
I want to navigate my GUI through a 360 controller, so D pad controls up down, left right, 'A' select, 'B' back...
....or on keyboard, arrow keys up down, left right, 'enter' select, 'escape' back or similar...
I've been reading vague stuff about move maps, 'tabbing' through gui controls etc. but can't actually find ANYTHING that says, 'If you want to ditch the mouse cursor in your GUI and use up, down, left, right keys, do this etc.'
Can anyone help? I'll gladly post our results and any working scripts etc.
Many thanks in advance
I've posted this on TGEA too, but will update if I get a bite, and someone spils the beans.. 8)
Harvey
#2
Well, most of our Gui screens are 1 dimension as above, but we do have some with 2 dimensions, ie. we'd need to be able to go left and right too...This look REALLY interesting though, I'll gt our programmer to have a look at it. Basically, if we could get the Stronghold demo mainmenu.gui to scroll around using keys or a controller, we'd have a real fighting chance of hooking up our entire GUI this way...Maybe it's a paid job I can get out there on marketplace...It would make a good resource to give back to the community...
Cheers James, nice start !!!
04/28/2008 (3:51 pm)
Ahaar, a glimmer of hope from someone 8)Well, most of our Gui screens are 1 dimension as above, but we do have some with 2 dimensions, ie. we'd need to be able to go left and right too...This look REALLY interesting though, I'll gt our programmer to have a look at it. Basically, if we could get the Stronghold demo mainmenu.gui to scroll around using keys or a controller, we'd have a real fighting chance of hooking up our entire GUI this way...Maybe it's a paid job I can get out there on marketplace...It would make a good resource to give back to the community...
Cheers James, nice start !!!
#3
Hey Harvey,
If you have not downloaded the new TGEA 1.7 then you should because it has the new gui system with working xbox 360 controller support. The demo that it can be viewed on is called T3D.
Hope that helps.
05/02/2008 (2:29 am)
Hi Guys, just to let you know, I've had this on the TGEA forum. There's a working version of this in the new TGEA 1.7. I works too, just got to get my head around it all now...Hey Harvey,
If you have not downloaded the new TGEA 1.7 then you should because it has the new gui system with working xbox 360 controller support. The demo that it can be viewed on is called T3D.
Hope that helps.
Associate James Ford
Sickhead Games
In general, you might want to have an actionmap that is setup in your gui's onwake and removed in onsleep. Then you need some structure to store the way in which your controls are interconnected.
If it is a simple 1 dimensional structure you could probably use a simSet and cycle through them in order of their index. In the below example however, I use a simple script array.
Lets say, in the simplest cast, you have 1 dimension - its a main menu with several buttons stacked on top of one another.
You might make an array like: funtion mygui::onwake(%this) { %this.navArray[0] = button1Ctrl; %this.navArray[1] = button2Ctrl; %this.navArray[2] = button3Ctrl; %this.selected = 0; %this.last = 2; %map = new ActionMap(); %map.bindObj(%this, Keyboard, right, gotonext ); %map.bindObj(%this, Keyboard, left, gotoprev ); %map.bindObj(%this, Keyboard, enter, pressSelected ); %map.push(); %this.map = %map; } funtion mygui::onsleep(%this) { %this.map.pop(); %this.map.delete(); } function mygui::gotonext( %this ) { %this.selected++; if ( %this.selected > %this.last ) %this.selected = 0; %this.updateSelected(); } function mygui::gotoprev( %this ) { %this.selected--; if ( %this.selected < 0 ) %this.selected = %this.last; %this.updateSelected(); } function mygui::updateSelected(%this) { // Do something here to visually represent which button is selected. } function mygui::pressSelected( %this ) { // I don't recall how to simulate a click event on a button - or execute the command of a button // but do that here. %this.navArray[%this.selected].trigger(); }