зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1313581 - Part 1: Support hand attribute in GamepadAPI; r=kip,lenzak800,qdot
MozReview-Commit-ID: 9n48LGaqOP2 --HG-- extra : rebase_source : b4e7a0dd831a15b1b1ea36ef1dd8d1c83e7b3fce
This commit is contained in:
Родитель
390a9ca00f
Коммит
168eb8d109
|
@ -38,11 +38,13 @@ Gamepad::UpdateTimestamp()
|
|||
Gamepad::Gamepad(nsISupports* aParent,
|
||||
const nsAString& aID, uint32_t aIndex,
|
||||
GamepadMappingType aMapping,
|
||||
GamepadHand aHand,
|
||||
uint32_t aNumButtons, uint32_t aNumAxes)
|
||||
: mParent(aParent),
|
||||
mID(aID),
|
||||
mIndex(aIndex),
|
||||
mMapping(aMapping),
|
||||
mHand(aHand),
|
||||
mConnected(true),
|
||||
mButtons(aNumButtons),
|
||||
mAxes(aNumAxes),
|
||||
|
@ -122,6 +124,7 @@ Gamepad::SyncState(Gamepad* aOther)
|
|||
if (Preferences::GetBool(kGamepadExtEnabledPref)) {
|
||||
MOZ_ASSERT(aOther->GetPose());
|
||||
mPose->SetPoseState(aOther->GetPose()->GetPoseState());
|
||||
mHand = aOther->Hand();
|
||||
}
|
||||
|
||||
UpdateTimestamp();
|
||||
|
@ -132,7 +135,7 @@ Gamepad::Clone(nsISupports* aParent)
|
|||
{
|
||||
RefPtr<Gamepad> out =
|
||||
new Gamepad(aParent, mID, mIndex, mMapping,
|
||||
mButtons.Length(), mAxes.Length());
|
||||
mHand, mButtons.Length(), mAxes.Length());
|
||||
out->SyncState(this);
|
||||
return out.forget();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class Gamepad final : public nsISupports,
|
|||
public:
|
||||
Gamepad(nsISupports* aParent,
|
||||
const nsAString& aID, uint32_t aIndex,
|
||||
GamepadMappingType aMapping,
|
||||
GamepadMappingType aMapping, GamepadHand aHand,
|
||||
uint32_t aNumButtons, uint32_t aNumAxes);
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Gamepad)
|
||||
|
@ -81,6 +81,11 @@ public:
|
|||
return mMapping;
|
||||
}
|
||||
|
||||
GamepadHand Hand()
|
||||
{
|
||||
return mHand;
|
||||
}
|
||||
|
||||
bool Connected() const
|
||||
{
|
||||
return mConnected;
|
||||
|
@ -117,6 +122,7 @@ protected:
|
|||
|
||||
// The mapping in use.
|
||||
GamepadMappingType mMapping;
|
||||
GamepadHand mHand;
|
||||
|
||||
// true if this gamepad is currently connected.
|
||||
bool mConnected;
|
||||
|
|
|
@ -16,6 +16,10 @@ struct GamepadAdded {
|
|||
// 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;
|
||||
GamepadServiceType service_type;
|
||||
uint32_t num_buttons;
|
||||
uint32_t num_axes;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://w3c.github.io/gamepad/
|
||||
* https://w3c.github.io/gamepad/extensions.html
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.enabled"]
|
||||
interface GamepadButton {
|
||||
|
@ -9,6 +14,12 @@ interface GamepadButton {
|
|||
readonly attribute double value;
|
||||
};
|
||||
|
||||
enum GamepadHand {
|
||||
"",
|
||||
"left",
|
||||
"right"
|
||||
};
|
||||
|
||||
enum GamepadMappingType {
|
||||
"",
|
||||
"standard"
|
||||
|
@ -33,6 +44,13 @@ interface Gamepad {
|
|||
*/
|
||||
readonly attribute GamepadMappingType mapping;
|
||||
|
||||
/**
|
||||
* The hand in use for this device. The empty string
|
||||
* indicates that unknown, both hands, or not applicable
|
||||
*/
|
||||
[Pref="dom.gamepad.extensions.enabled"]
|
||||
readonly attribute GamepadHand hand;
|
||||
|
||||
/**
|
||||
* true if this gamepad is currently connected to the system.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче