📄 disabler.cpp
字号:
// Disabler.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
// All programs using the Synaptics COM SDK include SynKit.h
#include "SynKit.h"
enum eAction {eNone = -1,
eDisableStick = 0x000,
eEnableStick = 0x001,
eDisableTouchPad = 0x100,
eEnableTouchPad = 0x101,
eDisableStickButtons = 0x010,
eEnableStickButtons = 0x011,
eDisableTouchPadButtons = 0x110,
eEnableTouchPadButtons = 0x111,
eDisablePressToSelect = 0x020,
eEnablePressToSelect = 0x021,
eDisableTaps = 0x120,
eEnableTaps = 0x121,
eWaitForStickButton = 0x030,
eWaitForTouchPadButton = 0x130
};
enum eAction ParseCommandLine(int argc, char* argv[])
{
if (argc != 2)
return eNone;
else if(!stricmp(argv[1], "DisableStick"))
return eDisableStick;
else if(!stricmp(argv[1], "EnableStick"))
return eEnableStick;
else if(!stricmp(argv[1], "DisableTouchPad"))
return eDisableTouchPad;
else if(!stricmp(argv[1], "EnableTouchPad"))
return eEnableTouchPad;
else if(!stricmp(argv[1], "DisableStickButtons"))
return eDisableStickButtons;
else if(!stricmp(argv[1], "EnableStickButtons"))
return eEnableStickButtons;
else if(!stricmp(argv[1], "DisableTouchPadButtons"))
return eDisableTouchPadButtons;
else if(!stricmp(argv[1], "EnableTouchPadButtons"))
return eEnableTouchPadButtons;
else if(!stricmp(argv[1], "DisablePressToSelect"))
return eDisablePressToSelect;
else if(!stricmp(argv[1], "EnablePressToSelect"))
return eEnablePressToSelect;
else if(!stricmp(argv[1], "DisableTaps"))
return eDisableTaps;
else if(!stricmp(argv[1], "EnableTaps"))
return eEnableTaps;
else if(!stricmp(argv[1], "WaitForStickButton"))
return eWaitForStickButton;
else if(!stricmp(argv[1], "WaitForTouchPadButton"))
return eWaitForTouchPadButton;
else
return eNone;
};
int main(int argc, char* argv[])
{
ISynAPI *pAPI = 0;
if (CoInitialize(0) ||
CoCreateInstance(_uuidof(SynAPI), 0,
CLSCTX_INPROC_SERVER, _uuidof(ISynAPI), (void **) &pAPI) ||
pAPI->Initialize())
{
printf("Could not obtain a Synaptics API object.\n");
exit(-1);
}
int iAction = ParseCommandLine(argc, argv);
if (iAction == eNone)
{
printf("Failed to parse a command.\n");
exit(-1);
}
ISynDevice *pDevice = 0;
if (iAction & 0x100)
{
long lHandle = -1;
if (pAPI->FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, &lHandle) ||
pAPI->CreateDevice(lHandle, &pDevice))
{
printf("Unable to find a Synaptics TouchPad.\n");
exit(-1);
}
}
else
{
long lHandle = -1;
if (pAPI->FindDevice(SE_ConnectionAny, SE_DeviceIBMCompatibleStick, &lHandle) ||
pAPI->CreateDevice(lHandle, &pDevice))
{
printf("Unable to find an IBM compatible stick.\n");
exit(-1);
}
}
switch (iAction)
{
case eDisableStick:
case eDisableTouchPad:
pDevice->SetProperty(SP_DisableState, 1);
break;
case eEnableStick:
case eEnableTouchPad:
pDevice->SetProperty(SP_DisableState, 0);
break;
case eDisableStickButtons:
case eDisableTouchPadButtons:
{
long lMask;
pDevice->GetProperty(SP_LeftButtonAction, &lMask);
lMask &= ~SF_ActionPrimary;
pDevice->SetProperty(SP_LeftButtonAction, lMask);
pDevice->GetProperty(SP_RightButtonAction, &lMask);
lMask &= ~SF_ActionSecondary;
pDevice->SetProperty(SP_LeftButtonAction, lMask);
}
break;
case eEnableStickButtons:
case eEnableTouchPadButtons:
{
long lMask;
pDevice->GetProperty(SP_LeftButtonAction, &lMask);
lMask |= SF_ActionPrimary;
pDevice->SetProperty(SP_LeftButtonAction, lMask);
pDevice->GetProperty(SP_RightButtonAction, &lMask);
lMask |= SF_ActionSecondary;
pDevice->SetProperty(SP_LeftButtonAction, lMask);
}
break;
case eDisablePressToSelect:
case eDisableTaps:
{
long lMask;
pDevice->GetProperty(SP_Gestures, &lMask);
lMask &= ~SF_GestureTap;
pDevice->SetProperty(SP_Gestures, lMask);
}
break;
case eEnablePressToSelect:
case eEnableTaps:
{
long lMask;
pDevice->GetProperty(SP_Gestures, &lMask);
lMask |= SF_GestureTap;
pDevice->SetProperty(SP_Gestures, lMask);
}
break;
case eWaitForStickButton:
case eWaitForTouchPadButton:
{
HANDLE hEvent = CreateEvent(0, 0, 0, 0);
pDevice->SetEventNotification(hEvent);
for ( ; ; )
{
WaitForSingleObject(hEvent, INFINITE);
SynPacket Packet;
pDevice->LoadPacket(Packet);
if (Packet.ButtonState())
{
exit(0);
}
}
}
break;
default:
break;
};
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -