Handle libspnav login on FreeBSD just like on Linux

FreeBSD uses libspnav, just like a Linux does, so all the
conditional code addressing the spnav APIs should be used
on FreeBSD, too.
Unfortunately, the logic was not consistent in all places:
sometimes we had "#ifdef", sometimes "#if defined" and
sometimes it was negated as "#ifndef". To make the intention
clearer across both Linux and FreeBSD, I unified all places
to a "#if defined(__linux__) || defined(__FreeBSD__)".
If we get another OS latching onto the same logic, we should
introduce a simple flag for this, but for only two OSes I
decided against adding central logic for this.
This commit is contained in:
Christoph Moench-Tegeder
2026-02-16 21:22:51 +01:00
committed by Ian McInerney
parent f16fbbb061
commit 129995acbd
14 changed files with 66 additions and 66 deletions
+2 -2
View File
@@ -62,7 +62,7 @@
#include <project_pcb.h>
#include <toolbars_3d.h>
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <spacenav/libspnav_driver.h>
#include <3d_spacenav/spnav_viewer_plugin.h>
#else
@@ -198,7 +198,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
try
{
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_VIEWER_PLUGIN>( m_canvas );
#else
m_spaceMouse = std::make_unique<NL_3D_VIEWER_PLUGIN>( m_canvas );
+2 -2
View File
@@ -44,7 +44,7 @@
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
// Forward declarations
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_VIEWER_PLUGIN;
#else
class NL_3D_VIEWER_PLUGIN;
@@ -280,7 +280,7 @@ private:
bool m_disable_ray_tracing;
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_VIEWER_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_3D_VIEWER_PLUGIN> m_spaceMouse;
+6 -6
View File
@@ -48,10 +48,10 @@
#include <eda_3d_viewer_settings.h>
#include <board_design_settings.h>
#ifndef __linux__
#include <3d_navlib/nl_footprint_properties_plugin.h>
#else
#if defined(__linux__) || defined(__FreeBSD__)
#include <3d_spacenav/spnav_viewer_plugin.h>
#else
#include <3d_navlib/nl_footprint_properties_plugin.h>
#endif
PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
@@ -137,10 +137,10 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
try
{
#ifndef __linux__
m_spaceMouse = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN>( m_previewPane );
#else
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_VIEWER_PLUGIN>( m_previewPane );
#else
m_spaceMouse = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN>( m_previewPane );
#endif
m_spaceMouse->SetFocus( true );
}
+6 -6
View File
@@ -63,10 +63,10 @@ class EMBEDDED_FILES;
class BOARD;
class BOARD_ADAPTER;
class FOOTPRINT;
#ifndef __linux__
class NL_FOOTPRINT_PROPERTIES_PLUGIN;
#else
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_VIEWER_PLUGIN;
#else
class NL_FOOTPRINT_PROPERTIES_PLUGIN;
#endif
#define PANEL_PREVIEW_3D_MODEL_ID wxID_HIGHEST + 1244
@@ -233,10 +233,10 @@ private:
/// The 3d viewer Render initial settings (must be saved and restored)
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender;
#ifndef __linux__
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
#else
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_VIEWER_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
#endif
};
+2 -2
View File
@@ -1391,7 +1391,7 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
return new PANEL_MOUSE_SETTINGS( aParent );
}, _( "Mouse and Touchpad" ) );
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
book->AddLazyPage(
[] ( wxWindow* aParent ) -> wxWindow*
{
@@ -1898,4 +1898,4 @@ void EDA_BASE_FRAME::OnLanguageSelectionEvent( wxCommandEvent& event )
// tell all the KIWAY_PLAYERs about the language change.
Kiway().SetLanguage( id );
}
}
+2 -2
View File
@@ -24,7 +24,7 @@
#ifndef KICAD_LIBSPNAV_DRIVER_H
#define KICAD_LIBSPNAV_DRIVER_H
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <spnav.h>
#endif
@@ -52,4 +52,4 @@ private:
bool m_client_connected = false;
};
#endif // KICAD_LIBSPNAV_DRIVER_H
#endif // KICAD_LIBSPNAV_DRIVER_H
+6 -6
View File
@@ -68,11 +68,11 @@
#include <wx/msgdlg.h>
#include <trace_helpers.h>
#ifndef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <spacenav/spnav_2d_plugin.h>
#else
#include <navlib/nl_schematic_plugin.h>
#include <wx/fdrepdlg.h>
#else
#include <spacenav/spnav_2d_plugin.h>
#endif
@@ -341,11 +341,11 @@ void SCH_BASE_FRAME::ActivateGalCanvas()
{
if( !m_spaceMouse )
{
#ifndef __linux__
m_spaceMouse = std::make_unique<NL_SCHEMATIC_PLUGIN>();
#else
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( GetCanvas() );
m_spaceMouse->SetScale( schIUScale.IU_PER_MILS / pcbIUScale.IU_PER_MILS );
#else
m_spaceMouse = std::make_unique<NL_SCHEMATIC_PLUGIN>();
#endif
}
+6 -6
View File
@@ -59,10 +59,10 @@ class EESCHEMA_SETTINGS;
class SYMBOL_EDITOR_SETTINGS;
struct SCH_SELECTION_FILTER_OPTIONS;
#ifndef __linux__
class NL_SCHEMATIC_PLUGIN;
#else
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_2D_PLUGIN;
#else
class NL_SCHEMATIC_PLUGIN;
#endif
class PANEL_SCH_SELECTION_FILTER;
@@ -329,10 +329,10 @@ private:
wxTimer m_watcherDebounceTimer;
bool m_inSymChangeTimerEvent;
#ifndef __linux__
std::unique_ptr<NL_SCHEMATIC_PLUGIN> m_spaceMouse;
#else
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_SCHEMATIC_PLUGIN> m_spaceMouse;
#endif
};
+6 -6
View File
@@ -60,10 +60,10 @@
#include "widgets/dcode_selection_box.h"
#include <dialog_draw_layers_settings.h>
#ifndef __linux__
#include <navlib/nl_gerbview_plugin.h>
#else
#if defined(__linux__) || defined(__FreeBSD__)
#include <spacenav/spnav_2d_plugin.h>
#else
#include <navlib/nl_gerbview_plugin.h>
#endif
#include <wx/log.h>
@@ -1057,11 +1057,11 @@ void GERBVIEW_FRAME::ActivateGalCanvas()
{
if( !m_spaceMouse )
{
#ifndef __linux__
m_spaceMouse = std::make_unique<NL_GERBVIEW_PLUGIN>();
#else
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( galCanvas );
m_spaceMouse->SetScale( gerbIUScale.IU_PER_MILS / pcbIUScale.IU_PER_MILS );
#else
m_spaceMouse = std::make_unique<NL_GERBVIEW_PLUGIN>();
#endif
}
+6 -6
View File
@@ -46,10 +46,10 @@ class REPORTER;
class SELECTION;
class wxStaticText;
#ifndef __linux__
class NL_GERBVIEW_PLUGIN;
#else
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_2D_PLUGIN;
#else
class NL_GERBVIEW_PLUGIN;
#endif
@@ -528,10 +528,10 @@ private:
wxStaticText* m_dcodeText; // a message on the auxiliary toolbar,
// relative to the m_DCodeSelector
#ifndef __linux__
std::unique_ptr<NL_GERBVIEW_PLUGIN> m_spaceMouse;
#else
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_GERBVIEW_PLUGIN> m_spaceMouse;
#endif
};
+6 -6
View File
@@ -63,10 +63,10 @@ struct MAGNETIC_SETTINGS;
class PROGRESS_REPORTER;
class PCB_LAYER_BOX_SELECTOR;
#ifndef __linux__
class NL_PCBNEW_PLUGIN;
#else
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_2D_PLUGIN;
#else
class NL_PCBNEW_PLUGIN;
#endif
#ifdef wxHAS_INOTIFY
@@ -438,10 +438,10 @@ protected:
PCB_ORIGIN_TRANSFORMS m_originTransforms;
private:
#ifndef __linux__
std::unique_ptr<NL_PCBNEW_PLUGIN> m_spaceMouse;
#else
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_PCBNEW_PLUGIN> m_spaceMouse;
#endif
std::unique_ptr<wxFileSystemWatcher> m_watcher;
+6 -6
View File
@@ -66,10 +66,10 @@
#include <wx/log.h>
#include <kiplatform/ui.h>
#ifndef __linux__
#include <navlib/nl_pl_editor_plugin.h>
#else
#if defined(__linux__) || defined(__FreeBSD__)
#include <spacenav/spnav_2d_plugin.h>
#else
#include <navlib/nl_pl_editor_plugin.h>
#endif
@@ -241,11 +241,11 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
{
if( !m_spaceMouse )
{
#ifndef __linux__
m_spaceMouse = std::make_unique<NL_PL_EDITOR_PLUGIN>();
#else
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( GetCanvas() );
m_spaceMouse->SetScale( drawSheetIUScale.IU_PER_MILS / pcbIUScale.IU_PER_MILS );
#else
m_spaceMouse = std::make_unique<NL_PL_EDITOR_PLUGIN>();
#endif
}
+6 -6
View File
@@ -39,10 +39,10 @@ class PROPERTIES_FRAME;
class DS_DATA_ITEM;
class wxChoice;
#ifndef __linux__
class NL_PL_EDITOR_PLUGIN;
#else
#if defined(__linux__) || defined(__FreeBSD__)
class SPNAV_2D_PLUGIN;
#else
class NL_PL_EDITOR_PLUGIN;
#endif
/**
@@ -276,10 +276,10 @@ private:
// only on page 1, not on page 1
VECTOR2I m_grid_origin;
#ifndef __linux__
std::unique_ptr<NL_PL_EDITOR_PLUGIN> m_spaceMouse;
#else
#if defined(__linux__) || defined(__FreeBSD__)
std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
#else
std::unique_ptr<NL_PL_EDITOR_PLUGIN> m_spaceMouse;
#endif
wxString m_originChoiceList[5] =
+4 -4
View File
@@ -68,7 +68,7 @@
#include <tool/grid_menu.h>
#include <ratsnest/ratsnest_view_item.h>
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <spacenav/spnav_2d_plugin.h>
#else
#include <navlib/nl_pcbnew_plugin.h>
@@ -1026,11 +1026,11 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
{
if( !m_spaceMouse )
{
#ifndef __linux__
m_spaceMouse = std::make_unique<NL_PCBNEW_PLUGIN>( GetCanvas() );
#else
#if defined(__linux__) || defined(__FreeBSD__)
m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( GetCanvas() );
m_spaceMouse->SetScale( 0.01 );
#else
m_spaceMouse = std::make_unique<NL_PCBNEW_PLUGIN>( GetCanvas() );
#endif
}
}