Author Topic: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)  (Read 104891 times)

0 Members and 1 Guest are viewing this topic.

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #200 on: Tue, 08 December 2015, 16:31:23 »
got it to compile. i'll work on testing soon :thumb:

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #201 on: Tue, 08 December 2015, 16:36:53 »
Great!  I just hope it works...
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #202 on: Tue, 08 December 2015, 17:30:42 »
Here is the report. Buttons zero through seven work.

Analog pins A0 and A1 work well controlling X Axis / Y Axis here:

119464-0

no perceptible lag.  maybe some but it would be less than i can easily see without something to compare immediately like a/b testing.

Analog on other pin combinations, such as A2-A3, and A4-A5, result in X Axis / Y Axis control. But the control is only in a diagonal from lower left to upper right as follows:

119460-1

I think what I need is A2 and A3 pins to control these guys right here:

119462-2
I think this will be important because if the analogs are controlling the same thing, I'm sure it will be a problem for Xpadder to recognize them as different sticks.

And then I need pins A4 and A5 to be 4 buttons.

Here's the code that I got uploaded and working:

Code: [Select]
#define STICK_X 0
#define STICK_Y 1
#define OVERVAL 0

int Xstick;
int Ystick;
int Temp;
int myPins[] = {0,1,2,3,4,5,6,7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup() {
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, -127, 128);
  Xstick = constrain(Xstick, -127 , 128);
  Joystick.setXAxis(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 128, -127);
  Ystick = constrain(Ystick, -127 , 128);
  Joystick.setYAxis(Ystick);
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
 
   buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
  if(buttonState[i] != oState[i]) { //check against previous button state, if changed do something
    if(buttonState[i] == LOW) { //button has been pressed
      Joystick.pressButton(i); //press corresponding "joystick" button
    }
    else { //button has been released
      Joystick.releaseButton(i); //release corresponding "joystick" button
    }
  oState[i] = buttonState[i]; //save state to compare next time
  }

  Temp = analogRead(2);
  if (Temp < -30) {
    if (buttonState[8] == 0){
      buttonState[8] = 1;
    }
  else
    if (buttonState[8] == 1){
      buttonState[8] = 0;
    }
  }

  if (Temp > 30) {
    if (buttonState[9] == 0){
      buttonState[9] = 1;
    }
  else
    if (buttonState[9] == 1){
      buttonState[9] = 0;
    }
  }

  Temp = analogRead(3);
  if (Temp < -30) {
    if (buttonState[10] == 0){
      buttonState[10] = 1;
    }
  else
    if (buttonState[10] == 1){
      buttonState[10] = 0;
    }
  }

  if (Temp > 30) {
    if (buttonState[11] == 0){
      buttonState[11] = 1;
    }
  else
    if (buttonState[11] == 1){
      buttonState[11] = 0;
    }
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
    if (buttonState[12] == 0){
      buttonState[12] = 1;
    }
  else
    if (buttonState[12] == 1){
      buttonState[12] = 0;
    }
  }

  if (Temp > 30) {
    if (buttonState[13] == 0){
      buttonState[13] = 1;
    }
  else
    if (buttonState[13] == 1){
      buttonState[13] = 0;
    }
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
    if (buttonState[14] == 0){
      buttonState[14] = 1;
    }
  else
    if (buttonState[14] == 1){
      buttonState[14] = 0;
    }
  }

  if (Temp > 30) {
    if (buttonState[15] == 0){
      buttonState[15] = 1;
    }
  else
    if (buttonState[15] == 1){
      buttonState[15] = 0;
    }
  }
 
Joystick.sendState()
;}}

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #203 on: Tue, 08 December 2015, 18:07:23 »
Well that's strange.  As you can see in the second part of the code (after all the comments) A2-5 get read into Temp then  depending if that value is < -30 or > 30 it should press buttons 8-15 - the analog should not move at all.  A diagonal movement suggests you have a short as the power rises and falls on both axis at the same time, but that should happen whichever pair of pins you use and 0 and 1 work fine?  Can you try using pins A2 and A4?

I just had another look at the code and simplified it for the non-analog analogs (the rotation axis take values from 0-360 degrees rather than higher or lower than 0 so I don't think they'll work) and noticed that pin 4 was read twice and 5 not at all, but other than that this code won't fix anything.  Should run quicker though, though sounds like you won't notice! Edit: added lines to set analogs as input, just in case...

Code: [Select]
#define STICK_X 0
#define STICK_Y 1
#define OVERVAL 0

int Xstick;
int Ystick;
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
int Temp;
int myPins[] = {0,1,2,3,4,5,6,7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup() {
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, -127, 128);
  Xstick = constrain(Xstick, -127 , 128);
  Joystick.setXAxis(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 128, -127);
  Ystick = constrain(Ystick, -127 , 128);
  Joystick.setYAxis(Ystick);
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
 
   buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
  if(buttonState[i] != oState[i]) { //check against previous button state, if changed do something
    if(buttonState[i] == LOW) { //button has been pressed
      Joystick.pressButton(i); //press corresponding "joystick" button
    }
    else { //button has been released
      Joystick.releaseButton(i); //release corresponding "joystick" button
    }
  oState[i] = buttonState[i]; //save state to compare next time
  }

  Temp = analogRead(2);
  if (Temp < -30) {
      buttonState[8] = 1;
    }
  else {
      buttonState[8] = 0;
  }

  if (Temp > 30) {
      buttonState[9] = 1;
    }
  else {
      buttonState[9] = 0;
  }

  Temp = analogRead(3);
  if (Temp < -30) {
      buttonState[10] = 1;
    }
  else {
      buttonState[10] = 0;
  }

  if (Temp > 30) {
      buttonState[11] = 1;
    }
  else {
      buttonState[11] = 0;
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
      buttonState[12] = 1;
    }
  else {
      buttonState[12] = 0;
  }

  if (Temp > 30) {
      buttonState[13] = 1;
    }
  else {
      buttonState[13] = 0;
  }
 
  Temp = analogRead(5);
  if (Temp < -30) {
      buttonState[14] = 1;
    }
  else {
      buttonState[14] = 0;
  }

  if (Temp > 30) {
      buttonState[15] = 1;
    }
  else {
      buttonState[15] = 0;
  }
 
Joystick.sendState()
}}
« Last Edit: Tue, 08 December 2015, 18:18:30 by suicidal_orange »
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #204 on: Tue, 08 December 2015, 18:34:52 »
strange but i get the exact same results :-X   :))

i think i found a problem...

this code here only allows each analog stick to control 2 buttons instead of 4?  is that correct?

Code: [Select]
Temp = analogRead(2);
  if (Temp < -30) {
      buttonState[8] = 1;
    }
  else {
      buttonState[8] = 0;
  }

  if (Temp > 30) {
      buttonState[9] = 1;
    }
  else {
      buttonState[9] = 0;
  }

  Temp = analogRead(3);
  if (Temp < -30) {
      buttonState[10] = 1;
    }
  else {
      buttonState[10] = 0;
  }

  if (Temp > 30) {
      buttonState[11] = 1;
    }
  else {
      buttonState[11] = 0;
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
      buttonState[12] = 1;
    }
  else {
      buttonState[12] = 0;
  }

  if (Temp > 30) {
      buttonState[13] = 1;
    }
  else {
      buttonState[13] = 0;
  }
 
  Temp = analogRead(5);
  if (Temp < -30) {
      buttonState[14] = 1;
    }
  else {
      buttonState[14] = 0;
  }

  if (Temp > 30) {
      buttonState[15] = 1;
    }
  else {
      buttonState[15] = 0;
  }

this would perhaps explain why the stick is only moving in the diagonal line previously described.


i think the code for each stick needs to be twice as big, something like..

Code: [Select]
Temp = analogRead(5);
  if (Temp < -30) {
      buttonState[14] = 1;
    }
  else {
      buttonState[14] = 0;
  }
