Bug 1315896 - Part 2: Remove MOZ_GAMEPAD in Gamepad module; r?ted.mielczarek draft
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 08 Dec 2016 13:00:44 -1000
changeset 450568 98df1d5ce763927fb085e49422db3f7af436aec8
parent 450567 dc129e61779b8c16e0e559e6780268a4a9614404
child 450569 7afc961dafc3983672ae2af002050785084e3aa7
push id38902
push userbmo:dmu@mozilla.com
push dateSat, 17 Dec 2016 00:19:00 +0000
reviewersted.mielczarek
bugs1315896
milestone53.0a1
Bug 1315896 - Part 2: Remove MOZ_GAMEPAD in Gamepad module; r?ted.mielczarek MozReview-Commit-ID: Hbv6THaI5Rk
dom/events/EventListenerManager.cpp
dom/gamepad/GamepadPlatformService.cpp
dom/gamepad/GamepadServiceTest.cpp
dom/gamepad/GamepadServiceTest.h
dom/gamepad/ipc/GamepadEventTypes.ipdlh
dom/gamepad/ipc/GamepadMessageUtils.h
dom/gamepad/moz.build
dom/tests/moz.build
hal/moz.build
ipc/glue/BackgroundChildImpl.cpp
ipc/glue/BackgroundParentImpl.cpp
old-configure.in
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -403,23 +403,21 @@ EventListenerManager::AddEventListenerIn
       nsCOMPtr<nsIDocument> d = window->GetExtantDoc();
       NS_WARNING_ASSERTION(
         !nsContentUtils::IsChromeDoc(d),
         "Please do not use mouseenter/leave events in chrome. "
         "They are slower than mouseover/out!");
 #endif
       window->SetHasMouseEnterLeaveEventListeners();
     }
-#ifdef MOZ_GAMEPAD
   } else if (aEventMessage >= eGamepadEventFirst &&
              aEventMessage <= eGamepadEventLast) {
     if (nsPIDOMWindowInner* window = GetInnerWindowForTarget()) {
       window->SetHasGamepadEventListener();
     }
-#endif
   } else if (aTypeAtom == nsGkAtoms::onkeydown ||
              aTypeAtom == nsGkAtoms::onkeypress ||
              aTypeAtom == nsGkAtoms::onkeyup) {
     if (!aFlags.mInSystemGroup) {
       mMayHaveKeyEventListener = true;
     }
   } else if (aTypeAtom == nsGkAtoms::oncompositionend ||
              aTypeAtom == nsGkAtoms::oncompositionstart ||
--- a/dom/gamepad/GamepadPlatformService.cpp
+++ b/dom/gamepad/GamepadPlatformService.cpp
@@ -90,18 +90,18 @@ GamepadPlatformService::AddGamepad(const
 {
   // This method is called by monitor thread populated in
   // platform-dependent backends
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(!NS_IsMainThread());
 
   uint32_t index = ++mGamepadIndex;
   GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)), index,
-                 static_cast<uint32_t>(aMapping), static_cast<uint32_t>(GamepadHand::_empty),
-                 GamepadServiceType::Standard, aNumButtons, aNumAxes);
+                 aMapping, GamepadHand::_empty, GamepadServiceType::Standard,
+                 aNumButtons, aNumAxes);
   NotifyGamepadChange<GamepadAdded>(a);
   return index;
 }
 
 void
 GamepadPlatformService::RemoveGamepad(uint32_t aIndex)
 {
   // This method is called by monitor thread populated in
--- a/dom/gamepad/GamepadServiceTest.cpp
+++ b/dom/gamepad/GamepadServiceTest.cpp
@@ -108,27 +108,27 @@ GamepadServiceTest::DestroyPBackgroundAc
     // want to destroy it now, just cancel all pending
     // operations.
     mPendingOperations.Clear();
   }
 }
 
 already_AddRefed<Promise>
 GamepadServiceTest::AddGamepad(const nsAString& aID,
-                               uint32_t aMapping,
+                               GamepadMappingType aMapping,
                                uint32_t aNumButtons,
                                uint32_t aNumAxes,
                                ErrorResult& aRv)
 {
   if (mShuttingDown) {
     return nullptr;
   }
 
   GamepadAdded a(nsString(aID), 0,
-                 aMapping, static_cast<uint32_t>(GamepadHand::_empty),
+                 aMapping, GamepadHand::_empty,
                  GamepadServiceType::Standard,
                  aNumButtons, aNumAxes);
   GamepadChangeEvent e(a);
   nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
 
   RefPtr<Promise> p = Promise::Create(go, aRv);
   if (aRv.Failed()) {
     return nullptr;
--- a/dom/gamepad/GamepadServiceTest.h
+++ b/dom/gamepad/GamepadServiceTest.h
@@ -24,21 +24,21 @@ class GamepadServiceTest final : public 
                                  public nsIIPCBackgroundChildCreateCallback
 {
 public:
   NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GamepadServiceTest,
                                            DOMEventTargetHelper)
 
-  uint32_t NoMapping() const { return 0; }
-  uint32_t StandardMapping() const { return 1; }
+  GamepadMappingType NoMapping() const { return GamepadMappingType::_empty; }
+  GamepadMappingType StandardMapping() const { return GamepadMappingType::Standard; }
 
   already_AddRefed<Promise> AddGamepad(const nsAString& aID,
-                                       uint32_t aMapping,
+                                       GamepadMappingType aMapping,
                                        uint32_t aNumButtons,
                                        uint32_t aNumAxes,
                                        ErrorResult& aRv);
   void RemoveGamepad(uint32_t aIndex);
   void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed);
   void NewButtonValueEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, double aValue);
   void NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue);
   void Shutdown();
--- a/dom/gamepad/ipc/GamepadEventTypes.ipdlh
+++ b/dom/gamepad/ipc/GamepadEventTypes.ipdlh
@@ -1,30 +1,26 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 using mozilla::dom::GamepadServiceType from "mozilla/dom/GamepadMessageUtils.h";
 using mozilla::dom::GamepadPoseState from "mozilla/dom/GamepadMessageUtils.h";
+using mozilla::dom::GamepadMappingType from "mozilla/dom/GamepadMessageUtils.h";
+using mozilla::dom::GamepadHand from "mozilla/dom/GamepadMessageUtils.h";
 
 
 namespace mozilla {
 namespace dom {
 
 struct GamepadAdded {
   nsString id;
   uint32_t index;
-  // Ideally, mapping should be a GamepadMappingType
-  // But, we have dependency problems in non MOZ_GAMEPAD
-  // platforms. Therefore, we make it as an uint32_t here.
-  uint32_t mapping;
-  // Ideally, hand should be a GamepadHand
-  // But, we have dependency problems in non MOZ_GAMEPAD
-  // platforms. Therefore, we make it as an uint32_t here.
-  uint32_t hand;
+  GamepadMappingType mapping;
+  GamepadHand hand;
   GamepadServiceType service_type;
   uint32_t num_buttons;
   uint32_t num_axes;
 };
 
 struct GamepadRemoved {
   uint32_t index;
   GamepadServiceType service_type;
--- a/dom/gamepad/ipc/GamepadMessageUtils.h
+++ b/dom/gamepad/ipc/GamepadMessageUtils.h
@@ -1,19 +1,34 @@
 
 #ifndef mozilla_dom_gamepad_GamepadMessageUtils_h
 #define mozilla_dom_gamepad_GamepadMessageUtils_h
 
 #include "ipc/IPCMessageUtils.h"
+#include "mozilla/dom/GamepadBinding.h"
+#include "mozilla/dom/GamepadPoseState.h"
 #include "mozilla/dom/GamepadServiceType.h"
-#include "mozilla/dom/GamepadPoseState.h"
 
 namespace IPC {
 
 template<>
+struct ParamTraits<mozilla::dom::GamepadMappingType> :
+  public ContiguousEnumSerializer<mozilla::dom::GamepadMappingType,
+                                  mozilla::dom::GamepadMappingType(0),
+                                  mozilla::dom::GamepadMappingType(
+                                  mozilla::dom::GamepadMappingType::EndGuard_)> {};
+
+template<>
+struct ParamTraits<mozilla::dom::GamepadHand> :
+  public ContiguousEnumSerializer<mozilla::dom::GamepadHand,
+                                  mozilla::dom::GamepadHand(0),
+                                  mozilla::dom::GamepadHand(
+                                  mozilla::dom::GamepadHand::EndGuard_)> {};
+
+template<>
 struct ParamTraits<mozilla::dom::GamepadServiceType> :
   public ContiguousEnumSerializer<mozilla::dom::GamepadServiceType,
                                   mozilla::dom::GamepadServiceType(0),
                                   mozilla::dom::GamepadServiceType(
                                   mozilla::dom::GamepadServiceType::NumGamepadServiceType)> {};
 
 template<>
 struct ParamTraits<mozilla::dom::GamepadCapabilityFlags> :
--- a/dom/gamepad/moz.build
+++ b/dom/gamepad/moz.build
@@ -6,78 +6,74 @@
 
 IPDL_SOURCES += [
     'ipc/GamepadEventTypes.ipdlh',
     'ipc/PGamepadEventChannel.ipdl',
     'ipc/PGamepadTestChannel.ipdl'
 ]
 
 EXPORTS.mozilla.dom += [
+    'Gamepad.h',
+    'GamepadButton.h',
+    'GamepadManager.h',
+    'GamepadMonitoring.h',
+    'GamepadPlatformService.h',
+    'GamepadPose.h',
     'GamepadPoseState.h',
+    'GamepadServiceTest.h',
+    'ipc/GamepadEventChannelChild.h',
+    'ipc/GamepadEventChannelParent.h',
     'ipc/GamepadMessageUtils.h',
-    'ipc/GamepadServiceType.h'
+    'ipc/GamepadServiceType.h',
+    'ipc/GamepadTestChannelChild.h',
+    'ipc/GamepadTestChannelParent.h'
+]
+
+UNIFIED_SOURCES = [
+    'Gamepad.cpp',
+    'GamepadButton.cpp',
+    'GamepadManager.cpp',
+    'GamepadMonitoring.cpp',
+    'GamepadPlatformService.cpp',
+    'GamepadPose.cpp',
+    'GamepadServiceTest.cpp',
+    'ipc/GamepadEventChannelChild.cpp',
+    'ipc/GamepadEventChannelParent.cpp',
+    'ipc/GamepadTestChannelChild.cpp',
+    'ipc/GamepadTestChannelParent.cpp'
 ]
 
-if CONFIG['MOZ_GAMEPAD']:
-    EXPORTS.mozilla.dom += [
-        'Gamepad.h',
-        'GamepadButton.h',
-        'GamepadManager.h',
-        'GamepadMonitoring.h',
-        'GamepadPlatformService.h',
-        'GamepadPose.h',
-        'GamepadServiceTest.h',
-        'ipc/GamepadEventChannelChild.h',
-        'ipc/GamepadEventChannelParent.h',
-        'ipc/GamepadTestChannelChild.h',
-        'ipc/GamepadTestChannelParent.h'
-        ]
-
-    UNIFIED_SOURCES = [
-        'Gamepad.cpp',
-        'GamepadButton.cpp',
-        'GamepadManager.cpp',
-        'GamepadMonitoring.cpp',
-        'GamepadPlatformService.cpp',
-        'GamepadPose.cpp',
-        'GamepadServiceTest.cpp',
-        'ipc/GamepadEventChannelChild.cpp',
-        'ipc/GamepadEventChannelParent.cpp',
-        'ipc/GamepadTestChannelChild.cpp',
-        'ipc/GamepadTestChannelParent.cpp'
-        ]
-
-    if CONFIG['MOZ_GAMEPAD_BACKEND'] == 'stub':
-        UNIFIED_SOURCES += [
-            'fallback/FallbackGamepad.cpp'
-        ]
-    elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'cocoa':
-        UNIFIED_SOURCES += [
-            'cocoa/CocoaGamepad.cpp'
-        ]
-    elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'windows':
-        UNIFIED_SOURCES += [
-            'windows/WindowsGamepad.cpp'
-        ]
-    elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'linux':
-        UNIFIED_SOURCES += [
-            'linux/LinuxGamepad.cpp'
-        ]
-    elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'android':
-        UNIFIED_SOURCES += [
-            'android/AndroidGamepad.cpp'
-        ]
-
-    LOCAL_INCLUDES += [
-        'ipc',
+if CONFIG['MOZ_GAMEPAD_BACKEND'] == 'stub':
+    UNIFIED_SOURCES += [
+        'fallback/FallbackGamepad.cpp'
+    ]
+elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'cocoa':
+    UNIFIED_SOURCES += [
+        'cocoa/CocoaGamepad.cpp'
+    ]
+elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'windows':
+    UNIFIED_SOURCES += [
+        'windows/WindowsGamepad.cpp'
+    ]
+elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'linux':
+    UNIFIED_SOURCES += [
+        'linux/LinuxGamepad.cpp'
+    ]
+elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'android':
+    UNIFIED_SOURCES += [
+        'android/AndroidGamepad.cpp'
     ]
 
-    include('/ipc/chromium/chromium-config.mozbuild')
+LOCAL_INCLUDES += [
+    'ipc',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
 
-    FINAL_LIBRARY = 'xul'
-    LOCAL_INCLUDES += [
-        '/dom/base',
-    ]
+FINAL_LIBRARY = 'xul'
+LOCAL_INCLUDES += [
+    '/dom/base',
+]
 
-    CFLAGS += CONFIG['GLIB_CFLAGS']
-    CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
-    CXXFLAGS += CONFIG['GLIB_CFLAGS']
-    CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+CFLAGS += CONFIG['GLIB_CFLAGS']
+CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+CXXFLAGS += CONFIG['GLIB_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
--- a/dom/tests/moz.build
+++ b/dom/tests/moz.build
@@ -13,16 +13,17 @@ MOCHITEST_MANIFESTS += [
     'mochitest/beacon/mochitest.ini',
     'mochitest/bugs/mochitest.ini',
     'mochitest/crypto/mochitest.ini',
     'mochitest/dom-level0/mochitest.ini',
     'mochitest/dom-level1-core/mochitest.ini',
     'mochitest/dom-level2-core/mochitest.ini',
     'mochitest/dom-level2-html/mochitest.ini',
     'mochitest/fetch/mochitest.ini',
+    'mochitest/gamepad/mochitest.ini',
     'mochitest/general/mochitest.ini',
     'mochitest/geolocation/mochitest.ini',
     'mochitest/localstorage/mochitest.ini',
     'mochitest/notification/mochitest.ini',
     'mochitest/orientation/mochitest.ini',
     'mochitest/pointerlock/mochitest.ini',
     'mochitest/sessionstorage/mochitest.ini',
     'mochitest/storageevent/mochitest.ini',
@@ -36,21 +37,16 @@ MOCHITEST_CHROME_MANIFESTS += [
     'mochitest/general/chrome.ini',
     'mochitest/geolocation/chrome.ini',
     'mochitest/localstorage/chrome.ini',
     'mochitest/sessionstorage/chrome.ini',
     'mochitest/webcomponents/chrome.ini',
     'mochitest/whatwg/chrome.ini',
 ]
 
-if CONFIG['MOZ_GAMEPAD']:
-    MOCHITEST_MANIFESTS += [
-        'mochitest/gamepad/mochitest.ini',
-    ]
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']
 
 TEST_HARNESS_FILES.testing.mochitest.tests.dom.tests.mochitest.ajax.lib += [
     'mochitest/ajax/lib/AJAX_setup.js',
     'mochitest/ajax/lib/test.css',
 ]
 
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -159,20 +159,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
 IPDL_SOURCES = [
     'sandbox/PHal.ipdl',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
-if CONFIG['MOZ_GAMEPAD']:
-    LOCAL_INCLUDES += [
-        '/dom/base',
-    ]
+LOCAL_INCLUDES += [
+    '/dom/base',
+]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     # So that we can call nsScreenManagerGonk::GetConfiguration().
     LOCAL_INCLUDES += [
         '/widget',
         '/widget/gonk',
     ]
 
--- a/ipc/glue/BackgroundChildImpl.cpp
+++ b/ipc/glue/BackgroundChildImpl.cpp
@@ -19,20 +19,18 @@
 #include "mozilla/dom/PFileSystemRequestChild.h"
 #include "mozilla/dom/FileSystemTaskBase.h"
 #include "mozilla/dom/asmjscache/AsmJSCache.h"
 #include "mozilla/dom/cache/ActorUtils.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
 #include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsChild.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/dom/quota/PQuotaChild.h"
-#ifdef MOZ_GAMEPAD
 #include "mozilla/dom/GamepadEventChannelChild.h"
 #include "mozilla/dom/GamepadTestChannelChild.h"
-#endif
 #include "mozilla/dom/MessagePortChild.h"
 #include "mozilla/ipc/PBackgroundTestChild.h"
 #include "mozilla/ipc/PSendStreamChild.h"
 #include "mozilla/layout/VsyncChild.h"
 #include "mozilla/net/PUDPSocketChild.h"
 #include "mozilla/dom/network/UDPSocketChild.h"
 #include "nsID.h"
 #include "nsTraceRefcnt.h"
@@ -476,39 +474,33 @@ BackgroundChildImpl::AllocPGamepadEventC
 {
   MOZ_CRASH("PGamepadEventChannelChild actor should be manually constructed!");
   return nullptr;
 }
 
 bool
 BackgroundChildImpl::DeallocPGamepadEventChannelChild(PGamepadEventChannelChild* aActor)
 {
-#ifdef MOZ_GAMEPAD
   MOZ_ASSERT(aActor);
   delete static_cast<dom::GamepadEventChannelChild*>(aActor);
-#endif
   return true;
 }
 
 dom::PGamepadTestChannelChild*
 BackgroundChildImpl::AllocPGamepadTestChannelChild()
 {
-#ifdef MOZ_GAMEPAD
   MOZ_CRASH("PGamepadTestChannelChild actor should be manually constructed!");
-#endif
   return nullptr;
 }
 
 bool
 BackgroundChildImpl::DeallocPGamepadTestChannelChild(PGamepadTestChannelChild* aActor)
 {
-#ifdef MOZ_GAMEPAD
   MOZ_ASSERT(aActor);
   delete static_cast<dom::GamepadTestChannelChild*>(aActor);
-#endif
   return true;
 }
 
 } // namespace ipc
 } // namespace mozilla
 
 mozilla::ipc::IPCResult
 TestChild::Recv__delete__(const nsCString& aTestArg)
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -12,20 +12,18 @@
 #include "CamerasParent.h"
 #endif
 #include "mozilla/media/MediaParent.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemRequestParent.h"
-#ifdef MOZ_GAMEPAD
 #include "mozilla/dom/GamepadEventChannelParent.h"
 #include "mozilla/dom/GamepadTestChannelParent.h"
-#endif
 #include "mozilla/dom/PBlobParent.h"
 #include "mozilla/dom/PGamepadEventChannelParent.h"
 #include "mozilla/dom/PGamepadTestChannelParent.h"
 #include "mozilla/dom/MessagePortParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/asmjscache/AsmJSCache.h"
 #include "mozilla/dom/cache/ActorUtils.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
@@ -901,58 +899,46 @@ BackgroundParentImpl::DeallocPFileSystem
     dont_AddRef(static_cast<FileSystemRequestParent*>(aDoomed));
   return true;
 }
 
 // Gamepad API Background IPC
 dom::PGamepadEventChannelParent*
 BackgroundParentImpl::AllocPGamepadEventChannelParent()
 {
-#ifdef MOZ_GAMEPAD
   RefPtr<dom::GamepadEventChannelParent> parent =
     new dom::GamepadEventChannelParent();
 
   return parent.forget().take();
-#else
-  return nullptr;
-#endif
 }
 
 bool
 BackgroundParentImpl::DeallocPGamepadEventChannelParent(dom::PGamepadEventChannelParent *aActor)
 {
-#ifdef MOZ_GAMEPAD
   MOZ_ASSERT(aActor);
   RefPtr<dom::GamepadEventChannelParent> parent =
     dont_AddRef(static_cast<dom::GamepadEventChannelParent*>(aActor));
-#endif
   return true;
 }
 
 dom::PGamepadTestChannelParent*
 BackgroundParentImpl::AllocPGamepadTestChannelParent()
 {
-#ifdef MOZ_GAMEPAD
   RefPtr<dom::GamepadTestChannelParent> parent =
     new dom::GamepadTestChannelParent();
 
   return parent.forget().take();
-#else
-  return nullptr;
-#endif
 }
 
 bool
 BackgroundParentImpl::DeallocPGamepadTestChannelParent(dom::PGamepadTestChannelParent *aActor)
 {
-#ifdef MOZ_GAMEPAD
   MOZ_ASSERT(aActor);
   RefPtr<dom::GamepadTestChannelParent> parent =
     dont_AddRef(static_cast<dom::GamepadTestChannelParent*>(aActor));
-#endif
   return true;
 }
 
 } // namespace ipc
 } // namespace mozilla
 
 void
 TestParent::ActorDestroy(ActorDestroyReason aWhy)
--- a/old-configure.in
+++ b/old-configure.in
@@ -3448,51 +3448,41 @@ if test -n "$MOZ_ANGLE_RENDERER"; then
 fi # MOZ_ANGLE_RENDERER
 
 fi # COMPILE_ENVIRONMENT
 
 
 dnl ========================================================
 dnl Gamepad support
 dnl ========================================================
-MOZ_GAMEPAD=1
 MOZ_GAMEPAD_BACKEND=stub
 
-MOZ_ARG_DISABLE_BOOL(gamepad,
-[  --disable-gamepad   Disable gamepad support],
-    MOZ_GAMEPAD=,
-    MOZ_GAMEPAD=1)
-
-if test "$MOZ_GAMEPAD"; then
-    case "$OS_TARGET" in
-    Darwin)
-        if test -z "$MOZ_IOS"; then
-            MOZ_GAMEPAD_BACKEND=cocoa
-        fi
-        ;;
-    WINNT)
-        MOZ_GAMEPAD_BACKEND=windows
-        ;;
-    Linux)
-        MOZ_CHECK_HEADER([linux/joystick.h])
-        if test "$ac_cv_header_linux_joystick_h" != "yes"; then
-          AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers or reconfigure with --disable-gamepad to disable gamepad support.])
-        fi
-        MOZ_GAMEPAD_BACKEND=linux
-        ;;
-    Android)
-        MOZ_GAMEPAD_BACKEND=android
-        ;;
-    *)
-        ;;
-   esac
-
-  AC_DEFINE(MOZ_GAMEPAD)
-fi
-AC_SUBST(MOZ_GAMEPAD)
+case "$OS_TARGET" in
+Darwin)
+    if test -z "$MOZ_IOS"; then
+        MOZ_GAMEPAD_BACKEND=cocoa
+    fi
+    ;;
+WINNT)
+    MOZ_GAMEPAD_BACKEND=windows
+    ;;
+Linux)
+    MOZ_CHECK_HEADER([linux/joystick.h])
+    if test "$ac_cv_header_linux_joystick_h" != "yes"; then
+      AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
+    fi
+    MOZ_GAMEPAD_BACKEND=linux
+    ;;
+Android)
+    MOZ_GAMEPAD_BACKEND=android
+    ;;
+*)
+    ;;
+esac
+
 AC_SUBST(MOZ_GAMEPAD_BACKEND)
 
 dnl ========================================================
 dnl = Breakpad crash reporting (on by default on supported platforms)
 dnl ========================================================
 
 case $target in
 i?86-*-mingw*|x86_64-*-mingw*)