交换Alt键功能 [英] Swap alt keys functionality

查看:144
本文介绍了交换Alt键功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Windows 7中交换 Alt 键功能.一家大公司需要那些在打字机上写东西的老人,这些人在左侧有变音符号键,但Win7却是为此,正在工作的对象具有正确的 Alt .

I need to swap Alt keys functionality in Windows 7. A big company needs that for old people that were writing on typewriters, which had diacritic characters key on the left side, but Win7 which they are working on now has right Alt for this purpose.

经过两天的研究,我找到了一种驱动程序解决方案.我需要原始Windows 7驱动程序的源代码(两个.sys文件似乎是键盘驱动程序),并且可能需要在Windows DDK中进行修改.或者,我需要制作一个其他驱动程序以使用默认驱动程序.如我所见,解决方案将使用C或C ++.但是,我必须走什么路才能做到这一点?我应该采取什么步骤?

Two days of research brought me to a driver solution. I need source code for original Windows 7 drivers (two .sys files seem to be the keyboard drivers), and possibily to modify them in Windows DDK. Or I need to make an additional driver that would work with the default ones. As I can see, the solution would be in C or C++. But what way do I have to go to accomplish this? What steps should I take?

限制为:

  1. 仅重新安装驱动程序即可重启一个系统.
  2. 一种在Win7中工作时交换 Alt 密钥的简单方法(通过同时按下两个键来交换 Alt 密钥).
  3. 没有需要重新启动的Win7键盘重新映射.
  1. One system restart only for driver installation.
  2. A simple way to swap Alt keys while working in Win7 (swap Alt keys by pressing them both).
  3. No Win7 keyboard remapping which needs a restart.

稍后添加:我拥有所需的一切,但没有处理交换的代码.例如,由于只发送了一个扫描码,所以我对 Shift Enter 进行了切换.但是左边的 Alt 发送一个,右边的 Alt 发送两个扫描代码:

Added later: I have everything I need, but not the code that will handle the swapping. For example, I've made a switch for right Shift and Enter, because there is only one scancode sent. But left Alt sends one and right Alt sends two scancodes:

VOID
KbFilter_ServiceCallback(
IN PDEVICE_OBJECT  DeviceObject,
IN PKEYBOARD_INPUT_DATA InputDataStart,
IN PKEYBOARD_INPUT_DATA InputDataEnd,
IN OUT PULONG InputDataConsumed
)
/*++

Routine Description:

Called when there are keyboard packets to report to the Win32 subsystem.
You can do anything you like to the packets.  For instance:

o Drop a packet altogether
o Mutate the contents of a packet
o Insert packets into the stream

Arguments:

DeviceObject - Context passed during the connect IOCTL

InputDataStart - First packet to be reported

InputDataEnd - One past the last packet to be reported.  Total number of
               packets is equal to InputDataEnd - InputDataStart

InputDataConsumed - Set to the total number of packets consumed by the RIT
                    (via the function pointer we replaced in the connect
                    IOCTL)

Return Value:

Status is returned.

--*/
{
PDEVICE_EXTENSION   devExt;
WDFDEVICE   hDevice;

hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject);

devExt = FilterGetData(hDevice);

if (InputDataStart->MakeCode==0x1c)
    InputDataStart->MakeCode=0x36;
else if (InputDataStart->MakeCode==0x36)
    InputDataStart->MakeCode=0x1c;
else if (InputDataStart->MakeCode==0x9c)
    InputDataStart->MakeCode=0xb6;
else if (InputDataStart->MakeCode==0xb6)
    InputDataStart->MakeCode=0x9c;

(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) devExt->UpperConnectData.ClassService)(
    devExt->UpperConnectData.ClassDeviceObject,
    InputDataStart,
    InputDataEnd,
    InputDataConsumed);
}

因此,我只是简单地交换分别按下和释放两个键的扫描代码.正确的 Alt 正在发送两个扫描代码,但我不确定是通过两次调用此函数还是在InputDataStart结构中创建两个扫描代码来做到这一点.我会尝试对每个 Alt 扫描代码发出哔哔声,但您的帮助将不胜感激.

So I simply swap the scancodes of pressing and releasing both keys individually. Right Alt is sending two scancodes and I'm not sure if it does that by two calls of this function or makes two scancodes in the InputDataStart structure. I'll try to beep every Alt scancode but your help would be appreciated.

推荐答案

解决方案:

if (InputDataStart->MakeCode==0x38 || InputDataStart->MakeCode==0xb8)
    InputDataStart->Flags^=KEY_E0;

交换左右Alt键功能.

which swaps right-left Alt keys functionality.

现在,我需要对交换进行配置.最好-按下两个Alt键.

Now I need to make the swapping configurable. For the best - by pressing both Alts.

这篇关于交换Alt键功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