Пример #1
0
 public bool setMousehWheelCallback(MouseHWheel.MouseHWheelCallback cb)
 {
     if (cb == null)
     {
         return(false);
     }
     this.keyEnableSynaptic = RegistryManager.Instance.DefaultGuest.HScroll;
     if (this.keyEnableSynaptic != 1)
     {
         Logger.Info("Horizontal Mouse Wheel support is Disabled");
         return(false);
     }
     MouseHWheel.s_MouseHWheelCallback = new MouseHWheel.MouseHWheelCallback(cb.Invoke);
     try
     {
         if (!HDPlusModule.SetMouseHWheelCallback(MouseHWheel.s_MouseHWheelCallback))
         {
             Logger.Info("Horizontal scrolling disabled, no synaptic device found");
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Error("Continue with MouseHWheel error:");
         Logger.Error(ex.ToString());
     }
     return(false);
 }
Пример #2
0
 public void SendMouseState(uint x, uint y, uint mask)
 {
     if (!HDPlusModule.MonitorSendMouseState(x, y, mask))
     {
         throw new IOException("Cannot send mouse state");
     }
 }
Пример #3
0
 public void SendControl(Monitor.BstInputControlType type)
 {
     if (!HDPlusModule.MonitorSendControl(type))
     {
         throw new IOException("Cannot send control state state");
     }
 }
Пример #4
0
 public void SendScanCode(byte code)
 {
     if (!HDPlusModule.MonitorSendScanCode(code))
     {
         throw new IOException("Cannot send keyboard scan code");
     }
 }
Пример #5
0
 public void SendShutdown(IntPtr msg)
 {
     if (HDPlusModule.SensorSendMsg(msg))
     {
         return;
     }
     CommonError.ThrowLastWin32Error("Cannot send message to guest");
 }
Пример #6
0
 public Monitor Attach(uint id, Monitor.ExitHandler exitHandler)
 {
     if (!HDPlusModule.ManagerAttach(this.handle, id))
     {
         CommonError.ThrowLastWin32Error("Cannot attach to monitor " + id.ToString());
     }
     return(new Monitor(this.handle, id, exitHandler));
 }
Пример #7
0
 public void SendLocation(GPSManager.GpsLocation location)
 {
     if (HDPlusModule.MonitorSendLocation(location))
     {
         return;
     }
     CommonError.ThrowLastWin32Error("Cannot send GPS location update");
 }
Пример #8
0
        public Video.Mode GetMode()
        {
            uint width  = 0;
            uint height = 0;
            uint depth  = 0;

            HDPlusModule.VideoGetMode(this.addr, ref width, ref height, ref depth);
            return(new Video.Mode((int)width, (int)height, (int)depth));
        }
Пример #9
0
        public void CheckMagic()
        {
            uint magic = 0;

            if (!HDPlusModule.VideoCheckMagic(this.addr, ref magic))
            {
                throw new SystemException("Bad magic 0x" + magic.ToString("x"));
            }
        }
Пример #10
0
 internal void SendAndroidString(string formattedString)
 {
     try
     {
         byte[] bytes = Encoding.UTF8.GetBytes(formattedString);
         HDPlusModule.MonitorSendImeMsg(bytes, bytes.Length);
     }
     catch
     {
     }
 }
Пример #11
0
 public void SendTouchState(Monitor.TouchPoint[] points)
 {
     if (points == null)
     {
         points = new Monitor.TouchPoint[0];
     }
     if (!HDPlusModule.MonitorSendTouchState(points, points.Length))
     {
         throw new IOException("Cannot send touch state");
     }
 }
        public void InitCamera(string[] args)
        {
            if (args.Length != 1)
            {
                throw new SystemException("InitCamera: Should have vmName as one arg");
            }
            string vmName = args[0];

            this.keyEnableCam = RegistryManager.Instance.DefaultGuest.Camera;
            if (this.keyEnableCam != 1)
            {
                Logger.Info("Camera is Disabled");
            }
            else
            {
                uint vmId = MonitorLocator.Lookup(vmName);
                lock (CameraManager.s_IoHandleLock)
                {
                    if (CameraManager.s_IoHandle != IntPtr.Zero)
                    {
                        throw new SystemException("I/O handle is already open");
                    }
                    Logger.Info("Attaching to monitor ID {0}", (object)vmId);
                    CameraManager.s_IoHandle = HDPlusModule.CameraIoAttach(vmId);
                    if (CameraManager.s_IoHandle == IntPtr.Zero)
                    {
                        throw new SystemException("Cannot attach for I/O", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
                    }
                }
                this.s_fpStartStopCamera = new CameraManager.fpStartStopCamera(this.BstStartStopCamera);
                HDPlusModule.SetStartStopCamerCB(this.s_fpStartStopCamera);
                Logger.Info("Waiting for Camera messages...");
                new Thread((ThreadStart)(() =>
                {
                    while (!this.bShutDown)
                    {
                        int num = HDPlusModule.CameraIoProcessMessages(CameraManager.s_IoHandle);
                        if (num != 0)
                        {
                            Logger.Error("Camera: Cannot process VM messages. Error: " + num.ToString());
                            this.Shutdown();
                        }
                    }
                }))
                {
                    IsBackground = true
                }.Start();
            }
        }
        public void getFrame(IntPtr ip, int width, int height, int stride)
        {
            if (ip == IntPtr.Zero || this.camera == null || (CameraManager.s_IoHandle == IntPtr.Zero || this.cameraStoped))
            {
                return;
            }
            IntPtr stream = ip;

            if (this.m_color == SupportedColorFormat.RGB24)
            {
                if (this.m_buffer == IntPtr.Zero)
                {
                    this.m_buffer = Marshal.AllocCoTaskMem(width * height * 2);
                }
                HDPlusModule.convertRGB24toYUV422(ip, width, height, this.m_buffer);
                stream = this.m_buffer;
            }
            HDPlusModule.CameraSendCaptureStream(CameraManager.s_IoHandle, stream, width * height * 2, width, height, stride);
        }
Пример #14
0
        public Video VideoAttach(bool verbose)
        {
            IntPtr zero = IntPtr.Zero;
            IntPtr addr = HDPlusModule.MonitorVideoAttach(this.mId, verbose);

            if (addr == IntPtr.Zero)
            {
                CommonError.ThrowLastWin32Error(string.Format("FATAL ERROR: Cannot attach to monitor video: {0}", (object)Marshal.GetLastWin32Error()));
            }
            Video video = new Video(addr);

            try
            {
                video.CheckMagic();
            }
            catch (Exception ex)
            {
                HDPlusModule.MonitorVideoDetach(addr);
                throw;
            }
            Logger.Info("Video Attached");
            return(video);
        }
Пример #15
0
 public void StartReceiver(VmMonitor.ReceiverCallback callback)
 {
     this.mReceiverCallback = callback;
     this.mReceiverWakeup   = (EventWaitHandle) new ManualResetEvent(false);
     this.mReceiverThread   = new Thread((ThreadStart)(() =>
     {
         try
         {
             if (HDPlusModule.SensorRecvMsg(this.mReceiverCallback))
             {
                 return;
             }
             CommonError.ThrowLastWin32Error("Cannot receive monitor message");
         }
         catch (Exception ex)
         {
             Logger.Error("Exception, receiver thread died. Err : " + ex.ToString());
         }
     }))
     {
         IsBackground = true
     };
     this.mReceiverThread.Start();
 }
Пример #16
0
 private static SafeFileHandle ManagerOpenSafe()
 {
     return(new SafeFileHandle(HDPlusModule.ManagerOpen(), true));
 }
Пример #17
0
 public bool GetAndClearDirty()
 {
     return(HDPlusModule.VideoGetAndClearDirty(this.addr));
 }
Пример #18
0
 static Monitor()
 {
     HDPlusModule.MonitorSetLogger(Monitor.sLoggerCallback);
     Monitor.camLoggerCallback = (Monitor.LoggerCallback)(msg => Logger.Info("Camera: " + msg));
     HDPlusModule.CameraSetLogger(Monitor.camLoggerCallback);
 }