user1539: I'm stuck, I figured I'd ask here for some help... Note I'm a newb and this is essentially my first Arduino project beyond blink...
I'm creating Virtual cockpit panels for DCS World, using an Arduino Leonardo as an HID device. I'm using three SN74HC165 Shift-In registers for multi-buttons (24) - as it seemed the easiest - and all in all it does work...
So I figured that I'm using only 4 pins on the Leonardo, so why not try to setup 3 of these "shift-in clusters" (12 pins) to appear as 3 separate joysticks?
I got the one working and I got 2 more joysticks showing up in Windows10... now my problem is: how would I setup 2 more "shiftIn Clusters", I've tried many things but I must defer to outside help (cause I really don't know what I'm doing)
Edit to clarify: So each joystick need 3 or 4 shift registers making 24-32 buttons on each joystick
Shift In Lib: https://github.com/…/Ardu…/blob/master/ShiftIn/src/ShiftIn.h
Joy2 Lib: https://github.com/MHeironimus/ArduinoJoystickLibrary
Here's an image of the Layout I want: https://i.imgur.com/eZfMMzI.png
... any help would relieve a great headache, Thank for your time
#include <ShiftIn.h> 
#include <Joystick.h>           

// use <n> shift registers
ShiftIn<3> shift;             // use three shift register


// Create joystick
// TESTING MULTI JOYSTICKS
// 1/3 Works!!!
// 3/3 Appear in Windows
// ????? must add shiftIn sections for 2nd and 3rd joysticks????
// (add pin usage + modify line 77-79 stuff)


#define JOYSTICK_COUNT 3
Joystick_ Joystick[JOYSTICK_COUNT] = {
  Joystick_(0x03, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false), 
  Joystick_(0x04, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false),
  Joystick_(0x05, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false),
};

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
const bool testAutoSendMode = false;

const unsigned long gcCycleDelta = 1000;
const unsigned long gcAnalogDelta = 25;
const unsigned long gcButtonDelta = 500;
unsigned long gNextTime = 0;
unsigned int gCurrentStep = 0;
int gJoystickId = 0;



/*
// WORKING SECTION Single Joystick with Shift Reg
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD,
  32, 0,                        // Button Count, Hat Switch Count
  false, false, false,          // X and Y, but no Z Axis
  false, false, false,          // No Rx, Ry, or Rz
  false, false,                 // No rudder or throttle
  false, false, false);         // No accelerator, brake, or steering
*/



void setup() {

  shift.begin(8, 9, 11, 12);  // set pins of the shift register
//  shift[1].begin(7, 6, 5, 4);  // set pins of the shift register
//  shift[2].begin(3, 2, 1, 0);  // set pins of the shift register

 Joystick[0].begin();
 Joystick[1].begin();
 Joystick[2].begin();
}


void loop() {

  if (shift.update()) {
    for (int i = 0; i < shift.getDataWidth(); i++)
    Joystick[0].setButton(i, shift.state(i));            // just press or release the button
  }
/*if (shift[1].update()) {
    for (int i = 0; i < shift[1].getDataWidth(); i++)
    Joystick[0].setButton(i, shift[1].state(i));            // just press or release the button
  }
if (shift[2].update()) {
    for (int i = 0; i < shift[2].getDataWidth(); i++)
    Joystick[0].setButton(i, shift[2].state(i));            // just press or release the button
  }
  delay(10);
*/ 
}


user4143: Each ShiftIn instance handles just one connection. You need to make multiple instances.
ShiftIn shift1<3>;
ShiftIn shift2<3>;
ShiftIn shift3<3>;

Then you begin each of them:
void setup() {      
    shift1.begin(8, 9, 11, 12); 
    shift2.begin(7, 6, 5, 4); 
    shift3.begin(3, 2, 1, 0);
    ... etc ...
}

Each shiftx is a completely separate entity. You can just repeat your block of code for each shift object:
if (shift1.update()) {
    for (int i = 0; i < shift1.getDataWidth(); i++)
    Joystick[0].setButton(i, shift1.state(i)); 
}

if (shift2.update()) {
    for (int i = 0; i < shift2.getDataWidth(); i++)
    Joystick[1].setButton(i, shift2.state(i)); 
}

if (shift3.update()) {
    for (int i = 0; i < shift3.getDataWidth(); i++)
    Joystick[2].setButton(i, shift3.state(i)); 
}

You could arrange the ShiftIn objects into an array like you do with your Joystick objects and then loop through them, but that is pretty pointless for just three of them. 

1539: <p>I'm stuck, I figured I'd ask here for some help... Note I'm a newb and this is essentially my first Arduino project beyond blink...</p>

<p>I'm creating Virtual cockpit panels for DCS World, using an Arduino Leonardo as an HID device. I'm using three SN74HC165 Shift-In registers for multi-buttons (24) - as it seemed the easiest - and all in all it does work...</p>

<p>So I figured that I'm using only 4 pins on the Leonardo, so why not try to setup 3 of these "shift-in clusters" (12 pins) to appear as 3 separate joysticks?</p>

<p>I got the one working and I got 2 more joysticks showing up in Windows10... now my problem is: how would I setup 2 more "shiftIn Clusters", I've tried many things but I must defer to outside help (cause I really don't know what I'm doing)</p>

<p>Edit to clarify: So each joystick need 3 or 4 shift registers making 24-32 buttons on each joystick</p>

<p>Shift In Lib: <a href="https://github.com/" rel="nofollow noreferrer">https://github.com/</a>…/Ardu…/blob/master/ShiftIn/src/ShiftIn.h</p>

<p>Joy2 Lib: <a href="https://github.com/MHeironimus/ArduinoJoystickLibrary" rel="nofollow noreferrer">https://github.com/MHeironimus/ArduinoJoystickLibrary</a></p>

<p>Here's an image of the Layout I want: <a href="https://i.imgur.com/eZfMMzI.png" rel="nofollow noreferrer">https://i.imgur.com/eZfMMzI.png</a></p>

<p>... any help would relieve a great headache, Thank for your time</p>

<pre><code>#include &lt;ShiftIn.h&gt; 
#include &lt;Joystick.h&gt;           

// use &lt;n&gt; shift registers
ShiftIn&lt;3&gt; shift;             // use three shift register


// Create joystick
// TESTING MULTI JOYSTICKS
// 1/3 Works!!!
// 3/3 Appear in Windows
// ????? must add shiftIn sections for 2nd and 3rd joysticks????
// (add pin usage + modify line 77-79 stuff)


#define JOYSTICK_COUNT 3
Joystick_ Joystick[JOYSTICK_COUNT] = {
  Joystick_(0x03, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false), 
  Joystick_(0x04, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false),
  Joystick_(0x05, JOYSTICK_TYPE_GAMEPAD, 32, 0, false, false, false, false, false, false, false, false, false, false, false),
};

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
const bool testAutoSendMode = false;

const unsigned long gcCycleDelta = 1000;
const unsigned long gcAnalogDelta = 25;
const unsigned long gcButtonDelta = 500;
unsigned long gNextTime = 0;
unsigned int gCurrentStep = 0;
int gJoystickId = 0;



/*
// WORKING SECTION Single Joystick with Shift Reg
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD,
  32, 0,                        // Button Count, Hat Switch Count
  false, false, false,          // X and Y, but no Z Axis
  false, false, false,          // No Rx, Ry, or Rz
  false, false,                 // No rudder or throttle
  false, false, false);         // No accelerator, brake, or steering
*/



void setup() {

  shift.begin(8, 9, 11, 12);  // set pins of the shift register
//  shift[1].begin(7, 6, 5, 4);  // set pins of the shift register
//  shift[2].begin(3, 2, 1, 0);  // set pins of the shift register

 Joystick[0].begin();
 Joystick[1].begin();
 Joystick[2].begin();
}


void loop() {

  if (shift.update()) {
    for (int i = 0; i &lt; shift.getDataWidth(); i++)
    Joystick[0].setButton(i, shift.state(i));            // just press or release the button
  }
/*if (shift[1].update()) {
    for (int i = 0; i &lt; shift[1].getDataWidth(); i++)
    Joystick[0].setButton(i, shift[1].state(i));            // just press or release the button
  }
if (shift[2].update()) {
    for (int i = 0; i &lt; shift[2].getDataWidth(); i++)
    Joystick[0].setButton(i, shift[2].state(i));            // just press or release the button
  }
  delay(10);
*/ 
}
</code></pre>
 4143: <p>Each <code>ShiftIn</code> instance handles just one connection. You need to make multiple instances.</p>

<pre><code>ShiftIn shift1&lt;3&gt;;
ShiftIn shift2&lt;3&gt;;
ShiftIn shift3&lt;3&gt;;
</code></pre>

<p>Then you <code>begin</code> each of them:</p>

<pre><code>void setup() {      
    shift1.begin(8, 9, 11, 12); 
    shift2.begin(7, 6, 5, 4); 
    shift3.begin(3, 2, 1, 0);
    ... etc ...
}
</code></pre>

<p>Each <code>shiftx</code> is a completely separate entity. You can just repeat your block of code for each <code>shift</code> object:</p>

<pre><code>if (shift1.update()) {
    for (int i = 0; i &lt; shift1.getDataWidth(); i++)
    Joystick[0].setButton(i, shift1.state(i)); 
}

if (shift2.update()) {
    for (int i = 0; i &lt; shift2.getDataWidth(); i++)
    Joystick[1].setButton(i, shift2.state(i)); 
}

if (shift3.update()) {
    for (int i = 0; i &lt; shift3.getDataWidth(); i++)
    Joystick[2].setButton(i, shift3.state(i)); 
}
</code></pre>

<p>You could arrange the <code>ShiftIn</code> objects into an array like you do with your <code>Joystick</code> objects and then loop through them, but that is pretty pointless for just three of them. </p>
