Initial public release of SystemK.
This commit is contained in:
parent
387f57cdda
commit
6f51f5b006
129 changed files with 11654 additions and 2 deletions
148
Events/Command_Mapping.h
Executable file
148
Events/Command_Mapping.h
Executable file
|
@ -0,0 +1,148 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
||||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief This file maps IR remote control codes to events used by the KTag system (SystemK).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_MAPPING_H
|
||||
#define COMMAND_MAPPING_H
|
||||
|
||||
// First Roku Remote Replacement
|
||||
// https://www.amazon.com/gp/product/B01G7OX9WS/
|
||||
#define NEC_COMMAND_ROKU_01_BACK_ARROW 2573648618
|
||||
#define NEC_COMMAND_ROKU_01_HOME 4228104938
|
||||
#define NEC_COMMAND_ROKU_01_UP_ARROW 3860447978
|
||||
#define NEC_COMMAND_ROKU_01_RIGHT_ARROW 3526214378
|
||||
#define NEC_COMMAND_ROKU_01_DOWN_ARROW 3425944298
|
||||
#define NEC_COMMAND_ROKU_01_LEFT_ARROW 3776889578
|
||||
#define NEC_COMMAND_ROKU_01_OK 3576349418
|
||||
#define NEC_COMMAND_ROKU_01_COUNTERCLOCKWISE 3576349418
|
||||
#define NEC_COMMAND_ROKU_01_ASTERIX 2657207018
|
||||
#define NEC_COMMAND_ROKU_01_REWIND 3409232618
|
||||
#define NEC_COMMAND_ROKU_01_PLAY_PAUSE 3008152298
|
||||
#define NEC_COMMAND_ROKU_01_FAST_FORWARD 2857747178
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_CRACKLE 2155856618
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_PANDORA 2907882218
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_MGO 4027564778
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_AMAZON 4027564778
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_NETFLIX 3024863978
|
||||
#define NEC_COMMAND_ROKU_01_CHANNEL_BLOCKBUSTER 3743466218
|
||||
|
||||
// Second Roku Remote Replacement
|
||||
// https://www.amazon.com/dp/B09Z6Q2MLC/
|
||||
#define NEC_COMMAND_ROKU_02_BACK_ARROW 2573649898
|
||||
#define NEC_COMMAND_ROKU_02_HOME 4228106218
|
||||
#define NEC_COMMAND_ROKU_02_UP_ARROW 3860449258
|
||||
#define NEC_COMMAND_ROKU_02_RIGHT_ARROW 3526215658
|
||||
#define NEC_COMMAND_ROKU_02_DOWN_ARROW 3425945578
|
||||
#define NEC_COMMAND_ROKU_02_LEFT_ARROW 3776890858
|
||||
#define NEC_COMMAND_ROKU_02_OK 3576350698
|
||||
#define NEC_COMMAND_ROKU_02_COUNTERCLOCKWISE 2272839658
|
||||
#define NEC_COMMAND_ROKU_02_ASTERIX 2272839658
|
||||
#define NEC_COMMAND_ROKU_02_REWIND 3409233898
|
||||
#define NEC_COMMAND_ROKU_02_PLAY_PAUSE 3008153578
|
||||
#define NEC_COMMAND_ROKU_02_FAST_FORWARD 2857748458
|
||||
#define NEC_COMMAND_ROKU_02_CHANNEL_NETFLIX 2907883498
|
||||
#define NEC_COMMAND_ROKU_02_CHANNEL_HULU 2991441898
|
||||
#define NEC_COMMAND_ROKU_02_CHANNEL_YOUTUBE 2841036778
|
||||
#define NEC_COMMAND_ROKU_02_CHANNEL_DISNEYPLUS 4077701098
|
||||
|
||||
// Samsung BN59-01301A TV Remote Control
|
||||
// https://samsungparts.com/products/bn59-01301a
|
||||
#define NEC_COMMAND_SAMSUNG_TV_POWER 4244768519
|
||||
#define NEC_COMMAND_SAMSUNG_TV_SOURCE 4261480199
|
||||
#define NEC_COMMAND_SAMSUNG_TV_SLEEP 4228056839
|
||||
#define NEC_COMMAND_SAMSUNG_TV_HOME 2256078599
|
||||
#define NEC_COMMAND_SAMSUNG_TV_GUIDE 2957969159
|
||||
#define NEC_COMMAND_SAMSUNG_TV_SETTINGS 3843688199
|
||||
#define NEC_COMMAND_SAMSUNG_TV_INFO 3760129799
|
||||
#define NEC_COMMAND_SAMSUNG_TV_UP_ARROW 2673870599
|
||||
#define NEC_COMMAND_SAMSUNG_TV_RIGHT_ARROW 2640447239
|
||||
#define NEC_COMMAND_SAMSUNG_TV_DOWN_ARROW 2657158919
|
||||
#define NEC_COMMAND_SAMSUNG_TV_LEFT_ARROW 2590312199
|
||||
#define NEC_COMMAND_SAMSUNG_TV_CENTER_SELECT 2540177159
|
||||
#define NEC_COMMAND_SAMSUNG_TV_RETURN 2807564039
|
||||
#define NEC_COMMAND_SAMSUNG_TV_EXIT 3526166279
|
||||
|
||||
__attribute__((always_inline)) inline void Remap_NEC_Command(KEvent_T *event, uint32_t NEC_data)
|
||||
{
|
||||
switch (NEC_data)
|
||||
{
|
||||
case NEC_COMMAND_ROKU_01_HOME:
|
||||
case NEC_COMMAND_ROKU_02_HOME:
|
||||
case NEC_COMMAND_SAMSUNG_TV_HOME:
|
||||
case NEC_COMMAND_SAMSUNG_TV_SETTINGS:
|
||||
event->ID = KEVENT_MENU_ENTER;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_BACK_ARROW:
|
||||
case NEC_COMMAND_ROKU_02_BACK_ARROW:
|
||||
case NEC_COMMAND_SAMSUNG_TV_EXIT:
|
||||
event->ID = KEVENT_MENU_EXIT;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_OK:
|
||||
case NEC_COMMAND_ROKU_02_OK:
|
||||
case NEC_COMMAND_SAMSUNG_TV_CENTER_SELECT:
|
||||
event->ID = KEVENT_MENU_SELECT;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_UP_ARROW:
|
||||
case NEC_COMMAND_ROKU_02_UP_ARROW:
|
||||
case NEC_COMMAND_SAMSUNG_TV_UP_ARROW:
|
||||
event->ID = KEVENT_MENU_UP;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_DOWN_ARROW:
|
||||
case NEC_COMMAND_ROKU_02_DOWN_ARROW:
|
||||
case NEC_COMMAND_SAMSUNG_TV_DOWN_ARROW:
|
||||
event->ID = KEVENT_MENU_DOWN;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_LEFT_ARROW:
|
||||
case NEC_COMMAND_ROKU_02_LEFT_ARROW:
|
||||
case NEC_COMMAND_ROKU_01_RIGHT_ARROW:
|
||||
case NEC_COMMAND_ROKU_02_RIGHT_ARROW:
|
||||
case NEC_COMMAND_SAMSUNG_TV_LEFT_ARROW:
|
||||
case NEC_COMMAND_SAMSUNG_TV_RIGHT_ARROW:
|
||||
event->ID = KEVENT_MENU_BACK;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_ASTERIX:
|
||||
case NEC_COMMAND_ROKU_02_ASTERIX:
|
||||
case NEC_COMMAND_SAMSUNG_TV_SOURCE:
|
||||
event->ID = KEVENT_REPROGRAM;
|
||||
break;
|
||||
|
||||
case NEC_COMMAND_ROKU_01_PLAY_PAUSE:
|
||||
case NEC_COMMAND_ROKU_02_PLAY_PAUSE:
|
||||
event->ID = KEVENT_PLAY_PRESSED_ON_REMOTE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMMAND_MAPPING_H
|
76
Events/KEvents.c
Executable file
76
Events/KEvents.c
Executable file
|
@ -0,0 +1,76 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
||||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SystemK.h"
|
||||
#include "Command_Mapping.h"
|
||||
|
||||
#define QUEUE_LENGTH 10
|
||||
#define ITEM_SIZE sizeof(KEvent_T)
|
||||
static StaticQueue_t StaticQueue;
|
||||
static uint8_t QueueStorageArea[QUEUE_LENGTH * ITEM_SIZE];
|
||||
QueueHandle_t xQueueEvents;
|
||||
|
||||
static void Remap_Event(KEvent_T *event)
|
||||
{
|
||||
switch (event->ID)
|
||||
{
|
||||
case KEVENT_COMMAND_RECEIVED:
|
||||
{
|
||||
if (((DecodedPacket_T *)(event->Data))->Command.protocol == NEC_PROTOCOL)
|
||||
{
|
||||
uint32_t NEC_data = ((DecodedPacket_T *)(event->Data))->Command.data;
|
||||
Remap_NEC_Command(event, NEC_data);
|
||||
}
|
||||
FreeDecodedPacketBuffer(event->Data);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// No remapping necessary.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Init_KEvents(void)
|
||||
{
|
||||
xQueueEvents = xQueueCreateStatic(QUEUE_LENGTH, ITEM_SIZE, QueueStorageArea, &StaticQueue);
|
||||
}
|
||||
|
||||
void Post_KEvent(KEvent_T *event)
|
||||
{
|
||||
Remap_Event(event);
|
||||
xQueueSend(xQueueEvents, event, 0);
|
||||
}
|
||||
|
||||
void Post_KEvent_From_ISR(KEvent_T *event, portBASE_TYPE *xHigherPriorityTaskWoken)
|
||||
{
|
||||
Remap_Event(event);
|
||||
xQueueSendFromISR(xQueueEvents, event, xHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
portBASE_TYPE Receive_KEvent(KEvent_T *event)
|
||||
{
|
||||
return xQueueReceive(xQueueEvents, event, 0);
|
||||
}
|
104
Events/KEvents.h
Executable file
104
Events/KEvents.h
Executable file
|
@ -0,0 +1,104 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
||||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief This file defines the events used by the KTag system (SystemK).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVENTS_H
|
||||
#define EVENTS_H
|
||||
|
||||
//! Event identifiers used by the SystemK.
|
||||
typedef enum
|
||||
{
|
||||
KEVENT_NO_EVENT = 0,
|
||||
KEVENT_AUTOMATIC_TRANSITION = 1,
|
||||
KEVENT_CAPSENSE_ONE_PRESSED = 2,
|
||||
KEVENT_CAPSENSE_ONE_RELEASED = 3,
|
||||
KEVENT_CAPSENSE_TWO_PRESSED = 4,
|
||||
KEVENT_CAPSENSE_TWO_RELEASED = 5,
|
||||
KEVENT_TRIGGER_SWITCH_PRESSED = 6,
|
||||
KEVENT_CENTER_SWITCH_PRESSED = KEVENT_TRIGGER_SWITCH_PRESSED,
|
||||
KEVENT_TRIGGER_SWITCH_RELEASED = 7,
|
||||
//! For #KEVENT_CENTER_SWITCH_RELEASED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
||||
KEVENT_CENTER_SWITCH_RELEASED = KEVENT_TRIGGER_SWITCH_RELEASED,
|
||||
KEVENT_UP_SWITCH_PRESSED = 8,
|
||||
KEVENT_UP_SWITCH_LONG_PRESSED = 9,
|
||||
KEVENT_UP_SWITCH_RELEASED = 10,
|
||||
KEVENT_DOWN_SWITCH_PRESSED = 11,
|
||||
KEVENT_DOWN_SWITCH_LONG_PRESSED = 12,
|
||||
KEVENT_DOWN_SWITCH_RELEASED = 13,
|
||||
KEVENT_FORWARD_SWITCH_PRESSED = 14,
|
||||
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 15,
|
||||
KEVENT_FORWARD_SWITCH_RELEASED = 16,
|
||||
KEVENT_BACKWARD_SWITCH_PRESSED = 17,
|
||||
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 18,
|
||||
KEVENT_BACKWARD_SWITCH_RELEASED = 19,
|
||||
KEVENT_TAG_SENT = 20,
|
||||
//! For #KEVENT_TAG_RECEIVED, #KEvent_T::Data points to #TagPacket_T.
|
||||
KEVENT_TAG_RECEIVED = 21,
|
||||
KEVENT_TAGGED_OUT = 22,
|
||||
KEVENT_MISFIRE = 23,
|
||||
KEVENT_NEAR_MISS = 24,
|
||||
//! For #KEVENT_BLE_PACKET_RECEIVED, #KEvent_T::Data points to #COMM_BLE_Packet_T.
|
||||
KEVENT_BLE_PACKET_RECEIVED = 25,
|
||||
//! For #KEVENT_COMMAND_RECEIVED, #KEvent_T::Data points to #CommandPacket_T.
|
||||
KEVENT_COMMAND_RECEIVED = 26,
|
||||
KEVENT_MENU_ENTER = 27,
|
||||
KEVENT_MENU_SELECT = 28,
|
||||
KEVENT_MENU_BACK = 29,
|
||||
KEVENT_MENU_UP = 30,
|
||||
KEVENT_MENU_DOWN = 31,
|
||||
KEVENT_MENU_EXIT = 32,
|
||||
KEVENT_REPROGRAM = 33,
|
||||
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration the switch has not been pressed in milliseconds.
|
||||
KEVENT_ACCESSORY_SWITCH_PRESSED = 34,
|
||||
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
||||
KEVENT_ACCESSORY_SWITCH_RELEASED = 35,
|
||||
//! For #KEVENT_AUDIO_COMPLETED, #KEvent_T::Data contains the AudioActionID_T of the completed action.
|
||||
KEVENT_AUDIO_COMPLETED = 36,
|
||||
KEVENT_GAME_OVER = 37,
|
||||
KEVENT_PLAY_PRESSED_ON_REMOTE = 38,
|
||||
// KEVENT_IS_OUT_OF_RANGE is one more than the last valid event.
|
||||
KEVENT_IS_OUT_OF_RANGE
|
||||
} KEvent_ID_T;
|
||||
|
||||
//! Events used by the SystemK.
|
||||
/*!
|
||||
* The #Data is event-dependent.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
KEvent_ID_T ID;
|
||||
void *Data;
|
||||
} KEvent_T;
|
||||
|
||||
// Verify the pointer size, since sometime we store uint32_t's in the KEvent_T::Data pointer.
|
||||
_Static_assert(sizeof(uintptr_t) >= sizeof(uint32_t), "Pointer size is less than 32 bits! KEvents will not work properly on this system.");
|
||||
|
||||
void Init_KEvents(void);
|
||||
void Post_KEvent(KEvent_T *event);
|
||||
void Post_KEvent_From_ISR(KEvent_T *event, portBASE_TYPE *xHigherPriorityTaskWoken);
|
||||
portBASE_TYPE Receive_KEvent(KEvent_T *event);
|
||||
|
||||
#endif // EVENTS_H
|
Loading…
Add table
Add a link
Reference in a new issue