// a piece of code that says if Temp is between something and something, button 15 should be activated
  if (Temp > 30) {
      buttonState[16] = 1;
    }
  else {
      buttonState[16] = 0;
// a piece of code that says if Temp is between something and something, button 17 should be activated
  }



Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #205 on: Tue, 08 December 2015, 18:53:28 »
It shouldn't be doing analog at all though, just buttons :confused:

Each stick is read one axis at a time and there are two switches per axis so the code says if you press down on pin 2 (< -30) press button 8 or if you press up (> 30) press button 9 - anything between -30 and 30 registers as nothing.  Then it checks left/right with a button for each.

This seems sound, but maybe you're supposed to analogRead(A2) etc instead of just (2)?  I'd hope it would error but maybe not.

Also did you add the bit below in?  I think it should be in setup rather than at the top where I put it

pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #206 on: Tue, 08 December 2015, 19:53:45 »
Looks like I made a mistake before and didn't use the newest code you posted at all. I don't know how that happened because I and  copy and pasted it....

anyway, i just now uploaded this code, and still got the exact same result:

Code: [Select]
#define STICK_X 0
#define STICK_Y 1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[] = {0,1,2,3,4,5,6,7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup() {

pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);

  int i;
  for (i = 0; i < 8; i = i + 1) {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, -127, 128);
  Xstick = constrain(Xstick, -127 , 128);
  Joystick.setXAxis(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 128, -127);
  Ystick = constrain(Ystick, -127 , 128);
  Joystick.setYAxis(Ystick);
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
 
   buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
  if(buttonState[i] != oState[i]) { //check against previous button state, if changed do something
    if(buttonState[i] == LOW) { //button has been pressed
      Joystick.pressButton(i); //press corresponding "joystick" button
    }
    else { //button has been released
      Joystick.releaseButton(i); //release corresponding "joystick" button
    }
  oState[i] = buttonState[i]; //save state to compare next time
  }

  Temp = analogRead(2);
  if (Temp < -30) {
      buttonState[8] = 1;
    }
  else {
      buttonState[8] = 0;
  }

  if (Temp > 30) {
      buttonState[9] = 1;
    }
  else {
      buttonState[9] = 0;
  }

  Temp = analogRead(3);
  if (Temp < -30) {
      buttonState[10] = 1;
    }
  else {
      buttonState[10] = 0;
  }

  if (Temp > 30) {
      buttonState[11] = 1;
    }
  else {
      buttonState[11] = 0;
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
      buttonState[12] = 1;
    }
  else {
      buttonState[12] = 0;
  }

  if (Temp > 30) {
      buttonState[13] = 1;
    }
  else {
      buttonState[13] = 0;
  }
 
  Temp = analogRead(5);
  if (Temp < -30) {
      buttonState[14] = 1;
    }
  else {
      buttonState[14] = 0;
  }

  if (Temp > 30) {
      buttonState[15] = 1;
    }
  else {
      buttonState[15] = 0;
  }
 
Joystick.sendState()
;}}

no button action at all on 2nd and 3rd analog stick connections on A2-A3 or A4-A5.  just the diagonal analog movement in x axis / y axis


Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #207 on: Tue, 08 December 2015, 20:33:28 »
It shouldn't be doing analog at all though, just buttons :confused:

And yeah, it shouldn't be doing any analog stuff at all on those other pins :-X

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #208 on: Tue, 08 December 2015, 20:37:16 »
Maybe this bit of code isn't getting seen.
Code: [Select]
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);

Have I got it in the wrong spot here?

Code: [Select]
#define STICK_X 0
#define STICK_Y 1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[] = {0,1,2,3,4,5,6,7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup() {

pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);

  int i;
  for (i = 0; i < 8; i = i + 1) {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, -127, 128);
  Xstick = constrain(Xstick, -127 , 128);
  Joystick.setXAxis(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 128, -127);
  Ystick = constrain(Ystick, -127 , 128);
  Joystick.setYAxis(Ystick);
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
 
   buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
  if(buttonState[i] != oState[i]) { //check against previous button state, if changed do something
    if(buttonState[i] == LOW) { //button has been pressed
      Joystick.pressButton(i); //press corresponding "joystick" button
    }
    else { //button has been released
      Joystick.releaseButton(i); //release corresponding "joystick" button
    }
  oState[i] = buttonState[i]; //save state to compare next time
  }

  Temp = analogRead(2);
  if (Temp < -30) {
      buttonState[8] = 1;
    }
  else {
      buttonState[8] = 0;
  }

  if (Temp > 30) {
      buttonState[9] = 1;
    }
  else {
      buttonState[9] = 0;
  }

  Temp = analogRead(3);
  if (Temp < -30) {
      buttonState[10] = 1;
    }
  else {
      buttonState[10] = 0;
  }

  if (Temp > 30) {
      buttonState[11] = 1;
    }
  else {
      buttonState[11] = 0;
  }
 
  Temp = analogRead(4);
  if (Temp < -30) {
      buttonState[12] = 1;
    }
  else {
      buttonState[12] = 0;
  }

  if (Temp > 30) {
      buttonState[13] = 1;
    }
  else {
      buttonState[13] = 0;
  }
 
  Temp = analogRead(5);
  if (Temp < -30) {
      buttonState[14] = 1;
    }
  else {
      buttonState[14] = 0;
  }

  if (Temp > 30) {
      buttonState[15] = 1;
    }
  else {
      buttonState[15] = 0;
  }
 
Joystick.sendState()
;}}

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #209 on: Wed, 09 December 2015, 02:29:24 »
Is this the Arduino which wont do serial.print or was that someone else?  Printing out the analog values would be helpful...

You need to experiment a bit - change STICK_X and Y at the top to the other pins and comment/delete the second section and 4 new lines (they are in the right place, you probably missed them because I edited the post after you read it - not quick enough :))) to see if the pins are working correctly.  If they are I'm stumped and will be waiting for W11cE to tell me what I've missed.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #210 on: Wed, 09 December 2015, 02:47:59 »
I have no analog stick at home but I can take a deeper look into the code if you want.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #211 on: Wed, 09 December 2015, 03:02:40 »
I have no analog stick at home but I can take a deeper look into the code if you want.

Please do - it's pretty simple and I've outlined above what it's supposed to do but not only is it not pressing the buttons as requested it's moving the analog, and not even doing that well.  Either I've missed something major or there's a hardware issue, but with nothing here to "poke and see what happens" it's hard to tell which!
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #212 on: Wed, 09 December 2015, 13:59:22 »
I have no analog stick at home but I can take a deeper look into the code if you want.

Please do - it's pretty simple and I've outlined above what it's supposed to do but not only is it not pressing the buttons as requested it's moving the analog, and not even doing that well.  Either I've missed something major or there's a hardware issue, but with nothing here to "poke and see what happens" it's hard to tell which!

I can't test with the hardware, but here's the revised code. I used the full pin name for analog pins and deleted their pinmode() as it seems to be the way to do (only worked with digital pins on my Arduino codes). I also reduced your code size by using ternary operator for simple IF THEN ELSE structures.

Note: I can't test compilation with Joystick functions on Archlinux as I'm limited to IDE 1.6.5 (need 1.6.6 for Joystick lib it seems).

Code: [Select]
#define STICK_X A0
#define STICK_Y A1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[]          = {0, 1, 2, 3, 4, 5, 6, 7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[]      = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup()
{
  for (int i = 0 ; i < 8 ; i++)
  {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop()
{
  // X axis computations
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024 - OVERVAL, -127, 127);
  Xstick = constrain(Xstick, -127, 127);
  Joystick.setXAxis(Xstick);

  // Y axis computations
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024 - OVERVAL, 127, -127);
  Ystick = constrain(Ystick, -127, 127);
  Joystick.setYAxis(Ystick);
 
  for (int i = 0 ; i < 8 ; i++)
  {
    buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
    if(buttonState[i] != oState[i]) // check against previous button state, if changed do something
    {
      if(buttonState[i] == LOW)     // button has been pressed
      {
        Joystick.pressButton(i);    // press corresponding "joystick" button
      }
      else                          // button has been released
      {
        Joystick.releaseButton(i);  // release corresponding "joystick" button
      }
      oState[i] = buttonState[i];   // save state to compare next time
    }

    Temp = analogRead(A2);
    (Temp < -30) ? buttonState[8] = 1 : buttonState[8] = 0;
    (Temp >  30) ? buttonState[9] = 1 : buttonState[9] = 0;
   
    Temp = analogRead(A3);
    (Temp < -30) ? buttonState[10] = 1 : buttonState[10] = 0;
    (Temp >  30) ? buttonState[11] = 1 : buttonState[11] = 0;
 
    Temp = analogRead(A4);
    (Temp < -30) ? buttonState[12] = 1 : buttonState[12] = 0;
    (Temp >  30) ? buttonState[13] = 1 : buttonState[13] = 0;
 
    Temp = analogRead(A5);
    (Temp < -30) ? buttonState[14] = 1 : buttonState[14] = 0;
    (Temp >  30) ? buttonState[15] = 1 : buttonState[15] = 0;
 
    // Update joystick state
    Joystick.sendState();
  }
}
« Last Edit: Wed, 09 December 2015, 14:01:11 by GuilleAcoustic »

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #213 on: Wed, 09 December 2015, 14:23:35 »
ty guys working hard day - hope to be able to work together with you on this tonight or soon otherwise ;D

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #214 on: Wed, 09 December 2015, 15:21:29 »
here is the report.  most recent code above produces exact same results :-\

teensy will allow for better troubleshooting.

yes, this is the leonardo that doesn't output anything to serial monitor.  tried again just now.  opened serial monitor and moved analog stick on working pins and on non-working pins.  no output whatsoever to serial monitor.

for further troubleshooting, i removed the proto-shield and connected to board directly with these results which haven't changed:

works
119516-0

doesn't work
119518-1

doesn't work
119520-2


i had a thought.  maybe the 2nd analog stick only works if the 1st analog stick remains connected.  i haven't tried connecting both existing sticks yet. 

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #215 on: Wed, 09 December 2015, 15:37:51 »
Well you're doing better than me - I downloaded a fresh copy of 1.6.6, swapped the files and added the library but on compiling it says this mess :))

Code: [Select]
Arduino: 1.6.6 (Windows 7), Board: "Arduino Leonardo"

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\USBAPI.h:38:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:19:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:54:71: error: 'USB_EP_SIZE' was not declared in this scope

  D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0),

                                                                       ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\USBCore.h:272:22: note: in definition of macro 'D_ENDPOINT'

  { 7, 5, _addr,_attr,_packetSize, _interval }

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:55:71: error: 'USB_EP_SIZE' was not declared in this scope

  D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0)

                                                                       ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\USBCore.h:272:22: note: in definition of macro 'D_ENDPOINT'

  { 7, 5, _addr,_attr,_packetSize, _interval }

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:64:16: error: 'bool CDC_Setup' redeclared as different kind of symbol

 bool CDC_Setup(USBSetup& setup)

                ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:19:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\USBAPI.h:269:6: error: previous declaration of 'bool CDC_Setup(Setup&)'

 bool CDC_Setup(Setup& setup);

      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp:64:16: error: 'USBSetup' was not declared in this scope

 bool CDC_Setup(USBSetup& setup)

                ^

exit status 1
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.



Not surprising you're getting the same results as the code is the same just much tidier (thanks GuilleAcousitc - I'll remember that structure!)

There's no reason that having two analogs connected would change anything but to confirm you can try swapping STICK_X and STICK_Y to different pins at the top to see whether it's the pins or the stick - comment out the stick-buttons bit at the bottom so it doesn't interfere.

120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #216 on: Wed, 09 December 2015, 15:48:03 »
i had a thought.  maybe the 2nd analog stick only works if the 1st analog stick remains connected.  i haven't tried connecting both existing sticks yet.

yeah this was a longshot and didn't work. 1st analog works as usual.  2nd analog stick doesn't do anything when added.  no diagonal-only analog movement as before.  and no buttons.  just no output at all.

i've tried all kinds of combos.  i've even tried connecting analog 2 to pins A2-A4 instead of A2-A3 as they should be.  just trying anything and everything.

anyway, teensy will allow for more certainty about the problem when it arrives ;)

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #217 on: Thu, 10 December 2015, 02:27:19 »
Not surprising you're getting the same results as the code is the same just much tidier (thanks GuilleAcousitc - I'll remember that structure!)

It is not exactly the same as I changed the analog pin label from 0, 1, 2, 3, 4, 5 to A0, A1, A2, A3, A4 and A5. Sadly I have no analog source to test the code. Or I could wire my arcade stick parts to analog inputs and read either 0V or 5V .... Also I have no Arduino Leonardo at home. Only spare board is an Arduino Mega2560. Arduino micro is used inside my trackball and the Teensy++ 2.0 is used inside my keyboard.

Maybe you could try this library (especially the Joystick3 version): https://github.com/MHeironimus/ArduinoJoystickLibrary

Regarding the serial output, could you send me the code ?
« Last Edit: Thu, 10 December 2015, 02:32:59 by GuilleAcoustic »

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #218 on: Thu, 10 December 2015, 17:58:27 »

Regarding the serial output, could you send me the code ?

aah sorry but i don't understand your question.  if that question is for me, can you please tell me some more details?

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #219 on: Thu, 10 December 2015, 17:59:00 »
teensy arrived. installing...

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #220 on: Thu, 10 December 2015, 18:35:53 »
hey guys i installed teensyduino and teensy 3.2 board no problem.  tried to just verify this code and got the error message below.  what's this about?  i remember when i got the leonardo set up for joystick use, i had to add some files to my arduino IDE install folder.  did perhaps installing teensyduino botch those up?

Code: [Select]
#define STICK_X A0
#define STICK_Y A1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[]          = {0, 1, 2, 3, 4, 5, 6, 7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[]      = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup()
{
  for (int i = 0 ; i < 8 ; i++)
  {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop()
{
  // X axis computations
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024 - OVERVAL, -127, 127);
  Xstick = constrain(Xstick, -127, 127);
  Joystick.setXAxis(Xstick);

  // Y axis computations
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024 - OVERVAL, 127, -127);
  Ystick = constrain(Ystick, -127, 127);
  Joystick.setYAxis(Ystick);
 
  for (int i = 0 ; i < 8 ; i++)
  {
    buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
    if(buttonState[i] != oState[i]) // check against previous button state, if changed do something
    {
      if(buttonState[i] == LOW)     // button has been pressed
      {
        Joystick.pressButton(i);    // press corresponding "joystick" button
      }
      else                          // button has been released
      {
        Joystick.releaseButton(i);  // release corresponding "joystick" button
      }
      oState[i] = buttonState[i];   // save state to compare next time
    }

    Temp = analogRead(A2);
    (Temp < -30) ? buttonState[8] = 1 : buttonState[8] = 0;
    (Temp >  30) ? buttonState[9] = 1 : buttonState[9] = 0;
   
    Temp = analogRead(A3);
    (Temp < -30) ? buttonState[10] = 1 : buttonState[10] = 0;
    (Temp >  30) ? buttonState[11] = 1 : buttonState[11] = 0;
 
    Temp = analogRead(A4);
    (Temp < -30) ? buttonState[12] = 1 : buttonState[12] = 0;
    (Temp >  30) ? buttonState[13] = 1 : buttonState[13] = 0;
 
    Temp = analogRead(A5);
    (Temp < -30) ? buttonState[14] = 1 : buttonState[14] = 0;
    (Temp >  30) ? buttonState[15] = 1 : buttonState[15] = 0;
 
    // Update joystick state
    Joystick.sendState();
  }
}


Code: [Select]
Arduino: 1.6.5 (Windows 7), TD: 1.26, Board: "Teensy 3.2 / 3.1, Serial + Keyboard + Mouse + Joystick, 96 MHz optimized (overclock), US English"

Build options changed, rebuilding all

sketch_dec09a.ino: In function 'void setup()':
sketch_dec09a:20: error: no matching function for call to 'usb_joystick_class::begin(bool)'
sketch_dec09a.ino:20:23: note: candidate is:
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:28:0,
from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Arduino.h:1,
from sketch_dec09a.ino:5:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/usb_joystick.h:55:14: note: void usb_joystick_class::begin()
void begin(void) { }
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/usb_joystick.h:55:14: note:   candidate expects 0 arguments, 1 provided
sketch_dec09a.ino: In function 'void loop()':
sketch_dec09a:28: error: 'class usb_joystick_class' has no member named 'setXAxis'
sketch_dec09a:33: error: 'class usb_joystick_class' has no member named 'setYAxis'
sketch_dec09a:43: error: 'class usb_joystick_class' has no member named 'pressButton'
sketch_dec09a:47: error: 'class usb_joystick_class' has no member named 'releaseButton'
sketch_dec09a:69: error: 'class usb_joystick_class' has no member named 'sendState'
'class usb_joystick_class' has no member named 'sendState'

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #221 on: Thu, 10 December 2015, 19:28:36 »
From reading this there are quite a few differences between the code for a Teensy and a standard Arduino, it's similar enough that you should be able to substitute the button parts but the real analog might need some work.

Have a look at the sample code and try to map it to your pins, if you can get the buttons and the real analog working it should be easy enough to add the digitized analogs (assuming it was your Leonardo doing strange things not the sticks...)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #222 on: Thu, 10 December 2015, 23:08:15 »
damn, not having any luck with basic teensy setup.  i think the one i got may even be defective.

tried on 2 Win7 machines

followed install instructions here

https://www.pjrc.com/teensy/td_download.html

then followed these instructions for joystick setup and uploading the Complete example sketch

https://www.pjrc.com/teensy/td_joystick.html

and this is the mess that shows up in controller properties


not sure if you can see, button 14 shows as pressed. nothing is connected.  no buttons or anything. 




anyway

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #223 on: Thu, 10 December 2015, 23:16:32 »
sent message to seller to see if he or she thinks the board is defective based on post info above.

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #224 on: Thu, 10 December 2015, 23:20:16 »
in MUCH better news, finland guy is going to make 2 more vita mods for us ;D

it might take a while. but without those, this project won't be even near to its potential :cool:

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #225 on: Fri, 11 December 2015, 02:55:19 »
That's random, if the seller says it's all good I'll replicate it tonight - might just be floating inputs (because you've got nothing connected) but will need to look at the code to see why 14 is different!
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #226 on: Fri, 11 December 2015, 03:39:19 »
Maybe you should just force the unconnected buttons to "released" inside your setup() function. That's too bad that you can't specify the exact number of axis and buttons unless you go real C++ and makes your own HID descriptor.

Haven't tried it, but there's maybe a way to change the HID descriptor on the lib side ... maybe. Also, from the link you provided, this forum thread could interest you: https://forum.pjrc.com/threads/23681-Many-axis-joystick

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #227 on: Fri, 11 December 2015, 10:10:18 »
seller concurs that unconnected pins will appear as floating.  still doesn't explain button 14, but maybe it doesn't matter.


Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #228 on: Fri, 11 December 2015, 10:11:55 »
i'll have to do some work to see if i can get something to work on this board.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #229 on: Fri, 11 December 2015, 12:36:36 »
So I'm on Linux now, downloaded Arduino and installed Teensyduino but it does not like "Joystick" and refuses to compile the sample code.  Handy.

Looking at the code there is nothing special for pin 14 so that leaves it's location on the Teensy to be the problem and the only pin numbering I can find says it's pin 15 that has the LED so I'd expect that one to be your problem but no!  You only have 8 switches anyway, so just change numButtons at the top and you should be good.  Does the serial monitor work with the Teensy?
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #230 on: Fri, 11 December 2015, 12:47:09 »
Yeah, I plan to do these kinds of troubleshooting activities.

For the teensy, I plan to reduce the Complete sketch down to just one button and one analog stick for testing.

For the Leonardo and the sketch we've been trying to get to work with three analog sticks, I'm thinking that I will reduce that code down to just one analog stick set to connect with pins A2-A3 to see if those pins happen to be defective.

Of course the serial monitor doesn't work with the teensy :'( and I tried it on two different PCs.  The Complete sketch doesn't mention baud rate, so I don't know which baud rate to select in the serial monitor. If we can figure out which baud rate I should select, and the serial monitor still doesn't work for the teensy on two different PCs, I think were probably looking at user error as I couldn't get the Leonardo serial monitor to work on two different PCs either :-X

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #231 on: Fri, 11 December 2015, 12:58:32 »
Have you tried running the Arduino program as administrator?  Perhaps you don't have permission to access serial ports.  Also have you set the USB type under tools?  Don't think that was there with an Arduino but it is for Teensy, having changed that the code compiled!  Then I had to select a port (also under tools) so check that looks right.  I can't believe you have two defective boards, that would be so unlucky!

With everything working and 32 buttons selected I get no serial output suggesting stuff's happening after the initialisation stuff, but I'm on a 2.0++ not a 3.x so who knows if it's even comparable...
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #232 on: Fri, 11 December 2015, 13:16:42 »
Have you tried running the Arduino program as administrator?  Perhaps you don't have permission to access serial ports.  Also have you set the USB type under tools?  Don't think that was there with an Arduino but it is for Teensy, having changed that the code compiled!  Then I had to select a port (also under tools) so check that looks right.  I can't believe you have two defective boards, that would be so unlucky!

Haven't tried running as administrator yet. I'll give that a try in a little while.

Yeah, for teensy I selected USB type. If I don't, no game controller shows up at all.

But there was still some ugliness in getting the teensy to show up as a game controller. That went as follows:

On PC one, selecting serial keyboard mouse joystick resulted in the same text showing up in Win7 game controllers.  But it did not say teensy serial keyboard mouse joystick like it does in the instructions here:
https://www.pjrc.com/teensy/td_joystick.html

Also, selecting USB type keyboard mouse joystick without serial resulted in the properties page of the controller showing up blank.  and the name of the controller is just  keyboard mouse joystick - no mention of teensy in the name.

on PC2, both USB types work and show the game controller properties page with the hysteria (which is probably explained by floating), but there is still no mention of teensy in the game controller name, which may not be problematic.

Either way, I hope serial keyboard mouse joystick can be used, because that's the only one that works at all on PC1, which is my primary work and gaming station.

oh wait, it wasn't that serial monitor didn't work on teensy on 2 PCs, it's that when i tried running it, i got this error message and intended to ask you guys about it at some point...

Code: [Select]
Arduino: 1.6.5 (Windows 7), TD: 1.26, Board: "Teensy 3.2 / 3.1, Serial + Keyboard + Mouse + Joystick, 96 MHz optimized (overclock), US English"

Sketch uses 18,664 bytes (7%) of program storage space. Maximum is 262,144 bytes.

Global variables use 6,480 bytes (9%) of dynamic memory, leaving 59,056 bytes for local variables. Maximum is 65,536 bytes.

Teensy did not respond to a USB-based request to automatically reboot.

Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.

no serial port name defined

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #233 on: Fri, 11 December 2015, 14:33:09 »
Prolly a dumb question, but did you plug the Teensy to a Usb2 or a Usb3 ?

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #234 on: Fri, 11 December 2015, 14:48:14 »
USB 3.0 on PC1

USB 2.0 on PC2

could explain the properties blank i got on PC1 when choosing keyboard/mouse/joystick without serial

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #235 on: Fri, 11 December 2015, 15:54:09 »
USB 3.0 on PC1

USB 2.0 on PC2

could explain the properties blank i got on PC1 when choosing keyboard/mouse/joystick without serial

I've read here and there people havibg issues with peripherals on Usb3...

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #236 on: Fri, 11 December 2015, 16:51:35 »
"no serial port name defined" is what I get when there's nothing set in tools -> port.  There's only one entry in the list so you'd think it would default to that but it doesn't.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #237 on: Sun, 13 December 2015, 00:35:09 »
Found a problem with teensy i can’t overcome and i’m not hopeful about it.  Xpadder can’t see analog input from teensy on USB 2.0 or 3.0.  i tried testing USB 2.0 on 2 different PCs.

The teensy experience included a lot of difficulties, some of which we already got working on, and some of which i’m not even going to bother getting into because of the xpadder issue.

So, it’s back to leonardo.  Spent some time repeating trials on the code which was worked on already and still found the same results of fail on analogs 2 and 3 (A2-A3 and A4-A5).  I changed the code to test normal analog on pins (A2-A3 and A4-A5) to confirm leonardo pins aren’t defective with this sketch which has the analog to digital stuff removed and a change to the pin assignment at the very top:

Code: [Select]
#define STICK_X 2
#define STICK_Y 3
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[] = {0,1,2,3,4,5,6,7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup() {

pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);

  int i;
  for (i = 0; i < 8; i = i + 1) {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, -127, 128);
  Xstick = constrain(Xstick, -127 , 128);
  Joystick.setXAxis(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 128, -127);
  Ystick = constrain(Ystick, -127 , 128);
  Joystick.setYAxis(Ystick);
 
  int i;
  for (i = 0; i < 8; i = i + 1) {
 
   buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
  if(buttonState[i] != oState[i]) { //check against previous button state, if changed do something
    if(buttonState[i] == LOW) { //button has been pressed
      Joystick.pressButton(i); //press corresponding "joystick" button
    }
    else { //button has been released
      Joystick.releaseButton(i); //release corresponding "joystick" button
    }
  oState[i] = buttonState[i]; //save state to compare next time
  }

 
 
Joystick.sendState()
;}}

found the analog stick works just fine to control X Axis / Y Axis on pins (A2-A3 and A4-A5).  next thing to do is ...not sure yet :D

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #238 on: Sun, 13 December 2015, 00:42:36 »
i'd like to be able to report info from the serial monitor as previously noted would be helpful. 

latest version of the sketch we're working on is this i believe:
Code: [Select]
#define STICK_X A0
#define STICK_Y A1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[]          = {0, 1, 2, 3, 4, 5, 6, 7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[]      = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup()
{
  for (int i = 0 ; i < 8 ; i++)
  {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Joystick.begin(false);
}

void loop()
{
  // X axis computations
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024 - OVERVAL, -127, 127);
  Xstick = constrain(Xstick, -127, 127);
  Joystick.setXAxis(Xstick);

  // Y axis computations
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024 - OVERVAL, 127, -127);
  Ystick = constrain(Ystick, -127, 127);
  Joystick.setYAxis(Ystick);
 
  for (int i = 0 ; i < 8 ; i++)
  {
    buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
    if(buttonState[i] != oState[i]) // check against previous button state, if changed do something
    {
      if(buttonState[i] == LOW)     // button has been pressed
      {
        Joystick.pressButton(i);    // press corresponding "joystick" button
      }
      else                          // button has been released
      {
        Joystick.releaseButton(i);  // release corresponding "joystick" button
      }
      oState[i] = buttonState[i];   // save state to compare next time
    }

    Temp = analogRead(A2);
    (Temp < -30) ? buttonState[8] = 1 : buttonState[8] = 0;
    (Temp >  30) ? buttonState[9] = 1 : buttonState[9] = 0;
   
    Temp = analogRead(A3);
    (Temp < -30) ? buttonState[10] = 1 : buttonState[10] = 0;
    (Temp >  30) ? buttonState[11] = 1 : buttonState[11] = 0;
 
    Temp = analogRead(A4);
    (Temp < -30) ? buttonState[12] = 1 : buttonState[12] = 0;
    (Temp >  30) ? buttonState[13] = 1 : buttonState[13] = 0;
 
    Temp = analogRead(A5);
    (Temp < -30) ? buttonState[14] = 1 : buttonState[14] = 0;
    (Temp >  30) ? buttonState[15] = 1 : buttonState[15] = 0;
 
    // Update joystick state
    Joystick.sendState();
  }
}

would someone mind adding a serial print thing to the sketch?  i can only take away or change things in a sketch that's more than about 2 lines :rolleyes:


Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #239 on: Sun, 13 December 2015, 00:46:17 »

I've read here and there people havibg issues with peripherals on Usb3...

yeah me too. i've tried 2.0 on both PCs and get same result.  oh well...

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #240 on: Sun, 13 December 2015, 00:54:53 »
"no serial port name defined" is what I get when there's nothing set in tools -> port.  There's only one entry in the list so you'd think it would default to that but it doesn't.

leonardo doesn't do error message when opening serial monitor.  it opens but nothing appears.  just a blank page when trying before.  the sketch before that wouldn't work was from a tutorial.  the hello world one.  maybe there was something about that sketch that didn't work well with leonardo.
i want to try again with an addition to the sketch we got going. 

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #241 on: Sun, 13 December 2015, 12:18:28 »
would someone mind adding a serial print thing to the sketch?  i can only take away or change things in a sketch that's more than about 2 lines :rolleyes:

Sure :)

Code: [Select]
#define STICK_X A0
#define STICK_Y A1
#define OVERVAL 0

int Xstick;
int Ystick;

int Temp;
int myPins[]          = {0, 1, 2, 3, 4, 5, 6, 7};
boolean buttonState[] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
boolean oState[]      = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

void setup()
{
  for (int i = 0 ; i < 8 ; i++)
  {
    pinMode(myPins[i], INPUT_PULLUP);
  }
 
  Serial.begin(9600);
  Serial.println("Joystick ready");
  Joystick.begin(false);
}

void loop()
{
  // X axis computations
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024 - OVERVAL, -127, 127);
  Xstick = constrain(Xstick, -127, 127);
  Joystick.setXAxis(Xstick);

  // Y axis computations
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024 - OVERVAL, 127, -127);
  Ystick = constrain(Ystick, -127, 127);
  Joystick.setYAxis(Ystick);
 
  for (int i = 0 ; i < 8 ; i++)
  {
    buttonState[i] = digitalRead(myPins[i]); //read physical pin to corresponding buttonState
 
    if(buttonState[i] != oState[i]) // check against previous button state, if changed do something
    {
      if(buttonState[i] == LOW)     // button has been pressed
      {
        Joystick.pressButton(i);    // press corresponding "joystick" button
      }
      else                          // button has been released
      {
        Joystick.releaseButton(i);  // release corresponding "joystick" button
      }
      oState[i] = buttonState[i];   // save state to compare next time
    }

    Temp = analogRead(A2);
    Serial.println(Temp)
    (Temp < -30) ? buttonState[8] = 1 : buttonState[8] = 0;
    (Temp >  30) ? buttonState[9] = 1 : buttonState[9] = 0;
   
    Temp = analogRead(A3);
    (Temp < -30) ? buttonState[10] = 1 : buttonState[10] = 0;
    (Temp >  30) ? buttonState[11] = 1 : buttonState[11] = 0;
 
    Temp = analogRead(A4);
    (Temp < -30) ? buttonState[12] = 1 : buttonState[12] = 0;
    (Temp >  30) ? buttonState[13] = 1 : buttonState[13] = 0;
 
    Temp = analogRead(A5);
    (Temp < -30) ? buttonState[14] = 1 : buttonState[14] = 0;
    (Temp >  30) ? buttonState[15] = 1 : buttonState[15] = 0;
 
    // Update joystick state
    Joystick.sendState();
  }
}

This will spam the serial with the reading from A2, so probaly 0 or max unless it's wired up and you're moving it.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #242 on: Sun, 13 December 2015, 15:21:54 »
Did a quick sketch program that will output the values from A0, A1, A2, A3, A4 and A5 to the serial port every seconds. I've successfully tested it with my Arduino Mega2560 and it workedpush-buttons (so either -127 or 127 reading  :))).

Code: [Select]
// Includes
#include <stdio.h> // In order to use the sprintf() function

// Joysticks pinout
const int _JOY1_XAXIS = A0;
const int _JOY1_YAXIS = A1;
const int _JOY2_XAXIS = A2;
const int _JOY2_YAXIS = A3;
const int _JOY3_XAXIS = A4;
const int _JOY3_YAXIS = A5;

void setup()
{
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop()
{
  // Joystick 1
  int joy1_xvalue = map(analogRead(_JOY1_XAXIS), 0, 1023, -127,  127);
  int joy1_yvalue = map(analogRead(_JOY1_YAXIS), 0, 1023,  127, -127);

  // Joystick 2
  int joy2_xvalue = map(analogRead(_JOY2_XAXIS), 0, 1023, -127,  127);
  int joy2_yvalue = map(analogRead(_JOY2_YAXIS), 0, 1023,  127, -127);

  // Joystick 3
  int joy3_xvalue = map(analogRead(_JOY3_XAXIS), 0, 1023, -127,  127);
  int joy3_yvalue = map(analogRead(_JOY3_YAXIS), 0, 1023,  127, -127);

  // Print the results to the serial monitor:
  char buffer[256];
  sprintf(buffer, "Stick 1: %4d/%4d | Stick 2: %4d/%4d | Stick 3: %4d/%4d", joy1_xvalue, joy1_yvalue, joy2_xvalue, joy2_yvalue, joy3_xvalue, joy3_yvalue);
  Serial.println(buffer);

  // Wait 1 second before the next loop
  delay(1000);
}

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #243 on: Sun, 13 December 2015, 21:39:43 »

Sure :)



This will spam the serial with the reading from A2, so probaly 0 or max unless it's wired up and you're moving it.

thanks pal, really appreciate it as always :-*  this one output this error message.

Code: [Select]
Arduino: 1.6.5 (Windows 7), TD: 1.26, Board: "Arduino Leonardo"

analog_a2_a3_test.ino: In function 'void loop()':
analog_a2_a3_test:56: error: expression cannot be used as a function
expression cannot be used as a function

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

lemme try the one below from GA

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #244 on: Sun, 13 December 2015, 21:45:28 »
Did a quick sketch program that will output the values from A0, A1, A2, A3, A4 and A5 to the serial port every seconds. I've successfully tested it with my Arduino Mega2560 and it workedpush-buttons (so either -127 or 127 reading  :))).


works :thumb:

although i don't know what this stuff means, i hope it does give you guys some info.

the output continues indefinitely, i copied a bunch and here it is:

Code: [Select]
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -39/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -39/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57

that was with me doing nothing. not pressing any buttons or moving analog stick.

i just tried pressing the single button i have connected to pin 0.  but nothing happens in controller properties page.  the analog stick doesn't work at all either (i had it connected to A2-A3 during this serial monitor output recording).  i guess that's probably by design?  let me know if there's something i'm supposed to be doing other than just uploading the sketch and opening serial monitor.
« Last Edit: Sun, 13 December 2015, 21:48:07 by Camineet »

Offline GuilleAcoustic

  • Posts: 77
  • Location: France
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #245 on: Mon, 14 December 2015, 01:58:16 »
works :thumb:

although i don't know what this stuff means, i hope it does give you guys some info.

the output continues indefinitely, i copied a bunch and here it is:

Code: [Select]
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -39/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -39/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -59/  61 | Stick 2:  -40/  49 | Stick 3:  -54/  56
Stick 1:  -60/  62 | Stick 2:  -40/  49 | Stick 3:  -54/  57
Stick 1:  -61/  63 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  58
Stick 1:  -63/  65 | Stick 2:  -40/  49 | Stick 3:  -55/  57
Stick 1:  -62/  64 | Stick 2:  -40/  49 | Stick 3:  -55/  57

that was with me doing nothing. not pressing any buttons or moving analog stick.

i just tried pressing the single button i have connected to pin 0.  but nothing happens in controller properties page.  the analog stick doesn't work at all either (i had it connected to A2-A3 during this serial monitor output recording).  i guess that's probably by design?  let me know if there's something i'm supposed to be doing other than just uploading the sketch and opening serial monitor.

The sketch only outputs values read from the specified analog inputs. Try moving your stick to see if anything changes on the serial output. Just do not move too fast as it reads and print once every 1s. About the button, it is intended as the sketch does nothing on the Joystick axis / button side, just analog read and serial print.

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #246 on: Mon, 14 December 2015, 17:29:39 »
ok guys i got the serial monitor output for ya :D

1st section is /w analog connected to pins A0 A1
2nd section is /w analog connected to pins A2 A3
3rd section is /w analog connected to pins A4 A5

the readout is for the following physical activity I did /w the analog stick in each case the same.

5 seconds of no input from me
5 seconds of me pressing up
5 seconds of no input from me
5 seconds of me pressing down
5 seconds of no input from me
5 seconds of me pressing left
5 seconds of no input from me
5 seconds of me pressing right
10 seconds of me scrambling back to PC to hit control A control C to get the data into windows clipboard


edit: found i had some crossed wires.  re-testing now...

ok, here's it is:

Code: [Select]
Stick 1:  -36/  40 | Stick 2:  -50/  56 | Stick 3:  -59/  61
Stick 1:  -36/  40 | Stick 2:  -50/  56 | Stick 3:  -60/  62
Stick 1:  -36/  40 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:  -36/  40 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:  -36/  40 | Stick 2:  -51/  56 | Stick 3:  -60/  61
Stick 1:  -41/  40 | Stick 2:  -50/  56 | Stick 3:  -59/  60
Stick 1:  -46/ -13 | Stick 2:  -12/  28 | Stick 3:  -39/  45
Stick 1:  -46/ -13 | Stick 2:  -10/  25 | Stick 3:  -36/  42
Stick 1:  -46/ -13 | Stick 2:  -10/  25 | Stick 3:  -36/  42
Stick 1:  -46/ -13 | Stick 2:   -9/  24 | Stick 3:  -35/  42
Stick 1:  -46/ -13 | Stick 2:   -9/  25 | Stick 3:  -36/  43
Stick 1:  -46/  40 | Stick 2:  -48/  53 | Stick 3:  -57/  59
Stick 1:  -46/  40 | Stick 2:  -49/  55 | Stick 3:  -59/  60
Stick 1:  -46/  40 | Stick 2:  -50/  56 | Stick 3:  -60/  62
Stick 1:  -46/  40 | Stick 2:  -51/  56 | Stick 3:  -61/  62
Stick 1:  -46/  40 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:  -46/  42 | Stick 2:  -52/  57 | Stick 3:  -61/  61
Stick 1:  -48/ 102 | Stick 2:  -93/  87 | Stick 3:  -81/  76
Stick 1:  -48/ 102 | Stick 2:  -93/  87 | Stick 3:  -81/  76
Stick 1:  -48/ 102 | Stick 2:  -93/  86 | Stick 3:  -80/  75
Stick 1:  -48/ 102 | Stick 2:  -93/  86 | Stick 3:  -80/  75
Stick 1:  -48/ 102 | Stick 2:  -93/  86 | Stick 3:  -80/  76
Stick 1:  -48/ 103 | Stick 2:  -93/  87 | Stick 3:  -81/  77
Stick 1:  -48/  45 | Stick 2:  -55/  59 | Stick 3:  -62/  63
Stick 1:  -48/  45 | Stick 2:  -55/  59 | Stick 3:  -62/  63
Stick 1:  -48/  45 | Stick 2:  -55/  60 | Stick 3:  -63/  64
Stick 1:  -48/  45 | Stick 2:  -55/  60 | Stick 3:  -63/  64
Stick 1:  -48/  45 | Stick 2:  -55/  60 | Stick 3:  -63/  64
Stick 1:  -99/  32 | Stick 2:  -46/  53 | Stick 3:  -57/  59
Stick 1:  -99/  32 | Stick 2:  -45/  52 | Stick 3:  -56/  57
Stick 1: -100/  32 | Stick 2:  -44/  51 | Stick 3:  -55/  56
Stick 1:  -99/  32 | Stick 2:  -44/  50 | Stick 3:  -54/  55
Stick 1:  -99/  32 | Stick 2:  -44/  50 | Stick 3:  -54/  56
Stick 1:  -51/  40 | Stick 2:  -49/  54 | Stick 3:  -57/  58
Stick 1:  -51/  40 | Stick 2:  -50/  55 | Stick 3:  -58/  60
Stick 1:  -51/  40 | Stick 2:  -50/  56 | Stick 3:  -59/  61
Stick 1:  -51/  40 | Stick 2:  -51/  56 | Stick 3:  -60/  61
Stick 1:  -51/  40 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:   13/  41 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:   13/  41 | Stick 2:  -51/  57 | Stick 3:  -61/  62
Stick 1:   13/  41 | Stick 2:  -51/  56 | Stick 3:  -60/  61
Stick 1:   13/  41 | Stick 2:  -51/  56 | Stick 3:  -59/  60
Stick 1:   13/  41 | Stick 2:  -50/  55 | Stick 3:  -58/  59
Stick 1:   13/  41 | Stick 2:  -50/  55 | Stick 3:  -57/  58
Stick 1:  -33/  45 | Stick 2:  -54/  58 | Stick 3:  -60/  61
Stick 1:  -33/  45 | Stick 2:  -53/  56 | Stick 3:  -58/  59
Stick 1:  -33/  45 | Stick 2:  -54/  58 | Stick 3:  -61/  62
Stick 1:  -33/  45 | Stick 2:  -54/  58 | Stick 3:  -61/  62
Stick 1:  -33/  45 | Stick 2:  -54/  59 | Stick 3:  -62/  63
Stick 1:  -33/  45 | Stick 2:  -55/  60 | Stick 3:  -63/  63
Stick 1:  -33/  45 | Stick 2:  -55/  60 | Stick 3:  -63/  63
Stick 1:  -33/  45 | Stick 2:  -55/  59 | Stick 3:  -62/  62
Stick 1:  -33/  45 | Stick 2:  -54/  58 | Stick 3:  -61/  61
Stick 1:  -33/  45 | Stick 2:  -54/  58 | Stick 3:  -60/  60

Code: [Select]
Stick 1:  -60/  62 | Stick 2:  -53/  40 | Stick 3:  -48/  52
Stick 1:  -61/  64 | Stick 2:  -52/  40 | Stick 3:  -49/  53
Stick 1:  -63/  65 | Stick 2:  -53/  40 | Stick 3:  -49/  54
Stick 1:  -64/  66 | Stick 2:  -53/  40 | Stick 3:  -49/  54
Stick 1:  -63/  65 | Stick 2:  -52/  40 | Stick 3:  -49/  52
Stick 1:  -61/  62 | Stick 2:  -45/ -13 | Stick 3:  -10/  23
Stick 1:  -58/  61 | Stick 2:  -45/ -13 | Stick 3:   -9/  22
Stick 1:  -57/  59 | Stick 2:  -45/ -13 | Stick 3:   -9/  22
Stick 1:  -57/  59 | Stick 2:  -45/ -13 | Stick 3:   -9/  22
Stick 1:  -58/  60 | Stick 2:  -45/ -13 | Stick 3:   -9/  23
Stick 1:  -59/  61 | Stick 2:  -45/  -6 | Stick 3:  -15/  28
Stick 1:  -61/  64 | Stick 2:  -45/  40 | Stick 3:  -47/  52
Stick 1:  -63/  65 | Stick 2:  -45/  40 | Stick 3:  -48/  53
Stick 1:  -63/  65 | Stick 2:  -45/  40 | Stick 3:  -48/  52
Stick 1:  -62/  63 | Stick 2:  -45/  40 | Stick 3:  -48/  52
Stick 1:  -60/  62 | Stick 2:  -46/ 102 | Stick 3:  -89/  81
Stick 1:  -59/  61 | Stick 2:  -45/ 102 | Stick 3:  -90/  82
Stick 1:  -59/  61 | Stick 2:  -45/ 102 | Stick 3:  -90/  83
Stick 1:  -61/  62 | Stick 2:  -45/ 103 | Stick 3:  -91/  84
Stick 1:  -62/  63 | Stick 2:  -45/ 102 | Stick 3:  -91/  85
Stick 1:  -64/  65 | Stick 2:  -45/ 103 | Stick 3:  -92/  86
Stick 1:  -65/  66 | Stick 2:  -44/  45 | Stick 3:  -53/  57
Stick 1:  -63/  65 | Stick 2:  -45/  45 | Stick 3:  -52/  55
Stick 1:  -62/  64 | Stick 2:  -44/  44 | Stick 3:  -52/  54
Stick 1:  -60/  62 | Stick 2:  -45/  45 | Stick 3:  -51/  53
Stick 1:  -59/  62 | Stick 2: -100/  43 | Stick 3:  -50/  53
Stick 1:  -59/  61 | Stick 2: -100/  42 | Stick 3:  -49/  53
Stick 1:  -60/  62 | Stick 2: -100/  42 | Stick 3:  -50/  54
Stick 1:  -61/  63 | Stick 2: -100/  42 | Stick 3:  -50/  54
Stick 1:  -63/  65 | Stick 2: -100/  42 | Stick 3:  -51/  55
Stick 1:  -63/  64 | Stick 2:  -67/  40 | Stick 3:  -49/  53
Stick 1:  -63/  65 | Stick 2:  -50/  41 | Stick 3:  -49/  53
Stick 1:  -62/  64 | Stick 2:  -51/  41 | Stick 3:  -49/  52
Stick 1:  -61/  63 | Stick 2:  -50/  41 | Stick 3:  -48/  51
Stick 1:  -59/  61 | Stick 2:  -49/  41 | Stick 3:  -48/  51
Stick 1:  -58/  58 | Stick 2:   11/  49 | Stick 3:  -54/  56
Stick 1:  -60/  61 | Stick 2:   12/  49 | Stick 3:  -54/  57
Stick 1:  -61/  62 | Stick 2:   12/  49 | Stick 3:  -55/  57
Stick 1:  -63/  64 | Stick 2:   12/  49 | Stick 3:  -55/  58
Stick 1:  -64/  64 | Stick 2:   12/  49 | Stick 3:  -55/  58
Stick 1:  -64/  64 | Stick 2:   13/  49 | Stick 3:  -55/  57
Stick 1:  -63/  64 | Stick 2:  -33/  45 | Stick 3:  -53/  55
Stick 1:  -59/  60 | Stick 2:  -33/  45 | Stick 3:  -50/  53
Stick 1:  -58/  60 | Stick 2:  -33/  45 | Stick 3:  -51/  53
Stick 1:  -59/  61 | Stick 2:  -33/  45 | Stick 3:  -51/  54
Stick 1:  -60/  61 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -61/  63 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -62/  64 | Stick 2:  -33/  45 | Stick 3:  -53/  56
Stick 1:  -63/  65 | Stick 2:  -33/  45 | Stick 3:  -53/  56
Stick 1:  -63/  65 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -63/  64 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -61/  63 | Stick 2:  -33/  45 | Stick 3:  -52/  54
Stick 1:  -60/  61 | Stick 2:  -33/  45 | Stick 3:  -51/  54
Stick 1:  -59/  61 | Stick 2:  -33/  45 | Stick 3:  -51/  54
Stick 1:  -60/  61 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -61/  63 | Stick 2:  -33/  45 | Stick 3:  -52/  55
Stick 1:  -62/  64 | Stick 2:  -33/  45 | Stick 3:  -53/  56
Stick 1:  -63/  65 | Stick 2:  -33/  45 | Stick 3:  -53/  56

