void add(int& bob) { if(bob < 90) bob++; } void sub(int& bob) { if (bob > 0) bob--; } void motion(unsigned char key) { switch (key) { case 't':add(angle[3][2]);break; // pinkie case 'T':sub(angle[3][2]);break; case 'g':add(angle[3][1]);break; case 'G':sub(angle[3][1]);break; case 'b':add(angle[3][0]);break; case 'B':sub(angle[3][0]);break; case 'r':add(angle[2][2]);break; // ring case 'R':sub(angle[2][2]);break; case 'f':add(angle[2][1]);break; case 'F':sub(angle[2][1]);break; case 'v':add(angle[2][0]);break; case 'V':sub(angle[2][0]);break; case 'e':add(angle[1][2]);break; // middle case 'E':sub(angle[1][2]);break; case 'd':add(angle[1][1]);break; case 'D':sub(angle[1][1]);break; case 'c':add(angle[1][0]);break; case 'C':sub(angle[1][0]);break; case 'w':add(angle[0][2]);break; // index case 'W':sub(angle[0][2]);break; case 's':add(angle[0][1]);break; case 'S':sub(angle[0][1]);break; case 'x':add(angle[0][0]);break; case 'X':sub(angle[0][0]);break; case 'q':add(angle[4][2]);break; // thumb case 'Q':sub(angle[4][2]);break; case 'a':add(angle[4][1]);break; case 'A':sub(angle[4][1]);break; case 'z':add(angle[4][0]);break; case 'Z':sub(angle[4][0]);break; case 'y': add(spread[4]);break; // thumb spread case 'Y': sub(spread[4]);break; case 'u': add(spread[3]);break; // index spread case 'U': sub(spread[3]);break; case 'i': add(spread[2]);break; // middle spread case 'I': sub(spread[2]);break; case 'o': add(spread[1]);break; // ring spread case 'O': sub(spread[1]);break; case 'p': add(spread[0]);break; // pinkie spread case 'P': sub(spread[0]);break; } }Motion makes small changes (one degree at a time) to the finger angles. Each key is a shortcut to a certain joint. imagine placing your right hand on the keyboard, aligned to the left so your thumb fills the far left column of keys. Those three keys, q, a, z, change the angle of the thumb. The next column change the index finger, etc, until t, g, b, change the pinkie angles. when the key is pressed, it reduces the angle of the joint, making a fist. When the capital of the same letter (<shift> + that letter) is pressed, the joint strightens, both one degree at a time. That is what the helper functions add and sub do. They are called, and add or subtract one degree to the sent joint. They also limit the angles of the joints to between straight (no overextension) and 90 degrees bent. The spread is modified in a similar fasion through the keys y, u, i, o, and p.