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

F1/F2 Brightness for iOS #23

Open
balsman225 opened this issue May 6, 2020 · 6 comments
Open

F1/F2 Brightness for iOS #23

balsman225 opened this issue May 6, 2020 · 6 comments

Comments

@balsman225
Copy link

I am trying to use an ESP32 to control a wall mounted iPad screen brightness (plan on pairing this library with MQTT).

On a normal Apple Bluetooth keyboard you can used F1 and F2 to adjust the brightness.
I have looked over Keyboard Modifier

I tried several combination without success
bleKeyboard.press(KEY_F1)
bleKeyboard.write(KEY_F1)
bleKeyboard.press(194)
bleKeyboard.write(194)
bleKeyboard.write(0xC2)

When testing with the "SendKeyStrokes" sketch I am able to get all other tests to work.
KEY_MEDIA_VOLUME_UP and KEY_MEDIA_VOLUME_DOWN work fine as well.

I'm curious if I need to create a custom "KEY_MEDIA" for brightness since iOS does not seem to be responding to F1/F2 keys

Thank you for the assistance
Also - Thank you for the great library

@T-vK
Copy link
Owner

T-vK commented May 6, 2020

Can you check if your keys are recognized in any way? https://www.keyboardtester.com/tester.html

@balsman225
Copy link
Author

Thanks for the pointer - I looked over #3 and tested something out -
I changed the Volume increase and decrease to a custom brightness button.

I found the needed Hex for the Brightness Adjustment Link Here

For Brightness Up -

USAGE(1), 0xE9, // USAGE (Volume Increment) ; bit 5: 32

with

    USAGE(1),           0x006F,        //   USAGE (Brightness Up)       ; bit 5: 32

For Brightness Down -

USAGE(1), 0xEA, // USAGE (Volume Decrement) ; bit 6: 64

with

  USAGE(1),           0x0070,        //   USAGE (Brightness Down)     ; bit 6: 64

For Brightness Up -

const MediaKeyReport KEY_MEDIA_VOLUME_UP = {32, 0};

with

const MediaKeyReport KEY_MEDIA_BRIGHTNESS_UP = {32, 0};

For Brightness Down -

const MediaKeyReport KEY_MEDIA_VOLUME_DOWN = {64, 0};

with

const MediaKeyReport KEY_MEDIA_BRIGHTNESS_DOWN = {64, 0};

Once I added
bleKeyboard.write(KEY_MEDIA_BRIGHTNESS_UP)
and
bleKeyboard.write(KEY_MEDIA_BRIGHTNESS_DOWN)
to my test sketch It seems to be working great now.

This is all new to me so I don't know how to help added this to as a new media key in the library instead of stealing the volume entries but I would be happy to test for you if needed.

@T-vK
Copy link
Owner

T-vK commented May 11, 2020

I can't quite remember, but I think there was a reason why I only implemented a few media keys. Maybe it was a limitation in the hid descriptor or some kind of compatibility issue with the official Arduino USB keyboard library. If it was easy, I would of course have added way more, if not all media keys.
But thanks for sharing. This is probably gonna be useful to someone in the future.

@theguaz
Copy link

theguaz commented May 31, 2022

@balsman225 @T-vK Hello !, first of all nice work, I've found your solution while browsing for brightness control using BLe devices, I followed the changes u made in both files to basically swap the volume control with brightness control but so far when I swaped the values I only get volume control on iOS (iphone) but it behaves correctly on OSX (MacbookPro).

In CPP file:
//const MediaKeyReport KEY_MEDIA_VOLUME_UP = {32, 0};
//const MediaKeyReport KEY_MEDIA_VOLUME_DOWN = {64, 0};

const MediaKeyReport KEY_MEDIA_BRIGHTNESS_UP = {32, 0};
const MediaKeyReport KEY_MEDIA_BRIGHTNESS_DOWN = {64, 0};

In H file:
USAGE(1),           0xCD,          //   USAGE (Play/Pause)          ; bit 3: 8
USAGE(1),           0xE2,          //   USAGE (Mute)                ; bit 4: 16
USAGE(1),           0x006F,        	//   USAGE (Bright Increment)    ; bit 5: 32
USAGE(1),           0x0070,        	//   USAGE (Bright Decrement)    ; bit 6: 64
USAGE(2),           0x23, 0x02,    //   Usage (WWW Home)            ; bit 7: 128

The hexadecimal needs to be edited somewhere else in order to trigger brightness?
Thank you in advance :)

@TanjuDuygu
Copy link

TanjuDuygu commented Feb 15, 2023

Hi balsman.

You are on the right way

USAGE(1), 0x006F, // USAGE (Bright Increment) ; bit 5: 32
USAGE(1), 0x0070, // USAGE (Bright Decrement) ; bit 6: 64

You need just need unpair (forget device on your iphone bluetoot menu) and again pair your bluetooth device on your iphone. I treid %100 working birightness on my iphone and ipad. If you din't refresh pair still stick working just volume up and down.
Good luck

@and7ey
Copy link

and7ey commented Dec 5, 2023

@balsman225 sorry for off top question - is it possible to switch off the iOS screen with ESP32 keyboard? or to lock the iPad?

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

No branches or pull requests

5 participants