Checkin, per Jason Vandermark.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@294 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,155 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* AUTHOR: nobody <baron>
|
||||||
|
* FILE: Input.cpp
|
||||||
|
* DATE: Sun Dec 16 15:57:43 2001
|
||||||
|
* DESCR:
|
||||||
|
***********************************************************************/
|
||||||
|
#include "Input.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::~BInputDevice()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
BInputDevice::~BInputDevice()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Name()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
BInputDevice::Name() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Type()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
input_device_type
|
||||||
|
BInputDevice::Type() const
|
||||||
|
{
|
||||||
|
input_device_type dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::IsRunning()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BInputDevice::IsRunning() const
|
||||||
|
{
|
||||||
|
bool dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Start()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Start()
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Stop()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Stop()
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Control()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Control(uint32 code,
|
||||||
|
BMessage *message)
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Start()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Start(input_device_type type)
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Stop()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Stop(input_device_type type)
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::Control()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BInputDevice::Control(input_device_type type,
|
||||||
|
uint32 code,
|
||||||
|
BMessage *message)
|
||||||
|
{
|
||||||
|
status_t dummy;
|
||||||
|
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::BInputDevice()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
BInputDevice::BInputDevice()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BInputDevice::set_name_and_type()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BInputDevice::set_name_and_type(const char *name,
|
||||||
|
input_device_type type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: Input.h
|
||||||
|
/
|
||||||
|
/ Description: Functions and class to manage input devices.
|
||||||
|
/
|
||||||
|
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||||
|
/
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _INPUT_H
|
||||||
|
#define _INPUT_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
enum input_method_op {
|
||||||
|
B_INPUT_METHOD_STARTED = 0,
|
||||||
|
B_INPUT_METHOD_STOPPED = 1,
|
||||||
|
B_INPUT_METHOD_CHANGED = 2,
|
||||||
|
B_INPUT_METHOD_LOCATION_REQUEST = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum input_device_type {
|
||||||
|
B_POINTING_DEVICE = 0,
|
||||||
|
B_KEYBOARD_DEVICE = 1,
|
||||||
|
B_UNDEFINED_DEVICE = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
what == B_INPUT_DEVICES_CHANGED
|
||||||
|
FindString("name", name_of_device);
|
||||||
|
FindInt32("opcode", input_device_notification);
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum input_device_notification {
|
||||||
|
B_INPUT_DEVICE_ADDED = 0x0001,
|
||||||
|
B_INPUT_DEVICE_STARTED = 0x0002,
|
||||||
|
B_INPUT_DEVICE_STOPPED = 0x0004,
|
||||||
|
B_INPUT_DEVICE_REMOVED = 0x0008
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BInputDevice;
|
||||||
|
|
||||||
|
|
||||||
|
_IMPEXP_BE BInputDevice* find_input_device(const char *name);
|
||||||
|
_IMPEXP_BE status_t get_input_devices(BList *list);
|
||||||
|
_IMPEXP_BE status_t watch_input_devices(BMessenger target, bool start);
|
||||||
|
|
||||||
|
|
||||||
|
class BInputDevice {
|
||||||
|
public:
|
||||||
|
~BInputDevice();
|
||||||
|
|
||||||
|
const char* Name() const;
|
||||||
|
input_device_type Type() const;
|
||||||
|
bool IsRunning() const;
|
||||||
|
|
||||||
|
status_t Start();
|
||||||
|
status_t Stop();
|
||||||
|
status_t Control(uint32 code,
|
||||||
|
BMessage *message);
|
||||||
|
|
||||||
|
static status_t Start(input_device_type type);
|
||||||
|
static status_t Stop(input_device_type type);
|
||||||
|
static status_t Control(input_device_type type,
|
||||||
|
uint32 code,
|
||||||
|
BMessage *message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend BInputDevice* find_input_device(const char *name);
|
||||||
|
friend status_t get_input_devices(BList *list);
|
||||||
|
|
||||||
|
BInputDevice();
|
||||||
|
void set_name_and_type(const char *name,
|
||||||
|
input_device_type type);
|
||||||
|
|
||||||
|
char* fName;
|
||||||
|
input_device_type fType;
|
||||||
|
uint32 _reserved[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,37 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// OpenBeOS InputServer
|
||||||
|
//
|
||||||
|
// Version: [0.0.5] [Development Stage]
|
||||||
|
//
|
||||||
|
// [Description]
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// This application and all source files used in its construction, except
|
||||||
|
// where noted, are licensed under the MIT License, and have been written
|
||||||
|
// and are:
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "InputServer.h"
|
#include "InputServer.h"
|
||||||
@@ -5,14 +39,44 @@
|
|||||||
#include "Directory.h"
|
#include "Directory.h"
|
||||||
#include "FindDirectory.h"
|
#include "FindDirectory.h"
|
||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
|
#include "Locker.h"
|
||||||
|
|
||||||
#include "InputServerDeviceListEntry.h"
|
#include "InputServerDeviceListEntry.h"
|
||||||
|
#include "InputServerFilterListEntry.h"
|
||||||
|
#include "InputServerMethodListEntry.h"
|
||||||
|
#include "Message.h"
|
||||||
|
|
||||||
|
// include app_server headers for communication
|
||||||
|
|
||||||
|
#include "PortLink.h"
|
||||||
|
#include "ServerProtocol.h"
|
||||||
|
|
||||||
|
#define SERVER_PORT_NAME "OBappserver"
|
||||||
|
#define SERVER_INPUT_PORT "OBinputport"
|
||||||
|
#define X_VALUE "x"
|
||||||
|
#define Y_VALUE "y"
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void RegisterDevices(input_device_ref** devices)
|
||||||
|
{
|
||||||
|
printf("RegisterDevices\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Static InputServer member variables.
|
||||||
|
//
|
||||||
|
BList InputServer::gInputDeviceList;
|
||||||
|
BLocker InputServer::gInputDeviceListLocker;
|
||||||
|
|
||||||
|
BList InputServer::mInputServerDeviceList;
|
||||||
|
BList InputServer::mInputServerFilterList;
|
||||||
|
BList InputServer::mInputServerMethodList;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int main(int argc, char* argv[])
|
int main()
|
||||||
{
|
{
|
||||||
InputServer *myInputServer;
|
InputServer *myInputServer;
|
||||||
|
|
||||||
@@ -21,29 +85,24 @@ int main(int argc, char* argv[])
|
|||||||
myInputServer->Run();
|
myInputServer->Run();
|
||||||
|
|
||||||
delete myInputServer;
|
delete myInputServer;
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
thread_id InputServer::Run()
|
|
||||||
{
|
|
||||||
InitDevices();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::InputServer()
|
* Method: InputServer::InputServer()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
InputServer::InputServer(void) : BApplication("application/x-vnd.OpenBeOS-input_server")
|
InputServer::InputServer(void) : BApplication("application/x-vnd.OBOS-input_server")
|
||||||
{
|
{
|
||||||
void *pointer;
|
void *pointer;
|
||||||
|
|
||||||
InitDevices();
|
|
||||||
EventLoop(pointer);
|
EventLoop(pointer);
|
||||||
|
|
||||||
|
InitTestDevice();
|
||||||
|
|
||||||
|
// InitDevices();
|
||||||
|
InitFilters();
|
||||||
|
InitMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -59,9 +118,28 @@ InputServer::~InputServer(void)
|
|||||||
* Method: InputServer::ArgvReceived()
|
* Method: InputServer::ArgvReceived()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
void InputServer::ArgvReceived(long,
|
void InputServer::ArgvReceived(int32 argc, char** argv)
|
||||||
char **)
|
|
||||||
{
|
{
|
||||||
|
if (2 == argc)
|
||||||
|
{
|
||||||
|
if (0 == strcmp("-q", argv[1]) )
|
||||||
|
{
|
||||||
|
// :TODO: Shutdown and restart the InputServer.
|
||||||
|
printf("InputServer::ArgvReceived - Restarting . . .\n");
|
||||||
|
status_t quit_status;
|
||||||
|
//BMessenger msgr = BMessenger("application/x-vnd.OpenBeOS-input_server", -1, &quit_status);
|
||||||
|
BMessenger msgr = BMessenger("application/x-vnd.OBOS-input_server", -1, &quit_status);
|
||||||
|
if (B_OK == quit_status)
|
||||||
|
{
|
||||||
|
BMessage msg = BMessage(B_QUIT_REQUESTED);
|
||||||
|
msgr.SendMessage(&msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Unable to send Quit message to running InputServer.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,8 +149,60 @@ void InputServer::ArgvReceived(long,
|
|||||||
*/
|
*/
|
||||||
void InputServer::InitKeyboardMouseStates(void)
|
void InputServer::InitKeyboardMouseStates(void)
|
||||||
{
|
{
|
||||||
|
// This is where we read in the preferences data for the mouse and keyboard as well as
|
||||||
|
// determine the screen resolution from the app_server and find the center of the screen
|
||||||
|
// sMousePos is then set to the center of the screen.
|
||||||
|
|
||||||
|
sMousePos.x = 200;
|
||||||
|
sMousePos.y = 200;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputServer::InitTestDevice()
|
||||||
|
{
|
||||||
|
printf("InputServer::InitTestDevice - Enter\n");
|
||||||
|
const char* path = "/boot/home/Projects/InputServer/ISD/nervous/nervous";
|
||||||
|
printf("InputServer::InitTestDevice - Loading add-on . . .\n");
|
||||||
|
image_id addon_image = load_add_on(path);
|
||||||
|
if (B_ERROR != addon_image)
|
||||||
|
{
|
||||||
|
status_t isd_status = B_NO_INIT;
|
||||||
|
BInputServerDevice* (*func)() = NULL;
|
||||||
|
printf("InputServer::InitTestDevice - Resolving symbol . . .\n");
|
||||||
|
if (B_OK == get_image_symbol(addon_image, "instantiate_input_device", B_SYMBOL_TYPE_TEXT, (void**)&func) )
|
||||||
|
{
|
||||||
|
printf("Found instantiate_input_device.\n");
|
||||||
|
if (NULL != func)
|
||||||
|
{
|
||||||
|
BInputServerDevice* isd = (*func)();
|
||||||
|
if (NULL != isd)
|
||||||
|
{
|
||||||
|
printf("InputServer::InitTestDevice - Calling InitCheck . . .\n");
|
||||||
|
isd_status = isd->InitCheck();
|
||||||
|
mInputServerDeviceList.AddItem(
|
||||||
|
new InputServerDeviceListEntry(path, isd_status, isd) );
|
||||||
|
if (B_OK == isd_status)
|
||||||
|
{
|
||||||
|
//printf("Starting Nervous . . .\n");
|
||||||
|
//isd->Start("Nervous Device", NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("InitCheck failed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (B_OK != isd_status)
|
||||||
|
{
|
||||||
|
// Free resources associated with ISD's
|
||||||
|
// that failed to initialize.
|
||||||
|
//
|
||||||
|
//unload_add_on(addon_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("InputServer::InitTestDevice - Exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::InitDevices()
|
* Method: InputServer::InitDevices()
|
||||||
@@ -138,7 +268,7 @@ status_t InputServer::AddInputServerDevice(const char* path)
|
|||||||
BInputServerDevice* isd = (*func)();
|
BInputServerDevice* isd = (*func)();
|
||||||
if (NULL != isd)
|
if (NULL != isd)
|
||||||
{
|
{
|
||||||
status_t isd_status = isd->InitCheck();
|
isd_status = isd->InitCheck();
|
||||||
mInputServerDeviceList.AddItem(
|
mInputServerDeviceList.AddItem(
|
||||||
new InputServerDeviceListEntry(path, isd_status, isd) );
|
new InputServerDeviceListEntry(path, isd_status, isd) );
|
||||||
}
|
}
|
||||||
@@ -179,7 +309,7 @@ void InputServer::InitFilters(void)
|
|||||||
|
|
||||||
printf("InputServer::InitFilters - Enter\n");
|
printf("InputServer::InitFilters - Enter\n");
|
||||||
|
|
||||||
// Find all Input Server Devices in each of the predefined
|
// Find all Input Filters in each of the predefined
|
||||||
// addon directories.
|
// addon directories.
|
||||||
//
|
//
|
||||||
for (int i = 0; i < addon_dir_count; i++)
|
for (int i = 0; i < addon_dir_count; i++)
|
||||||
@@ -192,11 +322,55 @@ void InputServer::InitFilters(void)
|
|||||||
{
|
{
|
||||||
entry.GetPath(&addon_path);
|
entry.GetPath(&addon_path);
|
||||||
printf("Adding %s . . .\n", addon_path.Path() );
|
printf("Adding %s . . .\n", addon_path.Path() );
|
||||||
AddInputServerDevice(addon_path.Path() );
|
AddInputServerFilter(addon_path.Path() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("InputServer::InitDevices - Exit\n");
|
printf("InputServer::InitFilters - Exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: InputServer::AddInputServerFilter()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t InputServer::AddInputServerFilter(const char* path)
|
||||||
|
{
|
||||||
|
image_id addon_image= load_add_on(path);
|
||||||
|
if (B_ERROR != addon_image)
|
||||||
|
{
|
||||||
|
status_t isf_status = B_NO_INIT;
|
||||||
|
BInputServerFilter* (*func)() = NULL;
|
||||||
|
if (B_OK == get_image_symbol(addon_image, "instantiate_input_filter", B_SYMBOL_TYPE_TEXT, (void**)&func) )
|
||||||
|
{
|
||||||
|
if (NULL != func)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// :DANGER: Only reenable this section if this
|
||||||
|
// InputServer can start and manage the
|
||||||
|
// filters, otherwise the system will hang.
|
||||||
|
//
|
||||||
|
BInputFilter isf = (*func)();
|
||||||
|
if (NULL != isf)
|
||||||
|
{
|
||||||
|
isf_status = isf->InitCheck();
|
||||||
|
mInputServerFilterList.AddItem(
|
||||||
|
new InputServerFilterListEntry(path, isf_status, isf );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
mInputServerFilterList.AddItem(
|
||||||
|
new InputServerFilterListEntry(path, B_NO_INIT, NULL) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (B_OK != isf_status)
|
||||||
|
{
|
||||||
|
// Free resources associated with InputServerFilters
|
||||||
|
// that failed to initialize.
|
||||||
|
//
|
||||||
|
unload_add_on(addon_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -218,26 +392,70 @@ void InputServer::InitMethods(void)
|
|||||||
};
|
};
|
||||||
const int addon_dir_count = sizeof(addon_dirs) / sizeof(directory_which);
|
const int addon_dir_count = sizeof(addon_dirs) / sizeof(directory_which);
|
||||||
|
|
||||||
printf("InputServer::InitDevices - Enter\n");
|
printf("InputServer::InitMethods - Enter\n");
|
||||||
|
|
||||||
// Find all Input Server Devices in each of the predefined
|
// Find all Input Methods in each of the predefined
|
||||||
// addon directories.
|
// addon directories.
|
||||||
//
|
//
|
||||||
for (int i = 0; i < addon_dir_count; i++)
|
for (int i = 0; i < addon_dir_count; i++)
|
||||||
{
|
{
|
||||||
if (B_OK == find_directory(addon_dirs[i], &addon_dir) )
|
if (B_OK == find_directory(addon_dirs[i], &addon_dir) )
|
||||||
{
|
{
|
||||||
addon_dir.Append("input_server/devices");
|
addon_dir.Append("input_server/methods");
|
||||||
dir.SetTo(addon_dir.Path() );
|
dir.SetTo(addon_dir.Path() );
|
||||||
while (B_NO_ERROR == dir.GetNextEntry(&entry, false) )
|
while (B_NO_ERROR == dir.GetNextEntry(&entry, false) )
|
||||||
{
|
{
|
||||||
entry.GetPath(&addon_path);
|
entry.GetPath(&addon_path);
|
||||||
printf("Adding %s . . .\n", addon_path.Path() );
|
printf("Adding %s . . .\n", addon_path.Path() );
|
||||||
AddInputServerDevice(addon_path.Path() );
|
AddInputServerMethod(addon_path.Path() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("InputServer::InitDevices - Exit\n");
|
printf("InputServer::InitMethods - Exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: InputServer::AddInputServerMethod()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t InputServer::AddInputServerMethod(const char* path)
|
||||||
|
{
|
||||||
|
image_id addon_image= load_add_on(path);
|
||||||
|
if (B_ERROR != addon_image)
|
||||||
|
{
|
||||||
|
status_t ism_status = B_NO_INIT;
|
||||||
|
BInputServerMethod* (*func)() = NULL;
|
||||||
|
if (B_OK == get_image_symbol(addon_image, "instantiate_input_method", B_SYMBOL_TYPE_TEXT, (void**)&func) )
|
||||||
|
{
|
||||||
|
if (NULL != func)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// :DANGER: Only reenable this section if this
|
||||||
|
// InputServer can start and manage the
|
||||||
|
// methods, otherwise the system will hang.
|
||||||
|
//
|
||||||
|
BInputServerMethod ism = (*func)();
|
||||||
|
if (NULL != ism)
|
||||||
|
{
|
||||||
|
ism_status = ism->InitCheck();
|
||||||
|
mInputServerMethodList.AddItem(
|
||||||
|
new InputServerMethodListEntry(path, ism_status, ism) );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
mInputServerMethodList.AddItem(
|
||||||
|
new InputServerMethodListEntry(path, B_NO_INIT, NULL) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (B_OK != ism_status)
|
||||||
|
{
|
||||||
|
// Free resources associated with InputServerMethods
|
||||||
|
// that failed to initialize.
|
||||||
|
//
|
||||||
|
unload_add_on(addon_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -404,13 +622,18 @@ BMessenger *app_server;
|
|||||||
//HandleFocusUnfocusIMAwareView();
|
//HandleFocusUnfocusIMAwareView();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case B_QUIT_REQUESTED:
|
||||||
|
{
|
||||||
|
QuitRequested();
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
printf("Default message . . .\n");
|
||||||
app_server = new BMessenger("application/x-vnd.Be-APPS", -1, NULL);
|
app_server = new BMessenger("application/x-vnd.Be-APPS", -1, NULL);
|
||||||
if (app_server->IsValid())
|
if (app_server->IsValid())
|
||||||
{
|
{
|
||||||
app_server->SendMessage(message);
|
//app_server->SendMessage(message);
|
||||||
|
|
||||||
}
|
}
|
||||||
delete app_server;
|
delete app_server;
|
||||||
@@ -583,9 +806,10 @@ void InputServer::HandleFocusUnfocusIMAwareView(BMessage *,
|
|||||||
* Method: InputServer::EnqueueDeviceMessage()
|
* Method: InputServer::EnqueueDeviceMessage()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::EnqueueDeviceMessage(BMessage *)
|
status_t InputServer::EnqueueDeviceMessage(BMessage *message)
|
||||||
{
|
{
|
||||||
return 0;
|
//return (write_port(fEventPort, (int32)message, NULL, 0));
|
||||||
|
return (write_port(EventLooperPort, (int32)message, NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -657,15 +881,14 @@ const BMessenger* InputServer::MethodReplicant(void)
|
|||||||
*/
|
*/
|
||||||
status_t InputServer::EventLoop(void *)
|
status_t InputServer::EventLoop(void *)
|
||||||
{
|
{
|
||||||
|
printf("Starting event loop . . .\n");
|
||||||
EventLooperPort = create_port(29,"is_event_port");
|
EventLooperPort = create_port(100, "obos_is_event_port");
|
||||||
if(EventLooperPort < 0) {
|
if(EventLooperPort < 0) {
|
||||||
_sPrintf("OBOS InputServer: create_port error: (0x%x) %s\n",EventLooperPort,strerror(EventLooperPort));
|
_sPrintf("OBOS InputServer: create_port error: (0x%x) %s\n",EventLooperPort,strerror(EventLooperPort));
|
||||||
}
|
}
|
||||||
ISPortThread = spawn_thread(ISPortWatcher, "_input_server_event_loop_", B_REAL_TIME_DISPLAY_PRIORITY+3, this);
|
ISPortThread = spawn_thread(ISPortWatcher, "_input_server_event_loop_", B_REAL_TIME_DISPLAY_PRIORITY+3, this);
|
||||||
resume_thread(ISPortThread);
|
resume_thread(ISPortThread);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,12 +907,56 @@ bool InputServer::EventLoopRunning(void)
|
|||||||
* Method: InputServer::DispatchEvents()
|
* Method: InputServer::DispatchEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::DispatchEvents(BList *)
|
bool InputServer::DispatchEvents(BList *eventList)
|
||||||
{
|
{
|
||||||
|
BMessage *event;
|
||||||
|
|
||||||
|
for ( int32 i = 0; NULL != (event = (BMessage *)eventList->ItemAt(i)); i++ )
|
||||||
|
{
|
||||||
|
// now we must send each event to the app_server
|
||||||
|
DispatchEvent(event);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}// end DispatchEvents()
|
||||||
|
|
||||||
|
int InputServer::DispatchEvent(BMessage *message)
|
||||||
|
{
|
||||||
|
// variables
|
||||||
|
int32 xValue,
|
||||||
|
yValue;
|
||||||
|
uint32 buttons = 0;
|
||||||
|
|
||||||
|
message->FindInt32("x",xValue);
|
||||||
|
printf("[DispatchEvent] x = %lu:\n",xValue);
|
||||||
|
|
||||||
|
port_id pid = find_port(SERVER_INPUT_PORT);
|
||||||
|
PortLink *appsvrlink = new PortLink(pid);
|
||||||
|
switch(message->what){
|
||||||
|
case B_MOUSE_MOVED:{
|
||||||
|
// get point and button from msg
|
||||||
|
if((message->FindInt32(X_VALUE,&xValue) == B_OK) && (message->FindInt32(Y_VALUE,&yValue) == B_OK)){
|
||||||
|
int64 time=(int64)real_time_clock();
|
||||||
|
appsvrlink->SetOpCode(B_MOUSE_MOVED);
|
||||||
|
appsvrlink->Attach(&time,sizeof(int64));
|
||||||
|
appsvrlink->Attach(&xValue,sizeof(float));
|
||||||
|
appsvrlink->Attach(&yValue,sizeof(float));
|
||||||
|
message->FindInt32("buttons",buttons);
|
||||||
|
appsvrlink->Attach(&buttons,sizeof(int32));
|
||||||
|
appsvrlink->Flush();
|
||||||
|
printf("B_MOUSE_MOVED: x = %lu: y = %lu: time = %llu: buttons = %lu\n",xValue,yValue,time,buttons);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Should be some Mouse Down and Up code here ..
|
||||||
|
// Along with some Key Down and up codes ..
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
delete appsvrlink;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::CacheEvents()
|
* Method: InputServer::CacheEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
@@ -712,10 +979,82 @@ const BList* InputServer::GetNextEvents(BList *)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::FilterEvents()
|
* Method: InputServer::FilterEvents()
|
||||||
* Descr:
|
* Descr: This method applies all defined filters to each event in the
|
||||||
|
* supplied list. The supplied list is modified to reflect the
|
||||||
|
* output of the filters.
|
||||||
|
* The method returns true if the filters were applied to all
|
||||||
|
* events without error and false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InputServer::FilterEvents(BList *)
|
bool InputServer::FilterEvents(BList *eventsToFilter)
|
||||||
{
|
{
|
||||||
|
if (NULL != eventsToFilter)
|
||||||
|
{
|
||||||
|
BInputServerFilter* current_filter;
|
||||||
|
BMessage* current_event;
|
||||||
|
int32 filter_index = 0;
|
||||||
|
int32 event_index = 0;
|
||||||
|
|
||||||
|
while (NULL != (current_filter = (BInputServerFilter*)mInputServerFilterList.ItemAt(filter_index) ) )
|
||||||
|
{
|
||||||
|
// Apply the current filter to all available event messages.
|
||||||
|
//
|
||||||
|
while (NULL != (current_event = (BMessage*)eventsToFilter->ItemAt(event_index) ) )
|
||||||
|
{
|
||||||
|
// Storage for new event messages generated by the filter.
|
||||||
|
//
|
||||||
|
BList out_list;
|
||||||
|
|
||||||
|
// Apply the current filter to the current event message.
|
||||||
|
//
|
||||||
|
filter_result result = current_filter->Filter(current_event, &out_list);
|
||||||
|
if (B_DISPATCH_MESSAGE == result)
|
||||||
|
{
|
||||||
|
// Use the result in current_message; ignore out_list.
|
||||||
|
//
|
||||||
|
event_index++;
|
||||||
|
|
||||||
|
// Free resources associated with items in out_list.
|
||||||
|
//
|
||||||
|
void* out_item;
|
||||||
|
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
||||||
|
{
|
||||||
|
delete out_item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (B_SKIP_MESSAGE == result)
|
||||||
|
{
|
||||||
|
// Use the result in out_list (if any); ignore current message.
|
||||||
|
//
|
||||||
|
eventsToFilter->RemoveItem(event_index);
|
||||||
|
eventsToFilter->AddList(&out_list, event_index);
|
||||||
|
event_index += out_list.CountItems();
|
||||||
|
|
||||||
|
// NOTE: eventsToFilter now owns out_list's items.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Error - Free resources associated with items in out_list and return.
|
||||||
|
//
|
||||||
|
void* out_item;
|
||||||
|
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
||||||
|
{
|
||||||
|
delete out_item;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: The BList destructor frees out_lists's resources here.
|
||||||
|
// It does NOT free the resources associated with out_list's
|
||||||
|
// member items - those should either already be deleted or
|
||||||
|
// should be owned by eventsToFilter.
|
||||||
|
}
|
||||||
|
|
||||||
|
} // while()
|
||||||
|
|
||||||
|
filter_index++;
|
||||||
|
|
||||||
|
} // while()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,9 +1084,34 @@ bool InputServer::MethodizeEvents(BList *,
|
|||||||
* Method: InputServer::StartStopDevices()
|
* Method: InputServer::StartStopDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::StartStopDevices(const char* deviceName, input_device_type deviceType, bool doStart)
|
status_t InputServer::StartStopDevices(const char* deviceName,
|
||||||
|
input_device_type deviceType,
|
||||||
|
bool doStart)
|
||||||
{
|
{
|
||||||
return 0;
|
printf("StartStopDevice: Enter\n");
|
||||||
|
for (int i = gInputDeviceList.CountItems() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
printf("Device #%d\n", i);
|
||||||
|
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
||||||
|
if (NULL != item)
|
||||||
|
{
|
||||||
|
BInputServerDevice* isd = item->mIsd;
|
||||||
|
input_device_ref* dev = item->mDev;
|
||||||
|
printf("Hey\n");
|
||||||
|
if ( (NULL != isd) && (NULL != dev) )
|
||||||
|
{
|
||||||
|
printf(" Starting/stopping: %s\n", dev->name);
|
||||||
|
if (deviceType == dev->type)
|
||||||
|
{
|
||||||
|
if (doStart) isd->Start(dev->name, dev->cookie);
|
||||||
|
else isd->Stop(dev->name, dev->cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("StartStopDevice: Exit\n");
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -834,32 +1198,40 @@ void InputServer::WatchPort()
|
|||||||
int32 code;
|
int32 code;
|
||||||
ssize_t length;
|
ssize_t length;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
BMessage *event;
|
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Block until we find the size of the next message
|
// Block until we find the size of the next message
|
||||||
length = port_buffer_size(EventLooperPort);
|
length = port_buffer_size(EventLooperPort);
|
||||||
buffer = (char*)malloc(length);
|
buffer = (char*)malloc(length);
|
||||||
event = NULL;
|
printf("[Event Looper] BMessage Size = %d\n", length);
|
||||||
event = new BMessage();
|
//event = NULL;
|
||||||
|
BMessage *event = new BMessage();
|
||||||
err = read_port(EventLooperPort, &code, buffer, length);
|
err = read_port(EventLooperPort, &code, buffer, length);
|
||||||
if(err != length) {
|
if(err != length) {
|
||||||
if(err >= 0) {
|
if(err >= 0) {
|
||||||
_sPrintf("InputServer: failed to read full packet (read %u of %u)\n",err,length);
|
printf("InputServer: failed to read full packet (read %lu of %lu)\n",err,length);
|
||||||
} else {
|
} else {
|
||||||
_sPrintf("InputServer: read_port error: (0x%x) %s\n",err,strerror(err));
|
printf("InputServer: read_port error: (0x%lx) %s\n",err,strerror(err));
|
||||||
}
|
}
|
||||||
} else if ((err = event->Unflatten(buffer)) < 0) {
|
|
||||||
_sPrintf("InputServer: (0x%x) %s\n",err,strerror(err));
|
|
||||||
}else{
|
}else{
|
||||||
// add the event
|
|
||||||
//CacheEvents(event);
|
if ((err = event->Unflatten(buffer)) < 0) {
|
||||||
event = NULL;
|
printf("[InputServer] Unflatten() error: (0x%lx) %s\n",err,strerror(err));
|
||||||
|
} else {
|
||||||
|
// This is where the message should be processed.
|
||||||
|
event->PrintToStream();
|
||||||
|
|
||||||
|
DispatchEvent(event);
|
||||||
|
|
||||||
|
//printf("Event writen to port\n");
|
||||||
|
delete(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
if(event!=NULL) {
|
if(event!=NULL) {
|
||||||
delete(event);
|
//delete(event);
|
||||||
event = NULL;
|
event = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,13 @@
|
|||||||
// BeAPI Headers
|
// BeAPI Headers
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include "InputServerDevice.h"
|
#include "InputServerDevice.h"
|
||||||
|
#include "InputServerFilter.h"
|
||||||
|
#include "InputServerMethod.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <Locker.h>
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -43,7 +47,44 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include "InputServerTypes.h"
|
class PortLink;
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
#define SET_METHOD 'stmd'
|
||||||
|
#define GET_MOUSE_TYPE 'gtmt'
|
||||||
|
#define SET_MOUSE_TYPE 'stmt'
|
||||||
|
#define GET_MOUSE_ACCELERATION 'gtma'
|
||||||
|
#define SET_MOUSE_ACCELERATION 'stma'
|
||||||
|
#define GET_KEY_REPEAT_DELAY 'gkrd'
|
||||||
|
#define SET_KEY_REPEAT_DELAY 'skrd'
|
||||||
|
#define GET_KEY_INFO 'ktki'
|
||||||
|
#define GET_MODIFIERS 'gtmf'
|
||||||
|
#define SET_MODIFIER_KEY 'smky'
|
||||||
|
#define SET_KEYBOARD_LOCKS 'skbl'
|
||||||
|
#define GET_MOUSE_SPEED 'gtms'
|
||||||
|
#define SET_MOUSE_SPEED 'stms'
|
||||||
|
#define SET_MOUSE_POSITION 'stmp'
|
||||||
|
#define GET_MOUSE_MAP 'gtmm'
|
||||||
|
#define SET_MOUSE_MAP 'stmm'
|
||||||
|
#define GET_KEYBOARD_ID 'gkbi'
|
||||||
|
#define GET_CLICK_SPEED 'gtcs'
|
||||||
|
#define SET_CLICK_SPEED 'stcs'
|
||||||
|
#define GET_KEY_REPEAT_RATE 'gkrr'
|
||||||
|
#define SET_KEY_REPEAT_RATE 'skrr'
|
||||||
|
#define GET_KEY_MAP 'gtkm'
|
||||||
|
#define SET_KEY_MAP 'stkm'
|
||||||
|
#define FOCUS_IM_AWARE_VIEW 'fiav'
|
||||||
|
#define UNFOCUS_IM_AWARE_VIEW 'uiav'
|
||||||
|
|
||||||
|
class InputDeviceListItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BInputServerDevice* mIsd;
|
||||||
|
input_device_ref* mDev;
|
||||||
|
|
||||||
|
InputDeviceListItem(BInputServerDevice* isd, input_device_ref* dev):
|
||||||
|
mIsd(isd), mDev(dev) {};
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// InputServer
|
// InputServer
|
||||||
@@ -97,16 +138,17 @@ public:
|
|||||||
const BMessenger* MethodReplicant(void);
|
const BMessenger* MethodReplicant(void);
|
||||||
|
|
||||||
status_t EventLoop(void*);
|
status_t EventLoop(void*);
|
||||||
bool EventLoopRunning(void);
|
static bool EventLoopRunning(void);
|
||||||
|
|
||||||
bool DispatchEvents(BList*);
|
bool DispatchEvents(BList*);
|
||||||
|
int DispatchEvent(BMessage*);
|
||||||
bool CacheEvents(BList*);
|
bool CacheEvents(BList*);
|
||||||
const BList* GetNextEvents(BList*);
|
const BList* GetNextEvents(BList*);
|
||||||
bool FilterEvents(BList*);
|
bool FilterEvents(BList*);
|
||||||
bool SanitizeEvents(BList*);
|
bool SanitizeEvents(BList*);
|
||||||
bool MethodizeEvents(BList*, bool);
|
bool MethodizeEvents(BList*, bool);
|
||||||
|
|
||||||
status_t StartStopDevices(const char *, input_device_type, bool);
|
static status_t StartStopDevices(const char *, input_device_type, bool);
|
||||||
status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*);
|
status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*);
|
||||||
|
|
||||||
bool DoMouseAcceleration(long*, long*);
|
bool DoMouseAcceleration(long*, long*);
|
||||||
@@ -116,22 +158,39 @@ public:
|
|||||||
|
|
||||||
bool SafeMode(void);
|
bool SafeMode(void);
|
||||||
|
|
||||||
|
static BList gInputDeviceList;
|
||||||
|
static BLocker gInputDeviceListLocker;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void InitTestDevice();
|
||||||
|
|
||||||
status_t AddInputServerDevice(const char* path);
|
status_t AddInputServerDevice(const char* path);
|
||||||
|
status_t AddInputServerFilter(const char* path);
|
||||||
|
status_t AddInputServerMethod(const char* path);
|
||||||
|
|
||||||
bool sEventLoopRunning;
|
bool sEventLoopRunning;
|
||||||
bool sSafeMode;
|
bool sSafeMode;
|
||||||
|
port_id sEventPort;
|
||||||
|
BPoint sMousePos;
|
||||||
|
|
||||||
BList mInputServerDeviceList;
|
|
||||||
BList mInputMethodList;
|
|
||||||
BList mInputFilterList;
|
|
||||||
port_id ISPort;
|
port_id ISPort;
|
||||||
port_id EventLooperPort;
|
port_id EventLooperPort;
|
||||||
thread_id ISPortThread;
|
thread_id ISPortThread;
|
||||||
static int32 ISPortWatcher(void *arg);
|
static int32 ISPortWatcher(void *arg);
|
||||||
void WatchPort();
|
void WatchPort();
|
||||||
|
|
||||||
|
static bool doStartStopDevice(void*, void*);
|
||||||
|
|
||||||
|
static BList mInputServerDeviceList;
|
||||||
|
static BList mInputServerFilterList;
|
||||||
|
static BList mInputServerMethodList;
|
||||||
|
|
||||||
|
// added this to communicate via portlink
|
||||||
|
|
||||||
|
PortLink *serverlink;
|
||||||
|
|
||||||
//fMouseState;
|
//fMouseState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,12 +1,41 @@
|
|||||||
/***********************************************************************
|
/*****************************************************************************/
|
||||||
* AUTHOR: nobody <baron>
|
// OpenBeOS InputServer
|
||||||
* FILE: InputServerDevice.cpp
|
//
|
||||||
* DATE: Sun Dec 16 15:57:43 2001
|
// Version: [0.0.5] [Development Stage]
|
||||||
* DESCR:
|
//
|
||||||
***********************************************************************/
|
// [Description]
|
||||||
#include "InputServerDevice.h"
|
//
|
||||||
|
//
|
||||||
|
// This application and all source files used in its construction, except
|
||||||
|
// where noted, are licensed under the MIT License, and have been written
|
||||||
|
// and are:
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
|
#include "InputServerDevice.h"
|
||||||
|
#include "InputServer.h"
|
||||||
|
|
||||||
|
/**
|
||||||
* Method: BInputServerDevice::BInputServerDevice()
|
* Method: BInputServerDevice::BInputServerDevice()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -15,7 +44,7 @@ BInputServerDevice::BInputServerDevice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::~BInputServerDevice()
|
* Method: BInputServerDevice::~BInputServerDevice()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +53,7 @@ BInputServerDevice::~BInputServerDevice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::InitCheck()
|
* Method: BInputServerDevice::InitCheck()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -37,7 +66,7 @@ BInputServerDevice::InitCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::SystemShuttingDown()
|
* Method: BInputServerDevice::SystemShuttingDown()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -50,7 +79,7 @@ BInputServerDevice::SystemShuttingDown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::Start()
|
* Method: BInputServerDevice::Start()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -64,7 +93,7 @@ BInputServerDevice::Start(const char *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::Stop()
|
* Method: BInputServerDevice::Stop()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +107,7 @@ BInputServerDevice::Stop(const char *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::Control()
|
* Method: BInputServerDevice::Control()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -94,20 +123,57 @@ BInputServerDevice::Control(const char *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::RegisterDevices()
|
* Method: BInputServerDevice::RegisterDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
||||||
{
|
{
|
||||||
status_t dummy;
|
/*
|
||||||
|
// Lock this section of code so that access to the device list
|
||||||
|
// is serialized. Be sure to release the lock before exitting.
|
||||||
|
//
|
||||||
|
InputServer::gInputDeviceListLocker.Lock();
|
||||||
|
|
||||||
return dummy;
|
bool has_pointing_device = false;
|
||||||
|
bool has_keyboard_device = false;
|
||||||
|
|
||||||
|
input_device_ref *device = NULL;
|
||||||
|
for (int i = 0; NULL != (device = devices[i]); i++)
|
||||||
|
{
|
||||||
|
// :TODO: Check to make sure that each device is valid and
|
||||||
|
// that it is not already registered.
|
||||||
|
// getDeviceIndex()
|
||||||
|
|
||||||
|
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, device) );
|
||||||
|
|
||||||
|
has_pointing_device = has_pointing_device || (device->type == B_POINTING_DEVICE);
|
||||||
|
has_keyboard_device = has_keyboard_device || (device->type == B_KEYBOARD_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the InputServer event loop is running, signal the InputServer
|
||||||
|
// to start all devices of the type managed by this InputServerDevice.
|
||||||
|
//
|
||||||
|
if (InputServer::EventLoopRunning() )
|
||||||
|
{
|
||||||
|
if (has_pointing_device)
|
||||||
|
{
|
||||||
|
InputServer::StartStopDevices(NULL, B_POINTING_DEVICE, true);
|
||||||
|
}
|
||||||
|
if (has_keyboard_device)
|
||||||
|
{
|
||||||
|
InputServer::StartStopDevices(NULL, B_KEYBOARD_DEVICE, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InputServer::gInputDeviceListLocker.Unlock();
|
||||||
|
*/
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::UnregisterDevices()
|
* Method: BInputServerDevice::UnregisterDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -120,20 +186,33 @@ BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::EnqueueMessage()
|
* Method: BInputServerDevice::EnqueueMessage()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BInputServerDevice::EnqueueMessage(BMessage *message)
|
BInputServerDevice::EnqueueMessage(BMessage *message)
|
||||||
{
|
{
|
||||||
status_t dummy;
|
/* status_t err;
|
||||||
|
|
||||||
return dummy;
|
ssize_t length = message->FlattenedSize();
|
||||||
|
char* buffer = new char[length];
|
||||||
|
if ((err = message->Flatten(buffer,length)) < 0) {
|
||||||
|
} else {
|
||||||
|
if((write_port(mEventPort, 0, buffer, length)) < 0) {
|
||||||
|
|
||||||
|
}else {
|
||||||
|
free(buffer);
|
||||||
|
err = B_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
*/
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::StartMonitoringDevice()
|
* Method: BInputServerDevice::StartMonitoringDevice()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +225,7 @@ BInputServerDevice::StartMonitoringDevice(const char *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::StopMonitoringDevice()
|
* Method: BInputServerDevice::StopMonitoringDevice()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -158,8 +237,12 @@ BInputServerDevice::StopMonitoringDevice(const char *device)
|
|||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
///////////////////////// Below this line is reserved functions /////////////////////////////
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* Method: BInputServerDevice::_ReservedInputServerDevice1()
|
* Method: BInputServerDevice::_ReservedInputServerDevice1()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -169,7 +252,7 @@ BInputServerDevice::_ReservedInputServerDevice1()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::_ReservedInputServerDevice2()
|
* Method: BInputServerDevice::_ReservedInputServerDevice2()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -179,7 +262,7 @@ BInputServerDevice::_ReservedInputServerDevice2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::_ReservedInputServerDevice3()
|
* Method: BInputServerDevice::_ReservedInputServerDevice3()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -189,7 +272,7 @@ BInputServerDevice::_ReservedInputServerDevice3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerDevice::_ReservedInputServerDevice4()
|
* Method: BInputServerDevice::_ReservedInputServerDevice4()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: InputServerDevice.h
|
||||||
|
/
|
||||||
|
/ Description: Add-on class for input_server devices.
|
||||||
|
/
|
||||||
|
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||||
|
/
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _INPUTSERVERDEVICE_H
|
||||||
|
#define _INPUTSERVERDEVICE_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <Input.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct input_device_ref {
|
||||||
|
char *name;
|
||||||
|
input_device_type type;
|
||||||
|
void *cookie;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
// B_KEYBOARD_DEVICE notifications
|
||||||
|
B_KEY_MAP_CHANGED = 1,
|
||||||
|
B_KEY_LOCKS_CHANGED,
|
||||||
|
B_KEY_REPEAT_DELAY_CHANGED,
|
||||||
|
B_KEY_REPEAT_RATE_CHANGED,
|
||||||
|
|
||||||
|
// B_POINTING_DEVICE notifications
|
||||||
|
B_MOUSE_TYPE_CHANGED,
|
||||||
|
B_MOUSE_MAP_CHANGED,
|
||||||
|
B_MOUSE_SPEED_CHANGED,
|
||||||
|
B_CLICK_SPEED_CHANGED,
|
||||||
|
B_MOUSE_ACCELERATION_CHANGED
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class _BDeviceAddOn_;
|
||||||
|
|
||||||
|
|
||||||
|
class BInputServerDevice {
|
||||||
|
public:
|
||||||
|
BInputServerDevice();
|
||||||
|
virtual ~BInputServerDevice();
|
||||||
|
|
||||||
|
virtual status_t InitCheck();
|
||||||
|
virtual status_t SystemShuttingDown();
|
||||||
|
|
||||||
|
virtual status_t Start(const char *device, void *cookie);
|
||||||
|
virtual status_t Stop(const char *device, void *cookie);
|
||||||
|
virtual status_t Control(const char *device,
|
||||||
|
void *cookie,
|
||||||
|
uint32 code,
|
||||||
|
BMessage *message);
|
||||||
|
|
||||||
|
status_t RegisterDevices(input_device_ref **devices);
|
||||||
|
status_t UnregisterDevices(input_device_ref **devices);
|
||||||
|
|
||||||
|
status_t EnqueueMessage(BMessage *message);
|
||||||
|
|
||||||
|
status_t StartMonitoringDevice(const char *device);
|
||||||
|
status_t StopMonitoringDevice(const char *device);
|
||||||
|
|
||||||
|
private:
|
||||||
|
_BDeviceAddOn_* fOwner;
|
||||||
|
virtual void _ReservedInputServerDevice1();
|
||||||
|
virtual void _ReservedInputServerDevice2();
|
||||||
|
virtual void _ReservedInputServerDevice3();
|
||||||
|
virtual void _ReservedInputServerDevice4();
|
||||||
|
uint32 _reserved[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,12 +6,12 @@ class InputServerDeviceListEntry
|
|||||||
public:
|
public:
|
||||||
inline const char* getPath() { return mPath; };
|
inline const char* getPath() { return mPath; };
|
||||||
inline status_t getStatus() { return mStatus; };
|
inline status_t getStatus() { return mStatus; };
|
||||||
inline const BInputServerDevice* getInputServerDevice() { return mIsd; };
|
inline BInputServerDevice* getInputServerDevice() { return mIsd; };
|
||||||
|
|
||||||
InputServerDeviceListEntry(
|
InputServerDeviceListEntry(
|
||||||
const char* path,
|
const char* path,
|
||||||
status_t status,
|
status_t status,
|
||||||
const BInputServerDevice* isd) : mPath (path),
|
BInputServerDevice* isd) : mPath (path),
|
||||||
mStatus(status),
|
mStatus(status),
|
||||||
mIsd (isd)
|
mIsd (isd)
|
||||||
{ /* Do nothing */ };
|
{ /* Do nothing */ };
|
||||||
@@ -22,6 +22,6 @@ class InputServerDeviceListEntry
|
|||||||
private:
|
private:
|
||||||
const char* mPath;
|
const char* mPath;
|
||||||
status_t mStatus;
|
status_t mStatus;
|
||||||
const BInputServerDevice* mIsd;
|
BInputServerDevice* mIsd;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,40 @@
|
|||||||
/***********************************************************************
|
/*****************************************************************************/
|
||||||
* AUTHOR: nobody <baron>
|
// OpenBeOS InputServer
|
||||||
* FILE: InputServerFilter.cpp
|
//
|
||||||
* DATE: Sun Dec 16 15:57:43 2001
|
// Version: [0.0.5] [Development Stage]
|
||||||
* DESCR:
|
//
|
||||||
***********************************************************************/
|
// [Description]
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// This application and all source files used in its construction, except
|
||||||
|
// where noted, are licensed under the MIT License, and have been written
|
||||||
|
// and are:
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "InputServerFilter.h"
|
#include "InputServerFilter.h"
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::BInputServerFilter()
|
* Method: BInputServerFilter::BInputServerFilter()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -15,7 +43,7 @@ BInputServerFilter::BInputServerFilter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::~BInputServerFilter()
|
* Method: BInputServerFilter::~BInputServerFilter()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +52,7 @@ BInputServerFilter::~BInputServerFilter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::InitCheck()
|
* Method: BInputServerFilter::InitCheck()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -37,7 +65,7 @@ BInputServerFilter::InitCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::Filter()
|
* Method: BInputServerFilter::Filter()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +79,7 @@ BInputServerFilter::Filter(BMessage *message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::GetScreenRegion()
|
* Method: BInputServerFilter::GetScreenRegion()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -64,7 +92,7 @@ BInputServerFilter::GetScreenRegion(BRegion *region) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::_ReservedInputServerFilter1()
|
* Method: BInputServerFilter::_ReservedInputServerFilter1()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +102,7 @@ BInputServerFilter::_ReservedInputServerFilter1()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::_ReservedInputServerFilter2()
|
* Method: BInputServerFilter::_ReservedInputServerFilter2()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +112,7 @@ BInputServerFilter::_ReservedInputServerFilter2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::_ReservedInputServerFilter3()
|
* Method: BInputServerFilter::_ReservedInputServerFilter3()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -94,7 +122,7 @@ BInputServerFilter::_ReservedInputServerFilter3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerFilter::_ReservedInputServerFilter4()
|
* Method: BInputServerFilter::_ReservedInputServerFilter4()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: InputServerFilter.h
|
||||||
|
/
|
||||||
|
/ Description: Add-on class for input_server filters.
|
||||||
|
/
|
||||||
|
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _INPUTSERVERFILTER_H
|
||||||
|
#define _INPUTSERVERFILTER_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <MessageFilter.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BInputServerFilter {
|
||||||
|
public:
|
||||||
|
BInputServerFilter();
|
||||||
|
virtual ~BInputServerFilter();
|
||||||
|
|
||||||
|
virtual status_t InitCheck();
|
||||||
|
|
||||||
|
virtual filter_result Filter(BMessage *message, BList *outList);
|
||||||
|
|
||||||
|
status_t GetScreenRegion(BRegion *region) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void _ReservedInputServerFilter1();
|
||||||
|
virtual void _ReservedInputServerFilter2();
|
||||||
|
virtual void _ReservedInputServerFilter3();
|
||||||
|
virtual void _ReservedInputServerFilter4();
|
||||||
|
uint32 _reserved[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Class to encapsulate entries in the InputServer's InputServerFilter list.
|
||||||
|
//
|
||||||
|
class InputServerFilterListEntry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline const char* getPath() { return mPath; };
|
||||||
|
inline status_t getStatus() { return mStatus; };
|
||||||
|
inline const BInputServerFilter* getInputServerFilter() { return mIsd; };
|
||||||
|
|
||||||
|
InputServerFilterListEntry(
|
||||||
|
const char* path,
|
||||||
|
status_t status,
|
||||||
|
const BInputServerFilter* isd) : mPath (path),
|
||||||
|
mStatus(status),
|
||||||
|
mIsd (isd)
|
||||||
|
{ /* Do nothing */ };
|
||||||
|
|
||||||
|
~InputServerFilterListEntry()
|
||||||
|
{ /* Do nothing */ };
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* mPath;
|
||||||
|
status_t mStatus;
|
||||||
|
const BInputServerFilter* mIsd;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -1,13 +1,41 @@
|
|||||||
/***********************************************************************
|
/*****************************************************************************/
|
||||||
* AUTHOR: nobody <baron>
|
// OpenBeOS InputServer
|
||||||
* FILE: InputServerMethod.cpp
|
//
|
||||||
* DATE: Sun Dec 16 15:57:43 2001
|
// Version: [0.0.5] [Development Stage]
|
||||||
* DESCR:
|
//
|
||||||
***********************************************************************/
|
// [Description]
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// This application and all source files used in its construction, except
|
||||||
|
// where noted, are licensed under the MIT License, and have been written
|
||||||
|
// and are:
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "InputServerMethod.h"
|
#include "InputServerMethod.h"
|
||||||
#include "Messenger.h"
|
#include "Messenger.h"
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::BInputServerMethod()
|
* Method: BInputServerMethod::BInputServerMethod()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +45,7 @@ BInputServerMethod::BInputServerMethod(const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::~BInputServerMethod()
|
* Method: BInputServerMethod::~BInputServerMethod()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +54,7 @@ BInputServerMethod::~BInputServerMethod()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::MethodActivated()
|
* Method: BInputServerMethod::MethodActivated()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -39,7 +67,7 @@ BInputServerMethod::MethodActivated(bool active)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::EnqueueMessage()
|
* Method: BInputServerMethod::EnqueueMessage()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +80,7 @@ BInputServerMethod::EnqueueMessage(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::SetName()
|
* Method: BInputServerMethod::SetName()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +93,7 @@ BInputServerMethod::SetName(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::SetIcon()
|
* Method: BInputServerMethod::SetIcon()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +106,7 @@ BInputServerMethod::SetIcon(const uchar *icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::SetMenu()
|
* Method: BInputServerMethod::SetMenu()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +120,7 @@ BInputServerMethod::SetMenu(const BMenu *menu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::_ReservedInputServerMethod1()
|
* Method: BInputServerMethod::_ReservedInputServerMethod1()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +130,7 @@ BInputServerMethod::_ReservedInputServerMethod1()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::_ReservedInputServerMethod2()
|
* Method: BInputServerMethod::_ReservedInputServerMethod2()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -112,7 +140,7 @@ BInputServerMethod::_ReservedInputServerMethod2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::_ReservedInputServerMethod3()
|
* Method: BInputServerMethod::_ReservedInputServerMethod3()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
@@ -122,7 +150,7 @@ BInputServerMethod::_ReservedInputServerMethod3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Method: BInputServerMethod::_ReservedInputServerMethod4()
|
* Method: BInputServerMethod::_ReservedInputServerMethod4()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: InputServerMethod.h
|
||||||
|
/
|
||||||
|
/ Description: Add-on class for input_server methods.
|
||||||
|
/
|
||||||
|
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||||
|
/
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _INPUTSERVERMETHOD_H
|
||||||
|
#define _INPUTSERVERMETHOD_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <InputServerFilter.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
class _BMethodAddOn_;
|
||||||
|
|
||||||
|
|
||||||
|
class BInputServerMethod : public BInputServerFilter {
|
||||||
|
public:
|
||||||
|
BInputServerMethod(const char *name,
|
||||||
|
const uchar *icon);
|
||||||
|
virtual ~BInputServerMethod();
|
||||||
|
|
||||||
|
virtual status_t MethodActivated(bool active);
|
||||||
|
|
||||||
|
status_t EnqueueMessage(BMessage *message);
|
||||||
|
|
||||||
|
status_t SetName(const char *name);
|
||||||
|
status_t SetIcon(const uchar *icon);
|
||||||
|
status_t SetMenu(const BMenu *menu, const BMessenger target);
|
||||||
|
|
||||||
|
private:
|
||||||
|
_BMethodAddOn_* fOwner;
|
||||||
|
|
||||||
|
virtual void _ReservedInputServerMethod1();
|
||||||
|
virtual void _ReservedInputServerMethod2();
|
||||||
|
virtual void _ReservedInputServerMethod3();
|
||||||
|
virtual void _ReservedInputServerMethod4();
|
||||||
|
uint32 _reserved[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Class to encapsulate entries in the InputServer's InputServerMethod list.
|
||||||
|
//
|
||||||
|
class InputServerMethodListEntry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline const char* getPath() { return mPath; };
|
||||||
|
inline status_t getStatus() { return mStatus; };
|
||||||
|
inline const BInputServerMethod* getInputServerMethod() { return mIsm; };
|
||||||
|
|
||||||
|
InputServerMethodListEntry(
|
||||||
|
const char* path,
|
||||||
|
status_t status,
|
||||||
|
const BInputServerMethod* ism) : mPath (path),
|
||||||
|
mStatus(status),
|
||||||
|
mIsm (ism)
|
||||||
|
{ /* Do nothing */ };
|
||||||
|
|
||||||
|
~InputServerMethodListEntry()
|
||||||
|
{ /* Do nothing */ };
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* mPath;
|
||||||
|
status_t mStatus;
|
||||||
|
const BInputServerMethod* mIsm;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -0,0 +1,440 @@
|
|||||||
|
/*
|
||||||
|
PortLink.cpp:
|
||||||
|
A helper class for port-based messaging
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
How it works:
|
||||||
|
The class utilizes a fixed-size array of PortLinkData object pointers. When
|
||||||
|
data is attached, a new PortLinkData object is allocated and a copy of the
|
||||||
|
passed data is created inside it. When the time comes for the message to be sent,
|
||||||
|
the data is pieced together into a flattened array and written to the port.
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
Data members:
|
||||||
|
|
||||||
|
*attachments[] - fixed-size array of pointers used to hold the attached data
|
||||||
|
opcode - message value which is sent along with any data
|
||||||
|
target - port to which the message is sent when Flush() is called
|
||||||
|
replyport - port used with synchronous messaging - FlushWithReply()
|
||||||
|
bufferlength - total bytes taken up by attachments
|
||||||
|
num_attachments - internal variable which is used to track which "slot"
|
||||||
|
will be the next one to receive an attachment object
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PortLink.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#ifdef OPENBEOS
|
||||||
|
namespace OpenBeOS {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define PLDEBUG
|
||||||
|
|
||||||
|
// Internal data storage class for holding attached data whilst it is waiting
|
||||||
|
// to be Flattened() and then Flushed(). There is no need for this to be called outside
|
||||||
|
// the PortLink class.
|
||||||
|
class PortLinkData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PortLinkData(void);
|
||||||
|
~PortLinkData(void);
|
||||||
|
bool Set(void *data, size_t size);
|
||||||
|
char *buffer;
|
||||||
|
size_t buffersize;
|
||||||
|
};
|
||||||
|
|
||||||
|
PortLink::PortLink(port_id port)
|
||||||
|
{
|
||||||
|
// For this class to be useful (and to prevent a lot of init problems)
|
||||||
|
// we require a port in the constructor
|
||||||
|
target=port;
|
||||||
|
|
||||||
|
// We start out without any data attached to the port message
|
||||||
|
num_attachments=0;
|
||||||
|
opcode=0;
|
||||||
|
bufferlength=0;
|
||||||
|
replyport=create_port(30,"PortLink reply port");
|
||||||
|
}
|
||||||
|
|
||||||
|
PortLink::~PortLink(void)
|
||||||
|
{
|
||||||
|
// If, for some odd reason, this is deleted with something attached,
|
||||||
|
// free the memory used by the attachments. We do not flush the queue
|
||||||
|
// because the port may no longer be valid in cases such as the app
|
||||||
|
// is in the process of quitting
|
||||||
|
MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::SetOpCode(int32 code)
|
||||||
|
{
|
||||||
|
// Sets the message code. This does not change once the message is sent.
|
||||||
|
// Another call to SetOpCode() is required for such things.
|
||||||
|
opcode=code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::SetPort(port_id port)
|
||||||
|
{
|
||||||
|
// Sets the target port. While not necessary in most uses, this exists
|
||||||
|
// mostly to prevent flexibility problems
|
||||||
|
target=port;
|
||||||
|
}
|
||||||
|
|
||||||
|
port_id PortLink::GetPort(void)
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Flush(void)
|
||||||
|
{
|
||||||
|
// Fires a message off to the target, complete with attachments. NOTE:
|
||||||
|
// the recipient must delete all attachments, being the PortLink object assumes
|
||||||
|
// no responsiblity for the attachments once the message is sent.
|
||||||
|
int8 *msgbuffer;
|
||||||
|
int32 size;
|
||||||
|
|
||||||
|
if(num_attachments>0)
|
||||||
|
{
|
||||||
|
FlattenData(&msgbuffer,&size);
|
||||||
|
// Dump message to port, reset attachments, and clean up
|
||||||
|
write_port(target,opcode,msgbuffer,size);
|
||||||
|
MakeEmpty();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
write_port(target,opcode,NULL,0);
|
||||||
|
|
||||||
|
// if(size>0)
|
||||||
|
// delete msgbuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT)
|
||||||
|
{
|
||||||
|
// Fires a message to the target and then waits for a reply. The target will
|
||||||
|
// receive a message with the first item being the port_id to reply to.
|
||||||
|
// NOTE: like Flush(), any attached data must be deleted.
|
||||||
|
|
||||||
|
// Effectively, an Attach() call inlined for changes
|
||||||
|
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
{
|
||||||
|
*status=B_ERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&replyport,sizeof(port_id)))
|
||||||
|
{
|
||||||
|
bufferlength+=sizeof(port_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
*status=B_ERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flatten() inlined to make some necessary changes
|
||||||
|
int8 *buffer=new int8[bufferlength];
|
||||||
|
int8 *bufferindex=buffer;
|
||||||
|
size_t size=0;
|
||||||
|
|
||||||
|
// attach our port_id first
|
||||||
|
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||||
|
bufferindex += pld->buffersize;
|
||||||
|
size+=pld->buffersize;
|
||||||
|
|
||||||
|
// attach everything else
|
||||||
|
for(int i=0;i<num_attachments;i++)
|
||||||
|
{
|
||||||
|
pld=attachments[i];
|
||||||
|
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||||
|
bufferindex += pld->buffersize;
|
||||||
|
size+=pld->buffersize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush the thing....FOOSH! :P
|
||||||
|
write_port(target,opcode,buffer,size);
|
||||||
|
MakeEmpty();
|
||||||
|
delete buffer;
|
||||||
|
|
||||||
|
// Now we wait for the reply
|
||||||
|
if(timeout==B_INFINITE_TIMEOUT)
|
||||||
|
{
|
||||||
|
*buffersize=port_buffer_size(replyport);
|
||||||
|
if(*buffersize>0)
|
||||||
|
buffer=(int8*)new int8[*buffersize];
|
||||||
|
read_port(replyport,code, buffer, *buffersize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*buffersize=port_buffer_size_etc(replyport,0,timeout);
|
||||||
|
if(*buffersize==B_TIMED_OUT)
|
||||||
|
{
|
||||||
|
*status=*buffersize;
|
||||||
|
return NULL;
|
||||||
|
//return *buffersize;
|
||||||
|
}
|
||||||
|
if(*buffersize>0)
|
||||||
|
buffer=(int8*)new int8[*buffersize];
|
||||||
|
read_port(replyport,code, buffer, *buffersize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We got this far, so we apparently have some data
|
||||||
|
*status=B_OK;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(void *data, size_t size)
|
||||||
|
{
|
||||||
|
// This is the member called to attach data to a message. Attachments are
|
||||||
|
// treated to be in 'Append' mode, tacking on each attached piece of data
|
||||||
|
// to the end of the list.
|
||||||
|
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(size==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// These functions were added for a major convenience in passing common types
|
||||||
|
// Eventually, I'd like to templatize these, but for now, this'll do
|
||||||
|
|
||||||
|
void PortLink::Attach(int32 data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(int32);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(int16 data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(int16);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(int8 data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(int8);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(float data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(float);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(bool data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(bool);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(BRect data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(BRect);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::Attach(BPoint data)
|
||||||
|
{
|
||||||
|
// Prevent parameter problems
|
||||||
|
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 size=sizeof(BPoint);
|
||||||
|
|
||||||
|
// create a new storage object and stash the data
|
||||||
|
PortLinkData *pld=new PortLinkData;
|
||||||
|
if(pld->Set(&data,size))
|
||||||
|
{
|
||||||
|
num_attachments++;
|
||||||
|
attachments[num_attachments-1]=pld;
|
||||||
|
bufferlength+=size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::FlattenData(int8 **buffer,int32 *size)
|
||||||
|
{
|
||||||
|
// This function is where all the magic happens, but it is strictly internal.
|
||||||
|
// It iterates through each PortLinkData object and copies it to the main buffer
|
||||||
|
// which ends up, ultimately, being written to the PortLink's target port.
|
||||||
|
|
||||||
|
// skip if there aree no attachments
|
||||||
|
if(bufferlength<1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*buffer=new int8[bufferlength];
|
||||||
|
int8 *bufferindex=*buffer;
|
||||||
|
PortLinkData *pld;
|
||||||
|
*size=0;
|
||||||
|
|
||||||
|
for(int i=0;i<num_attachments;i++)
|
||||||
|
{
|
||||||
|
pld=attachments[i];
|
||||||
|
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||||
|
bufferindex += pld->buffersize;
|
||||||
|
*size+=pld->buffersize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortLink::MakeEmpty(void)
|
||||||
|
{
|
||||||
|
// Nukes all the attachments currently held by the PortLink class
|
||||||
|
if(num_attachments!=0)
|
||||||
|
{
|
||||||
|
for(int i=0; i<num_attachments; i++)
|
||||||
|
{
|
||||||
|
delete attachments[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num_attachments=0;
|
||||||
|
bufferlength=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortLinkData::PortLinkData(void)
|
||||||
|
{
|
||||||
|
// Initialize object to empty
|
||||||
|
buffersize=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortLinkData::~PortLinkData(void)
|
||||||
|
{
|
||||||
|
// Frees the buffer if we actually used the class to store data
|
||||||
|
if(buffersize>0)
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PortLinkData::Set(void *data, size_t size)
|
||||||
|
{
|
||||||
|
// Function copies the passed to the internal buffers for storage
|
||||||
|
if(size>0 && buffersize==0 && data!=NULL)
|
||||||
|
{
|
||||||
|
buffer=(char *)malloc(size);
|
||||||
|
if(buffer==NULL)
|
||||||
|
return false;
|
||||||
|
memcpy(buffer, data, size);
|
||||||
|
buffersize=size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OPENBEOS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef _PORTLINK_H_
|
||||||
|
#define _PORTLINK_H_
|
||||||
|
|
||||||
|
#include <Errors.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
|
||||||
|
#ifndef _PORTLINK_BUFFERSIZE
|
||||||
|
#define _PORTLINK_MAX_ATTACHMENTS 50
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPENBEOS
|
||||||
|
namespace OpenBeOS {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class PortLinkData;
|
||||||
|
|
||||||
|
class PortLink
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PortLink(port_id port);
|
||||||
|
~PortLink(void);
|
||||||
|
void SetOpCode(int32 code);
|
||||||
|
void SetPort(port_id port);
|
||||||
|
port_id GetPort(void);
|
||||||
|
void Flush(void);
|
||||||
|
int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize,
|
||||||
|
bigtime_t timeout=B_INFINITE_TIMEOUT);
|
||||||
|
void Attach(void *data, size_t size);
|
||||||
|
void Attach(int32 data);
|
||||||
|
void Attach(int16 data);
|
||||||
|
void Attach(int8 data);
|
||||||
|
void Attach(float data);
|
||||||
|
void Attach(bool data);
|
||||||
|
void Attach(BRect data);
|
||||||
|
void Attach(BPoint data);
|
||||||
|
void MakeEmpty(void);
|
||||||
|
protected:
|
||||||
|
void FlattenData(int8 **buffer,int32 *size);
|
||||||
|
port_id target, replyport;
|
||||||
|
int32 opcode, bufferlength;
|
||||||
|
int num_attachments;
|
||||||
|
PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS];
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef OPENBEOS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
#ifndef _APPSERVER_PROTOCOL_
|
||||||
|
#define _APPSERVER_PROTOCOL_
|
||||||
|
|
||||||
|
#define CREATE_APP 'drca'
|
||||||
|
#define DELETE_APP 'drda'
|
||||||
|
#define QUIT_APP 'srqa'
|
||||||
|
|
||||||
|
#define SET_SERVER_PORT 'srsp'
|
||||||
|
|
||||||
|
#define CREATE_WINDOW 'drcw'
|
||||||
|
#define DELETE_WINDOW 'drdw'
|
||||||
|
#define SHOW_WINDOW 'drsw'
|
||||||
|
#define HIDE_WINDOW 'drhw'
|
||||||
|
#define QUIT_WINDOW 'srqw'
|
||||||
|
|
||||||
|
#define SERVER_PORT_NAME "OBappserver"
|
||||||
|
#define SERVER_INPUT_PORT "OBinputport"
|
||||||
|
|
||||||
|
#define SET_CURSOR_DATA 'sscd'
|
||||||
|
#define SET_CURSOR_BCURSOR 'sscb'
|
||||||
|
#define SET_CURSOR_BBITMAP 'sscB'
|
||||||
|
#define SHOW_CURSOR 'srsc'
|
||||||
|
#define HIDE_CURSOR 'srhc'
|
||||||
|
#define OBSCURE_CURSOR 'sroc'
|
||||||
|
|
||||||
|
#define GFX_COUNT_WORKSPACES 'gcws'
|
||||||
|
#define GFX_SET_WORKSPACE_COUNT 'ggwc'
|
||||||
|
#define GFX_CURRENT_WORKSPACE 'ggcw'
|
||||||
|
#define GFX_ACTIVATE_WORKSPACE 'gaws'
|
||||||
|
#define GFX_GET_SYSTEM_COLORS 'gsyc'
|
||||||
|
#define GFX_SET_SYSTEM_COLORS 'gsyc'
|
||||||
|
#define GFX_SET_SCREEN_MODE 'gssm'
|
||||||
|
#define GFX_GET_SCROLLBAR_INFO 'ggsi'
|
||||||
|
#define GFX_SET_SCROLLBAR_INFO 'gssi'
|
||||||
|
#define GFX_IDLE_TIME 'gidt'
|
||||||
|
#define GFX_SELECT_PRINTER_PANEL 'gspp'
|
||||||
|
#define GFX_ADD_PRINTER_PANEL 'gapp'
|
||||||
|
#define GFX_RUN_BE_ABOUT 'grba'
|
||||||
|
#define GFX_SET_FOCUS_FOLLOWS_MOUSE 'gsfm'
|
||||||
|
#define GFX_FOCUS_FOLLOWS_MOUSE 'gffm'
|
||||||
|
|
||||||
|
#define GFX_SET_HIGH_COLOR 'gshc'
|
||||||
|
#define GFX_SET_LOW_COLOR 'gslc'
|
||||||
|
#define GFX_SET_VIEW_COLOR 'gsvc'
|
||||||
|
|
||||||
|
#define GFX_STROKE_ARC 'gsar'
|
||||||
|
#define GFX_STROKE_BEZIER 'gsbz'
|
||||||
|
#define GFX_STROKE_ELLIPSE 'gsel'
|
||||||
|
#define GFX_STROKE_LINE 'gsln'
|
||||||
|
#define GFX_STROKE_POLYGON 'gspy'
|
||||||
|
#define GFX_STROKE_RECT 'gsrc'
|
||||||
|
#define GFX_STROKE_ROUNDRECT 'gsrr'
|
||||||
|
#define GFX_STROKE_SHAPE 'gssh'
|
||||||
|
#define GFX_STROKE_TRIANGLE 'gstr'
|
||||||
|
|
||||||
|
#define GFX_FILL_ARC 'gfar'
|
||||||
|
#define GFX_FILL_BEZIER 'gfbz'
|
||||||
|
#define GFX_FILL_ELLIPSE 'gfel'
|
||||||
|
#define GFX_FILL_POLYGON 'gfpy'
|
||||||
|
#define GFX_FILL_RECT 'gfrc'
|
||||||
|
#define GFX_FILL_REGION 'gfrg'
|
||||||
|
#define GFX_FILL_ROUNDRECT 'gfrr'
|
||||||
|
#define GFX_FILL_SHAPE 'gfsh'
|
||||||
|
#define GFX_FILL_TRIANGLE 'gftr'
|
||||||
|
|
||||||
|
#define GFX_MOVEPENBY 'gmpb'
|
||||||
|
#define GFX_MOVEPENTO 'gmpt'
|
||||||
|
#define GFX_SETPENSIZE 'gsps'
|
||||||
|
|
||||||
|
#define GFX_DRAW_STRING 'gdst'
|
||||||
|
#define GFX_SET_FONT 'gsft'
|
||||||
|
#define GFX_SET_FONT_SIZE 'gsfs'
|
||||||
|
|
||||||
|
#define GFX_FLUSH 'gfsh'
|
||||||
|
#define GFX_SYNC 'gsyn'
|
||||||
|
|
||||||
|
#define LAYER_CREATE 'lycr'
|
||||||
|
#define LAYER_DELETE 'lydl'
|
||||||
|
#define LAYER_ADD_CHILD 'lyac'
|
||||||
|
#define LAYER_REMOVE_CHILD 'lyrc'
|
||||||
|
#define LAYER_REMOVE_SELF 'lyrs'
|
||||||
|
#define LAYER_SHOW 'lysh'
|
||||||
|
#define LAYER_HIDE 'lyhd'
|
||||||
|
#define LAYER_MOVE 'lymv'
|
||||||
|
#define LAYER_RESIZE 'lyre'
|
||||||
|
#define LAYER_INVALIDATE 'lyin'
|
||||||
|
#define LAYER_DRAW 'lydr'
|
||||||
|
|
||||||
|
#define BEGIN_RECT_TRACKING 'rtbg'
|
||||||
|
#define END_RECT_TRACKING 'rten'
|
||||||
|
|
||||||
|
#define VIEW_GET_TOKEN 'vgtk'
|
||||||
|
#define VIEW_ADD 'vadd'
|
||||||
|
#define VIEW_REMOVE 'vrem'
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user