return _emul_info.sdl_bpp;
}
-/* mouse device */
-void set_emul_input_mouse_enable(bool on)
-{
- _emul_info.input_mouse_enable = on;
-
- if (_emul_info.input_mouse_enable == true) {
- LOG_INFO("set_emul_input_mouse_enable\n");
- }
-}
-
-bool is_emul_input_mouse_enable(void)
-{
- return _emul_info.input_mouse_enable;
-}
-
-/* touchscreen device */
-void set_emul_input_touch_enable(bool on)
-{
- _emul_info.input_touch_enable = on;
-
- if (_emul_info.input_touch_enable == true) {
- LOG_INFO("set_emul_input_touch_enable\n");
- }
-}
-
-bool is_emul_input_touch_enable(void)
-{
- return _emul_info.input_touch_enable;
-}
-
bool is_netclient_tap_attached(void)
{
NetClientState *ncs[MAX_QUEUE_NUM];
return false;
}
-/* file sharing path */
-const char* get_host_directory_sharing_path(void)
-{
- FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
- const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL);
-
- return sharing_path;
-}
-
//
// cleaned-up
//
return vio_evdi->profile;
}
-/* GPU virtualization */
+// host directory sharing path
+const char* get_host_directory_sharing_path(void)
+{
+ FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
+ const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL);
+
+ return sharing_path;
+}
+
+// GPU virtualization
static bool gpu_accel_enabled;
bool is_gpu_accel_enabled(void)
return ram_size;
}
+// look-up PCI devices
+bool is_pci_device_enabled(int device_id)
+{
+ bool is_enabled = false;
+ PciInfoList *info_list, *info;
+ Error *err = NULL;
+
+ info_list = qmp_query_pci(&err);
+ if (err) {
+ LOG_WARNING("PCI devices not supported\n");
+ error_free(err);
+ return false;
+ }
+
+ for (info = info_list; info; info = info->next) {
+ PciDeviceInfoList *dev;
+ for (dev = info->value->devices; dev; dev = dev->next) {
+ if (dev->value->id.device == device_id) {
+ is_enabled = true;
+ break;
+ }
+ }
+ }
+
+ qapi_free_PciInfoList(info_list);
+
+ return is_enabled;
+}
+
+// mouse input
+bool is_mouse_enabled(void)
+{
+ /* TODO: If the maru mouse device is added,
+ * the device id should to be changed for it.
+ */
+ return !is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN);
+}
+
+// touchscreen input
+bool is_touchscreen_enabled(void)
+{
+ return is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN);
+}
+
// vm_data_path
static const char *vm_data_path = NULL;
#include "display/maru_finger.h"
#include "config-host.h"
+#include "hw/maru_device_ids.h"
#define SUPPORT_LEGACY_ARGS
#define MAX_ADDR_LEN 256
typedef struct EmulatorConfigInfo {
int sdl_bpp;
- bool input_mouse_enable;
- bool input_touch_enable;
int vm_base_port;
int device_serial_number;
int ecs_port;
/* setter */
void set_emul_win_scale(double scale);
void set_emul_sdl_bpp(int bpp);
-void set_emul_input_mouse_enable(bool on);
-void set_emul_input_touch_enable(bool on);
void set_emul_vm_base_port(int port);
void set_emul_ecs_port(int port);
void set_emul_guest_ip(char *ip);
/* getter */
double get_emul_win_scale(void);
int get_emul_sdl_bpp(void);
-bool is_emul_input_mouse_enable(void);
-bool is_emul_input_touch_enable(void);
int get_emul_vm_base_port(void);
int get_device_serial_number(void);
int get_emul_ecs_port(void);
const char *get_http_proxy_addr(void);
const char *get_vm_name(void);
const char *get_profile_name(void);
-bool is_gpu_accel_enabled(void);
const char* get_host_directory_sharing_path(void);
const char *get_vm_data_path(void);
+
+bool is_gpu_accel_enabled(void);
+bool is_pci_device_enabled(int device_id);
+bool is_mouse_enabled(void);
+bool is_touchscreen_enabled(void);
+
uint64_t get_ram_size(void);
+
void set_initial_display_resolution(int width, int height);
int get_display_resolution_width(void);
int get_display_resolution_height(void);
DECLARE_DEBUG_CHANNEL(main);
-#define INPUT_TOUCH_PARAMETER "virtio-touchscreen-pci"
#define ARGS_LIMIT 128
char *maru_kernel_cmdline;
is_printed = true;
}
-static void set_qemu_input_mode(void)
-{
- int i;
- for (i = 0; i < _qemu_argc; ++i) {
- if (strstr(_qemu_argv[i], INPUT_TOUCH_PARAMETER) != NULL) {
- /* touchscreen */
- set_emul_input_touch_enable(true);
- }
- }
-
- if (is_emul_input_touch_enable() != true) {
- set_emul_input_mouse_enable(true);
- }
-}
-
static void print_options_info(void)
{
int i;
void prepare_maru_after_device_init(void)
{
make_vm_lock_os();
- set_qemu_input_mode();
init_device_hotplug();
start_ecs();
init_sdb(get_emul_vm_base_port() + SDB_UDP_SENSOR_INDEX);
strstr(qemu_argv[i], IMAGE_PATH_SUFFIX) != NULL) {
set_image_and_log_path(qemu_argv[i]);
} else if (strstr(qemu_argv[i], INPUT_TOUCH_PARAMETER) != NULL) {
- /* touchscreen */
- set_emul_input_touch_enable(true);
-
char *option = strstr(qemu_argv[i] + strlen(INPUT_TOUCH_PARAMETER), TOUCHSCREEN_OPTION_NAME);
if (option != NULL) {
option += strlen(TOUCHSCREEN_OPTION_NAME) + 1;
}
}
}
-
- if (is_emul_input_touch_enable() != true) {
- set_emul_input_mouse_enable(true);
- }
}
// deprecated
// TODO: check sensor device whether it exists or not
set_eventcast_sensor_status(EVENTCAST__STATE__ENABLED);
- if (is_emul_input_touch_enable()) {
+ if (is_touchscreen_enabled()) {
touch_status = EVENTCAST__STATE__ENABLED;
} else {
touch_status = EVENTCAST__STATE__DISABLED;
/* input */
char buf_input[12] = { 0, };
- if (is_emul_input_mouse_enable() == true) {
+ if (is_mouse_enabled() == true) {
strcpy(buf_input, OPT_INPUT_MOUSE);
} else {
strcpy(buf_input, OPT_INPUT_TOUCH);
this->gImg = new QImage();
this->gPxmImg = new QPixmap();
- isMouse = is_emul_input_mouse_enable();
- if (isMouse) {
+ isTouch = is_touchscreen_enabled();
+ if (!isTouch) {
prevX = 0;
prevY = 0;
lastMouseTime.tv_sec = 0;
if (event->button() == Qt::LeftButton) {
isDragging = true;
- if (isMouse) {
- do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0);
- } else {
+ if (isTouch) {
tsHelper->mousePressed(event, getGuestPos(event->pos()));
+ } else {
+ do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0);
}
}
}
isDragging = false;
}
- if (isMouse) {
- do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
- } else {
+ if (isTouch) {
tsHelper->mouseReleased(event, getGuestPos(event->pos()));
+ } else {
+ do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
}
}
}
void DisplayBase::handleMouseMove(QMouseEvent *event)
{
- if (isMouse) {
- int event_type = MOUSE_MOVE;
- int clientX = event->x();
- int clientY = event->y();
-
- if (clientX < 0 || clientX > widget->width() ||
- clientY < 0 || clientY > widget->height()) {
- if (isDragging == true) {
- isDragging = false;
- qDebug("auto released...");
- do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
- return;
- } else {
- /* do nothing */
- }
- }
- sendMouseEvent(event_type, clientX, clientY);
- } else { /* touch device */
+ if (isTouch) { /* touch device */
if (isDragging == true) {
int hostPosX = event->x();
int hostPosY = event->y();
tsHelper->mouseMoved(event, getGuestPos(event->pos()));
}
}
+ } else {
+ int event_type = MOUSE_MOVE;
+ int clientX = event->x();
+ int clientY = event->y();
+
+ if (clientX < 0 || clientX > widget->width() ||
+ clientY < 0 || clientY > widget->height()) {
+ if (isDragging == true) {
+ isDragging = false;
+ qDebug("auto released...");
+ do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0);
+ return;
+ } else {
+ /* do nothing */
+ }
+ }
+ sendMouseEvent(event_type, clientX, clientY);
}
}
void DisplayBase::handleMouseEnter(QEvent *event)
{
- if (isMouse) {
+ if (!isTouch) {
if (mouseStatus == MOUSE_LEAVE) {
mouseStatus = MOUSE_ENTER;
}
void DisplayBase::handleMouseLeave(QEvent *event)
{
- if (isMouse) {
+ if (!isTouch) {
mouseStatus = MOUSE_LEAVE;
}
}
void sendMouseEvent(int eventType, int clientX, int clientY);
QSize resolution;
- bool isMouse;
+ bool isTouch;
int prevX;
int prevY;
QGLWidget(context, parent), DisplayBase(displayForm, resolution, scaleFactor, this)
{
setAutoBufferSwap(false);
- isMouse = is_emul_input_mouse_enable();
+ isTouch = is_touchscreen_enabled();
/* mouse mode */
- if (isMouse) {
+ if (!isTouch) {
setCursor(Qt::BlankCursor);
setMouseTracking(true);
}
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
- bool isMouse;
+ bool isTouch;
};
#endif // DISPLAYGLWIDGET_H
initImage.fill(Qt::black);
setPixmap(initImage);
- isMouse = is_emul_input_mouse_enable();
+ isTouch = is_touchscreen_enabled();
/* mouse mode */
- if (isMouse) {
+ if (!isTouch) {
setCursor(Qt::BlankCursor);
setMouseTracking(true);
}
void leaveEvent(QEvent *event);
private:
MultiTouchTracker *mtTracker;
- bool isMouse;
+ bool isTouch;
};
#endif // DISPLAYSWWIDGET_H
break;
case MOUSE_WHEELUP:
case MOUSE_WHEELDOWN:
- if (is_emul_input_touch_enable() == true) {
+ if (is_touchscreen_enabled() == true) {
x -= guest_x;
y -= guest_y;
guest_x += x;