private void buttonPressed(int offset, int value) { string state; // check button state based on value // this is the inverse of OS X, where != 0 is up if (value == 0) { state = "Up"; } else { state = "Down"; } var offsetValue = int.Parse(offset.ToString().Replace("Buttons", "")); // leave just a number commands.joystickButtonChanged(offsetValue, state); }