finished up the fitpc pc side joystick reading code

This meant writing a nice OO api for reading joysticks.
It also involved redoing the wire format to fix byte-order problems and
get rid of the need for packing structs.
diff --git a/aos/atom_code/input/FRCComm.h b/aos/atom_code/input/FRCComm.h
deleted file mode 100644
index 98619de..0000000
--- a/aos/atom_code/input/FRCComm.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*************************************************************
- * 					NOTICE
- * 
- * 	These are the only externally exposed functions to the
- *   NetworkCommunication library
- * 
- * This is an implementation of FRC Spec for Comm Protocol
- * Revision 4.5, June 30, 2008
- *
- * Copyright (c) National Instruments 2008.  All Rights Reserved.
- * 
- *************************************************************/
-
-#ifndef __FRC_COMM_H__
-#define __FRC_COMM_H__
-
-#include <stdint.h>
-
-typedef uint64_t UINT64;
-typedef uint32_t UINT32;
-typedef uint16_t UINT16;
-typedef uint8_t  UINT8;
-typedef int8_t  INT8;
-
-struct FRCCommonControlData{
-	UINT16 packetIndex;
-	union {
-		UINT8 control;
-    // The order of the bits has to be flipped on little-endian machines (aka
-    // everything other than the cRIO that we build for) in order for it to
-    // work. Upstream WPILib does this based off of a different macro.
-#ifndef __VXWORKS__
-		struct {
-			UINT8 checkVersions :1;
-			UINT8 test :1;
-			UINT8 resync : 1;
-			UINT8 fmsAttached:1;
-			UINT8 autonomous : 1;
-			UINT8 enabled : 1;
-			UINT8 notEStop : 1;
-			UINT8 reset : 1;
-		};
-#else
-		struct {
-			UINT8 reset : 1;
-			UINT8 notEStop : 1;
-			UINT8 enabled : 1;
-			UINT8 autonomous : 1;
-			UINT8 fmsAttached:1;
-			UINT8 resync : 1;
-			UINT8 test :1;
-			UINT8 checkVersions :1;
-		};
-#endif
-	};
-	UINT8 dsDigitalIn;
-	UINT16 teamID;
-
-	char dsID_Alliance;
-	char dsID_Position;
-
-	union {
-		INT8 stick0Axes[6];
-		struct {
-			INT8 stick0Axis1;
-			INT8 stick0Axis2;
-			INT8 stick0Axis3;
-			INT8 stick0Axis4;
-			INT8 stick0Axis5;
-			INT8 stick0Axis6;
-		};
-	};
-	UINT16 stick0Buttons;		// Left-most 4 bits are unused
-
-	union {
-		INT8 stick1Axes[6];
-		struct {
-			INT8 stick1Axis1;
-			INT8 stick1Axis2;
-			INT8 stick1Axis3;
-			INT8 stick1Axis4;
-			INT8 stick1Axis5;
-			INT8 stick1Axis6;
-		};
-	};
-	UINT16 stick1Buttons;		// Left-most 4 bits are unused
-
-	union {
-		INT8 stick2Axes[6];
-		struct {
-			INT8 stick2Axis1;
-			INT8 stick2Axis2;
-			INT8 stick2Axis3;
-			INT8 stick2Axis4;
-			INT8 stick2Axis5;
-			INT8 stick2Axis6;
-		};
-	};
-	UINT16 stick2Buttons;		// Left-most 4 bits are unused
-
-	union {
-		INT8 stick3Axes[6];
-		struct {
-			INT8 stick3Axis1;
-			INT8 stick3Axis2;
-			INT8 stick3Axis3;
-			INT8 stick3Axis4;
-			INT8 stick3Axis5;
-			INT8 stick3Axis6;
-		};
-	};
-	UINT16 stick3Buttons;		// Left-most 4 bits are unused
-
-	//Analog inputs are 10 bit right-justified
-	UINT16 analog1;
-	UINT16 analog2;
-	UINT16 analog3;
-	UINT16 analog4;
-
-	UINT64 cRIOChecksum;
-	UINT32 FPGAChecksum0;
-	UINT32 FPGAChecksum1;
-	UINT32 FPGAChecksum2;
-	UINT32 FPGAChecksum3;
-
-	char versionData[8];
-} __attribute__((packed));
-
-#endif
diff --git a/aos/atom_code/input/input.gyp b/aos/atom_code/input/input.gyp
index 25ef4b9..19d0d2f 100644
--- a/aos/atom_code/input/input.gyp
+++ b/aos/atom_code/input/input.gyp
@@ -1,15 +1,22 @@
 {
   'targets': [
     {
-      'target_name': 'joystick',
+      'target_name': 'joystick_input',
       'type': 'static_library',
       'sources': [
-         'JoystickInput.cpp'
+        'joystick_input.cc',
       ],
       'dependencies': [
+        '<(AOS)/common/input/input.gyp:driver_station_data',
         '<(AOS)/common/messages/messages.gyp:aos_queues',
         '<(AOS)/common/network/network.gyp:socket',
-      ]
+        '<(AOS)/common/common.gyp:common',
+        '<(EXTERNALS):WPILib-NetworkRobotValues',
+        '<(AOS)/build/aos.gyp:logging',
+      ],
+      'export_dependent_settings': [
+        '<(AOS)/common/input/input.gyp:driver_station_data',
+      ],
     },
   ],
 }
