Game Development Community

Using controller in menus

by Stephen · in Torque 3D Beginner · 03/18/2014 (6:36 pm) · 31 replies

I have been searching the forums to see if anyone has got their controller working so they can navigate through the menus to change options, enter, and leave missions. Anyone have any input? Thanks
Page «Previous 1 2
#1
03/18/2014 (7:09 pm)
action maps.... Use action maps. If you have bindings to make them work in game then you can use similar bindings with functions that change the selections and activate the selected control. See default.binds.cs
#2
03/18/2014 (7:12 pm)
Okay, so just use action maps. I was wondering if there was someone who created code. I did find this but it's old. Torque: Gui Updates - Beta 1
#3
03/18/2014 (7:31 pm)
I trying to figure out how to move through the menus and it highlights the button like the mouse.

EDIT:
I did find you post about this. www.garagegames.com/community/forums/viewthread/133098/1#comment-840074

Is there any examples on this?
#4
03/18/2014 (7:58 pm)
So I came across GuiGameListMenuCtrl and GuiGameListOptionsCtrl. Is this something I can use?
#5
03/18/2014 (8:36 pm)
Sadly these errors are coming up in the console,
GuiGameListMenuCtrl: (null) can't be created with a profile of type GuiControlProfile. Please create it with a profile of type GuiGameListMenuProfile.
<input> (0): Register object failed for object (null) of class GuiGameListMenuCtrl.
This post says it's fixed but it was an older version of T3D.
www.garagegames.com/community/forums/viewthread/104365
#6
03/18/2014 (10:40 pm)
So I have started creating the custom GUIs for the controller. I made a input menu before the main menu. I'm having problems loading the action map for the controller.

The next thing is to figure out how to highlight the buttons with the controller. Any help? Thanks
#7
03/18/2014 (11:10 pm)
I started researching the same topic. I never got it working with the controller but I did get it to display. I'm going to revisit it soon. Here's what I could dig up from the last time I tried:

singleton GuiGameListMenuProfile(DefaultListMenuProfile)
{
   fontType = "Arial Bold";
   fontSize = 20;
   fontColor = "120 120 120";
   fontColorSEL = "16 16 16";
   fontColorNA = "200 200 200";
   fontColorHL = "100 100 120";
   HitAreaUpperLeft = "16 20";
   HitAreaLowerRight = "503 74";
   IconOffset = "40 0";
   TextOffset = "100 0";
   RowSize = "525 93";
   bitmap = "art/gui/listMenuArray";
   canKeyFocus = true;
};

singleton GuiGameListOptionsProfile(DefaultOptionsMenuProfile)
{
   fontType = "Arial Bold";
   fontSize = 20;
   fontColor = "120 120 120";
   fontColorSEL = "16 16 16";
   fontColorNA = "200 200 200";
   fontColorHL = "100 100 120";
   HitAreaUpperLeft = "16 20";
   HitAreaLowerRight = "503 74";
   IconOffset = "40 0";
   TextOffset = "90 0";
   RowSize = "525 93";
   ColumnSplit = "220";
   RightPad = "20";
   bitmap = "art/gui/listMenuArray";
   canKeyFocus = true;
};

singleton GuiControlProfile(GamepadDefaultProfile)
{
   border = 0;
};

singleton GuiControlProfile(GamepadButtonTextLeft)
{
   fontType = "Arial Bold";
   fontSize = 20;
   fontColor = "40 40 40";
   justify = "left";
};

singleton GuiControlProfile(GamepadButtonTextRight : GamepadButtonTextLeft)
{
   justify = "right";
};

That's the datablocks you're looking for. And it points to this image:
i.imgur.com/df5nP72.png

Here's an example of it from the .gui file:
singleton GuiGameListMenuCtrl(ListMenu) {
      canSaveDynamicFields = "0";
      isContainer = "0";
      Profile = "DefaultListMenuProfile";
      HorizSizing = "right";
      VertSizing = "bottom";
      position = "0 0";
      Extent = "320 240";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      hovertime = "1000";
      CallbackOnA = "ListMenu.activateRow();";
      DebugRender = false;
   };

Oh and to get it working you have to populate it onWake:
function MainMenuGui::onWake(%this)
{
   ListMenu.addRow("Host", "onSinglePlayer", 0);
   ListMenu.addRow("Join", "onSinglePlayer", 0);
   ListMenu.addRow("Options", "onSinglePlayer", 0);
   ListMenu.addRow("Quit", "onSinglePlayer", 0);
}

Hopefully this helps you in some way.
#8
03/19/2014 (2:32 am)
It does help. I just don't understand Garage Games never fully got the controller working; menus and in game.

So I added the code to my project and the buttons load but I'm getting this error in the console.
GuiGameListMenuCtrl: ListMenu can't be woken up without any rows. Please use "addRow" to add at least one row to the control before pushing it to the canvas.
GuiControl::awaken: failed onWake for obj: 2036:GuiGameListMenuCtrl (ListMenu)

I downloaded TGEA 1.8.2 again because I remember them having the GUI setup for a controller. I found more functions dealing with the controller. Was you getting that error as well? The button works with the mouse. I changed it where I can host/join server and open the options. Just the controller doesn't work.
#9
03/19/2014 (3:15 am)
I have added GamepadButtonsGui.cs and GamepadButtonsGui.gui to my project and I'm getting these errors.
art/gui/GamepadButtonsGui.cs (69): Unknown command setEnabled.
  Object ButtonALabel(2038) ButtonALabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (73): Unknown command setEnabled.
  Object ButtonAButton(2039) ButtonAButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (76): Unknown command setEnabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (69): Unknown command setEnabled.
  Object ButtonBLabel(2035) ButtonBLabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (73): Unknown command setEnabled.
  Object ButtonBButton(2036) ButtonBButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (76): Unknown command setEnabled.
  Object ButtonBImg(2034) ButtonBImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (69): Unknown command setEnabled.
  Object ButtonXLabel(2041) ButtonXLabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (73): Unknown command setEnabled.
  Object ButtonXButton(2042) ButtonXButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (76): Unknown command setEnabled.
  Object ButtonXImg(2040) ButtonXImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (69): Unknown command setEnabled.
  Object ButtonYLabel(2044) ButtonYLabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (73): Unknown command setEnabled.
  Object ButtonYButton(2045) ButtonYButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (76): Unknown command setEnabled.
  Object ButtonYImg(2043) ButtonYImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (69): Unknown command setEnabled.
  Object ButtonALabel(2038) ButtonALabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (73): Unknown command setEnabled.
  Object ButtonAButton(2039) ButtonAButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.cs (76): Unknown command setEnabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
I noticed that in the TGEA, it would load buttons at the bottom.
#10
03/19/2014 (4:13 am)
Here's what I got so far.
customProfiles.cs
GamepadButtonsGui.gui
mainMenuGui.gui

The errors,
GuiGameListMenuCtrl: ListMenu can't be woken up without any rows. Please use "addRow" to add at least one row to the control before pushing it to the canvas.
GuiControl::awaken: failed onWake for obj: 2032:GuiGameListMenuCtrl (ListMenu)
Activating DirectInput...
art/gui/GamepadButtonsGui.gui (226): Unknown command setButton.
  Object ListMenu(2032) ListMenu -> GuiGameListMenuCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (227): Unknown command setButton.
  Object ListMenu(2032) ListMenu -> GuiGameListMenuCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (228): Unknown command setButton.
  Object ListMenu(2032) ListMenu -> GuiGameListMenuCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (229): Unknown command setButton.
  Object ListMenu(2032) ListMenu -> GuiGameListMenuCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (263): Unknown command setEnabled.
  Object ButtonALabel(2038) ButtonALabel -> GuiTextCtrl -> GuiContainer -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (267): Unknown command setEnabled.
  Object ButtonAButton(2039) ButtonAButton -> GuiButtonBaseCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (270): Unknown command setEnabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
#11
03/20/2014 (1:37 pm)
Anyone have any ideas? The menus work with the mouse but it doesn't detect the controller or something.
#12
03/20/2014 (2:49 pm)
Quote:
I just don't understand Garage Games never fully got the controller working; menus and in game.
Probably because console-style controllers weren't even an option when the original engine was written and even today it's not very common to use them with PC games - mouse/keyboard is still superior in almost every way.

As for all of those errors, you have called a member function on an object for which that member function is not defined. You'll have to make sure all of those objects (or the class that those objects belong to) have that method defined before calling it.

And your links are broken....
#13
03/20/2014 (2:59 pm)
I understand that mouse and keyboard are superior but there are people that prefer controller since it's easier to control.

I'll have to contact my web host. Sorry about that. Try this new link for the files. If I'm missing something let me know and I'll upload it.
#14
03/20/2014 (3:32 pm)
<shrug> I'll have to fiddle with it when I get home. I don't have a controller but I can probably simulate using WASD.

BTW - setEnabled() doesn't exist for most GUI controls - try just %theControl.enabled = true; or false....

And try this:
function GamepadButtonsGui::onWake(%this)
{
   %this.setButton($BUTTON_A);
   %this.setButton($BUTTON_B);
   %this.setButton($BUTTON_X);
   %this.setButton($BUTTON_Y);
}
Unless the ListMenu object is defined somewhere else - it doesn't seem to have a setButton() method if it is....
#15
03/20/2014 (3:50 pm)
So I just commented out the "SetEnabled" and I don't get those errors anymore but the menus work the same. I'm not sure if commenting them out will help are not.

I have added two screenshots of TGEA and T3D. In TGEA the buttons would show up correctly. (TGEA.png and T3D.png). You can use the same link from my previous post to see the screenshots.
#16
03/20/2014 (4:39 pm)
I didn't say "comment out," I said use
%whateverControl.enabled = true;
// or
%whateverControl.enabled = false;
There is no setEnabled() method, but you can access the enabled property instead.

I'll have to get home and fiddle with it - it's tough to help from here because I have no way to test what I'm thinking.
#17
03/20/2014 (4:44 pm)
%set = (! ((%text $= "") && (%command $= "")));
   %labelCtrl.setText(%text);
   %labelCtrl.enabled = true;
   %labelCtrl.setVisible(%set);

   %buttonCtrl.Command = %command;
   %buttonCtrl.enabled = true;
   %buttonCtrl.setVisible(%set);

   %imgCtrl.enabled(%set);
   %imgCtrl.setVisible(%set);
art/gui/GamepadButtonsGui.gui (287): Unknown command enabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (287): Unknown command enabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (287): Unknown command enabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (287): Unknown command enabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
art/gui/GamepadButtonsGui.gui (287): Unknown command enabled.
  Object ButtonAImg(2037) ButtonAImg -> GuiBitmapCtrl -> GuiControl -> SimGroup -> SimSet -> SimObject
#18
03/20/2014 (5:05 pm)
I don't think you need to worry about enabling or disabling images - just set their visible property if you want to show/hide them....
#19
03/20/2014 (5:09 pm)
Well displaying the images is a small problem. The main problem is getting the engine to pick up the controller and be able to navigate the menus. I'm not sure if this error is the problem or what.
GuiGameListMenuCtrl: ListMenu can't be woken up without any rows. Please use "addRow" to add at least one row to the control before pushing it to the canvas.
GuiControl::awaken: failed onWake for obj: 2032:GuiGameListMenuCtrl (ListMenu)
Code Link
#20
03/23/2014 (1:17 pm)
Any ideas?
Page «Previous 1 2