public static void uploadKeySymMap(this iGraphicsEngine engine) { lock ( syncRoot ) { if (uploaded) { return; } uploaded = true; // Deserialize into an array Assembly ass = Assembly.GetExecutingAssembly(); using (var x11 = ComLightCast.cast <iLinuxEngine>(engine)) using (var stm = ass.GetManifestResourceStream(resourceName)) using (var unzip = new GZipStream(stm, CompressionMode.Decompress)) using (var reader = new BinaryReader(unzip)) { int count = reader.ReadInt32(); sKeySymMap[] map = new sKeySymMap[count]; for (int i = 0; i < count; i++) { map[i].read(reader); } // Upload the data to native memory. // X11 window class uses the data to resolve key symbols // https://www.oreilly.com/library/view/xlib-reference-manual/9780937175262/16_appendix-h.html // into characters, to be passed to iKeyboardHandler.keyEvent method. x11.uploadKeySymMap(map, count); } } }
/// <summary>Export all buffers from V4L2, import them into GLES in Diligent Engine</summary> public void exportTextures(IRenderDevice renderDevice, VideoDevice device, ref sPixelFormatMP pixelFormat, ref ColorFormat color) { iGlesRenderDevice gles = ComLightCast.cast <iGlesRenderDevice>(renderDevice); textures = new Nv12Texture[buffers.Length]; for (int i = 0; i < buffers.Length; i++) { textures[i] = buffers[i].exportNv12(gles, device, ref pixelFormat, ref color); } }
public static void testKeyboard() { iRawInputSink sink; // sink = new RawEventsLogger(); sink = new LayoutTest(); createEngine(out var engine); engine.setConsoleLoggerSink(consoleLoggingLevel); using (var disp = engine.dispatcher()) { // string device = RawDevice.list().FirstOrDefault( RawInput.isQwertyKeyboard ).eventInterface; string device = @"/dev/input/event4"; using (iLinuxDispatcher linuxDispatcher = ComLightCast.cast <iLinuxDispatcher>(disp.nativeDispatcher)) linuxDispatcher.openInputDevice(device, sink); disp.run(); } }
public static void test() { createEngine(out var engine); engine.setConsoleLoggerSink(consoleLoggingLevel); var devices = RawDevice.list().ToArray(); using (var disp = engine.dispatcher()) { Console.WriteLine("Created a dispatcher"); using (var linuxDisp = ComLightCast.cast <iLinuxDispatcher>(disp.nativeDispatcher)) { // Console.WriteLine( "Casted to iLinuxDispatcher" ); string path = devices[0].eventInterface; linuxDisp.openInputDevice(path, new EventPrinter()); disp.run(); } } }
/// <summary>Open a raw mouse device and wrap it into an adapter that will call the provided object when input happens.</summary> public static iInputEventTimeSource openRawMouse(this Dispatcher dispatcher, iMouseHandler handler, CRect clipRect, RawDevice device = null) { // Find the mouse if (null == device) { device = RawDevice.list().FirstOrDefault(isMouse); if (null == device) { throw new ApplicationException("No mice are detected"); } } // Create the adapter to translate raw events into mouse events RawMouse mouse = clipRect.isEmpty ? new RawMouse(device, handler) : new RawMouseClipped(device, clipRect, handler); // Open the device using (iLinuxDispatcher linuxDispatcher = ComLightCast.cast <iLinuxDispatcher>(dispatcher.nativeDispatcher)) linuxDispatcher.openInputDevice(device.eventInterface, mouse); return(mouse); }
/// <summary>Open a raw input device, interpret the input as a US English keyboard</summary> public static iInputEventTimeSource openRawKeyboard(this Dispatcher dispatcher, iKeyboardHandler handler, RawDevice device = null) { // Find the keyboard if (null == device) { device = RawDevice.list().FirstOrDefault(isQwertyKeyboard); if (null == device) { throw new ApplicationException("No keyboards found"); } } // Create the layout. That object also owns the state, i.e. shift/numlock/etc. iKeyboardLayout layout = new UsEnglishLayout(); // Create the adapter to translate raw events into keyboard events var keyboard = new RawKeyboard(device, layout, handler);; // Open the device using (iLinuxDispatcher linuxDispatcher = ComLightCast.cast <iLinuxDispatcher>(dispatcher.nativeDispatcher)) linuxDispatcher.openInputDevice(device.eventInterface, keyboard); return(keyboard); }