It can be said, with a good degree of certainty, that there is basically no connection between the medieval and modern attitudes towards the possession and usage of the firearms or weapons in general, as the limitation on firearms (or weapon) possession, although present in the past, were largely a product of modern era, as a response to increased density of population and sophistication of societal systems, additionally facilitated by the relatively frequent changes of legal systems.
I believe that we need to address the assumption that the possession of weapons in the Middle Ages (what by definition limits the territorial scope of the discussed phenomenon to Europe) was generally not subjected to restrictions, with the main factor influencing the possession being the physical and economical accessibility and, on some occasion, sumptuary laws forbidding e.g. non-nobles from carrying (not necessarily possessing) swords that could have been considered a mark of knightly status. This did not, however, forbid anyone from possessing and using equally or even more efficient weapons. In some areas, where common defense systems were present, such as remnants of fyrd in England, possession of specified weapons and armour was mandatory among all people owning or holding land of specified value. In addition, although after the crystallization of the knightly class, the military defense was generally provided by the landowners (noble or otherwise) offering their martial services to their seniors, villages were largely self-reliant when it came to protection of peace and order, and thus local peasants were generally expected to capture or fend off criminals on their own, as the landowners were not always available or capable of allocating resources necessary for punitive actions. Thus, rural commoners usually had at least some weapons that could have proven useful against unarmored opponents, with the quality and type of such armaments being limited more by their availability and price rather than anything else.
In the time of rapid urbanization between 12th and 16th century, many cities required their citizens possessing a real estate within city walls to possess specific set of weapons, often including a bow, crossbow or (in later centuries) a firearm, ammunition and armour under an assumption that every able-bodied burgher should contribute to the defense of the city and an inability to procure prescribed weapons could have resulted in the revocation of the burgher status (essentially meaning social demotion). With the rising population of the cities in the 14th and 15th century, the local authorities started to introduced various restrictions concerning public carrying of the weapons, as was the case in Cologne in 1400, although mere possession of such items was in no way restricted. Similarly, an edict of Charles IX issued on 28th September 1563 stated that no one is to carry loaded firearms unless specifically permitted by relevant authorities, although the law did not limit the possession of such weapons.
Polish-Lithuanian Commonwealth in XVI-XVIII century although introduced sumptuary laws prohibiting non-nobles from carrying sabres and wearing distinctive clothing typical of a nobleman and had some laws regulating carrying of weapons in specific places, such as ban on public carrying of warhammers and picks outside military setting, introduced in w 1578 and repeated in 1601 and 1620 (what did not discourage one of the nobles to use such a weapon in an unsuccessful regicide attempt in the latter year), it did not have any laws regarding possession or carrying weapons in general, what included firearms. The ban on carrying sabres is thus generally interpreted as a mean to discourage impersonation of the nobility in the era predating ubiquitous personal documents, directly mirroring similar regulations concerning certain clothing elements (e.g. belts commonly worn by knights) present in medieval Europe.
One of the first modern European regulations concerning the possession of firearms was an Imperial Arms Patent introduced on 24th October 1852 in Austria that created provisions not dissimilar to those found in present regulations. It made a distinction between 'permitted' and 'forbidden' weapons. The former were not specified explicitly, but the executive documents to the main Act strongly suggest that they covered short firearms (pistols and revolvers, save for those used in military) and all hunting weapons, while the latter included grenades and other explosives, blunderbusses, high-caliber pistols and military rifles, but also weapons (both bladed and firearms) hidden inside inconspicuous items, daggers, epees and airguns (the latter meant, of course, lethal weapons like those designed by Girandoni or Pritchard, not modern recreational plinkers). The 'permitted' weapons could have been generally bought and possessed without any permission but carrying them in public required one. In addition, the act made it illegal for people without a documented source of income or residence, alcoholics and people found to be mentally ill from possession of any sort of firearm. Similar provisions requiring the firearms owners to register already owned weapons and get a permit to buy one were introduced in German Empire in a Weapons and Explosives Act of 9th June 1884, although This particular legislative document was focused on the sales of weapons and the possession of explosives. This was followed by more detailed regulations, such as so-called Tagantsev's Code introduced in the Russian Empire in 1903 detailed not only the rules for possession and sales of firearms, but also regulated safe usage of such weapons, stating limits of the amount of gunpowder and other propellants outside of warehouses (to 30 pounds, more than enough for any domestic use), 'careless handling of a firearm' or 'using the firearms in places not suited for such activity'.
It is also worth noting that the control of the firearms possession could have been far from uniform. For example, in Russian Empire that generally was considered a country where the discussed regulation were considered relatively restrictive, they might have been enforced in densely populated areas, such as large cities, while being ignored or possibly not even known in rural Siberia where hunting was a mainstay of local population that used it as a means of procuring food and trading goods. For example, young Iosif Stalin, when exiled to the Monastyrkoye village in Turukhansk Region (Central Siberia) got in conflict with a gendarme assigned to guard him (essentially being responsible for keeping the exiles in his area accounted for) over the possession of a shotgun. Being an exile (and thus a convicted criminal) Stalin theoretically did not have a right to possess or carry a firearm but he complained to the authorities that the aforementioned officer makes it hard for him to procure food and help locals in hunting and the authorities supported this complaint.
The diversified approach to the possession of firearms was heavily influenced by the complex national and political composition of the 19th century European empires. Being largely multi-ethnic, expansive monarchies, they experienced serious tensions, especially in the recently annexed areas. This caused the differentiated approach to the discussed question. Local nobility, industrialists, officials or, in general, representatives of the domestic middle class generally had unrestricted access to the firearms save for the military ones (but even then, no one controlled what such do have in their homes). On the other hand, people in the aforementioned recently annexed territories, especially those where national or independentist ideas were common, became a subject to administrative measures aimed at disarmament of the population. For example, Russian administration on former Polish territories introduced mass confiscation of any firearms, including historical ones, starting in mid-1861 and increasing the efforts after the suppression of January Uprising of 1863-1864. In other words, while Russian nobles could have owned whatever they wanted, and Russian rural hunters were not bothered by authorities (illegal possession of smoothbore hunting weapons was considered a breach of an administrative procedures rather than a crime even in Soviet era), Polish nobles were facing the possibility of fines, imprisonment or even exile for firearms possession.