3 #include "LEDAnimation.h"
5 #include <InterfaceDefs.h>
9 #define SNOOZE_TIME 150000
12 LEDAnimation::LEDAnimation()
16 fOrigModifiers(::modifiers())
21 LEDAnimation::~LEDAnimation()
30 // don't do anything if the thread is already running
34 fOrigModifiers
= ::modifiers();
35 ::set_keyboard_locks(0);
37 fThread
= ::spawn_thread(AnimationThread
,"LED thread",B_NORMAL_PRIORITY
,this);
38 ::resume_thread(fThread
);
45 // don't do anything if the thread doesn't run
51 ::wait_for_thread(fThread
,&result
);
53 ::set_keyboard_locks(fOrigModifiers
);
58 LEDAnimation::AnimationThread(void* data
)
60 LEDAnimation
*anim
= (LEDAnimation
*)data
;
62 while (anim
->fRunning
) {
64 LED(B_NUM_LOCK
,false);
66 LED(B_CAPS_LOCK
,true);
67 LED(B_CAPS_LOCK
,false);
69 LED(B_SCROLL_LOCK
,true);
70 LED(B_SCROLL_LOCK
,false);
72 LED(B_CAPS_LOCK
,true);
73 LED(B_CAPS_LOCK
,false);
81 LEDAnimation::LED(uint32 mod
,bool on
)
83 uint32 current_modifiers
= ::modifiers();
85 current_modifiers
|= mod
;
87 current_modifiers
&= ~mod
;
88 ::set_keyboard_locks(current_modifiers
);
90 ::snooze(SNOOZE_TIME
);