1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "GamepadHandle.h"
8 #include "mozilla/Assertions.h"
9 #include "mozilla/HashFunctions.h"
11 namespace mozilla::dom
{
13 GamepadHandle::GamepadHandle(uint32_t aValue
, GamepadHandleKind aKind
)
14 : mValue(aValue
), mKind(aKind
) {
15 MOZ_RELEASE_ASSERT(mValue
);
18 GamepadHandleKind
GamepadHandle::GetKind() const { return mKind
; }
20 PLDHashNumber
GamepadHandle::Hash() const {
21 return HashGeneric(mValue
, uint8_t(mKind
));
24 bool operator==(const GamepadHandle
& a
, const GamepadHandle
& b
) {
25 return (a
.mValue
== b
.mValue
) && (a
.mKind
== b
.mKind
);
28 bool operator!=(const GamepadHandle
& a
, const GamepadHandle
& b
) {
32 bool operator<(const GamepadHandle
& a
, const GamepadHandle
& b
) {
33 if (a
.mKind
== b
.mKind
) {
34 return a
.mValue
< b
.mValue
;
36 // Arbitrarily order them by kind
37 return uint8_t(a
.mKind
) < uint8_t(b
.mKind
);
40 } // namespace mozilla::dom