Misc style changes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14575 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+286
-301
@@ -1,301 +1,286 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in
|
// The above copyright notice and this permission notice shall be included in
|
||||||
// all copies or substantial portions of the Software.
|
// all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
// File Name: Input.cpp
|
// File Name: Input.cpp
|
||||||
// Author: Marc Flerackers ([email protected])
|
// Author: Marc Flerackers ([email protected])
|
||||||
// Description: Functions and class to manage input devices.
|
// Description: Functions and class to manage input devices.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
#include <stdlib.h>
|
||||||
// Standard Includes -----------------------------------------------------------
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <Input.h>
|
||||||
|
#include <List.h>
|
||||||
// System Includes -------------------------------------------------------------
|
#include <Message.h>
|
||||||
#include <Input.h>
|
|
||||||
#include <Message.h>
|
#include <input_globals.h>
|
||||||
#include <Errors.h>
|
#include <InputServerTypes.h>
|
||||||
#include <List.h>
|
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
static BMessenger *sInputServer = NULL;
|
||||||
#include "InputServerTypes.h"
|
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
BInputDevice *
|
||||||
|
find_input_device(const char *name)
|
||||||
// Local Defines ---------------------------------------------------------------
|
{
|
||||||
|
BMessage command(IS_FIND_DEVICES);
|
||||||
// Globals ---------------------------------------------------------------------
|
BMessage reply;
|
||||||
|
|
||||||
BMessenger *input_server=NULL;
|
command.AddString("device", name);
|
||||||
|
|
||||||
_IMPEXP_BE status_t _control_input_server_(BMessage *command, BMessage *reply);
|
status_t err = _control_input_server_(&command, &reply);
|
||||||
|
|
||||||
/*static bool PrintNameAndDelete(void *ptr)
|
if (err != B_OK)
|
||||||
{
|
return NULL;
|
||||||
if(ptr)
|
|
||||||
{
|
BInputDevice *dev = new BInputDevice;
|
||||||
BInputDevice *dev = (BInputDevice *)ptr;
|
|
||||||
printf("* %s : %s\n", dev->Name(), dev->IsRunning() ? "running" : "not running");
|
const char *device;
|
||||||
delete dev;
|
int32 type;
|
||||||
return false;
|
|
||||||
}
|
reply.FindString("device", &device);
|
||||||
|
reply.FindInt32("type", &type);
|
||||||
return true;
|
|
||||||
}
|
dev->set_name_and_type(device, (input_device_type)type);
|
||||||
|
|
||||||
void PrintDevices()
|
return dev;
|
||||||
{
|
}
|
||||||
BList devices;
|
|
||||||
|
|
||||||
status_t err = get_input_devices(&devices);
|
status_t
|
||||||
|
get_input_devices(BList *list)
|
||||||
if(err != B_OK)
|
{
|
||||||
printf("Error while getting input devices\n");
|
list->MakeEmpty();
|
||||||
else
|
|
||||||
{
|
BMessage command(IS_FIND_DEVICES);
|
||||||
devices.DoForEach(PrintNameAndDelete);
|
BMessage reply;
|
||||||
devices.MakeEmpty();
|
|
||||||
}
|
status_t err = _control_input_server_(&command, &reply);
|
||||||
}*/
|
|
||||||
|
if (err != B_OK)
|
||||||
//------------------------------------------------------------------------------
|
return err;
|
||||||
BInputDevice *find_input_device(const char *name)
|
|
||||||
{
|
const char *name;
|
||||||
BMessage command(IS_FIND_DEVICES);
|
int32 type;
|
||||||
BMessage reply;
|
int32 i = 0;
|
||||||
|
|
||||||
command.AddString("device", name);
|
while (reply.FindString("device", i, &name) == B_OK) {
|
||||||
|
reply.FindInt32("type", i++, &type);
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
|
||||||
|
BInputDevice *dev = new BInputDevice;
|
||||||
if (err != B_OK)
|
|
||||||
return NULL;
|
dev->set_name_and_type(name, (input_device_type)type);
|
||||||
|
|
||||||
BInputDevice *dev = new BInputDevice;
|
list->AddItem(dev);
|
||||||
|
}
|
||||||
const char *device;
|
|
||||||
int32 type;
|
return err;
|
||||||
|
}
|
||||||
reply.FindString("device", &device);
|
|
||||||
reply.FindInt32("type", &type);
|
|
||||||
|
status_t
|
||||||
dev->set_name_and_type(device, (input_device_type)type);
|
watch_input_devices(BMessenger target, bool start)
|
||||||
|
{
|
||||||
return dev;
|
BMessage command(IS_WATCH_DEVICES);
|
||||||
}
|
BMessage reply;
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t get_input_devices(BList *list)
|
command.AddMessenger("target", target);
|
||||||
{
|
command.AddBool("start", start);
|
||||||
list->MakeEmpty();
|
|
||||||
|
return _control_input_server_(&command, &reply);
|
||||||
BMessage command(IS_FIND_DEVICES);
|
}
|
||||||
BMessage reply;
|
|
||||||
|
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
BInputDevice::~BInputDevice()
|
||||||
|
{
|
||||||
if (err != B_OK)
|
free(fName);
|
||||||
return err;
|
}
|
||||||
|
|
||||||
const char *name;
|
|
||||||
int32 type;
|
const char *
|
||||||
int32 i = 0;
|
BInputDevice::Name() const
|
||||||
|
{
|
||||||
while (reply.FindString("device", i, &name) == B_OK)
|
return fName;
|
||||||
{
|
}
|
||||||
reply.FindInt32("type", i++, &type);
|
|
||||||
|
|
||||||
BInputDevice *dev = new BInputDevice;
|
input_device_type
|
||||||
|
BInputDevice::Type() const
|
||||||
dev->set_name_and_type(name, (input_device_type)type);
|
{
|
||||||
|
return fType;
|
||||||
list->AddItem(dev);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
bool
|
||||||
}
|
BInputDevice::IsRunning() const
|
||||||
//------------------------------------------------------------------------------
|
{
|
||||||
status_t watch_input_devices(BMessenger target, bool start)
|
if (!fName)
|
||||||
{
|
return false;
|
||||||
BMessage command(IS_WATCH_DEVICES);
|
|
||||||
BMessage reply;
|
BMessage command(IS_IS_DEVICE_RUNNING);
|
||||||
|
BMessage reply;
|
||||||
command.AddMessenger("target", target);
|
|
||||||
command.AddBool("start", start);
|
command.AddString("device", fName);
|
||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply) == B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
BInputDevice::~BInputDevice()
|
|
||||||
{
|
status_t
|
||||||
if (fName)
|
BInputDevice::Start()
|
||||||
free (fName);
|
{
|
||||||
}
|
if (!fName)
|
||||||
//------------------------------------------------------------------------------
|
return B_ERROR;
|
||||||
const char *BInputDevice::Name() const
|
|
||||||
{
|
BMessage command(IS_START_DEVICE);
|
||||||
return fName;
|
BMessage reply;
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
command.AddString("device", fName);
|
||||||
input_device_type BInputDevice::Type() const
|
|
||||||
{
|
return _control_input_server_(&command, &reply);
|
||||||
return fType;
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool BInputDevice::IsRunning() const
|
status_t
|
||||||
{
|
BInputDevice::Stop()
|
||||||
if (!fName)
|
{
|
||||||
return false;
|
if (!fName)
|
||||||
|
return B_ERROR;
|
||||||
BMessage command(IS_IS_DEVICE_RUNNING);
|
|
||||||
BMessage reply;
|
BMessage command(IS_STOP_DEVICE);
|
||||||
|
BMessage reply;
|
||||||
command.AddString("device", fName);
|
|
||||||
|
command.AddString("device", fName);
|
||||||
return _control_input_server_(&command, &reply) == B_OK;
|
|
||||||
}
|
return _control_input_server_(&command, &reply);
|
||||||
//------------------------------------------------------------------------------
|
}
|
||||||
status_t BInputDevice::Start()
|
|
||||||
{
|
|
||||||
if (!fName)
|
status_t
|
||||||
return B_ERROR;
|
BInputDevice::Control(uint32 code, BMessage *message)
|
||||||
|
{
|
||||||
BMessage command(IS_START_DEVICE);
|
if (!fName)
|
||||||
BMessage reply;
|
return B_ERROR;
|
||||||
|
|
||||||
command.AddString("device", fName);
|
BMessage command(IS_CONTROL_DEVICES);
|
||||||
|
BMessage reply;
|
||||||
return _control_input_server_(&command, &reply);
|
|
||||||
}
|
command.AddString("device", fName);
|
||||||
//------------------------------------------------------------------------------
|
command.AddInt32("code", code);
|
||||||
status_t BInputDevice::Stop()
|
command.AddMessage("message", message);
|
||||||
{
|
|
||||||
if (!fName)
|
message->MakeEmpty();
|
||||||
return B_ERROR;
|
|
||||||
|
status_t err = _control_input_server_(&command, &reply);
|
||||||
BMessage command(IS_STOP_DEVICE);
|
|
||||||
BMessage reply;
|
if (err == B_OK)
|
||||||
|
reply.FindMessage("message", message);
|
||||||
command.AddString("device", fName);
|
|
||||||
|
return err;
|
||||||
return _control_input_server_(&command, &reply);
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Control(uint32 code, BMessage *message)
|
status_t
|
||||||
{
|
BInputDevice::Start(input_device_type type)
|
||||||
if (!fName)
|
{
|
||||||
return B_ERROR;
|
BMessage command(IS_START_DEVICE);
|
||||||
|
BMessage reply;
|
||||||
BMessage command(IS_CONTROL_DEVICES);
|
|
||||||
BMessage reply;
|
command.AddInt32("type", type);
|
||||||
|
|
||||||
command.AddString("device", fName);
|
return _control_input_server_(&command, &reply);
|
||||||
command.AddInt32("code", code);
|
}
|
||||||
command.AddMessage("message", message);
|
|
||||||
|
|
||||||
message->MakeEmpty();
|
status_t
|
||||||
|
BInputDevice::Stop(input_device_type type)
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
{
|
||||||
|
BMessage command(IS_STOP_DEVICE);
|
||||||
if (err == B_OK)
|
BMessage reply;
|
||||||
reply.FindMessage("message", message);
|
|
||||||
|
command.AddInt32("type", type);
|
||||||
return err;
|
|
||||||
}
|
return _control_input_server_(&command, &reply);
|
||||||
//------------------------------------------------------------------------------
|
}
|
||||||
status_t BInputDevice::Start(input_device_type type)
|
|
||||||
{
|
|
||||||
BMessage command(IS_START_DEVICE);
|
status_t
|
||||||
BMessage reply;
|
BInputDevice::Control(input_device_type type, uint32 code,
|
||||||
|
BMessage *message)
|
||||||
command.AddInt32("type", type);
|
{
|
||||||
|
BMessage command(IS_CONTROL_DEVICES);
|
||||||
return _control_input_server_(&command, &reply);
|
BMessage reply;
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
command.AddInt32("type", type);
|
||||||
status_t BInputDevice::Stop(input_device_type type)
|
command.AddInt32("code", code);
|
||||||
{
|
command.AddMessage("message", message);
|
||||||
BMessage command(IS_STOP_DEVICE);
|
|
||||||
BMessage reply;
|
message->MakeEmpty();
|
||||||
|
|
||||||
command.AddInt32("type", type);
|
status_t err = _control_input_server_(&command, &reply);
|
||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
if (err == B_OK)
|
||||||
}
|
reply.FindMessage("message", message);
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Control(input_device_type type, uint32 code,
|
return err;
|
||||||
BMessage *message)
|
}
|
||||||
{
|
|
||||||
BMessage command(IS_CONTROL_DEVICES);
|
|
||||||
BMessage reply;
|
BInputDevice::BInputDevice()
|
||||||
|
{
|
||||||
command.AddInt32("type", type);
|
fName = NULL;
|
||||||
command.AddInt32("code", code);
|
fType = B_UNDEFINED_DEVICE;
|
||||||
command.AddMessage("message", message);
|
}
|
||||||
|
|
||||||
message->MakeEmpty();
|
|
||||||
|
void
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
BInputDevice::set_name_and_type(const char *name, input_device_type type)
|
||||||
|
{
|
||||||
if (err == B_OK)
|
if (fName) {
|
||||||
reply.FindMessage("message", message);
|
free (fName);
|
||||||
|
fName = NULL;
|
||||||
return err;
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
if (name)
|
||||||
BInputDevice::BInputDevice()
|
fName = strdup(name);
|
||||||
{
|
|
||||||
fName = NULL;
|
fType = type;
|
||||||
fType = B_UNDEFINED_DEVICE;
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BInputDevice::set_name_and_type(const char *name, input_device_type type)
|
status_t
|
||||||
{
|
_control_input_server_(BMessage *command, BMessage *reply)
|
||||||
if (fName)
|
{
|
||||||
{
|
if (!sInputServer)
|
||||||
free (fName);
|
sInputServer = new BMessenger;
|
||||||
fName = NULL;
|
|
||||||
}
|
if (!sInputServer->IsValid())
|
||||||
|
*sInputServer = BMessenger("application/x-vnd.Be-input_server", -1, NULL);
|
||||||
if (name)
|
|
||||||
fName = strdup(name);
|
status_t err = sInputServer->SendMessage(command, reply);
|
||||||
|
|
||||||
fType = type;
|
if (err != B_OK)
|
||||||
}
|
return err;
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t _control_input_server_(BMessage *command, BMessage *reply)
|
if (reply->FindInt32("status", &err) != B_OK)
|
||||||
{
|
return B_ERROR;
|
||||||
if (!input_server)
|
|
||||||
input_server = new BMessenger;
|
return err;
|
||||||
|
}
|
||||||
if (!input_server->IsValid())
|
|
||||||
*input_server = BMessenger("application/x-vnd.Be-input_server", -1, NULL);
|
|
||||||
//*input_server = BMessenger("application/x-vnd.OBOS-input_server", -1, NULL);
|
|
||||||
|
|
||||||
status_t err = input_server->SendMessage(command, reply);
|
|
||||||
|
|
||||||
if (err != B_OK)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
if (reply->FindInt32("status", &err) != B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|||||||
@@ -3766,7 +3766,7 @@ BView::InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags
|
|||||||
fPermanentState = NULL;
|
fPermanentState = NULL;
|
||||||
fState = new BPrivate::ViewState;
|
fState = new BPrivate::ViewState;
|
||||||
|
|
||||||
fBounds = frame.OffsetToCopy(0.0, 0.0);
|
fBounds = frame.OffsetToCopy(B_ORIGIN);
|
||||||
fShelf = NULL;
|
fShelf = NULL;
|
||||||
pr_state = NULL;
|
pr_state = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
// BMallocIO and BMemoryIO classes implement the protocol,
|
// BMallocIO and BMemoryIO classes implement the protocol,
|
||||||
// as does BFile in the Storage Kit.
|
// as does BFile in the Storage Kit.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include <algorithm>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -251,17 +250,15 @@ BMemoryIO::Position() const
|
|||||||
status_t
|
status_t
|
||||||
BMemoryIO::SetSize(off_t size)
|
BMemoryIO::SetSize(off_t size)
|
||||||
{
|
{
|
||||||
status_t err = B_ERROR;
|
|
||||||
|
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
if (size <= fPhys) {
|
|
||||||
err = B_OK;
|
|
||||||
fLen = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
if (size > fPhys)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
fLen = size;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user