diff --git a/aos/atom_code/input/joystick_input.cc b/aos/atom_code/input/joystick_input.cc
new file mode 100644
index 0000000..01bcbc6
--- /dev/null
+++ b/aos/atom_code/input/joystick_input.cc
@@ -0,0 +1,56 @@
+#include "aos/atom_code/input/joystick_input.h"
+
+#include <string.h>
+
+#include "aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h"
+
+#include "aos/common/Configuration.h"
+#include "aos/common/network/ReceiveSocket.h"
+#include "aos/common/messages/RobotState.q.h"
+#include "aos/common/logging/logging.h"
+
+namespace aos {
+namespace input {
+
+void JoystickInput::Run() {
+  ReceiveSocket sock(NetworkPort::kDS);
+
+  NetworkRobotJoysticks joysticks;
+  char buffer[sizeof(joysticks) + ::buffers::kOverhead];
+  driver_station::Data data;
+
+  while (true) {
+    int received = sock.Receive(buffer, sizeof(buffer));
+    if (received == -1) {
+      LOG(WARNING, "socket receive failed with %d: %s\n",
+          errno, strerror(errno));
+      continue;
+    }
+
+    if (!joysticks.DeserializeFrom(buffer, received)) {
+      LOG(WARNING, "deserializing data from %zd bytes failed\n", received);
+      continue;
+    }
+
+    if (!robot_state.MakeWithBuilder()
+        .enabled(joysticks.control.enabled())
+        .autonomous(joysticks.control.autonomous())
+        .team_id(joysticks.team_number)
+        .Send()) {
+			LOG(WARNING, "sending robot_state failed\n");
+		} else {
+      LOG(DEBUG, "sent robot_state{%s, %s, %hu}\n",
+          joysticks.control.enabled() ? "enabled" : "disabled",
+          joysticks.control.autonomous() ? "auto" : "not auto",
+          joysticks.team_number);
+    }
+
+    data.Update(joysticks);
+    // TODO(brians): posedge/negedge logging
+
+    RunIteration(data);
+  }
+}
+
+}  // namespace input
+}  // namespace aos
diff --git a/aos/atom_code/input/joystick_input.h b/aos/atom_code/input/joystick_input.h
new file mode 100644
index 0000000..d905eaa
--- /dev/null
+++ b/aos/atom_code/input/joystick_input.h
@@ -0,0 +1,20 @@
+#ifndef AOS_ATOM_CODE_INPUT_JOYSTICKS_INPUT_H_
+#define AOS_ATOM_CODE_INPUT_JOYSTICKS_INPUT_H_
+
+#include "aos/common/input/driver_station_data.h"
+
+namespace aos {
+namespace input {
+
+class JoystickInput {
+ public:
+  void Run();
+
+ private:
+  virtual void RunIteration(const driver_station::Data &data) = 0;
+};
+
+}  // namespace input
+}  // namespace aos
+
+#endif  // AOS_ATOM_CODE_INPUT_JOYSTICKS_INPUT_H_