25 November 2023

Project: Game Controller

 Inside: Control Helmet


    This is my custom-made controller for the game Inside by Playdead Studios. Inside is a narrative and immersive puzzle game that you can find on Steam. The main inspiration for the design of the controller is a similar item that you find in the game, a helmet that the main character puts on to control others. To make this look and feel like the one inside the game, I added some plastic caps with some wiring coming from the top and exposed pixels which light up similar to the design in the game. As a helmet, the first signifier to use this item is to wear it and try moving around with it. Once you attempt to move your head you will notice that the head movements correlate to the characters, and if you hold your head the light sensor will also send data to use the grab functions. The LEDs are also exposed because they all relate to movements, so when you do an input the light will change colors, like blue when you jump(look up) or red when you grab (tap your head from the top). You can tilt your head left to move left, right to move right, down to move or look down, up to move up, or jump. The light sensor from the top of the helmet can be covered to use the grab function. These mappings should allow you to play the game simply with your head, mimicking the character and having your head mostly free, giving you a more immersive and unique experience. What other functions or signifiers could be added to a more fully-fledged version of this design?
    
Video:

Code:

#include <Keyboard.h>
#include <KeyboardLayout.h>   //Keyboard library Controls
#include <Keyboard_da_DK.h>
#include <Keyboard_de_DE.h>
#include <Keyboard_es_ES.h>
#include <Keyboard_fr_FR.h>
#include <Keyboard_it_IT.h>
#include <Keyboard_sv_SE.h>



#include <Adafruit_CircuitPlayground.h>  //Including libraries for the project
#include <Adafruit_Circuit_Playground.h>


const int debounce = 0; //used for delays

void setup() {
  // put your setup code here, to run once:
  CircuitPlayground.begin();  
  pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP); //start device up
  Serial.begin(9600);
  delay (1000);


}

void loop() {
  // put your main code here, to run repeatedly:  
    float z =  CircuitPlayground.motionZ();  // track head movement up or down via z
    float x =  CircuitPlayground.motionX();  //  track head movement left or right on x
    float l = analogRead(A3);
   
 
  if (x > 3)
  {
     Keyboard.press(KEY_RIGHT_ARROW); // moves to the right by tilting your head to the right
     delay(1);
     CircuitPlayground.clearPixels();
     for(int i = 0; i < 5; i++)   //  //lights up the right side of the neopixels relative to head movement
    {
      CircuitPlayground.setPixelColor(i,255,150,0);
    }
     
  }
  if (x < 3 && x > -3)   // Release left and right keys.
  {
    Keyboard.release(KEY_RIGHT_ARROW);
    Keyboard.release(KEY_LEFT_ARROW);
    delay(1);
    for(int i = 0; i <10; i++)  // Sets the neutral mode color for the neopixels and resets it when back to neutral position.
    {
      CircuitPlayground.setPixelColor(i,255,150,0);
    }
   

  }


  if (x < -3 )
  {
    Keyboard.press(KEY_LEFT_ARROW); // moves to the left by tilting your head to the left.
    delay(1);
    CircuitPlayground.clearPixels();
     for(int i = 5; i < 10; i++)  
    {
      CircuitPlayground.setPixelColor(i,255,150,0); //lights up the left side of the neopixels relative to head movement
     
    }
  }

  if (z < -1)
  {
    Keyboard.press(KEY_DOWN_ARROW); // go down using down tilt head motion.
     for(int i = 0; i < 10; i++)  
    {
      CircuitPlayground.setPixelColor(i,0,150,0);  // Set colors to Green
     
    }
  }

  if (z > 5)
  {   //  move up
    Keyboard.press(KEY_UP_ARROW); //  Jump or up input using the accelerometer z axis. tilt your head up
     delay(debounce);  
     for(int i = 0; i < 10; i++)  
    {
      CircuitPlayground.setPixelColor(i,0,0,255);
     
    }
  }
   
  if (z < 5 && z > -1)    // Jump/up and down input release.
  {
    Keyboard.release(KEY_UP_ARROW);
    Keyboard.release(KEY_DOWN_ARROW);
  }




  if (l > 1000)
   {
    Keyboard.press (KEY_DELETE); // Grab/hold key connected to the external light sensor when you tap it or cover it from light
    delay(debounce);
    for(int i = 0; i < 10; i++)  // set lights to red
    {
      CircuitPlayground.setPixelColor(i,255,0,0);
    }
   

  }

  if  (l < 900)              
  {
    Keyboard.release (KEY_DELETE); //Grab/hold release, when light is not completely obscured
 
   
    delay(debounce);
     

  }
}
Sketch:

    

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.