Code: [Select]
Stick 1:  -54/  59 | Stick 2:  -64/  66 | Stick 3:  -33/  45
Stick 1:  -54/  58 | Stick 2:  -63/  64 | Stick 3:  -33/  45
Stick 1:  -53/  57 | Stick 2:  -62/  63 | Stick 3:  -33/  45
Stick 1:  -53/  56 | Stick 2:  -61/  62 | Stick 3:  -33/  45
Stick 1:  -52/  56 | Stick 2:  -60/  62 | Stick 3:  -33/  45
Stick 1:  -12/  26 | Stick 2:  -39/  47 | Stick 3:  -42/ -13
Stick 1:  -11/  26 | Stick 2:  -39/  47 | Stick 3:  -42/ -13
Stick 1:  -12/  27 | Stick 2:  -40/  48 | Stick 3:  -43/ -13
Stick 1:  -12/  27 | Stick 2:  -41/  49 | Stick 3:  -43/ -13
Stick 1:  -12/  27 | Stick 2:  -40/  48 | Stick 3:  -43/ -13
Stick 1:  -48/  53 | Stick 2:  -59/  61 | Stick 3:  -43/  39
Stick 1:  -48/  53 | Stick 2:  -58/  61 | Stick 3:  -43/  39
Stick 1:  -48/  53 | Stick 2:  -58/  60 | Stick 3:  -42/  38
Stick 1:  -48/  53 | Stick 2:  -58/  60 | Stick 3:  -43/  39
Stick 1:  -51/  55 | Stick 2:  -60/  63 | Stick 3:  -43/  42
Stick 1:  -91/  85 | Stick 2:  -83/  79 | Stick 3:  -43/  99
Stick 1:  -92/  86 | Stick 2:  -85/  81 | Stick 3:  -50/  99
Stick 1:  -92/  87 | Stick 2:  -85/  81 | Stick 3:  -50/ 100
Stick 1:  -92/  86 | Stick 2:  -85/  81 | Stick 3:  -50/ 100
Stick 1:  -92/  86 | Stick 2:  -84/  80 | Stick 3:  -50/  99
Stick 1:  -54/  57 | Stick 2:  -62/  64 | Stick 3:  -49/  45
Stick 1:  -53/  56 | Stick 2:  -61/  63 | Stick 3:  -49/  45
Stick 1:  -53/  56 | Stick 2:  -61/  63 | Stick 3:  -49/  45
Stick 1:  -53/  57 | Stick 2:  -62/  63 | Stick 3:  -49/  45
Stick 1:  -54/  57 | Stick 2:  -63/  65 | Stick 3:  -49/  45
Stick 1:  -54/  58 | Stick 2:  -64/  66 | Stick 3:  -99/  46
Stick 1:  -55/  59 | Stick 2:  -65/  67 | Stick 3:  -99/  46
Stick 1:  -55/  59 | Stick 2:  -64/  67 | Stick 3:  -99/  46
Stick 1:  -54/  58 | Stick 2:  -63/  66 | Stick 3:  -99/  46
Stick 1:  -54/  58 | Stick 2:  -63/  65 | Stick 3:  -99/  46
Stick 1:  -49/  54 | Stick 2:  -59/  61 | Stick 3:  -52/  40
Stick 1:  -49/  53 | Stick 2:  -59/  61 | Stick 3:  -52/  40
Stick 1:  -49/  53 | Stick 2:  -59/  61 | Stick 3:  -52/  40
Stick 1:  -49/  54 | Stick 2:  -60/  62 | Stick 3:  -52/  40
Stick 1:  -50/  55 | Stick 2:  -60/  63 | Stick 3:  -52/  40
Stick 1:  -50/  55 | Stick 2:  -62/  64 | Stick 3:  -49/  40
Stick 1:  -51/  56 | Stick 2:  -62/  64 | Stick 3:   11/  41
Stick 1:  -51/  56 | Stick 2:  -62/  64 | Stick 3:   12/  41
Stick 1:  -51/  56 | Stick 2:  -62/  63 | Stick 3:   12/  41
Stick 1:  -51/  55 | Stick 2:  -61/  62 | Stick 3:   12/  41
Stick 1:  -50/  55 | Stick 2:  -60/  61 | Stick 3:   13/  41
Stick 1:  -50/  54 | Stick 2:  -59/  60 | Stick 3:   13/  41
Stick 1:  -49/  53 | Stick 2:  -59/  61 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -59/  61 | Stick 3:  -33/  40
Stick 1:  -50/  55 | Stick 2:  -61/  63 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -60/  62 | Stick 3:  -33/  40
Stick 1:  -50/  56 | Stick 2:  -62/  64 | Stick 3:  -33/  40
Stick 1:  -50/  56 | Stick 2:  -62/  64 | Stick 3:  -33/  40
Stick 1:  -50/  56 | Stick 2:  -62/  64 | Stick 3:  -33/  40
Stick 1:  -50/  55 | Stick 2:  -61/  63 | Stick 3:  -33/  40
Stick 1:  -50/  55 | Stick 2:  -60/  62 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -59/  61 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -59/  61 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -59/  61 | Stick 3:  -33/  40
Stick 1:  -49/  54 | Stick 2:  -60/  62 | Stick 3:  -33/  40
« Last Edit: Mon, 14 December 2015, 17:44:32 by Camineet »

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #247 on: Mon, 14 December 2015, 17:33:48 »
let me know if the serial output tells us anything helpful and let me know i should do next.

if it would be helpful, i'm very happy to paypal you guys some funds so you can get a leonardo board and an analog stick to have and test.  that way we can eliminate this problem of you guys not having something to poke at ;D

Offline Camineet

  • Thread Starter
  • Posts: 287
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #248 on: Mon, 14 December 2015, 17:55:54 »
web results of another account of a guy finding that teensy and xpadder are a fail:

https://www.reddit.com/r/arduino/comments/2xn4i0/picked_up_a_teensy_31_and_want_to_use_it_with_an/

no web results found indicating anyone has successfully had teensy input recognized by xpadder.

leonardo certainly is big and clunky compared to teensy, and the firehose of a cable that's going to have to come out of the handset to go to a project box housing leonardo is unfortunate compared to how cool it would be to have teensy integrated into handset with just a usb cable gong from it to the PC, but oh well.

unless i discover some new info, leonardo it is for this project.  maybe in future another try can be had with teensy :)

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: game controller build thread (PS Vita analog stick, Cherry Red, Leonardo, LoL)
« Reply #249 on: Mon, 14 December 2015, 17:57:37 »
Thanks for the offer but I have an Arduino Micro which is basically the same, and an analog stick.  Can I convince a sketch to compile and load for it?  That's another question entirely.  Actually I just tried GuilleAcoustic's serial print and it works!

What you should see in that output is the values for the pins the stick isn't connected to staying nearly the same - whatever they read in their middle position.  The only time you get close to this is if you don't move the stick and in the "stick 1" section of your second chunk.  My output looks similar.

I also have a diode here (one way resistor) and putting that between ground and an analog pin which is giving random values stops it jumping around, so once you get your 3 sticks in place you're good.

Next try - get your proper sketch to compile.  Though what the Linux equivalent of xpadder is I have no idea :P
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod