forked from len0rd/rockbox
nwztools/plattools: switch to BACK key to quit
The power off/option does not exist on some models. Change-Id: Ifb45293b3b3faa96d9fece2340cbd98299a4a0b7
This commit is contained in:
parent
d42b43c786
commit
794104dd17
5 changed files with 22 additions and 22 deletions
|
|
@ -24,7 +24,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* clear screen and display welcome message */
|
/* clear screen and display welcome message */
|
||||||
nwz_lcdmsg(true, 0, 0, "test_adc");
|
nwz_lcdmsg(true, 0, 0, "test_adc");
|
||||||
nwz_lcdmsg(false, 0, 2, "PWR OFF: quit");
|
nwz_lcdmsg(false, 0, 2, "BACK: quit");
|
||||||
/* open input device */
|
/* open input device */
|
||||||
int input_fd = nwz_key_open();
|
int input_fd = nwz_key_open();
|
||||||
if(input_fd < 0)
|
if(input_fd < 0)
|
||||||
|
|
@ -55,7 +55,7 @@ int main(int argc, char **argv)
|
||||||
struct input_event evt;
|
struct input_event evt;
|
||||||
if(nwz_key_read_event(input_fd, &evt) != 1)
|
if(nwz_key_read_event(input_fd, &evt) != 1)
|
||||||
continue;
|
continue;
|
||||||
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_OPTION && !nwz_key_event_is_press(&evt))
|
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* finish nicely */
|
/* finish nicely */
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* clear screen and display welcome message */
|
/* clear screen and display welcome message */
|
||||||
nwz_lcdmsg(true, 0, 0, "test_bl");
|
nwz_lcdmsg(true, 0, 0, "test_bl");
|
||||||
nwz_lcdmsg(false, 0, 2, "UP/DOWN: level");
|
nwz_lcdmsg(false, 0, 2, "LEFT/RIGHT: level");
|
||||||
nwz_lcdmsg(false, 0, 3, "LEFT/RIGHT: step");
|
nwz_lcdmsg(false, 0, 3, "UP/DOWN: step");
|
||||||
nwz_lcdmsg(false, 0, 4, "VOL UP/DOWN: period");
|
nwz_lcdmsg(false, 0, 4, "VOL UP/DOWN: period");
|
||||||
nwz_lcdmsg(false, 0, 5, "PWR OFF: quit");
|
nwz_lcdmsg(false, 0, 5, "BACK: quit");
|
||||||
/* open input and framebuffer device */
|
/* open input and framebuffer device */
|
||||||
int input_fd = nwz_key_open();
|
int input_fd = nwz_key_open();
|
||||||
if(input_fd < 0)
|
if(input_fd < 0)
|
||||||
|
|
@ -65,25 +65,25 @@ int main(int argc, char **argv)
|
||||||
/* only act on release */
|
/* only act on release */
|
||||||
if(press)
|
if(press)
|
||||||
continue;
|
continue;
|
||||||
if(code == NWZ_KEY_OPTION)
|
if(code == NWZ_KEY_BACK)
|
||||||
break; /* quit */
|
break; /* quit */
|
||||||
bool change_bl = false;
|
bool change_bl = false;
|
||||||
if(code == NWZ_KEY_UP && bl.level < NWZ_FB_BL_MAX_LEVEL)
|
if(code == NWZ_KEY_RIGHT && bl.level < NWZ_FB_BL_MAX_LEVEL)
|
||||||
{
|
{
|
||||||
change_bl = true;
|
change_bl = true;
|
||||||
bl.level++;
|
bl.level++;
|
||||||
}
|
}
|
||||||
else if(code == NWZ_KEY_DOWN && bl.level > NWZ_FB_BL_MIN_LEVEL)
|
else if(code == NWZ_KEY_LEFT && bl.level > NWZ_FB_BL_MIN_LEVEL)
|
||||||
{
|
{
|
||||||
change_bl = true;
|
change_bl = true;
|
||||||
bl.level--;
|
bl.level--;
|
||||||
}
|
}
|
||||||
else if(code == NWZ_KEY_RIGHT && bl.step < NWZ_FB_BL_MAX_STEP)
|
else if(code == NWZ_KEY_UP && bl.step < NWZ_FB_BL_MAX_STEP)
|
||||||
{
|
{
|
||||||
change_bl = true;
|
change_bl = true;
|
||||||
bl.step++;
|
bl.step++;
|
||||||
}
|
}
|
||||||
else if(code == NWZ_KEY_LEFT && bl.step > NWZ_FB_BL_MIN_STEP)
|
else if(code == NWZ_KEY_DOWN && bl.step > NWZ_FB_BL_MIN_STEP)
|
||||||
{
|
{
|
||||||
change_bl = true;
|
change_bl = true;
|
||||||
bl.step--;
|
bl.step--;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* clear screen and display welcome message */
|
/* clear screen and display welcome message */
|
||||||
nwz_lcdmsg(true, 0, 0, "test_keys");
|
nwz_lcdmsg(true, 0, 0, "test_keys");
|
||||||
nwz_lcdmsg(false, 0, 2, "hold PWR OFF for 3 seconds to quit");
|
nwz_lcdmsg(false, 0, 2, "hold BACK for 3 seconds to quit");
|
||||||
/* open input device */
|
/* open input device */
|
||||||
int input_fd = nwz_key_open();
|
int input_fd = nwz_key_open();
|
||||||
if(input_fd < 0)
|
if(input_fd < 0)
|
||||||
|
|
@ -34,7 +34,7 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* display input state in a loop */
|
/* display input state in a loop */
|
||||||
int pwr_off_pressed = 0; /* 0 = no pressed, >0 = number of seconds pressed - 1 */
|
int back_pressed = 0; /* 0 = no pressed, >0 = number of seconds pressed - 1 */
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
/* display HOLD status */
|
/* display HOLD status */
|
||||||
|
|
@ -43,9 +43,9 @@ int main(int argc, char **argv)
|
||||||
int ret = nwz_key_wait_event(input_fd, 1000000);
|
int ret = nwz_key_wait_event(input_fd, 1000000);
|
||||||
if(ret != 1)
|
if(ret != 1)
|
||||||
{
|
{
|
||||||
if(pwr_off_pressed > 0)
|
if(back_pressed > 0)
|
||||||
pwr_off_pressed++;
|
back_pressed++;
|
||||||
if(pwr_off_pressed >= 4)
|
if(back_pressed >= 4)
|
||||||
break;
|
break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -56,10 +56,10 @@ int main(int argc, char **argv)
|
||||||
nwz_key_get_name(nwz_key_event_get_keycode(&evt)),
|
nwz_key_get_name(nwz_key_event_get_keycode(&evt)),
|
||||||
nwz_key_event_is_press(&evt) ? "pressed" : "released",
|
nwz_key_event_is_press(&evt) ? "pressed" : "released",
|
||||||
nwz_key_event_get_hold_status(&evt));
|
nwz_key_event_get_hold_status(&evt));
|
||||||
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_OPTION && nwz_key_event_is_press(&evt))
|
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && nwz_key_event_is_press(&evt))
|
||||||
pwr_off_pressed = 1;
|
back_pressed = 1;
|
||||||
else
|
else
|
||||||
pwr_off_pressed = 0;
|
back_pressed = 0;
|
||||||
}
|
}
|
||||||
/* close input device */
|
/* close input device */
|
||||||
close(input_fd);
|
close(input_fd);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* clear screen and display welcome message */
|
/* clear screen and display welcome message */
|
||||||
nwz_lcdmsg(true, 0, 0, "test_power");
|
nwz_lcdmsg(true, 0, 0, "test_power");
|
||||||
nwz_lcdmsg(false, 0, 2, "PWR OFF: quit");
|
nwz_lcdmsg(false, 0, 2, "BACK: quit");
|
||||||
/* open input device */
|
/* open input device */
|
||||||
int input_fd = nwz_key_open();
|
int input_fd = nwz_key_open();
|
||||||
if(input_fd < 0)
|
if(input_fd < 0)
|
||||||
|
|
@ -126,7 +126,7 @@ int main(int argc, char **argv)
|
||||||
struct input_event evt;
|
struct input_event evt;
|
||||||
if(nwz_key_read_event(input_fd, &evt) != 1)
|
if(nwz_key_read_event(input_fd, &evt) != 1)
|
||||||
continue;
|
continue;
|
||||||
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_OPTION && !nwz_key_event_is_press(&evt))
|
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* finish nicely */
|
/* finish nicely */
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* clear screen and display welcome message */
|
/* clear screen and display welcome message */
|
||||||
nwz_lcdmsg(true, 0, 0, "test_ts");
|
nwz_lcdmsg(true, 0, 0, "test_ts");
|
||||||
nwz_lcdmsg(false, 0, 2, "PWR OFF: quit");
|
nwz_lcdmsg(false, 0, 2, "BACK: quit");
|
||||||
/* open input device */
|
/* open input device */
|
||||||
int key_fd = nwz_key_open();
|
int key_fd = nwz_key_open();
|
||||||
if(key_fd < 0)
|
if(key_fd < 0)
|
||||||
|
|
@ -61,7 +61,7 @@ int main(int argc, char **argv)
|
||||||
struct input_event evt;
|
struct input_event evt;
|
||||||
if(nwz_key_read_event(key_fd, &evt) == 1)
|
if(nwz_key_read_event(key_fd, &evt) == 1)
|
||||||
{
|
{
|
||||||
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_OPTION &&
|
if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK &&
|
||||||
nwz_key_event_is_press(&evt))
|
nwz_key_event_is_press(&evt))
|
||||||
break; /* quit */
|
break; /* quit */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue