XIM Community

Tut: Microcontrollers as a HID device(s) on XIM adapters.  (Read 66235 times)

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #330 on: 05:45 PM - 06/06/15 »
np  ;)

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #331 on: 02:56 PM - 08/04/15 »
Could I use W11ce's package, teensy 3.1 and wii nunchuk to replace my NAV much like this post but for joystick instead of mouse?

http://www.instructables.com/id/USB-Mouse-Made-Out-Of-A-Wii-Nunchuck/?ALLSTEPS

Also seen this wiichuck that enables I2c use which appears supported by teensy

http://proto-pic.co.uk/wiichuck-adapter/
« Last Edit: 03:28 AM - 08/05/15 by DomA »
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #332 on: 12:45 PM - 08/05/15 »
Yeah, Either way should be possible.

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #333 on: 04:24 PM - 08/05/15 »
Thanks, teensy 3.1 ordered, going to try the dismantle route
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #334 on: 05:34 PM - 08/07/15 »
I'm nearly there with the nunchuck but my Y AXIS is inverted, could someone tell me exactly what to add to the Y axis line please;

// Pin 13 has the LED on Teensy 3.1
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
}

// the loop routine runs over and over again forever:
void loop() {
  Joystick.X(analogRead(0));
  Joystick.Y(analogRead(1));
  Joystick.button(1, !digitalRead(0));
  Joystick.button(2, !digitalRead(1));
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
}
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #335 on: 07:21 AM - 08/08/15 »
Code: [Select]
Joystick.Y(1023 - analogRead(1));This inverts it.
And as always, some pics please.

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #336 on: 09:43 AM - 08/08/15 »
Super thankyou, that fixed my axis, now I'll try and work out how and why :)



One last question : the Z and C buttons on the nunchuck are on a single pcb - very left in pic, with a shared ground. My Z button works with the code as expected but the C button is always on and can't be changed, any ideas?

Dom
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #337 on: 10:50 AM - 08/09/15 »
Dow did you wire it? Looking from the picture looks like you did not wire the button pcb directly to teensy.

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #338 on: 11:46 AM - 08/09/15 »
Yeah, the button PCB was wired to the main PCB so took it from there, I'll cut those and go back directly to the button PCB.

However, I've been thinking about the use of the INPUT_PULLUP voltage would that cause a problem if the ground is shared?
« Last Edit: 11:52 AM - 08/09/15 by DomA »
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #339 on: 12:52 PM - 08/09/15 »
No, thats how buttons are usually wired. Just separate the button pcb from the main board and wire the ground and pins to teensy.

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #340 on: 02:55 PM - 08/11/15 »
Thanks again, all done and working fine now, will assemble it all soon. I'm just waiting for some momentary buttons to arrive, going to put 2 on the side for 3rd and 4th fingers and then I'll be done.

PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #341 on: 02:38 PM - 08/17/15 »
Well I've wired it all up, just went for the single side button in the end which i'm using in place of the missing joystick down button.

One thing I have noticed is that joystick up and down doesn't work in the in-game menu for BF-HL. It works fine in game and on the Playstation home screen so I've just mapped a couple of the mouse buttons to take care of this.



Thanks again W11ce, Dom.
« Last Edit: 04:19 AM - 08/18/15 by DomA »
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #342 on: 02:56 PM - 08/29/15 »
Well done :)
The menus not working might be because the joystick value does not go to the max or min at all. You can fix it by scaling the axes. Here is an example on how to do it:
Code: [Select]
#define STICK_X 0
#define STICK_Y 1

#define OVERVAL 256
int Xstick;
int Ystick;



void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
}

void loop() {
 
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, 0, 1024);
  Xstick = constrain(Xstick, 0 , 1023);
  Joystick.X(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 1024, 0);
  Ystick = constrain(Ystick, 0 , 1023);
  Joystick.Y(Ystick);

  Joystick.button(1, !digitalRead(0));
  Joystick.button(2, !digitalRead(1));
 
}

Offline DomA

  • Member
  • *
  • Posts: 196
    • View Profile
    • Youtube
  • PSN ID: DomAll
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #343 on: 01:36 PM - 09/19/15 »
I made the changes and unfortunately it still doesn't work in the menus. Also noticed that it won't let me move to a vehicle when on the spawn map.

// Pin 13 has the LED on Teensy 3.1 give it a name
int led = 13;
//define STICK_X 0
//define STICK_Y 1
//define OVERVAL 256
int Xstick;
int Ystick;
int OVERVAL;
int STICK_X = 0;
int STICK_Y = 1;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  // initialize the digital pins as inputs.
  pinMode(led, OUTPUT);     
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
}

// the loop routine runs over and over again forever:
void loop() {
//  Joystick.X(analogRead(0));
//  Joystick.Y(1023 - analogRead(1));
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, 0, 1024);
  Xstick = constrain(Xstick, 0 , 1023);
  Joystick.X(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 1024, 0);
  Ystick = constrain(Ystick, 0 , 1023);
  Joystick.Y(Ystick);
  Joystick.button(1, !digitalRead(0));
  Joystick.button(2, !digitalRead(1));
  Joystick.button(3, !digitalRead(2));
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
}


Should I change the overval line to int OVERVAL=256; ?
Thanks
Dom
PS3/PS4 2tb - XIM4 - G502 - Nav - Optoma HD141X - HD598 - Mixamp - Hauppauge HD PVR Rocket

http://www.twitch.tv/snafudom/
https://www.youtube.com/user/snafudom/

Offline W11cE

  • MVP
  • *
  • Posts: 1519
    • View Profile
Re: Tut: Microcontrollers as a HID device(s) on XIM adapters.
« Reply #344 on: 11:36 AM - 09/28/15 »
Sorry, forgot to answer. Why have you exluded #defines?

It should be like this:

Code: [Select]
// Pin 13 has the LED on Teensy 3.1 give it a name
int led = 13;
#define STICK_X 0
#define STICK_Y 1
#define OVERVAL 256
int Xstick;
int Ystick;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  // initialize the digital pins as inputs.
  pinMode(led, OUTPUT);     
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
}

// the loop routine runs over and over again forever:
void loop() {
  Xstick = map(analogRead(STICK_X), OVERVAL, 1024-OVERVAL, 0, 1024);
  Xstick = constrain(Xstick, 0 , 1023);
  Joystick.X(Xstick);
  Ystick = map(analogRead(STICK_Y), OVERVAL, 1024-OVERVAL, 1024, 0);
  Ystick = constrain(Ystick, 0 , 1023);
  Joystick.Y(Ystick);
  Joystick.button(1, !digitalRead(0));
  Joystick.button(2, !digitalRead(1));
  Joystick.button(3, !digitalRead(2));
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
}

Sure you can change those to int also if you want, but previously the OVERVAL was 0. That means nothing was changed in behaviour.


Admin