%define __enable_network_camera 0
%endif
+%if "%{enable_gamepad_latency_test}" == "1"
+%define __enable_gamepad_latency_test 1
+%else
+%define __enable_gamepad_latency_test 0
+%endif
%{?_use_system_icu: %define __use_system_icu %{_use_system_icu}}
# Product tv can't utilize system icu due to nacl dependency.
%if "%{?profile}" != "tv" && %{tizen_version} == 60 && %{?_use_system_icu: 0}%{!?_use_system_icu: 1}
%if %{__enable_network_camera}
"enable_network_camera=true" \
%endif
+%if %{__enable_gamepad_latency_test}
+ "enable_gamepad_latency_test=true" \
+%endif
%if %{__drm_mapi_aarch_64} && "%{?tizen_profile_name}" == "tv" && %{tizen_version} >= 80
"drm_mapi_aarch_64=true" \
%endif
// floor.
void Gamepad::SetTimestamp(const device::Gamepad& device_gamepad,
bool cross_origin_isolated_capability) {
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ timestamp_ = device_gamepad.timestamp;
+#else
base::TimeTicks last_updated =
base::TimeTicks() + base::Microseconds(device_gamepad.timestamp);
if (last_updated < time_floor_)
TRACE_COUNTER1("input", "XR gamepad pose age (ms)",
(now - last_updated).InMilliseconds());
}
+#endif
}
void Gamepad::Trace(Visitor* visitor) const {
#include "third_party/blink/renderer/modules/gamepad/navigator_gamepad.h"
#include "base/auto_reset.h"
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+#include "base/files/file_util.h"
+#endif
#include "device/gamepad/public/cpp/gamepad_features.h"
#include "device/gamepad/public/cpp/gamepads.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
}
namespace {
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+FILE* latency_file = nullptr;
+void openLatencyFile() {
+ if (latency_file != nullptr)
+ return;
+
+ LOG(ERROR) << "openLatencyFile";
+ char filename[128];
+ pid_t pid = getpid();
+ snprintf(filename, sizeof(char) * (128), "/tmp/latency-%d-render", (int)pid);
+ LOG(ERROR) << "filename is " << filename;
+ base::FilePath filepath(filename);
+ latency_file = base::OpenFile(filepath, "a");
+ if (latency_file == nullptr) {
+ LOG(ERROR) << "file open failed!";
+ return;
+ }
+ LOG(ERROR) << "file open success";
+}
+
+void closeLatencyFile() {
+ LOG(ERROR) << "Enter closeLatencyFile";
+ if (latency_file == nullptr) {
+ LOG(ERROR) << "file is not open!";
+ return;
+ }
+ base::CloseFile(latency_file);
+ latency_file = nullptr;
+}
+#endif
void RecordGamepadsForIdentifiabilityStudy(
ExecutionContext* context,
}
vibration_actuators_.resize(device::Gamepads::kItemsLengthCap);
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ openLatencyFile();
+#endif
}
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+NavigatorGamepad::~NavigatorGamepad() {
+ closeLatencyFile();
+}
+#else
NavigatorGamepad::~NavigatorGamepad() = default;
+#endif
void NavigatorGamepad::RegisterWithDispatcher() {
gamepad_dispatcher_->AddController(this, DomWindow());
GamepadComparisons::Compare(gamepads_, gamepads_back_, false, false);
if (compare_result.IsDifferent()) {
std::swap(gamepads_, gamepads_back_);
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ if (gamepads_[0] != nullptr && latency_file != nullptr) {
+ struct timespec time_now;
+ clock_gettime(CLOCK_REALTIME, &time_now);
+ unsigned long long curtime =
+ (unsigned long long)time_now.tv_sec * 1000000 +
+ (unsigned long long)(time_now.tv_nsec / 1000);
+ fprintf(latency_file, "%s%f%s%llu\n",
+ "driver time:", gamepads_[0]->timestamp(),
+ " render current time:", curtime);
+ fflush(latency_file);
+ LOG(ERROR) << "[LatencyTestRender][" << gamepads_[0]->timestamp()
+ << "] chromium-render got time: " << curtime;
+ }
+#endif
bool is_gamepads_back_exposed = is_gamepads_exposed_;
is_gamepads_exposed_ = false;
"_LINUX",
]
}
+ if (enable_gamepad_latency_test) {
+ defines += [ "TIZEN_ENABLE_GAMEPAD_LATENCY_TEST" ]
+ }
if (build_chrome) {
defines += [ "BUILD_CHROME" ]
}
tizen_resource_manager = false
enable_network_camera = false
+ enable_gamepad_latency_test = false
tizen_thread_booster_service = false
drm_mapi_aarch_64 = false
#include "tizen_src/ewk/efl_integration/browser/gamepad/oci_gamepad_item.h"
#include <autoinput.h>
#include <utility>
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+#include "base/files/file_util.h"
+#endif
#include "base/logging.h"
#include "tizen_src/chromium_impl/build/tizen_version.h"
#define VIRTUAL_KEY_GAMEHOME 572
namespace device {
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+FILE* latency_file = nullptr;
+void openLatencyFile() {
+ LOG(ERROR) << "openLatencyFile";
+ char filename[128];
+ pid_t pid = getpid();
+ snprintf(filename, sizeof(char) * (128), "/tmp/latency-%d-browser", (int)pid);
+ LOG(ERROR) << "filename is " << filename;
+ base::FilePath filepath(filename);
+ latency_file = base::OpenFile(filepath, "a");
+ if (latency_file == nullptr) {
+ LOG(ERROR) << "file open failed!";
+ return;
+ }
+ LOG(ERROR) << "file open success ";
+}
+
+void closeLatencyFile() {
+ if (latency_file == nullptr) {
+ LOG(ERROR) << "file is not open!";
+ return;
+ }
+ base::CloseFile(latency_file);
+ latency_file = nullptr;
+}
+#endif
+
size_t OCIGamepadItem::s_oci_gamepaditem_num_ = 0;
// static function
home_event_.type = OCI_EV_KEY;
home_event_.value = (long)HomekeyValue::kNoEvent;
#endif
+
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ openLatencyFile();
+#endif
}
OCIGamepadItem::~OCIGamepadItem() {
return;
this->DestroyDevice();
s_oci_gamepaditem_num_--;
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ closeLatencyFile();
+#endif
}
bool OCIGamepadItem::CreateDevice() {
}
}
#if TIZEN_VERSION_AT_LEAST(8, 0, 0)
+#ifdef TIZEN_ENABLE_GAMEPAD_LATENCY_TEST
+ struct timespec time_now;
+ clock_gettime(CLOCK_REALTIME, &time_now);
+ unsigned long long curtime = (unsigned long long)time_now.tv_sec * 1000000 +
+ (unsigned long long)(time_now.tv_nsec / 1000);
+ pad.timestamp = event.time;
+ if (latency_file != nullptr) {
+ LOG(ERROR) << "[LatencyTestBrowser][" << pad.timestamp
+ << "] chromium-browser got time: " << curtime;
+ fprintf(latency_file, "%s%llu%s%llu\n", "driver time:", pad.timestamp,
+ " browser current time:", curtime);
+ fflush(latency_file);
+ }
+#else
/*for home key long press, we should use
* pad.timestamp = GamepadDataFetcher::CurrentTimeInMicroseconds()
* + event.time - current_microseconds;
current_time.tv_usec;
pad.timestamp = GamepadDataFetcher::CurrentTimeInMicroseconds() + event.time -
current_microseconds;
+#endif
#else
/*
event.time is unsigned long type exported from accessory.