diff --git a/G940LEDControl/Bin/LogiJoystickDLL.dll b/G940LEDControl/Bin/LogiJoystickDLL.dll index 3e2f08f..1271d75 100644 Binary files a/G940LEDControl/Bin/LogiJoystickDLL.dll and b/G940LEDControl/Bin/LogiJoystickDLL.dll differ diff --git a/G940LEDControl/Forms/MainFrm.dfm b/G940LEDControl/Forms/MainFrm.dfm index f006fba..53af5e5 100644 --- a/G940LEDControl/Forms/MainFrm.dfm +++ b/G940LEDControl/Forms/MainFrm.dfm @@ -14,8 +14,8 @@ object MainForm: TMainForm Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnCloseQuery = FormCloseQuery OnCreate = FormCreate - OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object pcConnections: TPageControl @@ -670,9 +670,4 @@ object MainForm: TMainForm OnClick = btnRetryClick end end - object tmrG940Init: TTimer - Interval = 250 - Left = 268 - Top = 24 - end end diff --git a/G940LEDControl/Forms/MainFrm.pas b/G940LEDControl/Forms/MainFrm.pas index 4d85258..c7815e9 100644 --- a/G940LEDControl/Forms/MainFrm.pas +++ b/G940LEDControl/Forms/MainFrm.pas @@ -51,21 +51,15 @@ type btnFSXConnect: TButton; btnFSXDisconnect: TButton; lblFSXLocal: TLabel; - tmrG940Init: TTimer; procedure FormCreate(Sender: TObject); - procedure FormDestroy(Sender: TObject); procedure btnRetryClick(Sender: TObject); procedure btnFSXConnectClick(Sender: TObject); procedure btnFSXDisconnectClick(Sender: TObject); -// procedure tmrG940InitTimer(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); private FEventMonitor: TOmniEventMonitor; FStateConsumerTask: IOmniTaskControl; - -// FInitCounter: Integer; -// FInitRedState: Byte; -// FInitGreenState: Byte; protected procedure SetDeviceState(const AMessage: string; AFound: Boolean); @@ -76,6 +70,8 @@ type procedure UpdateMappingFSX; procedure EventMonitorMessage(const task: IOmniTaskControl; const msg: TOmniMessage); + procedure EventMonitorTerminated(const task: IOmniTaskControl); + procedure HandleDeviceStateMessage(ATask: IOmniTaskControl; AMessage: TOmniMessage); procedure HandleRunInMainThreadMessage(ATask: IOmniTaskControl; AMessage: TOmniMessage); @@ -90,6 +86,7 @@ uses SysUtils, Windows, + OtlCommon, OtlTask, FSXLEDStateProvider, @@ -125,17 +122,18 @@ begin // ToDo handle OnTerminate, check exit code for initialization errors EventMonitor.OnTaskMessage := EventMonitorMessage; + EventMonitor.OnTaskTerminated := EventMonitorTerminated; StateConsumerTask.Run; end; -procedure TMainForm.FormDestroy(Sender: TObject); +procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin - FinalizeStateProvider; - - StateConsumerTask.Terminate; - StateConsumerTask.WaitFor(INFINITE); - FStateConsumerTask := nil; + if Assigned(StateConsumerTask) then + begin + StateConsumerTask.Terminate; + CanClose := False; + end; end; @@ -227,6 +225,8 @@ begin TLEDStateConsumer.SetFunction(StateConsumerTask, 2, FUNCTION_FSX_LANDINGLIGHTS); TLEDStateConsumer.SetFunction(StateConsumerTask, 3, FUNCTION_FSX_GEAR); TLEDStateConsumer.SetFunction(StateConsumerTask, 6, FUNCTION_FSX_INSTRUMENTLIGHTS); + + TLEDStateConsumer.SetFunction(StateConsumerTask, 7, FUNCTION_OFF); end; @@ -239,6 +239,16 @@ begin end; +procedure TMainForm.EventMonitorTerminated(const task: IOmniTaskControl); +begin + if task = StateConsumerTask then + begin + FStateConsumerTask := nil; + Close; + end; +end; + + procedure TMainForm.HandleDeviceStateMessage(ATask: IOmniTaskControl; AMessage: TOmniMessage); begin case AMessage.MsgData.AsInteger of @@ -258,8 +268,16 @@ end; procedure TMainForm.HandleRunInMainThreadMessage(ATask: IOmniTaskControl; AMessage: TOmniMessage); +var + waitableObject: TObject; + waitableValue: TOmniWaitableValue; + begin - (AMessage.MsgData.AsInterface as IRunInMainThread).Execute; + waitableObject := ATask.Param[0].AsObject; + waitableValue := (waitableObject as TOmniWaitableValue); + +// (waitableValue.Value.AsInterface as IRunInMainThread).Execute; +// waitableValue.Signal; end; diff --git a/G940LEDControl/Units/FSXLEDStateProvider.pas b/G940LEDControl/Units/FSXLEDStateProvider.pas index 45d7b58..8c25fc3 100644 --- a/G940LEDControl/Units/FSXLEDStateProvider.pas +++ b/G940LEDControl/Units/FSXLEDStateProvider.pas @@ -7,16 +7,17 @@ uses Classes, SyncObjs, + LEDFunctionMap, LEDStateConsumer, LEDStateProvider, SimConnect; const - FUNCTION_FSX_GEAR = 1; - FUNCTION_FSX_LANDINGLIGHTS = 2; - FUNCTION_FSX_INSTRUMENTLIGHTS = 3; - FUNCTION_FSX_PARKINGBRAKE = 4; + FUNCTION_FSX_GEAR = FUNCTION_PROVIDER_OFFSET + 1; + FUNCTION_FSX_LANDINGLIGHTS = FUNCTION_PROVIDER_OFFSET + 2; + FUNCTION_FSX_INSTRUMENTLIGHTS = FUNCTION_PROVIDER_OFFSET + 3; + FUNCTION_FSX_PARKINGBRAKE = FUNCTION_PROVIDER_OFFSET + 4; EXIT_ERROR_INITSIMCONNECT = 1; EXIT_ERROR_CONNECT = 2; @@ -26,19 +27,24 @@ type TFSXLEDStateProvider = class(TLEDStateProvider) private FSimConnectHandle: THandle; - FUseFunctionGear: Boolean; + FDefinitions: TList; protected function GetProcessMessagesInterval: Integer; override; - procedure SetInitialState; procedure UpdateMap; procedure HandleDispatch(AData: PSimConnectRecv); + procedure AddDefinition(ADefinition: Cardinal); + procedure ClearDefinitions; + function GetDataBoolean(var AData: Cardinal): Boolean; function GetDataDouble(var AData: Cardinal): Double; property SimConnectHandle: THandle read FSimConnectHandle; public + constructor Create(AConsumer: ILEDStateConsumer); override; + destructor Destroy; override; + procedure Initialize; override; procedure Finalize; override; procedure ProcessMessages; override; @@ -48,9 +54,7 @@ type implementation uses ComObj, - SysUtils, - - LEDFunctionMap; + SysUtils; const @@ -76,6 +80,22 @@ const { TFSXLEDStateProvider } +constructor TFSXLEDStateProvider.Create(AConsumer: ILEDStateConsumer); +begin + inherited; + + FDefinitions := TList.Create; +end; + + +destructor TFSXLEDStateProvider.Destroy; +begin + FreeAndNil(FDefinitions); + + inherited; +end; + + procedure TFSXLEDStateProvider.Initialize; begin if not InitSimConnect then @@ -85,7 +105,6 @@ begin raise EInitializeError.Create('Connection to Flight Simulator could not be established', EXIT_ERROR_CONNECT); UpdateMap; - SetInitialState; end; @@ -93,6 +112,8 @@ procedure TFSXLEDStateProvider.Finalize; begin inherited; + ClearDefinitions; + if SimConnectHandle <> 0 then begin SimConnect_Close(SimConnectHandle); @@ -114,26 +135,11 @@ begin end; -procedure TFSXLEDStateProvider.SetInitialState; -begin -// if FUseFunctionGear then -// begin -// SimConnect_RequestDataOnSimObject(SimConnectHandle, REQUEST_GEAR, -// DEFINITION_GEAR, -// SIMCONNECT_OBJECT_ID_USER, -// SIMCONNECT_PERIOD_ONCE, -// SIMCONNECT_DATA_REQUEST_FLAG_DEFAULT); -// end; -end; - - procedure TFSXLEDStateProvider.UpdateMap; begin - if FUseFunctionGear then - SimConnect_ClearDataDefinition(SimConnectHandle, DEFINITION_GEAR); - - FUseFunctionGear := Consumer.FunctionMap.HasFunction(FUNCTION_FSX_GEAR); - if FUseFunctionGear then + ClearDefinitions; + + if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_GEAR) then begin SimConnect_AddToDataDefinition(SimConnectHandle, DEFINITION_GEAR, FSX_VARIABLE_GEARTOTALPCTEXTENDED, @@ -143,11 +149,9 @@ begin SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED); - end; -// ToDo for other vars too! -// if FUseFunctionGear then -// SimConnect_ClearDataDefinition(SimConnectHandle, DEFINITION_GEAR); + AddDefinition(DEFINITION_GEAR); + end; if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_LANDINGLIGHTS) or Consumer.FunctionMap.HasFunction(FUNCTION_FSX_INSTRUMENTLIGHTS) then @@ -161,6 +165,8 @@ begin SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED); + + AddDefinition(DEFINITION_LIGHTS); end; if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_PARKINGBRAKE) then @@ -174,6 +180,8 @@ begin SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED); + + AddDefinition(DEFINITION_PARKINGBRAKE); end; end; @@ -227,6 +235,27 @@ begin end; +procedure TFSXLEDStateProvider.AddDefinition(ADefinition: Cardinal); +begin + FDefinitions.Add(Pointer(ADefinition)); +end; + + +procedure TFSXLEDStateProvider.ClearDefinitions; +var + definition: Pointer; + +begin + if SimConnectHandle <> 0 then + begin + for definition in FDefinitions do + SimConnect_ClearDataDefinition(SimConnectHandle, Cardinal(definition)); + end; + + FDefinitions.Clear; +end; + + function TFSXLEDStateProvider.GetDataBoolean(var AData: Cardinal): Boolean; begin Result := (AData <> 0); diff --git a/G940LEDControl/Units/G940LEDStateConsumer.pas b/G940LEDControl/Units/G940LEDStateConsumer.pas index 332e9cb..b981cb9 100644 --- a/G940LEDControl/Units/G940LEDStateConsumer.pas +++ b/G940LEDControl/Units/G940LEDStateConsumer.pas @@ -21,11 +21,16 @@ type private FDirectInput: IDirectInput8; FThrottleDevice: IDirectInputDevice8; + + FRed: Byte; + FGreen: Byte; protected procedure MsgFindThrottleDevice(var msg: TOmniMessage); message MSG_FINDTHROTTLEDEVICE; protected function Initialize: Boolean; override; + procedure ResetLEDState; override; procedure LEDStateChanged(ALEDIndex: Integer; AState: TLEDState); override; + procedure Changed; override; procedure FindThrottleDevice; procedure FoundThrottleDevice(ADeviceGUID: TGUID); @@ -54,16 +59,17 @@ uses LogiJoystickDLL; + type - TRunInMainThreadSetButtonColor = class(TInterfacedObject, IRunInMainThread) + TRunInMainThreadSetLEDs = class(TInterfacedObject, IRunInMainThread) private FDevice: IDirectInputDevice8; - FButton: TLogiPanelButton; - FColor: TLogiColor; + FRed: Byte; + FGreen: Byte; protected procedure Execute; public - constructor Create(device: IDirectInputDevice8; button: TLogiPanelButton; color: TLogiColor); + constructor Create(ADevice: IDirectInputDevice8; ARed, AGreen: Byte); end; @@ -103,9 +109,6 @@ begin exit; end; -// btnRetry.Visible := False; -// SetState(STATE_SEARCHING, False); - if DirectInput8Create(SysInit.HInstance, DIRECTINPUT_VERSION, IDirectInput8, FDirectInput, nil) <> S_OK then begin Task.SetExitStatus(EXIT_ERROR_DIRECTINPUT, 'Failed to initialize DirectInput'); @@ -117,31 +120,68 @@ begin end; +procedure TG940LEDStateConsumer.ResetLEDState; +begin + FRed := 0; + FGreen := $FF; + + inherited; +end; + + procedure TG940LEDStateConsumer.LEDStateChanged(ALEDIndex: Integer; AState: TLEDState); + + procedure SetBit(var AMask: Byte; ABit: Integer; ASet: Boolean); inline; + begin + if ASet then + AMask := AMask or (1 shl ABit) + else + AMask := AMask and not (1 shl ABit); + end; + var - color: TLogiColor; -// msg: TMsg; + red: Boolean; + green: Boolean; begin - // ToDo SetLEDs gebruiken (vereist override van SetStateByFunction om te groeperen) - if Assigned(ThrottleDevice) then - begin - color := LOGI_GREEN; + red := False; + green := False; - case AState of - lsOff: color := LOGI_OFF; - lsGreen: color := LOGI_GREEN; - lsAmber: color := LOGI_AMBER; - lsRed: color := LOGI_RED; + case AState of + lsGreen: + green := True; - // ToDo timers voor warning / error - lsWarning: color := LOGI_RED; - lsError: color := LOGI_RED; - end; + lsAmber: + begin + red := True; + green := True; + end; - { Logitech SDK will not change the color outside of the main thread } - RunInMainThread(TRunInMainThreadSetButtonColor.Create(ThrottleDevice, TLogiPanelButton(ALEDIndex), color)); + lsRed: + red := True; + + // ToDo timers voor warning / error + lsWarning: + red := True; + + lsError: + red := True; end; + + SetBit(FRed, ALEDIndex, red); + SetBit(FGreen, ALEDIndex, green); + + inherited; +end; + + +procedure TG940LEDStateConsumer.Changed; +begin + inherited; + + if Assigned(ThrottleDevice) then + { Logitech SDK will not change the color outside of the main thread } + RunInMainThread(TRunInMainThreadSetLEDs.Create(ThrottleDevice, FRed, FGreen)); end; @@ -154,7 +194,9 @@ begin DIEDFL_ATTACHEDONLY); if not Assigned(ThrottleDevice) then - SetDeviceState(DEVICESTATE_NOTFOUND); + SetDeviceState(DEVICESTATE_NOTFOUND) + else + Changed; end; @@ -177,43 +219,20 @@ begin end; -//procedure TCustomLEDStateProvider.SetStateByFunction(AFunction: Integer; AState: TLEDState); -//var -// functionMap: TLEDFunctionMap; -// ledIndex: Integer; -// -//begin -// functionMap := LockFunctionMap; -// try -// for ledIndex := 0 to Pred(functionMap.Count) do -// if functionMap.GetFunction(ledIndex) = AFunction then -// begin -// if AState <> FState[ledIndex] then -// begin -// FState[ledIndex] := AState; -// ConsumerChannel.Send(MSG_STATECHANGED, [ledIndex, Ord(AState)]); -// end; -// end; -// finally -// UnlockFunctionMap; -// end; -//end; - - -{ TRunInMainThreadSetButtonColor } -constructor TRunInMainThreadSetButtonColor.Create(device: IDirectInputDevice8; button: TLogiPanelButton; color: TLogiColor); +{ TRunInMainThreadSetLEDs } +constructor TRunInMainThreadSetLEDs.Create(ADevice: IDirectInputDevice8; ARed, AGreen: Byte); begin inherited Create; - FDevice := device; - FButton := button; - FColor := color; + FDevice := ADevice; + FRed := ARed; + FGreen := AGreen; end; -procedure TRunInMainThreadSetButtonColor.Execute; +procedure TRunInMainThreadSetLEDs.Execute; begin - SetButtonColor(FDevice, FButton, FColor); + SetLEDs(FDevice, FRed, FGreen); end; end. diff --git a/G940LEDControl/Units/LEDFunctionMap.pas b/G940LEDControl/Units/LEDFunctionMap.pas index 134f871..200d90c 100644 --- a/G940LEDControl/Units/LEDFunctionMap.pas +++ b/G940LEDControl/Units/LEDFunctionMap.pas @@ -48,6 +48,12 @@ type const FUNCTION_NONE = 0; + FUNCTION_OFF = 1; + FUNCTION_RED = 2; + FUNCTION_AMBER = 3; + FUNCTION_GREEN = 4; + + FUNCTION_PROVIDER_OFFSET = FUNCTION_GREEN; implementation diff --git a/G940LEDControl/Units/LEDStateConsumer.pas b/G940LEDControl/Units/LEDStateConsumer.pas index 3099a66..a1d571c 100644 --- a/G940LEDControl/Units/LEDStateConsumer.pas +++ b/G940LEDControl/Units/LEDStateConsumer.pas @@ -15,8 +15,9 @@ const MSG_INITIALIZE_PROVIDER = 3; MSG_FINALIZE_PROVIDER = 4; MSG_PROCESS_MESSAGES = 5; + MSG_FINALIZE = 6; - MSG_RUN_IN_MAINTHREAD = 6; + MSG_RUN_IN_MAINTHREAD = 7; MSG_CONSUMER_OFFSET = MSG_RUN_IN_MAINTHREAD; @@ -37,18 +38,26 @@ type FStateMap: TLEDStateMap; FProvider: TLEDStateProvider; FTimerSet: Boolean; + FChanged: Boolean; + FUpdateCount: Integer; protected procedure MsgClearFunctions(var msg: TOmniMessage); message MSG_CLEAR_FUNCTIONS; procedure MsgSetFunction(var msg: TOmniMessage); message MSG_SET_FUNCTION; procedure MsgInitializeProvider(var msg: TOmniMessage); message MSG_INITIALIZE_PROVIDER; procedure MsgFinalizeProvider(var msg: TOmniMessage); message MSG_FINALIZE_PROVIDER; procedure MsgProcessMessages(var msg: TOmniMessage); message MSG_PROCESS_MESSAGES; + procedure MsgFinalize(var msg: TOmniMessage); message MSG_FINALIZE; + + procedure Cleanup; override; procedure InitializeProvider(AProviderClass: TLEDStateProviderClass); procedure FinalizeProvider; procedure RunInMainThread(AExecutor: IRunInMainThread); + procedure InitializeLEDState; virtual; + procedure ResetLEDState; virtual; procedure LEDStateChanged(ALEDIndex: Integer; AState: TLEDState); virtual; + procedure Changed; virtual; { ILEDStateConsumer } function GetFunctionMap: TLEDFunctionMap; @@ -57,14 +66,18 @@ type property FunctionMap: TLEDFunctionMap read GetFunctionMap; property StateMap: TLEDStateMap read FStateMap; property Provider: TLEDStateProvider read FProvider; + property UpdateCount: Integer read FUpdateCount write FUpdateCount; public constructor Create; - destructor Destroy; override; + + procedure BeginUpdate; + procedure EndUpdate; class procedure ClearFunctions(AConsumer: IOmniTaskControl); class procedure SetFunction(AConsumer: IOmniTaskControl; ALEDIndex, AFunction: Integer); class procedure InitializeStateProvider(AConsumer: IOmniTaskControl; AProviderClass: TLEDStateProviderClass); class procedure FinalizeStateProvider(AConsumer: IOmniTaskControl); + class procedure Finalize(AConsumer: IOmniTaskControl); end; @@ -77,6 +90,10 @@ uses OtlCommon; +const + G940_LED_COUNT = 8; + + { TLEDStateConsumer } constructor TLEDStateConsumer.Create; begin @@ -84,17 +101,38 @@ begin FFunctionMap := TLEDFunctionMap.Create; FStateMap := TLEDStateMap.Create; + + InitializeLEDState; + + end; -destructor TLEDStateConsumer.Destroy; +procedure TLEDStateConsumer.Cleanup; begin - FinalizeProvider; - + inherited; + FreeAndNil(FStateMap); FreeAndNil(FFunctionMap); +end; - inherited; + +procedure TLEDStateConsumer.BeginUpdate; +begin + if FUpdateCount = 0 then + FChanged := False; + + Inc(FUpdateCount); +end; + + +procedure TLEDStateConsumer.EndUpdate; +begin + if FUpdateCount > 0 then + Dec(FUpdateCount); + + if (FUpdateCount = 0) and FChanged then + Changed; end; @@ -148,7 +186,18 @@ end; procedure TLEDStateConsumer.MsgProcessMessages(var msg: TOmniMessage); begin - Provider.ProcessMessages; + BeginUpdate; + try + Provider.ProcessMessages; + finally + EndUpdate; + end; +end; + + +procedure TLEDStateConsumer.MsgFinalize(var msg: TOmniMessage); +begin + FinalizeProvider; end; @@ -165,6 +214,8 @@ begin Task.SetTimer(TIMER_PROCESSMESSAGES, Provider.ProcessMessagesInterval, MSG_PROCESS_MESSAGES); FTimerSet := True; end; + + InitializeLEDState; end; @@ -181,18 +232,83 @@ begin Provider.Terminate; Provider.Finalize; FreeAndNil(FProvider); + + StateMap.Clear; + ResetLEDState; end; end; procedure TLEDStateConsumer.RunInMainThread(AExecutor: IRunInMainThread); +var + value: TOmniWaitableValue; + begin - Task.Comm.Send(MSG_RUN_IN_MAINTHREAD, AExecutor); + value := TOmniWaitableValue.Create; + try + value.Value.AsInterface := AExecutor; + Task.Comm.Send(MSG_RUN_IN_MAINTHREAD, value); + + value.WaitFor(INFINITE); + finally + FreeAndNil(value); + end; +end; + + +procedure TLEDStateConsumer.InitializeLEDState; +var + ledIndex: Integer; + state: TLEDState; + newState: TLEDState; + +begin + BeginUpdate; + try + ResetLEDState; + + for ledIndex := 0 to Pred(G940_LED_COUNT) do + begin + state := StateMap.GetState(ledIndex, lsGreen); + newState := state; + + case FunctionMap.GetFunction(ledIndex) of + FUNCTION_OFF: newState := lsOff; + FUNCTION_RED: newState := lsRed; + FUNCTION_AMBER: newState := lsAmber; + FUNCTION_GREEN: newState := lsGreen; + end; + + if state <> newState then + LEDStateChanged(ledIndex, newState); + end; + finally + EndUpdate; + end; +end; + + +procedure TLEDStateConsumer.ResetLEDState; +begin + if UpdateCount = 0 then + Changed + else + FChanged := True; end; procedure TLEDStateConsumer.LEDStateChanged(ALEDIndex: Integer; AState: TLEDState); begin + if UpdateCount = 0 then + Changed + else + FChanged := True; +end; + + +procedure TLEDStateConsumer.Changed; +begin + FChanged := False; end; @@ -219,4 +335,10 @@ begin AConsumer.Comm.Send(MSG_FINALIZE_PROVIDER); end; + +class procedure TLEDStateConsumer.Finalize(AConsumer: IOmniTaskControl); +begin + AConsumer.Comm.Send(MSG_FINALIZE); +end; + end. diff --git a/G940LEDControl/Units/LEDStateProvider.pas b/G940LEDControl/Units/LEDStateProvider.pas index b7df4c6..87fc2d5 100644 --- a/G940LEDControl/Units/LEDStateProvider.pas +++ b/G940LEDControl/Units/LEDStateProvider.pas @@ -39,7 +39,7 @@ type property Consumer: ILEDStateConsumer read FConsumer; public - constructor Create(AConsumer: ILEDStateConsumer); + constructor Create(AConsumer: ILEDStateConsumer); virtual; destructor Destroy; override; procedure Initialize; virtual; diff --git a/LogiJoystickDLL/LogiJoystickDLL.sdf b/LogiJoystickDLL/LogiJoystickDLL.sdf deleted file mode 100644 index de6774d..0000000 Binary files a/LogiJoystickDLL/LogiJoystickDLL.sdf and /dev/null differ diff --git a/LogiJoystickDLL/LogiJoystickDLL.sln b/LogiJoystickDLL/LogiJoystickDLL.sln index cdb1326..503eb53 100644 --- a/LogiJoystickDLL/LogiJoystickDLL.sln +++ b/LogiJoystickDLL/LogiJoystickDLL.sln @@ -1,17 +1,15 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiJoystickDLL", "LogiJoystickDLL\LogiJoystickDLL.vcxproj", "{CEC7BCB7-FB0A-4454-B345-1DE883F8FD4F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiJoystickDLL", "LogiJoystickDLL\LogiJoystickDLL.vcxproj", "{62FA1486-30C0-4289-9557-6F5206977593}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CEC7BCB7-FB0A-4454-B345-1DE883F8FD4F}.Debug|Win32.ActiveCfg = Debug|Win32 - {CEC7BCB7-FB0A-4454-B345-1DE883F8FD4F}.Debug|Win32.Build.0 = Debug|Win32 - {CEC7BCB7-FB0A-4454-B345-1DE883F8FD4F}.Release|Win32.ActiveCfg = Release|Win32 + {62FA1486-30C0-4289-9557-6F5206977593}.Release|Win32.ActiveCfg = Release|Win32 + {62FA1486-30C0-4289-9557-6F5206977593}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LogiJoystickDLL/LogiJoystickDLL.suo b/LogiJoystickDLL/LogiJoystickDLL.suo index 4936f28..1b4f04f 100644 Binary files a/LogiJoystickDLL/LogiJoystickDLL.suo and b/LogiJoystickDLL/LogiJoystickDLL.suo differ diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.cpp b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.cpp deleted file mode 100644 index 528004b..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -extern "C" -{ - __declspec(dllexport) DWORD LJ_SetButtonColor(LPDIRECTINPUTDEVICE8 device, LogiPanelButton button, LogiColor color) - { - return SetButtonColor(device, button, color); - } - - __declspec(dllexport) DWORD LJ_SetAllButtonsColor(LPDIRECTINPUTDEVICE8 device, LogiColor color) - { - return SetAllButtonsColor(device, color); - } - - __declspec(dllexport) BOOL LJ_IsButtonColor(LPDIRECTINPUTDEVICE8 device, LogiPanelButton button, LogiColor color) - { - return IsButtonColor(device, button, color); - } - - __declspec(dllexport) DWORD LJ_SetLEDs(LPDIRECTINPUTDEVICE8 device, BYTE redLEDs, BYTE greenLEDs) - { - return SetLEDs(device, redLEDs, greenLEDs); - } - - __declspec(dllexport) DWORD LJ_GetLEDs(LPDIRECTINPUTDEVICE8 device, BYTE& redLEDs, BYTE& greenLEDs) - { - return GetLEDs(device, redLEDs, greenLEDs); - } -} \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.h b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.h deleted file mode 100644 index 982e389..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.h +++ /dev/null @@ -1,19 +0,0 @@ -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the LOGIJOYSTICKDLL_EXPORTS -// symbol defined on the command line. This symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// LOGIJOYSTICKDLL_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef LOGIJOYSTICKDLL_EXPORTS -#define LOGIJOYSTICKDLL_API -#else -#define LOGIJOYSTICKDLL_API __declspec(dllimport) -#endif - - -LOGIJOYSTICKDLL_API DWORD LJ_SetButtonColor(LPDIRECTINPUTDEVICE8 device, LogiPanelButton button, LogiColor color); -LOGIJOYSTICKDLL_API DWORD LJ_SetAllButtonsColor(LPDIRECTINPUTDEVICE8 device, LogiColor color); -LOGIJOYSTICKDLL_API BOOL LJ_IsButtonColor(LPDIRECTINPUTDEVICE8 device, LogiPanelButton button, LogiColor color); - -LOGIJOYSTICKDLL_API DWORD LJ_SetLEDs(LPDIRECTINPUTDEVICE8 device, BYTE redLEDs, BYTE greenLEDs); -LOGIJOYSTICKDLL_API DWORD LJ_GetLEDs(LPDIRECTINPUTDEVICE8 device, BYTE& redLEDs, BYTE& greenLEDs); \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcproj b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcproj new file mode 100644 index 0000000..756613b --- /dev/null +++ b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcproj @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj deleted file mode 100644 index 191cc09..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj +++ /dev/null @@ -1,103 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {CEC7BCB7-FB0A-4454-B345-1DE883F8FD4F} - Win32Proj - LogiJoystickDLL - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - - - false - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LOGIJOYSTICKDLL_EXPORTS;%(PreprocessorDefinitions) - Cdecl - F:\Development\G940\Logitech_SDK_For_PC_1.00.002\Joystick\Include;%(AdditionalIncludeDirectories) - - - Windows - true - LogiJoystick.lib;%(AdditionalDependencies) - F:\Development\G940\Logitech_SDK_For_PC_1.00.002\Joystick\Lib\x86;%(AdditionalLibraryDirectories) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LOGIJOYSTICKDLL_EXPORTS;%(PreprocessorDefinitions) - Cdecl - F:\Development\G940\Logitech_SDK_For_PC_1.00.002\Joystick\Include;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - LogiJoystick.lib;%(AdditionalDependencies) - F:\Development\G940\Logitech_SDK_For_PC_1.00.002\Joystick\Lib\x86;%(AdditionalLibraryDirectories) - Default - - - - - - - - - - - false - - - false - - - - - - - - - \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.filters b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.filters deleted file mode 100644 index cf8c402..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.user b/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.user deleted file mode 100644 index 695b5c7..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/LogiJoystickDLL.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/ReadMe.txt b/LogiJoystickDLL/LogiJoystickDLL/ReadMe.txt deleted file mode 100644 index 3093642..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/ReadMe.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - DYNAMIC LINK LIBRARY : LogiJoystickDLL Project Overview -======================================================================== - -AppWizard has created this LogiJoystickDLL DLL for you. - -This file contains a summary of what you will find in each of the files that -make up your LogiJoystickDLL application. - - -LogiJoystickDLL.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -LogiJoystickDLL.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -LogiJoystickDLL.cpp - This is the main DLL source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named LogiJoystickDLL.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/LogiJoystickDLL/LogiJoystickDLL/dllmain.cpp b/LogiJoystickDLL/LogiJoystickDLL/dllmain.cpp index 8a4edd3..9d19357 100644 --- a/LogiJoystickDLL/LogiJoystickDLL/dllmain.cpp +++ b/LogiJoystickDLL/LogiJoystickDLL/dllmain.cpp @@ -1,7 +1,8 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" +#include "windows.h" -BOOL APIENTRY DllMain( HMODULE hModule, +BOOL APIENTRY DLLMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) diff --git a/LogiJoystickDLL/LogiJoystickDLL/exports.def b/LogiJoystickDLL/LogiJoystickDLL/exports.def new file mode 100644 index 0000000..23986ea --- /dev/null +++ b/LogiJoystickDLL/LogiJoystickDLL/exports.def @@ -0,0 +1,7 @@ +LIBRARY LogiJoystickDLL +EXPORTS + SetButtonColor @1 + SetAllButtonsColor @2 + IsButtonColor @3 + SetLEDs @4 + GetLEDs @5 \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/stdafx.h b/LogiJoystickDLL/LogiJoystickDLL/stdafx.h index 677e68a..50ce84c 100644 --- a/LogiJoystickDLL/LogiJoystickDLL/stdafx.h +++ b/LogiJoystickDLL/LogiJoystickDLL/stdafx.h @@ -1,16 +1,5 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - #pragma once -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: +#define WIN32_LEAN_AND_MEAN #include - - - -// TODO: reference additional headers your program requires here +#include "LogiJoystick.h" \ No newline at end of file diff --git a/LogiJoystickDLL/LogiJoystickDLL/targetver.h b/LogiJoystickDLL/LogiJoystickDLL/targetver.h deleted file mode 100644 index 90e767b..0000000 --- a/LogiJoystickDLL/LogiJoystickDLL/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include