18 April 2022

Game Controller - The Hanged Man

 



For the custom controller, I decided to use the game the Hanged Man to try and create an alternative controller. The goal was originally to try and create a controller that would help with handicap accessibilities, so that players who had one hand would be able to play it. I thought to make a controller that was small in design and size, but comfortable. However, I found that to be more challenging that I originally thought, as I did not take into account the wiring and enclosure space as well as the material for the controller and my own capabilities. As I constructed the controller, I had to remake the enclosure to a larger size and cruder construction in the hopes of being able to convey the idea I had. The controller was going the use the accelerometer to sense the tilting of the controller in order to press the arrow keys in order to move about in the game, and I had originally planned to map inputs using light sensors in place of the two buttons needed. However, since I was restricted with the size again, I found the task too difficult for me and decided to use a potentiometer for the button presses, where turning the dial to one side fully would try and represent a button press. However, I was unable to create a proper mapping for the potentiometer to use this in the fashion that I wanted to perfectly. The reason I decided to make the controller in the visage of a tarot card was to pay homage to the title of the game, as well as to immerse the player in the theme of the game in an attempt to be entertaining. 

What do you think could have been done to create a controller with this idea with a larger size in mind, that is, how would you create a controller that would be ergonomic in the hands of a disabled person? what inputs would you use, how would you build it, and where would you place things?








SCHEMATIC: 






 CODE: 

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include<math.h>
#include <Keyboard.h>


//Written by Jeffrey Jourdan

//Global Variables

const int debounce = 100;
const int thresh = 500;
float map(float x, float in_min, float in_max, float out_min, float out_max);


void setup() {
  // put your setup code here, to run once:
  
  
  Serial.begin(9600);

  delay(1000);

  CircuitPlayground.begin();
  
}//end setup

void loop() {
  // put your main code here, to run repeatedly:
  
  //initialize accelerometor
  
  float x = CircuitPlayground.motionX();
  float y = CircuitPlayground.motionY();
  float rad = atan2(y, x);

//check accelerometer readings

  //Serial.print("\t X value: ");
  //Serial.print(x);
  //Serial.print("\t Y value: ");
  //Serial.println(y);


// If statements to write keyboard presses for the arrow keys based on the positions of x and y.

  if(x <= -5)
  {
    Keyboard.press(216);
    delay(debounce);
  }//end if

  else
  {
    Keyboard.release(216);
  }//else if

  if(x >= 5)
  {
    Keyboard.press(215);
    delay(debounce);
  }//end if

  else
  {
    Keyboard.release(215);
  }//end else

  if(y <= -4)
  {
    Keyboard.press(217);
    delay(debounce);
  }//end if

  else
  {
    Keyboard.release(217);
  }//end else


  if(y >= 2)
  {
    Keyboard.press(218);
    delay(debounce);
  }//end if

  else
  {
    Keyboard.release(218);
  }//end else



  // Setting up the potentiometer to write the other buttons needing to play the game.

  //delcare potentiometer
  int potButton = analogRead(A7);
  //if statements for button presses

  if(potButton > 300 && potButton < 400)
  {
    Keyboard.press('Z');
    delay(500);
    Keyboard.release('Z');
  }//end if



  else if(potButton > 400 && potButton < 500)
  {
    Keyboard.press('X');
    delay(500);
    Keyboard.release('X');
  }//end if
  
  Serial.println(analogRead(A7));
  
}//end loop



VIDEO:



For some reason the first fifteen seconds of the video was clipped, but it talked about choosing the Hanged man for the game controller!




No comments:

Post a Comment

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