-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,034 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
// author: mark cass | ||
// project: somax personal AI | ||
// project url: https://mechanizedai.com | ||
// license: open source and free for all uses without encumbrance. | ||
// | ||
// FILE: inputevent.c | ||
// DESCRIPTION: Somax input event provides storage for input device streamed | ||
// output. | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
#include <string.h> | ||
|
||
#include "somax.h" | ||
#include "inputevent.h" | ||
#include "inputsource.h" | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//CONSTANTS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
#define INPUTEVT_MAX_FIELDS 8 | ||
#define INPUTEVT_DTYPE_UNKNOWN 0 | ||
#define INPUTEVT_DTYPE_INT 1 | ||
#define INPUTEVT_DTYPE_FLOAT 2 | ||
#define INPUTEVT_DTYPE_INTARRAY 3 | ||
#define INPUTEVT_DTYPE_FLOATARRAY 4 | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//DATA STRUCTURES | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
|
||
union INPUTEVT_FIELDDATA | ||
{ | ||
int ival; | ||
float fval; | ||
int * iarray; | ||
float *farray; | ||
}; | ||
|
||
struct INPUTEVT_FIELD | ||
{ | ||
inputevt_fieldid field_id; | ||
inputevt_device_fieldid device_ref; | ||
inputevt_dtypeid datatype_id; | ||
INPUTEVT_FIELDDATA data; | ||
}; | ||
|
||
typedef INPUTEVT_FIELD event_data[INPUTEVT_MAX_FIELDS]; | ||
|
||
struct INPUT_EVENT | ||
{ | ||
inputevt_eventid event_id; | ||
inputevt_deviceid device_id; | ||
event_data data; | ||
int num_data; | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE DATA | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static INPUT_EVENT inputevt_templates[INPUTEVT_NUM_EVENTID + 1] = | ||
{ | ||
{ | ||
0, | ||
0, | ||
{ | ||
{0,0,0}, | ||
}, | ||
0 | ||
}, | ||
{ | ||
INPUTEVT_EVENTID_PRESSED, | ||
0, | ||
{ | ||
//device_ref, data assigned by device | ||
{INPUTEVT_FIELDID_PRESSED_ISPRESSED, 0, INPUTEVT_DTYPE_INT, 0}, | ||
}, | ||
1, | ||
}, | ||
}; | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE FUNCTION DECLARATIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static bool inputevt_can_new(inputevt_eventid event_id); | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PUBLIC FUNCTIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
input_event inputevt_ini_new(inputevt_eventid event_id, inputevt_deviceid device_id) | ||
{ | ||
if (!inputevt_can_new(event_id)) | ||
return 0; | ||
|
||
input_event evt = (input_event)somax_malloc(sizeof(struct INPUT_EVENT)); | ||
|
||
memcpy(evt, &inputevt_templates[event_id], sizeof(INPUT_EVENT)); | ||
evt->device_id = device_id; | ||
|
||
return evt; | ||
} | ||
|
||
void inputevt_ini_dispose(input_event evt) | ||
{ | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE FUNCTIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static bool inputevt_can_new(inputevt_eventid event_id) | ||
{ | ||
if (event_id <= 0 || event_id > INPUTSRC_NUM_DEVICEID) | ||
{ | ||
somax_log_add(SOMAX_LOG_ERR, "INPUTEVT. open. unkown event id (%d)", event_id); | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef __inputevent_h__ | ||
#define __inputevent_h__ | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
// author: mark cass | ||
// project: somax personal AI | ||
// project url: https://mechanizedai.com | ||
// license: open source and free for all uses without encumbrance. | ||
// | ||
// FILE: inputevent.h | ||
// DESCRIPTION: Somax input provides a common interface to various input events. | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
|
||
#include "somax.h" | ||
|
||
#define INPUTEVT_EVENTID_UNKOWN 0b00000000000000000000000000000000 | ||
#define INPUTEVT_EVENTID_PRESSED 0b00000000000000000000000000000001 | ||
#define INPUTEVT_EVENTID_RELEASED 0b00000000000000000000000000000010 | ||
#define INPUTEVT_EVENTID_CLICKED 0b00000000000000000000000000000100 | ||
#define INPUTEVT_EVENTID_XCLICKED 0b00000000000000000000000000001000 | ||
#define INPUTEVT_EVENTID_UP 0b00000000000000000000000000010000 | ||
#define INPUTEVT_EVENTID_DOWN 0b00000000000000000000000000100000 | ||
#define INPUTEVT_EVENTID_LEFT 0b00000000000000000000000001000000 | ||
#define INPUTEVT_EVENTID_RIGHT 0b00000000000000000000000010000000 | ||
#define INPUTEVT_EVENTID_VALUEI 0b00000000000000000000000100000000 | ||
#define INPUTEVT_EVENTID_VALUEF 0b00000000000000000000001000000000 | ||
#define INPUTEVT_EVENTID_VALUEP 0b00000000000000000000010000000000 | ||
#define INPUTEVT_EVENTID_ARRAYI1D 0b00000000000000000000100000000000 | ||
#define INPUTEVT_EVENTID_ARRAYI2D 0b00000000000000000001000000000000 | ||
#define INPUTEVT_EVENTID_ARRAYF1D 0b00000000000000000010000000000000 | ||
#define INPUTEVT_EVENTID_ARRAYF2D 0b00000000000000000100000000000000 | ||
#define INPUTEVT_NUM_EVENTID 14 | ||
|
||
//pressed event | ||
#define INPUTEVT_FIELDID_PRESSED_ISPRESSED 0 | ||
//released event | ||
#define INPUTEVT_FIELDID_RELEASED_ISRELEASED 0 | ||
|
||
struct INPUT_EVENT; | ||
typedef struct INPUT_EVENT *input_event; | ||
typedef int inputevt_eventid; | ||
typedef int inputevt_deviceid; | ||
typedef int inputevt_fieldid; | ||
typedef int inputevt_device_fieldid; | ||
typedef int inputevt_dtypeid; | ||
|
||
input_event inputevt_ini_new(inputevt_eventid event_id, inputevt_deviceid device_id); | ||
void inputevt_ini_dispose(input_event evt); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
// author: mark cass | ||
// project: somax personal AI | ||
// project url: https://mechanizedai.com | ||
// license: open source and free for all uses without encumbrance. | ||
// | ||
// FILE: inputmixer.c | ||
// DESCRIPTION: Somax input mixer provides a means to configure and query input | ||
// devices. | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
|
||
#include "somax.h" | ||
#include "inputmixer.h" | ||
#include "inputsource.h" | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//CONSTANTS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//DATA STRUCTURES | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
struct INPUTMIXER_CONTEXT | ||
{ | ||
int context_slotid; | ||
inputsrc_context sources[INPUTMIX_NUM_SOURCEID]; | ||
int num_sources; | ||
inputmix_applicationid applications[INPUTMIX_MAX_APPLICATIONS]; | ||
int num_applications; | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE DATA | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static INPUTMIXER_CONTEXT mixer; | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE FUNCTION DECLARATIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static bool inputmix_can_open(); | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PUBLIC FUNCTIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
inputmix_applicationid inputmix_ini_open() | ||
{ | ||
if (!inputmix_can_open()) | ||
return 0; | ||
|
||
mixer.num_applications++; | ||
|
||
return mixer.num_applications; | ||
} | ||
|
||
void inputmix_ini_close(inputmix_applicationid appid) | ||
{ | ||
mixer.num_applications--; | ||
} | ||
|
||
bool inputmix_cfg_source(inputmix_applicationid appid, inputmix_sourceid source_id, bool enable) | ||
{ | ||
bool error = false; | ||
return error; | ||
} | ||
|
||
bool inputmix_cfg_event(inputmix_applicationid appid, inputmix_sourceid source_id, inputevt_eventid event_id, bool enable) | ||
{ | ||
bool error = false; | ||
return error; | ||
} | ||
|
||
bool inputmix_cfg_event_observer(inputmix_applicationid appid, inputmix_event_observer observer) | ||
{ | ||
bool error = false; | ||
return error; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
//PRIVATE FUNCTIONS | ||
//------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------ | ||
static bool inputmix_can_open() | ||
{ | ||
return true; | ||
} |
Oops, something went wrong.