Thread Tools Display Modes
11/05/15, 10:01 AM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Coding with/for Gamepad UI

Hello,

This afternoon, I will reply to the request to push Roomba to be Gamepad compatible, I'll update this post, and hope you'll enjoy the feedback !


1st step : the request itself : WTF ? Roomba not compatible ? It should be ! It's just a keybind and user need to clic on it ? it's only A KEYBIND maybe he need to move with its controller and press the action button on it ? no ?

Let's try.

2nd step : Damn, ZOS keybind are at left. I had created something which hide Roomba's keybind if there is already something. ok, working as intended


And at right there is ZOS stuff too. Hopefuly , I already write something to put it in the middle ! (or almost, very easy to do).


lines #774, #820 ..
KEYBIND_STRIP_ALIGN_LEFT -> KEYBIND_STRIP_ALIGN_CENTER .. hmm what the code behind ? Let's do a /zgoo while being at bank and keybind_strip displayed !


Ahhhhhhh.. /zgoo don't work while in gamepad menus ?... WTF is this Zgoo dev .. wait.. it's me now.

I neeed that KEYBIND_STRIP while being in menu !!!

okay.. let's see zgoo now...

1, 2, 3rd file, found id. slash_command .. SetGameCameraUIMode() ? try it. testing .. seems that ! commenting.. It don't works. ok SetGameCameraUIMode is not the guilty.. adding a comment to the 1st line of my function linked to my handler :


Lua Code:
  1. SLASH_COMMANDS["/zgoo"] = Zgoo.CommandHandler
  2.  
  3. function Zgoo.CommandHandler(text)
  4.    
  5.     d("zgoo called")
  6.         ...


Nothing. that slash command isn't available while being in menu in gamepad mode ?!


Let's try it differently, take pChat addon and add a d() to check if everything is broken as intended.


Lua Code:
  1. function pChat.showAutoMsg()
  2.     d("showing")
  3.     LMM:ToggleCategory(MENU_CATEGORY_PCHAT)
  4. end
  5.  
  6. -- Register Slash commands
  7. SLASH_COMMANDS["/msg"] = pChat.showAutoMsg

reload, displaying the C panel, or no, already did it, let's try the L panel. that works. ? testing back the C panel ? that works... hmmmm.. ok. that was only the zgoo mouse broken ? my tests were not so correctly done. (hey I should have edited this ! but didn't do.).

So, what's a /zgoo mouse ? Oh wait. it's the push on my associated keybind Alt+F12 which call a zgoo mouse.

Code:
			<Action name="ZGOO_MOUSE">
				<Down>Zgoo.CommandHandler("mouse")</Down>
			</Action>

Maybe the Alt+f12 ? let's try the F4 key. don't work. problem. It should output me d("zgoo called") at least. I must have done an error.

Oh yes, I know a good test !

My addon SuperStar is linked to the key à. tsting it while not being in menus, pressing the key. it works. my addon is displayed.

Displaying the C panel..... presing "à" , DON'T WORK.


Okay, I understood

-> Bindings are disabled while in Gamepad menus. Let's test with F10/F11/F112 (my language switchers). confirmed !



So now.. what's a menu ? a scene ? .. hmmm.. a gamepad scene .. need to guess which part of the UI disabled my bindings in menus.. wait zos, seriously.

Because when I'm on the C panel, the L binding is enabled, but not my F4 one... There should have something.

Let's see esoui\ingame\globals\bindings.xml



Code:
    <Layer name="GamepadUIMode" allowFallthrough="false">
        <Category>
            <Action name="GAMEPAD_UI_EXIT" hideAction="true" rebindable="false">
                <Down>MAIN_MENU_GAMEPAD:AttemptShowBaseScene()</Down>
            </Action>
            <AllowAction name="START_CHAT_ENTER"/>
looks very promising.

let's do it.

Elder Scrolls Online\liveeu\AddOns\DevTools\Bindings.xml
Code:
    <Layer name="GamepadUIMode" allowFallthrough="false">
        <Category>
            <AllowAction name="ZGOO_MOUSE"/>
		</Category>
	</Layer>

ReloadUI > C > F4 . Working !



-> Back to Roomba

F. my life, there is no center keybind anywhere in gamepad. let's revert to keyboard and find on quickly. ok it was centerButtons


#685

Lua Code:
  1. if IsInGamepadPreferredMode() then
  2.         defaults.RoombaPosition = KEYBIND_STRIP_ALIGN_CENTER
  3.     else
  4.         defaults.RoombaPosition = KEYBIND_STRIP_ALIGN_LEFT
  5.     end

#775

Lua Code:
  1. if Roomba.opts.RoombaPosition == KEYBIND_STRIP_ALIGN_LEFT then
  2.         Roomba.keyBindCheck = "leftButtons"
  3.     elseif Roomba.opts.RoombaPosition == KEYBIND_STRIP_ALIGN_RIGHT then
  4.         Roomba.keyBindCheck = "rightButtons"
  5.     elseif Roomba.opts.RoombaPosition == KEYBIND_STRIP_ALIGN_CENTER then
  6.         Roomba.keyBindCheck = "centerButtons"
  7.     end

#825

Lua Code:
  1. setFunc = function(choice)
  2.             if choice == Roomba.lang.RoombaPositionChoice[KEYBIND_STRIP_ALIGN_LEFT] then
  3.                 Roomba.opts.RoombaPosition = KEYBIND_STRIP_ALIGN_LEFT
  4.                 Roomba.keyBindCheck = "leftButtons"
  5.             elseif choice == Roomba.lang.RoombaPositionChoice[KEYBIND_STRIP_ALIGN_RIGHT] then
  6.                 Roomba.opts.RoombaPosition = KEYBIND_STRIP_ALIGN_RIGHT
  7.                 Roomba.keyBindCheck = "rightButtons"
  8.             elseif choice == Roomba.lang.RoombaPositionChoice[KEYBIND_STRIP_ALIGN_CENTER] then
  9.                 Roomba.opts.RoombaPosition = KEYBIND_STRIP_ALIGN_CENTER
  10.                 Roomba.keyBindCheck = "centerButtons"
  11.             elseif IsInGamepadPreferredMode() then
  12.                 -- When user click on LAM reinit button
  13.                 Roomba.opts.RoombaPosition = defaults.RoombaPosition
  14.                 Roomba.keyBindCheck = "centerButtons"
  15.             else
  16.             -- When user click on LAM reinit button
  17.                 Roomba.opts.RoombaPosition = defaults.RoombaPosition
  18.                 Roomba.keyBindCheck = "leftButtons"
  19.             end

reload. and try to align the keybind in center.

ooops. forget fr/en/de.lua and Roomba.lua#819

Lua Code:
  1. Roomba.lang.RoombaPositionChoice[KEYBIND_STRIP_ALIGN_CENTER],

new reloadui. Ooops I push the German key switcher. Np keybind, and I'm aligned in center mode. let's see keybind_strip.

Roomba is here, and enabled. Why not displayed ? are the gamepad UI does not allow keybinds in the center ? First, checking my conditions !

Lua Code:
  1. visible = function(descriptor) return Roomba.isBagDisplayed() end,


Lua Code:
  1. local scene = SCENE_MANAGER:GetCurrentScene():GetName()
  2.     if scene == "guildBank" then
  3.         return true
  4.     else
  5.         return false
  6.     end



Lua Code:
  1. d(SCENE_MANAGER:GetCurrentScene():GetName())
-> [17:42:42] gamepad_guild_bank

Found you little one !

-> All scenes in gamepad mode must be checked !


Changing my scenes ... ok.. ahw, this is still badly coded.

Keybind is here ! Keybind Works !! and .. UI is badly displayed



XML .. relativeTo="ZO_SharedRightPanelBackground" oh yes. Oops. old reference ?


