Example #1
0
        public static bool GetConfig(int pad, out SMXConfig config)
        {
            if (!DLLAvailable())
            {
                config = SMXConfig.Create();
                return(false);
            }

            return(SMX_GetConfig(pad, out config));
        }
Example #2
0
 public static bool GetConfig(int pad, out SMXConfig config)
 {
     if (!DLLAvailable())
     {
         config = new SMXConfig();
         config.enabledSensors = new Byte[5];
         config.stepColor      = new Byte[3 * 9];
         return(false);
     }
     return(SMX_GetConfig(pad, out config));
 }
Example #3
0
        public static void SetConfig(int pad, SMXConfig config)
        {
            if (!DLLAvailable())
            {
                return;
            }

            // Always bump the configVersion to the version we support on write.
            config.configVersion = 2;

            SMX_SetConfig(pad, ref config);
        }
Example #4
0
        // Create an empty SMXConfig.
        static public SMXConfig Create()
        {
            SMXConfig result = new SMXConfig();

            result.enabledSensors     = new Byte[5];
            result.stepColor          = new Byte[3 * 9];
            result.panelSettings      = new PackedSensorSettings[9];
            result.platformStripColor = new Byte[3];
            for (int panel = 0; panel < 9; ++panel)
            {
                result.panelSettings[panel].fsrLowThreshold  = new Byte[4];
                result.panelSettings[panel].fsrHighThreshold = new Byte[4];
            }
            return(result);
        }
Example #5
0
        public static void Start(UpdateCallback callback)
        {
            if (!DLLAvailable())
            {
                return;
            }

            // Sanity check SMXConfig, which should be 250 bytes.  If this is incorrect,
            // check the padding array.
            {
                SMXConfig config = new SMXConfig();
                int       bytes  = Marshal.SizeOf(config);
                if (bytes != 250)
                {
                    throw new Exception("SMXConfig is " + bytes + " bytes, but should be 250 bytes");
                }
            }

            // Make a wrapper to convert from the native enum to SMXUpdateCallbackReason.
            InternalUpdateCallback NewCallback = delegate(int PadNumber, int reason, IntPtr user) {
                SMXUpdateCallbackReason ReasonEnum = (SMXUpdateCallbackReason)Enum.ToObject(typeof(SMXUpdateCallbackReason), reason);
                callback(PadNumber, ReasonEnum);
            };

            if (callback == null)
            {
                NewCallback = null;
            }

            SMX_Start(NewCallback, IntPtr.Zero);

            // Keep a reference to the delegate, so it isn't garbage collected.  Do this last.  Once
            // we do this the old callback may be collected, so we want to be sure that native code
            // has already updated the callback.
            CurrentUpdateCallback = NewCallback;

            Console.WriteLine("Struct sizes (C#): " +
                              Marshal.SizeOf(typeof(SMXConfig)) + " " +
                              Marshal.SizeOf(typeof(SMXInfo)) + " " +
                              Marshal.SizeOf(typeof(SMXSensorTestModeData)));
        }
Example #6
0
 private static extern void SMX_SetConfig(int pad, ref SMXConfig config);
Example #7
0
 private static extern bool SMX_GetConfig(int pad, out SMXConfig config);