# How to add volume control in stand alone emulators

**URL:** <https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144>\
**Category:** Tutorials\
**Created:** [July 26, 2019, 3:27am UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144 "2019-07-26T03:27:23Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![namanjohnson101](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/namanjohnson101/32/3467_2.png) [@namanjohnson101](https://forum.clockworkpi.com/u/namanjohnson101)\
**Post date:** [September 28, 2019, 7:52am UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/22 "2019-09-28T07:52:24Z")

</div>

hello,

i am trying this , but it doesn’t work out for me i have still same problem now if any know how to fix this issue than please tell me

thanks in advance

---

<div class="post-metadata">

**Author:** ![javelinface](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/javelinface/32/3079_2.png) [@javelinface](https://forum.clockworkpi.com/u/javelinface)\
**Post date:** [September 28, 2019, 3:13pm UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/23 "2019-09-28T15:13:50Z")

</div>

Did you go to the github page, following the link, and follow the instruction; in particular pertaining to using the editor “nano”?

If you don’t do this, it won’t work. Make sure you write your changes to the file. Preferably do it this way for formatting and mode change/permission reasons. There are other ways, but you may end up messing something up if you don’t know what you’re doing.

> <https://github.com/zfteam/gameshell_backlight_hotkey/blob/master/README.md>

Don’t forget the “&” at the end of the ammendment.

---

<div class="post-metadata">

**Author:** ![namair](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@namair](https://forum.clockworkpi.com/u/namair)\
**Post date:** [October 2, 2019, 3:48am UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/24 "2019-10-02T03:48:47Z")

</div>

thank you for your tutorial, I got it work!!!  
however there is a slight issue: the backlight brightness key was inverted for me. Select + down: brighter, Select + up: dimmer. Otherwise everything works fine!

---

<div class="post-metadata">

**Author:** ![javelinface](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/javelinface/32/3079_2.png) [@javelinface](https://forum.clockworkpi.com/u/javelinface)\
**Post date:** [October 2, 2019, 5:38am UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/25 "2019-10-02T05:38:01Z")

</div>

Hey, I actually modified the code in my post here to have the backlight corrected. The original posted had DPAD-UP as brightness down, and DPAD-DOWN as brightness up, which as you mentioned is inverted.  
I also changed the incremental changes of the volume, as it went up 20% after each push.

> [@How to add volume control in stand alone emulators](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/15):
>
> IMPORTANT!! BACK UP BEFORE COPYING ANY SYSTEM FILES!! If you don’t do this correctly, your device may not start up, and you will need to reflash your system!! I’ve just uploaded my rc.local file, pre edited. Copy it to the etc directory. This is basically Step 2 of the readme file. I would however strongly recommend you use nano or another editor to edit the file yourself. 2.add reboot command shell "sudo nano /etc/rc.local" open rc.local file and input this to the last line nohup python…

It’s the same thing that this user did. I just prepared the code:

> [@How to add volume control in stand alone emulators](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/5):
>
> There’s no big change ! Look there : The script enables you to control volume via select + left/right and brightness via select + up/down everywhere. I personnally changed the values of amount volume modification to 4 because 20 is too much. And I also inverted the brightnessTool.Further() and brightnessTool.StepBack() , so select+up increase and select+down decrease brightness.

---

<div class="post-metadata">

**Author:** ![namair](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@namair](https://forum.clockworkpi.com/u/namair)\
**Post date:** [October 2, 2019, 6:09am UTC](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144/26 "2019-10-02T06:09:44Z")

</div>

> [@javelinface](#):
>
> import time from evdev import InputDevice from select import select from tools.brightness\_tool import BrightnessTool import alsaaudio m = alsaaudio.Mixer() sound\_volume=m.getvolume()[0] # print(“cur aound volume:%d”,sound\_volume) dev = InputDevice(‘/dev/input/event1’) select\_press=False while True: select([dev], , ) for event in dev.read(): # print “code:%s value:%s” % (event.code, event.value) if (event.code==57 and event.value==1): select\_press=True # print(“sel press”) elif(event.code==57 and event.value==0): select\_press=False if(select\_press==True and event.code==103 and event.value==1): brightnessTool = BrightnessTool() brightnessTool.Further() del brightnessTool elif(select\_press==True and event.code==108 and event.value==1): brightnessTool = BrightnessTool() brightnessTool.StepBack() del brightnessTool elif(select\_press==True and event.code==105 and event.value==1): sound\_volume=sound\_volume - 4 if(sound\_volume\<0): sound\_volume=0 try: m = alsaaudio.Mixer() m.setvolume(sound\_volume) except Exception,e: print(str(e)) elif(select\_press==True and event.code==106 and event.value==1): sound\_volume=sound\_volume + 4 if(sound\_volume\>100): sound\_volume=98 try: m = alsaaudio.Mixer() m.setvolume(sound\_volume) except Exception,e: print(str(e))

Oh thank you, I thought the file “backlight\_hotkey.py” was already modified that’s why.  
I have copied your code and modified backlight\_hotkey.py and now it’s works fine!  
Thank you again!

[Previous page](https://forum.clockworkpi.com/t/how-to-add-volume-control-in-stand-alone-emulators/4144.md?page=1)
