Contribute
Register

Remapping keyboard with VoodooPS2

Status
Not open for further replies.
You can find them by running the debug PS2 kext and looking at the log as you press each one (or by using 'ioio -s ApplePS2Keyboard LogScanCodes 1').

But they have standard codes... see here:
http://www.computer-engineering.org/ps2keyboard/scancodes1.html
I can't do that with the debug version, cause I don't have any key that simulates one of those keys.

So if I look at the page, I can try to patch the DSDT with this:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0x00E0) //PlayPauseKey\n
end;
or this:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0x0022) //PlayPauseKey\n
end;
or it's actually:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0xE022) //PlayPauseKey\n
end;
And it will work?
 
I can't do that with the debug version, cause I don't have any key that simulates one of those keys.

What do you mean "cause I don't have any key that simulates one of those keys"?

You mean that your keyboard does not have those keys?

So if I look at the page, I can try to patch the DSDT with this:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0x00E0) //PlayPauseKey\n
end;
or this:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0x0022) //PlayPauseKey\n
end;
or it's actually:
Code:
into method label _Q6F replace_content
begin
// Play Pause\n
    Notify(\_SB.PCI0.LPCB.PS2K, 0xE022) //PlayPauseKey\n
end;
And it will work?

That code is wrong.

The only valid notification codes start with: 0x01, 0x02, 0x03, or 0x04.

Eg... codes 0x0100-0x01ff, 0x0200-0x02ff, 0x0300-0x03ff, 0x0400-0x04ff are the only valid codes.
0x00E0, 0x0022, and 0xE022 are all invalid.

Note code in VoodooPS2Keyboard.cpp:
Code:
IOReturn ApplePS2Keyboard::message(UInt32 type, IOService* provider, void* argument)
{
#ifdef DEBUG
    if (argument)
        IOLog("ApplePS2Keyboard::message: type=%x, provider=%p, argument=%p, argument=%04x, cmp=%x\n", type, provider, argument, *static_cast<UInt32*>(argument), kIOACPIMessageDeviceNotification);
    else
        IOLog("ApplePS2Keyboard::message: type=%x, provider=%p", type, provider);
#endif
  
    if (type == kIOACPIMessageDeviceNotification && NULL != argument)
    {
        UInt32 arg = *static_cast<UInt32*>(argument);
        if ((arg & 0xFFFF0000) == 0)
        {
            UInt8 packet[kPacketLength];
            packet[0] = arg >> 8;
            packet[1] = arg;
            if (1 == packet[0] || 2 == packet[0])
            {
                // mark packet with timestamp
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet
                    dispatchKeyboardEventWithPacket(packet);
                }
            }
            if (3 == packet[0] || 4 == packet[0])
            {
                // code 3 and 4 indicate send both make and break
                packet[0] -= 2;
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet (make)
                    dispatchKeyboardEventWithPacket(packet);
                }
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                packet[1] |= 0x80; // break code
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet (break)
                    dispatchKeyboardEventWithPacket(packet);
                }
            }
        }
    }
    return kIOReturnSuccess;
}
 
What do you mean "cause I don't have any key that simulates one of those keys"?

You mean that your keyboard does not have those keys?



That code is wrong.

The only valid notification codes start with: 0x01, 0x02, 0x03, or 0x04.

Eg... codes 0x0100-0x01ff, 0x0200-0x02ff, 0x0300-0x03ff, 0x0400-0x04ff are the only valid codes.
0x00E0, 0x0022, and 0xE022 are all invalid.

Note code in VoodooPS2Keyboard.cpp:
Code:
IOReturn ApplePS2Keyboard::message(UInt32 type, IOService* provider, void* argument)
{
#ifdef DEBUG
    if (argument)
        IOLog("ApplePS2Keyboard::message: type=%x, provider=%p, argument=%p, argument=%04x, cmp=%x\n", type, provider, argument, *static_cast<UInt32*>(argument), kIOACPIMessageDeviceNotification);
    else
        IOLog("ApplePS2Keyboard::message: type=%x, provider=%p", type, provider);
#endif
 
    if (type == kIOACPIMessageDeviceNotification && NULL != argument)
    {
        UInt32 arg = *static_cast<UInt32*>(argument);
        if ((arg & 0xFFFF0000) == 0)
        {
            UInt8 packet[kPacketLength];
            packet[0] = arg >> 8;
            packet[1] = arg;
            if (1 == packet[0] || 2 == packet[0])
            {
                // mark packet with timestamp
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet
                    dispatchKeyboardEventWithPacket(packet);
                }
            }
            if (3 == packet[0] || 4 == packet[0])
            {
                // code 3 and 4 indicate send both make and break
                packet[0] -= 2;
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet (make)
                    dispatchKeyboardEventWithPacket(packet);
                }
                clock_get_uptime((uint64_t*)(&packet[kPacketTimeOffset]));
                packet[1] |= 0x80; // break code
                if (!_macroInversion || !invertMacros(packet))
                {
                    // normal packet (break)
                    dispatchKeyboardEventWithPacket(packet);
                }
            }
        }
    }
    return kIOReturnSuccess;
}
Sorry, but I didn't understand how it can help me :(
 
Sorry, but I didn't understand how it can help me :(

Refer to the brightness guide. It explains how to map your brightness keys from ACPI.

It uses 0x04xx codes to send the PS2 codes for the Dell brightness keys.

0x01xx: standard PS2 codes... make/break separate
0x02xx: extended PS2 codes (e0)... make/break separate
0x03xx: standard PS2 codes... make/break combined (eg. make and break are sent with only a single notify)
0x04xx: extended PS2 codes (e0)... make/break combined
 
Refer to the brightness guide. It explains how to map your brightness keys from ACPI.

It uses 0x04xx codes to send the PS2 codes for the Dell brightness keys.

0x01xx: standard PS2 codes... make/break separate
0x02xx: extended PS2 codes (e0)... make/break separate
0x03xx: standard PS2 codes... make/break combined (eg. make and break are sent with only a single notify)
0x04xx: extended PS2 codes (e0)... make/break combined
Shouldn't it be universal? As the ACPI calls a method activating an action. Or maybe it's processed through the kext anyway?

Windows scan codes would help? (taken with a program and it should be individual for my laptop)
Fn+Down Arrow - Play/Pause - 179
Fn+Left Arrow - Previous - 177
Fn+Right Arrow - Next - 176

they are 1xx so it actually fits :p
 
Shouldn't it be universal?

No idea what you mean by your question.

As the ACPI calls a method activating an action. Or maybe it's processed through the kext anyway?

What are you referring to?

Windows scan codes would help? (taken with a program and it should be individual for my laptop)
Fn+Down Arrow - Play/Pause - 179
Fn+Left Arrow - Previous - 177
Fn+Right Arrow - Next - 176

They are not PS2 scan codes.

they are 1xx so it actually fits :p

Comparing decimal to hex, Windows to hacked PS2 kext, etc is nonsense.
 
No idea what you mean by your question.



What are you referring to?



They are not PS2 scan codes.



Comparing decimal to hex, Windows to hacked PS2 kext, etc is nonsense.
I'll ask it differently - So every laptop will have a different PS2 code he can use inside his ACPI with a Notify command?
 
I'll ask it differently - So every laptop will have a different PS2 code he can use inside his ACPI with a Notify command?

The Notify mechanism we are using here is something specific to my version of VoodooPS2Controller.kext (specifically the keyboard driver inside it, VoodooPS2Keyboard.kext). It is a mechanism I created. It has nothing to do with any laptop OEM, nor any standard developed anywhere else. It is the code for ApplePS2Keyboard::message, that I authored and posted earlier in this thread.

The set of default PS2 codes and their mapping to ADB codes is in ApplePS2ToADBMap.h. After the notify codes are parsed by ApplePS2Keyboard::message, they pass through this mapping via the code in ApplePS2Keyboard::dispatchKeyboardEventWithPacket.

The Notify mechanism being discussed here was created solely to be able to generate keystrokes from ACPI when running OS X/macOS on hacks.
 
The Notify mechanism we are using here is something specific to my version of VoodooPS2Controller.kext (specifically the keyboard driver inside it, VoodooPS2Keyboard.kext). It is a mechanism I created. It has nothing to do with any laptop OEM, nor any standard developed anywhere else. It is the code for ApplePS2Keyboard::message, that I authored and posted earlier in this thread.

The set of default PS2 codes and their mapping to ADB codes is in ApplePS2ToADBMap.h. After the notify codes are parsed by ApplePS2Keyboard::message, they pass through this mapping via the code in ApplePS2Keyboard::dispatchKeyboardEventWithPacket.

The Notify mechanism being discussed here was created solely to be able to generate keystrokes from ACPI when running OS X/macOS on hacks.
I found this inside ApplePS2ToADBMap.h:
Code:
0x34,   // e0 22  Play/Pause
But it's just a number and it's hexadecimal value...
 
I found this inside ApplePS2ToADBMap.h:
Code:
0x34,   // e0 22  Play/Pause
But it's just a number and it's hexadecimal value...

It is the default PS2->ADB code mapping for Play/Pause. It corresponds to the 0x34 from the keymap as I showed in post #10.
The PS2 code is e0 22 (extended PS2 0x22, make: e0 22, break: e0 a2)
If you wanted to send make and break for that ps2 code from ACPI code, you would use Notify(..., 0x0422).
 
Status
Not open for further replies.
Back
Top