X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fmapping.py;h=58aaf3d698461fed22e2913a5ffdb757e33dc597;hb=fba0caf0417cbb4e5b370e16e4b0c855c74094c1;hp=84e99410874a979b7252329c245f152877582586;hpb=5c327cc405f11575446915627d1bbf0c14323b67;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/mapping.py b/helpers/mapping.py index 84e9941..58aaf3d 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py @@ -7,6 +7,15 @@ class Mapping: HEIGHT = 298 SIZE = WIDTH, HEIGHT + ROW_POSITIONS = { + 'first': 0, + 'second': 50, + 'third': 100, + 'fourth': 150, + 'fifth': 200, + 'sixth': 250, + } + KEYS = [ (pygame.K_ESCAPE, 'ESC', 'first', 0, {}), @@ -26,17 +35,17 @@ class Mapping: (pygame.K_F12, 'F12', 'first', 700, {}), - (178, '²', 'second', 0, {}), + (178, '²', 'second', 0, {}), (pygame.K_AMPERSAND, '&', 'second', 50, {}), - (233, 'é', 'second', 100, {}), + (233, 'é', 'second', 100, {}), (pygame.K_QUOTEDBL, '"', 'second', 150, {}), (pygame.K_QUOTE, "'", 'second', 200, {}), (pygame.K_LEFTPAREN, '(', 'second', 250, {}), (pygame.K_MINUS, '-', 'second', 300, {}), - (232, 'è', 'second', 350, {}), + (232, 'è', 'second', 350, {}), (pygame.K_UNDERSCORE, '_', 'second', 400, {}), - (231, 'ç', 'second', 450, {}), - (224, 'à', 'second', 500, {}), + (231, 'ç', 'second', 450, {}), + (224, 'à', 'second', 500, {}), (pygame.K_RIGHTPAREN, ')', 'second', 550, {}), (pygame.K_EQUALS, '=', 'second', 600, {}), @@ -57,9 +66,9 @@ class Mapping: (pygame.K_CARET, '^', 'third', 575, {}), (pygame.K_DOLLAR, '$', 'third', 625, {}), - (pygame.K_RETURN, 'Enter', 'third', 692, { 'width': 56, 'height': 98 }), + (pygame.K_RETURN, 'Enter', 'third', 692, { 'width': 56, 'height': 98 }), - (pygame.K_CAPSLOCK, 'CAPS', 'fourth', 0, { 'width': 88, 'disabled': True }), + (pygame.K_CAPSLOCK, 'CAPS', 'fourth', 0, { 'width': 88, 'disabled': True }), (pygame.K_q, 'q', 'fourth', 90, {}), (pygame.K_s, 's', 'fourth', 140, {}), @@ -71,7 +80,7 @@ class Mapping: (pygame.K_k, 'k', 'fourth', 440, {}), (pygame.K_l, 'l', 'fourth', 490, {}), (pygame.K_m, 'm', 'fourth', 540, {}), - (249, 'ù', 'fourth', 590, {}), + (249, 'ù', 'fourth', 590, {}), (pygame.K_ASTERISK, '*', 'fourth', 640, {}), @@ -96,7 +105,7 @@ class Mapping: (pygame.K_LALT, 'LAlt', 'sixth', 165, { 'disabled': True }), (pygame.K_SPACE, 'Espace', 'sixth', 215, { 'width': 248 }), (pygame.K_MODE, 'AltGr', 'sixth', 465, { 'disabled': True }), - (314, 'Compose', 'sixth', 515, { 'disabled': True }), + (314, 'Compose', 'sixth', 515, { 'disabled': True }), (pygame.K_RCTRL, 'RCtrl', 'sixth', 565, { 'width': 63, 'disabled': True }), @@ -122,7 +131,14 @@ class Mapping: self.keys = {} self.running = [] for key in self.KEYS: - self.keys[key[0]] = Key(self, self.draw_lock, *key[0:4], **key[4]) + if key[2] in self.ROW_POSITIONS: + position = self.ROW_POSITIONS[key[2]] + else: + position = key[2] + self.keys[key[0]] = Key(self, + self.draw_lock, + key[0], key[1], position, key[3], + **key[4]) def draw(self): for key_name in self.keys: