A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Rob Purchase
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "plugin.h"
22
23
24
25#if (CONFIG_KEYPAD == COWON_D2_PAD)
26#define TOUCHSCREEN_QUIT BUTTON_POWER
27#define TOUCHSCREEN_TOGGLE BUTTON_MENU
28#elif (CONFIG_KEYPAD == MROBE500_PAD)
29#define TOUCHSCREEN_QUIT BUTTON_POWER
30#define TOUCHSCREEN_TOGGLE BUTTON_RC_MODE
31#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
32#define TOUCHSCREEN_QUIT BUTTON_POWER
33#define TOUCHSCREEN_TOGGLE BUTTON_MENU
34#elif (CONFIG_KEYPAD == ONDAVX777_PAD)
35#define TOUCHSCREEN_QUIT BUTTON_POWER
36#define TOUCHSCREEN_TOGGLE BUTTON_MENU
37#elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD
38#define TOUCHSCREEN_QUIT BUTTON_POWER
39#define TOUCHSCREEN_TOGGLE BUTTON_MENU
40#elif CONFIG_KEYPAD == SHANLING_Q1_PAD
41#define TOUCHSCREEN_QUIT BUTTON_POWER
42#define TOUCHSCREEN_TOGGLE BUTTON_PLAY
43#elif (CONFIG_KEYPAD == ANDROID_PAD)
44#define TOUCHSCREEN_QUIT BUTTON_BACK
45#define TOUCHSCREEN_TOGGLE BUTTON_MENU
46#elif (CONFIG_KEYPAD == SDL_PAD)
47#define TOUCHSCREEN_QUIT BUTTON_MIDLEFT
48#define TOUCHSCREEN_TOGGLE BUTTON_CENTER
49#else
50# error "No keymap defined!"
51#endif
52
53/* plugin entry point */
54enum plugin_status plugin_start(const void* parameter)
55{
56 int button = 0;
57 enum touchscreen_mode mode = TOUCHSCREEN_BUTTON;
58
59 /* standard stuff */
60 (void)parameter;
61
62 rb->touchscreen_set_mode(mode);
63
64 /* wait until user closes plugin */
65 do
66 {
67 short x = 0;
68 short y = 0;
69 bool draw_rect = false;
70
71 button = rb->button_get(true);
72
73 if (button & BUTTON_TOPLEFT)
74 {
75 draw_rect = true;
76 x = 0; y = 0;
77 }
78 else if (button & BUTTON_TOPMIDDLE)
79 {
80 draw_rect = true;
81 x = LCD_WIDTH/3; y = 0;
82 }
83 else if (button & BUTTON_TOPRIGHT)
84 {
85 draw_rect = true;
86 x = 2*(LCD_WIDTH/3); y = 0;
87 }
88 else if (button & BUTTON_MIDLEFT)
89 {
90 draw_rect = true;
91 x = 0; y = LCD_HEIGHT/3;
92 }
93 else if (button & BUTTON_CENTER)
94 {
95 draw_rect = true;
96 x = LCD_WIDTH/3; y = LCD_HEIGHT/3;
97 }
98 else if (button & BUTTON_MIDRIGHT)
99 {
100 draw_rect = true;
101 x = 2*(LCD_WIDTH/3); y = LCD_HEIGHT/3;
102 }
103 else if (button & BUTTON_BOTTOMLEFT)
104 {
105 draw_rect = true;
106 x = 0; y = 2*(LCD_HEIGHT/3);
107 }
108 else if (button & BUTTON_BOTTOMMIDDLE)
109 {
110 draw_rect = true;
111 x = LCD_WIDTH/3; y = 2*(LCD_HEIGHT/3);
112 }
113 else if (button & BUTTON_BOTTOMRIGHT)
114 {
115 draw_rect = true;
116 x = 2*(LCD_WIDTH/3); y = 2*(LCD_HEIGHT/3);
117 }
118
119 if (button & TOUCHSCREEN_TOGGLE && (button & BUTTON_REL))
120 {
121 mode = (mode == TOUCHSCREEN_POINT) ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT;
122 rb->touchscreen_set_mode(mode);
123 }
124
125 if (button & BUTTON_REL) draw_rect = false;
126
127 rb->lcd_clear_display();
128
129 if (draw_rect)
130 {
131 rb->lcd_set_foreground(LCD_RGBPACK(0xc0, 0, 0));
132 rb->lcd_fillrect(x, y, LCD_WIDTH/3, LCD_HEIGHT/3);
133 }
134
135 if (draw_rect || button & BUTTON_TOUCHSCREEN)
136 {
137 intptr_t button_data = rb->button_get_data();
138 x = button_data >> 16;
139 y = button_data & 0xffff;
140
141 rb->lcd_set_foreground(LCD_RGBPACK(0, 0, 0xc0));
142 rb->lcd_fillrect(x-7, y-7, 14, 14);
143
144 /* in stylus mode, show REL position in black */
145 if (mode == TOUCHSCREEN_POINT && (button & BUTTON_REL))
146 rb->lcd_set_foreground(LCD_BLACK);
147 else
148 rb->lcd_set_foreground(LCD_WHITE);
149
150 rb->lcd_hline(x-5, x+5, y);
151 rb->lcd_vline(x, y-5, y+5);
152 }
153 rb->lcd_update();
154
155 } while (button != TOUCHSCREEN_QUIT);
156
157 return PLUGIN_OK;
158}