akane_sound 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/akane_sound +4 -0
- data/data/NotoSansCJKjp-Bold.otf +0 -0
- data/data/NotoSansCJKjp-Medium.otf +0 -0
- data/data/NotoSansCJKjp-Regular.otf +0 -0
- data/data/akane_bg.png +0 -0
- data/data/config.yaml +79 -0
- data/data/save_data.yaml +14 -0
- data/lib/akane_sound.rb +214 -0
- data/lib/akane_sound/class.background.rb +66 -0
- data/lib/akane_sound/class.element.rb +13 -0
- data/lib/akane_sound/class.input.rb +356 -0
- data/lib/akane_sound/class.section_dir.rb +108 -0
- data/lib/akane_sound/class.section_playlist.rb +87 -0
- data/lib/akane_sound/class.section_status.rb +223 -0
- data/lib/akane_sound/class.setup.rb +60 -0
- data/lib/akane_sound/class.sound.rb +381 -0
- data/lib/akane_sound/class.upper_section_base.rb +421 -0
- data/lib/akane_sound/class.view_base.rb +24 -0
- data/lib/akane_sound/module.util.rb +48 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 05e08e2a4733d384835cf4c9aef5dafd56f8d96d94cbfd9dcb2685ec7d175030
|
4
|
+
data.tar.gz: a93c37248fae9eb06677126d26cb793b1100ed8382a838dd80b8ae4a41e6d955
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c7e6570560976108332a884d657bcd1e7e9d85bfdbdf1a6df1b82fb1735228313890c5ca77b44a7186157d54dca5974c929024ac06a7960517fb8762b3aa791
|
7
|
+
data.tar.gz: 929437fe3cc9ceabeb4e766f12fbfae463eea3d0730348ac8ebdd5b145803f16f370f770ff91bbc992f420cb37c02a6b4ad11ad68c0894829bbdc6783cfe8cab
|
data/bin/akane_sound
ADDED
Binary file
|
Binary file
|
Binary file
|
data/data/akane_bg.png
ADDED
Binary file
|
data/data/config.yaml
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
:window_w: 640
|
3
|
+
:window_h: 480
|
4
|
+
:sleep_timer: 60 # seconds without input until player goes into sleep. 0 disables the feature
|
5
|
+
:bg_img: 'data/akane_bg.png'
|
6
|
+
:font: 'data/NotoSansCJKjp-Regular.otf'
|
7
|
+
:font_big: 'data/NotoSansCJKjp-Bold.otf'
|
8
|
+
:font_size: 12
|
9
|
+
:line_height_mod: 1.5
|
10
|
+
:root_dir: 'FILE_PATH_ROOT'
|
11
|
+
:root_dir_debug: ''
|
12
|
+
:bg_type: 'normal' # 'none', 'normal', 'center', 'repeat'
|
13
|
+
:bg_color:
|
14
|
+
:red: 0
|
15
|
+
:green: 12
|
16
|
+
:blue: 27
|
17
|
+
:alpha: 225
|
18
|
+
:view_left_bg_color:
|
19
|
+
:red: 200
|
20
|
+
:green: 0
|
21
|
+
:blue: 20
|
22
|
+
:alpha: 0
|
23
|
+
:view_right_bg_color:
|
24
|
+
:red: 0
|
25
|
+
:green: 200
|
26
|
+
:blue: 20
|
27
|
+
:alpha: 0
|
28
|
+
:view_bottom_bg_color:
|
29
|
+
:red: 0
|
30
|
+
:green: 0
|
31
|
+
:blue: 20
|
32
|
+
:alpha: 255
|
33
|
+
:fg_color:
|
34
|
+
:red: 255
|
35
|
+
:green: 255
|
36
|
+
:blue: 255
|
37
|
+
:alpha: 255
|
38
|
+
:text_color:
|
39
|
+
:red: 255
|
40
|
+
:green: 255
|
41
|
+
:blue: 255
|
42
|
+
:alpha: 255
|
43
|
+
:text_color_selected:
|
44
|
+
:red: 200
|
45
|
+
:green: 255
|
46
|
+
:blue: 200
|
47
|
+
:alpha: 255
|
48
|
+
:text_color_status:
|
49
|
+
:red: 255
|
50
|
+
:green: 255
|
51
|
+
:blue: 255
|
52
|
+
:alpha: 255
|
53
|
+
:text_color_disabled:
|
54
|
+
:red: 120
|
55
|
+
:green: 120
|
56
|
+
:blue: 120
|
57
|
+
:alpha: 255
|
58
|
+
:volume_bar_color:
|
59
|
+
:red: 0
|
60
|
+
:green: 155
|
61
|
+
:blue: 80
|
62
|
+
:alpha: 255
|
63
|
+
:volume_bar_max_color:
|
64
|
+
:red: 155
|
65
|
+
:green: 0
|
66
|
+
:blue: 80
|
67
|
+
:alpha: 255
|
68
|
+
:prog_bar_color:
|
69
|
+
:red: 0
|
70
|
+
:green: 155
|
71
|
+
:blue: 155
|
72
|
+
:alpha: 255
|
73
|
+
:select_bg_color:
|
74
|
+
:red: 0
|
75
|
+
:green: 0
|
76
|
+
:blue: 0
|
77
|
+
:alpha: 200
|
78
|
+
|
79
|
+
|
data/data/save_data.yaml
ADDED
data/lib/akane_sound.rb
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
require "sdl2"
|
2
|
+
require "yaml"
|
3
|
+
require "akane_sound/module.util"
|
4
|
+
|
5
|
+
class Integer
|
6
|
+
def bit?(mask)
|
7
|
+
(self & mask) != 0
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class AkaneSound
|
12
|
+
@@window = nil
|
13
|
+
@@win_w = 0
|
14
|
+
@@win_h = 0
|
15
|
+
@@renderer = nil
|
16
|
+
@@pref_dir = nil
|
17
|
+
@@screen = nil
|
18
|
+
@@sec_status = nil
|
19
|
+
@@sec_dir = nil
|
20
|
+
@@sec_pl = nil
|
21
|
+
@@sound = nil
|
22
|
+
@@config = Hash.new
|
23
|
+
@@save_data = Hash.new
|
24
|
+
@@cache = Hash.new
|
25
|
+
@@alert_flag = false
|
26
|
+
@@inp = nil
|
27
|
+
@@debug_flag = false
|
28
|
+
@@font = nil
|
29
|
+
@@font_bold = nil
|
30
|
+
@@music = nil
|
31
|
+
@@cmd_flag = false
|
32
|
+
@@sleep_flag = false
|
33
|
+
@@tstmp_now = nil
|
34
|
+
@@msg = nil
|
35
|
+
@@msg_rect = nil
|
36
|
+
def initialize
|
37
|
+
SDL2.init(SDL2::INIT_TIMER|SDL2::INIT_AUDIO|SDL2::INIT_VIDEO|
|
38
|
+
SDL2::INIT_EVENTS)
|
39
|
+
SDL2::TTF.init
|
40
|
+
SDL2::Mixer.init(SDL2::Mixer::INIT_FLAC|SDL2::Mixer::INIT_MODPLUG|
|
41
|
+
SDL2::Mixer::INIT_MP3|SDL2::Mixer::INIT_OGG)
|
42
|
+
#SDL2::Mixer.open(44100, SDL2::Mixer::DEFAULT_FORMAT, 2, 512)
|
43
|
+
#SDL2::Mixer.open(48000, SDL2::Mixer::DEFAULT_FORMAT, 2, 512)
|
44
|
+
|
45
|
+
Setup::init(ARGV[0])
|
46
|
+
|
47
|
+
@@window = SDL2::Window.create("akane_sound", SDL2::Window::POS_CENTERED,
|
48
|
+
SDL2::Window::POS_CENTERED,
|
49
|
+
@@config[:window_w], @@config[:window_h],
|
50
|
+
SDL2::Window::Flags::RESIZABLE)
|
51
|
+
@@win_w = @@window.size[0]
|
52
|
+
@@win_h = @@window.size[1]
|
53
|
+
|
54
|
+
@@renderer = @@window.create_renderer(-1, 0)
|
55
|
+
@@screen = SDL2::Rect[0, 0, @@config[:window_w], @@config[:window_h]]
|
56
|
+
@@font = SDL2::TTF.open(@@config[:font], @@config[:font_size])
|
57
|
+
@@font_bold = SDL2::TTF.open(@@config[:font_big], @@config[:font_size])
|
58
|
+
@frames = 0
|
59
|
+
@fps = 30
|
60
|
+
@tstmp_start = nil
|
61
|
+
@tstmp_last_input = SDL2.get_ticks
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def run(argv)
|
66
|
+
bg = Background.new(@@config[:bg_img])
|
67
|
+
@@inp = Input.new
|
68
|
+
@@sound = Sound.new
|
69
|
+
@@sec_status = SectionStatus.new(0, @@config[:window_h]-80,
|
70
|
+
@@config[:window_w], 80,
|
71
|
+
@@config[:view_bottom_bg_color])
|
72
|
+
@@sec_dir = SectionDir.new(0, 0, @@config[:window_w]/2,
|
73
|
+
@@config[:window_h]-80,
|
74
|
+
@@config[:view_left_bg_color])
|
75
|
+
@@sec_pl = SectionPlaylist.new(@@config[:window_w]/2, 0,
|
76
|
+
@@config[:window_w]/2, @@config[:window_h]-80,
|
77
|
+
@@config[:view_right_bg_color])
|
78
|
+
loop do
|
79
|
+
update_fps
|
80
|
+
while event = SDL2::Event.poll
|
81
|
+
@@inp.handle_event(event)
|
82
|
+
end
|
83
|
+
@@inp.set_state
|
84
|
+
#update
|
85
|
+
@tstmp_last_input = SDL2.get_ticks if @@inp.any_key >= 1
|
86
|
+
if @@inp.quit >= 1
|
87
|
+
save
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
unless @@sleep_flag
|
91
|
+
if @@inp.switch == 1
|
92
|
+
if @@sec_dir.focus_flag
|
93
|
+
@@sec_dir.focus_flag = false
|
94
|
+
@@sec_pl.focus_flag = true
|
95
|
+
else
|
96
|
+
@@sec_dir.focus_flag = true
|
97
|
+
@@sec_pl.focus_flag = false
|
98
|
+
end
|
99
|
+
@@sec_dir.update_element_strings
|
100
|
+
#@@sec_dir.set_page
|
101
|
+
@@sec_dir.update_element_positions
|
102
|
+
@@sec_pl.update_element_strings
|
103
|
+
#@@sec_pl.set_page
|
104
|
+
@@sec_pl.update_element_positions
|
105
|
+
end
|
106
|
+
if @@inp.clear == 1
|
107
|
+
@@sec_pl.clear
|
108
|
+
end
|
109
|
+
if @@inp.write == 1
|
110
|
+
write_playlist
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if @@window.size[0] != @@win_w || @@window.size[1] != @@win_h
|
114
|
+
@@win_w = @@window.size[0]
|
115
|
+
@@win_h = @@window.size[1]
|
116
|
+
@@screen = SDL2::Rect[0, 0, @@win_w, @@win_h]
|
117
|
+
bg.update
|
118
|
+
@@sec_dir.update_size(0, 0, @@win_w/2, @@win_h-80)
|
119
|
+
@@sec_pl.update_size(@@win_w/2, 0, @@win_w/2, @@win_h-80)
|
120
|
+
@@sec_status.update_size(0, @@win_h-80, @@win_w, 80)
|
121
|
+
else
|
122
|
+
bg.update
|
123
|
+
end
|
124
|
+
@@sound.update
|
125
|
+
unless @@sleep_flag
|
126
|
+
@@sec_dir.update
|
127
|
+
@@sec_pl.update
|
128
|
+
end
|
129
|
+
@@sec_status.update
|
130
|
+
@@sleep_flag = false if @@inp.any_key >= 1
|
131
|
+
sleep_check
|
132
|
+
#draw
|
133
|
+
@@renderer.viewport = nil
|
134
|
+
bg.draw
|
135
|
+
unless @@sleep_flag
|
136
|
+
@@sec_dir.draw
|
137
|
+
@@sec_pl.draw
|
138
|
+
end
|
139
|
+
@@sec_status.draw
|
140
|
+
@@renderer.present
|
141
|
+
#GC.start
|
142
|
+
wait_fps
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def set_status(str)
|
147
|
+
@@msg.destroy if @@msg
|
148
|
+
@@msg = @@font.render_blended('> '+str, Util.to_col_ar(
|
149
|
+
@@config[:text_color_status]))
|
150
|
+
@@msg_rect = SDL2::Rect[0, 0, @@msg.w,
|
151
|
+
@@msg.h]
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def save
|
157
|
+
@@save_data[:volume] = @@sound.volume
|
158
|
+
@@save_data[:cur_pl] = @@sec_pl.playlist
|
159
|
+
File.open(@@pref_dir+'save_data.yaml', 'w') do |file|
|
160
|
+
file.write(@@save_data.to_yaml)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def write_playlist
|
165
|
+
unless Dir.exist?(File.join(@@config[:root_dir], "akane_playlists"))
|
166
|
+
Dir.mkdir(File.join(@@config[:root_dir], "akane_playlists"))
|
167
|
+
end
|
168
|
+
File.open(File.join(@@config[:root_dir], "akane_playlists",
|
169
|
+
SDL2.get_ticks.to_s+'.apl.yaml'), 'w') do |file|
|
170
|
+
file.write(@@sec_pl.playlist.to_yaml)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def sleep_check
|
175
|
+
@@tstmp_now = SDL2.get_ticks
|
176
|
+
if @@config[:sleep_timer] > 0
|
177
|
+
if (@@tstmp_now-@tstmp_last_input) >= @@config[:sleep_timer]*1000
|
178
|
+
@@sleep_flag = true
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def update_fps
|
184
|
+
if @frames == 0
|
185
|
+
@tstmp_start = SDL2.get_ticks
|
186
|
+
end
|
187
|
+
if @frames == @fps
|
188
|
+
t = SDL2.get_ticks
|
189
|
+
fps = 1000.to_f / ((t - @tstmp_start) / @fps.to_f)
|
190
|
+
@frames = 0
|
191
|
+
@tstmp_start = SDL2.get_ticks
|
192
|
+
end
|
193
|
+
@frames += 1
|
194
|
+
end
|
195
|
+
|
196
|
+
def wait_fps
|
197
|
+
took_time = SDL2.get_ticks - @tstmp_start
|
198
|
+
wait_time = @frames * 1000 / @fps - took_time
|
199
|
+
if wait_time > 0
|
200
|
+
SDL2.delay(wait_time)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
require "akane_sound/class.sound"
|
206
|
+
require "akane_sound/class.element"
|
207
|
+
require "akane_sound/class.setup"
|
208
|
+
require "akane_sound/class.background"
|
209
|
+
require "akane_sound/class.input"
|
210
|
+
require "akane_sound/class.view_base"
|
211
|
+
require "akane_sound/class.upper_section_base"
|
212
|
+
require "akane_sound/class.section_dir"
|
213
|
+
require "akane_sound/class.section_playlist"
|
214
|
+
require "akane_sound/class.section_status"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Background < AkaneSound
|
2
|
+
@sprite = nil
|
3
|
+
@pos = nil
|
4
|
+
def initialize(filepath)
|
5
|
+
surface = SDL2::Surface.load(filepath)
|
6
|
+
@sprite = @@renderer.create_texture_from(surface)
|
7
|
+
surface.destroy
|
8
|
+
updt
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
updt
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
unless @@config[:bg_type] == 'none'
|
17
|
+
if @@config[:bg_type] == 'repeat'
|
18
|
+
@pos.each do |pos|
|
19
|
+
@@renderer.copy(@sprite, nil, pos)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
@@renderer.copy(@sprite, nil, @pos)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# overlay
|
26
|
+
unless @@sleep_flag
|
27
|
+
@@renderer.draw_blend_mode = SDL2::BlendMode::BLEND
|
28
|
+
@@renderer.draw_color = [@@config[:bg_color][:red],
|
29
|
+
@@config[:bg_color][:green],
|
30
|
+
@@config[:bg_color][:blue],
|
31
|
+
@@config[:bg_color][:alpha]]
|
32
|
+
@@renderer.fill_rect(@@screen)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def updt
|
39
|
+
case @@config[:bg_type]
|
40
|
+
when 'normal'
|
41
|
+
@pos = SDL2::Rect[0, 0, @sprite.w, @sprite.h]
|
42
|
+
when 'none'
|
43
|
+
@pos = nil
|
44
|
+
when 'center'
|
45
|
+
x = @@win_w/2-@sprite.w/2
|
46
|
+
y = @@win_h/2-@sprite.h/2
|
47
|
+
@pos = SDL2::Rect[x, y, @sprite.w, @sprite.h]
|
48
|
+
when 'repeat'
|
49
|
+
@pos = Array.new
|
50
|
+
x = y = 0
|
51
|
+
while y < @@win_h
|
52
|
+
while x < @@win_w
|
53
|
+
@pos.push(SDL2::Rect[x, y, @sprite.w, @sprite.h])
|
54
|
+
x += @sprite.w
|
55
|
+
end
|
56
|
+
y += @sprite.h
|
57
|
+
x = 0
|
58
|
+
end
|
59
|
+
when 'fit'
|
60
|
+
when 'stretch'
|
61
|
+
@pos = nil
|
62
|
+
when 'scale'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,356 @@
|
|
1
|
+
class Input < AkaneSound
|
2
|
+
attr_accessor :up, :down, :pageup, :pagedown, :quit, :accept,
|
3
|
+
:toggle_shuffle, :toggle_repeat, :toggle_next, :toggle_mute,
|
4
|
+
:vol_up, :vol_down, :stop, :pause, :next, :refresh, :cmd, :any_key,
|
5
|
+
:last, :first, :prev, :append, :append_r, :switch, :clear, :write
|
6
|
+
def initialize
|
7
|
+
@tmp_up, @up = 0
|
8
|
+
@tmp_down, @down = 0
|
9
|
+
@tmp_last, @last = 0
|
10
|
+
@tmp_first, @first = 0
|
11
|
+
@tmp_pageup, @pageup = 0
|
12
|
+
@tmp_pagedown, @pagedown = 0
|
13
|
+
@tmp_quit, @quit = 0
|
14
|
+
@tmp_accept, @accept = 0
|
15
|
+
@tmp_clear, @clear = 0
|
16
|
+
@tmp_toggle_shuffle, @toggle_shuffle = 0
|
17
|
+
@tmp_toggle_repeat, @toggle_repeat = 0
|
18
|
+
@tmp_toggle_next, @toggle_next = 0
|
19
|
+
@tmp_toggle_mute, @toggle_mute = 0
|
20
|
+
@tmp_vol_up, @vol_up = 0
|
21
|
+
@tmp_vol_down, @vol_down = 0
|
22
|
+
@tmp_stop, @stop = 0
|
23
|
+
@tmp_pause, @pause = 0
|
24
|
+
@tmp_next, @next = 0
|
25
|
+
@tmp_prev, @prev = 0
|
26
|
+
@tmp_append, @append = 0
|
27
|
+
@tmp_append_r, @append_r = 0
|
28
|
+
@tmp_refresh, @refresh = 0
|
29
|
+
@tmp_cmd, @cmd = 0
|
30
|
+
@tmp_switch, @switch = 0
|
31
|
+
@tmp_write, @write = 0
|
32
|
+
@tmp_any_key, @any_key = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def handle_event(event)
|
36
|
+
case event
|
37
|
+
when SDL2::Event::Quit
|
38
|
+
@quit = 1
|
39
|
+
when SDL2::Event::KeyDown
|
40
|
+
@tmp_any_key = 1
|
41
|
+
if event.sym == SDL2::Key::TAB
|
42
|
+
@tmp_switch = 1
|
43
|
+
end
|
44
|
+
if event.sym == SDL2::Key::ESCAPE
|
45
|
+
@tmp_quit = 1
|
46
|
+
end
|
47
|
+
if event.sym == SDL2::Key::RETURN
|
48
|
+
@tmp_accept = 1
|
49
|
+
end
|
50
|
+
if event.sym == SDL2::Key::SPACE
|
51
|
+
@tmp_pause = 1
|
52
|
+
end
|
53
|
+
|
54
|
+
if event.sym == SDL2::Key::J
|
55
|
+
@tmp_down = 1
|
56
|
+
end
|
57
|
+
if event.sym == SDL2::Key::K
|
58
|
+
@tmp_up = 1
|
59
|
+
end
|
60
|
+
if event.sym == SDL2::Key::W
|
61
|
+
@tmp_write = 1
|
62
|
+
end
|
63
|
+
|
64
|
+
if event.sym == SDL2::Key::PAGEDOWN
|
65
|
+
@tmp_pagedown = 1
|
66
|
+
end
|
67
|
+
if event.sym == SDL2::Key::PAGEUP
|
68
|
+
@tmp_pageup = 1
|
69
|
+
end
|
70
|
+
if event.sym == SDL2::Key::P
|
71
|
+
@tmp_prev = 1
|
72
|
+
end
|
73
|
+
|
74
|
+
if event.sym == SDL2::Key::G
|
75
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
76
|
+
@tmp_last = 1
|
77
|
+
else
|
78
|
+
@tmp_first = 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if event.sym == SDL2::Key::S
|
83
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
84
|
+
@tmp_toggle_shuffle = 1
|
85
|
+
else
|
86
|
+
@tmp_stop = 1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
if event.sym == SDL2::Key::N
|
91
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
92
|
+
@tmp_toggle_next = 1
|
93
|
+
else
|
94
|
+
@tmp_next = 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
if event.sym == SDL2::Key::R
|
99
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
100
|
+
@tmp_toggle_repeat = 1
|
101
|
+
else
|
102
|
+
@tmp_refresh = 1
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
if event.sym == SDL2::Key::A
|
107
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
108
|
+
@tmp_append_r = 1
|
109
|
+
else
|
110
|
+
@tmp_append = 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if event.sym == SDL2::Key::C
|
115
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
116
|
+
@tmp_clear = 1
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if event.sym == SDL2::Key::PERIOD
|
121
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
122
|
+
@tmp_vol_up = 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
if event.sym == SDL2::Key::VOLUMEUP
|
126
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
127
|
+
@tmp_vol_up = 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if event.sym == SDL2::Key::COMMA
|
132
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
133
|
+
@tmp_vol_down = 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
if event.sym == SDL2::Key::SEMICOLON
|
138
|
+
if event.mod.bit?(SDL2::Key::Mod::SHIFT)
|
139
|
+
@tmp_cmd = 1
|
140
|
+
end
|
141
|
+
end
|
142
|
+
when SDL2::Event::KeyUp
|
143
|
+
@tmp_any_key = 0
|
144
|
+
if event.sym == SDL2::Key::TAB
|
145
|
+
@tmp_switch = 0
|
146
|
+
end
|
147
|
+
if event.sym == SDL2::Key::ESCAPE
|
148
|
+
@tmp_quit = 0
|
149
|
+
end
|
150
|
+
if event.sym == SDL2::Key::RETURN
|
151
|
+
@tmp_accept = 0
|
152
|
+
end
|
153
|
+
if event.sym == SDL2::Key::SPACE
|
154
|
+
@tmp_pause = 0
|
155
|
+
end
|
156
|
+
|
157
|
+
if event.sym == SDL2::Key::J
|
158
|
+
@tmp_down = 0
|
159
|
+
end
|
160
|
+
if event.sym == SDL2::Key::K
|
161
|
+
@tmp_up = 0
|
162
|
+
end
|
163
|
+
if event.sym == SDL2::Key::W
|
164
|
+
@tmp_write = 0
|
165
|
+
end
|
166
|
+
|
167
|
+
if event.sym == SDL2::Key::PAGEDOWN
|
168
|
+
@tmp_pagedown = 0
|
169
|
+
end
|
170
|
+
if event.sym == SDL2::Key::P
|
171
|
+
@tmp_prev = 0
|
172
|
+
end
|
173
|
+
if event.sym == SDL2::Key::PAGEUP
|
174
|
+
@tmp_pageup = 0
|
175
|
+
end
|
176
|
+
|
177
|
+
if event.sym == SDL2::Key::G
|
178
|
+
@tmp_last = 0
|
179
|
+
@tmp_first = 0
|
180
|
+
end
|
181
|
+
|
182
|
+
if event.sym == SDL2::Key::S
|
183
|
+
@tmp_toggle_shuffle = 0
|
184
|
+
@tmp_stop = 0
|
185
|
+
end
|
186
|
+
|
187
|
+
if event.sym == SDL2::Key::N
|
188
|
+
@tmp_toggle_next = 0
|
189
|
+
@tmp_next = 0
|
190
|
+
end
|
191
|
+
|
192
|
+
if event.sym == SDL2::Key::R
|
193
|
+
@tmp_toggle_repeat = 0
|
194
|
+
@tmp_refresh = 0
|
195
|
+
end
|
196
|
+
|
197
|
+
if event.sym == SDL2::Key::A
|
198
|
+
@tmp_append = 0
|
199
|
+
@tmp_append_r = 0
|
200
|
+
end
|
201
|
+
|
202
|
+
if event.sym == SDL2::Key::C
|
203
|
+
@tmp_clear = 0
|
204
|
+
end
|
205
|
+
|
206
|
+
if event.sym == SDL2::Key::PERIOD
|
207
|
+
@tmp_vol_up = 0
|
208
|
+
end
|
209
|
+
if event.sym == SDL2::Key::VOLUMEUP
|
210
|
+
@tmp_vol_up = 0
|
211
|
+
end
|
212
|
+
|
213
|
+
if event.sym == SDL2::Key::COMMA
|
214
|
+
@tmp_vol_down = 0
|
215
|
+
end
|
216
|
+
|
217
|
+
if event.sym == SDL2::Key::SEMICOLON
|
218
|
+
@tmp_cmd = 0
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def set_state
|
224
|
+
if @tmp_any_key == 1
|
225
|
+
@any_key += 1
|
226
|
+
else
|
227
|
+
@any_key = 0
|
228
|
+
end
|
229
|
+
if @tmp_switch == 1
|
230
|
+
@switch += 1
|
231
|
+
else
|
232
|
+
@switch = 0
|
233
|
+
end
|
234
|
+
if @tmp_quit == 1
|
235
|
+
@quit += 1
|
236
|
+
else
|
237
|
+
@quit = 0
|
238
|
+
end
|
239
|
+
if @tmp_write == 1
|
240
|
+
@write += 1
|
241
|
+
else
|
242
|
+
@write = 0
|
243
|
+
end
|
244
|
+
if @tmp_up == 1
|
245
|
+
@up += 1
|
246
|
+
else
|
247
|
+
@up = 0
|
248
|
+
end
|
249
|
+
if @tmp_down == 1
|
250
|
+
@down += 1
|
251
|
+
else
|
252
|
+
@down = 0
|
253
|
+
end
|
254
|
+
if @tmp_last == 1
|
255
|
+
@last += 1
|
256
|
+
else
|
257
|
+
@last = 0
|
258
|
+
end
|
259
|
+
if @tmp_first == 1
|
260
|
+
@first += 1
|
261
|
+
else
|
262
|
+
@first = 0
|
263
|
+
end
|
264
|
+
if @tmp_pageup == 1
|
265
|
+
@pageup += 1
|
266
|
+
else
|
267
|
+
@pageup = 0
|
268
|
+
end
|
269
|
+
if @tmp_pagedown == 1
|
270
|
+
@pagedown += 1
|
271
|
+
else
|
272
|
+
@pagedown = 0
|
273
|
+
end
|
274
|
+
if @tmp_accept == 1
|
275
|
+
@accept += 1
|
276
|
+
else
|
277
|
+
@accept = 0
|
278
|
+
end
|
279
|
+
if @tmp_pause == 1
|
280
|
+
@pause += 1
|
281
|
+
else
|
282
|
+
@pause = 0
|
283
|
+
end
|
284
|
+
if @tmp_stop == 1
|
285
|
+
@stop += 1
|
286
|
+
else
|
287
|
+
@stop = 0
|
288
|
+
end
|
289
|
+
if @tmp_toggle_shuffle == 1
|
290
|
+
@toggle_shuffle += 1
|
291
|
+
else
|
292
|
+
@toggle_shuffle = 0
|
293
|
+
end
|
294
|
+
if @tmp_toggle_repeat == 1
|
295
|
+
@toggle_repeat += 1
|
296
|
+
else
|
297
|
+
@toggle_repeat = 0
|
298
|
+
end
|
299
|
+
if @tmp_toggle_next == 1
|
300
|
+
@toggle_next += 1
|
301
|
+
else
|
302
|
+
@toggle_next = 0
|
303
|
+
end
|
304
|
+
if @tmp_toggle_mute == 1
|
305
|
+
@toggle_mute += 1
|
306
|
+
else
|
307
|
+
@toggle_mute = 0
|
308
|
+
end
|
309
|
+
if @tmp_vol_up == 1
|
310
|
+
@vol_up += 1
|
311
|
+
else
|
312
|
+
@vol_up = 0
|
313
|
+
end
|
314
|
+
if @tmp_vol_down == 1
|
315
|
+
@vol_down += 1
|
316
|
+
else
|
317
|
+
@vol_down = 0
|
318
|
+
end
|
319
|
+
if @tmp_next == 1
|
320
|
+
@next += 1
|
321
|
+
else
|
322
|
+
@next = 0
|
323
|
+
end
|
324
|
+
if @tmp_prev == 1
|
325
|
+
@prev += 1
|
326
|
+
else
|
327
|
+
@prev = 0
|
328
|
+
end
|
329
|
+
if @tmp_append == 1
|
330
|
+
@append += 1
|
331
|
+
else
|
332
|
+
@append = 0
|
333
|
+
end
|
334
|
+
if @tmp_clear == 1
|
335
|
+
@clear += 1
|
336
|
+
else
|
337
|
+
@clear = 0
|
338
|
+
end
|
339
|
+
if @tmp_append_r == 1
|
340
|
+
@append_r += 1
|
341
|
+
else
|
342
|
+
@append_r = 0
|
343
|
+
end
|
344
|
+
if @tmp_refresh == 1
|
345
|
+
@refresh += 1
|
346
|
+
else
|
347
|
+
@refresh = 0
|
348
|
+
end
|
349
|
+
if @tmp_cmd == 1
|
350
|
+
@cmd += 1
|
351
|
+
else
|
352
|
+
@cmd = 0
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
end
|