Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Media keys works #332

Closed
tmk opened this issue Apr 17, 2016 · 5 comments
Closed

How Media keys works #332

tmk opened this issue Apr 17, 2016 · 5 comments

Comments

@tmk
Copy link
Owner

tmk commented Apr 17, 2016

System/Media Keycodes

Short/long names

/* Sytem Control */
#define KC_PWR KC_SYSTEM_POWER
#define KC_SLEP KC_SYSTEM_SLEEP
#define KC_WAKE KC_SYSTEM_WAKE
/* Consumer Page */
#define KC_MUTE KC_AUDIO_MUTE
#define KC_VOLU KC_AUDIO_VOL_UP
#define KC_VOLD KC_AUDIO_VOL_DOWN
#define KC_MNXT KC_MEDIA_NEXT_TRACK
#define KC_MPRV KC_MEDIA_PREV_TRACK
#define KC_MFFD KC_MEDIA_FAST_FORWARD
#define KC_MRWD KC_MEDIA_REWIND
#define KC_MSTP KC_MEDIA_STOP
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
#define KC_EJCT KC_MEDIA_EJECT
#define KC_MSEL KC_MEDIA_SELECT
#define KC_MAIL KC_MAIL
#define KC_CALC KC_CALCULATOR
#define KC_MYCM KC_MY_COMPUTER
#define KC_WSCH KC_WWW_SEARCH
#define KC_WHOM KC_WWW_HOME
#define KC_WBAK KC_WWW_BACK
#define KC_WFWD KC_WWW_FORWARD
#define KC_WSTP KC_WWW_STOP
#define KC_WREF KC_WWW_REFRESH
#define KC_WFAV KC_WWW_FAVORITES

/* Sytem Control */
#define KC_PWR  KC_SYSTEM_POWER
#define KC_SLEP KC_SYSTEM_SLEEP
#define KC_WAKE KC_SYSTEM_WAKE
/* Consumer Page */
#define KC_MUTE KC_AUDIO_MUTE
#define KC_VOLU KC_AUDIO_VOL_UP
#define KC_VOLD KC_AUDIO_VOL_DOWN
#define KC_MNXT KC_MEDIA_NEXT_TRACK
#define KC_MPRV KC_MEDIA_PREV_TRACK
#define KC_MFFD KC_MEDIA_FAST_FORWARD
#define KC_MRWD KC_MEDIA_REWIND
#define KC_MSTP KC_MEDIA_STOP
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
#define KC_EJCT KC_MEDIA_EJECT
#define KC_MSEL KC_MEDIA_SELECT
#define KC_MAIL KC_MAIL
#define KC_CALC KC_CALCULATOR
#define KC_MYCM KC_MY_COMPUTER
#define KC_WSCH KC_WWW_SEARCH
#define KC_WHOM KC_WWW_HOME
#define KC_WBAK KC_WWW_BACK
#define KC_WFWD KC_WWW_FORWARD
#define KC_WSTP KC_WWW_STOP
#define KC_WREF KC_WWW_REFRESH
#define KC_WFAV KC_WWW_FAVORITES

keycode to system/consumer usage translation

/* keycode to system usage */
#define KEYCODE2SYSTEM(key) \
(key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
(key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
(key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
/* keycode to consumer usage */
#define KEYCODE2CONSUMER(key) \
(key == KC_AUDIO_MUTE ? AUDIO_MUTE : \
(key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
(key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
(key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
(key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
(key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \
(key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \
(key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
(key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \
(key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
(key == KC_MEDIA_SELECT ? APPLAUNCH_CC_CONFIG : \
(key == KC_MAIL ? APPLAUNCH_EMAIL : \
(key == KC_CALCULATOR ? APPLAUNCH_CALCULATOR : \
(key == KC_MY_COMPUTER ? APPLAUNCH_LOCAL_BROWSER : \
(key == KC_WWW_SEARCH ? APPCONTROL_SEARCH : \
(key == KC_WWW_HOME ? APPCONTROL_HOME : \
(key == KC_WWW_BACK ? APPCONTROL_BACK : \
(key == KC_WWW_FORWARD ? APPCONTROL_FORWARD : \
(key == KC_WWW_STOP ? APPCONTROL_STOP : \
(key == KC_WWW_REFRESH ? APPCONTROL_REFRESH : \
(key == KC_WWW_FAVORITES ? APPCONTROL_BOOKMARKS : 0)))))))))))))))))))))

/* keycode to system usage */
#define KEYCODE2SYSTEM(key) \
    (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
    (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
    (key == KC_SYSTEM_WAKE  ? SYSTEM_WAKE_UP : 0)))

/* keycode to consumer usage */
#define KEYCODE2CONSUMER(key) \
    (key == KC_AUDIO_MUTE           ?  AUDIO_MUTE : \
    (key == KC_AUDIO_VOL_UP         ?  AUDIO_VOL_UP : \
    (key == KC_AUDIO_VOL_DOWN       ?  AUDIO_VOL_DOWN : \
    (key == KC_MEDIA_NEXT_TRACK     ?  TRANSPORT_NEXT_TRACK : \
    (key == KC_MEDIA_PREV_TRACK     ?  TRANSPORT_PREV_TRACK : \
    (key == KC_MEDIA_FAST_FORWARD   ?  TRANSPORT_FAST_FORWARD : \
    (key == KC_MEDIA_REWIND         ?  TRANSPORT_REWIND : \
    (key == KC_MEDIA_STOP           ?  TRANSPORT_STOP : \
    (key == KC_MEDIA_EJECT          ?  TRANSPORT_STOP_EJECT : \
    (key == KC_MEDIA_PLAY_PAUSE     ?  TRANSPORT_PLAY_PAUSE : \
    (key == KC_MEDIA_SELECT         ?  APPLAUNCH_CC_CONFIG : \
    (key == KC_MAIL                 ?  APPLAUNCH_EMAIL : \
    (key == KC_CALCULATOR           ?  APPLAUNCH_CALCULATOR : \
    (key == KC_MY_COMPUTER          ?  APPLAUNCH_LOCAL_BROWSER : \
    (key == KC_WWW_SEARCH           ?  APPCONTROL_SEARCH : \
    (key == KC_WWW_HOME             ?  APPCONTROL_HOME : \
    (key == KC_WWW_BACK             ?  APPCONTROL_BACK : \
    (key == KC_WWW_FORWARD          ?  APPCONTROL_FORWARD : \
    (key == KC_WWW_STOP             ?  APPCONTROL_STOP : \
    (key == KC_WWW_REFRESH          ?  APPCONTROL_REFRESH : \
    (key == KC_WWW_FAVORITES        ?  APPCONTROL_BOOKMARKS : 0)))))))))))))))))))))

Protocol: USB LUFA

Linux Xorg(Ubuntu/Xfce):

Keycode Action
POWER Pop out Logout dialog
PWR Pop out Logout dialog
SLEP No action??
WAKE No action(XF86WakeUp)
MUTE Mute
VOLU Volume Down
VOLD Volume Up
MNXT works in VLC media player (XF86AudioNext)
MPRV works in VLC media player (XF86AudioPrev)
MFFD ?? (XF86AudioForward)
MRWD ?? (XF86AudioRewind)
MSTP works in VLC media player (XF86AudioStop)
MPLY works in VLC media player (XF86AudioPlay)
EJCT No action(NoSymbol)
MSEL No action(XF86Tools)
MAIL No action(XF86Mail)
CALC No action(XF86Calculator)
MYCM No action(XF86Explorer)
WSCH Focus address bar in Chrome49 (XF86Search)
WHOM Load home page in Chrome49 (XF86HomePage)
WBAK History back in Chrome49 (XF86Back)
WFWD History forward in Chrome49 (XF86Forward)
WSTP ??(Cancel)
WREF Refresh in Chrome49 (XF86Reload)
WFAV Toggle bookmark bar in Chrome49 (XF86Favorites)

Windows 10

Keycode Action
POWER No action (BIOS scan code:E05E)
PWR act as Power button on my ThinkPad
SLEP act as Sleep button on my ThinkPad
WAKE No action
MUTE Mute
VOLU Volume Down
VOLD Volume Up
MNXT works in Windows media player
MPRV works in Windows media player
MFFD ??
MRWD ??
MSTP works in Widnows media player
MPLY works in Windows media player
EJCT No action
MSEL Open media player
MAIL Open default Mailer
CALC Open Calculator
MYCM Open Explorer
WSCH Open Search Windows dialog
WHOM Load home page in Internet Explorer
WBAK History back in Internet Explorer
WFWD History forward in Internet Explorer
WSTP Stop loading in Internet Explorer
WREF Refresh in Internet Explorer
WFAV Toggle bookmark pane in Internet Explorer

OSX

Please contribute.

Use MFFD and MRWD instead of MNXT and MPRV.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#media-control-keys-in-mac-osx

Protocol: Bluetooth HHKB w/ RN42

https://geekhack.org/index.php?topic=12047.0
http://www.microchip.com/wwwproducts/en/RN42

Supported usages

RN42 supports only keycodes below.

MUTE
VOLU
VOLD
MNXT
MPRV
MFFD
MRWD
MSTP
MPLY
EJCT
MAIL
WSCH
WHOM

static uint16_t usage2bits(uint16_t usage)
{
switch (usage) {
case AC_HOME: return 0x01;
case AL_EMAIL: return 0x02;
case AC_SEARCH: return 0x04;
//case AL_KBD_LAYOUT: return 0x08; // Apple virtual keybaord toggle
case AUDIO_VOL_UP: return 0x10;
case AUDIO_VOL_DOWN: return 0x20;
case AUDIO_MUTE: return 0x40;
case TRANSPORT_PLAY_PAUSE: return 0x80;
case TRANSPORT_NEXT_TRACK: return 0x100;
case TRANSPORT_PREV_TRACK: return 0x200;
case TRANSPORT_STOP: return 0x400;
case TRANSPORT_STOP_EJECT: return 0x800;
case TRANSPORT_FAST_FORWARD: return 0x1000;
case TRANSPORT_REWIND: return 0x2000;
//case return 0x4000; // Stop/eject
//case return 0x8000; // Internet browser
};
return 0;
}

static uint16_t usage2bits(uint16_t usage)
{
    switch (usage) {
        case AC_HOME:                 return 0x01;
        case AL_EMAIL:                return 0x02;
        case AC_SEARCH:               return 0x04;
        //case AL_KBD_LAYOUT:         return 0x08;  // Apple virtual keybaord toggle
        case AUDIO_VOL_UP:            return 0x10;
        case AUDIO_VOL_DOWN:          return 0x20;
        case AUDIO_MUTE:              return 0x40;
        case TRANSPORT_PLAY_PAUSE:    return 0x80;
        case TRANSPORT_NEXT_TRACK:    return 0x100;
        case TRANSPORT_PREV_TRACK:    return 0x200;
        case TRANSPORT_STOP:          return 0x400;
        case TRANSPORT_STOP_EJECT:    return 0x800;
        case TRANSPORT_FAST_FORWARD:  return 0x1000;
        case TRANSPORT_REWIND:        return 0x2000;
        //case return 0x4000;   // Stop/eject
        //case return 0x8000;   // Internet browser
    };
    return 0;
}

Linux Xorg(Ubuntu/Xfce)

Keycode Action
MUTE Mute
VOLU Volume Down
VOLD Volume Up
MNXT works in VLC media player
MPRV works in VLC media player
MFFD No action
MRWD No action
MSTP works in VLC media player
MPLY works in VLC media player
EJCT No action
MAIL No action
WSCH Open Search Windows dialog
WHOM Load home page in Internet Explorer

Windows 10

Keycode Action
MUTE Mute
VOLU Volume Down
VOLD Volume Up
MNXT works in Windows media player
MPRV works in Windows media player
MFFD ??
MRWD ??
MSTP works in Widnows media player
MPLY works in Windows media player
EJCT No action
MAIL No action
WSCH Focus address bar in Chrome49 (XF86Search)
WHOM Load home page in Chrome49 (XF86HomePage)

OSX

Please contribute.

Use MFFD and MRWD instead of MNXT and MPRV.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#media-control-keys-in-mac-osx

xrigau pushed a commit to xrigau/tmk_keyboard that referenced this issue May 22, 2016
* Add folders to keymaps

* test

* test
@shelaf
Copy link

shelaf commented Jul 9, 2016

I tested on OSX.
Environment:
Keyboard: HHKB Pro2 (with Hasu's Alternative contoller)
Firmware: tmk_keyboard (develop branch, BUILD: f8bab8c)
OS: El Capitan(10.11.5)

Protocol: USB LUFA

OSX (El Capitan)

Keycode Action
PWR press and release: sleep / hold down: show restart, sleep, or shut down dialog
SLEP press and release: sleep / hold down: show restart, sleep, or shut down dialog
WAKE press and release: sleep / hold down: show restart, sleep, or shut down dialog
MUTE Mute
VOLU Volume Up
VOLD Volume Down
MNXT Next track. works in VLC, VOX
MPRV Previous track. works in VLC, VOX
MFFD Next track or fast-foward(hold down). works in VLC, VOX
MRWD Previous track or rewind(hold down). works in VLC, VOX
MSTP No action
MPLY works in VLC, VOX
EJCT No action
MSEL No action
MAIL No action
CALC No action
MYCM No action
WSCH No action
WHOM No action
WBAK No action
WFWD No action
WSTP No action
WREF No action
WFAV No action

@tmk
Copy link
Owner Author

tmk commented Jul 9, 2016

Thank you. It is really helpful.

@tmk
Copy link
Owner Author

tmk commented Jan 28, 2019

Report descriptor fix(feebc23) for #435 may affect to this.
See qmk/qmk_firmware#963 also for detail.

@tmk tmk closed this as completed Feb 8, 2021
@CJacobStucki
Copy link

CJacobStucki commented Mar 9, 2021

MPLY doesn't seem to be working in Windows 10 (MPRV and MNXT work fine).

Backround;
I am using a kbparadise v60 type R polestar, and have programmed it using keyboard layout editor and the tgz.io tool. I use the eep file with a script from kbparadise to flash the keyboard. The .eep file doesn't provide any insite, but the optional .c file from tgz.io does, and it seems to list the key as MPLY correctly. After flashing however, that keycode does nothing...

Can you point me towards a fix for this? I would greatly appreciate it :)

(I've attached the .c file as a .txt file because github doesn't support attaching .c files for some reason... The MPLY is near the bottom left of layer 1)

keymap_c_file.txt

@tmk
Copy link
Owner Author

tmk commented Mar 9, 2021

I just confirmed KC_MPLY(KC_MEDIA_PLAY_PAUSE) still works on Ubuntu/Xfce and Windows 10 with the latest code(a93677c).

Contact with proper firmware maintainer for your keyboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants