     
     Joystick.button(gear, 0);
     Joystick.send_now();
-    
+
     while (get_current_gear() != 0) {
       delay(5);
     }
-  }      
+  }
+}
+
+void poll_handbrake() {
+  int minBrakeValue = 60; // I got these values printing idle and max brake values
+  int maxBrakeValue = 160;
+  int rawBrake = analogRead(PIN_HANDBRAKE);
   
+  if (rawBrake > maxBrakeValue) {
+    rawBrake = maxBrakeValue;
+  } else if (rawBrake < minBrakeValue) {
+    rawBrake = minBrakeValue;
+  }
+  
+  int normalizedBrake = (rawBrake - minBrakeValue) * (1024 / (maxBrakeValue-minBrakeValue));
+  
+  Joystick.X(normalizedBrake);
+  Joystick.send_now();  
+}
+
+void loop() {
+  #ifdef DEBUG
+  debug();
+  #endif
+
+  pollShifter();
+  pollHandbrake();
+
   delay(5);
 }
 



int get_current_gear() {
  int x = analogRead(PIN_X);
  int y = analogRead(PIN_Y);

  if (y > 1000) {
    if (x < 100) {

}

void debug() {
  Serial.print("shifter x: ");
  Serial.print(analogRead(PIN_SHIFTER_X));
  Serial.print(" shifter y: ");
  Serial.print(analogRead(PIN_SHIFTER_Y));
  Serial.print(" handbrake: ");
  Serial.println(analogRead(PIN_HANDBRAKE));
}

void poll_shifter() {
  int gear = get_current_gear();

  if (gear != 0) {
    Joystick.button(gear, 1);
    Joystick.send_now();
