Skip to content

Instantly share code, notes, and snippets.

@tmzt
Created October 29, 2010 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmzt/fff94eb7a42334ef9646 to your computer and use it in GitHub Desktop.
Save tmzt/fff94eb7a42334ef9646 to your computer and use it in GitHub Desktop.
#include "../android.h"
#include <stdio.h>
#include <sys/socket.h>
#include <sys/stat.h>
static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
jint
JNI_OnLoad(JavaVM *jvm, void *reserved) {
Android = (AndroidVars *)calloc(sizeof(AndroidVars), 1);
Android->miEventQueueMutex = &miEventQueueMutex;
androidInitNative(jvm);
return JNI_VERSION_1_4;
}
void
Java_net_homeip_ofn_androix_AndroiXLib_init( JNIEnv* env, jobject thiz )
{
struct stat stats;
int mode = 0666;
char argv[] = {":1"};
char envp[] = {};
LOG("fixing up /data/data/net.homeip.ofn.androix/usr/bin/xkbcomp");
chmod("/data/data/net.homeip.ofn.androix/usr/bin/xkbcomp", 0775);
LOG("done.");
LOG("creating event wakeup socket pair");
socketpair(AF_UNIX, SOCK_STREAM, 0, Android->wakeupFD);
LOG("remote (Xorg) fd: %d", Android->wakeupFD[0]);
LOG("local (android) fd: %d", Android->wakeupFD[1]);
LOG("starting DIX");
dix_main(1, &argv, &envp);
LOG("returning from DIX (this shouldn't happen)");
}
void wakeupFD() {
int res;
char nullbyte=0;
// <daniels> oh, i ... er ... christ.
LOG("writing to wakeupFD");
res = write(Android->wakeupFD[1], &nullbyte, sizeof(nullbyte));
//res = write(Android->wakeupFD[1], "X", 1);
LOG("wrote %d bytes", res);
}
void
Java_net_homeip_ofn_androix_AndroiXLib_keyDown( JNIEnv* env, jobject thiz, jint kbd, jint keyCode )
{
LOG("keyDown: kbd: %p keyCode: %d", kbd, keyCode);
androidCallbackKeyDown((void *)kbd, keyCode);
wakeupFD();
}
void
Java_net_homeip_ofn_androix_AndroiXLib_keyUp( JNIEnv* env, jobject thiz, jint kbd, jint keyCode )
{
LOG("keyUp: kbd: %p keyCode: %d", (unsigned int)kbd, keyCode);
androidCallbackKeyUp((void *)kbd, keyCode);
wakeupFD();
}
void
Java_net_homeip_ofn_androix_AndroiXLib_touchDown( JNIEnv* env, jobject thiz, jint mouse, jint x, jint y )
{
LOG("touchDown: mouse: %p x: %d y: %d", mouse, x, y);
androidCallbackTouchDown((void *)mouse, x, y);
wakeupFD();
}
void
Java_net_homeip_ofn_androix_AndroiXLib_touchUp( JNIEnv* env, jobject thiz, jint mouse, jint x, jint y )
{
LOG("touchUp: mouse: %p x: %d y: %d", mouse, x, y);
androidCallbackTouchUp((void *)mouse, x, y);
wakeupFD();
}
package net.homeip.ofn.androix;
import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.view.*;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.Log;
import java.nio.*;
/* 2d version */
public class AndroiXBlitView extends View implements View.OnKeyListener, View.OnTouchListener {
private int mScreenPtr = 0;
private int mKeyboardPtr = 0;
private int mMousePtr = 0;
private Bitmap mBitmap = null;
private ByteBuffer mBuf = null;
private boolean mCreated = false;
private boolean mDrawing = false;
public AndroiXBlitView(Context context) {
super(context);
setOnKeyListener(this);
setOnTouchListener(this);
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
int W = 800;
int H = 480;
//mBitmap = Bitmap.createBitmap(W, H, Bitmap.Config.RGB_565);
}
public boolean getIsDrawing() { return mDrawing; }
public boolean getIsCreated() { return mCreated; }
public int initNativeScreen(int screen) {
mScreenPtr = screen; /* only on 32bit */
Log.d("AndroiX", "[blitView] initNativeScreen: screen: " + screen);
return 0;
}
public int initNativeKeyboard(int kbd) {
mKeyboardPtr = kbd; /* only on 32bit */
Log.d("AndroiX", "[blitView] initNativeKeyboard: kbd: " + kbd);
return 0;
}
public int initNativeMouse(int mouse) {
mMousePtr = mouse; /* only on 32bit */
Log.d("AndroiX", "[blitView] initNativeMouse: mouse: " + mouse);
return 0;
}
public int initFramebuffer(int width, int height, int depth, java.nio.ByteBuffer buf) {
Log.d("AndroiX", "Initialize Framebuffer: " + width + " x " + height + " depth: " + depth);
if (depth != 16) {
Log.d("AndroiX", "Bad depth: " + depth);
return -1;
}
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
AndroiX.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
AndroiX.getActivity().setContentView(AndroiXService.blitView);
AndroiXService.blitView.setOnKeyListener(AndroiXService.blitView);
AndroiXService.blitView.setOnTouchListener(AndroiXService.blitView);
AndroiXService.blitView.setFocusable(true);
AndroiXService.blitView.setFocusableInTouchMode(true);
AndroiXService.blitView.requestFocus();
AndroiXService.blitView.resume();
AndroiXService.blitView.invalidate();
}
});
// AndroiX.getActivity().setContentView(this);
mBuf = buf;
return 0;
}
public void draw(int x, int y, int w, int h) {
Log.d("AndroiX", "Draw from native: " + x + "," + y + "(" + w + " x " + h + ")");
if (!mDrawing) {
Log.d("AndroiX", "draw ignored while suspended");
return;
}
mBitmap.copyPixelsFromBuffer(mBuf);
postInvalidate();
}
public void suspend() {
mDrawing = false;
}
public void resume() {
mDrawing = true;
}
@Override protected void onDraw(Canvas canvas) {
// assume we're created
mCreated = true;
if (mBitmap == null) {
Log.d("AndroiX", "mBitmap not ready, did [native] run?");
postInvalidate(); // call us again
}
canvas.drawBitmap(mBitmap, 0, 0, null);
invalidate();
}
/* OnKeyListener */
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (mKeyboardPtr == 0) { Log.d("AndroiX", "keyboard not ready. kbd: " + mKeyboardPtr); return false; }
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
Log.d("AndroiX", "onKey: ACTION_DOWN keyCode: " + keyCode);
AndroiXService.lib.keyDown(mKeyboardPtr, keyCode);
return true;
case KeyEvent.ACTION_UP:
Log.d("AndroiX", "onKey: ACTION_UP keyCode: " + keyCode);
AndroiXService.lib.keyUp(mKeyboardPtr, keyCode);
return true;
/* not handling multiple keypresses yet */
};
return false;
}
/* OnTouchListener */
public boolean onTouch(View v, MotionEvent event) {
if (mMousePtr == 0) { Log.d("AndroiX", "mouse not ready. mouse: " + mMousePtr); return false; }
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("AndroiX", "onTouchEvent: ACTION_DOWN x: " + event.getX() + " y: " + event.getY());
AndroiXService.lib.touchDown(mMousePtr, (int)(event.getX()), (int)(event.getY()));
return true;
case MotionEvent.ACTION_UP:
Log.d("AndroiX", "onTouchEvent: ACTION_UP x: " + event.getX() + " y: " + event.getY());
AndroiXService.lib.touchUp(mMousePtr, (int)(event.getX()), (int)(event.getY()));
return true;
};
return false;
}
}
package net.homeip.ofn.androix;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.view.View;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.util.Log;
import java.io.*;
import java.util.*;
import java.util.zip.*;
public class AndroiXService extends Service {
public static AndroiXBlitView blitView;
private static AndroiXService instance;
protected static AndroiXLib lib;
public static AndroiXService getService() { return instance; }
@Override
public void onCreate()
{
/* create the 2d view */
blitView = new AndroiXBlitView(this);
/* extract resources */
try {
BufferedOutputStream os;
BufferedInputStream is;
ZipEntry entry;
File usrdata = new File("/data/data/net.homeip.ofn.androix/lib/libusrdata.so");
ZipFile zip = new ZipFile(usrdata);
Enumeration<? extends ZipEntry> e = zip.entries();
File folder;
while(e.hasMoreElements()) {
entry = (ZipEntry)e.nextElement();
Log.d("AndroiX", "extracting " + "/data/data/net.homeip.ofn.androix/" + entry.getName());
if (entry.isDirectory()) {
folder = new File("/data/data/net.homeip.ofn.androix/" + entry.getName());
Log.d("AndroiX", "creating directory: " + "/data/data/net.homeip.ofn.androix/" + entry.getName());
try { folder.mkdirs(); } catch (SecurityException ex) {Log.d("AndroiX", "Could not create directory: " + entry.getName()); ex.printStackTrace(); }
continue;
}
is = new BufferedInputStream(zip.getInputStream(entry), 1024);
FileOutputStream fos = new FileOutputStream("/data/data/net.homeip.ofn.androix/" + entry.getName());
folder = new File(new File("/data/data/net.homeip.ofn.androix/" + entry.getName()).getParent());
if (!folder.exists()) folder.mkdirs();
os = new BufferedOutputStream(fos, 1024);
byte buf[] = new byte[1024];
int n;
while ((n = is.read(buf, 0, 1024)) != -1) {
os.write(buf, 0, n);
};
os.flush();
os.close();
is.close();
};
} catch (Exception ex) { ex.printStackTrace(); Log.d("AndroiX", "failed to extract."); }
Log.d("AndroiX", "Done extracting /usr");
lib = new AndroiXLib();
Log.d("AndroiX", "Waiting for View");
try { while(AndroiXService.blitView == null) Thread.sleep(250); } catch (InterruptedException e) {};
// Log.d("AndroiX", "Waiting for mCreated");
// try { while(!AndroiXService.blitView.getIsCreated()) Thread.sleep(250); } catch (InterruptedException e) {};
Log.d("AndroiX", "Now starting the X server");
Thread mainthread = new Thread(lib, "AndroiX DIX Thread");
mainthread.setDaemon(true);
mainthread.start();
instance = this;
}
/* service should not restart when it dies */
/*
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
return START_STICKY;
}
*/
@Override
public IBinder onBind(Intent intent)
{
return null;
}
}
#include <jni.h>
#include <inputstr.h>
#include <mi.h>
#include "private.h"
CARD32 lastEventTime = 0;
EventList *androidEvents;
void androidCallbackKeyDown(void *kbdPtr, int keyCode) {
int i, n;
DeviceIntPtr kbd = kbdPtr;
LogMessage(X_DEFAULT, "[native] androidCallbackKeyDown: kbd: %.8x keyCode: %d", (unsigned int)kbd, keyCode);
GetEventList(&androidEvents);
//lastEventTime = GetTimeInMillis();
n = GetKeyboardEvents(androidEvents, kbd, KeyPress, keyCode);
LogMessage(X_DEFAULT, "[native] androidCallbackKeyDown: n: %d", n);
for (i = 0; i < n; i++) {
mieqEnqueue(kbd, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackKeyDown: enqueueing event KeyPress %d", keyCode);
};
}
void androidCallbackKeyUp(void *kbdPtr, int keyCode) {
int i, n;
DeviceIntPtr kbd = kbdPtr;
LogMessage(X_DEFAULT, "[native] androidCallbackKeyUp: kbd: %p keyCode: %d", kbd, keyCode);
GetEventList(&androidEvents);
//lastEventTime = GetTimeInMillis();
n = GetKeyboardEvents(androidEvents, kbd, KeyRelease, keyCode);
LogMessage(X_DEFAULT, "[native] androidCallbackKeyUp: n: %d", n);
for (i = 0; i < n; i++) {
mieqEnqueue(kbd, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackKeyUp: enqueueing event KeyRelease %d", keyCode);
};
}
void androidCallbackTouchDown(void *mousePtr, int x, int y) {
int i, n;
int v[3] = {x, y, 1};
DeviceIntPtr mouse = mousePtr;
LogMessage(X_DEFAULT, "[native] androidCallbackTouchDown: mouse: %p x: %d y: %d", mouse, x, y);
GetEventList(&androidEvents);
n = GetPointerEvents(androidEvents, mouse, MotionNotify | ButtonPress, 1, POINTER_ABSOLUTE, 0, 2, v);
LogMessage(X_DEFAULT, "[native] andriodCallbackTouchDown mouse->enabled: %d", mouse->enabled);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchDown: n: %d", n);
for (i = 0; i < n; i++) {
mieqEnqueue(mouse, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchDown: enqueueing event MotionNotify %d %d %d", x, y, 1);
};
n = GetPointerEvents(androidEvents, mouse, ButtonPress, 1, POINTER_ABSOLUTE, 0, 2, v);
for (i = 0; i < n; i++) {
mieqEnqueue(mouse, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchDown: enqueueing event ButtonPress buttons: %d", 1);
};
}
void androidCallbackTouchUp(void *mousePtr, int x, int y) {
int i, n;
int v[3] = {x, y, 0};
DeviceIntPtr mouse = mousePtr;
LogMessage(X_DEFAULT, "[native] androidCallbackTouchUp: mouse: %p x: %d y: %d", mouse, x, y);
GetEventList(&androidEvents);
n = GetPointerEvents(androidEvents, mouse, MotionNotify | ButtonRelease, 1, POINTER_ABSOLUTE, 0, 2, v);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchUp mouse->enable: %d", mouse->enabled);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchUp: n: %d", n);
for (i = 0; i < n; i++) {
mieqEnqueue(mouse, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchUp: enqueueing event MotionNotify %d %d %d", x, y, 0);
};
n = GetPointerEvents(androidEvents, mouse, ButtonRelease, 1, POINTER_ABSOLUTE, 0, 2, v);
for (i = 0; i < n; i++) {
mieqEnqueue(mouse, (InternalEvent*)(androidEvents + i)->event);
LogMessage(X_DEFAULT, "[native] androidCallbackTouchDown: enqueueing event ButtonPress buttons: %d", 1);
};
}
#include <X11/X.h>
#include <X11/Xproto.h>
#include "os.h"
#include "servermd.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "mibstore.h" // mi backing store implementation
#include "mipointer.h" // mi software cursor
#include "micmap.h" // mi colormap code
#include "fb.h" // fb framebuffer code
#include "site.h"
#include "globals.h"
#include "dix.h"
#include "xkbsrv.h"
#include "shadow.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h"
//include "xserver-properties.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/syslimits.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include "android.h"
#include "screen.h"
#include "private.h"
void *
androidWindowLinear (ScreenPtr pScreen,
CARD32 row,
CARD32 offset,
int mode,
CARD32 *size,
void *closure)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
// if (!pScreenPriv->enabled)
// return 0;
*size = priv->bytes_per_line;
return priv->base + row * priv->bytes_per_line;
}
#if 0
Bool
androidMapFramebuffer (KdScreenInfo *screen)
{
AndroidScreenPriv *scrpriv = screen->driver;
KdPointerMatrix m;
AndroidPriv *priv = screen->card->driver;
#if 1
if (scrpriv->randr != RR_Rotate_0)
scrpriv->shadow = TRUE;
else
scrpriv->shadow = FALSE;
#else
scrpriv->shadow = TRUE;
#endif
LogMessage(X_DEFAULT, "[native] androidMapFramebuffer: shadow: %d", (int)scrpriv->shadow);
KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdSetPointerMatrix (&m);
priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
free(priv->base);
priv->base = malloc (priv->bytes_per_line * screen->height);
if (scrpriv->shadow)
{
if (!KdShadowFbAlloc (screen, scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
return FALSE;
}
else
{
screen->fb.byteStride = priv->bytes_per_line;
screen->fb.pixelStride = (priv->bytes_per_line * 8/
screen->fb.bitsPerPixel);
screen->fb.frameBuffer = (CARD8 *) (priv->base);
}
/* initFramebuffer here for now */
// androidInitNativeFramebuffer(screen, screen->width, screen->height, screen->fb.depth);
LogMessage(X_DEFAULT, "[android] androidMapFramebuffer: initFramebuffer base: %p buf: %p width: %d height: %d depth: %d", priv->base, priv->buf, screen->width, screen->height, screen->fb.depth);
androidInitNativeFramebuffer(priv->base, &(priv->buf), screen->width, screen->height, screen->fb.depth);
return TRUE;
}
void
androidSetScreenSizes (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
AndroidScreenPriv *scrpriv = screen->driver;
if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
{
pScreen->width = screen->width;
pScreen->height = screen->height;
pScreen->mmWidth = screen->width_mm;
pScreen->mmHeight = screen->height_mm;
}
else
{
pScreen->width = screen->width;
pScreen->height = screen->height;
pScreen->mmWidth = screen->height_mm;
pScreen->mmHeight = screen->width_mm;
}
}
Bool
androidUnmapFramebuffer (KdScreenInfo *screen)
{
AndroidPriv *priv = screen->card->driver;
KdShadowFbFree (screen);
if (priv->base)
{
free (priv->base);
priv->base = 0;
}
return TRUE;
}
#endif
Bool
androidSetShadow (ScreenPtr pScreen)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
ShadowUpdateProc update;
ShadowWindowProc window;
window = androidWindowLinear;
update = 0;
if (priv->randr)
update = shadowUpdateRotatePacked;
else
update = shadowUpdatePacked;
// return KdShadowSet (pScreen, scrpriv->randr, update, window);
if(!shadowAdd(pScreen, pScreen->devPrivate, update, window, 0, 0)) {
LogMessage(X_ERROR, "[screen] AndroidCreateScreenResources: shadowAdd failed");
}
}
#if defined(RANDR) && 0
Bool
androidRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
RRScreenSizePtr pSize;
Rotation randr;
int n;
*rotations = RR_Rotate_All|RR_Reflect_All;
for (n = 0; n < pScreen->numDepths; n++)
if (pScreen->allowedDepths[n].numVids)
break;
if (n == pScreen->numDepths)
return FALSE;
pSize = RRRegisterSize (pScreen,
screen->width,
screen->height,
screen->width_mm,
screen->height_mm);
randr = KdSubRotation (scrpriv->randr, screen->randr);
RRSetCurrentConfig (pScreen, randr, 0, pSize);
return TRUE;
}
Bool
androidRandRSetConfig (ScreenPtr pScreen,
Rotation randr,
int rate,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
AndroidScreenPriv *scrpriv = screen->driver;
Bool wasEnabled = pScreenPriv->enabled;
AndroidScreenPriv oldscr;
int oldwidth;
int oldheight;
int oldmmwidth;
int oldmmheight;
int newwidth, newheight;
if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
{
newwidth = pSize->width;
newheight = pSize->height;
}
else
{
newwidth = pSize->height;
newheight = pSize->width;
}
if (wasEnabled)
KdDisableScreen (pScreen);
oldscr = *scrpriv;
oldwidth = screen->width;
oldheight = screen->height;
oldmmwidth = pScreen->mmWidth;
oldmmheight = pScreen->mmHeight;
/*
* Set new configuration
*/
scrpriv->randr = KdAddRotation (screen->randr, randr);
androidUnmapFramebuffer (screen);
if (!androidMapFramebuffer (screen))
goto bail4;
KdShadowUnset (screen->pScreen);
if (!androidSetShadow (screen->pScreen))
goto bail4;
androidSetScreenSizes (screen->pScreen);
/*
* Set frame buffer mapping
*/
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
pScreen->width,
pScreen->height,
screen->fb.depth,
screen->fb.bitsPerPixel,
screen->fb.byteStride,
screen->fb.frameBuffer);
/* set the subpixel order */
KdSetSubpixelOrder (pScreen, scrpriv->randr);
if (wasEnabled)
KdEnableScreen (pScreen);
return TRUE;
bail4:
androidUnmapFramebuffer (screen);
*scrpriv = oldscr;
(void) androidMapFramebuffer (screen);
pScreen->width = oldwidth;
pScreen->height = oldheight;
pScreen->mmWidth = oldmmwidth;
pScreen->mmHeight = oldmmheight;
if (wasEnabled)
KdEnableScreen (pScreen);
return FALSE;
}
Bool
androidRandRInit (ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
if (!RRScreenInit (pScreen))
return FALSE;
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = androidRandRGetInfo;
pScrPriv->rrSetConfig = androidRandRSetConfig;
return TRUE;
}
#endif
#if 0
Bool
androidCreateColormap (ColormapPtr pmap)
{
return fbInitializeColormap (pmap);
}
Bool
androidInitScreen (ScreenPtr pScreen)
{
pScreen->CreateColormap = androidCreateColormap;
return TRUE;
}
Bool
androidFinishInitScreen (ScreenPtr pScreen)
{
if (!shadowSetup (pScreen))
return FALSE;
#ifdef RANDR
if (!androidRandRInit (pScreen))
return FALSE;
#endif
return TRUE;
}
Bool
androidCreateResources (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
AndroidScreenPriv *scrpriv = screen->driver;
if (scrpriv->shadow)
return KdShadowSet (pScreen,
scrpriv->randr,
androidShadowUpdate,
androidWindowLinear
);
else
return androidSetInternalDamage(pScreen);
//return androidSetShadow (pScreen);
}
#endif
#if 0
void
androidGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
{
while (n--)
{
pdefs->red = 0;
pdefs->green = 0;
pdefs->blue = 0;
pdefs++;
}
}
void
androidPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
{
}
#endif
/* track damage and update the process */
/* based on Xephyr */
void
androidShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
// Android_LOG("slow paint");
/* FIXME: Slow Rotated/Reflected updates could be much
* much faster efficiently updating via tranforming
* pBuf->pDamage regions
*/
// shadowUpdateRotatePacked(pScreen, pBuf);
//hostx_paint_rect(screen, 0,0,0,0, screen->width, screen->height);
//androidDraw(screen,0, 0, /*?*/ screen->width, screen->height);
androidDraw(0, 0, /*?*/ pScreen->width, pScreen->height);
}
static void
androidInternalDamageRedisplay (ScreenPtr pScreen)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
RegionPtr pRegion;
if (!priv || !priv->pDamage)
return;
pRegion = DamageRegion (priv->pDamage);
if (RegionNotEmpty(pRegion))
{
int nbox;
BoxPtr pbox;
nbox = RegionNumRects (pRegion);
pbox = RegionRects (pRegion);
while (nbox--)
{
/*
hostx_paint_rect(screen,
pbox->x1, pbox->y1,
pbox->x1, pbox->y1,
pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1);
*/
androidDraw(pbox->x1, pbox->y1,
/* ? */
pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1);
pbox++;
}
DamageEmpty (priv->pDamage);
}
}
static void
androidInternalDamageBlockHandler (pointer data,
OSTimePtr pTimeout,
pointer pRead)
{
ScreenPtr pScreen = (ScreenPtr) data;
androidInternalDamageRedisplay (pScreen);
}
static void
androidInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
{
/* FIXME: Not needed ? */
}
Bool
androidSetInternalDamage (ScreenPtr pScreen)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
PixmapPtr pPixmap = NULL;
priv->pDamage = DamageCreate ((DamageReportFunc) 0,
(DamageDestroyFunc) 0,
DamageReportNone,
TRUE,
pScreen,
pScreen);
if (!RegisterBlockAndWakeupHandlers (androidInternalDamageBlockHandler,
androidInternalDamageWakeupHandler,
(pointer) pScreen))
return FALSE;
pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
DamageRegister (&pPixmap->drawable, priv->pDamage);
return TRUE;
}
void
androidUnsetInternalDamage (ScreenPtr pScreen)
{
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
PixmapPtr pPixmap = NULL;
pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
DamageUnregister (&pPixmap->drawable, priv->pDamage);
DamageDestroy (priv->pDamage);
RemoveBlockAndWakeupHandlers (androidInternalDamageBlockHandler,
androidInternalDamageWakeupHandler,
(pointer) pScreen);
}
/*
Copyright 1993, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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 OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include "mi.h"
#include <X11/Xproto.h>
#include "scrnintstr.h"
#include "inputstr.h"
#include <X11/Xos.h>
#include "mibstore.h"
#include "mipointer.h"
#include "xkbsrv.h"
#include <X11/keysym.h>
#include "xserver-properties.h"
#include "exevents.h"
#include "extinit.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
#include "exevents.h"
#include "extinit.h"
#include "exglobals.h"
#include "eventstr.h"
#include "xserver-properties.h"
#include "android.h"
Bool
LegalModifier(unsigned int key, DeviceIntPtr pDev)
{
return TRUE;
}
void ProcessInputEvents(void) {
char nullbyte;
int x = sizeof(nullbyte);
// TA_SERVER();
LogMessage(X_INFO, "[events] before mieqProcessInputEvents();");
mieqProcessInputEvents();
LogMessage(X_INFO, "[events] after mieqProcessInputEvents();");
/*
// Empty the signaling pipe
while (x == sizeof(nullbyte)) {
x = read(Android->wakeupFD[0], &nullbyte, sizeof(nullbyte));
LogMessage(X_INFO, "[events] read %d bytes (nullbyte %c)", x, nullbyte);
}
*/
x = read(Android->wakeupFD[0], &nullbyte, 1);
LogMessage(X_INFO, "[events] read %d bytes (nullbyte %c)", x, nullbyte);
}
void DDXRingBell(int volume, int pitch, int duration)
{
}
#define VFB_MIN_KEY 8
#define VFB_MAX_KEY 255
static int
androidKeybdProc(DeviceIntPtr pDevice, int onoff)
{
DevicePtr pDev = (DevicePtr)pDevice;
switch (onoff)
{
case DEVICE_INIT:
InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL);
break;
case DEVICE_ON:
pDev->on = TRUE;
LogMessage(X_DEFAULT, "[events] initNativeKeyboard: pDevice: %p", pDevice);
androidInitNativeKeyboard(pDevice);
break;
case DEVICE_OFF:
pDev->on = FALSE;
break;
case DEVICE_CLOSE:
break;
}
return Success;
}
static int
androidMouseProc(DeviceIntPtr pDevice, int onoff)
{
#define NBUTTONS 3
#define NAXES 2
BYTE map[NBUTTONS + 1];
DevicePtr pDev = (DevicePtr)pDevice;
Atom btn_labels[NBUTTONS] = {0};
Atom axes_labels[NAXES] = {0};
switch (onoff)
{
case DEVICE_INIT:
map[1] = 1;
map[2] = 2;
map[3] = 3;
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels,
(PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), NAXES, axes_labels);
break;
case DEVICE_ON:
pDev->on = TRUE;
LogMessage(X_DEFAULT, "[events] initNativeMouse: pDevice: %p", pDevice);
androidInitNativeMouse(pDev);
break;
case DEVICE_OFF:
pDev->on = FALSE;
break;
case DEVICE_CLOSE:
break;
}
return Success;
#undef NBUTTONS
#undef NAXES
}
void
InitInput(int argc, char *argv[])
{
DeviceIntPtr p, k;
Atom xiclass;
LogMessage(X_DEFAULT, "[events] in InitInput");
LogMessage(X_DEFAULT, "[events] InitInput: adding mouse proc %p (serverClient: %p)", androidMouseProc, serverClient);
p = AddInputDevice(serverClient, androidMouseProc, TRUE);
LogMessage(X_DEFAULT, "[events] InitInput: adding keybd proc %p (serverClient: %p)", androidKeybdProc, serverClient);
k = AddInputDevice(serverClient, androidKeybdProc, TRUE);
LogMessage(X_DEFAULT, "[events] InitInput: registering pointer %p", p);
RegisterPointerDevice(p);
xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
AssignTypeAndName(p, xiclass, "Android mouse");
LogMessage(X_DEFAULT, "[events] InitInput: registering keyboard %p", p);
RegisterKeyboardDevice(k);
xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
AssignTypeAndName(k, xiclass, "Android keyboard");
LogMessage(X_DEFAULT, "[events] InitInput: AddEnabledDevice wakeupFD[0]", Android->wakeupFD[0]);
AddEnabledDevice(Android->wakeupFD[0]);
(void)mieqInit();
}
void
CloseInput (void)
{
}
int
ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
xDeviceCtl *control)
{
switch (control->control) {
case DEVICE_RESOLUTION:
/* FIXME do something more intelligent here */
return BadMatch;
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
return Success;
case DEVICE_CORE:
return BadMatch;
case DEVICE_ENABLE:
return Success;
default:
return BadMatch;
}
/* NOTREACHED */
return BadImplementation;
}
void
OpenInputDevice(DeviceIntPtr pDev, ClientPtr client, int *status)
{
if (!pDev)
*status = BadDevice;
else
*status = Success;
}
void
CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
{
return;
}
/* We initialise all input devices at startup. */
void
AddOtherInputDevices(void)
{
return;
}
void
DeleteInputDeviceRequest(DeviceIntPtr dev)
{
return;
}
/* At the moment, absolute/relative is up to the client. */
int
SetDeviceMode(register ClientPtr client, DeviceIntPtr pDev, int mode)
{
return BadMatch;
}
int
SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
int *valuators, int first_valuator, int num_valuators)
{
return BadMatch;
}
/*
Copyright 2010 Timothy Meade
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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 "../android.h"
void androidInitNative(JavaVM *jvm) {
JNIEnv *jni_env;
jclass AndroiXService_class;
jfieldID blitview_id;
jclass AndroiXBlitView_class;
jobject blitview;
Android->jvm = jvm;
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
AndroiXService_class = (*jni_env)->FindClass(jni_env, "net/homeip/ofn/androix/AndroiXService");
LOG("[native] init: local AndroiXService_class: %p", AndroiXService_class);
blitview_id = (*jni_env)->GetStaticFieldID(jni_env, AndroiXService_class, "blitView", "Lnet/homeip/ofn/androix/AndroiXBlitView;");
blitview = (*jni_env)->GetStaticObjectField(jni_env, AndroiXService_class, blitview_id);
LOG("[native] init: local blitview: %p", blitview);
AndroiXBlitView_class = (*jni_env)->GetObjectClass(jni_env, blitview);
LOG("[native] init: local AndroiXBlitView_class: %p", AndroiXBlitView_class);
/* setup global references and cache methodIDs */
Android->AndroiXService_class = (*jni_env)->NewGlobalRef(jni_env, AndroiXService_class);
Android->AndroiXBlitView_class = (*jni_env)->NewGlobalRef(jni_env, AndroiXBlitView_class);
Android->blitview = (*jni_env)->NewGlobalRef(jni_env, blitview);
Android->initNativeScreen = (*jni_env)->GetMethodID(jni_env, Android->AndroiXBlitView_class, "initNativeScreen", "(I)I");
Android->initNativeKeyboard = (*jni_env)->GetMethodID(jni_env, Android->AndroiXBlitView_class, "initNativeKeyboard", "(I)I");
Android->initNativeMouse = (*jni_env)->GetMethodID(jni_env, Android->AndroiXBlitView_class, "initNativeMouse", "(I)I");
Android->initFramebuffer = (*jni_env)->GetMethodID(jni_env, Android->AndroiXBlitView_class, "initFramebuffer", "(IIILjava/nio/ByteBuffer;)I");
Android->draw = (*jni_env)->GetMethodID(jni_env, Android->AndroiXBlitView_class, "draw", "(IIII)V");
(*jni_env)->DeleteLocalRef(jni_env, AndroiXService_class);
(*jni_env)->DeleteLocalRef(jni_env, AndroiXBlitView_class);
(*jni_env)->DeleteLocalRef(jni_env, blitview);
};
void androidInitNativeScreen(void *screen) {
JNIEnv *jni_env;
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
(*jni_env)->CallIntMethod(jni_env, Android->blitview, Android->initNativeScreen, screen);
};
int androidInitNativeKeyboard(void *keyboard) {
JNIEnv *jni_env;
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
LOG("[native] androidInitNativeKeyboard: keyboard: %p", keyboard);
return (*jni_env)->CallIntMethod(jni_env, Android->blitview, Android->initNativeKeyboard, keyboard);
};
int androidInitNativeMouse(void *mouse) {
JNIEnv *jni_env;
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
LOG("[native] androidInitNativeMouse: mouse: %p", mouse);
return (*jni_env)->CallIntMethod(jni_env, Android->blitview, Android->initNativeMouse, mouse);
};
int androidInitNativeFramebuffer(void *base, void **bufPtr, int width, int height, int depth) {
JNIEnv *jni_env;
jobject *buf = (jobject *)bufPtr;
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
int bpp = depth/8;
LOG("[native] androidInitNativeFramebuffer: base: %p buf: %p width: %d height: %d bpp: %d", base, buf, width, height, bpp);
buf = (*jni_env)->NewDirectByteBuffer(jni_env, base, (width*height*bpp));
jint res = (*jni_env)->CallIntMethod(jni_env, Android->blitview, Android->initFramebuffer, width, height, depth, buf);
return res;
};
void androidDraw(int x, int y, int w, int h) {
JNIEnv *jni_env;
jmethodID initNativeMouse;
LOG("[native] androidDraw: %d,%d %d x %d", x, y, w, h);
(*(Android->jvm))->AttachCurrentThread(Android->jvm, &jni_env, NULL);
(*jni_env)->CallVoidMethod(jni_env, Android->blitview, Android->draw, x, y, w, h);
};
#include <X11/X.h>
#include <X11/Xproto.h>
#include "os.h"
#include "servermd.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "mibstore.h" // mi backing store implementation
#include "mipointer.h" // mi software cursor
#include "micmap.h" // mi colormap code
#include "fb.h" // fb framebuffer code
#include "site.h"
#include "globals.h"
#include "dix.h"
#include "xkbsrv.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h"
//include "xserver-properties.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/syslimits.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include "android.h"
#include "screen.h"
#include "private.h"
DevPrivateKeyRec androidScreenKeyRec;
static Bool AndroidSaveScreen(ScreenPtr screen, int on) {
/* tell Android to shutoff the display (based on dpms settings?) */
return TRUE;
}
Bool DPMSSupported() { return TRUE; }
int DPMSSet(ClientPtr client, int level) {
/* tell Android to shutoff the display */
return TRUE;
}
static Bool AndroidCreateScreenResources(ScreenPtr pScreen) {
Bool res;
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
res = priv->wrappedCreateScreenResources(pScreen);
LogMessage(X_INFO, "[startup] AndroidCreateScreenResources: before androidSetInternalDamage: pScreen->devPrivate: %p", pScreen->devPrivate);
//androidSetShadow(pScreen);
androidSetInternalDamage(pScreen);
LogMessage(X_INFO, "[startup] AndroidCreateScreenResources: after androidSetInternalDamage: pScreen->devPrivate: %p", pScreen->devPrivate);
//return res;
return TRUE;
}
Bool AndroidScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) {
AndroidScreenPriv *priv;
LogMessage(X_INFO, "[startup] AndroidScreenInit called: index: %d pScreen: %p", index, pScreen);
if(!dixRegisterPrivateKey(androidScreenKey, PRIVATE_SCREEN, 0)) {
LogMessage(X_ERROR, "[startup] AndroidScreenInit: failed to register screen key");
};
LogMessage(X_INFO, "[startup] AndroidScreenInit: registered key: %p", androidScreenKey);
priv = (AndroidScreenPriv *)malloc(sizeof(AndroidScreenPriv));
LogMessage(X_INFO, "[startup] AndroidScreenInit: setting private: key: %p priv: %p", androidScreenKey, priv);
dixSetPrivate(&(pScreen->devPrivates), androidScreenKey, priv);
LogMessage(X_INFO, "[startup] AndroidScreenInit: private set: %p (devPrivates: %p)", androidScreenKey, pScreen->devPrivates );
pScreen->width = 800;
pScreen->height = 480;
priv->visuals = ((1 << TrueColor) | (1 << DirectColor));
#define Mask(o,l) (((1 << l) - 1) << o)
priv->dpi = 100; /* set from Android */
priv->depth = 16;
priv->bitsPerPixel = 16;
priv->redMask = Mask (11, 5);
priv->greenMask = Mask (5, 6);
priv->blueMask = Mask (0, 5);
//priv->bytes_per_line = ((pScreen->width * priv->bitsPerPixel + 31) >> 5) << 2;
priv->bytes_per_line = 1600;
priv->base = NULL;
free(priv->base);
priv->base = malloc (priv->bytes_per_line * pScreen->height);
LogMessage(X_INFO, "[startup] alloc framebuffer (%dx%d): %p", priv->bytes_per_line, pScreen->height, priv->base);
priv->byteStride = priv->bytes_per_line;
priv->pixelStride = (priv->bytes_per_line * 8/priv->bitsPerPixel);
LogMessage(X_INFO, "[startup] AddScreen: priv->base: %p", priv->base);
pScreen->SaveScreen = AndroidSaveScreen;
pScreen->CreateScreenResources = AndroidCreateScreenResources;
LogMessage(X_INFO, "[startup] AndroidScreenInit: pScreen->CreateScreenResources: %p", pScreen->CreateScreenResources);
miClearVisualTypes();
pScreen->x = 0;
pScreen->y = 0;
AndroidFinishScreenInit(index, pScreen, argc, argv);
LogMessage(X_INFO, "[startup] initNativeScreen: pScreen: %p", pScreen);
androidInitNativeScreen(pScreen);
LogMessage(X_INFO, "[startup] initNativeFramebuffer: base: %p buf: %p width: %d height: %d depth: %d", priv->base, &(priv->buf), pScreen->width, pScreen->height, priv->depth);
androidInitNativeFramebuffer(priv->base, &(priv->buf), pScreen->width, pScreen->height, priv->depth);
return TRUE;
}
Bool AndroidFinishScreenInit (int index, ScreenPtr pScreen, int argc, char **argv) {
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
char *pbits = NULL;
/* allocate */
if (!AndroidInitVisuals(pScreen)) {
LogMessage(X_ERROR, "[screen] AndroidFinishScreenInitFB: AndroidInitVisuals failed");
return FALSE;
}
LogMessage(X_INFO, "[startup] AndroidScreenInit: fbSetupScreen: pScreen: %p base: %p width: %d height: %d dpi: %d stride?: %d bpp: %d", pScreen, priv->base, pScreen->width, pScreen->height, priv->dpi, priv->pitch/(priv->bitsPerPixel/8), priv->bitsPerPixel);
if (! fbSetupScreen(pScreen,
priv->base, // pointer to screen bitmap
pScreen->width, pScreen->height, // screen size in pixels
priv->dpi, priv->dpi, // dots per inch
/* priv->pitch/(priv->bitsPerPixel/8), // pixel width of framebuffer */
pScreen->width,
priv->bitsPerPixel)) // bits per pixel for screen
{
LogMessage(X_ERROR, "[startup] AndroidScreenInit: fbScreenInit failed");
return FALSE;
}
pbits = priv->base;
miSetPixmapDepths();
pScreen->SaveScreen = AndroidSaveScreen;
if (!fbFinishScreenInit(pScreen,
priv->base, // pointer to screen bitmap
pScreen->width, pScreen->height, // screen size in pixels
priv->dpi, priv->dpi, // dots per inch
/* priv->pitch/(priv->bitsPerPixel/8), // pixel width of framebuffer */
pScreen->width,
priv->bitsPerPixel)) // bits per pixel for screen
{
LogMessage(X_ERROR, "[startup] AndroidScreenInit: fbFinishScreenInit failed");
return FALSE;
}
// pScreen->BlockHandler = androidBlockHandler;
// pScreen->WakeupHandler = androidWakeupHandler;
// pScreen->blockData = pScreen;
// pScreen->wakeupData = pScreen;
if (! fbPictureInit(pScreen, 0, 0)) {
LogMessage(X_ERROR, "[screen] AndroidFinishScreenInitFB: fbPictureInit failed");
return FALSE;
}
/* randr */
/* is this used?? */
miInitializeBackingStore (pScreen);
miDCInitialize(pScreen, &androidPointerCursorFuncs);
fbCreateDefColormap(pScreen);
if (!shadowSetup(pScreen))
{
ErrorF ("[screen] AndroidFinishScreenInit: shadowSetup failed\n");
return FALSE;
}
priv->wrappedCreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = AndroidCreateScreenResources;
return TRUE;
}
/* from kdrive/epyhr */
/* BlockHandler/WakeHandler */
static Bool AndroidInitVisuals (ScreenPtr pScreen) {
AndroidScreenPriv *priv = dixLookupPrivate(&(pScreen->devPrivates), androidScreenKey);
if (!miSetVisualTypesAndMasks (priv->depth,
/* TrueColorMask, */
priv->visuals,
8,
-1,
priv->redMask,
priv->greenMask,
priv->blueMask))
{
LogMessage(X_ERROR, "[screen] AndroidInitVisuals: miSetVisualTypesAndMasks failed");
return FALSE;
}
return TRUE;
}
static Bool androidCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
return FALSE;
}
static void androidCrossScreen(ScreenPtr pScreen, Bool entering)
{
}
static miPointerScreenFuncRec androidPointerCursorFuncs =
{
androidCursorOffScreen,
androidCrossScreen,
miPointerWarpCursor
};
#include <X11/X.h>
#include <X11/Xproto.h>
#include "os.h"
#include "servermd.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "mibstore.h" // mi backing store implementation
#include "mipointer.h" // mi software cursor
#include "micmap.h" // mi colormap code
#include "fb.h" // fb framebuffer code
#include "site.h"
#include "globals.h"
#include "dix.h"
#include "xkbsrv.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h"
//include "xserver-properties.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/syslimits.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include "android.h"
#include "screen.h"
#include "private.h"
//static DevScreenPrivateKeyRec androidScreenKeyRec;
//define androidScreenKey (&androidScreenKeyRec)
// Common pixmap formats
static PixmapFormatRec formats[] = {
{ 1, 1, BITMAP_SCANLINE_PAD },
{ 4, 8, BITMAP_SCANLINE_PAD },
{ 8, 8, BITMAP_SCANLINE_PAD },
{ 15, 16, BITMAP_SCANLINE_PAD },
{ 16, 16, BITMAP_SCANLINE_PAD },
{ 24, 32, BITMAP_SCANLINE_PAD },
{ 32, 32, BITMAP_SCANLINE_PAD }
};
const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
void AbortDDX(void) { exit(-1); }
void OsVendorInit(void) {}
void OsVendorFatalError(void) {}
void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv ) {
int i;
int numFormats = 0;
LogMessage(X_INFO, "[startup] InitOutput called");
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
for(i = 0; i < NUMFORMATS; i++) {
pScreenInfo->formats[i].depth = formats[i].depth;
pScreenInfo->formats[i].bitsPerPixel = formats[i].bitsPerPixel;
pScreenInfo->formats[i].scanlinePad = BITMAP_SCANLINE_PAD;
numFormats++;
}
pScreenInfo->numPixmapFormats = numFormats;
AddScreen(AndroidScreenInit, argc, argv);
}
int ddxProcessArgument(int argc, char *argv[], int i) { return 0; }
void ddxUseMsg(void) {
/* we're started from jni, not the command line */
}
void ddxGiveUp(void) {
LogMessage(X_ERROR, "[startup] AndroiX DIX Exiting");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment