Incidentally, I have done exactly what you are trying to do. The only catch is I was using Jbox2d so the code is in Java, but you should still be able to figure it out if you are using C++
You basically need to use joints/motors and all that fun stuff if you want to do swinging action. Here's a snippet of what my code looks like based on the key input:
if (myinput.mouse0) {
agents.get(0).rightForeJoint.enableMotor(true);
agents.get(0).rightArmJoint.enableMotor(false);
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)){
agents.get(0).rightForeJoint.enableMotor(false);
}
mouseY = Mouse.getY();
mouseX = Mouse.getX();
float temp = mouseY - prevPos[1];
float temp2 = -mouseX + prevPos[0];
temp2 *= modifier; temp2 *= 0.000026;
temp *= modifier; temp *= 0.000030;
agents.get(0).armR.applyAngularImpulse(-temp);
agents.get(0).foreR.applyAngularImpulse(temp2);
prevPos[1] = mouseY;
prevPos[0] = mouseX;
if(temp2 < 0){
temp2 *=-1;
}
if(temp < 0){
temp *=-1;
}
fatigueDrain += temp2;
fatigueDrain += temp;
}
And then as far as actually building the arms and whatnot, the snippet looks like this.
// RIGHTARM //
this.rightArmDef = new RevoluteJointDef();
this.rightArmDef.bodyA = this.torso ; this.rightArmDef.bodyB = this.armR;
this.rightArmDef.collideConnected = false;
torso_armL_pin = new Vec2(0.50f, +0.05f);
local_armL_pin = new Vec2(0.14f, 0.14f);
this.rightArmDef.localAnchorA.set(this.torso.getLocalCenter().add(torso_armL_pin));
this.rightArmDef.localAnchorB.set(this.armR.getLocalCenter().add(local_armL_pin));
this.rightArmDef.enableMotor = true;
this.rightArmDef.motorSpeed = 0f;
this.rightArmDef.maxMotorTorque =10f;
this.rightArmDef.enableLimit = true;
this.rightArmDef.lowerAngle = 1.2f;// * DEGTORAD;
this.rightArmDef.upperAngle = 5;
this.rightArmJoint = (RevoluteJoint)world.createJoint(this.rightArmDef);
I realize there is a lot going on here, but its probably easier if you just ask me what you need clarity on and I explain it. If you have never used any of these things though, you will probably need to do a fair bit of reading.
EDIT>>
Realize, Box2d has all of the collision detection and physics built clean into its libraries. Take it on faith when I say, it is easier to figure out their system than try and do things from scratch. If you want collision, you use fixtures bodydefs, if you want them to rotate or move, you use joints. It may seem a little more complicated at first, but in the end it saves you infinitely more time to use their methods.
In fact, I would suggest that you probably will never finish if you try and do things from scratch, assuming you are creating a physics game. Because computing things like friction, buoyancy and not to mention, /efficient/ collision detection, is going to take you a lifetime.