def configureKeyboard(self, currentDevice):
        menus.clearPreviousMenu()

        print('Configuring {0}'.format(currentDevice['name']))
        device = []  # Append new controls to this list
        deviceName = currentDevice[
            'name']  # Current controller being configured

        # Second, Configure Buttons
        for button in currentDevice['buttons']:
            cmdName = button[0]
            command = button[1]
            unit = pcolor('cyan', cmdName)
            print('Press and hold GPIO pin(s) to map {0}'.format(unit),
                  end=' ')
            sys.stdout.flush()
            pressed = self.wait_for_pin()
            pressed = ', '.join(map(str, pressed))
            print('- Pins(s):', pressed)
            self.waitForButtonRelease()
            device.append((deviceName, cmdName, 'KEY', command, pressed))

        # Save to Database
        print('Saving Configuration!')
        # Delete Old Entries
        SQL.deleteDevice(deviceName)

        # Create New Entries
        SQL.createDevice(device)
        time.sleep(1)
        self.getControllerType()
Exemplo n.º 2
0
def clearDevice():
    clearPreviousMenu()

    options = DEVICE_LIST + ['← Return to Main Menu']
    choice = SelectionMenu.get_selection(
        strings=options,
        title='CLEAR DEVICE',
        subtitle='Remove configs for which device?',
        exit_option=False)

    currentDevice['name'] = options[choice]

    if currentDevice['name'] == '← Return to Main Menu':
        return GOTO_MAIN
    else:
        clearPreviousMenu()
        print('Deleting config files for {0}...'.format(currentDevice['name']))
        SQL.deleteDevice(currentDevice['name'])
        time.sleep(1)
        return clearDevice()
    def configureJoypad(self, currentDevice):
        menus.clearPreviousMenu()

        print('Configuring {0}'.format(currentDevice['name']))
        device = []  # Append new controls to this list
        deviceName = currentDevice[
            'name']  # Current controller being configured

        # First, Configure Joysticks
        for dpad in range(currentDevice['axisCount']):
            # Define Axes
            device.append(self.defineAxis("UP", dpad, deviceName, offset=1))
            device.append(self.defineAxis("DOWN", dpad, deviceName, offset=1))
            device.append(self.defineAxis("LEFT", dpad, deviceName))
            device.append(self.defineAxis("RIGHT", dpad, deviceName))

        # Second, Configure Buttons
        for button in currentDevice['buttons']:
            cmdName = button[0]
            command = button[1]
            unit = pcolor('cyan', cmdName)
            print('Hold {0}'.format(unit), end=' ')
            sys.stdout.flush()
            pressed = self.wait_for_pin()
            pressed = ', '.join(map(str, pressed))
            print('- Pins(s):', pressed)
            self.waitForButtonRelease()
            device.append((deviceName, cmdName, 'BUTTON', command, pressed))

        # Save to Database
        print('Saving Configuration!')
        # Delete Old Entries
        SQL.deleteDevice(deviceName)

        # Create New Entries
        SQL.createDevice(device)
        time.sleep(1)

        self.getControllerType()