Your confusion is well-justified
Vehicles, drones and other devices have four operation modes (p. 265):
- Manual Control, which requires physical control, like turning a wheel, hitting buttons or operating levers;
- Remote Control, which happens when you use matrix actions (like Control Device, p238);
- Rigger Control, which happens when a rigger is jumped-in a device;
- Autopilot: The device operate autonomously.
Gunnery is linked to Agility when it requires physical manipulation of a mounted gun, as described by the skill (p. 146):
Gunnery is used when firing any vehicle-mounted weapon, regardless of how or where the weapon is mounted. This skill extends to manual and sensor-enhanced gunnery.
However, on the rules about using Gunnery (p. 183), it clarifies that remote-operated guns will use Logic instead of Agility:
The rules and modifiers for ranged combat apply to vehicle-mounted weapons. Vehicle-mounted weapons are fired using Gunnery + Agility [Accuracy] for manual operation, like door guns on mounts, or Gunnery + Logic [Accuracy] for remote operated systems.
While drones operating autonomously will use [Weapon] + Pilot [Accuracy/Sensor] when attacking, where [Weapon] is the weapon autosoft installed on the drone, and the limit on the check is either the weapon's Accuracy or the drone Sensor if the drone managed to lock on a target (see Sensor Attacks p184).
Drones attack using their Pilot + [Weapon] Targeting autosoft rating (p. 269), limited by Accuracy.
Which leaves us with the question of how Rigger Control works, which can be seen on the matrix chapter under Drone Combat (p. 270):
Rules for drone combat are the same as those for regular flesh-and-blood characters and can be found in the Combat chapter (p. 158). Specific rules for using Gunnery and Sensors in combat can be found there as well (p. 202).
So, not only it gives you the wrong page (202 is about vehicle combat), but doesn't really clarify how riggers do it differently than manual or remote operation.
Additionally, when we read about Remote Control (p. 265) as I mentioned earlier, it points us to the Control Device matrix action (p. 238), which says:
You perform an action through a device you control (or at least control sufficiently), using your commlink or deck like a remote control or video-game controller. The dice pool of any test you make using this action uses the rating of the appropriate skill and attribute you would use if you were performing the action normally. For example, firing a drone-mounted weapon at a target requires a Gunnery + Agility test
Wait, what? Wasn't agility for manual operation and logic for remote operation? Good job, Catalyst.
This topic is frequently discussed when someone creates a rigger (which is often), and the closest we got to an official answer, is a playtester/moderator saying that the rules are in conflict, and as of today, there is no official errata about this.
Fixing this mess
There is blending between the physical attributes and mental attributes that are specific to riggers and wasn't properly addressed by the writters (like astral combat was). You become the machine, and the control rig essentially intercepts your brain's signals to your meat body and returns the signals from the machine as if they came from your meat body.
Using a Logic or Intuition in place of Agility or Reaction is really how they should have done it, and it makes the most sense considering the flavor given to the matrix, virtual realities and how riggers are described to possess their drones.
So, personally, I would use Agility when the operation requires physical control, either manually, or removelly through a physical controller, such as using your commlink, cyberdeck or RCC using augmented reality. And use Logic whenever your character is in full virtual reality, meaning that your muscles have really no importance in whatever you are doing, and all you need is your brain power.
This interpretation is also suggested by the moderator I mentioned earlier. But in the same topic, he also points out that the german version of the game changed it to Gunnery+Agility:
By the way, page 183's German equivalent has Gunnery+Agility so they cleared that out, and unfortunately in the direction I feared.