Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Added support for the Ayaneo Air Plus 7320u.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Kranz authored and Derek J. Clark committed Feb 7, 2024
1 parent 2f348d9 commit ec4bbb5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/handycon/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import handycon.handhelds.aya_gen7 as aya_gen7
import handycon.handhelds.aya_gen8 as aya_gen8
import handycon.handhelds.aya_gen9 as aya_gen9
import handycon.handhelds.aya_gen10 as aya_gen10
import handycon.handhelds.ayn_gen1 as ayn_gen1
import handycon.handhelds.ayn_gen2 as ayn_gen2
import handycon.handhelds.ayn_gen3 as ayn_gen3
Expand Down Expand Up @@ -293,6 +294,8 @@ async def capture_keyboard_events():
await aya_gen8.process_event(seed_event, active_keys)
case "AYA_GEN9":
await aya_gen9.process_event(seed_event, active_keys)
case "AYA_GEN10":
await aya_gen10.process_event(seed_event, active_keys)
case "AYN_GEN1":
await ayn_gen1.process_event(seed_event, active_keys)
case "AYN_GEN2":
Expand Down
69 changes: 69 additions & 0 deletions src/handycon/handhelds/aya_gen10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
# This file is part of Handheld Game Console Controller System (HandyGCCS)
# Copyright 2022-2023 Derek J. Clark <[email protected]>

from evdev import ecodes as e

handycon = None


def init_handheld(handheld_controller):
global handycon
handycon = handheld_controller
handycon.BUTTON_DELAY = 0.11
handycon.CAPTURE_CONTROLLER = True
handycon.CAPTURE_KEYBOARD = True
handycon.CAPTURE_POWER = True
handycon.GAMEPAD_ADDRESS = 'usb-0000:05:00.0-1/input0'
handycon.GAMEPAD_NAME = 'Microsoft X-Box 360 pad'
handycon.KEYBOARD_ADDRESS = 'isa0060/serio0/input0'
handycon.KEYBOARD_NAME = 'AT Translated Set 2 keyboard'


# Captures keyboard events and translates them to virtual device events.
async def process_event(seed_event, active_keys):
global handycon

# Button map shortcuts for easy reference.
button1 = handycon.button_map["button1"]
button2 = handycon.button_map["button2"]
button4 = handycon.button_map["button4"]
button5 = handycon.button_map["button5"]

# Loop variables
button_on = seed_event.value

# Automatically pass default keycodes we dont intend to replace.
if seed_event.code in [e.KEY_VOLUMEDOWN, e.KEY_VOLUMEUP]:
handycon.emit_event(seed_event)

# BUTTON 1 (Default: Screenshot/Launch Chiumera) LC Button
if active_keys == [97, 125, 185] and button_on == 1 and button1 not in handycon.event_queue:
await handycon.handle_key_down(seed_event, button1)
elif active_keys == [] and seed_event.code in [97, 125, 185] and button_on == 0 and button1 in handycon.event_queue:
await handycon.handle_key_up(seed_event, button1)

# BUTTON 2 (Default: QAM) Small Button
if active_keys == [32, 125] and button_on == 1 and button2 not in handycon.event_queue:
await handycon.handle_key_down(seed_event, button2)
elif active_keys == [] and seed_event.code in [32, 125] and button_on == 0 and button2 in handycon.event_queue:
await handycon.handle_key_up(seed_event, button2)

# BUTTON 4 (Default: OSK) RC Button
if active_keys == [97, 125, 186] and button_on == 1 and button4 not in handycon.event_queue:
await handycon.handle_key_down(seed_event, button4)
elif active_keys == [] and seed_event.code in [97, 125, 186] and button_on == 0 and button4 in handycon.event_queue:
await handycon.handle_key_up(seed_event, button4)

# BUTTON 5 (Default: MODE) Big button
if active_keys == [97, 125, 187] and button_on == 1 and button5 not in handycon.event_queue:
await handycon.handle_key_down(seed_event, button5)
elif active_keys == [] and seed_event.code in [97, 125, 187] and button_on == 0 and button5 in handycon.event_queue:
await handycon.handle_key_up(seed_event, button5)

# Handle L_META from power button
elif active_keys == [] and seed_event.code == 125 and button_on == 0 and handycon.event_queue == [] and handycon.shutdown == True:
handycon.shutdown = False

if handycon.last_button:
await handycon.handle_key_up(seed_event, handycon.last_button)
13 changes: 11 additions & 2 deletions src/handycon/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import handycon.handhelds.aya_gen7 as aya_gen7
import handycon.handhelds.aya_gen8 as aya_gen8
import handycon.handhelds.aya_gen9 as aya_gen9
import handycon.handhelds.aya_gen10 as aya_gen10
import handycon.handhelds.ayn_gen1 as ayn_gen1
import handycon.handhelds.ayn_gen2 as ayn_gen2
import handycon.handhelds.ayn_gen3 as ayn_gen3
Expand Down Expand Up @@ -84,6 +85,10 @@ def id_system():
cpu_vendor = get_cpu_vendor()
handycon.logger.info(f"Found CPU Vendor: {cpu_vendor}")

board_name = open(
"/sys/devices/virtual/dmi/id/board_name", "r").read().strip()
handycon.logger.info(f"Found Board Name: {board_name}")

# Verify all system hardweare has initialized.
handycon.logger.info("Identifying system hardware.")
timeout = 0
Expand Down Expand Up @@ -166,8 +171,12 @@ def id_system():
handycon.system_type = "AYA_GEN7"
aya_gen7.init_handheld(handycon)
else:
handycon.system_type = "AYA_GEN5"
aya_gen5.init_handheld(handycon)
if board_name == "AB05-Mendocino":
handycon.system_type = "AYA_GEN10"
aya_gen10.init_handheld(handycon)
else:
handycon.system_type = "AYA_GEN5"
aya_gen5.init_handheld(handycon)

elif system_id in (
"AYANEO 2S",
Expand Down

0 comments on commit ec4bbb5

Please sign in to comment.