Hmmm.. which one should I use to do not rewrite My WHOLE UI ?


Let's look at esoui\ingame\inventory\gamepad\guildbank_gamepad.xml ...

ZO_GuildBankTopLevel_Gamepad ? or ZO_Gamepad_ParametricList_Screen ? 1st is interesting yes. but 2nd should be better.. oh.. it doesn't have any UI reference. toooo bad .. let's look at it.


Found in esoui\common\gamepad\zo_gamepadparametricscrolllistscreen.xml .. inherits ZO_AnchoredToQuadrant1Background .. nothing.. & nothing.. Oh, that's not very fair.

So let's use ZO_GuildBankTopLevel_Gamepad ! .. But how to do ?
hmmm .. breaking the parent at the addon loaded ?
Or having 2 XML definition and 2 Lua code ?
ZOS choose to do 2 XML and 2 Lua with Lua shared functions. they should have a reason. let's do like 'em !


So my toplevelcontrol will be replicated.. heyyy .. why not having a $(UIMode) in our metafiles ?
should be a nice request. but.. it could break the code because switching to keyboard <-> gamepad is made without reloadui. that's definitively a False good idea.



so : XML :


Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.  
  4.     <!-- Keyboard UI -->
  5.     <TopLevelControl name="RoombaWindow" hidden="true" mouseEnabled="true">
  6.         <Dimensions x="565" />
  7.         <Anchor point="TOPLEFT" relativeTo="ZO_SharedRightPanelBackground" offsetY="90" />
  8.         <Anchor point="BOTTOMLEFT" relativeTo="ZO_SharedRightPanelBackground" offsetY="-20" />
  9.         <Controls>
  10.             <Texture name="$(parent)BG" textureFile="EsoUI/Art/Miscellaneous/listItem_backdrop.dds">
  11.                 <AnchorFill />
  12.                 <TextureCoords left="0" right="1" top="0" bottom=".8125" />
  13.             </Texture>
  14.             <Texture name="$(parent)Icon">
  15.                 <Dimensions x="80" y="80" />
  16.                 <Anchor point="BOTTOM" relativePoint="CENTER" offsetX="20" offsetY="-40" />
  17.             </Texture>
  18.             <Label name="$(parent)Description" inherits="ZO_TooltipIfTruncatedLabel" font="ZoFontGameMedium" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_SECOND_CONTRAST" horizontalAlignment="CENTER">
  19.                 <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="BOTTOM" offsetY="5" offsetX="-300"/>
  20.                 <Dimensions x="600" y="40" />
  21.             </Label>
  22.             <Control name="$(parent)SpeedRow" inherits="ZO_StableTrainingRow_Keyboard" />
  23.         </Controls>
  24.     </TopLevelControl>
  25.  
  26.     <!-- Gamepad UI -->
  27.     <TopLevelControl name="RoombaWindowGamepad" hidden="true" mouseEnabled="true">
  28.         <Dimensions x="565" />
  29.         <Anchor point="TOPLEFT" relativeTo="ZO_GuildBankTopLevel_Gamepad" offsetY="90" />
  30.         <Anchor point="BOTTOMLEFT" relativeTo="ZO_GuildBankTopLevel_Gamepad" offsetY="-20" />
  31.         <Controls>
  32.             <Texture name="$(parent)BG" textureFile="EsoUI/Art/Miscellaneous/listItem_backdrop.dds">
  33.                 <AnchorFill />
  34.                 <TextureCoords left="0" right="1" top="0" bottom=".8125" />
  35.             </Texture>
  36.             <Texture name="$(parent)Icon">
  37.                 <Dimensions x="80" y="80" />
  38.                 <Anchor point="BOTTOM" relativePoint="CENTER" offsetX="20" offsetY="-40" />
  39.             </Texture>
  40.             <Label name="$(parent)Description" inherits="ZO_TooltipIfTruncatedLabel" font="ZoFontGameMedium" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_SECOND_CONTRAST" horizontalAlignment="CENTER">
  41.                 <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="BOTTOM" offsetY="5" offsetX="-300"/>
  42.                 <Dimensions x="600" y="40" />
  43.             </Label>
  44.             <Control name="$(parent)SpeedRow" inherits="ZO_StableTrainingRow_Keyboard" />
  45.         </Controls>
  46.     </TopLevelControl>
  47.  
  48.     </Controls>
  49. </GuiXml>



Changing all my RoombaWindowDescription, RoombaWindowSpeedRow to
Roomba.UI:GetNamedChild("Description"), etc
Oh my god, so many bad code here..

and a

Lua Code:
  1. if IsInGamepadPreferredMode() then
  2.             Roomba.UI = RoombaWindowGamepad
  3.         else
  4.             Roomba.UI = RoombaWindow
  5.         end

Let's see if it works better now.

Oh lua error .. ahw yes

Roomba.InitialiseFrame() at addon loaded and I didn't checked yet (I do it at EVENT_GUILD_BANK_ITEMS_READY).. so lets init both UIs.

Lua Code:
  1. Roomba.InitialiseFrame(RoombaWindow)
  2.         Roomba.InitialiseFrame(RoombaWindowGamepad)
  3.  
  4. function Roomba.InitialiseFrame(object)
  5.    
  6.     object:SetDrawLayer(DL_OVERLAY)
  7.     object:GetNamedChild("SpeedRow").value:SetText(" 0%")
  8.    
  9.     ZO_StatusBar_SetGradientColor(object:GetNamedChild("SpeedRow").bar, ZO_XP_BAR_GRADIENT_COLORS)
  10.     ZO_StatusBar_SmoothTransition(object:GetNamedChild("SpeedRow").bar, 0, 20, FORCE_VALUE)
  11.    
  12.  ...
  13.    
  14. end




Finished !



-> 3h30 for 1 Keybind and a little UI.


Feel free to post any comments or leave some advices if you try a gamepad integration of your addon.

Last edited by Ayantir : 11/05/15 at 01:17 PM.
  Reply With Quote
11/05/15, 10:13 AM   #2
Wandamey
Guest
Posts: n/a
I managed to do some /zgoo mouse on the left scrollList from the chat, but i didn't manage to do it from the keybind of Click4Info (uses that UI Mouse Mode function too) but i couldn't reach any other element (didn't try the keybinds though)

I've seen some mods not displaying what they should (Click4Info, PostIt from the keybind though it works when launched from a function running the same command) I couldn't tell if the problem was from the keybind or from the Mouse UI mode, seems like maybe both...

but I'm not driving more testing for a while. need a break from loading screens.
  Reply With Quote
11/05/15, 10:16 AM   #3
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
@Wandamey, just edited, I got the same cnoclusion as you. I'll look a bit why, but I'll try to focus on the addon to update then
  Reply With Quote
11/05/15, 10:17 AM   #4
Wandamey
Guest
Posts: n/a
Just thought... maybe addon keybind mapping is just not automatically copied to gamepad mode.

I haven't tried to fill in the 4 entries in the control settings.

Edit, forget this that's stupid. keybinds are working in HUD mode.

Last edited by Wandamey : 11/05/15 at 10:21 AM.
  Reply With Quote
11/05/15, 10:25 AM   #5
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Originally Posted by Wandamey View Post
Just thought... maybe addon keybind mapping is just not automatically copied to gamepad mode.

I haven't tried to fill in the 4 entries in the control settings.

Edit, forget this that's stupid. keybinds are working in HUD mode.

Answer in my edited post
  Reply With Quote
11/06/15, 02:57 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,903
Thanks for the intel Ayantir, always glad too see the way more experienced coders are suffering from the same try&error like I do

And many thanks for the good catch with ZGOO, I'd have searched too long for it
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » Coding with/for Gamepad UI

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off