[joystick] update for flutter 3.3.0 release (#55)
Signed-off-by: Hidenori Matsubayashi <hidenori.matsubayashi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1984167a61
commit
028b43fde3
@@ -1,2 +1,5 @@
|
|||||||
|
## 1.0.1
|
||||||
|
* Update for flutter 3.3.0 release
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
* First version.
|
* First version.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Group Corporation. All rights reserved.
|
// Copyright 2022 Sony Group Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Group Corporation. All rights reserved.
|
// Copyright 2022 Sony Group Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
# stop cmake from taking make from CMAKE_SYSROOT
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
project(runner LANGUAGES CXX)
|
project(runner LANGUAGES CXX)
|
||||||
|
|
||||||
set(BINARY_NAME "joystick_example")
|
set(BINARY_NAME "joystick_example")
|
||||||
@@ -7,21 +9,12 @@ cmake_policy(SET CMP0063 NEW)
|
|||||||
|
|
||||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||||
|
|
||||||
# Root filesystem for cross-building.
|
# Basically we use this include when we got the following error:
|
||||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
# fatal error: 'bits/c++config.h' file not found
|
||||||
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
include_directories(SYSTEM ${FLUTTER_SYSTEM_INCLUDE_DIRECTORIES})
|
||||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
||||||
|
|
||||||
# Basically we use this include when we got the following error:
|
|
||||||
# fatal error: 'bits/c++config.h' file not found
|
|
||||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
|
||||||
include_directories(SYSTEM ${FLUTTER_SYSTEM_INCLUDE_DIRECTORIES})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Configure build options.
|
# Configure build options.
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -13,8 +13,6 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// todo: Supports other types besides int, string.
|
|
||||||
|
|
||||||
namespace commandline {
|
namespace commandline {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -39,30 +37,49 @@ class CommandOptions {
|
|||||||
CommandOptions() = default;
|
CommandOptions() = default;
|
||||||
~CommandOptions() = default;
|
~CommandOptions() = default;
|
||||||
|
|
||||||
void AddWithoutValue(const std::string& name, const std::string& short_name,
|
void AddWithoutValue(const std::string& name,
|
||||||
const std::string& description, bool required) {
|
const std::string& short_name,
|
||||||
|
const std::string& description,
|
||||||
|
bool required) {
|
||||||
Add<std::string, ReaderString>(name, short_name, description, "",
|
Add<std::string, ReaderString>(name, short_name, description, "",
|
||||||
ReaderString(), required, false);
|
ReaderString(), required, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddInt(const std::string& name, const std::string& short_name,
|
void AddInt(const std::string& name,
|
||||||
const std::string& description, const int& default_value,
|
const std::string& short_name,
|
||||||
|
const std::string& description,
|
||||||
|
const int& default_value,
|
||||||
bool required) {
|
bool required) {
|
||||||
Add<int, ReaderInt>(name, short_name, description, default_value,
|
Add<int, ReaderInt>(name, short_name, description, default_value,
|
||||||
ReaderInt(), required, true);
|
ReaderInt(), required, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddString(const std::string& name, const std::string& short_name,
|
void AddDouble(const std::string& name,
|
||||||
|
const std::string& short_name,
|
||||||
|
const std::string& description,
|
||||||
|
const double& default_value,
|
||||||
|
bool required) {
|
||||||
|
Add<double, ReaderDouble>(name, short_name, description, default_value,
|
||||||
|
ReaderDouble(), required, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddString(const std::string& name,
|
||||||
|
const std::string& short_name,
|
||||||
const std::string& description,
|
const std::string& description,
|
||||||
const std::string& default_value, bool required) {
|
const std::string& default_value,
|
||||||
|
bool required) {
|
||||||
Add<std::string, ReaderString>(name, short_name, description, default_value,
|
Add<std::string, ReaderString>(name, short_name, description, default_value,
|
||||||
ReaderString(), required, true);
|
ReaderString(), required, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename F>
|
template <typename T, typename F>
|
||||||
void Add(const std::string& name, const std::string& short_name,
|
void Add(const std::string& name,
|
||||||
const std::string& description, const T default_value,
|
const std::string& short_name,
|
||||||
F reader = F(), bool required = true, bool required_value = true) {
|
const std::string& description,
|
||||||
|
const T default_value,
|
||||||
|
F reader = F(),
|
||||||
|
bool required = true,
|
||||||
|
bool required_value = true) {
|
||||||
if (options_.find(name) != options_.end()) {
|
if (options_.find(name) != options_.end()) {
|
||||||
std::cerr << "Already registered option: " << name << std::endl;
|
std::cerr << "Already registered option: " << name << std::endl;
|
||||||
return;
|
return;
|
||||||
@@ -213,7 +230,7 @@ class CommandOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t index_adjust = 0;
|
size_t index_adjust = 0;
|
||||||
constexpr int kSpacerNum = 5;
|
constexpr int kSpacerNum = 10;
|
||||||
auto need_value = registration_order_options_[i]->IsRequiredValue();
|
auto need_value = registration_order_options_[i]->IsRequiredValue();
|
||||||
ostream << kOptionStyleNormal
|
ostream << kOptionStyleNormal
|
||||||
<< registration_order_options_[i]->GetName();
|
<< registration_order_options_[i]->GetName();
|
||||||
@@ -240,10 +257,17 @@ class CommandOptions {
|
|||||||
std::string operator()(const std::string& value) { return value; }
|
std::string operator()(const std::string& value) { return value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ReaderDouble {
|
||||||
|
double operator()(const std::string& value) { return std::stod(value); }
|
||||||
|
};
|
||||||
|
|
||||||
class Option {
|
class Option {
|
||||||
public:
|
public:
|
||||||
Option(const std::string& name, const std::string& short_name,
|
Option(const std::string& name,
|
||||||
const std::string& description, bool required, bool required_value)
|
const std::string& short_name,
|
||||||
|
const std::string& description,
|
||||||
|
bool required,
|
||||||
|
bool required_value)
|
||||||
: name_(name),
|
: name_(name),
|
||||||
short_name_(short_name),
|
short_name_(short_name),
|
||||||
description_(description),
|
description_(description),
|
||||||
@@ -288,9 +312,12 @@ class CommandOptions {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class OptionValue : public Option {
|
class OptionValue : public Option {
|
||||||
public:
|
public:
|
||||||
OptionValue(const std::string& name, const std::string& short_name,
|
OptionValue(const std::string& name,
|
||||||
const std::string& description, const T& default_value,
|
const std::string& short_name,
|
||||||
bool required, bool required_value)
|
const std::string& description,
|
||||||
|
const T& default_value,
|
||||||
|
bool required,
|
||||||
|
bool required_value)
|
||||||
: Option(name, short_name, description, required, required_value),
|
: Option(name, short_name, description, required, required_value),
|
||||||
default_value_(default_value),
|
default_value_(default_value),
|
||||||
value_(default_value){};
|
value_(default_value){};
|
||||||
@@ -316,10 +343,18 @@ class CommandOptions {
|
|||||||
template <typename T, typename F>
|
template <typename T, typename F>
|
||||||
class OptionValueReader : public OptionValue<T> {
|
class OptionValueReader : public OptionValue<T> {
|
||||||
public:
|
public:
|
||||||
OptionValueReader(const std::string& name, const std::string& short_name,
|
OptionValueReader(const std::string& name,
|
||||||
const std::string& description, const T default_value,
|
const std::string& short_name,
|
||||||
F reader, bool required, bool required_value)
|
const std::string& description,
|
||||||
: OptionValue<T>(name, short_name, description, default_value, required,
|
const T default_value,
|
||||||
|
F reader,
|
||||||
|
bool required,
|
||||||
|
bool required_value)
|
||||||
|
: OptionValue<T>(name,
|
||||||
|
short_name,
|
||||||
|
description,
|
||||||
|
default_value,
|
||||||
|
required,
|
||||||
required_value),
|
required_value),
|
||||||
reader_(reader) {}
|
reader_(reader) {}
|
||||||
~OptionValueReader() = default;
|
~OptionValueReader() = default;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -14,18 +14,24 @@
|
|||||||
class FlutterEmbedderOptions {
|
class FlutterEmbedderOptions {
|
||||||
public:
|
public:
|
||||||
FlutterEmbedderOptions() {
|
FlutterEmbedderOptions() {
|
||||||
options_.AddString("bundle", "b", "Path to Flutter app bundle", "./",
|
options_.AddString("bundle", "b", "Path to Flutter project bundle",
|
||||||
false);
|
"./bundle", true);
|
||||||
options_.AddWithoutValue("no-cursor", "n", "No mouse cursor/pointer",
|
options_.AddWithoutValue("no-cursor", "n", "No mouse cursor/pointer",
|
||||||
false);
|
false);
|
||||||
|
options_.AddInt("rotation", "r",
|
||||||
|
"Window rotation(degree) [0(default)|90|180|270]", 0,
|
||||||
|
false);
|
||||||
|
options_.AddDouble("force-scale-factor", "s",
|
||||||
|
"Force a scale factor instead using default value", 1.0,
|
||||||
|
false);
|
||||||
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
||||||
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
||||||
// no more options.
|
// no more options.
|
||||||
#elif defined(FLUTTER_TARGET_BACKEND_X11)
|
#elif defined(FLUTTER_TARGET_BACKEND_X11)
|
||||||
options_.AddWithoutValue("fullscreen", "f", "Always full-screen display",
|
options_.AddWithoutValue("fullscreen", "f", "Always full-screen display",
|
||||||
false);
|
false);
|
||||||
options_.AddInt("width", "w", "Flutter app window width", 1280, false);
|
options_.AddInt("width", "w", "Window width", 1280, false);
|
||||||
options_.AddInt("height", "h", "Flutter app window height", 720, false);
|
options_.AddInt("height", "h", "Window height", 720, false);
|
||||||
#else // FLUTTER_TARGET_BACKEND_WAYLAND
|
#else // FLUTTER_TARGET_BACKEND_WAYLAND
|
||||||
options_.AddWithoutValue("onscreen-keyboard", "k",
|
options_.AddWithoutValue("onscreen-keyboard", "k",
|
||||||
"Enable on-screen keyboard", false);
|
"Enable on-screen keyboard", false);
|
||||||
@@ -33,8 +39,8 @@ class FlutterEmbedderOptions {
|
|||||||
"Enable window decorations", false);
|
"Enable window decorations", false);
|
||||||
options_.AddWithoutValue("fullscreen", "f", "Always full-screen display",
|
options_.AddWithoutValue("fullscreen", "f", "Always full-screen display",
|
||||||
false);
|
false);
|
||||||
options_.AddInt("width", "w", "Flutter app window width", 1280, false);
|
options_.AddInt("width", "w", "Window width", 1280, false);
|
||||||
options_.AddInt("height", "h", "Flutter app window height", 720, false);
|
options_.AddInt("height", "h", "Window height", 720, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
~FlutterEmbedderOptions() = default;
|
~FlutterEmbedderOptions() = default;
|
||||||
@@ -48,6 +54,34 @@ class FlutterEmbedderOptions {
|
|||||||
|
|
||||||
bundle_path_ = options_.GetValue<std::string>("bundle");
|
bundle_path_ = options_.GetValue<std::string>("bundle");
|
||||||
use_mouse_cursor_ = !options_.Exist("no-cursor");
|
use_mouse_cursor_ = !options_.Exist("no-cursor");
|
||||||
|
if (options_.Exist("rotation")) {
|
||||||
|
switch (options_.GetValue<int>("rotation")) {
|
||||||
|
case 90:
|
||||||
|
window_view_rotation_ =
|
||||||
|
flutter::FlutterViewController::ViewRotation::kRotation_90;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
window_view_rotation_ =
|
||||||
|
flutter::FlutterViewController::ViewRotation::kRotation_180;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
window_view_rotation_ =
|
||||||
|
flutter::FlutterViewController::ViewRotation::kRotation_270;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
window_view_rotation_ =
|
||||||
|
flutter::FlutterViewController::ViewRotation::kRotation_0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options_.Exist("force-scale-factor")) {
|
||||||
|
is_force_scale_factor_ = true;
|
||||||
|
scale_factor_ = options_.GetValue<double>("force-scale-factor");
|
||||||
|
} else {
|
||||||
|
is_force_scale_factor_ = false;
|
||||||
|
scale_factor_ = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
#if defined(FLUTTER_TARGET_BACKEND_GBM) || \
|
||||||
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
defined(FLUTTER_TARGET_BACKEND_EGLSTREAM)
|
||||||
@@ -86,6 +120,11 @@ class FlutterEmbedderOptions {
|
|||||||
}
|
}
|
||||||
int WindowWidth() const { return window_width_; }
|
int WindowWidth() const { return window_width_; }
|
||||||
int WindowHeight() const { return window_height_; }
|
int WindowHeight() const { return window_height_; }
|
||||||
|
flutter::FlutterViewController::ViewRotation WindowRotation() const {
|
||||||
|
return window_view_rotation_;
|
||||||
|
}
|
||||||
|
bool IsForceScaleFactor() const { return is_force_scale_factor_; }
|
||||||
|
double ScaleFactor() const { return scale_factor_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
commandline::CommandOptions options_;
|
commandline::CommandOptions options_;
|
||||||
@@ -98,6 +137,10 @@ class FlutterEmbedderOptions {
|
|||||||
flutter::FlutterViewController::ViewMode::kNormal;
|
flutter::FlutterViewController::ViewMode::kNormal;
|
||||||
int window_width_ = 1280;
|
int window_width_ = 1280;
|
||||||
int window_height_ = 720;
|
int window_height_ = 720;
|
||||||
|
flutter::FlutterViewController::ViewRotation window_view_rotation_ =
|
||||||
|
flutter::FlutterViewController::ViewRotation::kRotation_0;
|
||||||
|
bool is_force_scale_factor_;
|
||||||
|
double scale_factor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTTER_EMBEDDER_OPTIONS_
|
#endif // FLUTTER_EMBEDDER_OPTIONS_
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
@@ -29,9 +29,12 @@ int main(int argc, char** argv) {
|
|||||||
view_properties.width = options.WindowWidth();
|
view_properties.width = options.WindowWidth();
|
||||||
view_properties.height = options.WindowHeight();
|
view_properties.height = options.WindowHeight();
|
||||||
view_properties.view_mode = options.WindowViewMode();
|
view_properties.view_mode = options.WindowViewMode();
|
||||||
|
view_properties.view_rotation = options.WindowRotation();
|
||||||
view_properties.use_mouse_cursor = options.IsUseMouseCursor();
|
view_properties.use_mouse_cursor = options.IsUseMouseCursor();
|
||||||
view_properties.use_onscreen_keyboard = options.IsUseOnscreenKeyboard();
|
view_properties.use_onscreen_keyboard = options.IsUseOnscreenKeyboard();
|
||||||
view_properties.use_window_decoration = options.IsUseWindowDecoraation();
|
view_properties.use_window_decoration = options.IsUseWindowDecoraation();
|
||||||
|
view_properties.force_scale_factor = options.IsForceScaleFactor();
|
||||||
|
view_properties.scale_factor = options.ScaleFactor();
|
||||||
|
|
||||||
// The Flutter instance hosted by this window.
|
// The Flutter instance hosted by this window.
|
||||||
FlutterWindow window(view_properties, project);
|
FlutterWindow window(view_properties, project);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ description: Demonstrates how to use the joystick plugin for eLinux.
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
flutter: ">=2.10.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
cupertino_icons: ^1.0.2
|
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
joystick:
|
joystick:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Sony Group Corporation. All rights reserved.
|
// Copyright 2022 Sony Group Corporation. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
name: joystick
|
name: joystick
|
||||||
description: A Flutter plugin for getting information about and controlling the
|
description: A Flutter plugin for getting information about and controlling the
|
||||||
joystick on eLinux.
|
joystick on eLinux.
|
||||||
version: 1.0.0
|
version: 1.0.1
|
||||||
homepage: https://github.com/sony/flutter-elinux-plugins
|
homepage: https://github.com/sony/flutter-elinux-plugins
|
||||||
repository: https://github.com/sony/flutter-elinux-plugins/tree/main/packages/joystick
|
repository: https://github.com/sony/flutter-elinux-plugins/tree/main/packages/joystick
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
flutter: ">=1.20.0"
|
flutter: ">=2.10.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
ffi: ^1.1.2
|
ffi: ^2.0.0
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user